Skip to content

Commit 82a5a05

Browse files
committed
changed raman back
1 parent a54b9d0 commit 82a5a05

File tree

1 file changed

+39
-85
lines changed

1 file changed

+39
-85
lines changed

atomate/vasp/workflows/tests/test_raman_workflow.py

Lines changed: 39 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -9,139 +9,93 @@
99
from fireworks import FWorker
1010
from fireworks.core.rocket_launcher import rapidfire
1111

12-
from atomate.common.powerups import powerup_by_kwargs
12+
from atomate.vasp.powerups import use_fake_vasp
1313
from atomate.vasp.workflows.presets.core import wf_raman_spectra
1414
from atomate.utils.testing import AtomateTest
1515

1616
from pymatgen.util.testing import PymatgenTest
1717

18-
__author__ = "Kiran Mathew"
19-
__email__ = "[email protected]"
18+
__author__ = 'Kiran Mathew'
19+
__email__ = '[email protected]'
2020

2121
module_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
2222
db_dir = os.path.join(module_dir, "..", "..", "..", "common", "test_files")
2323
ref_dir = os.path.join(module_dir, "..", "..", "test_files")
2424

25-
DEBUG_MODE = (
26-
False # If true, retains the database and output dirs at the end of the test
27-
)
28-
VASP_CMD = (
29-
None # If None, runs a "fake" VASP. Otherwise, runs VASP with this command...
30-
)
25+
DEBUG_MODE = False # If true, retains the database and output dirs at the end of the test
26+
VASP_CMD = None # If None, runs a "fake" VASP. Otherwise, runs VASP with this command...
3127

3228

3329
class TestRamanWorkflow(AtomateTest):
30+
3431
def setUp(self):
3532
super(TestRamanWorkflow, self).setUp()
3633
self.struct_si = PymatgenTest.get_structure("Si")
37-
self.raman_config = {
38-
"MODES": [0, 1],
39-
"STEP_SIZE": 0.005,
40-
"VASP_CMD": ">>vasp_cmd<<",
41-
"DB_FILE": ">>db_file<<",
42-
}
34+
self.raman_config = {"MODES": [0, 1], "STEP_SIZE": 0.005,
35+
"VASP_CMD": ">>vasp_cmd<<", "DB_FILE": ">>db_file<<"}
4336
self.wf = wf_raman_spectra(self.struct_si, self.raman_config)
4437

4538
def _simulate_vasprun(self, wf):
4639
reference_dir = os.path.abspath(os.path.join(ref_dir, "raman_wf"))
47-
si_ref_dirs = {
48-
"structure optimization": os.path.join(reference_dir, "1"),
49-
"static dielectric": os.path.join(reference_dir, "2"),
50-
"raman_0_-0.005": os.path.join(reference_dir, "6"),
51-
"raman_0_0.005": os.path.join(reference_dir, "5"),
52-
"raman_1_-0.005": os.path.join(reference_dir, "4"),
53-
"raman_1_0.005": os.path.join(reference_dir, "3"),
54-
}
55-
return powerup_by_kwargs(
56-
wf, use_fake_vasp={"ref_dirs": si_ref_dirs, "params_to_check": ["ENCUT"]}
57-
)
58-
# return use_fake_vasp(wf, si_ref_dirs, params_to_check=["ENCUT"])
40+
si_ref_dirs = {"structure optimization": os.path.join(reference_dir, "1"),
41+
"static dielectric": os.path.join(reference_dir, "2"),
42+
"raman_0_-0.005": os.path.join(reference_dir, "6"),
43+
"raman_0_0.005": os.path.join(reference_dir, "5"),
44+
"raman_1_-0.005": os.path.join(reference_dir, "4"),
45+
"raman_1_0.005": os.path.join(reference_dir, "3")}
46+
return use_fake_vasp(wf, si_ref_dirs, params_to_check=["ENCUT"])
5947

6048
def _check_run(self, d, mode):
61-
if mode not in [
62-
"structure optimization",
63-
"static dielectric",
64-
"raman_0_0.005",
65-
"raman analysis",
66-
]:
49+
if mode not in ["structure optimization", "static dielectric",
50+
"raman_0_0.005", "raman analysis"]:
6751
raise ValueError("Invalid mode!")
6852

6953
if mode not in ["raman analysis"]:
7054
self.assertEqual(d["formula_pretty"], "Si")
7155
self.assertEqual(d["formula_anonymous"], "A")
7256
self.assertEqual(d["nelements"], 1)
7357
self.assertEqual(d["state"], "successful")
74-
self.assertAlmostEqual(
75-
d["calcs_reversed"][0]["output"]["structure"]["lattice"]["a"], 3.867, 2
76-
)
58+
self.assertAlmostEqual(d["calcs_reversed"][0]["output"]["structure"]["lattice"]["a"], 3.867, 2)
7759

7860
if mode in ["structure optimization"]:
7961
self.assertAlmostEqual(d["output"]["energy"], -10.850, 2)
8062
self.assertAlmostEqual(d["output"]["energy_per_atom"], -5.425, 2)
8163

