Skip to content

Commit

Permalink
Added standard energy and gradients to results
Browse files Browse the repository at this point in the history
   * Added 'energy' and 'gradients' to optional results to support e.g. Energy Scan
   * Fixed crashing bug in description of the Energy substep.
  • Loading branch information
paulsaxe committed May 23, 2024
1 parent 6198055 commit 680f29e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.5.23 -- Added standard energy and gradients to results
* Added 'energy' and 'gradients' to optional results to support e.g. Energy Scan
* Fixed crashing bug in description of the Energy substep.

2024.3.17 -- Updated the installer
* Updated the installer to use the new version of the SEAMM installer.
* Finalizes installing either with Conda or Docker
Expand Down
9 changes: 8 additions & 1 deletion psi4_step/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def description_text(
):
"""Prepare information about what this node will do"""

if P is not None:
if P is None:
P = self.parameters.values_to_dict()

if P["level"] == "recommended":
Expand Down Expand Up @@ -273,6 +273,7 @@ def get_input(self, calculation_type="energy", restart=None):
lines.append(
f"Eelec, wfn = {calculation_type}('{functional}', return_wfn=True)"
)
lines.append(f"G = gradient('{functional}', ref_wfn=wfn)")
else:
if calculation_type == "gradient":
lines.append(
Expand All @@ -290,6 +291,7 @@ def get_input(self, calculation_type="energy", restart=None):
lines.append(
f"Eelec, wfn = {calculation_type}('{method}', return_wfn=True)"
)
lines.append(f"G = gradient('{method}', ref_wfn=wfn)")
else:
if calculation_type == "gradient":
lines.append(
Expand Down Expand Up @@ -332,6 +334,11 @@ def get_input(self, calculation_type="energy", restart=None):
for item in arrays:
variables[item] = wfn.array_variable(item).np.tolist()
variables["Eelec"] = Eelec
variables["energy"] = Eelec
try:
variables["gradient"] = np.array(G).tolist()
except Exception:
pass
variables["_method"] = "{method}"
variables["_method_string"] = "{method_string}"
Expand Down
14 changes: 13 additions & 1 deletion psi4_step/psi4_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,19 @@
Optional units for the result. If present, the value should be in these units.
"""
metadata["results"] = {
"energy": {
"description": "The total energy",
"dimensionality": "scalar",
"property": "total energy#Psi4#{model}",
"type": "float",
"units": "kJ/mol",
},
"gradients": {
"description": "The gradients",
"dimensionality": "[3, n_atoms]",
"type": "float",
"units": "kJ/mol/Å",
},
"(T) CORRECTION ENERGY": {
"calculation": ["energy", "optimization", "thermochemistry", "vibrations"],
"description": "",
Expand Down Expand Up @@ -1816,7 +1829,6 @@
"description": "the electronic energy from the current method",
"dimensionality": "scalar",
"methods": ["ccsd", "ccsd(t)", "dft", "hf", "lccd", "mp2", "mp3", "mp4"],
"property": "total energy#Psi4#{model}",
"type": "float",
"units": "E_h",
},
Expand Down

0 comments on commit 680f29e

Please sign in to comment.