Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def wf_bandstructure_no_opt(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
wf = get_wf(structure, "bandstructure_no_opt.yaml",
vis=MPStaticSet(structure, force_gamma=True),
common_params={"vasp_cmd": vasp_cmd, "db_file": db_file})
wf = add_common_powerups(wf, c)
if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY):
wf = add_small_gap_multiply(wf, 0.5, 5, "static")
wf = add_small_gap_multiply(wf, 0.5, 5, "nscf")
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)
return wf
def wf_bandstructure_hse(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
wf_src_name = "bandstructure_hse_full.yaml"
wf = get_wf(structure, wf_src_name, vis=MPHSERelaxSet(structure, force_gamma=True),
common_params={"vasp_cmd": vasp_cmd, "db_file": db_file})
wf = add_common_powerups(wf, c)
if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY):
wf = add_small_gap_multiply(wf, 0.5, 5, "static")
if c.get("STABILITY_CHECK", STABILITY_CHECK):
wf = add_stability_check(wf, fw_name_constraint="structure optimization")
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)
return wf
def wf_bandstructure_plus_boltztrap(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
params = []
for x in range(4): # everything but BoltzTrap task
params.append({"vasp_cmd": vasp_cmd, "db_file": db_file})
params.append({"db_file": db_file})
wf = get_wf(structure, "bandstructure_boltztrap.yaml", vis=MPRelaxSet(structure, force_gamma=True),
params=params)
wf = add_common_powerups(wf, c)
if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY):
wf = add_small_gap_multiply(wf, 0.5, 5, "static")
wf = add_small_gap_multiply(wf, 0.5, 5, "nscf")
if c.get("STABILITY_CHECK", STABILITY_CHECK):
wf = add_stability_check(wf, fw_name_constraint="structure optimization")
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)
return wf
# 21 deformed structures: from -10% to +10%
defos = [(np.identity(3) * (1 + x)).tolist() for x in np.linspace(-0.1, 0.1, 21)]
deformations = c.get("DEFORMATIONS", defos)
user_kpoints_settings = {"grid_density": 7000}
tag = "gibbs group: >>{}<<".format(str(uuid4()))
# input set for structure optimization
vis_relax = MPRelaxSet(structure, force_gamma=True)
v = vis_relax.as_dict()
v.update({"user_kpoints_settings": user_kpoints_settings})
vis_relax = vis_relax.__class__.from_dict(v)
# optimization only workflow
wf = get_wf(structure, "optimize_only.yaml",
params=[{"vasp_cmd": vasp_cmd, "db_file": db_file,
"name": "{} structure optimization".format(tag)}],
vis=vis_relax)
# static input set for the transmute firework
uis_static = {
"ISIF": 2,
"ISTART": 1,
}
lepsilon = False
if qha_type not in ["debye_model"]:
lepsilon = True
try:
from phonopy import Phonopy
except ImportError:
def wf_bandstructure(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
wf = get_wf(structure, "bandstructure.yaml", vis=MPRelaxSet(structure, force_gamma=True),
common_params={"vasp_cmd": vasp_cmd, "db_file": db_file})
wf = add_common_powerups(wf, c)
if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY):
wf = add_small_gap_multiply(wf, 0.5, 5, "static")
wf = add_small_gap_multiply(wf, 0.5, 5, "nscf")
if c.get("STABILITY_CHECK", STABILITY_CHECK):
wf = add_stability_check(wf, fw_name_constraint="structure optimization")
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)
return wf
def wf_scan_opt(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
user_incar_settings = c.get("USER_INCAR_SETTINGS", {})
half_kpts = c.get("HALF_KPOINTS_FIRST_RELAX", HALF_KPOINTS_FIRST_RELAX)
ediffg = user_incar_settings.get("EDIFFG", -0.05)
wf = get_wf(
structure,
"optimize_only.yaml",
vis=MVLScanRelaxSet(
structure, user_incar_settings=user_incar_settings),
common_params={
"vasp_cmd": vasp_cmd,
"db_file": db_file
})
wf = use_custodian(
wf,
custodian_params={
"ediffg": ediffg,
"max_force_threshold": 0,
"half_kpts_first_relax": half_kpts,
"job_type": "metagga_opt_run",
pressure = c.get("PRESSURE", 0.0)
user_kpoints_settings = {"grid_density": 7000}
# 10 deformations
deformations = [(np.identity(3) * (1 + x)).tolist() for x in np.linspace(-0.1, 0.1, 10)]
tag = "thermal_expansion group: >>{}<<".format(str(uuid4()))
# input set for structure optimization
vis_relax = MPRelaxSet(structure, force_gamma=True)
v = vis_relax.as_dict()
v.update({"user_kpoints_settings": user_kpoints_settings})
vis_relax = vis_relax.__class__.from_dict(v)
# optimization only workflow
wf = get_wf(structure, "optimize_only.yaml",
params=[{"vasp_cmd": vasp_cmd, "db_file": db_file,
"name": "{} structure optimization".format(tag)}],
vis=vis_relax)
wf_thermal = get_wf_thermal_expansion(structure, user_kpoints_settings=user_kpoints_settings,
deformations=deformations, vasp_cmd=vasp_cmd, db_file=db_file,
eos=eos, pressure=pressure, tag=tag)
# chain it
wf.append_wf(wf_thermal, wf.leaf_fw_ids)
wf = add_modify_incar(wf, modify_incar_params={"incar_update": {"ENCUT": 600, "EDIFF": 1e-6}})
wf = add_common_powerups(wf, c)
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
def wf_dielectric_constant_no_opt(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
wf = get_wf(structure, "dielectric_constant_no_opt.yaml",
common_params={"vasp_cmd": vasp_cmd, "db_file": db_file})
wf = add_common_powerups(wf, c)
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)
return wf
def wf_dielectric_constant(structure, c=None):
c = c or {}
vasp_cmd = c.get("VASP_CMD", VASP_CMD)
db_file = c.get("DB_FILE", DB_FILE)
wf = get_wf(structure, "dielectric_constant.yaml", vis=MPRelaxSet(structure, force_gamma=True),
common_params={"vasp_cmd": vasp_cmd, "db_file": db_file})
wf = add_common_powerups(wf, c)
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)
return wf
# mesh internally
kpts_settings = Kpoints.automatic_density(structure, 40000, force_gamma=True)
stencils = np.linspace(-0.075, 0.075, 7)
else:
kpts_settings = {'grid_density': 7000}
stencils = None
uis_static = uis_optimize.copy()
uis_static.update({'ISIF': 2, 'IBRION': 2, 'NSW': 99, 'ISTART': 1, "PREC": "High"})
# input set for structure optimization
vis_relax = MPRelaxSet(structure, force_gamma=True, user_incar_settings=uis_optimize,
user_kpoints_settings=kpts_settings)
# optimization only workflow
wf = get_wf(structure, "optimize_only.yaml", vis=vis_relax,
params=[{"vasp_cmd": vasp_cmd, "db_file": db_file,
"name": "elastic structure optimization"}])
vis_static = MPStaticSet(structure, force_gamma=True, lepsilon=False,
user_kpoints_settings=kpts_settings,
user_incar_settings=uis_static)
# deformations wflow for elasticity calculation
wf_elastic = get_wf_elastic_constant(structure, vasp_cmd=vasp_cmd, db_file=db_file,
order=order, stencils=stencils, copy_vasp_outputs=True,
vasp_input_set=vis_static, sym_reduce=sym_reduce)
wf.append_wf(wf_elastic, wf.leaf_fw_ids)
wf = add_common_powerups(wf, c)
if c.get("ADD_WF_METADATA", ADD_WF_METADATA):
wf = add_wf_metadata(wf, structure)