Skip to content

[WIP] Fix remote error of the benchmark part #338

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
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
84 changes: 59 additions & 25 deletions src/autoplex/auto/phonons/flows.py
Original file line number Diff line number Diff line change
@@ -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 (
@@ -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])
@@ -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
93 changes: 10 additions & 83 deletions src/autoplex/auto/phonons/jobs.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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(
@@ -706,33 +655,11 @@ def dft_random_gen_data(

if displacement_maker is None:
displacement_maker = TightDFTStaticMaker(name="dft rattle static")
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
39 changes: 5 additions & 34 deletions src/autoplex/data/phonons/flows.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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}
@@ -689,9 +666,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,
@@ -711,9 +686,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,
@@ -741,9 +714,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,
2 changes: 1 addition & 1 deletion src/autoplex/data/phonons/utils.py
Original file line number Diff line number Diff line change
@@ -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,
28 changes: 0 additions & 28 deletions tests/auto/phonons/test_flows.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ def ref_paths():
"dft tight relax_test": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 1_test": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2_test": "dft_ml_data_generation/tight_relax_2/",
"dft static_test": "dft_ml_data_generation/static/",
"Cl-stat_iso_atom": "Cl_iso_atoms/Cl-statisoatom/",
"Li-stat_iso_atom": "Li_iso_atoms/Li-statisoatom/",
"dft phonon static 1/2_test": "dft_ml_data_generation/phonon_static_1/",
@@ -38,7 +37,6 @@ def ref_paths():
"dft tight relax_mp-22905": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 1_mp-22905": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2_mp-22905": "dft_ml_data_generation/tight_relax_2/",
"dft static_mp-22905": "dft_ml_data_generation/static/",
"dft phonon static 1/2_mp-22905": "dft_ml_data_generation/phonon_static_1/",
"dft phonon static 2/2_mp-22905": "dft_ml_data_generation/phonon_static_2/",
"dft rattle static 1/12_mp-22905": "dft_ml_data_generation/rand_static_1/",
@@ -53,7 +51,6 @@ def ref_paths():
"dft rattle static 10/12_mp-22905": "dft_ml_data_generation/rand_static_10/",
"dft rattle static 11/12_mp-22905": "dft_ml_data_generation/rand_static_11/",
"dft rattle static 12/12_mp-22905": "dft_ml_data_generation/rand_static_12/",

}


@@ -63,7 +60,6 @@ def ref_paths_mpid():
"dft tight relax_mp-22905": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 1_mp-22905": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2_mp-22905": "dft_ml_data_generation/tight_relax_2/",
"dft static_mp-22905": "dft_ml_data_generation/static/",
"Cl-stat_iso_atom": "Cl_iso_atoms/Cl-statisoatom/",
"Li-stat_iso_atom": "Li_iso_atoms/Li-statisoatom/",
"dft phonon static 1/2_mp-22905": "dft_ml_data_generation/phonon_static_1/",
@@ -260,7 +256,6 @@ def ref_paths4():
"dft tight relax_test": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 1_test": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2_test": "dft_ml_data_generation/tight_relax_2/",
"dft static_test": "dft_ml_data_generation/static/",
"Cl-stat_iso_atom": "Cl_iso_atoms/Cl-statisoatom/",
"Li-stat_iso_atom": "Li_iso_atoms/Li-statisoatom/",
"dft phonon static 1/2_test": "dft_ml_data_generation/phonon_static_1/",
@@ -280,7 +275,6 @@ def fake_run_vasp_kwargs5():
"dft tight relax 2_test": {"incar_settings": ["NSW", "ISMEAR"]},
"dft phonon static 1/2_test": {"incar_settings": ["NSW", "ISMEAR"]},
"dft phonon static 2/2_test": {"incar_settings": ["NSW", "ISMEAR"]},

