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) user_kpoints_settings = c.get("user_kpoints_settings", {"grid_density": 7000}) deformations = c.get("deformations", [(np.identity(3)*(1+x)).tolist() for x in np.linspace(-0.1, 0.1, 10)]) pressure = c.get("pressure", 0.0) wf = 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) 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 test_modify_incar(self): my_wf = add_modify_incar(self._copy_wf(self.bs_wf), {"incar_update": {"NCORE": 1}}, fw_name_constraint="structure optimization") for fw in my_wf.fws: if "structure optimization" in fw.name: self.assertTrue("ModifyIncar" in fw.to_dict()["spec"]["_tasks"][1]["_fw_name"]) self.assertEqual(fw.to_dict()["spec"]["_tasks"][1]["incar_update"], {"NCORE": 1}) else: for t in fw.to_dict()["spec"]["_tasks"]: self.assertFalse("ModifyIncar" in t["_fw_name"])
def setUp(self): super(TestElasticWorkflow, self).setUp() self.tf_loc = os.path.join(ref_dir, 'elastic_wf') self.struct_si = PymatgenTest.get_structure("Si") self.struct_si = SpacegroupAnalyzer(self.struct_si).get_conventional_standard_structure() self.opt_struct = Structure.from_file(os.path.join(self.tf_loc, '1', 'inputs', 'POSCAR')) # Base WF self.base_wf = get_wf(self.struct_si, "optimize_only.yaml", params=[{"db_file": ">>db_file<<"}]) self.base_wf.append_wf(get_wf_elastic_constant(self.struct_si, db_file='>>db_file<<', stencils=[[0.01]]*3 + [[0.03]]*3, copy_vasp_outputs=True), self.base_wf.leaf_fw_ids) self.base_wf_noopt = get_wf_elastic_constant(self.opt_struct, stencils=[[0.01]]*3 + [[0.03]]*3, copy_vasp_outputs=False, sym_reduce=False, db_file='>>db_file<<') ec_incar_update = {'incar_update': {'EDIFF': 1e-6, 'ENCUT': 700}} self.base_wf = add_modify_incar(self.base_wf, ec_incar_update) self.base_wf_noopt = add_modify_incar(self.base_wf_noopt, ec_incar_update) # Full preset WF self.preset_wf = wf_elastic_constant(self.struct_si) # Minimal WF self.minimal_wf = wf_elastic_constant_minimal(self.opt_struct) self.minimal_wf = add_modify_incar(self.minimal_wf, ec_incar_update) # TOEC WF (minimal) self.toec_wf = wf_elastic_constant_minimal(self.struct_si, order=3) self.toec_wf = add_modify_incar(self.toec_wf, ec_incar_update) toec_data = loadfn(os.path.join(self.tf_loc, 'toec_data.json')) # Rather than run entire workflow, preload the spec to test the analysis toec_analysis = Firework([ElasticTensorToDb(structure=self.struct_si, order=3, db_file=">>db_file<<")], spec={"deformation_tasks": toec_data['deformation_tasks']}) self.toec_analysis = Workflow([toec_analysis]) # Check 4th order to see if constructed correctly self.foec_wf = wf_elastic_constant_minimal(self.struct_si, order=4)
def wf_piezoelectric_constant(structure, c=None): c = c or {} wf = wf_dielectric_constant(structure, c) wf = add_modify_incar(wf, modify_incar_params={"incar_update": {"ENCUT": 1000, "ADDGRID": True, "LREAL": False, "EDIFF": 1e-7} }, fw_name_constraint="static dielectric") for fw in wf.fws: fw.name = fw.name.replace("dielectric", "piezoelectric") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_elastic_constant(structure, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) user_kpoints_settings = c.get("user_kpoints_settings", {"grid_density": 7000}) norm_deformations = c.get("norm_deformations", [-0.01, -0.005, 0.005, 0.01]) shear_deformations = c.get("shear_deformations", [-0.06, -0.03, 0.03, 0.06]) wf = get_wf_elastic_constant(structure, vasp_cmd=vasp_cmd, norm_deformations=norm_deformations, shear_deformations=shear_deformations, db_file=db_file, user_kpoints_settings=user_kpoints_settings) mip = {"incar_update":{"ENCUT": 700, "EDIFF": 1e-6, "LAECHG":False}} wf = add_modify_incar(wf, modify_incar_params=mip) 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_raman_spectra(structure, c=None): """ Raman spectra workflow from the given structure and config dict Args: structure (Structure): input structure c (dict): workflow config dict Returns: Workflow """ c = c or {} wf = get_wf_raman_spectra(structure, modes=c.get("modes", None), step_size=c.get("step_size", 0.005), vasp_cmd=c.get("vasp_cmd", "vasp"), db_file=c.get("db_file", None)) wf = add_modify_incar(wf, modify_incar_params={"incar_update": {"ENCUT": 600, "EDIFF": 1e-6}}, fw_name_constraint="static dielectric") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
structure.replace_species({'O': 'N', 'N': 'O'}) structure.replace_species({ default_B: composition[1] }) #this will break if B-site is default_a but that shouldn't happen structure.replace_species({default_A: composition[0]}) poscar_key = tetra_dict[tilt_count] opt = OptimizeFW(structure, vasp_cmd='ibrun tacc_affinity vasp_std') stat = StaticFW(parents=opt, vasp_cmd='ibrun tacc_affinity vasp_std') wf = Workflow([opt, stat]) wf = add_modify_incar(wf, modify_incar_params={ 'incar_update': { 'KPAR': 2, 'NCORE': 4, 'NSIM': 8, 'EDIFF': 0.000002, 'LMAXMIX': 6, 'LSCALAPACK': '.FALSE.', 'ALGO': 'All' } }) wf = add_modify_incar(wf, modify_incar_params={ 'incar_update': { 'AMIX': 0.2, 'AMIX_MAG': 0.8, 'BMIX': 0.00001, 'BMIX_MAG': 0.00001, 'ICHARG': 2, 'EDIFFG': 0.0005 * site_num, 'KPAR': 1
def add_modify_incar_by_FWname(wf, modify_incar_params): from atomate.vasp.powerups import add_modify_incar for keyword in modify_incar_params.keys(): add_modify_incar(wf, modify_incar_params = modify_incar_params[keyword], fw_name_constraint = keyword)
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