Skip to content

Commit

Permalink
Merge pull request #1773 from ReactionMechanismGenerator/fix_solvaion…
Browse files Browse the repository at this point in the history
…_radical_bug

Fix solvaion radical bug
  • Loading branch information
mliu49 authored Nov 27, 2019
2 parents 1eac768 + 8e93013 commit 7e62adf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rmgpy/data/solvation.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,8 @@ def remove_h_bonding(self, saturated_struct, added_to_radicals, added_to_pairs,
for atom in saturated_struct.atoms:
# Iterate over heavy (non-hydrogen) atoms
if atom.is_non_hydrogen() and atom.radical_electrons > 0:
for electron in range(1, atom.radical_electrons):
# Get solute data for radical group
for electron in range(atom.radical_electrons):
# Get solute data for radical group
try:
self._add_group_solute_data(solute_data, self.groups['radical'], saturated_struct, {'*': atom})
except KeyError:
Expand Down
16 changes: 16 additions & 0 deletions rmgpy/data/solvationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ def test_radical_and_lone_pair_generation(self):
solute_data = self.database.get_solute_data_from_groups(species)
self.assertIsNotNone(solute_data)

def test_radical_solute_group(self):
"""Test that the existing radical group is found for the radical species when using group additivity"""
# First check whether the radical group is found for the radical species
rad_species = Species(smiles='[OH]')
rad_solute_data = self.database.get_solute_data_from_groups(rad_species)
self.assertTrue('radical' in rad_solute_data.comment)
# Then check that the radical and its saturated species give different solvation free energies
saturated_struct = rad_species.molecule[0].copy(deep=True)
saturated_struct.saturate_radicals()
sat_species = Species(molecule=[saturated_struct])
sat_solute_data = self.database.get_solute_data_from_groups(sat_species)
solvent_data = self.database.get_solvent_data('water')
rad_solvation_correction = self.database.get_solvation_correction(rad_solute_data, solvent_data)
sat_solvation_correction = self.database.get_solvation_correction(sat_solute_data, solvent_data)
self.assertNotAlmostEqual(rad_solvation_correction.gibbs / 1000, sat_solvation_correction.gibbs / 1000)

def test_correction_generation(self):
"""Test we can estimate solvation thermochemistry."""
self.testCases = [
Expand Down

0 comments on commit 7e62adf

Please sign in to comment.