From 2fdb981e52dac6c44357747887c64789ee48aa71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Robidas?= Date: Sun, 8 Oct 2023 13:33:20 -0400 Subject: [PATCH] Added support for --molden and --json output specifications in xtb --- ccinput/packages/orca.py | 18 ++++++++++++------ ccinput/packages/xtb.py | 6 +++++- ccinput/tests/test_xtb.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ccinput/packages/orca.py b/ccinput/packages/orca.py index 3858281..5e23bc9 100644 --- a/ccinput/packages/orca.py +++ b/ccinput/packages/orca.py @@ -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 diff --git a/ccinput/packages/xtb.py b/ccinput/packages/xtb.py index 2ab927a..c5e7d39 100644 --- a/ccinput/packages/xtb.py +++ b/ccinput/packages/xtb.py @@ -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, @@ -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 [ diff --git a/ccinput/tests/test_xtb.py b/ccinput/tests/test_xtb.py index 15d73cb..a6526bc 100644 --- a/ccinput/tests/test_xtb.py +++ b/ccinput/tests/test_xtb.py @@ -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))