Skip to content

Commit 5d9e22d

Browse files
authored
Merge pull request #29 from JaGeo/fix_inconsistent_settings_bulk_static
Fix inconsistent settings bulk relax runs (ISMEAR=0)
2 parents ba72c4a + bdbac3c commit 5d9e22d

File tree

3 files changed

+122
-9
lines changed

3 files changed

+122
-9
lines changed

autoplex/auto/flows.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from emmet.core.math import Matrix3D
1212
from pymatgen.core.structure import Structure
1313

14-
from atomate2.vasp.flows.phonons import PhononMaker as DFTPhononMaker
1514
from jobflow import Flow, Maker
1615

1716
from autoplex.auto.jobs import (
@@ -22,7 +21,7 @@
2221
)
2322
from autoplex.benchmark.flows import PhononBenchmarkMaker
2423
from autoplex.benchmark.jobs import write_benchmark_metrics
25-
from autoplex.data.flows import TightDFTStaticMaker
24+
from autoplex.data.flows import DFTPhononMaker, TightDFTStaticMaker
2625
from autoplex.fitting.flows import MLIPFitMaker
2726

2827
__all__ = [

autoplex/data/flows.py

+116-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
PhononDisplacementMaker,
1515
run_phonon_displacements,
1616
)
17-
from atomate2.vasp.jobs.core import StaticMaker
18-
from atomate2.vasp.sets.core import StaticSetGenerator
17+
from atomate2.vasp.flows.core import DoubleRelaxMaker
18+
from atomate2.vasp.flows.phonons import PhononMaker
19+
from atomate2.vasp.jobs.core import StaticMaker, TightRelaxMaker
20+
from atomate2.vasp.sets.core import StaticSetGenerator, TightRelaxSetGenerator
1921
from jobflow import Flow, Maker
2022
from phonopy.structure.cells import get_supercell
2123
from pymatgen.core import Molecule, Site
@@ -24,6 +26,7 @@
2426
from autoplex.data.jobs import generate_randomized_structures
2527

2628
__all__ = [
29+
"DFTPhononMaker",
2730
"IsoAtomMaker",
2831
"IsoAtomStaticMaker",
2932
"RandomStructuresDataGenerator",
@@ -83,6 +86,117 @@ class TightDFTStaticMaker(PhononDisplacementMaker):
8386
)
8487

8588

