SingleSiteTDVPEngine

Inheritance Diagram

Inheritance diagram of tenpy.algorithms.tdvp.SingleSiteTDVPEngine

Methods

SingleSiteTDVPEngine.__init__(psi, model, ...)

SingleSiteTDVPEngine.environment_sweeps(N_sweeps)

Perform N_sweeps sweeps without optimization to update the environment.

SingleSiteTDVPEngine.estimate_RAM([...])

Gives an approximate prediction for the required memory usage.

SingleSiteTDVPEngine.evolve(N_steps, dt)

Evolve by N_steps * dt.

SingleSiteTDVPEngine.evolve_step(dt)

SingleSiteTDVPEngine.free_no_longer_needed_envs()

Remove no longer needed environments after an update.

SingleSiteTDVPEngine.get_resume_data([...])

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

SingleSiteTDVPEngine.get_sweep_schedule()

slightly different sweep schedule than DMRG

SingleSiteTDVPEngine.init_env([model, ...])

(Re-)initialize the environment.

SingleSiteTDVPEngine.left_moving_update(i0, ...)

SingleSiteTDVPEngine.make_eff_H()

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

SingleSiteTDVPEngine.mixer_activate()

Set self.mixer to the class specified by options['mixer'].

SingleSiteTDVPEngine.mixer_cleanup()

Cleanup the effects of a mixer.

SingleSiteTDVPEngine.mixer_deactivate()

Deactivate the mixer.

SingleSiteTDVPEngine.post_update_local(...)

Algorithm-specific actions to be taken after local update.

SingleSiteTDVPEngine.prepare_evolve(dt)

Do nothing.

SingleSiteTDVPEngine.prepare_update_local()

Prepare self for calling update_local().

SingleSiteTDVPEngine.reset_stats([resume_data])

Reset the statistics.

SingleSiteTDVPEngine.resume_run()

Resume a run that was interrupted.

SingleSiteTDVPEngine.right_moving_update(i0, ...)

SingleSiteTDVPEngine.run()

Perform a (real-)time evolution of psi by N_steps * dt.

SingleSiteTDVPEngine.run_evolution(N_steps, dt)

Perform a (real-)time evolution of psi by N_steps * dt.

SingleSiteTDVPEngine.sweep([optimize])

One 'sweep' of a sweeper algorithm.

SingleSiteTDVPEngine.switch_engine(...[, ...])

Initialize algorithm from another algorithm instance of a different class.

SingleSiteTDVPEngine.update_env(**update_data)

Do nothing; super().update_env() is called explicitly in update_local().

SingleSiteTDVPEngine.update_local(theta, ...)

Perform algorithm-specific local update.

SingleSiteTDVPEngine.zero_site_update(i, ...)

Zero-site update on the left of site i.

Class Attributes and Properties

SingleSiteTDVPEngine.DefaultMixer

SingleSiteTDVPEngine.S_inv_cutoff

SingleSiteTDVPEngine.lanczos_options

Deprecated alias of lanczos_params.

SingleSiteTDVPEngine.n_optimize

The number of sites to be optimized at once.

SingleSiteTDVPEngine.time_dependent_H

whether the algorithm supports time-dependent H

SingleSiteTDVPEngine.use_mixer_by_default

class tenpy.algorithms.tdvp.SingleSiteTDVPEngine(psi, model, options, **kwargs)[source]

Bases: TDVPEngine

Engine for the single-site TDVP algorithm.

Parameters:

Options

config SingleSiteTDVPEngine
option summary

chi_list (from Sweep) in IterativeSweeps.reset_stats

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

chi_list_reactivates_mixer (from Sweep) in IterativeSweeps.sweep

If True, the mixer is reset/reactivated each time the bond dimension growth [...]

combine (from Sweep) in Sweep

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

dt (from TimeEvolutionAlgorithm) in TimeEvolutionAlgorithm

Minimal time step by which to evolve.

lanczos_params (from Sweep) in Sweep

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

max_dt (from TDVPEngine) in TDVPEngine

