"""Module defining Materials Project workflows.Reference: https://doi.org/10.1103/PhysRevMaterials.6.013801In case of questions, consult @Andrew-S-Rosen, @esoteric-ephemera or @janosh."""from__future__importannotationsimportloggingfromdataclassesimportdataclass,fieldfromtypingimportTYPE_CHECKINGfromjobflowimportFlow,Makerfrompymatgen.io.vasp.setsimportLobsterSetfromatomate2.lobster.jobsimportLobsterMakerfromatomate2.vasp.flows.coreimportDoubleRelaxMakerfromatomate2.vasp.flows.lobsterimportVaspLobsterMakerfromatomate2.vasp.jobs.mpimport(MPGGARelaxMaker,MPGGAStaticMaker,MPMetaGGARelaxMaker,MPMetaGGAStaticMaker,MPPreRelaxMaker,)logger=logging.getLogger(__name__)ifTYPE_CHECKING:frompathlibimportPathfrompymatgen.core.structureimportStructurefromatomate2.vasp.jobs.baseimportBaseVaspMaker
[docs]@dataclassclassMPGGADoubleRelaxMaker(DoubleRelaxMaker):"""MP GGA double relaxation workflow. Parameters ---------- name : str Name of the flows produced by this maker. relax_maker1 : .BaseVaspMaker Maker to generate the first relaxation. relax_maker2 : .BaseVaspMaker Maker to generate the second relaxation. """name:str="MP GGA double relax"relax_maker1:Maker|None=field(default_factory=MPGGARelaxMaker)relax_maker2:Maker=field(default_factory=lambda:MPGGARelaxMaker(copy_vasp_kwargs={"additional_vasp_files":("WAVECAR","CHGCAR")}))
[docs]@dataclassclassMPMetaGGADoubleRelaxMaker(DoubleRelaxMaker):"""MP meta-GGA double relaxation workflow. Parameters ---------- name : str Name of the flows produced by this maker. relax_maker1 : .BaseVaspMaker Maker to generate the first relaxation. relax_maker2 : .BaseVaspMaker Maker to generate the second relaxation. """name:str="MP meta-GGA double relax"relax_maker1:Maker|None=field(default_factory=MPPreRelaxMaker)relax_maker2:Maker=field(default_factory=lambda:MPMetaGGARelaxMaker(copy_vasp_kwargs={"additional_vasp_files":("WAVECAR","CHGCAR")}))
[docs]@dataclassclassMPGGADoubleRelaxStaticMaker(Maker):""" Maker to perform a VASP GGA relaxation workflow with MP settings. Only the middle job performing a PBE relaxation is non-optional. Parameters ---------- name : str Name of the flows produced by this maker. relax_maker : .BaseVaspMaker Maker to generate the relaxation. static_maker : .BaseVaspMaker Maker to generate the static calculation before the relaxation. """name:str="MP GGA relax"relax_maker:Maker=field(default_factory=MPGGADoubleRelaxMaker)static_maker:Maker|None=field(default_factory=lambda:MPGGAStaticMaker(copy_vasp_kwargs={"additional_vasp_files":("WAVECAR","CHGCAR")}))
[docs]defmake(self,structure:Structure,prev_dir:str|Path|None=None)->Flow:""" 1, 2 or 3-step flow with optional pre-relax and final static jobs. Parameters ---------- structure : .Structure A pymatgen structure object. prev_dir : str or Path or None A previous VASP calculation directory to copy output files from. Returns ------- Flow A flow containing the MP relaxation workflow. """relax_flow=self.relax_maker.make(structure=structure,prev_dir=prev_dir)output=relax_flow.outputjobs=[relax_flow]ifself.static_maker:# Run a static calculationstatic_job=self.static_maker.make(structure=output.structure,prev_dir=output.dir_name)output=static_job.outputjobs+=[static_job]returnFlow(jobs=jobs,output=output,name=self.name)
[docs]@dataclassclassMPMetaGGADoubleRelaxStaticMaker(MPGGADoubleRelaxMaker):""" Flow with optional pre-relax and final static jobs. Only the middle job performing a meta-GGA relaxation is non-optional. Parameters ---------- name : str Name of the flows produced by this maker. relax_maker : .BaseVaspMaker Maker to generate the relaxation. static_maker : .BaseVaspMaker Maker to generate the static calculation before the relaxation. """name:str="MP meta-GGA relax"relax_maker:Maker=field(default_factory=MPMetaGGADoubleRelaxMaker)static_maker:Maker|None=field(default_factory=lambda:MPMetaGGAStaticMaker(copy_vasp_kwargs={"additional_vasp_files":("WAVECAR","CHGCAR")}))
[docs]defmake(self,structure:Structure,prev_dir:str|Path|None=None)->Flow:"""Make a 2-step flow with a cheap pre-relaxation, then a high-quality one. An optional static calculation can be performed before the relaxation. Parameters ---------- structure : .Structure A pymatgen structure object. prev_dir : str or Path or None A previous VASP calculation directory to copy output files from. Returns ------- Flow A flow containing the MP relaxation workflow. """relax_flow=self.relax_maker.make(structure=structure,prev_dir=prev_dir)output=relax_flow.outputjobs=[relax_flow]ifself.static_maker:# Run a static calculation (typically r2SCAN)static_job=self.static_maker.make(structure=output.structure,prev_dir=output.dir_name)output=static_job.outputjobs+=[static_job]returnFlow(jobs=jobs,output=output,name=self.name)
# update potcars to 54, use correct W potcar# use staticmaker for compatibility
[docs]@dataclassclassMPVaspLobsterMaker(VaspLobsterMaker):""" Maker to perform a Lobster computation. The calculations performed are: 1. Optional optimization. 2. Static calculation with ISYM=0. 3. Several Lobster computations testing several basis sets are performed. .. Note:: The basis sets can only be changed with yaml files. Parameters ---------- name : str Name of the flows produced by this maker. relax_maker : .BaseVaspMaker or None A maker to perform a relaxation on the bulk. Set to ``None`` to skip the bulk relaxation. lobster_static_maker : .BaseVaspMaker A maker to perform the computation of the wavefunction before the static run. Cannot be skipped. It can be LOBSTERUNIFORM or LobsterStaticMaker() lobster_maker : .LobsterMaker A maker to perform the Lobster run. delete_wavecars : bool If true, all WAVECARs will be deleted after the run. address_min_basis : str A path to a yaml file including basis set information. address_max_basis : str A path to a yaml file including basis set information. """name:str="lobster"relax_maker:BaseVaspMaker|None=field(default_factory=MPGGADoubleRelaxMaker)lobster_static_maker:BaseVaspMaker=field(default_factory=lambda:MPGGAStaticMaker(input_set_generator=LobsterSet()))lobster_maker:LobsterMaker|None=field(default_factory=LobsterMaker)delete_wavecars:bool=Trueaddress_min_basis:str|None=Noneaddress_max_basis:str|None=None