Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xdat = Xdatcar(os.path.join(os.getcwd(),'XDATCAR.gz'))
else:
xdat = Xdatcar(os.path.join(os.getcwd(), 'XDATCAR'))
# Grab structure of final frame in MD run
structure = xdat.structures[len(xdat.structures)-1]
name = str(structure.composition.reduced_formula)
temps = self.get("temps", [500, 1000, 1500])
# Generate workflows for finding density
wfs = []
for temp in temps:
_wf = get_wf_density(structure=structure, temperature=temp, pressure_threshold=5,
name = name+"_snap_"+str(snap_num)+'_diffusion_'+str(temp), db_file=db_file,
copy_calcs=copy_calcs, calc_home=calc_home, cool=False, diffusion=True, priority_spec=priority_spec)
wf = powerups.add_modify_incar_envchk(_wf)
wfs.append(wf)
# Add workflows to launchpad
lp = LaunchPad.auto_load()
for wf in wfs:
lp.add_wf(wf)
return FWAction()
:return:
"""
structures = get_sample_structures(xdatcar_path=xdatcar_file, n=n, steps_skip_first=steps_skip_first)
wfs = []
if sim_anneal:
# Molecular dynamics in alternating cool and hold stages until desired temp is reached.
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
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=name + "_hold_" + str(temperature - temp_decrement)))
if copy_calcs:
t.append(CopyCalsHome(calc_home=os.path.join(calc_home, name),
run_name="hold_" + str(temperature - temp_decrement)))
if temperature == end_temp+temp_decrement:
t.append(RelaxStaticTask(copy_calcs=copy_calcs, calc_home=calc_home, db_file=db_file, snap_num=snap_num, priority_spec=priority_spec))
if diffusion:
t.append(DiffusionTask(copy_calcs=copy_calcs, calc_home=calc_home, db_file=db_file, snap_num=snap_num, priority_spec=priority_spec))
fw_list.append(Firework(t, name=name+"_hold_"+str(temperature-temp_decrement), parents=[fw_list[len(fw_list)-1]], spec=priority_spec))
temperature -= temp_decrement
wf = Workflow(fw_list, name=wflow_name + "_" + name + "simulated_anneal_WF")
wf = powerups.add_modify_incar_envchk(wf)
return wf
_name = "longrun"
fw_list = self.get_final_run_fws(_poscar.structure, name=_name, copy_calcs=copy_calcs,
calc_home=calc_home, target_steps=_steps, temperature=temperature,
priority_spec=priority_spec)
if snaps:
t = []
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR"]))
t.append(StructureSamplerTask(copy_calcs=copy_calcs, calc_home=calc_home, n_snapshots=snaps, priority_spec=priority_spec))
if len(fw_list) > 0:
new_fw = Firework(t, name=name + "structure_sampler", parents=fw_list[len(fw_list)-1], spec=priority_spec)
else:
new_fw = Firework(t, name=name + "structure_sampler", spec=priority_spec)
fw_list.append(new_fw)
if snaps or final_run:
wf = Workflow(fw_list, name=name + "_" + str(temperature) + "_longruns")
wf = powerups.add_modify_incar_envchk(wf)
return FWAction(stored_data={'pressure':p, 'density_calculated': True}, additions=wf)
return FWAction(stored_data={'pressure':p, 'density_calculated': True})
priority_spec = self.get("priority_spec", {})
if os.path.exists(os.path.join(os.getcwd(),'XDATCAR.gz')):
xdat = Xdatcar(os.path.join(os.getcwd(),'XDATCAR.gz'))
else:
xdat = Xdatcar(os.path.join(os.getcwd(), 'XDATCAR'))
structure = xdat.structures[len(xdat.structures)-1]
name = str(structure.composition.reduced_formula)
temps = self.get("temps", [500, 1000, 1500])
wfs = []
for temp in temps:
_wf = get_wf_density(structure=structure, temperature=temp, pressure_threshold=5,
name = name+"_snap_"+str(snap_num)+'_diffusion_'+str(temp), db_file=db_file,
copy_calcs=copy_calcs, calc_home=calc_home, cool=False, diffusion=True, priority_spec=priority_spec)
_wf = powerups.add_modify_incar_envchk(_wf)
wfs.append(_wf)
return FWAction(additions=wfs)
: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