Skip to content

Commit

Permalink
General improvements following reviews.
Browse files Browse the repository at this point in the history
- `conversion_factor()` function used to convert from eV to Hartree.
- cclib is just imported when invoking `.parse_output()`.
- `.get_gradient()` renamed to `._get_gradient()` so that it becomes
  a private function.
  • Loading branch information
muammar committed Jan 10, 2020
1 parent 0e3d699 commit 21ae056
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions qcengine/programs/orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"""

import string
import cclib
import io
import numpy as np
from typing import Any, Dict, List, Optional, Set, Tuple

from qcelemental.models import AtomicResult
from qcelemental.constants import conversion_factor
from qcelemental.util import parse_version, which
from qcelemental.models import AtomicResult

from ..exceptions import InputError, UnknownError
from ..util import execute
Expand Down Expand Up @@ -230,12 +230,16 @@ def build_input(
}

def parse_output(self, outfiles: Dict[str, str], input_model: "AtomicInput") -> "AtomicResult":
try:
import cclib
except ImportError:
raise("You need to install the cclib python module...")

data = cclib.io.ccread(io.StringIO(outfiles["stdout"]))

properties = {}
extras = {}
extras["ev_to_hartrees"] = 0.0367493
extras["ev_to_hartrees"] = conversion_factor("ev", "hartree")

# Process basis set data
properties["calcinfo_nbasis"] = data.nbasis
Expand All @@ -262,7 +266,7 @@ def parse_output(self, outfiles: Dict[str, str], input_model: "AtomicInput") ->
extras["CURRENT ENERGY"] = final_energy

elif input_model.driver == "gradient":
gradient = self.get_gradient(outfiles["outfiles"]["dispatch.engrad"])
gradient = self._get_gradient(outfiles["outfiles"]["dispatch.engrad"])
output_data["return_result"] = gradient
extras["CURRENT ENERGY"] = final_energy
extras["CURRENT GRADIENT"] = gradient
Expand All @@ -277,7 +281,7 @@ def parse_output(self, outfiles: Dict[str, str], input_model: "AtomicInput") ->

return AtomicResult(**output_data)

def get_gradient(self, gradient_file):
def _get_gradient(self, gradient_file):
"""Get gradient from engrad Orca file"""
copy = False
found = False
Expand Down

0 comments on commit 21ae056

Please sign in to comment.