Skip to content

Commit

Permalink
Code style standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
lint-action committed Apr 17, 2023
1 parent d5a5506 commit 0a6c69a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 52 deletions.
8 changes: 4 additions & 4 deletions ccinput/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CalcType(Enum):
"orca": ["orca5"],
"qchem": [],
"xtb": [],
"psi4":["psi4"]
"psi4": ["psi4"],
}

SYN_SOLVENTS = {
Expand Down Expand Up @@ -1615,7 +1615,7 @@ class CalcType(Enum):
"pbe": "pbe",
"pw91": "pw91",
"revpbe": "revpbe",
"rpbe": "rpbe",
"rpbe": "rpbe",
},
}

Expand Down Expand Up @@ -2058,8 +2058,8 @@ class CalcType(Enum):
"sto3g": "sto-3g",
"631g": "6-31G",
"ccpvdz": "cc-pVDZ",
"def2tzvp": "def2-tzvp"
}
"def2tzvp": "def2-tzvp",
},
}

SOFTWARE_SOLVENTS = {
Expand Down
42 changes: 18 additions & 24 deletions ccinput/packages/psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class Psi4Calculation:
"""

CALC_TYPES = {
CalcType.SP: ["sp","energy"],
CalcType.SP: ["sp", "energy"],
CalcType.OPT: ["optimize"],
# CalcType.CONSTR_OPT,
# CalcType.FREQ,
# CalcType.TS,
# CalcType.OPTFREQ,
}

def __init__(self, calc: Calculation):
self.calc = calc
self.has_scan = False
Expand All @@ -49,7 +49,8 @@ def __init__(self, calc: Calculation):
self.input_file = ""

if self.calc.type not in self.CALC_TYPES:
raise UnimplementedError(f"Calculation Type {self.calc.type} not implemented yet for psi4"
raise UnimplementedError(
f"Calculation Type {self.calc.type} not implemented yet for psi4"
)
self.type_method = ""

Expand All @@ -58,9 +59,7 @@ def __init__(self, calc: Calculation):
self.handle_xyz()

self.handle_solvation()




self.create_input_file()

def clean(self, s):
Expand All @@ -85,19 +84,19 @@ def handle_specifications(self):
return

def handle_command(self):
#method label, can be used to specifyiing xc func or the level of theory.
method = get_method(self.calc.parameters.method,'psi4')
basis_set = get_basis_set(self.calc.parameters.basis_set, 'psi4')
# method label, can be used to specifyiing xc func or the level of theory.
method = get_method(self.calc.parameters.method, "psi4")

basis_set = get_basis_set(self.calc.parameters.basis_set, "psi4")

if self.calc.type == CalcType.SP:
self.command_line += f"energy('{method}/{basis_set}')"
elif self.calc.type == CalcType.OPT:
self.command_line += f"optimize('{method}/{basis_set}')"
else:
raise UnimplementedError(f"Calculation Type {self.calc.type} not implemented yet for psi4")


raise UnimplementedError(
f"Calculation Type {self.calc.type} not implemented yet for psi4"
)

def handle_xyz(self):
lines = [i + "\n" for i in clean_xyz(self.calc.xyz).split("\n") if i != ""]
Expand All @@ -106,19 +105,14 @@ def handle_xyz(self):
def handle_solvation(self):
return




def create_input_file(self) -> None:
self.input_file = self.TEMPLATE.format(
charge= self.calc.charge,
multiplicity = self.calc.multiplicity,
coordinates = self.xyz_structure,
command_line = self.command_line
)
charge=self.calc.charge,
multiplicity=self.calc.multiplicity,
coordinates=self.xyz_structure,
command_line=self.command_line,
)
return



@property
def output(self):
Expand Down
49 changes: 25 additions & 24 deletions ccinput/tests/test_psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
class Psi4Tests(InputTests):
# def test_sp_SE(self):
# params = {

# }

# }

# inp = self.generate_calculation(**params)

Expand All @@ -25,7 +24,7 @@ def test_sp_HF(self):
"method": "hf",
"basis_set": "sto3g",
"charge": "-1",
"multiplicity" : "1",
"multiplicity": "1",
}
inp = self.generate_calculation(**params)

Expand All @@ -40,18 +39,18 @@ def test_sp_HF(self):
"""

self.assertTrue(self.is_equivalent(REF, inp.input_file))

def test_sp_DFT(self):
params = {
"type": "Energy",
"file": "Cl.xyz",
"software": "psi4",
"method": "b3lyp",
"basis_set": "def2-tzvp",
"charge": "-1",
"multiplicity" : "1",
"type": "Energy",
"file": "Cl.xyz",
"software": "psi4",
"method": "b3lyp",
"basis_set": "def2-tzvp",
"charge": "-1",
"multiplicity": "1",
}

inp = self.generate_calculation(**params)

REF = """
Expand All @@ -64,7 +63,7 @@ def test_sp_DFT(self):
energy('b3lyp/def2-tzvp')
"""
self.assertTrue(self.is_equivalent(REF, inp.input_file))

def test_opt_HF(self):
params = {
"type": "Geometrical Optimisation",
Expand All @@ -73,7 +72,7 @@ def test_opt_HF(self):
"method": "HF",
"basis_set": "ccpVDZ",
"charge": "-1",
"multiplicity" : "1",
"multiplicity": "1",
}

inp = self.generate_calculation(**params)
Expand All @@ -92,14 +91,14 @@ def test_opt_HF(self):

def test_opt_DFT(self):
params = {
"type": "Opt",
"file": "Cl.xyz",
"software": "psi4",
"method": "b3lyp",
"basis_set": "631g",
"charge": "-1",
"type": "Opt",
"file": "Cl.xyz",
"software": "psi4",
"method": "b3lyp",
"basis_set": "631g",
"charge": "-1",
}

inp = self.generate_calculation(**params)

REF = """
Expand All @@ -123,6 +122,8 @@ def test_unavailable_calc_type(self):
"basis_set": "cc-pvdz",
"charge": "-1",
}

self.assertRaises(ImpossibleCalculation, msg=f"Calculation Type of {params['type']} not implemented yet for psi4")


self.assertRaises(
ImpossibleCalculation,
msg=f"Calculation Type of {params['type']} not implemented yet for psi4",
)

0 comments on commit 0a6c69a

Please sign in to comment.