-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added encoders for TeraChem and the general encoder workflow. Added F…
…ileType.stdout as default filetype for parser decorator to reduce verbosity of parser code.
- Loading branch information
Showing
19 changed files
with
292 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from qcio import CalcType, ProgramInput | ||
|
||
from qcparse.exceptions import EncoderError | ||
from qcparse.models import NativeInput | ||
|
||
SUPPORTED_CALCTYPES = {CalcType.energy, CalcType.gradient, CalcType.hessian} | ||
XYZ_FILENAME = "geometry.xyz" | ||
PADDING = 20 # padding between keyword and value in tc.in | ||
|
||
|
||
def encode(inp_obj: ProgramInput) -> NativeInput: | ||
"""Translate a ProgramInput into TeraChem inputs files. | ||
Args: | ||
inp_obj: The qcio ProgramInput object for a computation. | ||
Returns: | ||
NativeInput with .input being a tc.in file and .geometry an xyz file. | ||
""" | ||
|
||
# calctype | ||
if inp_obj.calctype.value == CalcType.hessian: | ||
calctype = "frequencies" | ||
else: | ||
calctype = inp_obj.calctype.value | ||
|
||
# Collect lines for input file | ||
inp_lines = [] | ||
inp_lines.append(f"{'run':<{PADDING}} {calctype}") | ||
# Molecule | ||
inp_lines.append(f"{'coordinates':<{PADDING}} {XYZ_FILENAME}") | ||
inp_lines.append(f"{'charge':<{PADDING}} {inp_obj.molecule.charge}") | ||
inp_lines.append(f"{'spinmult':<{PADDING}} {inp_obj.molecule.multiplicity}") | ||
# Model | ||
inp_lines.append(f"{'method':<{PADDING}} {inp_obj.model.method}") | ||
inp_lines.append(f"{'basis':<{PADDING}} {inp_obj.model.basis}") | ||
|
||
# Keywords | ||
non_keywords = { | ||
"charge": ".molecule.charge", | ||
"spinmult": ".molecule.multiplicity", | ||
"run": ".calctype", | ||
"basis": ".model.basis", | ||
"method": ".model.method", | ||
} | ||
for key, value in inp_obj.keywords.items(): | ||
# Check for keywords that should be passed as structured data | ||
if key in non_keywords: | ||
raise EncoderError( | ||
f"Keyword '{key}' should not be set as a keyword. It " | ||
f"should be set at '{non_keywords[key]}'", | ||
) | ||
# Lowercase booleans | ||
inp_lines.append(f"{key:<{PADDING}} {str(value).lower()}") | ||
return NativeInput( | ||
input_file="\n".join(inp_lines) + "\n", # End file with newline | ||
geometry_file=inp_obj.molecule.to_xyz(), | ||
geometry_filename=XYZ_FILENAME, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.