89+
@dataclass
90+
class DFTPhononMaker(PhononMaker):
91+
"""
92+
Adapted PhononMaker to calculate harmonic phonons with VASP and Phonopy.
93+
94+
The input set used is same as PhononMaker from atomate2.
95+
Only difference is Spin polarization is switched off and Gaussian smearing is used
96+
97+
Parameters
98+
----------
99+
name : str = "phonon"
100+
Name of the flows produced by this maker.
101+
sym_reduce : bool = True
102+
Whether to reduce the number of deformations using symmetry.
103+
symprec : float = 1e-4
104+
Symmetry precision to use in the
105+
reduction of symmetry to find the primitive/conventional cell
106+
(use_primitive_standard_structure, use_conventional_standard_structure)
107+
and to handle all symmetry-related tasks in phonopy
108+
displacement: float = 0.01
109+
displacement distance for phonons
110+
min_length: float = 20.0
111+
min length of the supercell that will be built
112+
prefer_90_degrees: bool = True
113+
if set to True, supercell algorithm will first try to find a supercell
114+
with 3 90 degree angles
115+
get_supercell_size_kwargs: dict = {}
116+
kwargs that will be passed to get_supercell_size to determine supercell size
117+
use_symmetrized_structure: str or None = None
118+
allowed strings: "primitive", "conventional", None
119+
120+
- "primitive" will enforce to start the phonon computation
121+
from the primitive standard structure
122+
according to Setyawan, W., & Curtarolo, S. (2010).
123+
High-throughput electronic band structure calculations:
124+
Challenges and tools. Computational Materials Science,
125+
49(2), 299-312. doi:10.1016/j.commatsci.2010.05.010.
126+
This makes it possible to use certain k-path definitions
127+
with this workflow. Otherwise, we must rely on seekpath
128+
- "conventional" will enforce to start the phonon computation
129+
from the conventional standard structure
130+
according to Setyawan, W., & Curtarolo, S. (2010).
131+
High-throughput electronic band structure calculations:
132+
Challenges and tools. Computational Materials Science,
133+
49(2), 299-312. doi:10.1016/j.commatsci.2010.05.010.
134+
We will however use seekpath and primitive structures
135+
as determined by from phonopy to compute the phonon band structure
136+
bulk_relax_maker : .BaseVaspMaker or None
137+
A maker to perform a tight relaxation on the bulk.
138+
Set to ``None`` to skip the
139+
bulk relaxation
140+
static_energy_maker : .BaseVaspMaker or None
141+
A maker to perform the computation of the DFT energy on the bulk.
142+
Set to ``None`` to skip the
143+
static energy computation
144+
born_maker: .BaseVaspMaker or None
145+
Maker to compute the BORN charges.
146+
phonon_displacement_maker : .BaseVaspMaker or None
147+
Maker used to compute the forces for a supercell.
148+
generate_frequencies_eigenvectors_kwargs : dict
149+
Keyword arguments passed to :obj:`generate_frequencies_eigenvectors`.
150+
create_thermal_displacements: bool
151+
Arg that determines if thermal_displacement_matrices are computed
152+
kpath_scheme: str = "seekpath"
153+
scheme to generate kpoints. Please be aware that
154+
you can only use seekpath with any kind of cell
155+
Otherwise, please use the standard primitive structure
156+
Available schemes are:
157+
"seekpath", "hinuma", "setyawan_curtarolo", "latimer_munro".
158+
"seekpath" and "hinuma" are the same definition but
159+
seekpath can be used with any kind of unit cell as
160+
it relies on phonopy to handle the relationship
161+
to the primitive cell and not pymatgen
162+
code: str = "vasp"
163+
determines the DFT code. currently only vasp is implemented.
164+
This keyword might enable the implementation of other codes
165+
in the future
166+
store_force_constants: bool
167+
if True, force constants will be stored
168+
"""
169+
170+
name: str = "phonon"
171+
sym_reduce: bool = True
172+
symprec: float = 1e-4
173+
displacement: float = 0.01
174+
min_length: float | None = 20.0
175+
prefer_90_degrees: bool = True
176+
get_supercell_size_kwargs: dict = field(default_factory=dict)
177+
use_symmetrized_structure: str | None = None
178+
bulk_relax_maker: BaseVaspMaker | None = field(
179+
default_factory=lambda: DoubleRelaxMaker.from_relax_maker(
180+
TightRelaxMaker(
181+
input_set_generator=TightRelaxSetGenerator(
182+
user_incar_settings={"ISPIN": 1, "LAECHG": False, "ISMEAR": 0}
183+
)
184+
)
185+
),
186+
)
187+
static_energy_maker: BaseVaspMaker | None = field(
188+
default_factory=lambda: StaticMaker(
189+
input_set_generator=StaticSetGenerator(
190+
auto_ispin=False,
191+
user_incar_settings={"ISPIN": 1, "LAECHG": False, "ISMEAR": 0},
192+
)
193+
)
194+
)
195+
phonon_displacement_maker: BaseVaspMaker = field(
196+
default_factory=TightDFTStaticMaker
197+
)
198+
199+
86200
@dataclass
87201
class IsoAtomStaticMaker(StaticMaker):
88202
"""

tests/auto/test_auto_flows.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def test_complete_dft_vs_ml_benchmark_workflow(
8585
}
8686

8787
fake_run_vasp_kwargs = {
88-
"tight relax 1": {"incar_settings": ["NSW"]},
89-
"tight relax 2": {"incar_settings": ["NSW"]},
88+
"tight relax 1": {"incar_settings": ["NSW", "ISMEAR"]},
89+
"tight relax 2": {"incar_settings": ["NSW", "ISMEAR"]},
9090
"phonon static 1/2": {"incar_settings": ["NSW", "ISMEAR"]},
9191
"phonon static 2/2": {"incar_settings": ["NSW", "ISMEAR"]},
9292
"phonon static 1/3": {
@@ -356,10 +356,10 @@ def test_phonon_dft_ml_data_generation_flow(
356356
}
357357

358358
fake_run_vasp_kwargs = {
359-
"tight relax 1": {"incar_settings": ["NSW"]},
360-
"tight relax 2": {"incar_settings": ["NSW"]},
359+
"tight relax 1": {"incar_settings": ["NSW", "ISMEAR"]},
360+
"tight relax 2": {"incar_settings": ["NSW", "ISMEAR"]},
361361
"phonon static 1/2": {"incar_settings": ["NSW", "ISMEAR"]},
362-
"phonon static 2/2": {"incar_settings": ["NSW"]},
362+
"phonon static 2/2": {"incar_settings": ["NSW", "ISMEAR"]},
363363
"phonon static 1/3": {
364364
"incar_settings": ["NSW", "ISMEAR"],
365365
"check_inputs": ["incar", "kpoints", "potcar"],

0 commit comments

Comments
 (0)