VariationalApplyMPO

Inheritance Diagram

Inheritance diagram of tenpy.algorithms.mps_common.VariationalApplyMPO

Methods

VariationalApplyMPO.__init__(psi, U_MPO, ...)

VariationalApplyMPO.environment_sweeps(N_sweeps)

Perform N_sweeps sweeps without optimization to update the environment.

VariationalApplyMPO.free_no_longer_needed_envs()

Remove no longer needed environments after an update.

VariationalApplyMPO.get_resume_data([...])

Return necessary data to resume a run() interrupted at a checkpoint.

VariationalApplyMPO.get_sweep_schedule()

Define the schedule of the sweep.

VariationalApplyMPO.init_env(U_MPO[, ...])

Initialize the environment.

VariationalApplyMPO.make_eff_H()

Create new instance of self.EffectiveH at self.i0 and set it to self.eff_H.

VariationalApplyMPO.post_update_local(err, ...)

Algorithm-specific actions to be taken after local update.

VariationalApplyMPO.prepare_update()

Prepare self for calling update_local().

VariationalApplyMPO.reset_stats([resume_data])

Reset the statistics.

VariationalApplyMPO.resume_run()

Resume a run that was interrupted.

VariationalApplyMPO.run()

Run the compression.

VariationalApplyMPO.sweep([optimize])

One 'sweep' of a sweeper algorithm.

VariationalApplyMPO.update_env(**update_data)

Update the left and right environments after an update of the state.

VariationalApplyMPO.update_local(_[, optimize])

Perform local update.

VariationalApplyMPO.update_new_psi(theta)

Given a new two-site wave function theta, split it and save it in psi.

Class Attributes and Properties

VariationalApplyMPO.engine_params

VariationalApplyMPO.n_optimize

The number of sites to be optimized at once.

VariationalApplyMPO.verbose

class tenpy.algorithms.mps_common.VariationalApplyMPO(psi, U_MPO, options, **kwargs)[source]

Bases: tenpy.algorithms.mps_common.VariationalCompression

Variational compression for applying an MPO to an MPS (in place).

To apply an MPO U_MPO to an MPS psi, use VariationalApplyMPO(psi, U_MPO, options).run().

The goal is to find a new MPS phi (with N tensors) which is optimally close to U_MPO|psi>, i.e. it is normalized and maximizes | <phi|U_MPO|psi> |^2. The network for this (with M tensors for psi) is given by

.——-M[0]—-M[1]—-M[2]—- … —-.
| | | | |
LP[0]—W[0]—-W[1]—-W[2]—- … — RP[-1]
| | | | |
.——-N[0]*—N[1]*—N[2]*— … —-.

Here LP and RP are the environments with partial contractions, see also MPOEnvironment. This algorithms sweeps through the sites, updating 2 N tensors in each update_local(), say on sites i0 and i1 = i0 +1. We need to maximize:

|     .-------M[i0]---M[i1]---.
|     |       |       |       |
|     LP[i0]--W[i0]---W[i1]---RP[i1]
|     |       |       |       |
|     .-------N[i0]*--N[i1]*--.

The optimal solution is given by:

|                                     .-------M[i0]---M[i1]---.
|   ---N[i0]---N[i1]---               |       |       |       |
|      |       |          = SVD of    LP[i0]--W[i0]---W[i1]---RP[i1]
|                                     |       |       |       |
|                                     .-----                --.
Parameters
  • psi (MPS) – The state to which

  • U_MPO (MPO) – MPO to be applied to the state.

  • options (dict) – See VariationalCompression.

  • **kwargs – Further keyword arguments as described in the Sweep class.

Options

config VariationalApplyMPO
option summary

chi_list (from Sweep) in Sweep.reset_stats

By default (``None``) this feature is disabled. [...]

combine (from Sweep) in Sweep

Whether to combine legs into pipes. This combines the virtual and [...]

init_env_data (from Sweep) in DMRGEngine.init_env

Dictionary as returned by ``self.env.get_initialization_data()`` from [...]

lanczos_params (from Sweep) in Sweep

Lanczos parameters as described in :cfg:config:`Lanczos`.

N_sweeps (from VariationalCompression) in VariationalCompression

Number of sweeps to perform.

orthogonal_to (from Sweep) in DMRGEngine.init_env

