# Time evolution with time-dependent Hamiltonian¶

This notebook demonstrates how one can use the TimeDependentExpMPOEvolution to simulate the evolution under a time-dependent Hamiltonian: the model just reads out the time model parameter, and we do a full re-initialization of the model during each time step. (This could be optimized to e.g. just adjusting values in the final MPO, but generating the model is usually cheap compared to the actual evolution scaling as $$\mathcal{O}(\chi^3)$$.)

Note that this method is (currently) only correct to first order in dt; to acchieve higher order you need to adjust the algorithms in TeNPy to account for the time dependence.

[1]:

import numpy as np
import scipy
import matplotlib.pyplot as plt
np.set_printoptions(precision=5, suppress=True, linewidth=120)

[2]:

import tenpy
import tenpy.linalg.np_conserved as npc
from tenpy.algorithms import tebd
from tenpy.networks.mps import MPS
from tenpy.models.spins import SpinChain
tenpy.tools.misc.setup_logging(to_stdout="DEBUG")
import yaml

[ ]:



[3]:

class MyTimeDepModel(SpinChain):
def init_terms(self, model_params):
model_params['Jz'] = 1./(model_params.get('time', 0.) + 0.01)
super().init_terms(model_params)

[4]:

params = """
model_class :  MyTimeDepModel
model_params :
L : 14
bc_MPS : finite
explicit_plus_hc : True

initial_state_params:
method : lat_product_state
product_state : [[up], [down]]

algorithm_class: TimeDependentExpMPOEvolution
algorithm_params:
trunc_params:
chi_max: 120
dt : 0.05
N_steps : 2
compression_method: variational

final_time :  1.5
"""

[5]:

res = tenpy.run_simulation('RealTimeEvolution', **sim_params)

INFO    : simulation class RealTimeEvolution
INFO    : output filename: None
INFO    : RealTimeEvolution: reading 'algorithm_params'={'trunc_params': {'chi_max': 120}, 'dt': 0.05, 'N_steps': 2, 'compression_method': 'variational'}
INFO    : RealTimeEvolution: subconfig 'model_params'=Config(<3 options>, 'model_params')
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : model_params: setting 'Jz'=100.0
INFO    : RealTimeEvolution: subconfig 'initial_state_params'=Config(<2 options>, 'initial_state_params')
INFO    : calling InitialStateBuilder.lat_product_state()
INFO    : initial_state_params: reading 'product_state'=[['up'], ['down']]
INFO    : algorithm_params: subconfig 'trunc_params'=Config(<1 options>, 'trunc_params')
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.0}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.05}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.10, max chi=5
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.1}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.15000000000000002}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.20, max chi=8
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.2}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.25}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.30, max chi=11
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.3}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.35}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.40, max chi=11
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.39999999999999997}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.44999999999999996}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.50, max chi=13
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.49999999999999994}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.5499999999999999}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.60, max chi=13
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.6}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.65}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.70, max chi=15
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.7000000000000001}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.7500000000000001}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.80, max chi=16
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.8000000000000002}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.8500000000000002}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 0.90, max chi=16
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.9000000000000002}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 0.9500000000000003}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 1.00, max chi=17
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.0000000000000002}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.0500000000000003}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 1.10, max chi=18
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.1000000000000003}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.1500000000000004}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 1.20, max chi=20
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.2000000000000004}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.2500000000000004}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 1.30, max chi=22
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.3000000000000005}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.3500000000000005}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 1.40, max chi=22
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.4000000000000006}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : Calculate U for {'dt': 0.05, 'order': 1, 'approximation': 'II', 'time': 1.4500000000000006}
INFO    : MyTimeDepModel: set conserve to Sz
INFO    : reached time 1.50, max chi=23
INFO    : finished simulation run
================================================================================

[8]:

res['measurements']['energy_MPO']

[8]:

array([-325.     +0.j,  -29.63282+0.j,  -15.568  +0.j,  -10.57126+0.j,   -8.00839+0.j,   -6.44829+0.j,   -5.39811+0.j,
-4.64262+0.j,   -4.07283+0.j,   -3.62763+0.j,   -3.2701 +0.j,   -2.97661+0.j,   -2.73133+0.j,   -2.52328+0.j,
-2.34455+0.j,   -2.18937+0.j])

[ ]:



[ ]: