This page was generated from toycode_example_calls.ipynb (download).

Example functions inside toycodes

This notebook just gives further illustrations some of the toycodes can be called.

c_tebd.py

[1]:
from tenpy_toycodes import c_tebd
[2]:
c_tebd.example_TEBD_gs_tf_ising_finite(L=10, g=1.)
finite TEBD, imaginary time evolution, transverse field Ising
L=10, g=1.00
dt = 0.10000: E = -12.3446865032241
dt = 0.01000: E = -12.3780979960037
dt = 0.00100: E = -12.3811510623369
dt = 0.00010: E = -12.3814538480965
dt = 0.00001: E = -12.3814841409341
final bond dimensions:  [2, 4, 8, 14, 19, 14, 8, 4, 2]
magnetization in X = 7.32205
magnetization in Z = 0.00000
Exact diagonalization: E = -12.3814899996547
relative error:  4.731838146828168e-07
[2]:
(-12.38148414093407,
 <tenpy_toycodes.a_mps.SimpleMPS at 0x7fc645119cc0>,
 <tenpy_toycodes.b_model.TFIModel at 0x7fc64511a440>)
[3]:
E, psi, model = c_tebd.example_TEBD_gs_tf_ising_infinite(g=1.5)
infinite TEBD, imaginary time evolution, transverse field Ising
g=1.50
dt = 0.10000: E (per site) = -1.6622376659950
dt = 0.01000: E (per site) = -1.6709751043234
dt = 0.00100: E (per site) = -1.6718311225992
dt = 0.00010: E (per site) = -1.6719164301789
dt = 0.00001: E (per site) = -1.6719249672500
final bond dimensions:  [21, 21]
<sigma_x> = 0.87733
<sigma_z> = -0.00000
correlation length: 2.410718886443566
Analytic result: E (per site) = -1.6719262215362
relative error:  7.502042877632601e-07

d_dmrg.py

[4]:
from tenpy_toycodes import d_dmrg
[5]:
E, psi, model = d_dmrg.example_DMRG_tf_ising_finite(L=10, g=1.)
finite DMRG, transverse field Ising
L=10, g=1.00
sweep  1: E = -12.3720222354851
sweep  2: E = -12.3814900173904
sweep  3: E = -12.3814899996548
sweep  4: E = -12.3814899996548
sweep  5: E = -12.3814899996548
sweep  6: E = -12.3814899996548
sweep  7: E = -12.3814899996548
sweep  8: E = -12.3814899996548
sweep  9: E = -12.3814899996548
sweep 10: E = -12.3814899996548
final bond dimensions:  [2, 4, 8, 14, 19, 14, 8, 4, 2]
magnetization in X = 7.32255
magnetization in Z = -0.00000
Exact diagonalization: E = -12.3814899996548
relative error:  4.3040623691892867e-16
[6]:
E, psi, model = d_dmrg.example_DMRG_tf_ising_infinite(g=1.5)
infinite DMRG, transverse field Ising
g=1.50
sweep  1: E (per site) = -1.6772694701518
sweep  2: E (per site) = -1.6723228806395
sweep  3: E (per site) = -1.6719671140527
sweep  4: E (per site) = -1.6719314036249
sweep  5: E (per site) = -1.6719269556168
sweep  6: E (per site) = -1.6719263323442
sweep  7: E (per site) = -1.6719262389782
sweep  8: E (per site) = -1.6719262243659
sweep  9: E (per site) = -1.6719262220060
sweep 10: E (per site) = -1.6719262216156
sweep 11: E (per site) = -1.6719262215498
sweep 12: E (per site) = -1.6719262215386
sweep 13: E (per site) = -1.6719262215366
sweep 14: E (per site) = -1.6719262215363
sweep 15: E (per site) = -1.6719262215362
sweep 16: E (per site) = -1.6719262215362
sweep 17: E (per site) = -1.6719262215362
sweep 18: E (per site) = -1.6719262215362
sweep 19: E (per site) = -1.6719262215362
sweep 20: E (per site) = -1.6719262215362
final bond dimensions:  [30, 30]
<sigma_x> = 0.87733
<sigma_z> = 0.00000
correlation length: 2.4243849345542476
Analytic result: E (per site) = -1.6719262215362
relative error:  6.640382872906104e-16

e_tdvp.py

[7]:
from tenpy_toycodes import e_tdvp
[8]:
e_tdvp.example_TDVP_tf_ising_lightcone(L=20, g=1.5, tmax=3., dt=0.05, one_site=True)
finite TEBD, real time evolution, transverse field Ising
L=20, g=1.50, tmax=3.00, dt=0.050
finite DMRG, transverse field Ising
L=20, g=1.50
sweep  1: E = -33.2584260524715
sweep  2: E = -33.2545167807381
sweep  3: E = -33.2545167536354
sweep  4: E = -33.2545167536354
sweep  5: E = -33.2545167536354
sweep  6: E = -33.2545167536354
sweep  7: E = -33.2545167536354
sweep  8: E = -33.2545167536354
sweep  9: E = -33.2545167536354
sweep 10: E = -33.2545167536354
final bond dimensions:  [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
magnetization in X = 17.69863
magnetization in Z = -0.00000
E after applying Sz = -30.6225268617764
t = 0.00, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
/home/johannes/postdoc/tenpy_other/tenpy_toycodes/tenpy_toycodes/e_tdvp.py:242: UserWarning: Trace of LinearOperator not available, it will be estimated. Provide `traceA` to ensure performance.
  return expm_multiply((-1.j*dt) * H, psi0)
t = 0.20, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 0.40, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 0.60, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 0.80, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 1.00, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 1.20, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 1.40, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 1.60, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 1.80, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 2.00, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 2.20, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 2.40, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 2.60, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
t = 2.80, chi = [2, 4, 8, 13, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 13, 8, 4, 2]
final E = -30.6225239843235
../_images/toycodes_toycode_example_calls_11_3.png
[ ]:

[ ]: