Skip to content

Commit 8c7d860

Browse files
committed
Merge branch 'main' into qchem
# Conflicts: # atomate/qchem/drones.py # requirements-ci.txt # requirements.txt
2 parents 4e2141c + 1459100 commit 8c7d860

File tree

18 files changed

+133
-110
lines changed

18 files changed

+133
-110
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@ default_install_hook_types: [pre-commit, commit-msg]
99
exclude: ^(docs/|.*test_files/|.*tests/)
1010

1111
repos:
12-
- repo: https://github.com/myint/autoflake
12+
- repo: https://github.com/PyCQA/autoflake
1313
rev: v1.4
1414
hooks:
1515
- id: autoflake
16-
args:
17-
- --in-place
18-
- --remove-unused-variables
19-
- --remove-all-unused-imports
20-
- --expand-star-imports
21-
- --ignore-init-module-imports
2216

2317
- repo: https://github.com/psf/black
2418
rev: 22.6.0
@@ -29,6 +23,7 @@ repos:
2923
rev: 5.0.4
3024
hooks:
3125
- id: flake8
26+
additional_dependencies: [flake8-bugbear]
3227

3328
- repo: https://github.com/pre-commit/mirrors-mypy
3429
rev: v0.971

atomate/qchem/drones.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ def generate_doc(self, dir_name, qcinput_files, qcoutput_files, multirun):
231231
float(d_calc_final["opt_constraint"][6]),
232232
]
233233
if d["output"]["job_type"] in ["freq", "frequency"]:
234-
if len(d_calc_final["initial_molecule"]) != 1:
235-
d["output"]["frequencies"] = d_calc_final["frequencies"]
236-
d["output"]["frequency_modes"] = d_calc_final["frequency_mode_vectors"]
234+
d["output"]["frequencies"] = d_calc_final["frequencies"]
235+
# Note: for single-atom freq calcs, this key may not exist
236+
d["output"]["frequency_modes"] = d_calc_final.get("frequency_mode_vectors", [])
237237
d["output"]["enthalpy"] = d_calc_final["total_enthalpy"]
238238
d["output"]["entropy"] = d_calc_final["total_entropy"]
239239
if d["input"]["job_type"] in ["opt", "optimization", "ts"]:
@@ -507,7 +507,7 @@ def validate_doc(self, d):
507507
to pass validation is unfortunately unlikely to be noticed by a user.
508508
"""
509509
for k, v in self.schema.items():
510-
diff = v.difference(set(d.get(k, d).keys()))
510+
diff = v - set(d.get(k, d).keys())
511511
if diff:
512512
logger.warning(f"The keys {diff} in {k} not set")
513513

atomate/qchem/firetasks/parse_outputs.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ class ProtCalcToDb(FiretaskBase):
223223
224224
Optional params:
225225
calc_dir (str): path to dir (on current filesystem) that contains QChem
226-
input and output files for both the H0 and H2+. Default: use current working directory.
226+
input and output files for both the H2O and H3O+ calculations. Default: use current working directory.
227227
calc_loc (str OR bool): if True will set most recent calc_loc. If str
228228
search for the most recent calc_loc with the matching name
229-
input_file_H0 (str): name of the QChem input file for H0 calculation
230-
output_file_H0 (str): name of the QChem output file for H0 calculation
231-
input_file_H2 (str): name of the QChem input file for H2 calculation
232-
output_file_H2 (str): name of the QChem output file for H2 calculation
229+
input_file_H2O (str): name of the QChem input file for H2O calculation
230+
output_file_H2O (str): name of the QChem output file for H2O calculation
231+
input_file_H3O (str): name of the QChem input file for H3O+ calculation
232+
output_file_H3O (str): name of the QChem output file for H3O+ calculation
233233
additional_fields (dict): dict of additional fields to add
234234
db_file (str): path to file containing the database credentials.
235235
Supports env_chk. Default: write data to JSON file.
@@ -240,10 +240,10 @@ class ProtCalcToDb(FiretaskBase):
240240
optional_params = [
241241
"calc_dir",
242242
"calc_loc",
243-
"input_file_H0",
244-
"output_file_H0",
245-
"input_file_H2",
246-
"output_file_H2",
243+
"input_file_H2O",
244+
"output_file_H2O",
245+
"input_file_H3O",
246+
"output_file_H3O",
247247
"additional_fields",
248248
"db_file",
249249
"runs",
@@ -256,10 +256,10 @@ def run_task(self, fw_spec):
256256
calc_dir = self["calc_dir"]
257257
elif self.get("calc_loc"):
258258
calc_dir = get_calc_loc(self["calc_loc"], fw_spec["calc_locs"])["path"]
259-
input_file_H0 = self.get("input_file_H0", "H0.qin")
260-
output_file_H0 = self.get("output_file_H0", "H0.qout")
261-
input_file_H2 = self.get("input_file_H2", "H2_plus.qin")
262-
output_file_H2 = self.get("output_file_H2", "H2_plus.qout")
259+
input_file_H2O = self.get("input_file_H2O", "water.qin")
260+
output_file_H2O = self.get("output_file_H2O", "water.qout")
261+
input_file_H3O = self.get("input_file_H3O", "hydronium.qin")
262+
output_file_H3O = self.get("output_file_H3O", "hydronium.qout")
263263
runs = self.get("runs", None)
264264

265265
# parse the QChem directory
@@ -272,15 +272,15 @@ def run_task(self, fw_spec):
272272
# assimilate (i.e., parse)
273273
task_doc_1 = drone.assimilate(
274274
path=calc_dir,
275-
input_file=input_file_H0,
276-
output_file=output_file_H0,
275+
input_file=input_file_H2O,
276+
output_file=output_file_H2O,
277277
multirun=False,
278278
)
279279

280280
task_doc_2 = drone.assimilate(
281281
path=calc_dir,
282-
input_file=input_file_H2,
283-
output_file=output_file_H2,
282+
input_file=input_file_H3O,
283+
output_file=output_file_H3O,
284284
multirun=False,
285285
)
286286

@@ -292,6 +292,12 @@ def run_task(self, fw_spec):
292292
task_doc_clean["orig"]["molecule"]["spin_multiplicity"] = 1
293293
task_doc_clean["output"]["initial_molecule"]["charge"] = 1
294294
task_doc_clean["output"]["initial_molecule"]["spin_multiplicity"] = 1
295+
task_doc_clean["output"]["initial_molecule"]["sites"] = [{'name': 'H', 'species': [{'element': 'H', 'occu': 1}], 'xyz': [0.0, 0.0, 0.0], 'properties': {}}]
296+
task_doc_clean["output"]["mulliken"] = [+1.000000]
297+
task_doc_clean["output"]["resp"] = [+1.000000]
298+
task_doc_clean["output"]["optimized_molecule"]["charge"] = 1
299+
task_doc_clean["output"]["optimized_molecule"]["spin_multiplicity"] = 1
300+
task_doc_clean["output"]["optimized_molecule"]["sites"] = [{'name': 'H', 'species': [{'element': 'H', 'occu': 1}], 'xyz': [0.0, 0.0, 0.0], 'properties': {}}]
295301
task_doc_clean["output"]["final_energy"] = (
296302
task_doc_2["output"]["final_energy"] - task_doc_1["output"]["final_energy"]
297303
)

atomate/qchem/fireworks/core.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ def __init__(
117117
"""
118118
For this custom Firework the electronic energy of a proton in a specific solvent environment is approximated.
119119
Since a proton has 0 electrons,running a QChem job would yield an error. The energy can be approximated by
120-
calculating the electronic energy of a proton and a hydrogen atom at infinite separation and then subtracting
121-
the electronic energy of a hydrogen atom. This Firework combines these two calculations and adds a task doc to the
120+
calculating the electronic energy of a hydronium ion and a water molecule and then subtracting
121+
the respective electronic energies. This Firework combines these two calculations and adds a task doc to the
122122
DB with the separate calculation details and the effective energy after subtraction.
123123
124-
Args:
124+
Arg
125125
name (str): Name for the Firework.
126126
qchem_cmd (str): Command to run QChem. Supports env_chk.
127127
multimode (str): Parallelization scheme, either openmp or mpi. Supports env_chk.
@@ -150,21 +150,31 @@ def __init__(
150150

151151
qchem_input_params = qchem_input_params or {}
152152

153-
H_site = Site("H", [0.0, 0.0, 0.0])
154-
H_site_inf = Site("H", [100000.0, 0.0, 0.0])
155-
H0_atom = Molecule.from_sites([H_site])
156-
H2_plus_mol = Molecule.from_sites([H_site, H_site_inf])
157-
H0_atom.set_charge_and_spin(0, 2)
158-
H2_plus_mol.set_charge_and_spin(1, 2)
159-
input_file_1 = "H0.qin"
160-
output_file_1 = "H0.qout"
161-
input_file_2 = "H2_plus.qin"
162-
output_file_2 = "H2_plus.qout"
153+
H_site_1_H2O = Site("H", [0.18338, 2.20176, 0.01351])
154+
H_site_2_H2O = Site("H", [-1.09531, 1.61602, 0.70231])
155+
O_site_H2O = Site("O", [-0.80595, 2.22952, -0.01914])
156+
H2O_molecule = Molecule.from_sites([H_site_1_H2O, H_site_2_H2O, O_site_H2O])
157+
158+
H_site_1_H3O = Site("H", [0.11550, 2.34733, 0.00157])
159+
H_site_2_H3O = Site("H", [-1.17463, 1.77063, 0.67652])
160+
H_site_3_H3O = Site("H", [-1.29839, 2.78012, -0.51436])
161+
O_site_H3O = Site("O", [-0.78481, 1.99137, -0.20661])
162+
H3O_ion = Molecule.from_sites(
163+
[H_site_1_H3O, H_site_2_H3O, H_site_3_H3O, O_site_H3O]
164+
)
165+
166+
H2O_molecule.set_charge_and_spin(0, 1)
167+
H3O_ion.set_charge_and_spin(1, 1)
168+
169+
input_file_1 = "water.qin"
170+
output_file_1 = "water.qout"
171+
input_file_2 = "hydronium.qin"
172+
output_file_2 = "hydronium.qout"
163173
t = []
164174
t.append(
165175
WriteInputFromIOSet(
166-
molecule=H0_atom,
167-
qchem_input_set="SinglePointSet",
176+
molecule=H2O_molecule,
177+
qchem_input_set="OptSet",
168178
input_file=input_file_1,
169179
qchem_input_params=qchem_input_params,
170180
)
@@ -184,8 +194,8 @@ def __init__(
184194

185195
t.append(
186196
WriteInputFromIOSet(
187-
molecule=H2_plus_mol,
188-
qchem_input_set="SinglePointSet",
197+
molecule=H3O_ion,
198+
qchem_input_set="OptSet",
189199
input_file=input_file_2,
190200
qchem_input_params=qchem_input_params,
191201
)
@@ -205,10 +215,10 @@ def __init__(
205215
t.append(
206216
ProtCalcToDb(
207217
db_file=db_file,
208-
input_file_H0=input_file_1,
209-
output_file_H0=output_file_1,
210-
input_file_H2=input_file_2,
211-
output_file_H2=output_file_2,
218+
input_file_H2O=input_file_1,
219+
output_file_H2O=output_file_1,
220+
input_file_H3O=input_file_2,
221+
output_file_H3O=output_file_2,
212222
additional_fields={"task_label": name},
213223
)
214224
)

atomate/qchem/fireworks/tests/test_core.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,30 @@ def test_SinglePointFW_not_defaults(self):
137137
self.assertEqual(firework.name, "special single point")
138138

139139
def test_ProtonEnergyFW(self):
140-
H_site = Site("H", [0.0, 0.0, 0.0])
141-
H_site_inf = Site("H", [100000.0, 0.0, 0.0])
142-
H0_atom = Molecule.from_sites([H_site])
143-
H2_plus_mol = Molecule.from_sites([H_site, H_site_inf])
144-
H0_atom.set_charge_and_spin(0, 2)
145-
H2_plus_mol.set_charge_and_spin(1, 2)
140+
141+
H_site_1_H2O = Site("H", [0.18338, 2.20176, 0.01351])
142+
H_site_2_H2O = Site("H", [-1.09531, 1.61602, 0.70231])
143+
O_site_H2O = Site("O", [-0.80595, 2.22952, -0.01914])
144+
H2O_molecule = Molecule.from_sites([H_site_1_H2O, H_site_2_H2O, O_site_H2O])
145+
146+
H_site_1_H3O = Site("H", [0.11550, 2.34733, 0.00157])
147+
H_site_2_H3O = Site("H", [-1.17463, 1.77063, 0.67652])
148+
H_site_3_H3O = Site("H", [-1.29839, 2.78012, -0.51436])
149+
O_site_H3O = Site("O", [-0.78481, 1.99137, -0.20661])
150+
H3O_ion = Molecule.from_sites(
151+
[H_site_1_H3O, H_site_2_H3O, H_site_3_H3O, O_site_H3O]
152+
)
153+
154+
H2O_molecule.set_charge_and_spin(0, 1)
155+
H3O_ion.set_charge_and_spin(1, 1)
156+
146157
firework = ProtonEnergyFW(qchem_input_params={"smd_solvent": "water"})
147158
self.assertEqual(
148159
firework.tasks[0].as_dict(),
149160
WriteInputFromIOSet(
150-
molecule=H0_atom,
151-
qchem_input_set="SinglePointSet",
152-
input_file="H0.qin",
161+
molecule=H2O_molecule,
162+
qchem_input_set="OptSet",
163+
input_file="water.qin",
153164
qchem_input_params={"smd_solvent": "water"},
154165
).as_dict(),
155166
)
@@ -158,8 +169,8 @@ def test_ProtonEnergyFW(self):
158169
RunQChemCustodian(
159170
qchem_cmd=">>qchem_cmd<<",
160171
multimode=">>multimode<<",
161-
input_file="H0.qin",
162-
output_file="H0.qout",
172+
input_file="water.qin",
173+
output_file="water.qout",
163174
max_cores=">>max_cores<<",
164175
max_errors=5,
165176
job_type="normal",
@@ -169,9 +180,9 @@ def test_ProtonEnergyFW(self):
169180
self.assertEqual(
170181
firework.tasks[2].as_dict(),
171182
WriteInputFromIOSet(
172-
molecule=H2_plus_mol,
173-
qchem_input_set="SinglePointSet",
174-
input_file="H2_plus.qin",
183+
molecule=H3O_ion,
184+
qchem_input_set="OptSet",
185+
input_file="hydronium.qin",
175186
qchem_input_params={"smd_solvent": "water"},
176187
).as_dict(),
177188
)
@@ -180,8 +191,8 @@ def test_ProtonEnergyFW(self):
180191
RunQChemCustodian(
181192
qchem_cmd=">>qchem_cmd<<",
182193
multimode=">>multimode<<",
183-
input_file="H2_plus.qin",
184-
output_file="H2_plus.qout",
194+
input_file="hydronium.qin",
195+
output_file="hydronium.qout",
185196
max_cores=">>max_cores<<",
186197
max_errors=5,
187198
job_type="normal",
@@ -192,10 +203,10 @@ def test_ProtonEnergyFW(self):
192203
firework.tasks[4].as_dict(),
193204
ProtCalcToDb(
194205
db_file=None,
195-
input_file_H0="H0.qin",
196-
output_file_H0="H0.qout",
197-
input_file_H2="H2_plus.qin",
198-
output_file_H2="H2_plus.qout",
206+
input_file_H2O="water.qin",
207+
output_file_H2O="water.qout",
208+
input_file_H3O="hydronium.qin",
209+
output_file_H3O="hydronium.qout",
199210
additional_fields={"task_label": "proton electronic energy"},
200211
).as_dict(),
201212
)

atomate/utils/database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
**kwargs,
3636
):
3737
"""
38-
Obeject to handle storing calculation data to MongoDB databases.
38+
Object to handle storing calculation data to MongoDB databases.
3939
The results of calculations will be parsed by a Drone and
4040
CalcDb is only responsible for putting that data into the database
4141
@@ -50,7 +50,7 @@ def __init__(
5050
other authentication information will be ignored
5151
maggma_store_kwargs: additional kwargs for mongodb login.
5252
Currently supports:
53-
S3 store kwarges:
53+
S3 store kwargs:
5454
"bucket" : the S3 bucket where the data is stored
5555
"s3_profile" : the S3 profile that contains the login information
5656
typically found at ~/.aws/credentials
@@ -255,7 +255,7 @@ def _get_s3_store(self, store_name):
255255
and the store_name will double as the sub_dir name.
256256
257257
Args:
258-
store_name: correspond to the the key within calcs_reversed.0 that will be stored
258+
store_name: correspond to the key within calcs_reversed.0 that will be stored
259259
"""
260260
if self.host_uri is not None:
261261
index_store_ = MongoURIStore(

atomate/vasp/drones.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,9 @@ def validate_doc(self, d):
828828
# notice if the validation fails? -computron
829829
for k, v in self.schema.items():
830830
if k == "calcs_reversed":
831-
diff = v.difference(set(d.get(k, d)[0].keys()))
831+
diff = v - set(d.get(k, d)[0].keys())
832832
else:
833-
diff = v.difference(set(d.get(k, d).keys()))
833+
diff = v - set(d.get(k, d).keys())
834834
if diff:
835835
logger.warning(f"The keys {diff} in {k} not set")
836836

atomate/vasp/firetasks/electrode_tasks.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
from atomate.vasp.database import VaspCalcDb
1111
from atomate.vasp.firetasks import pass_vasp_result
1212
from atomate.vasp.fireworks.core import OptimizeFW, StaticFW
13-
14-
try:
15-
from pymatgen.analysis.defects import ChargeInsertionAnalyzer
16-
except ImportError:
17-
print(
18-
"Failed to import ChargeInsertionAnalyzer. This is likely due to converting the pymatgen defects module "
19-
"to a namespace package. See https://github.com/materialsproject/pymatgen/pull/2582#issuecomment-1198318101 "
20-
"for updates."
21-
)
13+
from pymatgen.analysis.defects.utils import ChargeInsertionAnalyzer
2214

2315
__author__ = "Jimmy Shen"
2416
__email__ = "[email protected]"

atomate/vasp/firetasks/write_inputs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ def run_task(self, fw_spec):
630630
t_cls = None
631631
for m in [
632632
"advanced_transformations",
633-
"defect_transformations",
634633
"site_transformations",
635634
"standard_transformations",
636635
]:
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Si2
22
1.0
3-
3.840198 0.000000 0.000000
4-
1.920099 3.325710 0.000000
5-
0.000000 -2.217138 3.135509
3+
3.8401979336999998 0.0000000000000000 0.0000000000000000
4+
1.9200989667999999 3.3257101909000002 0.0000000000000000
5+
0.0000000000000000 -2.2171384942999999 3.1355090603000000
66
Si
77
2
88
direct
9-
0.000000 0.000000 0.000000 Si
10-
0.750000 0.500000 0.750000 Si
9+
0.0000000000000000 0.0000000000000000 0.0000000000000000 Si
10+
0.7500000000000000 0.5000000000000000 0.7500000000000000 Si

0 commit comments

Comments
 (0)