pyblock.algorithm¶
pyblock.algorithm.dmrg¶
DMRG algorithm.

class
pyblock.algorithm.dmrg.
DMRG
(mpo, mps, bond_dims, noise=0.0, contractor=None)¶ Bases:
object
DMRG algorithm.
 Attributes:
 n_sites : int
 Number of sites/orbitals
 dot : int
 Twodot (2) or onedot (1) scheme.
 bond_dims : list(int) or int
 Bond dimension for each sweep.
 noise : list(float) or float
 Noise prefactor for each sweep.
 energies : list(float)
 Energies collected for all sweeps.

blocking
(i, forward, bond_dim, noise)¶ Perform one blocking iteration.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 noise : float
 Noise prefactor of current sweep.
 Returns:
 energy : float
 Ground state energy.
 error : float
 Sum of discarded weights.
 ndav : int
 Number of Davidson iterations.

construct_envs
()¶

set_mps
(tags, wfn)¶

solve
(n_sweeps, tol, forward=True, two_dot_to_one_dot=1)¶ Perform DMRG algorithm.
 Args:
 n_sweeps : int
 Maximum number of sweeps.
 tol : float
 Energy convergence threshold.
 forward : bool
 Direction of first sweep. If True, sweep is performed from left to right.
 two_dot_to_one_dot : int or 1
 Indicating when to switch to onedot scheme. If 1, no switching.
 Returns:
 energy : float
 Final ground state energy.

sweep
(forward, bond_dim, noise)¶ Perform one sweep iteration.
 Args:
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dims : int
 Bond dimension of current sweep.
 noise : float
 Noise prefactor of current sweep.
 Returns:
 energy : float
 Ground state energy.

update_one_dot
(i, forward, bond_dim, noise)¶ Update local site in onedot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 noise : float
 Noise prefactor of current sweep.
 Returns:
 energy : float
 Ground state energy.
 error : float
 Sum of discarded weights.
 ndav : int
 Number of Davidson iterations.

update_two_dot
(i, forward, bond_dim, noise)¶ Update local sites in twodot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 noise : float
 Noise prefactor of current sweep.
 Returns:
 energy : float
 Ground state energy.
 error : float
 Sum of discarded weights.
 ndav : int
 Number of Davidson iterations.

exception
pyblock.algorithm.dmrg.
DMRGError
¶ Bases:
Exception

class
pyblock.algorithm.dmrg.
MovingEnvironment
(n_sites, center, dot, tn, iprint=True)¶ Bases:
object
Environment blocks in DMRG.
 Attributes:
 n_sites : int
 Number of sites/orbitals.
 dot : int
 Twodot (2) or onedot (1) scheme.
 tnc : TensorNetwork
 The tensor network <braHket> before contraction.
 pos : int
 Current site position of left dot.
 envs : dict(int > TensorNetwork)
 DMRG Environment for different positions of left dot.

init_environments
()¶ Initialize DMRG Environment blocks by contraction.

move_to
(i)¶ Change the current left dot site to
i
(by zero or one site).

prepare_sweep
(dot, pos)¶ Prepare environment for next sweep.

pyblock.algorithm.dmrg.
pprint
(*args, **kwargs)¶
pyblock.algorithm.time_evolution¶
Imaginary time evolution algorithm.

class
pyblock.algorithm.time_evolution.
ExpoApply
(mpo, mps, beta, bond_dims, contractor=None, canonical_form=None)¶ Bases:
object
Apply exp(beta H) to MPS (tangent space approach).
 Attributes:
 n_sites : int
 Number of sites/orbitals
 dot : int
 Twodot (2) or onedot (1) scheme.
 bond_dims : list(int) or int
 Bond dimension for each sweep.
 energies : list(float)
 Energies collected for all sweeps.
 canonical_form : list(str)
 The canonical form of initial MPS. If None, assumming it is LL..CC..RR (dot=2) or LL..C..RR (dot=1)

