-
Notifications
You must be signed in to change notification settings - Fork 122
/
time_evolution.py
55 lines (43 loc) · 1.75 KB
/
time_evolution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Simulations for (real) time evolution."""
# Copyright 2020-2021 TeNPy Developers, GNU GPLv3
import numpy as np
from . import simulation
from .simulation import *
__all__ = simulation.__all__ + ['RealTimeEvolution']
class RealTimeEvolution(Simulation):
"""Perform a real-time evolution on a tensor network state.
Parameters
----------
options : dict-like
The simulation parameters. Ideally, these options should be enough to fully specify all
parameters of a simulation to ensure reproducibility.
Options
-------
.. cfg:config :: TimeEvolution
:include: Simulation
final_time : float
Mandatory. Perform time evolution until ``engine.evolved_time`` reaches this value.
Note that we can go (slightly) beyond this time if it is not a multiple of
the individual time steps.
"""
default_algorithm = 'TEBDEngine'
default_measurements = Simulation.default_measurements + [
('tenpy.simulations.measurement', 'evolved_time'),
]
def __init__(self, options):
super().__init__(options)
self.final_time = self.options['final_time'] - 1.e-10 # subtract eps: roundoff errors
def run_algorithm(self):
"""Run the algorithm. Calls ``self.engine.run()`` and :meth:`make_measurements`."""
# TODO: more fine-grained/custom break criteria?
while True:
if np.real(self.engine.evolved_time) >= self.final_time:
break
self.engine.run()
# TODO: call engine checkpoint?
self.make_measurements()
def final_measurements(self):
"""Do nothing.
We already performed a set of measurements after the evolution in :meth:`run_algorithm`.
"""
pass