Skip to content

Commit

Permalink
Began command line xtb support
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Apr 13, 2022
1 parent 37728f1 commit ef52249
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ccinput/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ def __init__(

if method == "":
if "functional" in kwargs:
method = get_method(kwargs["functional"], self.software)
self.method = get_method(kwargs["functional"], self.software)
elif self.software == "xtb":
method = "GFN2-xTB"
self.method = "gfn2-xtb"
else:
raise InvalidParameter("No calculation method specified (method='...')")

else:
self.method = get_method(method, self.software)

self.theory_level = get_theory_level(method)
self.theory_level = get_theory_level(self.method)

if self.theory_level not in ["semiempirical", "xtb", "special"]:
self.basis_set = get_abs_basis_set(basis_set)
Expand Down
2 changes: 1 addition & 1 deletion ccinput/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CalcType(Enum):
"hf": ["hartreefock"],
# Some old exotic semi-empirical methods in ORCA are missing
"semiempirical": ["am1", "pm3", "pm6", "pm7", "mndo"],
"xtb": ["gfn2xtb", "gfn1xtb", "gfn0xtb", "gfnff", "gfn2xtbgfnff"],
"xtb": ["gfn2xtb", "xtb2", "xtb1", "gfn1xtb", "gfn0xtb", "gfnff", "gfn2xtbgfnff"],
"special": ["hf3c", "pbeh3c", "r2scan3c", "b973c"],
"mp2": ["mp2", "rimp2"],
"cc": [
Expand Down
24 changes: 24 additions & 0 deletions ccinput/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,30 @@ def test_preset_additive_specifications(self):
line = '--preset specification --xyz "Cl 0 0 0" -c -1 --specification "5d"'
self.assertTrue(self.args_cmd_equivalent(args, line))

def test_sp_xtb(self):
args = {
"software": "xtb",
"type": "sp",
"file": self.struct("ethanol"),
}

inp = gen_input(**args)

line = "xtb ethanol.xyz"
self.assertEqual(inp, line)

def test_opt_xtb(self):
args = {
"software": "xtb",
"type": "opt",
"file": self.struct("ethanol"),
}

inp = gen_input(**args)

line = "xtb ethanol.xyz --opt tight"
self.assertEqual(inp, line)


class ManualCliTests(InputTests):
def setUp(self):
Expand Down
11 changes: 7 additions & 4 deletions ccinput/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,19 @@ def generate_calculation(
if type is None:
raise InvalidParameter("Specify a calculation type")

if method is None:
raise InvalidParameter("Specify a calculation method")

if xyz == "":
raise InvalidParameter("No input structure")

xyz_structure = standardize_xyz(xyz)

abs_software = get_abs_software(software)

if method is None:
if abs_software == "xtb":
method = "gfn2-xtb"
else:
raise InvalidParameter("Specify a calculation method")

calc_type = get_abs_type(type)

params = Parameters(
Expand Down Expand Up @@ -160,7 +163,7 @@ def gen_obj(**args):


def gen_input(**args):
return gen_obj(**args).input_file
return gen_obj(**args).output


def write_input(filename, **args):
Expand Down

0 comments on commit ef52249

Please sign in to comment.