Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def harvest_outfile_pass(outtext):
"""Function to read NWChem output file *outtext* and parse important
quantum chemical information from it in
"""
psivar = PreservingDict()
psivar_coord = None
psivar_grad = None
version = ""
error = "" # TODO (wardlt): The error string is never used.
NUMBER = r"(?x:" + regex.NUMBER + ")"
# fmt: off
# Process version
mobj = re.search(
r'^\s+' + r'Northwest Computational Chemistry Package (NWChem)' + r'\s+' + r'(?:\d+.\d+)' + r'\s*$',
outtext, re.MULTILINE)
if mobj:
logger.debug('matched version')
version = mobj.group('version')
def parse_reference_energy(stdout: str):
"""Parse stdout and return the energy of the reference wavefunction."""
energy_dict = PreservingDict()
# Total energy from dscf or ridft
total_energy_re = re.compile("total energy\s+=\s+([\d\-\.]+)")
mobj = total_energy_re.search(stdout)
total_energy = Decimal(mobj[1])
# Check for DFT, default to HF
energy_key = "HF TOTAL ENERGY"
dft_mobj = re.search("density functional", stdout)
if dft_mobj:
energy_key = "DFT TOTAL ENERGY"
energy_dict[energy_key] = total_energy
# Take into account energies from ricc2 runs. They will be different
# from the HF energy.
current_energy = total_energy
def parse_ricc2(stdout: str):
ricc2_dict = PreservingDict()
# As CC2 starts from a MP2 guess that is also reported there may be
# multiple matches for the following regex. Thats why we capture all
# matches with 'findall'.
matches = parse_decimal("Final (.+?) energy\s+:\s+", stdout, "findall")
if len(matches) == 0:
matches = parse_decimal("E(MP2)\s+:\s+", stdout, "search")
ricc2_dict["CURRENT ENERGY"] = matches[-1][1]
return ricc2_dict
def harvest_outfile_pass(outtext):
"""Function to read CFOUR output file *outtext* and parse important
quantum chemical information from it in
"""
psivar = PreservingDict()
psivar_coord = None
psivar_grad = None
version = ""
error = ""
# TODO: BCC
# CI
# QCISD(T)
# other ROHF tests
# vcc/ecc
# fmt: off
NUMBER = r'(?x:' + regex.NUMBER + ')'
# Process version
mobj = re.search(r'^\s*' + r'Version' + r'\s+' + r'(?P[\w.]+)' + r'\s*$',
def harvest_outfile_pass(outtext):
"""Function to read gamess output file *outtext* and parse important
quantum chemical information from it in
"""
qcvar = PreservingDict()
qcvar_coord = None
qcvar_grad = None
NUMBER = r"(?x:" + regex.NUMBER + ")"
# If calculation fail to converge
mobj = re.search(r"^\s+" + r"(?:GAMESS TERMINATED ABNORMALLY)" + r"\s*$", outtext, re.MULTILINE)
if mobj:
logger.debug("GAMESS TERMINATED ABNORMALLY")
# If calculation converged
# fmt: off
else:
mobj = re.search(
r'^\s+' + r'(?: TOTAL ENERGY)' + r'\s+=\s*' + NUMBER + r's*$',
outtext, re.MULTILINE)
def harvest(input_model, stdout, **outfiles):
qcvars = PreservingDict()
ref_energy_dict = parse_reference_energy(stdout)
qcvars.update(ref_energy_dict)
if "R I C C 2" in stdout:
ricc2_dict = parse_ricc2(stdout)
qcvars.update(ricc2_dict)
gradient = None
if "gradient" in outfiles:
gradient = parse_gradient(outfiles["gradient"])
hessian = None
return qcvars, gradient, hessian