1
+ from pathlib import Path
2
+
1
3
import numpy as np
2
4
import pytest
3
5
from jobflow import run_locally
6
+ from pymatgen .core import SETTINGS , Structure
4
7
from pymatgen .io .aims .sets .core import SocketIOSetGenerator , StaticSetGenerator
5
8
6
9
from atomate2 .aims .flows .anharmonicity import AnharmonicityMaker
11
14
PhononDisplacementMakerSocket ,
12
15
)
13
16
17
+ si_structure_file = Path (__file__ ).parents [2 ] / "test_data/structures/Si_diamond.cif"
18
+
14
19
15
- def test_anharmonic_quantification_oneshot (si , clean_dir , mock_aims , species_dir ):
20
+ def test_anharmonic_quantification_oneshot (clean_dir , mock_aims , species_dir ):
21
+ si = Structure .from_file (si_structure_file )
16
22
# mapping from job name to directory containing test files
17
23
ref_paths = {
18
24
"Relaxation calculation" : "phonon-relax-si" ,
@@ -21,94 +27,63 @@ def test_anharmonic_quantification_oneshot(si, clean_dir, mock_aims, species_dir
21
27
"phonon static aims anharmonicity quant. 1/1" : "anharm-os-si" ,
22
28
}
23
29
30
+ SETTINGS ["AIMS_SPECIES_DIR" ] = species_dir / "tight"
24
31
# settings passed to fake_run_aims; adjust these to check for certain input settings
25
32
fake_run_aims_kwargs = {}
26
33
27
34
# automatically use fake FHI-aims
28
35
mock_aims (ref_paths , fake_run_aims_kwargs )
29
36
30
- parameters = {
31
- "species_dir" : (species_dir / "light" ).as_posix (),
32
- "rlsy_symmetry" : "all" ,
33
- "sc_accuracy_rho" : 1e-06 ,
34
- "sc_accuracy_forces" : 0.0001 ,
35
- "relativistic" : "atomic_zora scalar" ,
36
- }
37
-
38
- parameters_phonon_disp = dict (compute_forces = True , ** parameters )
39
- parameters_phonon_disp ["rlsy_symmetry" ] = None
40
-
41
37
phonon_maker = PhononMaker (
42
- bulk_relax_maker = RelaxMaker .full_relaxation (
43
- user_params = parameters , user_kpoints_settings = {"density" : 5.0 }
44
- ),
45
- static_energy_maker = StaticMaker (
46
- input_set_generator = StaticSetGenerator (
47
- user_params = parameters , user_kpoints_settings = {"density" : 5.0 }
48
- )
49
- ),
38
+ min_length = 3.0 ,
39
+ generate_frequencies_eigenvectors_kwargs = {"tstep" : 100 },
40
+ create_thermal_displacements = True ,
41
+ store_force_constants = True ,
42
+ born_maker = None ,
50
43
use_symmetrized_structure = "primitive" ,
51
- phonon_displacement_maker = PhononDisplacementMaker (
52
- input_set_generator = StaticSetGenerator (
53
- user_params = parameters_phonon_disp ,
54
- user_kpoints_settings = {"density" : 5.0 },
55
- )
56
- ),
57
44
)
58
45
59
46
maker = AnharmonicityMaker (
60
47
phonon_maker = phonon_maker ,
61
48
)
62
49
maker .name = "anharmonicity"
63
- flow = maker .make (si , supercell_matrix = np .ones ((3 , 3 )) - 2 * np .eye (3 ))
50
+ flow = maker .make (
51
+ si ,
52
+ supercell_matrix = np .ones ((3 , 3 )) - 2 * np .eye (3 ),
53
+ one_shot_approx = True ,
54
+ seed = 1234 ,
55
+ )
64
56
65
57
# run the flow or job and ensure that it finished running successfully
66
58
responses = run_locally (flow , create_folders = True , ensure_success = True )
67
59
dct = responses [flow .job_uuids [- 1 ]][1 ].output .sigma_dict
68
- assert np .round (dct ["one-shot" ], 3 ) == 0.104
60
+ assert np .round (dct ["one-shot" ], 3 ) == 0.120
61
+
69
62
63
+ def test_anharmonic_quantification_full (clean_dir , mock_aims , species_dir ):
64
+ si = Structure .from_file (si_structure_file )
70
65
71
- def test_anharmonic_quantification_full (si , clean_dir , mock_aims , species_dir ):
72
66
ref_paths = {
73
- "Relaxation calculation" : "phonon-relax-si-full " ,
74
- "phonon static aims 1/1" : "phonon-disp-si-full " ,
75
- "SCF Calculation" : "phonon-energy-si-full " ,
67
+ "Relaxation calculation" : "phonon-relax-si" ,
68
+ "phonon static aims 1/1" : "phonon-disp-si" ,
69
+ "SCF Calculation" : "phonon-energy-si" ,
76
70
"phonon static aims anharmonicity quant. 1/1" : "anharm-si-full" ,
77
71
}
78
72
73
+ SETTINGS ["AIMS_SPECIES_DIR" ] = species_dir / "tight"
79
74
# settings passed to fake_run_aims; adjust these to check for certain input settings
80
75
fake_run_aims_kwargs = {}
81
76
82
77
# automatically use fake FHI-aims
83
78
mock_aims (ref_paths , fake_run_aims_kwargs )
84
79
85
- parameters = {
86
- "species_dir" : (species_dir / "light" ).as_posix (),
87
- "rlsy_symmetry" : "all" ,
88
- "sc_accuracy_rho" : 1e-06 ,
89
- "sc_accuracy_forces" : 0.0001 ,
90
- "relativistic" : "atomic_zora scalar" ,
91
- }
92
-
93
- parameters_phonon_disp = dict (compute_forces = True , ** parameters )
94
- parameters_phonon_disp ["rlsy_symmetry" ] = None
95
-
96
80
phonon_maker = PhononMaker (
97
- bulk_relax_maker = RelaxMaker .full_relaxation (
98
- user_params = parameters , user_kpoints_settings = {"density" : 5.0 }
99
- ),
100
- static_energy_maker = StaticMaker (
101
- input_set_generator = StaticSetGenerator (
102
- user_params = parameters , user_kpoints_settings = {"density" : 5.0 }
103
- )
104
- ),
81
+ min_length = 3.0 ,
82
+ generate_frequencies_eigenvectors_kwargs = {"tstep" : 100 },
83
+ create_thermal_displacements = True ,
84
+ store_force_constants = True ,
85
+ born_maker = None ,
105
86
use_symmetrized_structure = "primitive" ,
106
- phonon_displacement_maker = PhononDisplacementMaker (
107
- input_set_generator = StaticSetGenerator (
108
- user_params = parameters_phonon_disp ,
109
- user_kpoints_settings = {"density" : 5.0 },
110
- )
111
- ),
112
87
)
113
88
114
89
maker = AnharmonicityMaker (
@@ -125,7 +100,8 @@ def test_anharmonic_quantification_full(si, clean_dir, mock_aims, species_dir):
125
100
# run the flow or job and ensure that it finished running successfully
126
101
responses = run_locally (flow , create_folders = True , ensure_success = True )
127
102
dct = responses [flow .job_uuids [- 1 ]][1 ].output .sigma_dict
128
- assert pytest .approx (dct ["full" ], 0.001 ) == 0.12012
103
+
104
+ assert pytest .approx (dct ["full" ], 0.001 ) == 0.144264
129
105
130
106
131
107
def test_mode_resolved_anharmonic_quantification (si , clean_dir , mock_aims , species_dir ):
0 commit comments