ExactDiag

class tenpy.algorithms.exact_diag.ExactDiag(model, charge_sector=None, sparse=False, max_size=2000000.0)[source]

Bases: object

(Full) exact diagonalization of the Hamiltonian.

Parameters
modelMPOmodel | CouplingModel

The model which is to be diagonalized.

charge_sectorNone | charges

If not None, project onto the given charge sector.

sparsebool

If True, don’t sort/bunch the LegPipe used to combine the physical legs. This results in array blocks with just one entry, requires much more charge data, and is not what np_conserved was designed for, so it’s not recommended.

max_sizeint

The build_H_* functions will do nothing (but emit a warning) if the total size of the Hamiltonian would be larger than this.

Attributes
modelMPOmodel | CouplingModel

The model which is to be diagonalized.

chinfoChargeInfo

The nature of the charge (which is the same for all sites).

charge_sectorNone | charges

If not None, we project onto the given charge sector.

max_sizeint

The build_H_* functions will do nothing (but emit a warning) if the total size of the Hamiltonian would be larger than this.

full_HArray | None

The full Hamiltonian to be diagonalized with legs '(p0.p1....)', '(p0*,p1*...)' (in that order). None if the build_H_* functions haven’t been called yet, or if max_size would have been exceeded.

Endarray | None

1D array of eigenvalues.

VArray | None

Eigenvectors. First leg ‘ps’ are physical legs, the second leg 'ps*' corresponds to the eigenvalues.

_siteslist of Site

The sites in the given order.

_labels_plist or str

The labels use for the physical legs; just ['p0', 'p1', ...., 'p{L-1}'].

_labels_pconjlist or str

Just each of _labels_p with an *.

_pipeLegPipe

The pipe from the single physical legs to the full combined leg.

_pipe_conjLegPipe

Just _pipe.conj().

_mask1D bool ndarray | None

Bool mask, which of the indices of the pipe are in the desired charge_sector.

Methods

build_full_H_from_bonds(self)

Calculate self.full_H from self.mpo.

build_full_H_from_mpo(self)

Calculate self.full_H from self.mpo.

exp_H(self, dt)

Return U(dt) := exp(-i H dt).

from_H_mpo(H_MPO, \*args, \*\*kwargs)

Wrapper taking directly an MPO instead of a Model.

full_diagonalization(self, \*args, \*\*kwargs)

Full diagonalization to obtain all eigenvalues and eigenvectors.

full_to_mps(self, psi[, canonical_form])

Convert a full state (with a single leg) to an MPS.

groundstate(self[, charge_sector])

Pick the ground state energy and ground state from self.V.

matvec(self, psi)

Allow to use self as LinearOperator for lanczos.

mps_to_full(self, mps)

Contract an MPS along the virtual bonds and combine its legs.

sparse_diag(self, k, \*args, \*\*kwargs)

Call speigs().

classmethod from_H_mpo(H_MPO, *args, **kwargs)[source]

Wrapper taking directly an MPO instead of a Model.

Parameters
H_MPOMPO

The MPO representing the Hamiltonian.

*args, **kwargs :

Other arguments as for the __init__ of the class.

build_full_H_from_mpo(self)[source]

Calculate self.full_H from self.mpo.

build_full_H_from_bonds(self)[source]

Calculate self.full_H from self.mpo.

full_diagonalization(self, *args, **kwargs)[source]

Full diagonalization to obtain all eigenvalues and eigenvectors.

Arguments are given to eigh.

groundstate(self, charge_sector=None)[source]

Pick the ground state energy and ground state from self.V.

Parameters
charge_sectorNone | 1D ndarray

By default (None), consider all charge sectors. Alternatively, give the qtotal which the returned state should have.

Returns
E0float

Ground state energy (possibly in the given sector).

psi0Array

Ground state (possibly in the given sector).

exp_H(self, dt)[source]

Return U(dt) := exp(-i H dt).

mps_to_full(self, mps)[source]

Contract an MPS along the virtual bonds and combine its legs.

Parameters
mpsMPS

The MPS to be contracted.

Returns
psiArray

The MPO contracted along the virtual bonds.

full_to_mps(self, psi, canonical_form='B')[source]

Convert a full state (with a single leg) to an MPS.

Parameters
psiArray

The state (with a single leg) which should be splitted into an MPS.

canonical_fromArray

The form in which the MPS will be afterwards.

Returns
mpsMPS

An normalized MPS representation in canonical form.

matvec(self, psi)[source]

Allow to use self as LinearOperator for lanczos.

Just applies full_H to (the first axis of) the given psi.

sparse_diag(self, k, *args, **kwargs)[source]

Call speigs().