Skip to content

Commit 23d300f

Browse files
authored
Merge pull request #716 from samblau/qchem
Q-Chem NBO and misc updates
2 parents 0e4547f + 7cc965a commit 23d300f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+213
-67
lines changed

atomate/qchem/drones.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ def generate_doc(self, dir_name, qcinput_files, qcoutput_files, multirun):
274274
if d_calc_final["CDS_gradients"] is not None:
275275
d["output"]["CDS_gradients"] = d_calc_final["CDS_gradients"][0]
276276

277+
if d["output"]["job_type"] == "force":
278+
d["output"]["gradients"] = d_calc_final["gradients"][0]
279+
if d_calc_final["pcm_gradients"] is not None:
280+
d["output"]["pcm_gradients"] = d_calc_final["pcm_gradients"][0]
281+
if d_calc_final["CDS_gradients"] is not None:
282+
d["output"]["CDS_gradients"] = d_calc_final["CDS_gradients"][0]
283+
277284
opt_trajectory = []
278285
calcs = copy.deepcopy(d["calcs_reversed"])
279286
calcs.reverse()

atomate/qchem/firetasks/run_calc.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class RunQChemCustodian(FiretaskBase):
7171
calc_loc (str): Path where Q-Chem should run. Will env_chk by default. If not in
7272
environment, will be set to None, in which case Q-Chem will run in
7373
the system-defined QCLOCALSCR.
74+
nboexe (str): Path to the NBO7 executable.
7475
save_scratch (bool): Whether to save scratch directory contents. Defaults to False.
7576
max_errors (int): Maximum # of errors to fix before giving up (default=5)
7677
job_type (str): Choose from "normal" (default) and "opt_with_frequency_flattener"
@@ -98,6 +99,7 @@ class RunQChemCustodian(FiretaskBase):
9899
"qclog_file",
99100
"suffix",
100101
"calc_loc",
102+
"nboexe",
101103
"save_scratch",
102104
"max_errors",
103105
"job_type",
@@ -128,7 +130,8 @@ def run_task(self, fw_spec):
128130
max_cores = env_chk(self["max_cores"], fw_spec)
129131
qclog_file = self.get("qclog_file", "mol.qclog")
130132
suffix = self.get("suffix", "")
131-
calc_loc = env_chk(self.get("calc_loc"), fw_spec)
133+
calc_loc = self.get("calc_loc", env_chk(">>calc_loc<<", fw_spec, strict=False))
134+
nboexe = self.get("nboexe", env_chk(">>nboexe<<", fw_spec, strict=False))
132135
save_scratch = self.get("save_scratch", False)
133136
max_errors = self.get("max_errors", 5)
134137
max_iterations = self.get("max_iterations", 10)
@@ -141,9 +144,7 @@ def run_task(self, fw_spec):
141144
freq_before_opt = self.get("freq_before_opt", False)
142145

143146
handler_groups = {
144-
"default": [
145-
QChemErrorHandler(input_file=input_file, output_file=output_file)
146-
],
147+
"default": [QChemErrorHandler(input_file=input_file, output_file=output_file)],
147148
"no_handler": [],
148149
}
149150

@@ -159,6 +160,7 @@ def run_task(self, fw_spec):
159160
qclog_file=qclog_file,
160161
suffix=suffix,
161162
calc_loc=calc_loc,
163+
nboexe=nboexe,
162164
save_scratch=save_scratch,
163165
backup=backup,
164166
)
@@ -178,6 +180,7 @@ def run_task(self, fw_spec):
178180
save_final_scratch=save_scratch,
179181
max_cores=max_cores,
180182
calc_loc=calc_loc,
183+
nboexe=nboexe,
181184
)
182185
else:
183186
jobs = QCJob.opt_with_frequency_flattener(
@@ -194,6 +197,7 @@ def run_task(self, fw_spec):
194197
save_final_scratch=save_scratch,
195198
max_cores=max_cores,
196199
calc_loc=calc_loc,
200+
nboexe=nboexe,
197201
)
198202

199203
else:
@@ -202,9 +206,7 @@ def run_task(self, fw_spec):
202206
# construct handlers
203207
handlers = handler_groups[self.get("handler_group", "default")]
204208

205-
c = Custodian(
206-
handlers, jobs, max_errors=max_errors, gzipped_output=gzipped_output
207-
)
209+
c = Custodian(handlers, jobs, max_errors=max_errors, gzipped_output=gzipped_output)
208210

209211
c.run()
210212

@@ -246,9 +248,7 @@ def _verify_inputs(self):
246248
ref_qin = QCInput.from_file(os.path.join(self["ref_dir"], input_file))
247249

248250
np.testing.assert_equal(ref_qin.molecule.species, user_qin.molecule.species)
249-
np.testing.assert_allclose(
250-
ref_qin.molecule.cart_coords, user_qin.molecule.cart_coords, atol=0.0001
251-
)
251+
np.testing.assert_allclose(ref_qin.molecule.cart_coords, user_qin.molecule.cart_coords, atol=0.0001)
252252
for key in ref_qin.rem:
253253
if user_qin.rem.get(key) != ref_qin.rem.get(key):
254254
raise ValueError(f"Rem key {key} is inconsistent!")

