kwant.operator.Current#
- class kwant.operator.Current(syst, onsite=1, where=None, check_hermiticity=True, *, sum=False)[source]#
Bases:
_LocalOperator
An operator for calculating general currents.
An instance of this class can be called like a function to evaluate the expectation value with a wavefunction. See
__call__
for details.- Parameters:
syst (
System
)onsite (scalar or square matrix or dict or callable) – The onsite matrix that defines the density from which this current is derived. If a dict is given, it maps from site families to square matrices (scalars are allowed if the site family has 1 orbital per site). If a function is given it must take the same arguments as the onsite Hamiltonian functions of the system.
where (sequence of pairs of int or
Site
, or callable, optional) – Where to evaluate the operator. Ifsyst
is not a finalized Builder, then this should be a sequence of pairs of integers. If a function is provided, it should take a pair of integers or a pair ofSite
(ifsyst
is a finalized builder) and return True or False. If not provided, the operator will be calculated over all hoppings in the system.check_hermiticity (bool) – Check whether the provided
onsite
is Hermitian. If it is not Hermitian, then an error will be raised when the operator is evaluated.sum (bool, default: False) – If True, then calling this operator will return a single scalar, otherwise a vector will be returned (see
__call__
for details).
Notes
In general, if there is a certain “density” (e.g. charge or spin) that is represented by a square matrix \(M_i\) associated with each site \(i\) and \(H_{ij}\) is the hopping Hamiltonian from site \(j\) to site i, then an instance of this class represents the tensor \(J_{ijαβ}\) which is equal to \(i\left[(H_{ij})^† M_i - M_i H_{ij}\right]\) when α and β are orbitals on sites \(i\) and \(j\) respectively, and zero otherwise.
The tensor \(J_{ijαβ}\) will also be referred to as \(Q_{nαβ}\), where \(n\) is the index of hopping \((i, j)\) in
where
.Methods
- act(self, ket, args=(), *, params=None)[source]#
Act with the operator on a wavefunction.
For an operator \(Q_{iαβ}\) and
ket
\(ψ_β\) this computes \(∑_{iβ} Q_{iαβ} ψ_β\).- Parameters:
ket (sequence of complex) – Wavefunctions defined over all the orbitals of the system.
args (tuple) – The extra arguments to the Hamiltonian value functions and the operator
onsite
function. Deprecated in favor of ‘params’ (and mutually exclusive with it).params (dict, optional) – Dictionary of parameter names and their values. Mutually exclusive with ‘args’.
- Return type:
Array of complex.
- bind(self, args=(), *, params=None)[source]#
Bind the given arguments to this operator.
Returns a copy of this operator that does not need to be passed extra arguments when subsequently called or when using the
act
method.Providing positional arguments via ‘args’ is deprecated, instead provide named parameters as a dictionary via ‘params’.
- __call__()[source]#
Return the matrix elements of the operator.
An operator
A
can be called like>>> A(psi)
to compute the expectation value \(\bra{ψ} A \ket{ψ}\), or like
>>> A(phi, psi)
to compute the matrix element \(\bra{φ} A \ket{ψ}\).
If
sum=True
was provided when constructing the operator, then a scalar is returned. Ifsum=False
, then a vector is returned. The vector is defined over the sites of the system if the operator is aDensity
, or over the hoppings if it is aCurrent
orSource
. By default, the returned vector is ordered in the same way as the sites (forDensity
) or hoppings in the graph of the system (forCurrent
orDensity
). If the keyword parameterwhere
was provided when constructing the operator, then the returned vector is instead defined only over the sites or hoppings specified, and is ordered in the same way aswhere
.Alternatively stated, for an operator \(Q_{iαβ}\),
bra
\(φ_α\) andket
\(ψ_β\) this computes \(q_i = ∑_{αβ} φ^*_α Q_{iαβ} ψ_β\) ifself.sum
is False, otherwise computes \(q = ∑_{iαβ} φ^*_α Q_{iαβ} ψ_β\). where \(i\) runs over all sites or hoppings, and \(α\) and \(β\) run over all the degrees of freedom.- Parameters:
bra (sequence of complex) – Must have the same length as the number of orbitals in the system. If only one is provided, both
bra
andket
are taken as equal.ket (sequence of complex) – Must have the same length as the number of orbitals in the system. If only one is provided, both
bra
andket
are taken as equal.args (tuple, optional) – The arguments to pass to the system. Used to evaluate the
onsite
elements and, possibly, the system Hamiltonian. Deprecated in favor of ‘params’ (and mutually exclusive with it).params (dict, optional) – Dictionary of parameter names and their values. Mutually exclusive with ‘args’.
- Returns:
float if
check_hermiticity
is True, andket
isNone
,otherwise complex. If this operator was created with
sum=True
,then a single value is returned, otherwise an array is returned.
Attributes