"dft rattle static 1/4_test": {
"incar_settings": ["NSW", "ISMEAR"],
"check_inputs": ["incar", "potcar"],
@@ -308,7 +302,6 @@ def fake_run_vasp_kwargs4():
"dft tight relax 2_test": {"incar_settings": ["NSW", "ISMEAR"]},
"dft phonon static 1/2_test": {"incar_settings": ["NSW", "ISMEAR"]},
"dft phonon static 2/2_test": {"incar_settings": ["NSW", "ISMEAR"]},

"dft rattle static 1/4_test": {
"incar_settings": ["NSW", "ISMEAR"],
"check_inputs": ["incar", "potcar"],
@@ -347,21 +340,10 @@ def ref_paths4_mpid():
"dft tight relax 1_test3": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2_test2": "dft_ml_data_generation/tight_relax_2/",
"dft tight relax 2_test3": "dft_ml_data_generation/tight_relax_2/",
"dft static_test": "dft_ml_data_generation/static/",
"dft static_test_0": "dft_ml_data_generation/static/",
"dft static_test_1": "dft_ml_data_generation/static/",
"dft static_test2": "dft_ml_data_generation/static/",
"dft static_test2_0": "dft_ml_data_generation/static/",
"dft static_test2_1": "dft_ml_data_generation/static/",
"dft static_test3": "dft_ml_data_generation/static/",
"dft static_test3_0": "dft_ml_data_generation/static/",
"dft static_test3_1": "dft_ml_data_generation/static/",
"dft tight relax 1_mp-22905": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 1_mp-22905_0": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2_mp-22905": "dft_ml_data_generation/tight_relax_2/",
"dft tight relax 2_mp-22905_0": "dft_ml_data_generation/tight_relax_2/",
"dft static_mp-22905": "dft_ml_data_generation/static/",
"dft static_mp-22905_0": "dft_ml_data_generation/static/",
"Cl-stat_iso_atom": "Cl_iso_atoms/Cl-statisoatom/",
"Cl-stat_iso_atom_0": "Cl_iso_atoms/Cl-statisoatom/",
"Cl-stat_iso_atom_1": "Cl_iso_atoms/Cl-statisoatom/",
@@ -434,11 +416,6 @@ def ref_paths4_mpid_new():
"dft tight relax 2_test3": "dft_ml_data_generation/strict_test/tight_relax_2_test/",
"dft tight relax 1_mp-22905": "dft_ml_data_generation/strict_test/tight_relax_1_test/",
"dft tight relax 2_mp-22905": "dft_ml_data_generation/strict_test/tight_relax_2_test/",
"dft static_test": "dft_ml_data_generation/static/",
"dft static_test2": "dft_ml_data_generation/static/",
"dft static_mp-22905": "dft_ml_data_generation/static/",
"dft static_test3": "dft_ml_data_generation/static/",
"dft static_test_mp-22905": "dft_ml_data_generation/static/",
"Cl-stat_iso_atom": "Cl_iso_atoms/Cl-statisoatom/",
"Li-stat_iso_atom": "Li_iso_atoms/Li-statisoatom/",
"dft phonon static 1/2_test": "dft_ml_data_generation/strict_test/phonon_static_1/",
@@ -473,10 +450,6 @@ def ref_paths4_mpid_new2():
"dft tight relax 2_test_1": "dft_ml_data_generation/strict_test/tight_relax_2_test/",
"dft tight relax 2_test_2": "dft_ml_data_generation/strict_test/tight_relax_2_test/",
"dft tight relax 2_test_3": "dft_ml_data_generation/strict_test/tight_relax_2_test/",
"dft static_test_0": "dft_ml_data_generation/static/",
"dft static_test_1": "dft_ml_data_generation/static/",
"dft static_test_2": "dft_ml_data_generation/static/",
"dft static_test_3": "dft_ml_data_generation/static/",
"Cl-stat_iso_atom_0": "Cl_iso_atoms/Cl-statisoatom/",
"Cl-stat_iso_atom_1": "Cl_iso_atoms/Cl-statisoatom/",
"Cl-stat_iso_atom_2": "Cl_iso_atoms/Cl-statisoatom/",
@@ -505,7 +478,6 @@ def ref_paths5_mpid():
"dft tight relax 1_test": "MP_finetuning/tight_relax_1/",
"dft tight relax 2_test": "MP_finetuning/tight_relax_2/",
"Sn-stat_iso_atom": "MP_finetuning/Sn-stat_iso_atom/",
"dft static_test": "MP_finetuning/static_test/",
"dft phonon static 1/1_test": "MP_finetuning/phonon_static_1/",
"dft rattle static 1/3_test": "MP_finetuning/rand_static_1/",
"dft rattle static 2/3_test": "MP_finetuning/rand_static_2/",
35 changes: 4 additions & 31 deletions tests/auto/phonons/test_jobs.py
Original file line number Diff line number Diff line change
@@ -45,37 +45,11 @@ def relax_maker():
)
)