8264
elif mode in ["static dielectric"]:
83-
epsilon = [
84-
[13.23245131, -1.98e-06, -1.4e-06],
85-
[-1.98e-06, 13.23245913, 8.38e-06],
86-
[-1.4e-06, 8.38e-06, 13.23245619],
87-
]
88-
np.testing.assert_allclose(
89-
epsilon, d["output"]["epsilon_static"], rtol=1e-5
90-
)
65+
epsilon = [[13.23245131, -1.98e-06, -1.4e-06],
66+
[-1.98e-06, 13.23245913, 8.38e-06],
67+
[-1.4e-06, 8.38e-06, 13.23245619]]
68+
np.testing.assert_allclose(epsilon, d["output"]["epsilon_static"], rtol=1e-5)
9169

9270
elif mode in ["raman_0_0.005"]:
93-
epsilon = [
94-
[13.16509632, 0.00850098, 0.00597267],
95-
[0.00850097, 13.25477303, -0.02979572],
96-
[0.00597267, -0.0297953, 13.28883867],
97-
]
98-
np.testing.assert_allclose(
99-
epsilon, d["output"]["epsilon_static"], rtol=1e-5
100-
)
71+
epsilon = [[13.16509632, 0.00850098, 0.00597267],
72+
[0.00850097, 13.25477303, -0.02979572],
73+
[0.00597267, -0.0297953, 13.28883867]]
74+
np.testing.assert_allclose(epsilon, d["output"]["epsilon_static"], rtol=1e-5)
10175

10276
elif mode in ["raman analysis"]:
103-
freq = [
104-
82.13378641656142,
105-
82.1337379843688,
106-
82.13373236539397,
107-
3.5794336040310436e-07,
108-
3.872360276932139e-07,
109-
1.410955723105983e-06,
110-
]
77+
freq = [82.13378641656142, 82.1337379843688, 82.13373236539397,
78+
3.5794336040310436e-07, 3.872360276932139e-07, 1.410955723105983e-06]
11179
np.testing.assert_allclose(freq, d["frequencies"], rtol=1e-5)
112-
raman_tensor = {
113-
"0": [
114-
[-0.14893062387265346, 0.01926196125448702, 0.013626954435454657],
115-
[0.019262321540910236, 0.03817444467845385, -0.06614541890150054],
116-
[0.013627229948601821, -0.06614564143135017, 0.11078513986463052],
117-
],
118-
"1": [
119-
[-0.021545749071077102, -0.12132200642389818, -0.08578776196143767],
120-
[-0.12131975993142007, -0.00945267872479081, -0.004279822490713417],
121-
[-0.08578678706847546, -0.004279960247327641, 0.032660281203217366],
122-
],
123-
}
124-
np.testing.assert_allclose(
125-
raman_tensor["0"], d["raman_tensor"]["0"], rtol=1e-5
126-
)
127-
np.testing.assert_allclose(
128-
raman_tensor["1"], d["raman_tensor"]["1"], rtol=1e-5
129-
)
80+
raman_tensor = {'0': [[-0.14893062387265346, 0.01926196125448702, 0.013626954435454657],
81+
[0.019262321540910236, 0.03817444467845385, -0.06614541890150054],
82+
[0.013627229948601821, -0.06614564143135017, 0.11078513986463052]],
83+
'1': [[-0.021545749071077102, -0.12132200642389818, -0.08578776196143767],
84+
[-0.12131975993142007, -0.00945267872479081, -0.004279822490713417],
85+
[-0.08578678706847546, -0.004279960247327641, 0.032660281203217366]]}
86+
np.testing.assert_allclose(raman_tensor["0"], d["raman_tensor"]["0"], rtol=1e-5)
87+
np.testing.assert_allclose(raman_tensor["1"], d["raman_tensor"]["1"], rtol=1e-5)
13088

13189
def test_wf(self):
13290
self.wf = self._simulate_vasprun(self.wf)
13391

13492
self.assertEqual(len(self.wf.fws), len(self.raman_config["MODES"]) * 2 + 3)
13593

13694
self.lp.add_wf(self.wf)
137-
rapidfire(
138-
self.lp, fworker=FWorker(env={"db_file": os.path.join(db_dir, "db.json")})
139-
)
95+
rapidfire(self.lp, fworker=FWorker(env={"db_file": os.path.join(db_dir, "db.json")}))
14096

14197
# check relaxation
142-
d = self.get_task_collection().find_one(
143-
{"task_label": "structure optimization"}
144-
)
98+
d = self.get_task_collection().find_one({"task_label": "structure optimization"})
14599
self._check_run(d, mode="structure optimization")
146100

147101
# check phonon DFPT calculation
@@ -157,7 +111,7 @@ def test_wf(self):
157111
self._check_run(d, mode="raman analysis")
158112

159113
wf = self.lp.get_wf_by_fw_id(1)
160-
self.assertTrue(all([s == "COMPLETED" for s in wf.fw_states.values()]))
114+
self.assertTrue(all([s == 'COMPLETED' for s in wf.fw_states.values()]))
161115

162116

163117
if __name__ == "__main__":

0 commit comments

Comments
 (0)