kwant.continuum.lambdify

kwant.continuum.lambdify(expr, locals=None)[source]

Return a callable object for computing a continuum Hamiltonian.

Warning

This function uses eval (because it calls sympy.sympify), and thus should not be used on unsanitized input.

If necessary, the given expression is sympified using kwant.continuum.sympify. It is then converted into a callable object.

Parameters
exprstr or SymPy expression

Expression to be converted into a callable object

localsdict or None (default)

Additional definitions for sympify.

Examples

>>> f = lambdify('a + b', locals={'b': 'b + c'})
>>> f(1, 3, 5)
9
>>> ns = {'sigma_plus': [[0, 2], [0, 0]]}
>>> f = lambdify('k_x**2 * sigma_plus', ns)
>>> f(0.25)
array([[ 0.   ,  0.125],
       [ 0.   ,  0.   ]])

Previous topic

kwant.continuum.sympify

Next topic

4.5. kwant.wraparound – Wrapping around translational symmetries

This Page