def run_task(self, fw_spec): struct = self.get("structure") or fw_spec["structure"] s = Structure.from_dict(struct.as_dict()) user_incar_settings = fw_spec.get("user_incar_settings", {}) vasp_input_set = MPRelaxSet(s, user_incar_settings=user_incar_settings) dec = MontyDecoder() vis = dec.process_decoded(vasp_input_set.as_dict()) output_dir = os.getcwd() vis.write_input(output_dir=output_dir) return FWAction()
def wf_thermal_expansion(structure, c=None): """ Thermal expansion coefficient workflow from the given structure and config dict. Args: structure (Structure): input structure c (dict): workflow config dict Returns: Workflow """ c = c or {} eos = c.get("EOS", "vinet") vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) 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): wf = add_wf_metadata(wf, structure) return wf
def wf_bulk_modulus(structure, c=None): """ Bulk modulus workflow from the given structure and config dict. Args: structure (Structure): input structure c (dict): workflow config dict Returns: Workflow """ c = c or {} eos = c.get("EOS", "vinet") vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) user_kpoints_settings = {"grid_density": 7000} # 6 deformations deformations = [(np.identity(3) * (1 + x)).tolist() for x in np.linspace(-0.05, 0.05, 6)] tag = "bulk_modulus 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) # static input set for the transmute firework uis_static = {"ISIF": 2, "ISTART": 1, "IBRION": 2, "NSW": 99} # 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) vis_static = MPStaticSet(structure, force_gamma=True, lepsilon=False, user_kpoints_settings=user_kpoints_settings, user_incar_settings=uis_static) # get the deformations wflow for bulk modulus calculation wf_bm = get_wf_bulk_modulus(structure, eos=eos, user_kpoints_settings=user_kpoints_settings, deformations=deformations, vasp_cmd=vasp_cmd, db_file=db_file, tag=tag, vasp_input_set=vis_static) # chain it wf.append_wf(wf_bm, 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): wf = add_wf_metadata(wf, structure) return wf
def wf_gibbs_free_energy(structure, c=None): """ Gibbs free energy workflow from the given structure and config dict. Args: structure (Structure): input structure c (dict): workflow config dict Returns: Workflow """ c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) eos = c.get("EOS", "vinet") qha_type = c.get("QHA_TYPE", "debye_model") # min and max temp in K, default setting is to compute the properties at 300K only t_min = c.get("T_MIN", 300.0) t_max = c.get("T_MAX", 300.0) t_step = c.get("T_STEP", 100.0) pressure = c.get("PRESSURE", 0.0) poisson = c.get("POISSON", 0.25) anharmonic_contribution = c.get("ANHARMONIC_CONTRIBUTION", False) metadata = c.get("METADATA", None) # 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: raise RuntimeError( "'phonopy' package is NOT installed but is required for the final " "analysis step; you can alternatively switch to the qha_type to " "'debye_model' which does not require 'phonopy'.") vis_static = MPStaticSet(structure, force_gamma=True, lepsilon=lepsilon, user_kpoints_settings=user_kpoints_settings, user_incar_settings=uis_static) # get gibbs workflow and chain it to the optimization workflow wf_gibbs = get_wf_gibbs_free_energy( structure, user_kpoints_settings=user_kpoints_settings, deformations=deformations, vasp_cmd=vasp_cmd, db_file=db_file, eos=eos, qha_type=qha_type, pressure=pressure, poisson=poisson, t_min=t_min, t_max=t_max, t_step=t_step, metadata=metadata, anharmonic_contribution=anharmonic_contribution, tag=tag, vasp_input_set=vis_static) # chaining wf.append_wf(wf_gibbs, wf.leaf_fw_ids) wf = add_modify_incar(wf, modify_incar_params={ "incar_update": { "ENCUT": 600, "EDIFF": 1e-6, "LAECHG": False } }) wf = add_common_powerups(wf, c) if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf