Skip to content

Commit 7083c42

Browse files
committed
update
1 parent d5da3f7 commit 7083c42

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

model.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,25 @@ class xxz_spm(object):
6262
"""
6363
def __init__(self, Jz, Jxy, dtype, device):
6464
s = spin_half(dtype, device)
65+
Jxy_sign = np.sign(Jxy)
66+
Jxy_abs = np.abs(Jxy)
6567
Jz_sign = np.sign(Jz)
6668
Jz_abs = np.abs(Jz)
6769

6870
Q = torch.zeros(2,2, dtype=dtype, device=device)
6971
L = torch.cat((
70-
s.Sp.view(1,2,2)*np.sqrt(Jxy/2),
71-
s.Sm.view(1,2,2)*np.sqrt(Jxy/2),
72+
s.Sp.view(1,2,2)*np.sqrt(Jxy_abs/2),
73+
s.Sm.view(1,2,2)*np.sqrt(Jxy_abs/2),
7274
np.sqrt(Jz_abs)*s.Z.view(1,2,2)/2
7375
), dim=0)
7476
R = torch.cat((
75-
s.Sm.view(1,2,2)*np.sqrt(Jxy/2),
76-
s.Sp.view(1,2,2)*np.sqrt(Jxy/2),
77-
-Jz_sign * np.sqrt(Jz_abs)*s.Z.view(1,2,2)/2
77+
s.Sm.view(1,2,2)*np.sqrt(Jxy_abs/2)*Jxy_sign,
78+
s.Sp.view(1,2,2)*np.sqrt(Jxy_abs/2)*Jxy_sign,
79+
np.sqrt(Jz_abs)*s.Z.view(1,2,2)/2 * (-Jz_sign)
7880
), dim=0)
7981
P = torch.zeros(3,3,2,2, dtype=dtype, device=device)
8082
self.T = cmpo(Q, L, R, P)
81-
self.W = torch.tensor([[0, 1, 0], [1, 0, 0], [0, 0, -Jz_sign]], dtype=dtype, device=device)
83+
self.W = torch.tensor([[0, Jxy_sign, 0], [Jxy_sign, 0, 0], [0, 0, -Jz_sign]], dtype=dtype, device=device)
8284
self.ph_leg = 2
8385
self.d = 3
8486

@@ -89,23 +91,25 @@ class xxz(object):
8991
"""
9092
def __init__(self, Jz, Jxy, dtype, device):
9193
s = spin_half(dtype, device)
94+
Jxy_sign = np.sign(Jxy)
95+
Jxy_abs = np.abs(Jxy)
9296
Jz_sign = np.sign(Jz)
9397
Jz_abs = np.abs(Jz)
9498

9599
Q = torch.zeros(2,2, dtype=dtype, device=device)
96100
L = torch.cat((
97-
np.sqrt(Jxy)/2 * s.X.view(1,2,2),
98-
np.sqrt(Jxy)/2 * s.iY.view(1,2,2),
101+
np.sqrt(Jxy_abs)/2 * s.X.view(1,2,2),
102+
np.sqrt(Jxy_abs)/2 * s.iY.view(1,2,2),
99103
np.sqrt(Jz_abs)/2 * s.Z.view(1,2,2)
100104
), dim=0 )
101105
R = torch.cat((
102-
np.sqrt(Jxy)/2 * s.X.view(1,2,2),
103-
-np.sqrt(Jxy)/2 * s.iY.view(1,2,2),
106+
np.sqrt(Jxy_abs)/2 * s.X.view(1,2,2)*Jxy_sign,
107+
-np.sqrt(Jxy_abs)/2 * s.iY.view(1,2,2)*Jxy_sign,
104108
-Jz_sign * np.sqrt(Jz_abs)/2 * s.Z.view(1,2,2)
105109
), dim=0 )
106110
P = torch.zeros(3,3,2,2, dtype=dtype, device=device)
107111
self.T = cmpo(Q, L, R, P)
108-
self.W = torch.diag(torch.tensor([1,-1,-Jz_sign], dtype=dtype, device=device))
112+
self.W = torch.diag(torch.tensor([Jxy_sign,-Jxy_sign,-Jz_sign], dtype=dtype, device=device))
109113
self.ph_leg = 2
110114
self.d = 3
111115

tests/test_model.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def func(Gamma, J):
5454

5555
@decorator_test_model
5656
def test_xxz_spm():
57-
Jz, Jxy = 0.78, 0.87
57+
Jz, Jxy = 0.78, -0.87
5858
def func(Jz, Jxy):
5959
# cmpo
6060
model = xxz_spm(Jz=Jz, Jxy=Jxy, dtype=torch.float64, device='cpu')
@@ -68,7 +68,7 @@ def func(Jz, Jxy):
6868

6969
@decorator_test_model
7070
def test_xxz():
71-
Jz, Jxy = 0.78, 0.87
71+
Jz, Jxy = 0.78, -0.87
7272
def func(Jz, Jxy):
7373
# cmpo
7474
model = xxz(Jz=Jz, Jxy=Jxy, dtype=torch.float64, device='cpu')
@@ -122,6 +122,3 @@ def func(Gamma, J, alpha):
122122
return model, H
123123
return func(Gamma, J, alpha)
124124

125-
#@decorator_test_model
126-
#def test_ising_powLR():
127-
# return ising_powLR(Gamma=1, J=1, alpha=2, dtype=torch.float64, device='cpu')

0 commit comments

Comments
 (0)