A tight binding system defined on a graph.
This is one of the central types in Kwant. It is used to construct tight binding systems in a flexible way.
The nodes of the graph are
Site instances. The edges, i.e. the hoppings,
are pairs (2-tuples) of sites. Each node and each edge has a value
associated with it. The values associated with nodes are interpreted as
on-site Hamiltonians, the ones associated with edges as hopping integrals.
To make the graph accessible in a way that is natural within the Python language it is exposed as a mapping (much like a built-in Python dictionary). Keys are sites or hoppings. Values are 2d arrays (e.g. NumPy or Tinyarray) or numbers (interpreted as 1 by 1 matrices).
Values can be also functions that receive the site or the hopping (passed to the function as two sites) and possibly additional arguments and are expected to return a valid value. This allows to define systems quickly, to modify them without reconstructing, and to save memory for many-orbital models.
In addition to simple keys (single sites and hoppings) more powerful keys
are possible as well that allow to manipulate multiple sites/hoppings in a
single operation. Such keys are internally expanded into a sequence of
simple keys by using the method
Builder.expand. For example,
sys[general_key] = value is equivalent to
for simple_key in sys.expand(general_key): sys[simple_key] = value
Builder instances automatically ensure that every hopping is Hermitian, so
builder[a, b] has been set, there is no need to set
Builder instances can be made to automatically respect a
Symmetry that is
passed to them during creation. The behavior of builders with a symmetry
is slightly more sophisticated. First of all, it is implicitly assumed
throughout Kwant that every function assigned as a value to a builder
with a symmetry possesses the same symmetry. Secondly, all keys are mapped
to the fundamental domain of the symmetry before storing them. This may
produce confusing results when neighbors of a site are queried.
attach_lead works only if the sites affected by them have
tags which are sequences of integers. It makes sense only when these
sites live on a regular lattice, like the ones provided by
builder0 += builder1 adds all the sites, hoppings, and leads of
builder0. Sites and hoppings present in both systems
are overwritten by those in
builder1. The leads of
appended to the leads of the system being extended.
If functions are used to set values in a builder with a symmetry, then they must satisfy the same symmetry. There is (currently) no check and wrong results will be the consequence of a misbehaving function.
Define a site.
>>> builder[site] = value
Print the value of a site.
>>> print builder[site]
Define a hopping.
>>> builder[site1, site2] = value
Delete a site.
>>> del builder[site3]
Detach the last lead. (This does not remove the sites that were added to
the scattering region by
>>> del builder.leads[-1]
attach_lead(lead_builder, origin=None, add_cells=0)¶
Attach a lead to the builder, possibly adding missing sites.
Returns the lead number (integer) of the attached lead.
add_cells : int
added_sites : list of
This method is not fool-proof, i.e. if it returns an error, there is no guarantee that the system stayed unaltered.
The lead numbering starts from zero and increments from there, i.e. the leads are numbered in the order in which they are attached.
Return an iterator over all dangling sites.
Return the number of neighbors of a site.
Keep deleting dangling sites until none are left.
Expand a general key into an iterator over simple keys.
key : builder key (see notes)
This method is internally used to expand the keys when getting or
deleting items of a builder (i.e.
sys[key] = value or
Return a finalized (=usable with solvers) copy of the system.
This method does not modify the Builder instance for which it is called.
Attached leads are also finalized and will be present in the finalized system to be returned.
Currently, only Builder instances without or with a 1D translational
Symmetry can be finalized.
Return an iterator over all (hopping, value) pairs.
Return an iterator over all Builder hoppings.
The hoppings that are returned belong to the fundamental domain of the
Builder symmetry, and are not necessarily the ones that were set
initially (but always the equivalent ones).
Return an iterator over all neighbors of a site.
Return a shallow copy of the builder with the symmetry reversed.
This method can be used to attach the same infinite system as lead from two opposite sides. It requires a builder to which an infinite symmetry is associated.
Return an iterator over all (site, value) pairs.