@pytest.fixture(scope="class")
def static_energy_maker():
return 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,
},
)
)


@pytest.fixture(scope="class")
def ref_paths():
return {
"dft tight relax 1": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2": "dft_ml_data_generation/tight_relax_2/",
"dft static": "dft_ml_data_generation/static/",
"dft phonon static 1/2": "dft_ml_data_generation/phonon_static_1/",
"dft phonon static 2/2": "dft_ml_data_generation/phonon_static_2/",
"dft rattle static 1/3": "dft_ml_data_generation/rand_static_1/",
@@ -89,7 +63,6 @@ def ref_paths_check_sc_mat():
return {
"dft tight relax 1": "dft_ml_data_generation/tight_relax_1/",
"dft tight relax 2": "dft_ml_data_generation/tight_relax_2/",
"dft static": "dft_ml_data_generation/static/",
"dft phonon static 1/2": "dft_ml_data_generation/phonon_static_1_sc_mat/",
"dft phonon static 2/2": "dft_ml_data_generation/phonon_static_2_sc_mat/",
"dft rattle static 1/3": "dft_ml_data_generation/rand_static_1_sc_mat/",
@@ -296,7 +269,6 @@ def test_dft_task_doc(
test_dir,
memory_jobstore,
relax_maker,
static_energy_maker,
ref_paths,
fake_run_vasp_kwargs,
clean_dir
@@ -307,7 +279,7 @@ def test_dft_task_doc(
dft_phonon_workflow = dft_phonopy_gen_data(structure=structure, mp_id="test", displacements=[0.01], symprec=0.1,
phonon_displacement_maker=TightDFTStaticMaker(),
phonon_bulk_relax_maker=relax_maker,
phonon_static_energy_maker=static_energy_maker,
phonon_static_energy_maker=None,
supercell_settings={"min_length": 10, "min_atoms": 20})

# automatically use fake VASP and write POTCAR.spec during the test
@@ -333,7 +305,8 @@ def test_dft_phonopy_gen_data_manual_supercell_matrix(
mock_vasp,
memory_jobstore,
relax_maker,
static_energy_maker,
ref_paths_check_sc_mat,
fake_run_vasp_kwargs,
clean_dir
):
path_to_struct = vasp_test_dir / "dft_ml_data_generation" / "POSCAR"
@@ -351,7 +324,7 @@ def test_dft_phonopy_gen_data_manual_supercell_matrix(
dft_phonon_workflow = dft_phonopy_gen_data(structure=structure, mp_id="test", displacements=[0.01], symprec=0.1,
phonon_displacement_maker=TightDFTStaticMaker(),
phonon_bulk_relax_maker=relax_maker,
phonon_static_energy_maker=static_energy_maker,
phonon_static_energy_maker=None,
supercell_settings=supercell_settings)

# automatically use fake VASP and write POTCAR.spec during the test