VariationalCompression

Inheritance Diagram

Inheritance diagram of tenpy.algorithms.mps_common.VariationalCompression

Methods

VariationalCompression.__init__(psi, options)

Initialize self.

VariationalCompression.environment_sweeps(…)

Perform N_sweeps sweeps without optimization to update the environment.

VariationalCompression.get_resume_data()

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

VariationalCompression.get_sweep_schedule()

Define the schedule of the sweep.

VariationalCompression.init_env(_[, …])

Initialize the environment.

VariationalCompression.make_eff_H()

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

VariationalCompression.post_update_local(…)

Algorithm-specific actions to be taken after local update.

VariationalCompression.prepare_update()

Prepare everything algorithm-specific to perform a local update.

VariationalCompression.reset_stats([resume_data])

Reset the statistics.

VariationalCompression.resume_run()

Resume a run that was interrupted.

VariationalCompression.run()

Run the compression.

VariationalCompression.sweep([optimize])

One ‘sweep’ of a sweeper algorithm.

VariationalCompression.update_LP(_)

VariationalCompression.update_RP(_)

VariationalCompression.update_local(_[, …])

Perform local update.

VariationalCompression.update_new_psi(theta)

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

Class Attributes and Properties

VariationalCompression.engine_params

VariationalCompression.n_optimize

the number of sites to be optimized over at once.

VariationalCompression.verbose

class tenpy.algorithms.mps_common.VariationalCompression(psi, options, resume_data=None)[source]

Bases: tenpy.algorithms.mps_common.Sweep

Variational compression of an MPS (in place).

To compress an MPS psi, use VariationalCompression(psi, options).run().

The algorithm is the same as described in VariationalApplyMPO, except that we dont have an MPO in the networks - one can think of the MPO being trivial.

Parameters
  • psi (MPS) – The state to be compressed.

  • options (dict) – See VariationalCompression.

  • resume_data (None | dict) – By default (None) ignored. If a dict, it should contain the data returned by get_resume_data() when intending to continue/resume an interrupted run, in particular ‘init_env_data’.

Options

config VariationalCompression
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

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 [...]

sweep_0 (from Sweep) in Sweep.reset_stats

Number of sweeps that have already been performed.

trunc_params

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

option trunc_params: dict

Truncation parameters as described in truncation.

option N_sweeps: int

Number of sweeps to perform.

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

run()[source]

Run the compression.

The state psi is compressed in place.

Returns

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

Return type

TruncationError

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

Initialize the environment.

The first argument and orthogonal_to are not used and only there for compatibility with the Sweep class. The second argument is the resume_data passed during initialization, as returned by get_resume_data().

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).

update_new_psi(theta)[source]

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

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

get_resume_data()[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.

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.

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. Only those LP and RP that can be used later should be updated.

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. The latter are chosen such that the environment is growing for infinite systems, but we only keep the minimal number of environment tensors in memory.

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 over 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(update_data)[source]

Algorithm-specific actions to be taken after local update.

An example would be to collect statistics.

prepare_update()[source]

Prepare everything algorithm-specific to perform a local update.

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.

option Sweep.sweep_0: int

Number of sweeps that have already been performed.

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().

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