Skip to content

Commit

Permalink
Thermochemistry calculation exception (duartegroup#166)
Browse files Browse the repository at this point in the history
* Throw useful exception in calc_thermo with non run calc

* Tweak sim axis tolerance for correct methane sn
  • Loading branch information
t-young31 committed Oct 1, 2022
1 parent 73b2fb9 commit 1e5fc3d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion autode/species/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ def calc_thermo(self,
:meth:`autode.thermochemistry.igm.calculate_thermo_cont` for
additional kwargs
"""
logger.info(f"Calculating thermochemical contributions for {self.name}")

if 'lfm_method' in kwargs:
try:
Expand All @@ -1158,8 +1159,14 @@ def calc_thermo(self,
f'be one of: {[m for m in LFMethod]}')

if calc is not None and calc.output.exists:
self.energy = calc.molecule.energy
logger.info("Setting the atoms, energy and Hessian from an "
"existing calculation")
if calc.molecule.hessian is None:
raise ValueError(f"Failed to set the Hessian from {calc.name}."
f" Maybe run() hasn't been called?")

self.atoms = calc.molecule.atoms.copy()
self.energy = calc.molecule.energy
self.hessian = calc.molecule.hessian

elif self.hessian is None or (calc is not None and not calc.output.exists):
Expand Down
4 changes: 2 additions & 2 deletions autode/thermochemistry/symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def strip_identical_and_inv_axes(axes, sim_axis_tol):
return unique_possible_axes


def get_possible_axes(coords, max_triple_dist=2.0, sim_axis_tol=0.05):
def get_possible_axes(coords, max_triple_dist=2.0, sim_axis_tol=0.1):
r"""
Possible rotation axes in a molecule. Currently limited to average vectors
and cross products i.e.::
Expand Down Expand Up @@ -215,7 +215,7 @@ def create_pcoords(species):
def symmetry_number(species, max_n_fold_rot_searched=6, dist_tol=0.25):
"""
Calculate the symmetry number of a molecule. See:
Theor Chem Account (2007) 118:813–826
Theor Chem Account (2007) 118:813–826. 10.1007/s00214-007-0328-0
---------------------------------------------------------------------------
Arguments:
Expand Down
2 changes: 2 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Bug Fixes
- Fixes variable harmonic frequencies (<2 cm-1 differences) due to projection vectors becoming close to rotational axes
- Fixes the extraction of atomic partial charges from ORCA output files
- Fixes gradients and Hessians not being reset on a molecule where the coordinates change
- Fixes unhelpful exception when calculating thermochemistry with EST methods without implemented "get_hessian" methods


See the table below for a quick benchmark of constrained optimisations in autodE
compared to ORCA. In all cases the structures were generated from SMILES strings (RDKit)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,14 @@ def test_species_does_not_have_reasonable_coordinates():

x = ch4_flat.coordinates
assert np.min(distance_matrix(x, x)+np.eye(5)) > 0.7


@testutils.requires_with_working_xtb_install
def test_calc_thermo_not_run_calculation():

m = Molecule(smiles="O")
calc = Calculation(name="water", molecule=m, method=xtb,
keywords=xtb.keywords.hess)
# run() has not been called
with pytest.raises(Exception):
m.calc_thermo(calc=calc)
1 change: 1 addition & 0 deletions tests/test_thermochem.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_symmetry_number():
assert Molecule('CO2.xyz').symmetry_number == 2
assert Molecule('H2O.xyz').symmetry_number == 2
assert Molecule('H3N.xyz').symmetry_number == 3
assert Molecule(smiles="C").symmetry_number == 12

# Symmetry numbers aren't calculated for large molecules
h_100 = Species('tmp', atoms=100*[Atom('H')], charge=1, mult=1)
Expand Down

0 comments on commit 1e5fc3d

Please sign in to comment.