Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Maker defaults to CompleteDFTvsMLBenchmarkWorkflow definition #333

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ dependencies = [
[tool.setuptools.packages.find]
where = ["src"]

#[tool.setuptools.package-data]
#"autoplex.fitting.common" = ["*.json"]
#"autoplex.auto.rss" = ["*.yaml"]

[project.optional-dependencies]
docs = [
"autodoc_pydantic==2.2.0",
Expand Down
84 changes: 59 additions & 25 deletions src/autoplex/auto/phonons/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
from dataclasses import dataclass, field

from atomate2.common.schemas.phonons import PhononBSDOSDoc
from atomate2.vasp.flows.core import DoubleRelaxMaker
from atomate2.vasp.flows.mp import (
MPGGADoubleRelaxMaker,
MPGGARelaxMaker,
MPGGAStaticMaker,
)
from atomate2.vasp.jobs.base import BaseVaspMaker
from atomate2.vasp.jobs.core import TightRelaxMaker
from atomate2.vasp.sets.core import TightRelaxSetGenerator
from jobflow import Flow, Maker
from pymatgen.core.structure import Structure
from pymatgen.io.vasp.sets import (
Expand Down Expand Up @@ -178,9 +181,61 @@ class CompleteDFTvsMLBenchmarkWorkflow(Maker):
add_dft_rattled_struct: bool = True
add_rss_struct: bool = False
displacement_maker: BaseVaspMaker = None
phonon_bulk_relax_maker: BaseVaspMaker = None
phonon_static_energy_maker: BaseVaspMaker = None
rattled_bulk_relax_maker: BaseVaspMaker = None
phonon_bulk_relax_maker: BaseVaspMaker | None = field(
default_factory=lambda: DoubleRelaxMaker.from_relax_maker(
TightRelaxMaker(
name="dft tight relax",
run_vasp_kwargs={"handlers": {}},
input_set_generator=TightRelaxSetGenerator(
user_incar_settings={
# TODO check if user_incar_settings has to be set like that or can be left out
"ALGO": "Normal",
"ISPIN": 1,
"LAECHG": False,
"ISMEAR": 0,
"ENCUT": 700,
"ISYM": 0,
"SIGMA": 0.05,
"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,
}
),
)
)
)
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,
}
),
)
)
isolated_atom_maker: IsoAtomStaticMaker | None = None
n_structures: int = 10
displacements: list[float] = field(default_factory=lambda: [0.01])
Expand Down Expand Up @@ -909,28 +964,7 @@ class CompleteDFTvsMLBenchmarkWorkflowMPSettings(CompleteDFTvsMLBenchmarkWorkflo
)
)

phonon_static_energy_maker: BaseVaspMaker = field(
default_factory=lambda: MPGGAStaticMaker(
run_vasp_kwargs={"handlers": ()},
name="dft phonon static",
input_set_generator=MPStaticSet(
force_gamma=True,
auto_metal_kpoints=True,
inherit_incar=False,
user_incar_settings={
"NPAR": 4,
"EDIFF": 1e-7,
"EDIFFG": 1e-6,
"ALGO": "NORMAL",
"ISPIN": 1,
"LREAL": False,
"LCHARG": False,
"ISMEAR": 0,
"KSPACING": 0.2,
},
),
)
)
phonon_static_energy_maker: BaseVaspMaker = None


@dataclass
Expand Down
93 changes: 10 additions & 83 deletions src/autoplex/auto/phonons/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

import numpy as np
from atomate2.common.schemas.phonons import ForceConstants, PhononBSDOSDoc
from atomate2.vasp.flows.core import DoubleRelaxMaker
from atomate2.vasp.jobs.base import BaseVaspMaker
from atomate2.vasp.jobs.core import StaticMaker, TightRelaxMaker
from atomate2.vasp.sets.core import StaticSetGenerator, TightRelaxSetGenerator
from jobflow import Flow, Response, job
from pymatgen.core.structure import Structure
from pymatgen.phonon.bandstructure import PhononBandStructure
Expand Down Expand Up @@ -539,65 +536,17 @@ def dft_phonopy_gen_data(

if phonon_displacement_maker is None:
phonon_displacement_maker = TightDFTStaticMaker(name="dft phonon static")
if phonon_bulk_relax_maker is None:
phonon_bulk_relax_maker = DoubleRelaxMaker.from_relax_maker(
TightRelaxMaker(
name="dft tight relax",
run_vasp_kwargs={"handlers": {}},
input_set_generator=TightRelaxSetGenerator(
user_incar_settings={
"ALGO": "Normal",
"ISPIN": 1,
"LAECHG": False,
"ISMEAR": 0,
"ENCUT": 700,
"ISYM": 0,
"SIGMA": 0.05,
"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,
}
),
)
)

if phonon_static_energy_maker is None:
phonon_static_energy_maker = StaticMaker(
name="dft static",
input_set_generator=StaticSetGenerator(
auto_ispin=False,
user_incar_settings={
"ALGO": "Normal",
"ISPIN": 1,
"LAECHG": False,
"ISMEAR": 0,
"ENCUT": 700,
"SIGMA": 0.05,
"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
# to be removed
"NPAR": 4,
},
),
)

# always set autoplex default as job name
phonon_displacement_maker.name = "dft phonon static"
phonon_static_energy_maker.name = "dft static"
try:
phonon_bulk_relax_maker.relax_maker1.name = "dft tight relax"
phonon_bulk_relax_maker.relax_maker2.name = "dft tight relax"
except AttributeError:
phonon_bulk_relax_maker.name = "dft tight relax"
if phonon_static_energy_maker is not None:
phonon_static_energy_maker.name = "dft static"
if phonon_bulk_relax_maker is not None:
try:
phonon_bulk_relax_maker.relax_maker1.name = "dft tight relax"
phonon_bulk_relax_maker.relax_maker2.name = "dft tight relax"
except AttributeError:
phonon_bulk_relax_maker.name = "dft tight relax"

for displacement in displacements:
dft_phonons = DFTPhononMaker(
Expand Down Expand Up @@ -706,33 +655,11 @@ def dft_random_gen_data(

if displacement_maker is None:
displacement_maker = TightDFTStaticMaker(name="dft rattle static")
Comment on lines 656 to 657
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep this as we need it in any case, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept this, and in the single atom-displaced supercell part as well, because we are setting different names and there should always be a displacement maker.
image

if rattled_bulk_relax_maker is None:
rattled_bulk_relax_maker = 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,
}
),
)

