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 callssympy.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:
expr (str or SymPy expression) – Expression to be converted into a callable object
locals (dict or
None
(default)) – Additional definitions forsympify
.
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. ]])