kwant.continuum.discretize(hamiltonian, coords=None, *, grid_spacing=1, locals=None)[source]

Construct a tight-binding model from a continuum Hamiltonian.

If necessary, the given Hamiltonian is sympified using kwant.continuum.sympify. It is then discretized symbolically and turned into a Builder instance that may be used with fill.

This is a convenience function that is equivalent to first calling discretize_symbolic and feeding its result into build_discretized.


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


hamiltonian : str or SymPy expression

Symbolic representation of a continuous Hamiltonian. It is converted to a SymPy expression using kwant.continuum.sympify.

coords : sequence of strings, or None (default)

The coordinates for which momentum operators will be treated as differential operators. May contain only “x”, “y” and “z” and must be sorted. If not provided, coords will be obtained from the input Hamiltonian by reading the present coordinates and momentum operators.

grid_spacing : int or float, default: 1

Spacing of the (quadratic or cubic) discretization grid.

locals : dict or None (default)

Additional namespace entries for sympify. May be used to simplify input of matrices or modify input before proceeding further. For example: locals={'k': 'k_x + I * k_y'} or locals={'sigma_plus': [[0, 2], [0, 0]]}.


model : Builder

The translationally symmetric builder that corresponds to the provided Hamiltonian. This builder instance belongs to a subclass of the standard builder that may be printed to obtain the source code of the value functions. It also holds the discretization lattice (a Monatomic instance with lattice constant grid_spacing) in the lattice attribute.

Previous topic

4.4. kwant.continuum – Tools for continuum systems

Next topic


This Page