Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if prev_calc_loc:
t.append(CopyVaspOutputs(calc_loc=prev_calc_loc,
contcar_to_poscar=True))
t.append(WriteVaspStaticFromPrev(other_params=vasp_input_set_params))
elif structure:
vasp_input_set = vasp_input_set or MPStaticSet(structure, **vasp_input_set_params)
t.append(WriteVaspFromIOSet(structure=structure,
vasp_input_set=vasp_input_set))
else:
raise ValueError("Must specify structure or previous calculation")
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<"))
t.append(PassCalcLocs(name=name))
t.append(
VaspToDb(db_file=db_file, **vasptodb_kwargs))
super(StaticFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)
rerelax_fw = OptimizeFW( prim_structure,
name="structure optimization",
vasp_input_set=vis,
vasp_cmd=vasp_cmd, db_file=db_file,
auto_npar=">>auto_npar<<",
parents=None)
fws.append(rerelax_fw)
parents = [rerelax_fw]
if hybrid_run_for_gap_corr: #only run HSEBSFW hybrid workflow here if re-relaxed since it requires a copy-over optimized structure
hse_fw = HSEBSFW(structure=prim_structure, parents=parents, name="hse-BS", vasp_cmd=vasp_cmd, db_file=db_file)
fws.append( hse_fw)
elif hybrid_run_for_gap_corr: #if not re-relaxing structure but want hybrid then need to run a static primitive struct calc initial
stat_gap_fw = StaticFW(structure=prim_structure, name="{} gap gga initialize".format(structure.composition.reduced_formula),
vasp_cmd=vasp_cmd, db_file=db_file)
fws.append( stat_gap_fw)
hse_fw = HSEBSFW(structure=prim_structure, parents=stat_gap_fw, name="hse-BS", vasp_cmd=vasp_cmd, db_file=db_file)
fws.append( hse_fw)
if diel_flag: #note dielectric DFPT run is only done with GGA
user_incar_settings = {}
copy_out = True if parents else False
diel_fw = DFPTFW(structure=prim_structure, name='ionic dielectric', vasp_cmd=vasp_cmd, copy_vasp_outputs=copy_out,
db_file=db_file, parents=parents, user_incar_settings=user_incar_settings)
fws.append( diel_fw)
t = []
if parents:
t.append(CopyVaspOutputs(calc_loc= True ))
i = 0
for s in structures:
diffusion = True if i==0 else False
wflow_name=s.composition.reduced_formula
_wf = get_simulated_anneal_wf(s, start_temp=2500, name='snap_' + str(i), diffusion=diffusion,
wflow_name=wflow_name, calc_home=calc_home, copy_calcs=copy_calcs,
db_file=db_file, snap_num=i, priority_spec=priority_spec)
_wf = powerups.add_modify_incar_envchk(_wf)
wfs.append(_wf)
i += 1
else:
# Relax the structure using a static relax with Materials Project Vasp settings
for s in structures:
fw1 = OptimizeFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[], spec=priority_spec, **kwargs)
fw2 = StaticFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[fw1], spec=priority_spec)
wfs.append(Workflow([fw1, fw2], name=name + str(s.composition.reduced_formula)))
return wfs
adsorb_finder = AdsorbateSiteFinder(slab=structure, selective_dynamics=True)
ad_structs = adsorb_finder.generate_adsorption_structures(molecule=molecule, **adsorbate_gen_args)
opt_fws = []
stat_fws = []
for ad_struct in ad_structs:
_struct_dict = ad_struct.as_dict()
for site in _struct_dict["sites"]:
if "velocities" in site["properties"].keys():
del site["properties"]["velocities"]
_ad_struct = Structure.from_dict(_struct_dict)
opt_fws.append(
OptimizeFW(structure=_ad_struct, name=structure.composition.reduced_formula + "_slab_optimize",
**run_specs))
stat_fw = StaticFW(structure=_ad_struct, name=structure.composition.reduced_formula + "_slab_static",
prev_calc_loc=True, **run_specs, parents=[opt_fws[-1]])
stat_fw.tasks.append(SpawnVibrationalFWTask(run_specs=run_specs))
stat_fws.append(stat_fw)
fws = opt_fws
fws.extend(stat_fws)
wf = Workflow(fws)
return FWAction(additions=wf)
:param structures:
:param vasp_cmd:
:param db_file:
:param name:
:param copy_calcs:
:param calc_home:
:param snap:
:param priority_spec:
:param kwargs:
:return:
"""
wfs = []
calc_home = os.path.join(calc_home, "snap_" + str(snap))
for s in structures:
fw1 = OptimizeFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[], spec=priority_spec, **kwargs)
fw2 = StaticFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[fw1], spec=priority_spec)
t = []
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"]))
if copy_calcs:
t.append(
CopyCalsHome(calc_home=calc_home,
run_name=name))
fw3 = Firework(t, name="relax_copy_calcs", parents=[fw2], spec=priority_spec)
_wf = Workflow([fw1, fw2, fw3], name=str(s.composition.reduced_formula) + "_" + str(snap) + "_" + name)
_wf = powerups.add_modify_incar_envchk(_wf)
wfs.append(_wf)
return wfs
# relax
fws.append(
OptimizeFW(
ordered_structure,
vasp_input_set=vis,
vasp_cmd=c["VASP_CMD"],
db_file=c["DB_FILE"],
max_force_threshold=0.05,
half_kpts_first_relax=False,
name=name + " optimize",
)
)
# static
fws.append(
StaticFW(
ordered_structure,
vasp_cmd=c["VASP_CMD"],
db_file=c["DB_FILE"],
name=name + " static",
prev_calc_loc=True,
parents=fws[-1],
vasptodb_kwargs={'parse_chgcar': True, 'parse_aeccar': True}
)
)
if not self.static:
# so a failed optimize doesn't crash workflow
fws[-1].spec["_allow_fizzled_parents"] = True
elif scan:
def get_relax_static_wf(structures, vasp_cmd=">>vasp_cmd<<", db_file=">>db_file<<",
name="regular_relax", copy_calcs=False, calc_home="~/wflows", snap=0, priority_spec={}, **kwargs):
"""
:param structures:
:param vasp_cmd:
:param db_file:
:param name:
:param kwargs:
:return:
"""
wfs = []
calc_home = os.path.join(calc_home, "snap_" + str(snap))
for s in structures:
fw1 = OptimizeFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[], spec=priority_spec, **kwargs)
fw2 = StaticFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[fw1], spec=priority_spec)
t = [CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"])]
if copy_calcs:
t.append(CopyCalsHome(calc_home=calc_home, run_name=name))
fw3 = Firework(t, name="relax_copy_calcs", parents=[fw2], spec=priority_spec)
_wf = Workflow([fw1, fw2, fw3], name=str(s.composition.reduced_formula) + "_" + str(snap) + "_" + name)
wfs.append(_wf)
return wfs
v = vis_relax.as_dict()
v.update({"user_kpoints_settings": user_kpoints_settings})
vis_relax = vis_relax.__class__.from_dict(v)
# Structure optimization firework
fws = [OptimizeFW(structure=structure, vasp_input_set=vis_relax, vasp_cmd=vasp_cmd,
db_file=db_file, name="{} structure optimization".format(tag))]
# Static firework: copy previous outputs and do a static run on the defect-free system
uis_static = {"ISTART": 1}
uis_static_relax_ions = {"ISTART": 1, "IBRION": 2, "NSW": 100}
vis_static = MPStaticSet(structure, force_gamma=True, lepsilon=lepsilon,
user_kpoints_settings=user_kpoints_settings,
user_incar_settings=uis_static_relax_ions)
nelect_input = vis_static.nelect
fws.append(StaticFW(structure, vasp_input_set=vis_static, vasp_cmd=vasp_cmd,
db_file=db_file, name="{} static calculation".format(tag),
copy_vasp_outputs=True, parents=fws[0]))
# Apply each defect transformation and run static calculations for each charge state
# ==> n_fireworks = n_defect_transformations * n_charge_states + n_defect_transformations
for i, dt in enumerate(defect_transformations):
# Transmuter firework: copy previous outputs, create supercell with the defect(neutral) and
# relax the ions
vis_static = MPStaticSet(structure, force_gamma=True, lepsilon=lepsilon,
user_kpoints_settings=user_kpoints_settings,
user_incar_settings=uis_static_relax_ions)
fw_neutral_defect = TransmuterFW(name="{}_{}_{}".format(tag, name, dt), structure=structure,
transformations=[dt],
transformation_params=[defect_transformations_params[i]],
vasp_input_set=vis_static, copy_vasp_outputs=True, parents=fws[1],
vasp_cmd=vasp_cmd, db_file=db_file)
"""
wfs = []
structures = get_sample_structures(xdatcar_path=xdatcar_file, n=n, steps_skip_first=steps_skip_first)
if sim_anneal:
for i in range(len(structures)):
s = structures[i]
diffusion = True if i == 0 else False
wflow_name=s.composition.reduced_formula
_wf = get_simulated_anneal_wf(s, start_temp=2500, name='snap_' + str(i), diffusion=diffusion,
wflow_name=wflow_name, calc_home=calc_home, copy_calcs=copy_calcs,
db_file=db_file, snap_num=i, priority_spec=priority_spec)
wfs.append(_wf)
else:
for s in structures:
fw1 = OptimizeFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[], spec=priority_spec, **kwargs)
fw2 = StaticFW(s, vasp_cmd=vasp_cmd, db_file=db_file, parents=[fw1], spec=priority_spec)
wfs.append(Workflow([fw1, fw2], name=name + str(s.composition.reduced_formula)))
return wfs