def func_to_parallelize(U): """Function to parallelize""" # all the variables must be internal! from pygra import geometry from pygra import meanfield g = geometry.honeycomb_lattice() h = g.get_hamiltonian() # create hamiltonian of the system mf = meanfield.guess(h,mode="antiferro") # antiferro initialization # perform SCF with specialized routine for Hubbard scf = meanfield.hubbardscf(h,nk=20,filling=0.5,U=U,verbose=1, mix=0.9,mf=mf) # alternatively use h = scf.hamiltonian # get the Hamiltonian gap = h.get_gap() # compute the gap return gap
h0 = g.get_hamiltonian() # create hamiltonian of the system ds = [] Us = np.linspace(0.0, 10.0, 10) f = open("DELTA_VS_T_VS_MU.OUT", "w") h0.add_swave(0.0) for U in Us: h = h0.copy() os.system("rm -rf *.pkl") #scf = scftypes.attractive_hubbard(h,nk=10,mix=0.9,mf=None,g=-2.0,T=t) mf = 10 * (meanfield.guess(h, "swave") + meanfield.guess(h, "CDW")) mf = meanfield.guess(h, "swave") #+ meanfield.guess(h,"CDW")) mf = meanfield.guess(h, "random") #+ meanfield.guess(h,"CDW")) scf = meanfield.hubbardscf( h, nk=10, mix=0.5, U=-U, mf=mf, filling=0.5, verbose=1, constrains=["no_charge"] # this forces the system to ignore CDW ) hscf = scf.hamiltonian # rho = hscf.get_filling() d = np.abs(np.mean(hscf.extract("swave"))) f.write(str(U) + " ") f.write(str(d) + "\n") print("Doing", U) f.flush() f.close()
# Add the root path of the pygra library import os import sys sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../src") # zigzag ribbon import numpy as np from pygra import geometry from pygra import meanfield g = geometry.honeycomb_lattice() h = g.get_hamiltonian() # create hamiltonian of the system h.add_swave(0.001) # add swave mf = meanfield.guess(h, mode="swave", fun=0.02) scf = meanfield.hubbardscf(h, nk=5, mf=mf, U=-2.0, filling=0.7) h = scf.hamiltonian print("Delta", h.extract("swave")) print("Onsite", h.extract("density")) h.write_swave() h.get_bands() #scf.hamiltonian.get_bands(operator="electron")
# Add the root path of the pygra library import os import sys sys.path.append(os.environ['PYGRAROOT']) # zigzag ribbon import numpy as np from pygra import geometry from pygra import meanfield g = geometry.honeycomb_lattice() g.write() Us = np.linspace(0., 4., 10) # different Us f = open("EVOLUTION.OUT", "w") # file with the results for U in Us: # loop over Us h = g.get_hamiltonian() # create hamiltonian of the system mf = meanfield.guess(h, mode="antiferro") # antiferro initialization # perform SCF with specialized routine for Hubbard scf = meanfield.hubbardscf(h, nk=20, filling=0.5, U=U, mix=0.9, mf=mf) # alternatively use # scf = scftypes.selfconsistency(h,nkp=20,filling=0.5,g=U, # mix=0.9,mf=mf) h = scf.hamiltonian # get the Hamiltonian gap = h.get_gap() # compute the gap f.write(str(U) + " " + str(gap) + "\n") # save in a file f.close()
# if you wanted to modify the Hamiltonian, just put here your data # h.geometry.r = rs # new positions # h.geometry.r2xyz() # update # h.geometry.a1 = a1 # first lattice vector # h.geometry.a2 = a2 # second lattice vector # h.intra = intra # your (spinless) intra cell hopping # h.tx = tx # your (spinless) (1,0,0) hopping matrix # h.ty = ty # your (spinless) (0,1,0) hopping matrix # h.txy = txy # your (spinless) (1,1,0) hopping matrix # h.txmy = txmy # your (spinless) (1,-1,0) hopping matrix # now make the Hamiltonian spinful h.turn_spinful() # let us do now a mean field calculation from pygra import meanfield mf = meanfield.guess(h, "randomXY") # random initial guess in XY plane # if you want to restart a calculation, just uncomment the mf=None line # that will force the code to pick the latest mean field from a file #mf = None scf = meanfield.hubbardscf(h, U=6.0, mf=mf, verbose=1, filling=0.5, nk=6, mix=0.5) # perform SCF calculation # this will write the magnetization to MAGNETISM.OUT scf.hamiltonian.write_magnetization(nrep=2) # write magnetization in a file
# Add the root path of the pygra library import os import sys sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../src") import numpy as np from pygra import geometry from pygra import meanfield # this example performs a selconsistent calculation in a dimer g = geometry.lieb_lattice() # generate the geometry Us = np.linspace(0., 2., 20) # different Hubbard U mz = [] # lists to store magnetizations for U in Us: # loop over Hubbard U h = g.get_hamiltonian() # create hamiltonian of the system mf = meanfield.guess(h, mode="antiferro") # antiferro initialization scf = meanfield.hubbardscf(h, filling=0.5, U=U, mf=mf, nk=5) # perform SCF mz0 = scf.hamiltonian.compute_vev("sz", nk=5) # expectation value mz.append(np.sum(np.abs(mz0))) # total magentization # now plot all the results import matplotlib.pyplot as plt plt.plot(Us, mz, marker="o", c="red") plt.xlabel("Hubbard U") plt.ylabel("Magnetic moment") plt.show()
# Add the root path of the pygra library import os ; import sys ; sys.path.append(os.environ['PYGRAROOT']) # zigzag ribbon import numpy as np from pygra import geometry from pygra import scftypes from pygra import meanfield import os g = geometry.honeycomb_lattice() h0 = g.get_hamiltonian() # create hamiltonian of the system ds = [] Us = np.linspace(0.0,3.0,10) f = open("DELTA_VS_T_VS_MU.OUT","w") h0.add_swave(0.0) for U in Us: h = h0.copy() os.system("rm -rf *.pkl") #scf = scftypes.attractive_hubbard(h,nk=10,mix=0.9,mf=None,g=-2.0,T=t) mf = meanfield.guess(h,"random") scf = meanfield.hubbardscf(h,nk=20,mix=0.9,U=-U,mf=mf,filling=0.1) hscf = scf.hamiltonian # rho = hscf.get_filling() d = -np.mean(hscf.extract("swave").real) f.write(str(U)+" ") f.write(str(d)+"\n") f.flush() f.close()
# Add the root path of the pygra library import os ; import sys sys.path.append(os.path.dirname(os.path.realpath(__file__))+"/../../../src") import numpy as np from pygra import geometry from pygra import meanfield # this example performs a selconsistent calculation in a dimer g = geometry.lieb_lattice() # generate the geometry #g = g.supercell(2) mz = [] # lists to store magnetizations h = g.get_hamiltonian() # create hamiltonian of the system h.add_rashba(1.0) # add Rashba spin-orbit coupling #h.get_bands() ; exit() mf = meanfield.guess(h,mode="ferro") # antiferro initialization scf = meanfield.hubbardscf(h,filling=0.5,U=1.0,mf=mf,nk=5,verbose=1) # perform SCF scf.hamiltonian.write_magnetization(nrep=4) # write selfconsistent magnetization scf.hamiltonian.get_bands(operator="sz")