Skip to content

Commit

Permalink
Added support for --molden and --json output specifications in xtb
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Oct 8, 2023
1 parent c423769 commit 2fdb981
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
18 changes: 12 additions & 6 deletions ccinput/packages/orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,19 @@ def handle_command(self):

electrons -= self.calc.charge

if self.calc.multiplicity != 1:
raise InvalidParameter("Unimplemented multiplicity")
if self.calc.multiplicity == 1:
n_HOMO = (electrons // 2) - 1
n_LUMO = electrons // 2
n_LUMO1 = (electrons // 2) + 1
n_LUMO2 = (electrons // 2) + 2
elif self.calc.multiplicity == 2:
n_HOMO = ((electrons + 1) // 2) - 1
n_LUMO = (electrons + 1) // 2
n_LUMO1 = ((electrons + 1) // 2) + 1
n_LUMO2 = ((electrons + 1) // 2) + 2

n_HOMO = int(electrons / 2) - 1
n_LUMO = int(electrons / 2)
n_LUMO1 = int(electrons / 2) + 1
n_LUMO2 = int(electrons / 2) + 2
else:
raise InvalidParameter("Unimplemented multiplicity")

mo_block = f"""%plots
dim1 45
Expand Down
6 changes: 5 additions & 1 deletion ccinput/packages/xtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ def handle_specifications(self):
self.cmd_arguments += "--squick "
elif ss[0] == "mquick":
self.cmd_arguments += "--mquick "
elif ss[0] == "molden":
self.cmd_arguments += "--molden "
elif ss[0] == "json":
self.cmd_arguments += "--json "
elif ss[0] == "concerted":
if self.calc.type not in [
CalcType.CONSTR_OPT,
Expand All @@ -237,7 +241,7 @@ def handle_specifications(self):
self.concerted_scan = True

else:
raise InvalidParameter("Invalid specification")
raise InvalidParameter("Invalid specification: {ss}")
elif len(ss) == 2:
if ss[0] == "o" or ss[0] == "opt":
if ss[1] not in [
Expand Down
32 changes: 32 additions & 0 deletions ccinput/tests/test_xtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,3 +847,35 @@ def test_unavailable_calc_type(self):

with self.assertRaises(ImpossibleCalculation):
xtb = self.generate_calculation(**params)

def test_molden_output(self):
params = {
"type": "Geometrical Optimisation",
"file": "Cl.xyz",
"software": "xtb",
"charge": "-1",
"specifications": "--molden",
}

xtb = self.generate_calculation(**params)

REF = "xtb Cl.xyz --opt tight --chrg -1 --molden"

self.assertTrue(self.is_equivalent(REF, xtb.command))
self.assertTrue(self.is_equivalent("", xtb.input_file))

def test_json_output(self):
params = {
"type": "Geometrical Optimisation",
"file": "Cl.xyz",
"software": "xtb",
"charge": "-1",
"specifications": "--JSon",
}

xtb = self.generate_calculation(**params)

REF = "xtb Cl.xyz --opt tight --chrg -1 --json"

self.assertTrue(self.is_equivalent(REF, xtb.command))
self.assertTrue(self.is_equivalent("", xtb.input_file))

0 comments on commit 2fdb981

Please sign in to comment.