blocking
(i, forward, bond_dim, beta)¶ Perform one blocking iteration.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 beta : float
 Beta parameter in \(\exp(\beta H)\).
 Returns:
 energy : float
 Energy of state \(\exp(\beta H) \psi\rangle\).
 normsq : float
 Self inner product of state \(\exp(\beta H) \psi\rangle\).
 error : float
 Sum of discarded weights.
 nexpos : (int, int)
 Number of operator multiplication in forward and backward exponential step.

construct_envs
()¶

set_mps
(tags, wfn)¶

solve
(n_sweeps, forward=True, two_dot_to_one_dot=1, current_beta=0.0, iprint=True)¶ Perform time evolution algorithm.
 Args:
 n_sweeps : int
 Maximum number of sweeps (two sweeps will calculate one exp(beta H) application)
 forward : bool
 Direction of first sweep. If True, sweep is performed from left to right.
 two_dot_to_one_dot : int or 1
 Indicating when to switch to onedot scheme. If 1, no switching.
 Returns:
 energy : float
 Energy of state \(\exp(\beta * (n_{sweeps}/2) H) \psi\rangle\).

sweep
(forward, bond_dim, beta)¶ Perform one sweep iteration.
 Args:
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 beta : float
 Beta parameter in \(\exp(\beta H)\).
 Returns:
 energy : float
 Energy of state \(\exp(\beta H) \psi\rangle\).
 normsq : float
 Self inner product of state \(\exp(\beta H) \psi\rangle\).
 error : float
 Largest sum of discarded weights.

update_one_dot
(i, forward, bond_dim, beta)¶ Update local site in onedot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 beta : float
 Beta parameter in \(\exp(\beta H)\).
 Returns:
 energy : float
 Energy of state \(\exp(\beta H) \psi\rangle\).
 normsq : float
 Self inner product of state \(\exp(\beta H) \psi\rangle\).
 error : float
 Sum of discarded weights.
 nexpos : (int, int)
 Number of operator multiplication in forward and backward exponential step.

update_two_dot
(i, forward, bond_dim, beta)¶ Update local sites in twodot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bond dimension of current sweep.
 beta : float
 Beta parameter in \(\exp(\beta H)\).
 Returns:
 energy : float
 Energy of state \(\exp(\beta H) \psi\rangle\).
 normsq : float
 Self inner product of state \(\exp(\beta H) \psi\rangle\).
 error : float
 Sum of discarded weights.
 nexpos : (int, int)
 Number of operator multiplication in forward and backward exponential step.

exception
pyblock.algorithm.time_evolution.
TEError
¶ Bases:
Exception

pyblock.algorithm.time_evolution.
pprint
(*args, **kwargs)¶
pyblock.algorithm.expectation¶
Expectation calculation for <MPS1MPOMPS2>.

class
pyblock.algorithm.expectation.
Expect
(mpo, bra_mps, ket_mps, bra_canonical_form=None, ket_canonical_form=None, contractor=None)¶ Bases:
object
Calculation of expectation value <MPS1MPOMPS2>. The expectation value can be evaluated at current canonical form, when forward is None. Otherwise, it is recommended that bond_dim (bond dimension) of the MPS is given, and one sweep will be performed and expectation value will be evaluated at each canonical form. The sweep will thus change the canonical form of MPS and MPSInfo in contractor. Therefore, it is recommended that a copy of MPS and MPSInfo is used here.
 Attributes:
 n_sites : int
 Number of sites/orbitals
 dot : int
 Twodot (2) or onedot (1) scheme.

blocking
(i, forward, bond_dim)¶ Perform one blocking iteration.
 Args:
 i : int
 Site index of left dot
 forward : bool or None
 Direction of current sweep. If True, sweep is performed from left to right. If None, no sweep is performed (local evaluation).
 bond_dim : int
 Bond dimension of current sweep.
 Returns:
 result : float
 Expectation value.

construct_envs
()¶

get_1pdm
(normsq=1)¶ 1particle density matrix.

get_1pdm_spatial
(normsq=1)¶ Spatial 1particle density matrix.

