From 0ff4d9460cd2387caa2a1eb64d53d7f540f4b096 Mon Sep 17 00:00:00 2001 From: yunsiechung Date: Fri, 18 Oct 2019 14:29:44 -0400 Subject: [PATCH 1/3] fixed a bug with solvation GAV not finding radical The solvation group additivty method had a bug that it cannot apply radical correction to the radical species even if its radical group exists in solvation radical database. It was because originally, when it was applying correction for each radical found, the for-loop range started from range(1, number of radical), instead of starting from range(0, number of radical). Because of that, if the number of radical is 1, the correction was never applied. This commits fixes this error by letting the range to be just range(number of radical) since the number of radical is always integer --- rmgpy/data/solvation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rmgpy/data/solvation.py b/rmgpy/data/solvation.py index fc6ff99d4b..fd97bbea5f 100644 --- a/rmgpy/data/solvation.py +++ b/rmgpy/data/solvation.py @@ -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: From 9370237aeb81dd11c2fb814b8818ee82d64a77e5 Mon Sep 17 00:00:00 2001 From: yunsiechung Date: Fri, 18 Oct 2019 15:04:56 -0400 Subject: [PATCH 2/3] added solvation unittest to check radical GAV I added one more unit test in solvationTest.py to make sure that the radical group is found for the radical species if its radical group exists in the solvation radical database --- rmgpy/data/solvationTest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rmgpy/data/solvationTest.py b/rmgpy/data/solvationTest.py index 2f7a11ed97..06402cf970 100644 --- a/rmgpy/data/solvationTest.py +++ b/rmgpy/data/solvationTest.py @@ -193,6 +193,12 @@ 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""" + species = Species(molecule=[Molecule(smiles='[OH]')]) + solute_data = self.database.get_solute_data_from_groups(species) + self.assertTrue('radical' in solute_data.comment) + def test_correction_generation(self): """Test we can estimate solvation thermochemistry.""" self.testCases = [ From 8e93013f8ebf2979a0c4e96fd25abe249bc30615 Mon Sep 17 00:00:00 2001 From: yunsiechung Date: Tue, 26 Nov 2019 21:23:41 -0500 Subject: [PATCH 3/3] added unittest to compare the radical and saturated Another uniitest is added to compare the radical and its saturated species solvation free energy in water. The test makes sure the two solvation energies are different. --- rmgpy/data/solvationTest.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rmgpy/data/solvationTest.py b/rmgpy/data/solvationTest.py index 06402cf970..e7771701e1 100644 --- a/rmgpy/data/solvationTest.py +++ b/rmgpy/data/solvationTest.py @@ -195,9 +195,19 @@ def test_radical_and_lone_pair_generation(self): def test_radical_solute_group(self): """Test that the existing radical group is found for the radical species when using group additivity""" - species = Species(molecule=[Molecule(smiles='[OH]')]) - solute_data = self.database.get_solute_data_from_groups(species) - self.assertTrue('radical' in solute_data.comment) + # 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."""