-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreespins.py
More file actions
29 lines (23 loc) · 886 Bytes
/
threespins.py
File metadata and controls
29 lines (23 loc) · 886 Bytes
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
# Author: Alex Gezerlis
# Numerical Methods in Physics with Python (CUP, 2020)
from qrmet import qrmet
from kron import paulimatrices, kron
import numpy as np
def threespins(omI,omII,omIII,gam):
hbar = 1.
paulis = paulimatrices()
iden = np.identity(2)
SIs = [hbar*kron(kron(pa,iden),iden)/2 for pa in paulis]
SIIs = [hbar*kron(kron(iden,pa),iden)/2 for pa in paulis]
SIIIs = [hbar*kron(kron(iden,iden),pa)/2 for pa in paulis]
SIdotII = sum([SIs[i]@SIIs[i] for i in range(3)])
SIdotIII = sum([SIs[i]@SIIIs[i] for i in range(3)])
SIIdotIII = sum([SIIs[i]@SIIIs[i] for i in range(3)])
H = -omI*SIs[2] - omII*SIIs[2] - omIII*SIIIs[2]
H += gam*(SIdotII+SIdotIII+SIIdotIII)
H = H.real
return H
if __name__ == '__main__':
np.set_printoptions(precision=3)
H = threespins(1.,2.,3.,0.5)
qreigvals = qrmet(H); print(qreigvals)