# always set autoplex default as job name
displacement_maker.name = "dft rattle static"
rattled_bulk_relax_maker.name = "dft tight relax"
if rattled_bulk_relax_maker is not None:
rattled_bulk_relax_maker.name = "dft tight relax"

# TODO: decide if we should remove the additional response here as well
# looks like only the output is changing
Expand Down
2 changes: 0 additions & 2 deletions src/autoplex/auto/rss/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ def initial_rss(
if dimer_box is None:
dimer_box = [20.0, 20.0, 20.0]

print(buildcell_options)

do_randomized_structure_generation = BuildMultiRandomizedStructure(
generated_struct_numbers=generated_struct_numbers,
buildcell_options=buildcell_options,
Expand Down
43 changes: 6 additions & 37 deletions src/autoplex/data/phonons/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,28 +223,7 @@ class DFTPhononMaker(PhononMaker):
)
),
)
static_energy_maker: BaseVaspMaker | None = field(
default_factory=lambda: StaticMaker(
input_set_generator=StaticSetGenerator(
auto_ispin=False,
user_incar_settings={
"ALGO": "Normal",
"ISPIN": 1,
"LAECHG": False,
"ISMEAR": 0,
"ENCUT": 700,
"SIGMA": 0.05,
"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
# to be removed
"NPAR": 4,
},
)
)
)
static_energy_maker: BaseVaspMaker | None = None

phonon_displacement_maker: BaseVaspMaker | None = field(
default_factory=TightDFTStaticMaker
Expand Down Expand Up @@ -580,9 +559,7 @@ class MLPhononMaker(FFPhononMaker):
force_field_name="GAP",
)
)
static_energy_maker: ForceFieldStaticMaker | None = field(
default_factory=lambda: ForceFieldStaticMaker(force_field_name="GAP")
)
static_energy_maker: ForceFieldStaticMaker | None = None
store_force_constants: bool = False
get_supercell_size_kwargs: dict = field(
default_factory=lambda: {"max_atoms": 20000, "step_size": 0.1}
Expand Down Expand Up @@ -663,9 +640,7 @@ def make_from_ml_model(
name="nep phonon static",
force_field_name="NEP",
),
static_energy_maker=ForceFieldStaticMaker(
force_field_name="NEP",
),
static_energy_maker=None,
calculator_kwargs=calculator_kwargs,
relax_maker_kwargs=self.relax_maker_kwargs,
static_maker_kwargs=self.static_maker_kwargs,
Expand All @@ -689,9 +664,7 @@ def make_from_ml_model(
name="nequip phonon static",
force_field_name="Nequip",
),
static_energy_maker=ForceFieldStaticMaker(
force_field_name="Nequip",
),
static_energy_maker=None,
calculator_kwargs=calculator_kwargs,
relax_maker_kwargs=self.relax_maker_kwargs,
static_maker_kwargs=self.static_maker_kwargs,
Expand All @@ -711,9 +684,7 @@ def make_from_ml_model(
name="m3gnet phonon static",
force_field_name="M3GNet",
),
static_energy_maker=ForceFieldStaticMaker(
force_field_name="M3GNet",
),
static_energy_maker=None,
calculator_kwargs=calculator_kwargs,
relax_maker_kwargs=self.relax_maker_kwargs,
static_maker_kwargs=self.static_maker_kwargs,
Expand Down Expand Up @@ -741,9 +712,7 @@ def make_from_ml_model(
name="mace phonon static",
force_field_name="MACE",
),
static_energy_maker=ForceFieldStaticMaker(
force_field_name="MACE",
),
static_energy_maker=None,
calculator_kwargs=calculator_kwargs,
relax_maker_kwargs=self.relax_maker_kwargs,
static_maker_kwargs=self.static_maker_kwargs,
Expand Down
2 changes: 1 addition & 1 deletion src/autoplex/data/phonons/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def ml_phonon_maker_preparation(
static_maker_kwargs: dict | None,
bulk_relax_maker: ForceFieldRelaxMaker,
phonon_displacement_maker: ForceFieldStaticMaker,
static_energy_maker: ForceFieldStaticMaker,
static_energy_maker: ForceFieldStaticMaker | None,
) -> tuple[
ForceFieldRelaxMaker | None,
ForceFieldStaticMaker | None,
Expand Down
6 changes: 3 additions & 3 deletions src/autoplex/fitting/common/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def machine_learning_fit(
num_processes_fit: int
Number of processes for fitting.
auto_delta: bool
Automatically determine delta for 2b, 3b and soap terms.
Automatically determine delta for 2b, 3b and soap terms. Only used for GAP fitting.
glue_xml: bool
Use the glue.xml core potential instead of fitting 2b terms.
Use the glue.xml core potential instead of fitting 2b terms. Only used for GAP fitting.
glue_file_path: str
Name of the glue.xml file path.
Name of the glue.xml file path. Only used for GAP fitting.
gpu_identifier_indices: list[int]
List of GPU indices to be used for fitting. Only used for NEP fitting.
mlip_type: str
Expand Down
Loading