def wf_bandstructure_hse(structure, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) wf_src_name = "bandstructure_hse_full.yaml" wf = get_wf(structure, wf_src_name, vis=MPHSERelaxSet(structure, force_gamma=True), common_params={ "vasp_cmd": vasp_cmd, "db_file": db_file }) wf = add_common_powerups(wf, c) if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY): wf = add_small_gap_multiply(wf, 0.5, 5, "static") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_bandstructure_plus_boltztrap(structure, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) params = [] for x in range(4): params.append({"vasp_cmd": vasp_cmd, "db_file": db_file}) params.append({"db_file": db_file}) wf = get_wf(structure, "bandstructure_boltztrap.yaml", vis=MPRelaxSet(structure, force_gamma=True), params=params) wf = add_common_powerups(wf, c) if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY): wf = add_small_gap_multiply(wf, 0.5, 5, "static") wf = add_small_gap_multiply(wf, 0.5, 5, "nscf") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_bandstructure_plus_boltztrap(structure, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) params = [] for x in range(4): # everything but BoltzTrap task params.append({"vasp_cmd": vasp_cmd, "db_file": db_file}) params.append({"db_file": db_file}) wf = get_wf(structure, "bandstructure_boltztrap.yaml", vis=MPRelaxSet(structure, force_gamma=True), params=params) wf = add_common_powerups(wf, c) if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY): wf = add_small_gap_multiply(wf, 0.5, 5, "static") wf = add_small_gap_multiply(wf, 0.5, 5, "nscf") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_bandstructure_plus_hse(structure, gap_only=True, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) if gap_only: wf_src_name = "bandstructure_hsegap.yaml" else: wf_src_name = "bandstructure_hse.yaml" wf = get_wf(structure, wf_src_name, vis=MPRelaxSet(structure, force_gamma=True), common_params={"vasp_cmd": vasp_cmd, "db_file": db_file}) wf = add_common_powerups(wf, c) if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY): wf = add_small_gap_multiply(wf, 0.5, 5, "static") wf = add_small_gap_multiply(wf, 0.5, 5, "nscf") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_bandstructure2D(structure, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) vdw_kernel = c.get("VDW_KERNEL_DIR", VDW_KERNEL_DIR) incar = _read_user_incar('Relax2D.txt') print(incar) mpr2d = MPRelaxSet(structure, force_gamma=True, user_incar_settings=incar) mpr2dstatic = MPRelaxSet(structure, force_gamma=True, user_incar_settings={ "NEDOS": "3001", "EMIN": "-15.0", "EMAX": "15.0" }) #fws = [OptimizeFW2D(structure=structure, vasp_input_set=mpr2d, vasp_cmd=vasp_cmd, db_file=db_file, vdw_kernel_dir=vdw_kernel)] fws = [ OptimizeFW2D(structure=structure, vasp_input_set=mpr2d, vasp_cmd=vasp_cmd, vdw_kernel_dir=vdw_kernel) ] fws.append(StaticFW2D(parents=fws[0], vasp_input_set=mpr2dstatic)) #fws.append(NonSCFFW2D(parents=fws[1], mode='uniform')) fws.append(NonSCFFW2D(parents=fws[1], mode='line')) wf = Workflow(fws) '''check bandstructure.yaml''' ''' wf = get_wf(structure, "bandstructure.yaml", vis=MPScanRelaxSet2D(structure, force_gamma=True,), \ params=[{'vasp_input_set': mpr2d},{},{},{}], common_params={"vasp_cmd": vasp_cmd, "db_file": db_file,}) #"vdw_kernel_dir": vdw_kernel}) ''' wf = add_common_powerups(wf, c) if c.get("SMALLGAP_KPOINT_MULTIPLY", SMALLGAP_KPOINT_MULTIPLY): wf = add_small_gap_multiply(wf, 0.5, 5, "static") wf = add_small_gap_multiply(wf, 0.5, 5, "nscf") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) wf.name = "{}:{}".format(structure.composition.reduced_formula, "bandStructure") ''' fws = wf.fws fws[0] = new_firework print(fws) ''' return wf
def get_wf(self, c=None): """ Get the workflow. Returns: Workflow """ c = c or {"VASP_CMD": VASP_CMD, "DB_FILE": DB_FILE} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) nsites = len(self.structure.sites) vis = MPRelaxSet(self.structure, potcar_functional="PBE_54", force_gamma=True) opt_fw = OptimizeFW( self.structure, vasp_input_set=vis, vasp_cmd=c["VASP_CMD"], db_file=c["DB_FILE"], ) vis = MPStaticSet(self.structure, potcar_functional="PBE_54", force_gamma=True) static_fw = StaticFW( self.structure, vasp_input_set=vis, vasp_cmd=c["VASP_CMD"], db_file=c["DB_FILE"], parents=[opt_fw], ) # Separate FW for each BZ surface calc # Run Z2Pack on unique TRIM planes in the BZ surfaces = ["kx_0", "kx_1"] equiv_planes = self.get_equiv_planes() # Only run calcs on inequivalent BZ surfaces if self.symmetry_reduction: for add_surface in equiv_planes.keys(): mark = True for surface in surfaces: if surface in equiv_planes[add_surface]: mark = False if mark and add_surface not in surfaces: surfaces.append(add_surface) else: # 4 TRI surfaces define Z2 in 3D surfaces = ["kx_1", "ky_1", "kz_0", "kz_1"] z2pack_fws = [] for surface in surfaces: z2pack_fw = Z2PackFW( parents=[static_fw], structure=self.structure, surface=surface, uuid=self.uuid, name="z2pack", vasp_cmd=c["VASP_CMD"], db_file=c["DB_FILE"], ) z2pack_fws.append(z2pack_fw) analysis_fw = InvariantFW( parents=z2pack_fws, structure=self.structure, symmetry_reduction=self.symmetry_reduction, equiv_planes=equiv_planes, uuid=self.uuid, name="invariant", db_file=c["DB_FILE"], ) fws = [opt_fw, static_fw] + z2pack_fws + [analysis_fw] wf = Workflow(fws) wf = add_additional_fields_to_taskdocs(wf, {"wf_meta": self.wf_meta}) # Add vdW corrections if structure is layered dim_data = StructureDimensionality(self.structure) if np.any( [ dim == 2 for dim in [dim_data.larsen_dim, dim_data.cheon_dim, dim_data.gorai_dim] ] ): wf = add_modify_incar( wf, modify_incar_params={ "incar_update": { "IVDW": 11, "EDIFFG": 0.005, "IBRION": 2, "NSW": 100, } }, fw_name_constraint="structure optimization", ) wf = add_modify_incar( wf, modify_incar_params={"incar_update": {"IVDW": 11}}, fw_name_constraint="static", ) wf = add_modify_incar( wf, modify_incar_params={"incar_update": {"IVDW": 11}}, fw_name_constraint="z2pack", ) else: wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"EDIFFG": 0.005, "IBRION": 2, "NSW": 100} }, fw_name_constraint="structure optimization", ) # Helpful vasp settings and no parallelization wf = add_modify_incar( wf, modify_incar_params={ "incar_update": { "ADDGRID": ".TRUE.", "LASPH": ".TRUE.", "GGA": "PS", "NCORE": 1, } }, ) # Generate inputs for Z2Pack with a static calc wf = add_modify_incar( wf, modify_incar_params={"incar_update": {"PREC": "Accurate"}}, fw_name_constraint="static", ) wf = add_common_powerups(wf, c) wf.name = "{} {}".format(self.structure.composition.reduced_formula, "Z2Pack") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, self.structure) tag = "z2pack: {}".format(self.uuid) wf = add_tags(wf, [tag]) return wf
def wf_irvsp(structure, magnetic=False, soc=False, v2t=False, c=None): """ Fireworks workflow for running an irvsp calculation. Optionally performs a vasp2trace calculation. Args: structure (Structure): Pymatgen structure object magnetic (bool): Whether the calculation is on a magnetic structure soc (bool): Spin-orbit coupling included v2t (bool): Do a vasp2trace calculation in addition to irvsp. Returns: Workflow """ c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) uuid = str(uuid4()) wf_meta = {"wf_uuid": uuid, "wf_name": "Irvsp WF"} magmoms = None if magnetic and "magmom" in structure.site_properties: magmoms_orig = structure.site_properties["magmom"] magmoms = [str(m) for m in magmoms_orig] magmoms = " ".join(magmoms) elif magnetic: raise RuntimeError( "Structure must have magnetic moments in site_properties for magnetic calcualtion!" ) ncoords = 3 * len(structure.sites) nbands = 0 for site in structure.sites: nbands += site.species.total_electrons trim_kpoints = Kpoints( comment="TRIM Points", num_kpts=8, style=Kpoints.supported_modes.Reciprocal, kpts=( (0, 0, 0), (0.5, 0, 0), (0, 0.5, 0), (0, 0, 0.5), (0.5, 0.5, 0), (0, 0.5, 0.5), (0.5, 0, 0.5), (0.5, 0.5, 0.5), ), kpts_shift=(0, 0, 0), kpts_weights=[1, 1, 1, 1, 1, 1, 1, 1], coord_type="Reciprocal", labels=["gamma", "x", "y", "z", "s", "t", "u", "r"], tet_number=0, tet_weight=0, tet_connections=None, ) # params dicts for wf params = [ {}, # optimization {}, # standardization {}, # static { "input_set_overrides": { "other_params": {"user_kpoints_settings": trim_kpoints} } }, # nscf {"wf_uuid": uuid}, # irvsp ] if magnetic and v2t: yaml_spec = "irvsp_v2t_magnetic.yaml" params.append({}) elif v2t: yaml_spec = "irvsp_v2t.yaml" params.append({}) else: yaml_spec = "irvsp.yaml" wf = get_wf( structure, yaml_spec, params=params, vis=MPStaticSet(structure, potcar_functional="PBE_54", force_gamma=True), common_params={"vasp_cmd": vasp_cmd, "db_file": db_file}, wf_metadata=wf_meta, ) dim_data = StructureDimensionality(structure) if np.any( [ dim == 2 for dim in [dim_data.larsen_dim, dim_data.cheon_dim, dim_data.gorai_dim] ] ): wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"IVDW": 11, "EDIFFG": 0.005, "IBRION": 2, "NSW": 100} }, fw_name_constraint="structure optimization", ) else: wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"EDIFFG": 0.005, "IBRION": 2, "NSW": 100} }, fw_name_constraint="structure optimization", ) wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"ADDGRID": ".TRUE.", "LASPH": ".TRUE.", "GGA": "PS"} }, ) # Includ ncl magmoms with saxis = (0, 0, 1) if magnetic and soc: magmoms = [] for m in magmoms_orig: magmoms += [0.0, 0.0, m] magmoms = [str(m) for m in magmoms] magmoms = " ".join(magmoms) wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"ISYM": 2, "MAGMOM": "%s" % magmoms} }, ) if magnetic and not soc: # Include magmoms in every calculation wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"ISYM": 2, "MAGMOM": "%s" % magmoms, "ISPIN": 2} }, ) wf = add_modify_incar( wf, modify_incar_params={ "incar_update": { "ISYM": 2, "LSORBIT": ".TRUE." if soc else ".FALSE.", "MAGMOM": "%s" % magmoms if magnetic else "%i*0.0" % ncoords, "ISPIN": 2 if magnetic and not soc else 1, "LWAVE": ".TRUE.", # "NBANDS": nbands, } }, fw_name_constraint="nscf", ) wf = add_common_powerups(wf, c) wf = add_additional_fields_to_taskdocs(wf, {"wf_meta": wf_meta}, task_name_constraint="VaspToDb") if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_vasp2trace_magnetic(structure, c=None): """ Fireworks workflow for running a vasp2trace calculation on a magnetic material. Args: structure (Structure): Pymatgen structure object with magmom site property. Returns: Workflow """ c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) ncoords = 3 * len(structure.sites) if "magmom" in structure.site_properties: magmoms = structure.site_properties["magmom"] magmoms = [str(m) for m in magmoms] magmoms = " ".join(magmoms) nbands = 0 for site in structure.sites: nbands += site.species.total_electrons trim_kpoints = Kpoints( comment="TRIM Points", num_kpts=8, style=Kpoints.supported_modes.Reciprocal, kpts=( (0, 0, 0), (0.5, 0, 0), (0, 0.5, 0), (0, 0, 0.5), (0.5, 0.5, 0), (0, 0.5, 0.5), (0.5, 0, 0.5), (0.5, 0.5, 0.5), ), kpts_shift=(0, 0, 0), kpts_weights=[1, 1, 1, 1, 1, 1, 1, 1], coord_type="Reciprocal", labels=["gamma", "x", "y", "z", "s", "t", "u", "r"], tet_number=0, tet_weight=0, tet_connections=None, ) wf_path = os.path.join(os.path.dirname(__file__), "vasp2trace_magnetic.yaml") wf = get_wf( structure, wf_path, params=[ {}, {}, { "input_set_overrides": { "other_params": {"user_kpoints_settings": trim_kpoints} } }, {}, ], vis=MPStaticSet(structure, potcar_functional="PBE_54", force_gamma=True), common_params={"vasp_cmd": vasp_cmd, "db_file": db_file}, ) dim_data = StructureDimensionality(structure) if np.any( [ dim == 2 for dim in [dim_data.larsen_dim, dim_data.cheon_dim, dim_data.gorai_dim] ] ): wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"IVDW": 11, "EDIFFG": 0.005, "IBRION": 2, "NSW": 100} }, fw_name_constraint="structure optimization", ) else: wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"EDIFFG": 0.005, "IBRION": 2, "NSW": 100} }, fw_name_constraint="structure optimization", ) wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"ADDGRID": ".TRUE.", "LASPH": ".TRUE.", "GGA": "PS"} }, ) # Include magmoms in every calculation wf = add_modify_incar( wf, modify_incar_params={ "incar_update": {"ISYM": 2, "MAGMOM": "%s" % magmoms, "ISPIN": 2} }, ) # Spin-polarized band structure wf = add_modify_incar( wf, modify_incar_params={ "incar_update": { "ISYM": 2, "LSORBIT": ".FALSE.", "MAGMOM": "%s" % magmoms, "ISPIN": 2, "LWAVE": ".TRUE.", "NBANDS": nbands, } }, fw_name_constraint="nscf", ) wf = add_common_powerups(wf, c) if c.get("STABILITY_CHECK", STABILITY_CHECK): wf = add_stability_check(wf, fw_name_constraint="structure optimization") if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf