diff --git a/pyproject.toml b/pyproject.toml index d824247a8..876a916f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ requires-python = ">=3.10,<3.12" dependencies = [ "pymatgen>=2024.9.17.1", - "atomate2[strict]>=0.0.19", + "atomate2[strict]>=0.0.21", "ase==3.23.0", "calorine>=3.0", "matgl==1.1.3", @@ -67,7 +67,7 @@ workflow-managers = [ strict = [ "calorine==3.0", "pymatgen==2024.11.13", #? - "atomate2[strict]==0.0.19", + "atomate2[strict]==0.0.21", "matgl==1.1.3", "quippy-ase==0.9.14; python_version < '3.12'", "torch==2.2.1", diff --git a/src/autoplex/auto/phonons/flows.py b/src/autoplex/auto/phonons/flows.py index 97cf207a2..703a50a3e 100644 --- a/src/autoplex/auto/phonons/flows.py +++ b/src/autoplex/auto/phonons/flows.py @@ -73,6 +73,9 @@ class CompleteDFTvsMLBenchmarkWorkflow(Maker): The total number of randomly displaced structures to be generated. displacement_maker: BaseVaspMaker Maker used for a static calculation for a supercell. + pre_relax_maker: BaseVaspMaker + Maker used for the bulk relax unit cell calculation + before the phonon_relax_maker or rattled_relax_maker. phonon_bulk_relax_maker: BaseVaspMaker Maker used for the bulk relax unit cell calculation. rattled_bulk_relax_maker: BaseVaspMaker @@ -181,7 +184,7 @@ class CompleteDFTvsMLBenchmarkWorkflow(Maker): add_dft_rattled_struct: bool = True add_rss_struct: bool = False displacement_maker: BaseVaspMaker = None - phonon_bulk_relax_maker: BaseVaspMaker | None = field( + pre_relax_maker: BaseVaspMaker | None = field( default_factory=lambda: DoubleRelaxMaker.from_relax_maker( TightRelaxMaker( name="dft tight relax", @@ -210,32 +213,9 @@ class CompleteDFTvsMLBenchmarkWorkflow(Maker): ) ) ) + phonon_bulk_relax_maker: BaseVaspMaker | None = None phonon_static_energy_maker: BaseVaspMaker | None = None - - rattled_bulk_relax_maker: BaseVaspMaker | None = field( - default_factory=lambda: TightRelaxMaker( - run_vasp_kwargs={"handlers": {}}, - input_set_generator=TightRelaxSetGenerator( - user_incar_settings={ - "ALGO": "Normal", - "ISPIN": 1, - "LAECHG": False, - "ISYM": 0, # to be changed - "ISMEAR": 0, - "SIGMA": 0.05, # to be changed back - "LCHARG": False, # Do not write the CHGCAR file - "LWAVE": False, # Do not write the WAVECAR file - "LVTOT": False, # Do not write LOCPOT file - "LORBIT": None, # No output of projected or partial DOS in EIGENVAL, PROCAR and DOSCAR - "LOPTICS": False, # No PCDAT file - "NSW": 200, - "NELM": 500, - # to be removed - "NPAR": 4, - } - ), - ) - ) + rattled_bulk_relax_maker: BaseVaspMaker | None = None isolated_atom_maker: IsoAtomStaticMaker | None = None n_structures: int = 10 displacements: list[float] = field(default_factory=lambda: [0.01]) @@ -342,16 +322,22 @@ def make( ), default_hyperparameters["GAP"]["soap"], ) - # add an optional pre-optimization step here for structure, mp_id in zip(structure_list, mp_ids): + if self.pre_relax_maker is not None: + pre_relax_job = self.pre_relax_maker.make(structure) + flows.append(pre_relax_job) + new_structure = pre_relax_job.output.structure + pre_relax_job.name = "dft tight relax" + else: + new_structure = structure self.supercell_settings.setdefault(mp_id, {}) logging.warning( "Currently, " "the same supercell settings for single-atom displaced and rattled supercells are used." ) supercell_matrix_job = reduce_supercell_size_job( - structure=structure, + structure=new_structure, min_length=self.supercell_settings.get("min_length", 15), max_length=self.supercell_settings.get("max_length", 20), fallback_min_length=self.supercell_settings.get( @@ -371,7 +357,7 @@ def make( if self.add_dft_rattled_struct: add_dft_ratt = self.add_dft_rattled( - structure=structure, + structure=new_structure, mp_id=mp_id, displacement_maker=self.displacement_maker, rattled_bulk_relax_maker=self.rattled_bulk_relax_maker, @@ -399,7 +385,7 @@ def make( fit_input.update({mp_id: add_dft_ratt.output}) if self.add_dft_phonon_struct: add_dft_phon = self.add_dft_phonons( - structure=structure, + structure=new_structure, mp_id=mp_id, displacements=self.displacements, symprec=self.symprec, @@ -465,6 +451,13 @@ def make( for ibenchmark_structure, benchmark_structure in enumerate( benchmark_structures ): + # To make sure that the structure is optimized + if ( + self.pre_relax_maker is not None + and self.phonon_bulk_relax_maker is None + ): + self.phonon_bulk_relax_maker = self.pre_relax_maker + # hard coded at the moment as other displacements # are not treated correctly in benchmark part complete_bm = complete_benchmark(