VariationalApplyMPO¶
full name: tenpy.algorithms.mps_common.VariationalApplyMPO
parent module:
tenpy.algorithms.mps_common
type: class
Inheritance Diagram
Methods
|
Initialize self. |
|
Perform N_sweeps sweeps without optimization to update the environment. |
Return necessary data to resume a |
|
Define the schedule of the sweep. |
|
|
Initialize the environment. |
Create new instance of self.EffectiveH at self.i0 and set it to self.eff_H. |
|
Algorithm-specific actions to be taken after local update. |
|
Prepare everything algorithm-specific to perform a local update. |
|
|
Reset the statistics. |
Resume a run that was interrupted. |
|
Run the compression. |
|
|
One ‘sweep’ of a sweeper algorithm. |
|
|
|
|
|
Perform local update. |
Given a new two-site wave function theta, split it and save it in |
Class Attributes and Properties
|
|
the number of sites to be optimized over at once. |
|
|
-
class
tenpy.algorithms.mps_common.
VariationalApplyMPO
(psi, U_MPO, options, resume_data=None)[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 eachupdate_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 whichU_MPO (
MPO
) – MPO to be applied to the state.options (dict) – See
VariationalCompression
.resume_data (None | dict) – By default (
None
) ignored. If a dict, it should contain the data returned byget_resume_data()
when intending to continue/resume an interrupted run, in particular ‘init_env_data’.
Options
-
config
VariationalApplyMPO
¶ option summary By default (``None``) this feature is disabled. [...]
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
List of other matrix product states to orthogonalize against. [...]
Number of sweeps to be performed without optimization to update [...]
Number of sweeps that have already been performed.
trunc_params (from VariationalCompression) in VariationalCompression
Truncation parameters as described in :cfg:config:`truncation`.
-
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).
-
EffectiveH
[source]¶ alias of
tenpy.algorithms.mps_common.TwoSiteH
-
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 savepsi
,model
andoptions
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(resume_data)
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
-
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
-
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 theTwoSiteH
and hence hasn_optimize=2
, while theSingleSiteDMRGEngine
hasn_optimize=1
.
-
post_update_local
(update_data)[source]¶ Algorithm-specific actions to be taken after local update.
An example would be to collect statistics.
-
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
.
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 fortrunc_params['chi_max']
. For examplechi_list={0: 50, 20: 100}
useschi_max=50
for the first 20 sweeps andchi_max=100
afterwards.
-
option
-
resume_run
()[source]¶ Resume a run that was interrupted.
In case we saved an intermediate result at a
checkpoint
, this function allows to resume therun()
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 callrun()
.
-
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