Deprecated in favor of the `orthogonal_to` function argument (forwarded fro [...]

start_env (from Sweep) in DMRGEngine.init_env

Number of sweeps to be performed without optimization to update the environment.

start_env_sites (from VariationalCompression) in VariationalCompression

Number of sites to contract for the inital LP/RP environment in case of inf [...]

trunc_params (from VariationalCompression) in VariationalCompression

Truncation parameters as described in :cfg:config:`truncation`.

renormalize

Used to keep track of renormalization in the last sweep for psi.norm.

Type

list

EffectiveH[source]

alias of tenpy.algorithms.mps_common.TwoSiteH

init_env(U_MPO, resume_data=None, orthogonal_to=None)[source]

Initialize the environment.

Parameters
  • U_MPO (MPO) – The MPO to be applied to the sate.

  • resume_data (dict) – May contain init_env_data.

  • orthogonal_to – Ignored.

update_local(_, optimize=True)[source]

Perform local update.

This simply contracts the environments and theta from the ket to get an updated theta for the bra self.psi (to be changed in place).

environment_sweeps(N_sweeps)[source]

Perform N_sweeps sweeps without optimization to update the environment.

Parameters

N_sweeps (int) – Number of sweeps to run without optimization

free_no_longer_needed_envs()[source]

Remove no longer needed environments after an update.

This allows to minimize the number of environments to be kept. For large MPO bond dimensions, these environments are by far the biggest part in memory, so this is a valuable optimiztion to reduce memory requirements.

get_resume_data(sequential_simulations=False)[source]

Return necessary data to resume a run() interrupted at a checkpoint.

At a checkpoint, you can save psi, model and options along with the data returned by this function. When the simulation aborts, you can resume it using this saved data with:

eng = AlgorithmClass(psi, model, options, resume_data=resume_data)
eng.resume_run()

An algorithm which doesn’t support this should override resume_run to raise an Error.

Parameters

sequential_simulations (bool) – If True, return only the data for re-initializing a sequential simulation run, where we “adiabatically” follow the evolution of a ground state (for variational algorithms), or do series of quenches (for time evolution algorithms); see run_seq_simulations().

Returns

resume_data – Dictionary with necessary data (apart from copies of psi, model, options) that allows to continue the simulation from where we are now. It might contain an explicit copy of psi.

Return type

dict

get_sweep_schedule()[source]

Define the schedule of the sweep.

One ‘sweep’ is a full sequence from the leftmost site to the right and back.

Returns

schedule – Schedule for the sweep. Each entry is (i0, move_right, (update_LP, update_RP)), where i0 is the leftmost of the self.EffectiveH.length sites to be updated in update_local(), move_right indicates whether the next i0 in the schedule is rigth (True) of the current one, and update_LP, update_RP indicate whether it is necessary to update the LP and RP of the environments.

Return type

iterable of (int, bool, (bool, bool))

make_eff_H()[source]

Create new instance of self.EffectiveH at self.i0 and set it to self.eff_H.

property n_optimize

The number of sites to be optimized at once.

Indirectly set by the class attribute EffectiveH and it’s length. For example, TwoSiteDMRGEngine uses the TwoSiteH and hence has n_optimize=2, while the SingleSiteDMRGEngine has n_optimize=1.

post_update_local(err, **update_data)[source]

Algorithm-specific actions to be taken after local update.

An example would be to collect statistics.

prepare_update()[source]

Prepare self for calling update_local().

Returns

theta – Current best guess for the ground state, which is to be optimized. Labels are 'vL', 'p0', 'p1', 'vR', or combined versions of it (if self.combine). For single-site DMRG, the 'p1' label is missing.

Return type

Array

reset_stats(resume_data=None)[source]

Reset the statistics. Useful if you want to start a new Sweep run.

This method is expected to be overwritten by subclass, and should then define self.update_stats and self.sweep_stats dicts consistent with the statistics generated by the algorithm particular to that subclass.

Parameters

resume_data (dict) – Given when resuming a simulation, as returned by get_resume_data(). Here, we read out the sweeps.

Options

option Sweep.chi_list: None | dict(int -> int)

By default (None) this feature is disabled. A dict allows to gradually increase the chi_max. An entry at_sweep: chi states that starting from sweep at_sweep, the value chi is to be used for trunc_params['chi_max']. For example chi_list={0: 50, 20: 100} uses chi_max=50 for the first 20 sweeps and chi_max=100 afterwards.

resume_run()[source]

Resume a run that was interrupted.

In case we saved an intermediate result at a checkpoint, this function allows to resume the run() of the algorithm (after re-initialization with the resume_data). Since most algorithms just have a while loop with break conditions, the default behaviour implemented here is to just call run().

run()[source]

Run the compression.

The state psi is compressed in place.

Warning

Call this function directly after initializing the class, without modifying psi inbetween. A copy of psi is made during init_env()!

Returns

max_trunc_err – The maximal truncation error of a two-site wave function.

Return type

TruncationError

sweep(optimize=True)[source]

One ‘sweep’ of a sweeper algorithm.

Iteratate over the bond which is optimized, to the right and then back to the left to the starting point. If optimize=False, don’t actually diagonalize the effective hamiltonian, but only update the environment.

Parameters

optimize (bool, optional) – Whether we actually optimize to find the ground state of the effective Hamiltonian. (If False, just update the environments).

Returns

max_trunc_err – Maximal truncation error introduced.

Return type

float

update_env(**update_data)[source]

Update the left and right environments after an update of the state.

Parameters

**update_data – Whatever is returned by update_local().

update_new_psi(theta)[source]

Given a new two-site wave function theta, split it and save it in psi.