Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Create flow to compute all the independent atomic perturbations
# corresponding to a [4, 4, 4] q-mesh.
# Electric field and Born effective charges are also computed.
flow = flowtk.PhononFlow.from_scf_input(options.workdir, scf_input,
ph_ngqpt=(4, 4, 4), with_becs=True)
return flow
# This block generates the thumbnails in the AbiPy gallery.
# You can safely REMOVE this part if you are using this script for production runs.
if os.getenv("READTHEDOCS", False):
__name__ = None
import tempfile
options = flowtk.build_flow_main_parser().parse_args(["-w", tempfile.mkdtemp()])
build_flow(options).graphviz_imshow()
@flowtk.flow_main
def main(options):
"""
This is our main function that will be invoked by the script.
flow_main is a decorator implementing the command line interface.
Command line args are stored in `options`.
"""
return build_flow(options)
if __name__ == "__main__":
sys.exit(main())
if qtype == "script":
manager = flowtk.TaskManager.from_user_config()
script = manager.qadapter.get_script_str(
job_name="job_name", launch_dir="workdir", executable="executable",
qout_path="qout_file.path", qerr_path="qerr_file.path",
stdin="stdin", stdout="stdout", stderr="stderr")
print(script)
else:
print(flowtk.TaskManager.autodoc())
print("qtype supported: %s" % flowtk.all_qtypes())
print("Use `abirun.py . manager slurm` to have the list of qparams for slurm.\n")
if qtype is not None:
print("QPARAMS for %s" % qtype)
flowtk.show_qparams(qtype)
return 0
if options.command == "doc_scheduler":
print("Options that can be specified in scheduler.yml:")
print(flowtk.PyFlowScheduler.autodoc())
return 0
if options.command == "abibuild":
abinit_build = flowtk.AbinitBuild()
print()
print(abinit_build)
print()
if not options.verbose:
print("Use --verbose for additional info")
else:
def build_flow(options):
if not options.workdir:
options.workdir = os.path.basename(sys.argv[0]).replace(".py", "").replace("run_", "flow_")
scf_input = make_scf_input(ecut=10, ngkpt=(6, 6, 6))
return flowtk.NonLinearCoeffFlow.from_scf_input(options.workdir, scf_input)
# This block generates the thumbnails in the AbiPy gallery.
# You can safely REMOVE this part if you are using this script for production runs.
if os.getenv("READTHEDOCS", False):
__name__ = None
import tempfile
# Temporarily disabled in v8.8.2
options = flowtk.build_flow_main_parser().parse_args(["-w", tempfile.mkdtemp()])
build_flow(options).graphviz_imshow()
@flowtk.flow_main
def main(options):
"""
This is our main function that will be invoked by the script.
flow_main is a decorator implementing the command line interface.
Command line args are stored in `options`.
"""
# Temporarily disabled in v8.8.2
#return 0
return build_flow(options)
if __name__ == "__main__":
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_")
# Get the SCF and the NSCF input.
scf_input, nscf_input = make_scf_nscf_inputs()
# Build the flow.
return flowtk.bandstructure_flow(options.workdir, scf_input, nscf_input, manager=options.manager)
tolrff=5.0e-2,
tolmxf=5.0e-5,
ntime=50,
dilatmx=1.05, # Important!
ecutsm=0.5, # Important!
)
# Here we set the k-meshes (Gamma-centered for simplicity)
for i, ngkpt in enumerate(ngkpt_list):
multi[i].set_kmesh(ngkpt=ngkpt, shiftk=[0, 0, 0])
# As the calculations are independent, we can use Flow.from_inputs
# and call split_datasets to create len(ngkpt_list) inputs.
# Note that it's a good idea to specify the task_class so that AbiPy knows how to restart the calculation.
return flowtk.Flow.from_inputs(options.workdir, inputs=multi.split_datasets(),
task_class=flowtk.RelaxTask)
# Documentation options that do not need a flow.
# Print docs and exit immediately.
if options.command == "doc_manager":
# Document TaskManager options and qparams.
qtype = options.qtype
if qtype == "script":
manager = flowtk.TaskManager.from_user_config()
script = manager.qadapter.get_script_str(
job_name="job_name", launch_dir="workdir", executable="executable",
qout_path="qout_file.path", qerr_path="qerr_file.path",
stdin="stdin", stdout="stdout", stderr="stderr")
print(script)
else:
print(flowtk.TaskManager.autodoc())
print("qtype supported: %s" % flowtk.all_qtypes())
print("Use `abirun.py . manager slurm` to have the list of qparams for slurm.\n")
if qtype is not None:
print("QPARAMS for %s" % qtype)
flowtk.show_qparams(qtype)
return 0
if options.command == "doc_scheduler":
print("Options that can be specified in scheduler.yml:")
print(flowtk.PyFlowScheduler.autodoc())
return 0
if options.command == "abibuild":
abinit_build = flowtk.AbinitBuild()
)
#nscf_kpath_inp.pop_vars(["tolvrs"])
nscf_kpath_inp.set_kpath(ndivsm=10)
# NSCF run with k-mesh to get WFK with empty states.
nscf_empty_kmesh_inp = gs_inp.new_with_vars(
nband=54,
nbdbuf=4,
tolwfr=1e-16,
iscf=-2,
)
flow = flowtk.Flow(workdir, manager=options.manager, remove=options.remove)
# GS run to get the WFK
work0 = flowtk.BandStructureWork(gs_inp, nscf_kpath_inp, dos_inputs=[nscf_empty_kmesh_inp])
flow.register_work(work0)
# Phonon work with 4x4x4 q-mesh
ddb_ngqpt = [2, 2, 2]
ph_work = flowtk.PhononWork.from_scf_task(work0[0], ddb_ngqpt, is_ngqpt=True)
flow.register_work(ph_work)
# Build input file for E-PH run. See v8/Input/t44.in
eph_inp = gs_inp.new_with_vars(
optdriver=7, # EPH driver.
eph_task=4, # For electronic self-energy due to phonon
nband=54,
ddb_ngqpt=ddb_ngqpt, # q-mesh used to produce the DDB file (must be consistent with DDB data)
symsigma=0,
nkptgw=2,
kptgw=[0, 0, 0, 0.5, 0, 0],
# Get our templates
scf_inp, nscf_inp, scr_inp, sig_inp = make_inputs()
ecuteps_list = np.arange(2, 8, 2)
max_ecuteps = max(ecuteps_list)
flow = flowtk.Flow(workdir=options.workdir, manager=options.manager)
# Band structure work to produce the WFK file
bands = flowtk.BandStructureWork(scf_inp, nscf_inp)
flow.register_work(bands)
# Build a work made of two SCR runs with different value of nband
# Use max_ecuteps for the dielectric matrix (sigma tasks will
# read a submatrix when we test the convergence wrt to ecuteps.
scr_work = flowtk.Work()
for inp in scr_inp.generate(nband=[10, 15]):
inp.set_vars(ecuteps=max_ecuteps)
scr_work.register_scr_task(inp, deps={bands.nscf_task: "WFK"})
flow.register_work(scr_work)
# Do a convergence study wrt ecuteps, each work is connected to a
# different SCR file computed with a different value of nband.
# Build a list of sigma inputs with different ecuteps
sigma_inputs = list(sig_inp.generate(ecuteps=ecuteps_list))
for scr_task in scr_work:
sigma_conv = flowtk.SigmaConvWork(wfk_node=bands.nscf_task, scr_node=scr_task, sigma_inputs=sigma_inputs)
flow.register_work(sigma_conv)