def Run_2(_T, _J, _i, _j, Phase, n=None): ''' This func calculate the system with Inversion Symmetry, which means that for the upper half and the lower half, the spin terms change signs. :para `n` defines how many layers (in upper half) contains the Spin term. In default, all of the upper half have the spin term. ''' print("Start Calculation: Theta=%.3f , J=%.3f" % (_T, _J)) _S = np.zeros([N, 3]) layer = int(N/2) if n == None else min(int(n), int(N/2)) for i in range(layer): _S[i, 0], _S[N-i-1, 0] = 1, -1 _S[i, 1], _S[N-i-1, 1] = _T, _T # _S[N-i-1, 2] = np.pi S = np.array([([s[0]*np.sin(s[1])*np.cos(s[2]), s[0] * np.sin(s[1]) * np.sin(s[2]), s[0]*np.cos(s[1])])for s in _S]) # print(S) h = Hamiltonian(N=N, J=_J, S=S) res = TIC.Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TIC.TopoOrder(res) # Phase[_i][_j] = _i*10+_j # print("(", _i, ",", _j, "),", end="") if Phase[_i][_j] != 0: print("=========================================\nNon Trivial Phase!") print("=========================================") # sys.stderr.write("Theta=%.3f pi , J=%.3f, Result: C=%.4f , Z2=%s" % # (_T/np.pi, _J, res.Chern, str(res._Z2))) print("End Calculation: Theta=%.3f pi , J=%.3f, Result: C=%.4f , Z2=%s" % (_T/np.pi, _J, res.Chern, str(res._Z2))) return
def Run_0(_N, _J, _i, _j, Phase): ''' This func calculate the system with uniform spin distribution in Z-direction. ''' h = Hamiltonian(N=_N, J=_J) res = TIC.Calc(h, CalcZ2=True, LogOut=False, settings=settings) print(res.Chern) Phase[_i][_j] = TIC.TopoOrder(res) return
def Run_1(_N, _J, _i, _j, Phase): ''' This func calculate the system with uniform spin distribution in Z-direction. ''' print("Start Calc: N=%d, J=%.3f" % (int(_N), _J)) h = Hamiltonian(N=int(_N), J=_J, Delta=3.333, **CONST_HJZ) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TopoOrder(res) print("End Calc: N=%d, J=%.3f; Res=%d" % (int(_N), _J, TopoOrder(res))) return
def Run_SpinZ(_N, _J, _i, _j, Phase, Delta=3, CONST=CONST_HZL): ''' This func calculate the system with uniform spin distribution in Z-direction. Use default constants from Hai-Zhou Lu's paper. ''' print("Start Calc: N=%d, J=%.3f" % (int(_N), _J)) h = Hamiltonian(N=int(_N), J=_J, Delta=Delta, **CONST) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings_strict) Phase[_i][_j] = TopoOrder(res) print("End Calc: N=%d, J=%.3f; Res=%d" % (int(_N), _J, TopoOrder(res))) return
def CalcGap(): TEST_HJZ = { "A1": 2.26, "A2": 3.33, "C": -0.0083, "D1": 5.74, "D2": 30.4, "M": 0.28, "B1": 6.86, "B2": 44.5 } TEST_HZL = { # Interesting!!!!! "A1": 3.3, "A2": 4.1, "C": -0.0068, "D1": 1.2, "D2": -30.1, "M": 0.28, "B1": 1.5, "B2": -54.1 } N_min, N_max, Step, J = 10, 35, 5, 0.00 L = int((N_max - N_min) / Step + 1) Gap = np.zeros([ L, ], dtype=float) X = np.linspace(N_min, N_max, num=L, endpoint=True, dtype=int) x = list(range(int(N_min / Step), int(N_max / Step + 1))) for i in range(L): # By Default it is Spin-Z N = X[i] h = Hamiltonian(N=N, J=J, Delta=1.9134, **TEST_HZL) eig = np.array([x.real for x in (linalg.eig(h(0, 0))[0])]) eig.sort() Gap[i] = eig[2 * N] - eig[2 * N - 1] # print(Gap[i]) plt.subplot() plt.plot(x, Gap, label=r"$\Delta_H$") plt.scatter(x, Gap) J = np.array(read3("PT_D1.9134_HZL_SpinZ18-09-05-08-46-02.txt")) * 2 plt.plot(x, J, color="red", label=r"$2\times J_c$") plt.scatter(x, J, color="red", marker="^") plt.legend(loc='upper right') plt.xlabel(r"$Thickness (\rm QL)$") plt.ylabel(r"$Gap(\rm eV)$") plt.title(r"Critical $J$ & Hybridization Gap vs Thickness") plt.savefig("Spin_Hybrid_vsThickness_10_35_D1.9134.png") return
def PT_SpinZ(_N, _J_Max, _i, _j, Phase, _J_Min=0, _J_tol=1e-4, Delta=3.189, CONST=CONST_HZL, settings=settings): assert _J_tol > 0, "_J_tol should >0!" print("Start Calc: N=%d" % (int(_N))) L, R = _J_Min, _J_Max print("===>Calculate N=%d, J=%.3f" % (int(_N), L)) h = Hamiltonian(N=int(_N), J=L, Delta=Delta, **CONST) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings) T_L = TopoOrder(res) print("Calculate N=%d, J=%.3f" % (int(_N), R)) h = Hamiltonian(N=int(_N), J=R, Delta=Delta, **CONST) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings) T_R = TopoOrder(res) if T_L == T_R: Phase[_i][_j] = -1 print("===>End Calc: N=%d. No phase transition, Res=%d" % (int(_N), TopoOrder(res))) else: while (R-L) > _J_tol: M = (R+L)/2 print("Calculate N=%d, J=%.3f" % (int(_N), M)) h = Hamiltonian(N=int(_N), J=M, Delta=Delta, **CONST) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings) T_M = TopoOrder(res) if T_M == T_R: R = M elif T_M == T_L: L = M else: Phase[_i][_j] = R raise Exception("Middle result different with either!") Phase[_i][_j] = R print("===>End Calc: N=%d, phase transition at %.3f" % (int(_N), R)) return
def Run_HZL(_N, _J, _i, _j, Phase): ''' This func calculate the system with uniform spin distribution in Z-direction. Use the Parameters from the Hai-Zhou Lu's paper. ''' print("Start Calc: N=%d, J=%.3f" % (int(_N), _J)) h = Hamiltonian(N=int(_N), J=_J, Delta=3.333, **CONST_HZL) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TopoOrder(res) print("End Calc: N=%d, J=%.3f; Res=%d" % (int(_N), _J, TopoOrder(res))) if TopoOrder(res) != 0: stderr.write("!!!!!!!!\nN=%d, J=%.3f; Res=%d\n!!!!!!!!!!\n" % (int(_N), _J, TopoOrder(res))) return
def CalcGap(): N_min, N_max, J = 6, 30, 0.00 Gap = np.zeros([N_max + 1], dtype=float) for N in range(N_min, N_max + 1): h = Hamiltonian(N=N, J=J) # By Default it is Spin-Z eig = np.array([x.real for x in (linalg.eig(h(0, 0))[0])]) eig.sort() Gap[N] = eig[2 * N] - eig[2 * N - 1] plt.subplot() plt.plot(list(range(N_min, N_max + 1)), Gap[N_min:N_max + 1] * 1000) plt.xlabel(r"$N$") plt.ylabel(r"$Gap(\rm meV)$") plt.title("Gap vs Thickness, No Spin") plt.savefig("Gap_vs_Thickness_No_Spin.png") return
def Run_Inv(_T, _J, _i, _j, Phase, N=20, n=None, Delta=3, CONST=CONST_HZL): ''' This func calculate the system with Mirror Symmetry, which means that for the upper half and the lower half,the parallel components changes sign while the perpendicular term keep unchanged :para `n` defines how many layers (in upper half) contains the Spin term. In default, all of the upper half have the spin term. ''' print("Start Calculation: Theta=%.3f , J=%.3f" % (_T, _J)) _S = np.zeros([N, 3]) layer = int(N / 2) if n == None else min(int(n), int(N / 2)) for i in range(layer): _S[i, 0], _S[N - i - 1, 0] = 1, 1 _S[i, 1], _S[N - i - 1, 1] = _T, _T S = convertSpin(_S) h = Hamiltonian(N=N, J=_J, S=S, Delta=Delta, **CONST) res = Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TopoOrder(res) print("End Calculation: Theta=%.3f pi , J=%.3f, Result: C=%.4f , Z2=%s" % (_T / np.pi, _J, res.Chern, str(res._Z2))) return
def Run_1(_N, _J, _i, _j, Phase): ''' This func calculate the system with spin distribution: +z in the upper half and -z in the lower half. If the # of layers is odd, then the layer in the very middle will have no spin to make sure the total spin in Z direction of this system to be ZERO. ''' print("Start Calculation: N=%d , J=%.3f" % (_N, _J)) _S = np.zeros([_N, 3]) for i in range(int(_N / 2)): _S[i, 0], _S[_N - i - 1, 0] = 1, -1 S = np.array([([ s[0] * np.sin(s[1]) * np.cos(s[2]), s[0] * np.sin(s[1]) * np.sin(s[2]), s[0] * np.cos(s[1]) ]) for s in _S]) h = Hamiltonian(N=_N, J=_J, S=S) res = TIC.Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TIC.TopoOrder(res) print("End Calculation: N=%d , J=%.3f, Result: C=%.4f , Z2=%s" % (_N, _J, res.Chern, str(res._Z2))) # Phase[_i][_j] = _i*10+_j return
def Run_4(_N, _J, _i, _j, Phase, n=1): r''' This func calculate the system with spin distribution: +z in the first $n$ layer and the last $n$ layer. ''' print("Start Calculation: N=%d , J=%.3f" % (_N, _J)) _S = np.zeros([_N, 3]) assert n <= int(_N / 2), "n should be less than half of the layer #。" for i in range(n): _S[i, 0], _S[_N - i - 1, 0] = 1, 1 S = np.array([([ s[0] * np.sin(s[1]) * np.cos(s[2]), s[0] * np.sin(s[1]) * np.sin(s[2]), s[0] * np.cos(s[1]) ]) for s in _S]) # print(S) h = Hamiltonian(N=_N, J=_J, S=S) res = TIC.Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TIC.TopoOrder(res) print("End Calculation: N=%d , J=%.3f, Result: C=%.4f , Z2=%s" % (_N, _J, res.Chern, str(res._Z2))) return
def Run_5(_N, _J, _i, _j, Phase): ''' This func calculate the system with uniform spin distribution in Z-direction. ''' print("Start Calculation: N=%d , J=%.3f" % (_N, _J)) _S = np.zeros([_N, 3]) for i in range(_N): _S[i, 0] = 1 _S[i, 1] = np.pi / 2 S = np.array([([ s[0] * np.sin(s[1]) * np.cos(s[2]), s[0] * np.sin(s[1]) * np.sin(s[2]), s[0] * np.cos(s[1]) ]) for s in _S]) # print(S) h = Hamiltonian(N=_N, J=_J, S=S) res = TIC.Calc(h, CalcZ2=True, LogOut=False, settings=settings) Phase[_i][_j] = TIC.TopoOrder(res) print("End Calculation: N=%d , J=%.3f, Result: C=%.4f , Z2=%s" % (_N, _J, res.Chern, str(res._Z2))) # Phase[_i][_j] = _i*10+_j return
z2pack.plot.wcc(result, axis=ax) plt.savefig("TestWCC_Alone_Z-Spin.png") if __name__ == "__main__": N, J = 20, 0.00 S_ = np.zeros([N, 3]) # S_[0, 0], S_[-1, 0] = 1, 1 # S_[1, 0], S_[-2, 0] = 1, 1 # S_[2, 0], S_[-3, 0] = 1, 1 layer = int(N/2) _S = np.zeros([N, 3]) for i in range(layer): _S[i, 0], _S[N-i-1, 0] = 1, 1 _S[i, 1], _S[N-i-1, 1] = 0.47124, 0.47124 _S[N-i-1, 2] = np.pi S = np.array([([s[0]*np.sin(s[1])*np.cos(s[2]), s[0]*np.sin(s[1]) * np.sin(s[2]), s[0]*np.cos(s[1])])for s in S_]) print(S) h = Hamiltonian(N=N, J=J) from TI_Film import plotLine plotLine(h, 2*N-2, 2*N+2) # e = Eig(h) # plotBS(e, 2*N-2, 2*N+2, title="TI Film: z&-z in 3 layers, J=0.01, 4 bands") # h = Ham_Small(0.02, 0.02) # bands=[2*N-2, 2*N], # res = Calc(h, KScale=1, CalcZ2=False, LogOut=True) # # print("Chern=", res.Chern) # res.plotChern()
import numpy as np # import matplotlib as mpl # # mpl.use("Agg") # from matplotlib import pyplot as plt from PhaseDiagram import PhaseDiag from _utils import nt, convertSpin, settings, settings_strict, CONST_HJZ, CONST_HZL from TI_Film import Hamiltonian, plotLine from TopoInvCalc import Calc, TopoOrder if __name__ == '__main__': N, J = 25, 0.00 h = Hamiltonian(N=N, J=J, Delta=1.9134, **CONST_HZL) res = Calc(h, CalcZ2=False, KScale=2, settings=settings_strict) res.plotChern(title="N=25 (5 QLs), J=0.00 eV, Spin-Z", filename="HZL_25_0.00_1.9134_K2") # xRange, yRange, Nx, Ny = 0.05, 0.05, 50, 50 # plotLine(h, 2*N-4, 2*N+4, xRange=xRange, Nx=Nx, # title="Band Structure(8 bands), N=30, Delta=$1.9134\AA$, No Spin\nParameters from Hai-Zhou Lu's paper.", filename="N30_J0_D1.9134")
def is_Chern(J0, c_tol=0.1): h = Hamiltonian(N=N, J=J0, S=S) res = TIC.Calc(h, CalcZ2=False) return abs(res.Chern) > c_tol