Sweep¶
full name: tenpy.algorithms.mps_sweeps.Sweep
parent module:
tenpy.algorithms.mps_sweeps
type: class
Inheritance Diagram
Methods
|
Initialize self. |
|
Perform N_sweeps sweeps without optimization to update the environment. |
Define the schedule of the sweep. |
|
|
(Re-)initialize the environment. |
Create new instance of self.EffectiveH at self.i0 and set it to self.eff_H. |
|
Set self.mixer to the class specified by options[‘mixer’]. |
|
Cleanup the effects of a mixer. |
|
|
Algorithm-specific actions to be taken after local update. |
Prepare everything algorithm-specific to perform a local update. |
|
Reset the statistics. |
|
|
One ‘sweep’ of a sweeper algorithm. |
|
Perform algorithm-specific local update. |
Class Attributes and Properties
|
-
class
tenpy.algorithms.mps_sweeps.
Sweep
(psi, model, options)[source]¶ Bases:
object
Prototype class for a ‘sweeping’ algorithm.
This is a superclass, intended to cover common procedures in all algorithms that ‘sweep’. This includes DMRG, TDVP, TEBD, etc. Only DMRG is currently implemented in this way.
- Parameters
Options
-
config
Sweep
¶ option summary chi_list in DMRGEngine.init_env
A dictionary to gradually increase the `chi_max` parameter of `trunc_params [...]
Whether to combine legs into pipes. This combines the virtual and [...]
init_env_data in DMRGEngine.init_env
Dictionary as returned by ``self.env.get_initialization_data()`` from [...]
Lanczos parameters as described in [...]
orthogonal_to in DMRGEngine.init_env
List of other matrix product states to orthogonalize against. [...]
start_env in DMRGEngine.init_env
Number of sweeps to be performed without optimization to update [...]
sweep_0 in Sweep.reset_stats
Number of sweeps that have already been performed.
Truncation parameters as described in [...]
Level of verbosity (i.e. how much status information to print); higher=more [...]
-
option
combine
: bool¶ Whether to combine legs into pipes. This combines the virtual and physical leg for the left site (when moving right) or right side (when moving left) into pipes. This reduces the overhead of calculating charge combinations in the contractions, but one
matvec()
is formally more expensive, \(O(2 d^3 \chi^3 D)\).
-
option
trunc_params
: dict¶ Truncation parameters as described in
truncate()
-
option
verbose
: bool | int¶ Level of verbosity (i.e. how much status information to print); higher=more output.
-
option
-
env
¶ Environment for contraction
<psi|H|psi>
.- Type
-
i0
¶ Only set during sweep. Left-most of the EffectiveH.length sites to be updated in
update_local()
.- Type
-
mixer
¶ If
None
, no mixer is used (anymore), otherwise the mixer instance.- Type
Mixer
|None
-
move_right
¶ Only set during sweep. Whether the next i0 of the sweep will be right or left of the current one.
- Type
-
ortho_to_envs
¶ List of environments
<psi|psi_ortho>
, where psi_ortho is an MPS to orthogonalize against.- Type
list of
MPSEnvironment
-
shelve
¶ If a simulation runs out of time (time.time() - start_time > max_seconds), the run will terminate with shelve = True.
- Type
-
update_LP_RP
¶ Only set during a sweep. 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 (inside
env
).
-
init_env
(model=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. IfNone
, keep the model used before.
Options
Deprecated since version 0.6.0: Options LP, LP_age, RP and RP_age are now collected in a dictionary init_env_data with different keys init_LP, init_RP, age_LP, age_RP
-
option
Sweep
.
chi_list
: dict |None
¶ A dictionary to gradually increase the chi_max parameter of trunc_params. The key defines starting from which sweep chi_max is set to the value, e.g.
{0: 50, 20: 100}
useschi_max=50
for the first 20 sweeps andchi_max=100
afterwards. Overwritestrunc_params['chi_list']
. By default (None
) this feature is disabled.
-
option
Sweep
.
init_env_data
: dict¶ Dictionary as returned by
self.env.get_initialization_data()
fromget_initialization_data()
.
-
option
Sweep
.
orthogonal_to
: list ofMPSEnvironment
¶ List of other matrix product states to orthogonalize against. Works only for finite systems. This parameter 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.
-
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.
-
reset_stats
()[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.
-
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
-
sweep
(optimize=True, meas_E_trunc=False)[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
- Returns
max_trunc_err (float) – Maximal truncation error introduced.
max_E_trunc (
None
| float) –None
if meas_E_trunc is False, else the maximal change of the energy due to the truncation.
-
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 theself.EffectiveH.length
sites to be updated inupdate_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
-
mixer_cleanup
()[source]¶ Cleanup the effects of a mixer.
A
sweep()
with an enabledMixer
leaves the MPS psi with 2D arrays in S. To recover the originial form, this function simply performs one sweep with disabled mixer.
-
mixer_activate
()[source]¶ Set self.mixer to the class specified by options[‘mixer’].
It is expected that different algorithms have differen ways of implementing mixers (with different defaults). Thus, this is algorithm-specific.