Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix solvaion radical bug #1773

Merged
merged 3 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought, should we add a test to check if we get the same (we shouldn't) Abraham solute parameters for OH radical and water? If we get the same values then we know something is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add that test. I will just add an additional test for checking whether their A parameters are different

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