Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_scf_input(ecut=10, ngkpt=(8, 8, 8)):
"""
This function constructs an `AbinitInput` for performing a
GS-SCF calculation in crystalline AlAs.
Args:
ecut: cutoff energy in Ha.
ngkpt: 3 integers specifying the k-mesh for the electrons.
Return:
`AbinitInput` object
"""
# Initialize the AlAs structure from an internal database. Use the pseudos shipped with AbiPy.
gs_inp = abilab.AbinitInput(structure=abidata.structure_from_ucell("AlAs"),
pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"))
# Set the value of the Abinit variables needed for GS runs.
gs_inp.set_vars(
nband=4,
ecut=ecut,
ngkpt=ngkpt,
nshiftk=1,
shiftk=[0.0, 0.0, 0.0],
ixc=7,
nstep=500,
iscf=7,
diemac=5.0,
toldfe=1.0e-22,
nbdbuf=0,
kptopt=1,
def make_scf_nscf_inputs(nsppol, paral_kgb=1):
"""
Generate two input files for the GS and the NSCF run for given `nsppol`.
"""
# Fe normal bcc structure for test of a ferromagnetic calculation
multi = abilab.MultiDataset(structure=data.structure_from_ucell("Fe-fm"),
pseudos=data.pseudos("26fe.pspnc"), ndtset=2)
# Global variables
global_vars = dict(
nsppol=nsppol,
ecut=18,
nband=8,
occopt=3,
tsmear=0.01,
paral_kgb=paral_kgb,
)
if nsppol == 2:
global_vars.update(spinat=[0.0, 0.0, 4.0])
multi.set_vars(global_vars)
def make_base_flow(options):
multi = abilab.MultiDataset(structure=data.structure_from_ucell("GaAs"),
pseudos=data.pseudos("31ga.pspnc", "33as.pspnc"), ndtset=5)
# Global variables
kmesh = dict(ngkpt=[4, 4, 4],
nshiftk=4,
shiftk=[[0.5, 0.5, 0.5],
[0.5, 0.0, 0.0],
[0.0, 0.5, 0.0],
[0.0, 0.0, 0.5]]
)
paral_kgb = 1
global_vars = dict(ecut=2, paral_kgb=paral_kgb)
global_vars.update(kmesh)
multi.set_vars(global_vars)
def build_flow(options):
# Set working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
if not options.workdir:
options.workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_")
structure = abidata.structure_from_ucell("GaAs")
pseudos = abidata.pseudos("Ga-low_r.psp8", "As_r.psp8")
num_electrons = structure.num_valence_electrons(pseudos)
#print("num_electrons:", num_electrons)
# Usa same shifts in all tasks.
ngkpt = [4, 4, 4]
shiftk= [
[0.5, 0.5, 0.5],
[0.5, 0.0, 0.0],
[0.0, 0.5, 0.0],
[0.0, 0.0, 0.5],
]
# NSCF run on k-path with large number of bands
kptbounds = [
[0.5, 0.0, 0.0], # L point
def build_flow(options, paral_kgb=0):
"""
Build flow for the calculation of optical properties with optic + band structure
along high-symmetry k-path. DDK are computed with 3 k-meshes of increasing density
to monitor the convergece of the spectra.
"""
# Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
workdir = options.workdir
if not options.workdir:
workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_")
multi = abilab.MultiDataset(structure=abidata.structure_from_ucell("GaAs"),
pseudos=abidata.pseudos("31ga.pspnc", "33as.pspnc"), ndtset=2)
# Usa same shifts in all tasks.
shiftk= [[0.5, 0.5, 0.5],
[0.5, 0.0, 0.0],
[0.0, 0.5, 0.0],
[0.0, 0.0, 0.5]]
# Global variables.
multi.set_vars(ecut=2, paral_kgb=paral_kgb)
# Dataset 1 (GS run)
multi[0].set_vars(tolvrs=1e-8, nband=4)
multi[0].set_kmesh(ngkpt=[4, 4, 4], shiftk=shiftk)
# NSCF run on k-path with large number of bands
def make_scf_input(ngkpt):
"""
This function constructs the input file for the GS calculation:
"""
structure = abidata.structure_from_ucell("AlAs")
pseudos = abidata.pseudos("13al.981214.fhi", "33as.pspnc")
gs_inp = abilab.AbinitInput(structure, pseudos=pseudos)
gs_inp.set_vars(
nband=6,
ecut=6.0,
ngkpt=ngkpt,
nshiftk=1,
shiftk=[0, 0, 0],
tolvrs=1.0e-10,
)
return gs_inp
def build_flow(options):
# Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
if not options.workdir:
options.workdir = os.path.basename(sys.argv[0]).replace(".py", "").replace("run_", "flow_")
pseudos = data.pseudos("14si.pspnc", "6c.pspnc")
structure = data.structure_from_ucell("SiC")
# Initialize the input
relax_inp = abilab.AbinitInput(structure, pseudos=pseudos)
# Set variables
relax_inp.set_vars(
ecut=20,
paral_kgb=1,
iomode=3,
# Relaxation part
ionmov=2,
optcell=1,
strfact=100,
ecutsm=0.5, # Important!
dilatmx=1.15, # Important!
toldff=1e-6,
def make_inputs(paral_kgb=1):
"""
Returns a tuple of 4 input files for SCF, NSCF, SCR, SIGMA calculations.
These files are then used as templates for the convergence study
wrt ecuteps and the number of bands in W.
"""
multi = abilab.MultiDataset(abidata.structure_from_ucell("SiC"),
pseudos=abidata.pseudos("14si.pspnc", "6c.pspnc"), ndtset=4)
ecut = 12
global_vars = dict(
ecut=ecut,
istwfk="*1",
paral_kgb=paral_kgb,
gwpara=2,
iomode=1,
)
ecuteps = 4
ngkpt = [4, 4, 4]
shiftk = [0, 0, 0]
multi.set_vars(global_vars)
def make_input(paw=False):
"""
Build and return an input file for GS calculations with paral_kgb=1
"""
pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \
abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw")
structure = abidata.structure_from_ucell("SiO2-alpha")
inp = abilab.AbinitInput(structure, pseudos)
inp.set_kmesh(ngkpt=[1, 1, 1], shiftk=[0, 0, 0])
# Global variables
ecut = 24
inp.set_vars(
ecut=ecut,
pawecutdg=ecut * 2 if paw else None,
paral_kgb=1,
nsppol=1,
nband=28,
npkpt=1,
npband=1,
npfft=1,
fftalg=112,