solve
(forward=None, bond_dim=1)¶ Calculate expectation value.
 Args:
 forward : bool or None
 Direction of current sweep. If True, sweep is performed from left to right. If None, no sweep is performed (local evaluation).
 bond_dim : int
 Bond dimension of current sweep.
 Returns:
 expect : float
 Expectation value.

update_one_dot
(i, forward, bond_dim)¶ Update local sites in onedot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool or None
 Direction of current sweep. If True, sweep is performed from left to right. If None, no sweep is performed (local evaluation).
 bond_dim : int
 Bond dimension of current sweep.
 Returns:
 expect : float
 Expectation value.

update_two_dot
(i, forward, bond_dim)¶ Update local sites in twodot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool or None
 Direction of current sweep. If True, sweep is performed from left to right. If None, no sweep is performed (local evaluation).
 bond_dim : int
 Bond dimension of current sweep.
 Returns:
 expect : float
 Expectation value.

exception
pyblock.algorithm.expectation.
ExpectationError
¶ Bases:
Exception

pyblock.algorithm.expectation.
pprint
(*args, **kwargs)¶
pyblock.algorithm.compress¶
Compression algorithm.

class
pyblock.algorithm.compress.
Compress
(mpo, mps, ket_mps, bond_dims, noise, ket_bond_dim=1, bra_canonical_form=None, ket_canonical_form=None, contractor=None)¶ Bases:
object
Compression after apply MPO on MPS.
 Attributes:
 n_sites : int
 Number of sites/orbitals
 dot : int
 Twodot (2) or onedot (1) scheme.
 bond_dims : list(int) or int
 Bond dimension for each sweep.

blocking
(i, forward, bond_dim, ket_bond_dim, noise, beta)¶ Perform one blocking iteration.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bra bond dimension of current sweep.
 ket_bond_dim : int
 Ket bond dimension of current sweep.
 noise : float
 Noise prefactor of current sweep.
 beta : float
 Not used.
 Returns:
 norm : float
 Norm of compressed state.
 error : float
 Sum of discarded weights.
 nexpo : int
 Number of operator multiplication steps.

construct_envs
()¶

set_mps
(tags, wfn)¶

solve
(n_sweeps, tol, forward=True, two_dot_to_one_dot=1)¶ Perform Compression algorithm.
 Args:
 n_sweeps : int
 Maximum number of sweeps.
 tol : float
 Norm convergence threshold.
 forward : bool
 Direction of first sweep. If True, sweep is performed from left to right.
 two_dot_to_one_dot : int or 1
 Indicating when to switch to onedot scheme. If 1, no switching.
 Returns:
 nrom : float
 Final compressed stae norm.

sweep
(forward, bond_dim, ket_bond_dim, noise, beta)¶ Perform one sweep iteration.
 Args:
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bra bond dimension of current sweep.
 ket_bond_dim : int
 Ket bond dimension of current sweep.
 noise : float
 Noise prefactor of current sweep.
 beta : float
 Not used.
 Returns:
 norm : float
 Norm of compressed state.

update_one_dot
(i, forward, bond_dim, ket_bond_dim, noise, beta)¶ Update local sites in onedot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bra bond dimension of current sweep.
 ket_bond_dim : int
 Ket bond dimension of current sweep.
 beta : float
 Not used.
 Returns:
 norm : float
 Norm of compressed state.
 error : float
 Sum of discarded weights.
 nexpos : (int, int)
 Number of operator multiplication steps.

update_two_dot
(i, forward, bond_dim, ket_bond_dim, noise, beta)¶ Update local sites in twodot scheme.
 Args:
 i : int
 Site index of left dot
 forward : bool
 Direction of current sweep. If True, sweep is performed from left to right.
 bond_dim : int
 Bra bond dimension of current sweep.
 ket_bond_dim : int
 Ket bond dimension of current sweep.
 beta : float
 Not used.
 Returns:
 norm : float
 Norm of compressed state.
 error : float
 Sum of discarded weights.
 nexpos : (int, int)
 Number of operator multiplication steps.

exception
pyblock.algorithm.compress.
CompressionError
¶ Bases:
Exception

pyblock.algorithm.compress.
pprint
(*args, **kwargs)¶