Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_final_run_fws(self, structure, target_steps=40000, copy_calcs=False, calc_home=None,
run_steps=5000, run_time = 86400, temperature=2500, vasp_cmd=">>vasp_cmd<<", db_file=None, name="longrun",
optional_MDWF_params=None, override_default_vasp_params=None, vasp_input_set=None, priority_spec={}):
fw_list = []
_steps = 0
spawn_count = 0
optional_MDWF_params = optional_MDWF_params or {}
optional_MDWF_params['spec'] = priority_spec
override_default_vasp_params = override_default_vasp_params or {}
override_default_vasp_params['user_incar_settings'] = override_default_vasp_params.get(
'user_incar_settings') or {}
override_default_vasp_params['user_incar_settings'].update({"ISIF": 1, "LWAVE": False})
fw1 = MDFW(structure=structure, start_temp=temperature, end_temp=temperature, nsteps=run_steps,
name=name + "_" + str(spawn_count), vasp_input_set=vasp_input_set, db_file=db_file,
vasp_cmd=vasp_cmd, wall_time=run_time, copy_vasp_outputs=False, override_default_vasp_params=override_default_vasp_params,
**optional_MDWF_params)
_steps += run_steps
spawn_count += 1
fw_list.append(fw1)
while _steps < target_steps:
_name = (name + "_" + str(spawn_count))
t = []
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"]))
if spawn_count == 1:
if copy_calcs:
t.append(CopyCalsHome(calc_home=calc_home, run_name=name + "_0"))
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, gamma_vasp_cmd=">>gamma_vasp_cmd<<",
handler_group="md", wall_time=run_time, gzip_output=False))
t = []
if copy_vasp_outputs:
t.append(CopyVaspOutputs(calc_loc=True, additional_files=["CHGCAR"],
contcar_to_poscar=True))
t.append(WriteVaspFromIOSet(structure=structure,
vasp_input_set=vasp_input_set))
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd,
gamma_vasp_cmd=">>gamma_vasp_cmd<<",
handler_group="md", wall_time=wall_time))
t.append(PassCalcLocs(name=name))
t.append(VaspToDb(db_file=db_file,
additional_fields={"task_label": name},
defuse_unsuccessful=False))
super(MDFW, self).__init__(t, parents=parents,
name="{}-{}".format(
structure.composition.reduced_formula,
name),
**kwargs)
def get_final_run_fws(self, structure, target_steps=40000, copy_calcs=False, calc_home=None,
run_steps=5000, run_time = 86400, temperature=2500, vasp_cmd=">>vasp_cmd<<", db_file=None, name="longrun",
optional_MDWF_params=None, override_default_vasp_params=None, vasp_input_set=None, priority_spec={}):
fw_list = []
_steps = 0
spawn_count = 0
optional_MDWF_params = optional_MDWF_params or {}
optional_MDWF_params['spec'] = priority_spec
override_default_vasp_params = override_default_vasp_params or {}
override_default_vasp_params['user_incar_settings'] = override_default_vasp_params.get(
'user_incar_settings') or {}
override_default_vasp_params['user_incar_settings'].update({"ISIF": 1, "LWAVE": False})
fw1 = MDFW(structure=structure, start_temp=temperature, end_temp=temperature, nsteps=run_steps,
name=name + "_" + str(spawn_count), vasp_input_set=vasp_input_set, db_file=db_file,
vasp_cmd=vasp_cmd, wall_time=run_time, override_default_vasp_params=override_default_vasp_params,
**optional_MDWF_params)
_steps += run_steps
spawn_count += 1
fw_list.append(fw1)
while _steps < target_steps:
_name = (name + "_" + str(spawn_count))
t = []
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"]))
if spawn_count == 1:
if copy_calcs:
t.append(CopyCalsHome(calc_home=calc_home, run_name=name + "_0"))
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, gamma_vasp_cmd=">>gamma_vasp_cmd<<",
handler_group="md", wall_time=run_time, gzip_output=False))
# If structure is in fact just a composition, create a random packed Structure!
if not isinstance(structure, Structure) and isinstance(structure, dict):
if not amorphous_maker_params:
raise ValueError("amorphous_maker_params must be defined!")
glass = AmorphousMaker(structure, **amorphous_maker_params)
structure = glass.random_packed_structure
# Add specs to VASP/MD run
optional_MDWF_params = optional_MDWF_params or {}
optional_MDWF_params['spec'] = priority_spec
override_default_vasp_params = override_default_vasp_params or {}
override_default_vasp_params['user_incar_settings'] = override_default_vasp_params.get('user_incar_settings') or {}
override_default_vasp_params['user_incar_settings'].update({"ISIF": 1, "LWAVE": False})
# Construct MD firework from atomate for initial run
fw1 = MDFW(structure=structure, start_temp=temperature, end_temp=temperature, nsteps=nsteps,
name=name + "run0", vasp_input_set=vasp_input_set, db_file=db_file,
vasp_cmd=vasp_cmd, wall_time=wall_time, copy_vasp_outputs=False, override_default_vasp_params=override_default_vasp_params,
**optional_MDWF_params)
# Copy calculations into external directory
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="run0"))
# Add pressure convergence Task
t.append(SpawnMDFWTask(pressure_threshold=pressure_threshold, max_rescales=max_rescales,
wall_time=wall_time, vasp_cmd=vasp_cmd, db_file=db_file,
copy_calcs=copy_calcs, calc_home=calc_home,
spawn_count=0, cool=cool, final_run=final_run, diffusion=diffusion,
:param wflow_name:
:param priority_spec:
:return:
"""
optional_MDWF_params = optional_MDWF_params or {}
optional_MDWF_params['spec'] = priority_spec
override_default_vasp_params = override_default_vasp_params or {}
override_default_vasp_params['user_incar_settings'] = override_default_vasp_params.get('user_incar_settings') or {}
override_default_vasp_params['user_incar_settings'].update({"ISIF": 1, "LWAVE": False})
fw_list = []
temperature = start_temp
# Firework for first cool step
fw1 = MDFW(structure=structure, start_temp=start_temp, end_temp=start_temp - temp_decrement, nsteps=nsteps_cool,
name=name + "_cool_" + str(start_temp - temp_decrement), vasp_input_set=vasp_input_set, db_file=db_file,
vasp_cmd=vasp_cmd, wall_time=wall_time, copy_vasp_outputs=False, override_default_vasp_params=override_default_vasp_params,
**optional_MDWF_params)
fw_list.append(fw1)
t = []
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"]))
if copy_calcs:
t.append(
CopyCalsHome(calc_home=os.path.join(calc_home, name), run_name="cool_" + str(start_temp - temp_decrement)))
# Firework for first hold step
t.append(WriteSetTask(start_temp= start_temp - temp_decrement, end_temp = start_temp - temp_decrement, nsteps= nsteps_hold))
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, gamma_vasp_cmd=">>gamma_vasp_cmd<<",
handler_group="md", wall_time=wall_time, gzip_output=False))
t.append(PassCalcLocs(name=str(name) + "_hold_" + str(start_temp - temp_decrement)))
raise ValueError("calc_home must be an existing folder.")
elif os.path.exists(calc_home + "/" + name):
raise ValueError("WF name already exists, choose a different name.")
else:
calc_home = os.path.join(calc_home, name)
os.mkdir(calc_home)
# If structure is in fact just a composition, create a random packed Structure!
if not isinstance(structure, Structure) and isinstance(structure, dict):
if not amorphous_maker_params:
raise ValueError("amorphous_maker_params must be defined!")
glass = AmorphousMaker(structure, **amorphous_maker_params)
structure = glass.random_packed_structure
# Create FW for first AIMD simulation
fw1 = MDFW(structure=structure, start_temp=temperature, end_temp=temperature, nsteps=nsteps,
name=name + "run0", vasp_input_set=vasp_input_set, db_file=db_file,
vasp_cmd=vasp_cmd, wall_time=wall_time, override_default_vasp_params=override_default_vasp_params,
**optional_MDWF_params)
#Create FW that converges desired property
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="run0"))
t.append(SpawnMDFWTask(pressure_threshold=pressure_threshold, max_rescales=max_rescales,
wall_time=wall_time, vasp_cmd=vasp_cmd, db_file=db_file,
copy_calcs=copy_calcs, calc_home=calc_home,
spawn_count=0, cool=cool, final_run=final_run, diffusion=diffusion,
temperature=temperature, priority_spec=priority_spec))
fw2 = Firework(t, parents=[fw1], name=name + "_initial_spawn", spec=priority_spec)
vasp_input_set=None, vasp_cmd=">>vasp_cmd<<", db_file=">>db_file<<", name="anneal",
optional_MDWF_params=None, override_default_vasp_params=None,
copy_calcs=False, calc_home="~/wflows", diffusion=False, wflow_name="", priority_spec={}):
temperature = start_temp
optional_MDWF_params = optional_MDWF_params or {}
optional_MDWF_params['spec'] = priority_spec
override_default_vasp_params = override_default_vasp_params or {}
override_default_vasp_params['user_incar_settings'] = override_default_vasp_params.get('user_incar_settings') or {}
override_default_vasp_params['user_incar_settings'].update({"ISIF": 1, "LWAVE": False})
fw_list = []
# Run first cool step
fw1 = MDFW(structure=structure, start_temp=start_temp, end_temp=start_temp - temp_decrement, nsteps=nsteps_cool,
name=name + "_cool_" + str(start_temp - temp_decrement), vasp_input_set=vasp_input_set, db_file=db_file,
vasp_cmd=vasp_cmd, wall_time=wall_time, override_default_vasp_params=override_default_vasp_params,
**optional_MDWF_params)
fw_list.append(fw1)
t = []
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"]))
if copy_calcs:
t.append(
CopyCalsHome(calc_home=os.path.join(calc_home, name), run_name="cool_" + str(start_temp - temp_decrement)))
# Run first hold step
t.append(WriteSetTask(start_temp= start_temp - temp_decrement, end_temp = start_temp - temp_decrement, nsteps= nsteps_hold))
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, gamma_vasp_cmd=">>gamma_vasp_cmd<<",
handler_group="md", wall_time=wall_time, gzip_output=False))