Skip to content

Commit

Permalink
Hotfix for orca charge extraction (duartegroup#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-young31 committed Oct 1, 2022
1 parent ce7e8c1 commit 4141160
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion autode/wrappers/ORCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def get_atomic_charges(self, calc):
charges = []
first, last = i+7, i+7+calc.molecule.n_atoms
for charge_line in calc.output.file_lines[first:last]:
charges.append(float(charge_line.split()[-1]))
charges.append(float(charge_line.split()[-2]))

return charges

Expand Down
Binary file modified tests/data/orca.zip
Binary file not shown.
20 changes: 17 additions & 3 deletions tests/test_orca_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def test_orca_opt_calculation():

# Should have a partial atomic charge for every atom
charges = calc.get_atomic_charges()
assert len(charges) == 5
assert type(charges[0]) == float
assert -1.0 < charges[0] < 1.0
assert charges == [-0.006954, -0.147352, 0.052983, 0.052943, 0.053457]

calc = Calculation(name='opt', molecule=methylchloride, method=method,
keywords=opt_keywords)
Expand Down Expand Up @@ -352,3 +350,19 @@ def test_other_input_block():

assert scf_line_exists
Config.ORCA.other_input_block = curr_other_input_block


@testutils.work_in_zipped_dir(os.path.join(here, 'data', 'orca.zip'))
def test_charges_from_v5_output_file():

water = Molecule(smiles='O')
calc = Calculation(name='h2_grad',
molecule=water,
method=method,
keywords=method.keywords.sp)
calc.output.filename = "h2o_orca_v5_charges.out"

assert calc.output.exists

# q_O q_H q_H
assert calc.get_atomic_charges() == [-0.313189, 0.156594, 0.156594]

0 comments on commit 4141160

Please sign in to comment.