-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrotter-test.py
95 lines (76 loc) · 2.11 KB
/
trotter-test.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 4 19:38:54 2018
@author: brian
"""
import numpy as np
from mps import MPS
from mps import MPO_from_local_matrix
from mps import MPS_from_product_states
from trotter import ExpPauliHamiltonian
import sys
sys.path.append("/home/brian/Documents/ryd-theory-code/ryd-theory/python_code/")
#sys.path.append("/Users/btimar/Documents/ryd-theory-code/python_code/")
from ryd_base import make_1d_TFI_static, get_fss_spin_static
###check product state construction
def test_product_state():
L=10
sps = 2
D=1
psiloc = np.array([0.0, 1.0])
psi = MPS_from_product_states([psiloc]*L)
print(psi.norm())
O = np.array([[1, 0], [0, -1]])
mpo = MPO_from_local_matrix(O, 4)
psi.gauge(4)
print(mpo._expt_value_local(psi))
### check imaginary-time trotter
from trotter import get_pauli_exp, sigmax
def test_imag_onesite():
U = get_pauli_exp(-1.0j, 'X')
L=10
D=5
sps=2
psi = MPS(L, sps=sps)
psi.init_random(D)
i=2
psi.normalize(i)
from trotter import _act_1qubit_gate
nstep = 100
sigma_x = MPO_from_local_matrix(sigmax(), i)
for _ in range(nstep):
_act_1qubit_gate(U, psi, i)
psi._normalize_site(i)
print(sigma_x._expt_value_local(psi))
from trotter import TrotterLayers, sigmaz, identity
L=30
D=10
sps=2
J=1.0000
psi = MPS(L,sps,Dmax=D)
dtype=np.complex128
psi.init_random(dtype=dtype)
psi.left_normalize_full()
Omega =0.1
static = make_1d_TFI_static(J, Omega, L, bc='open')
#static =[ ['X', [[-Omega, i] for i in range(L)]]]
T=-20.0j/1.0
nlayer=50
expH = ExpPauliHamiltonian(static)
expH.set_layer(['X'])
expH.set_layer(['ZZ'])
#expH.set_layer(['X'])
tl = TrotterLayers(expH)
tl.set_evolve_time(T)
tl.set_num_layers(nlayer)
tl.run_evolution(psi, renormalize=True)
###
psi.left_normalize_full()
for i in range(L):
psi.gauge(i)
z = MPO_from_local_matrix(sigmaz(), i)
x = MPO_from_local_matrix(sigmax(), i)
I = MPO_from_local_matrix(identity(),i)
print(z._expt_value_local(psi), x._expt_value_local(psi), I._expt_value_local(psi))
#