Threshold for raising errors on too large time steps. Default ``1.0``. [...]

max_N_sites_per_ring (from Algorithm) in Algorithm

Threshold for raising errors on too many sites per ring. Default ``18``. [...]

max_trunc_err (from TimeEvolutionAlgorithm) in TimeDependentHAlgorithm.evolve

Threshold for raising errors on too large truncation errors. Default ``0.01 [...]

mixer (from Sweep) in DMRGEngine.mixer_activate

Specifies which :class:`Mixer` to use, if any. [...]

mixer_params (from Sweep) in DMRGEngine.mixer_activate

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

N_steps (from TimeEvolutionAlgorithm) in TimeEvolutionAlgorithm

Number of time steps `dt` to evolve by in :meth:`run`. [...]

preserve_norm (from TimeEvolutionAlgorithm) in TimeEvolutionAlgorithm

Whether the state will be normalized to its initial norm after each time st [...]

start_env (from Sweep) in DMRGEngine.init_env

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

start_time (from TimeEvolutionAlgorithm) in TimeEvolutionAlgorithm

Initial value for :attr:`evolved_time`.

start_trunc_err (from TimeEvolutionAlgorithm) in TimeEvolutionAlgorithm

Initial truncation error for :attr:`trunc_err`.

trunc_params (from Algorithm) in Algorithm

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

EffectiveH[source]

alias of OneSiteH

get_sweep_schedule()[source]

slightly different sweep schedule than DMRG

update_local(theta, **kwargs)[source]

Perform algorithm-specific local update.

For two-site algorithms with n_optimize = 2, this always optimizes the sites i0 and i0 + 1. For single-site algorithms, the effective H only acts on site i0, but afterwards it also updates the bond to the right if move_right is True, or the bond to the left if move_right is False. Since the svd for truncation gives tensors to be multiplied into the tensors on both sides of the bond, tensors of two sites are updated even for single-site algorithms: when right-moving, site i0 + 1 is also updated; site i0 - 1 when left-moving.

Parameters:

theta (Array) – Local single- or two-site wave function, as returned by prepare_update_local().

Returns:

update_data – Data to be processed by update_env() and post_update_local(), e.g. containing the truncation error as err. If combine is set, it should also contain the U and VH from the SVD.

Return type:

dict

update_env(**update_data)[source]

Do nothing; super().update_env() is called explicitly in update_local().

zero_site_update(i, theta, dt)[source]

Zero-site update on the left of site i.

post_update_local(**update_data)[source]

Algorithm-specific actions to be taken after local update.

An example would be to collect statistics.

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

estimate_RAM(mem_saving_factor=None)[source]

Gives an approximate prediction for the required memory usage.

This calculation is based on the requested bond dimension, the local Hilbert space dimension, the number of sites, and the boundary conditions.

Parameters:

mem_saving_factor (float) – Represents the amount of RAM saved due to conservation laws. By default, it is ‘None’ and is extracted from the model automatically. However, this is only possible in a few cases and needs to be estimated in most cases. This is due to the fact that it is dependent on the model parameters. If one has a better estimate, one can pass the value directly. This value can be extracted by building the initial state psi (usually by performing DMRG) and then calling print(psi.get_B(0).sparse_stats()) TeNPy will automatically print the fraction of nonzero entries in the first line, for example, 6 of 16 entries (=0.375) nonzero. This fraction corresponds to the mem_saving_factor; in our example, it is 0.375.

Returns:

usage – Required RAM in MB.

Return type:

float

See also

tenpy.simulations.simulation.estimate_simulation_RAM

global function calling this.

evolve(N_steps, dt)[source]

Evolve by N_steps * dt.

Parameters:

N_steps (int) – The number of steps to evolve.

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 optimization 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 algorithm run from where we are now. It might contain an explicit copy of psi.

Return type:

dict

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

(Re-)initialize the environment.

This function is useful to (re-)start a Sweep with a slightly different model or different (engine) parameters. Note that we assume that we still have the same psi. Calls reset_stats().

