qsymm.model module

class qsymm.model.BlochCoeff(hop, coeff)[source]

Bases: tuple

copy()[source]
tosympy(momenta, nsimplify=False)[source]
class qsymm.model.BlochModel(hamiltonian=None, locals=None, momenta=('k_x', 'k_y', 'k_z'), keep=None, shape=None, format=None)[source]

Bases: Model

conj()[source]

Complex conjugation.

rotate_momenta(R)[source]

Rotate momenta with rotation matrix R.

subs(*args, **kwargs)[source]

Substitute symbolic expressions. See Model.subs.

tomodel(nsimplify=False)[source]

Convert to Model.

tosympy(nsimplify=False)[source]

Return sympy representation of the Model. If nsimplify=True, attempt to rewrite numerical coefficients as exact formulas.

transform_symbolic(func)[source]

Transform keys by applying func to all of them. Useful for symbolic substitutions, differentiation, etc.

class qsymm.model.Model(hamiltonian=None, locals=None, momenta=('k_x', 'k_y', 'k_z'), keep=None, symbol_normalizer=None, normalize=False, shape=None, format=None)[source]

Bases: UserDict

T()[source]

Transpose

allclose(other, rtol=1e-05, atol=1e-08, equal_nan=False)[source]

Test whether two Models are approximately equal

around(decimals=3)[source]

Return Model with matrices rounded to given number of decimals.

conj()[source]

Complex conjugation

copy()[source]

Return a copy.

eliminate_zeros(rtol=1e-05, atol=1e-08)[source]

Return a model with small terms removed. Tolerances are in Frobenius matrix norm, relative tolerance compares to the value with largest norm.

evalf(subs=None)[source]

Evaluate using parameter values in subs.

lambdify(nsimplify=False, *, onsite=False, hopping=False)[source]

Return a callable object for the model, with sympy symbols as parameters.

Parameters:
  • nsimplify (bool, default False) – Whether or not to attempt to rewrite numerical coefficients as exact symbols in sympification.

  • onsite (bool, default False) – If True, adds ‘site’ as the first argument to the callable object. Helpful for passing Model objects to kwant Builder objects as onsite functions.

  • hopping (bool, default False) – If True, adds ‘site1’ and ‘site2’ as the first two arguments to the callable object. Helpful for passing Model objects to kwant Builder objects as hopping functions.

Notes

onsite and hopping are mutually exclusive. If both are set to True, an error is thrown.

reshape(*args, **kwargs)[source]

Reshape, see numpy.reshape.

rotate_momenta(R)[source]

Rotate momenta with rotation matrix R.

subs(*args, **kwargs)[source]

Substitute symbolic expressions. See documentation of sympy.Expr.subs() for details.

Allows for the replacement of momenta in the Model object. Replacing a momentum k with a sympy.Symbol object p replaces the momentum k with p in the Model. Replacing a momentum k with a number removes the momentum k from the Model momenta. Replacing a momentum k with a sympy expression that does not contain any of the Model.momenta also removes the momentum k from the momenta.

toarray()[source]

Convert to dense numpy ndarray format.

tocsr()[source]

Convert to sparse csr format.

tosympy(nsimplify=False)[source]

Return sympy representation of the Model. If nsimplify=True, attempt to rewrite numerical coefficients as exact formulas.

trace()[source]

Take trace of the matrix and return a scalar valued Model.

transform_symbolic(func)[source]

Transform keys by applying func to all of them. Useful for symbolic substitutions, differentiation, etc.

value_list(key_list)[source]

Return a list of the matrix coefficients corresponding to the keys in key_list.

zeros_like()[source]

Return an empty model object that inherits the other properties

qsymm.model.substitute_exponents(expr)[source]

Substitute trigonometricfunctions with exp.

sin(X) -> (e^(I * X) - e^(-I * X)) / (2 * I) cos(X) -> (e^(I * X) + e^(-I * X)) / 2 exp(X) -> e^X