Skip to content

Commit

Permalink
Fixed G16 confirmed specifications and alternate specification syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Mar 22, 2022
1 parent 1373121 commit b6e1967
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ccinput/packages/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def handle_specifications(self):
for option in options.split(","):
if option.strip() != "":
self.add_option(key, option)
elif spec.find("=") != -1:
try:
key, option = spec.split("=")
except ValueError:
raise InvalidParameter(f"Invalid specification: {spec}")
self.add_option(key, option)
else:
self.add_option(spec, "")

Expand Down Expand Up @@ -371,7 +377,8 @@ def create_input_file(self):
if cmd.lower() != "scrf":
spec_options = []
for o in options:
print(o)
if o.strip() == "":
continue
if self.calc.type == CalcType.TS and o in [
"ts",
"NoEigenTest",
Expand All @@ -383,6 +390,7 @@ def create_input_file(self):
spec_options.append(o)
if len(spec_options) > 0:
spec_option_str = ", ".join(spec_options)

confirmed_spec = f"{cmd}({spec_option_str}) "
if cmd in self.KEYWORD_LIST:
self.confirmed_specifications = (
Expand Down
47 changes: 47 additions & 0 deletions ccinput/tests/test_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,53 @@ def test_multiple_global_specification3(self):
self.assertTrue(self.is_equivalent(REF, inp.input_file))
self.assertEqual(inp.confirmed_specifications.strip(), "scf(tight, xqc)")

def test_alternate_syntax_specification(self):
params = {
"nproc": 8,
"mem": "10000MB",
"type": "Single-Point Energy",
"file": "Cl.xyz",
"software": "Gaussian",
"method": "M06-2X",
"basis_set": "Def2-SVP",
"charge": "-1",
"specifications": "SCF=Tight",
}

inp = self.generate_calculation(**params)

REF = """
%chk=calc.chk
%nproc=8
%mem=10000MB
#p sp M062X/Def2SVP scf(tight)
File created by ccinput
-1 1
Cl 0.0 0.0 0.0
"""

self.assertTrue(self.is_equivalent(REF, inp.input_file))
self.assertEqual(inp.confirmed_specifications.strip(), "scf(tight)")

def test_alternate_syntax_specification_invalid(self):
params = {
"nproc": 8,
"mem": "10000MB",
"type": "Single-Point Energy",
"file": "Cl.xyz",
"software": "Gaussian",
"method": "M06-2X",
"basis_set": "Def2-SVP",
"charge": "-1",
"specifications": "SCF=Tight=2",
}

with self.assertRaises(InvalidParameter):
self.generate_calculation(**params)

def test_cmd_specification(self):
params = {
"nproc": 8,
Expand Down

0 comments on commit b6e1967

Please sign in to comment.