#kx = np.linspace(0.004, 0.0042, steps) omega0_bands = np.zeros((k, kx.shape[0])) true_bands = np.zeros((k, kx.shape[0])) ################################################### #phase diagram mu vs gam dirS = 'bands_data' if not os.path.exists(dirS): os.makedirs(dirS) try: PLOT = str(sys.argv[1]) except: PLOT = 'F' if PLOT != 'P': for i in range(kx.shape[0]): print(omega0_bands.shape[1]-i, kx[i]) H = SNRG.Junc_eff_Ham_gen(omega=0, Wj=Wj, Lx=Lx, nodx=cutx, nody=cuty, ax=ax, ay=ay, kx=kx[i], m_eff=0.026, alp_l=alpha, alp_t=alpha, mu=mu, Vj=Vj, Gam=gam, Gam_SC_factor=0, delta=delta, phi=phi, iter=50, eta=0) S = int(H.shape[0]/2) H = (H[:S, :])[:, :S] eigs, vecs = spLA.eigsh(H, k=k, sigma=0, which='LM') idx_sort = np.argsort(eigs) eigs = eigs[idx_sort] #print(eigs) #arg = np.argmin(np.absolute(eigs)) #print(arg) omega0_bands[:, i] = eigs[:] np.save("%s/SOCbands Lx = %.1f Wj = %.1f nodx = %.1f nody = %.1f Vj = %.1f alpha = %.1f delta = %.2f phi = %.3f mu = %.1f gam = %.1f.npy" % (dirS, Lx*.1, Junc_width, Nod_widthx, Nod_widthy, Vj, alpha, delta, phi, mu, gam), omega0_bands) gc.collect() #for i in range(omega0_bands.shape[0]): # for j in range(omega0_bands.shape[1]):
def SNRG_gam_finder(ax, ay, mu, gi, gf, Wj=0, Lx=0, cutxT=0, cutyT=0, cutxB=0, cutyB=0, Vj=0, Vsc=0, m_eff=0.026, alpha=0, delta=0, phi=0, k=20, QX=0, tol=1e-5, done=False, PLOT=False, n=3, plot_junction=False): delta_gam = abs(gf - gi) n1, n2 = step_finder(delta_gam / (2 * tol) + 1, n) H0 = SNRG.Junc_eff_Ham_gen(omega=0, Wj=Wj, Lx=Lx, cutxT=cutxT, cutyT=cutyT, cutxB=cutxB, cutyB=cutyB, ax=ax, ay=ay, kx=QX, m_eff=m_eff, alp_l=alpha, alp_t=alpha, mu=mu, Vj=Vj, Vsc=Vsc, Gam=1e-9, delta=delta, phi=phi, plot_junction=plot_junction) eigs, vecs = spLA.eigsh(H0, k=k, sigma=0, which='LM') vecs_hc = np.conjugate(np.transpose(vecs)) #hermitian conjugate idx_sort = np.argsort(eigs) eigs = eigs[idx_sort] #print(eigs) H_G1 = SNRG.Junc_eff_Ham_gen( omega=0, Wj=Wj, Lx=Lx, cutxT=cutxT, cutyT=cutyT, cutxB=cutxB, cutyB=cutyB, ax=ax, ay=ay, kx=QX, m_eff=m_eff, alp_l=alpha, alp_t=alpha, mu=mu, Vj=Vj, Vsc=Vsc, Gam=1 + 1e-9, delta=delta, phi=phi ) #Hamiltonian with ones on Zeeman energy along x-direction sites HG = H_G1 - H0 #the proporitonality matrix for gam-x, it is ones along the sites that have a gam value HG0_DB = np.dot(vecs_hc, H0.dot(vecs)) HG_DB = np.dot(vecs_hc, HG.dot(vecs)) G_crit = [] delta_gam = abs(gf - gi) steps = n1 gx = np.linspace(gi, gf, steps) eig_arr = np.zeros((gx.shape[0])) for i in range(gx.shape[0]): H_DB = HG0_DB + gx[i] * HG_DB eigs_DB, U_DB = LA.eigh(H_DB) idx_sort = np.argsort(eigs_DB) eigs_DB = eigs_DB[idx_sort] eig_arr[i] = eigs_DB[int(k / 2)] #checking edge cases if eig_arr[0] < 1e-10: print("eig at gx=0: ", eig_arr[0]) G_crit.append(gx[0]) if eig_arr[-1] < 1e-10: print("eig at gx=0", gx[-1], ": ", eig_arr[0]) G_crit.append(gx[-1]) local_min_idx = np.array(argrelextrema(eig_arr, np.less)[0]) print(local_min_idx.size, "Energy local minima found at gx = ", gx[local_min_idx]) #for i in range(local_min_idx.shape[0]): # print(eig_arr[:, local_min_idx[i]]) #sys.exit() if PLOT: plt.plot(gx, eig_arr[2, :], c='r') plt.scatter(gx[local_min_idx], eig_arr[2, local_min_idx], c='b', marker='X') plt.plot(gx, 0 * gx, c='k', lw=1) plt.show() for i in range(0, local_min_idx.size): #eigs_min.size gx_c = gx[local_min_idx[i]] #first approx g_critical gx_lower = gx[local_min_idx[i] - 1] # one step back gx_higher = gx[local_min_idx[i] + 1] #one step forward delta_gam = (gx_higher - gx_lower) n_steps = n2 gx_finer = np.linspace(gx_lower, gx_higher, n_steps) eig_arr_finer = np.zeros((gx_finer.size)) for j in range(gx_finer.shape[0]): H_DB = HG0_DB + gx_finer[j] * HG_DB eigs_DB, U_DB = LA.eigh(H_DB) idx_sort = np.argsort(eigs_DB) eigs_DB = eigs_DB[idx_sort] eig_arr_finer[j] = eigs_DB[int(k / 2)] min_idx_finer = np.array(argrelextrema( eig_arr_finer, np.less)[0]) #new local minima indices eigs_min_finer = eig_arr_finer[min_idx_finer] #isolating local minima gx_min_finer = gx_finer[min_idx_finer] if PLOT: plt.plot(gx_finer, eig_arr_finer, c='b') plt.scatter(gx_finer[min_idx_finer], eig_arr_finer[min_idx_finer], c='r', marker='X') plt.plot(gx_finer, 0 * gx_finer, c='k', lw=1) plt.show() for m in range(eigs_min_finer.shape[0]): if abs(eigs_min_finer[m]) < tol: G_crit.append(gx_min_finer[m]) print("Crossing found at Gx = {} | E = {} meV".format( gx_min_finer[m], eigs_min_finer[m])) if cutxT == 0 and cutxB == 0 and cutyT == 0 and cutyB == 0 and Vj == 0: G_crit = np.array(G_crit) return G_crit if not done: G_crit = G_crit + SNRG_gam_finder(ax, ay, mu, gi, gf, Wj=Wj, Lx=Lx, cutxT=cutxT, cutyT=cutyT, cutxB=cutxB, cutyB=cutyB, Vj=Vj, Vsc=Vsc, m_eff=m_eff, alpha=alpha, delta=delta, phi=phi, k=k, QX=np.pi / Lx, done=True, tol=tol, PLOT=PLOT) G_crit.sort() G_crit = np.array(G_crit) print(G_crit) return (G_crit) if done: return G_crit
#gap1 = gap[0:103] #kx_of_gap1 = kx_of_gap[0:103] #mu2 = np.linspace(mu[103], mu[103+1], 10) #gap2 = np.zeros(10) #kx_of_gap2 = np.zeros(10) #mu3 = mu[105:] #gap3 = gap[105:] #kx_of_gap3 = kx_of_gap[105:] #mu = np.concatenate((mu1, mu2, mu3), axis=None) #print(mu[0:160]) #sys.exit() #np.save("%s/mu Wj = %.1f Lx = %.1f cutxT = %.1f cutyT = %.1f cutxB = %.1f cutyB = %.1f Vj = %.1f phi = %.2f mu_i = %.1f mu_f = %.1f gx = %.2f.npy" % (dirS, Junc_width, Lx*.1, cutxT_width, cutyT_width, cutxB_width, cutyB_width, Vj, phi, mu_i, mu_f, gx), mu) for i in range(0, mu.shape[0]): print(mu.shape[0]-i, "| mu =", mu[i]) GAP, KX = SNRG.gap(Wj=Wj, Lx=Lx, cutxT=cutxT, cutyT=cutyT, cutxB=cutxB, cutyB=cutyB, ax=ax, ay=ay, gam=gx, mu=mu[i], Vj=Vj, alpha=alpha, delta=delta, phi=phi, targ_steps=50000, n_avg=4, muf=mu[i], PLOT=False, tol=1e-7) gap[i] = GAP kx_of_gap[i] = KX np.save("%s/gapfxmu Wj = %.1f Lx = %.1f cutxT = %.1f cutyT = %.1f cutxB = %.1f cutyB = %.1f Vj = %.1f phi = %.2f mu_i = %.1f mu_f = %.1f gx = %.2f.npy" % (dirS, Junc_width, Lx*.1, cutxT_width, cutyT_width, cutxB_width, cutyB_width, Vj, phi, mu_i, mu_f, gx), gap) np.save("%s/kxofgapfxmu Wj = %.1f Lx = %.1f cutxT = %.1f cutyT = %.1f cutxB = %.1f cutyB = %.1f Vj = %.1f phi = %.2f mu_i = %.1f mu_f = %.1f gx = %.2f.npy" % (dirS, Junc_width, Lx*.1, cutxT_width, cutyT_width, cutxB_width, cutyB_width, Vj, phi, mu_i, mu_f, gx), kx_of_gap) gc.collect() #gap = np.concatenate((gap1, gap2, gap3), axis=None) #kx_of_gap = np.concatenate((kx_of_gap1, kx_of_gap2, kx_of_gap3), axis=None) #np.save("%s/gapfxmu Wj = %.1f Lx = %.1f cutxT = %.1f cutyT = %.1f cutxB = %.1f cutyB = %.1f Vj = %.1f phi = %.2f mu_i = %.1f mu_f = %.1f gx = %.2f.npy" % (dirS, Junc_width, Lx*.1, cutxT_width, cutyT_width, cutxB_width, cutyB_width, Vj, phi, mu_i, mu_f, gx), gap) #np.save("%s/kxofgapfxmu Wj = %.1f Lx = %.1f cutxT = %.1f cutyT = %.1f cutxB = %.1f cutyB = %.1f Vj = %.1f phi = %.2f mu_i = %.1f mu_f = %.1f gx = %.2f.npy" % (dirS, Junc_width, Lx*.1, cutxT_width, cutyT_width, cutxB_width, cutyB_width, Vj, phi, mu_i, mu_f, gx), kx_of_gap) #gc.collect() sys.exit() else: np.save("%s/mu Wj = %.1f Lx = %.1f cutxT = %.1f cutyT = %.1f cutxB = %.1f cutyB = %.1f Vj = %.1f phi = %.2f mu_i = %.1f mu_f = %.1f gx = %.2f.npy" % (dirS, Junc_width, Lx*.1, cutxT_width, cutyT_width, cutxB_width, cutyB_width, Vj, phi, mu_i, mu_f, gx), mu)
if not os.path.exists(dirS): os.makedirs(dirS) try: PLOT = str(sys.argv[1]) except: PLOT = 'F' if PLOT != 'P': for i in range(mu.shape[0]): print(steps - i, "| mu =", mu[i]) gapmu[i] = SNRG.gap(Wj=Wj, Lx=Lx, nodx=nodx, nody=nody, ax=ax, ay=ay, gam=gx, mu=mu[i], Vj=Vj, alpha=alpha, delta=delta, phi=phi, muf=10, targ_steps=2500)[0] np.save( "%s/gapfxmu Wj = %.1f nodx = %.1f nody = %.1f Vj = %.1f alpha = %.1f delta = %.2f phi = %.3f mu_i = %.1f mu_f=%.1f gx=%.2f.npy" % (dirS, Junc_width, Nod_widthx, Nod_widthy, Vj, alpha, delta, phi, mu_i, mu_f, gx), gapmu) np.save( "%s/mu Wj = %.1f nodx = %.1f nody = %.1f Vj = %.1f alpha = %.1f delta = %.2f phi = %.3f mu_i = %.1f mu_f=%.1f gx=%.2f.npy" % (dirS, Junc_width, Nod_widthx, Nod_widthy, Vj, alpha, delta, phi, mu_i, mu_f, gx), mu)