Skip to content

Commit 825218f

Browse files
committed
Added test which runs Critic2 if exec is available
1 parent 61c3882 commit 825218f

File tree

17 files changed

+1180
-6
lines changed

17 files changed

+1180
-6
lines changed

atomate/qchem/firetasks/tests/test_critic2.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import os
55
import unittest
66
import shutil
7-
8-
from atomate.qchem.firetasks.critic2 import ProcessCritic2
7+
from monty.os.path import which
8+
from atomate.qchem.firetasks.critic2 import RunCritic2, ProcessCritic2
99
from atomate.utils.testing import AtomateTest
1010
from custodian.qchem.handlers import QChemErrorHandler
1111
from custodian.qchem.jobs import QCJob
@@ -17,6 +17,46 @@
1717

1818
module_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
1919

20+
@unittest.skipIf(not which("critic2"), "critic2 executable not present")
21+
class TestRunCritic2(AtomateTest):
22+
def setUp(self, lpad=False):
23+
os.chdir(os.path.join(module_dir, "..", "..", "test_files",
24+
"critic_test_files", "small_critic_example"))
25+
out_file = "mol.qout"
26+
qc_out = QCOutput(filename=out_file)
27+
self.mol = qc_out.data["initial_molecule"]
28+
self.cube_file = "dens.0.cube"
29+
super(TestRunCritic2, self).setUp(lpad=False)
30+
31+
def tearDown(self):
32+
os.remove("cpreport.json")
33+
os.remove("yt.json")
34+
35+
def test_RunCritic2(self):
36+
os.chdir(os.path.join(module_dir, "..", "..", "test_files",
37+
"critic_test_files", "small_critic_example"))
38+
firetask = RunCritic2(
39+
molecule=self.mol,
40+
cube_file="dens.0.cube.gz")
41+
firetask.run_task(fw_spec={})
42+
with open("cpreport_correct.json") as f:
43+
cpreport_reference = json.load(f)
44+
with open("yt_correct.json") as f:
45+
yt_reference = json.load(f)
46+
with open("cpreport.json") as f:
47+
cpreport = json.load(f)
48+
with open("yt.json") as f:
49+
yt = json.load(f)
50+
# Context for below - reference files were built before units were added
51+
# to Critic2, and we avoid testing the actual critical points because they
52+
# can change order between runs. But comparing everything else is sufficient.
53+
for key in cpreport:
54+
if key in ["structure", "field"]:
55+
self.assertEqual(cpreport_reference[key],cpreport[key])
56+
for key in yt:
57+
if key != "units":
58+
self.assertEqual(yt_reference[key],yt[key])
59+
2060

2161
class TestProcessCritic2(AtomateTest):
2262
def setUp(self, lpad=False):
@@ -27,26 +67,31 @@ def setUp(self, lpad=False):
2767
self.mol = qc_out.data["initial_molecule"]
2868
self.cube_file = "dens.0.cube.gz"
2969
shutil.move("bonding.json","bonding_correct.json")
70+
shutil.move("processed_critic2.json","processed_correct.json")
3071
super(TestProcessCritic2, self).setUp(lpad=False)
3172

3273
def tearDown(self):
3374
os.remove("bonding.json")
3475
shutil.move("bonding_correct.json","bonding.json")
76+
os.remove("processed_critic2.json")
77+
shutil.move("processed_correct.json","processed_critic2.json")
3578

3679
def test_ProcessCritic2(self):
3780
os.chdir(os.path.join(module_dir, "..", "..", "test_files",
3881
"critic_test_files", "critic_example"))
3982
firetask = ProcessCritic2(
40-
molecule=self.mol,
41-
cp_name="CP.json",
42-
yt_name="YT.json")
43-
print(os.getcwd())
83+
molecule=self.mol)
4484
firetask.run_task(fw_spec={})
4585
with open("bonding_correct.json") as f:
4686
reference = json.load(f)
4787
with open("bonding.json") as f:
4888
just_built = json.load(f)
4989
self.assertEqual(reference,just_built)
90+
with open("processed_correct.json") as f:
91+
reference = json.load(f)
92+
with open("processed_critic2.json") as f:
93+
just_built = json.load(f)
94+
self.assertEqual(reference,just_built)
5095

5196