Parameters:
  • model (MPOModel) – The model representing the Hamiltonian for which we want to find the ground state. If None, keep the model used before.

  • resume_data (None | dict) – Given when resuming a simulation, as returned by get_resume_data(). Can contain another dict under the key init_env_data; the contents of init_env_data get passed as keyword arguments to the environment initialization.

  • orthogonal_to (None | list of MPS | list of dict) – List of other matrix product states to orthogonalize against. Instead of just the state, you can specify a dict with the state as ket and further keyword arguments for initializing the MPSEnvironment; the psi to be optimized is used as bra. Works only for finite or segment MPS; for infinite MPS it must be None. This can be used to find (a few) excited states as follows. First, run DMRG to find the ground state, and then run DMRG again while orthogonalizing against the ground state, which yields the first excited state (in the same symmetry sector), and so on. Note that resume_data['orthogonal_to'] takes precedence over the argument.

Options

option Sweep.start_env: int

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

Raises:

ValueError – If the engine is re-initialized with a new model, which legs are incompatible with those of hte old model.

property lanczos_options

Deprecated alias of lanczos_params.

make_eff_H()[source]

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

mixer_activate()[source]

Set self.mixer to the class specified by options[‘mixer’].

option Sweep.mixer: str | class | bool | None

Specifies which Mixer to use, if any. A string stands for one of the mixers defined in this module. A class is assumed to have the same interface as Mixer and is used to instantiate the mixer. None uses no mixer. True uses the mixer specified by the DefaultMixer class attribute. The default depends on the subclass of Sweep.

option Sweep.mixer_params: dict

Mixer parameters as described in Mixer.

See also

mixer_deactivate

mixer_cleanup()[source]

Cleanup the effects of a mixer.

A sweep() with an enabled Mixer leaves the MPS psi with 2D arrays in S. This method recovers the original form by performing SVDs of the S and updating the MPS tensors accordingly.

mixer_deactivate()[source]

Deactivate the mixer.

Set self.mixer=None and revert any other effects of mixer_activate().

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.

prepare_evolve(dt)[source]

Do nothing.

prepare_update_local()[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. A value of None is initialized to the current value of trunc_params['chi_max'] at algorithm initialization.

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 behavior implemented here is to just call run().

run()[source]

Perform a (real-)time evolution of psi by N_steps * dt.

You probably want to call this in a loop along with measurements. The recommended way to do this is via the RealTimeEvolution.

run_evolution(N_steps, dt)[source]

Perform a (real-)time evolution of psi by N_steps * dt.

This is the inner part of run() without the logging. For parameters see TimeEvolutionAlgorithm.

sweep(optimize=True)[source]

One ‘sweep’ of a sweeper algorithm.

Iterate over the bond which is optimized, to the right and then back to the left to the starting point.

Parameters:

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

Options

option Sweep.chi_list_reactivates_mixer: bool

If True, the mixer is reset/reactivated each time the bond dimension growths due to Sweep.chi_list.

Returns:

max_trunc_err – Maximal truncation error introduced.

Return type:

float

classmethod switch_engine(other_engine, *, options=None, **kwargs)[source]

Initialize algorithm from another algorithm instance of a different class.

You can initialize one engine from another, not too different subclasses. Internally, this function calls get_resume_data() to extract data from the other_engine and then initializes the new class.

Note that it transfers the data without making copies in most case; even the options! Thus, when you call run() on one of the two algorithm instances, it will modify the state, environment, etc. in the other. We recommend to make the switch as engine = OtherSubClass.switch_engine(engine) directly replacing the reference.

Parameters:
  • cls (class) – Subclass of Algorithm to be initialized.

  • other_engine (Algorithm) – The engine from which data should be transferred. Another, but not too different algorithm subclass-class; e.g. you can switch from the TwoSiteDMRGEngine to the OneSiteDMRGEngine.

  • options (None | dict-like) – If not None, these options are used for the new initialization. If None, take the options from the other_engine.

  • **kwargs – Further keyword arguments for class initialization. If not defined, resume_data is collected with get_resume_data().

time_dependent_H = False

whether the algorithm supports time-dependent H