atomate/qchem/firetasks/tests/test_run_calc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def test_RunQChemCustodian_using_fw_spec_defaults(self):
8989
with patch("atomate.qchem.firetasks.run_calc.Custodian") as custodian_patch:
9090
firetask = RunQChemCustodian(
9191
qchem_cmd=">>qchem_cmd<<",
92-
calc_loc=">>calc_loc<<",
9392
input_file=os.path.join(
9493
module_dir, "..", "..", "test_files", "co_qc.in"
9594
),
@@ -103,6 +102,7 @@ def test_RunQChemCustodian_using_fw_spec_defaults(self):
103102
"calc_loc": "/this/is/a/test",
104103
"max_cores": 32,
105104
"multimode": "openmp",
105+
"nboexe": "/path/to/nbo7.i4.exe",
106106
}
107107
}
108108
)
@@ -121,6 +121,7 @@ def test_RunQChemCustodian_using_fw_spec_defaults(self):
121121
QCJob(
122122
qchem_command="qchem -slurm",
123123
calc_loc="/this/is/a/test",
124+
nboexe="/path/to/nbo7.i4.exe",
124125
max_cores=32,
125126
multimode="openmp",
126127
input_file=os.path.join(
@@ -179,7 +180,6 @@ def test_RunQChemCustodian_using_fw_spec_not_defaults(self):
179180
with patch("atomate.qchem.firetasks.run_calc.Custodian") as custodian_patch:
180181
firetask = RunQChemCustodian(
181182
qchem_cmd=">>qchem_cmd<<",
182-
calc_loc=">>calc_loc<<",
183183
multimode=">>multimode<<",
184184
input_file=os.path.join(
185185
module_dir, "..", "..", "test_files", "co_qc.in"
@@ -283,6 +283,7 @@ def test_RunQChemCustodian_FF_basic_defaults(self):
283283
"calc_loc": None,
284284
"freq_before_opt": False,
285285
"transition_state": False,
286+
"nboexe": None,
286287
},
287288
)
288289

@@ -293,7 +294,6 @@ def test_RunQChemCustodian_FF_using_fw_spec_defaults(self):
293294
) as FF_patch:
294295
firetask = RunQChemCustodian(
295296
qchem_cmd=">>qchem_cmd<<",
296-
calc_loc=">>calc_loc<<",
297297
max_cores=">>max_cores<<",
298298
multimode=">>multimode<<",
299299
input_file=os.path.join(
@@ -354,6 +354,7 @@ def test_RunQChemCustodian_FF_using_fw_spec_defaults(self):
354354
"max_cores": 32,
355355
"freq_before_opt": False,
356356
"transition_state": False,
357+
"nboexe": None,
357358
},
358359
)
359360

@@ -365,6 +366,7 @@ def test_RunQChemCustodian_FF_basic_not_defaults(self):
365366
firetask = RunQChemCustodian(
366367
qchem_cmd="qchem -slurm",
367368
calc_loc="/this/is/a/test",
369+
nboexe="/path/to/nbo7.i4.exe",
368370
input_file=os.path.join(
369371
module_dir,
370372
"..",
@@ -425,6 +427,7 @@ def test_RunQChemCustodian_FF_basic_not_defaults(self):
425427
"max_molecule_perturb_scale": 0.5,
426428
"linked": False,
427429
"calc_loc": "/this/is/a/test",
430+
"nboexe": "/path/to/nbo7.i4.exe",
428431
"save_final_scratch": True,
429432
"max_cores": 4,
430433
"freq_before_opt": True,
@@ -439,7 +442,6 @@ def test_RunQChemCustodian_FF_using_fw_spec_not_defaults(self):
439442
) as FF_patch:
440443
firetask = RunQChemCustodian(
441444
qchem_cmd=">>qchem_cmd<<",
442-
calc_loc=">>calc_loc<<",
443445
input_file=os.path.join(
444446
module_dir,
445447
"..",
@@ -509,6 +511,7 @@ def test_RunQChemCustodian_FF_using_fw_spec_not_defaults(self):
509511
"max_molecule_perturb_scale": 0.5,
510512
"linked": False,
511513
"calc_loc": "/this/is/a/test",
514+
"nboexe": None,
512515
"save_final_scratch": True,
513516
"max_cores": 4,
514517
"freq_before_opt": True,

atomate/qchem/firetasks/tests/test_write_inputs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ def test_write_input(self):
105105
rem = {
106106
"job_type": "opt",
107107
"basis": "def2-tzvppd",
108-
"max_scf_cycles": 200,
108+
"max_scf_cycles": 100,
109109
"method": "wB97xd",
110110
"geom_opt_max_cycles": 200,
111111
"gen_scfman": True,
112112
"scf_algorithm": "diis",
113113
"xc_grid": 3,
114+
"thresh": 14,
115+
"s2thresh": 16,
114116
"sym_ignore": True,
115117
"symmetry": False,
116118
"resp_charges": True,
@@ -127,12 +129,14 @@ def test_write_custom_input(self):
127129
rem = {
128130
"job_type": "opt",
129131
"basis": "def2-tzvppd",
130-
"max_scf_cycles": 200,
132+
"max_scf_cycles": 100,
131133
"method": "wB97xd",
132134
"geom_opt_max_cycles": 200,
133135
"gen_scfman": True,
134136
"scf_algorithm": "diis",
135137
"xc_grid": 3,
138+
"thresh": 14,
139+
"s2thresh": 16,
136140
"sym_ignore": True,
137141
"symmetry": False,
138142
"resp_charges": True,

atomate/qchem/fireworks/core.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(
3434
qchem_input_params=None,
3535
db_file=None,
3636
parents=None,
37+
max_errors=5,
3738
**kwargs
3839
):
3940
"""
@@ -83,6 +84,7 @@ def __init__(
8384
input_file=input_file,
8485
output_file=output_file,
8586
max_cores=max_cores,
87+
max_errors=max_errors,
8688
job_type="normal",
8789
)
8890
)
@@ -108,6 +110,7 @@ def __init__(
108110
qchem_input_params=None,
109111
db_file=None,
110112
parents=None,
113+
max_errors=5,
111114
**kwargs
112115
):
113116
"""
@@ -157,6 +160,7 @@ def __init__(
157160
input_file=input_file,
158161
output_file=output_file,
159162
max_cores=max_cores,
163+
max_errors=max_errors,
160164
job_type="normal",
161165
)
162166
)
@@ -182,6 +186,7 @@ def __init__(
182186
qchem_input_params=None,
183187
db_file=None,
184188
parents=None,
189+
max_errors=20,
185190
**kwargs
186191
):
187192
"""
@@ -232,6 +237,7 @@ def __init__(
232237
input_file=input_file,
233238
output_file=output_file,
234239
max_cores=max_cores,
240+
max_errors=max_errors,
235241
job_type="normal",
236242
)
237243
)
@@ -257,6 +263,7 @@ def __init__(
257263
qchem_input_params=None,
258264
db_file=None,
259265
parents=None,
266+
max_errors=5,
260267
**kwargs
261268
):
262269
"""
@@ -307,6 +314,7 @@ def __init__(
307314
input_file=input_file,
308315
output_file=output_file,
309316
max_cores=max_cores,
317+
max_errors=max_errors,
310318
job_type="normal",
311319
)
312320
)
@@ -332,6 +340,7 @@ def __init__(
332340
qchem_input_params=None,
333341
db_file=None,
334342
parents=None,
343+
max_errors=5,
335344
**kwargs
336345
):
337346
"""
@@ -382,6 +391,7 @@ def __init__(
382391
input_file=input_file,
383392
output_file=output_file,
384393
max_cores=max_cores,
394+
max_errors=max_errors,
385395
job_type="normal",
386396
)
387397
)
@@ -408,6 +418,7 @@ def __init__(
408418
scan_variables=None,
409419
db_file=None,
410420
parents=None,
421+
max_errors=5,
411422
**kwargs
412423
):
413424
"""
@@ -467,6 +478,7 @@ def __init__(
467478
input_file=input_file,
468479
output_file=output_file,
469480
max_cores=max_cores,
481+
max_errors=max_errors,
470482
job_type="normal",
471483
)
472484
)
@@ -499,6 +511,7 @@ def __init__(
499511
scale=1.0,
500512
db_file=None,
501513
parents=None,
514+
max_errors=20,
502515
**kwargs
503516
):
504517
"""
@@ -586,6 +599,7 @@ def __init__(
586599
max_molecule_perturb_scale=max_molecule_perturb_scale,
587600
linked=linked,
588601
freq_before_opt=freq_before_opt,
602+
max_errors=max_errors,
589603
)
590604
)
591605
t.append(
@@ -621,6 +635,7 @@ def __init__(
621635
scale=1,
622636
db_file=None,
623637
parents=None,
638+
max_errors=5,
624639
**kwargs
625640
):
626641
"""
@@ -719,6 +734,7 @@ def __init__(
719734
transition_state=True,
720735
linked=linked,
721736
freq_before_opt=freq_before_opt,
737+
max_errors=max_errors,
722738
)
723739
)
724740
t.append(
@@ -819,6 +835,7 @@ def __init__(
819835
qchem_input_params=None,
820836
db_file=None,
821837
parents=None,
838+
max_errors=5,
822839
**kwargs
823840
):
824841
"""
@@ -871,6 +888,7 @@ def __init__(
871888
input_file=input_file,
872889
output_file=output_file,
873890
max_cores=max_cores,
891+
max_errors=max_errors,
874892
job_type="normal",
875893
)
876894
)

0 commit comments

Comments
 (0)