5297
if __name__ == "__main__":
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"spec": {
3+
"tags": {
4+
"class": "m3_production"
5+
},
6+
"_priority": 10,
7+
"_tasks": [
8+
{
9+
"molecule": null,
10+
"qchem_input_set": "SinglePointSet",
11+
"input_file": "mol.qin",
12+
"qchem_input_params": {
13+
"dft_rung": 4,
14+
"smd_solvent": "custom",
15+
"custom_smd": "18.5,1.415,0.00,0.735,20.2,0.00,0.00",
16+
"overwrite_inputs": {
17+
"rem": {
18+
"thresh": "14",
19+
"scf_guess_always": "True"
20+
}
21+
},
22+
"plot_cubes": true
23+
},
24+
"_fw_name": "{{atomate.qchem.firetasks.write_inputs.WriteInputFromIOSet}}"
25+
},
26+
{
27+
"qchem_cmd": ">>qchem_cmd<<",
28+
"multimode": ">>multimode<<",
29+
"input_file": "mol.qin",
30+
"output_file": "mol.qout",
31+
"max_cores": ">>max_cores<<",
32+
"job_type": "normal",
33+
"_fw_name": "{{atomate.qchem.firetasks.run_calc.RunQChemCustodian}}"
34+
},
35+
{
36+
"molecule": null,
37+
"cube_file": "dens.0.cube.gz",
38+
"_fw_name": "{{atomate.qchem.firetasks.critic2.RunCritic2}}"
39+
},
40+
{
41+
"db_file": ">>db_file<<",
42+
"input_file": "mol.qin",
43+
"output_file": "mol.qout",
44+
"additional_fields": {
45+
"task_label": "C2 O1:CC2_m3frag_6938_charge-1_def2-tzvppd_wb97xv_smd"
46+
},
47+
"_fw_name": "{{atomate.qchem.firetasks.parse_outputs.QChemToDb}}"
48+
}
49+
],
50+
"prev_calc_molecule": {
51+
"@module": "pymatgen.core.structure",
52+
"@class": "Molecule",
53+
"charge": -1,
54+
"spin_multiplicity": 2,
55+
"sites": [
56+
{
57+
"name": "C",
58+
"species": [
59+
{
60+
"element": "C",
61+
"occu": 1
62+
}
63+
],
64+
"xyz": [
65+
1.8754703937,
66+
-0.0555233095,
67+
0.0422375917
68+
],
69+
"properties": {}
70+
},
71+
{
72+
"name": "O",
73+
"species": [
74+
{
75+
"element": "O",
76+
"occu": 1
77+
}
78+
],
79+
"xyz": [
80+
1.6042475702,
81+
-1.2905898096,
82+
-0.6352653227
83+
],
84+
"properties": {}
85+
},
86+
{
87+
"name": "C",
88+
"species": [
89+
{
90+
"element": "C",
91+
"occu": 1
92+
}
93+
],
94+
"xyz": [
95+
2.9267520361,
96+
-0.8737188809,
97+
-0.2653132689
98+
],
99+
"properties": {}
100+
}
101+
]
102+
},
103+
"prev_calc_mulliken": [
104+
[
105+
-0.433309,
106+
0.309191
107+
],
108+
[
109+
-0.133493,
110+
0.380939
111+
],
112+
[
113+
-0.433198,
114+
0.309871
115+
]
116+
]
117+
},
118+
"fw_id": 270029,
119+
"created_on": "2019-12-25T22:14:45.871756",
120+
"updated_on": "2019-12-30T14:37:25.354051",
121+
"launches": [
122+
{
123+
"fworker": {
124+
"name": "eagle_qchem_dev",
125+
"category": "",
126+
"query": "{\"spec.tags.class\": {\"$regex\": \"(solv(0|1|2)|m3)_production\"}}",
127+
"env": {
128+
"db_file": "/home/sblau/config/db.json",
129+
"qchem_cmd": "qchem",
130+
"scratch_dir": "/scratch/sblau",
131+
"max_cores": 32,
132+
"multimode": "openmp"
133+
}
134+
},
135+
"fw_id": 270029,
136+
"launch_dir": "/lustre/eaglefs/projects/silimorphous/sblau/new_frags/block_2019-12-21-04-16-21-972200/launcher_2019-12-21-04-26-24-950766",
137+
"host": "r2i1n16",
138+
"ip": "10.148.1.105",
139+
"trackers": [],
140+
"action": null,
141+
"state": "RUNNING",
142+
"state_history": [
143+
{
144+
"state": "RUNNING",
145+
"created_on": "2019-12-30T14:37:25.326892",
146+
"updated_on": "2019-12-30T14:37:25.326896"
147+
}
148+
],
149+
"launch_id": 213664
150+
}
151+
],
152+
"state": "RUNNING",
153+
"name": "C2 O1:CC2_m3frag_6938_charge-1_def2-tzvppd_wb97xv_smd"
154+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -l
2+
3+
#SBATCH --nodes=1
4+
#SBATCH --time=48:00:00
5+
#SBATCH --account=silimorphous
6+
#SBATCH --job-name=prod
7+
#SBATCH --output=prod-%j.out
8+
#SBATCH --error=prod-%j.error
9+
10+
11+
module load q-chem/5.2
12+
cd /lustre/eaglefs/projects/silimorphous/sblau/new_frags/block_2019-12-21-04-16-21-972200/launcher_2019-12-21-04-26-24-950766
13+
rlaunch -c /home/sblau/config singleshot
14+
15+
# CommonAdapter (SLURM) completed writing Template
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"4": {"field": 0.334474322269794, "atom_ids": ["1", "3"], "atoms": ["C", "C"], "distance": 1.3729230763034164}, "5": {"field": 0.245009497662718, "atom_ids": ["1", "2"], "atoms": ["C", "O"], "distance": 1.4585568079278048}, "6": {"field": 0.244795699119763, "atom_ids": ["3", "2"], "atoms": ["C", "O"], "distance": 1.4605371636151308}}

0 commit comments

Comments
 (0)