From 29e5ff4ac732caa44ce4fa892edaa411d47cae5f Mon Sep 17 00:00:00 2001 From: yunsiechung Date: Tue, 26 Nov 2019 16:44:42 -0500 Subject: [PATCH 1/3] fixed the solvation GAV heuristic For solute data group additivity, instead of averaging over all resonance structures in species.molecule list, only get the solute data estimation for the first item in species.molecule list as it corresponds to the most stable resonance structure found by gas-phase thermo estimation. This heutristic is chosen so the solvation GAV method is consistent with the gas phase thermo GAV method. --- rmgpy/data/solvation.py | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/rmgpy/data/solvation.py b/rmgpy/data/solvation.py index fd97bbea5f..ad70ab535c 100644 --- a/rmgpy/data/solvation.py +++ b/rmgpy/data/solvation.py @@ -702,32 +702,14 @@ def get_solute_data_from_groups(self, species): additivity method. If no group additivity values are loaded, a :class:`DatabaseError` is raised. - It averages (linearly) over the desciptors for each Molecule (resonance isomer) - in the Species. - """ - solute_data = SoluteData(0.0, 0.0, 0.0, 0.0, 0.0) - count = 0 - comments = [] - for molecule in species.molecule: - molecule.clear_labeled_atoms() - molecule.update_atomtypes() - sdata = self.estimate_solute_via_group_additivity(molecule) - solute_data.S += sdata.S - solute_data.B += sdata.B - solute_data.E += sdata.E - solute_data.L += sdata.L - solute_data.A += sdata.A - count += 1 - comments.append(sdata.comment) - - solute_data.S /= count - solute_data.B /= count - solute_data.E /= count - solute_data.L /= count - solute_data.A /= count - - # Print groups that are used for debugging purposes - solute_data.comment = "Average of {0}".format(" and ".join(comments)) + It estimates the solute data for the first item in the species's + molecule list because it is the most stable resonance structure found + by gas-phase thermo estimate. + """ + molecule = species.molecule[0] + molecule.clear_labeled_atoms() + molecule.update_atomtypes() + solute_data = self.estimate_solute_via_group_additivity(molecule) return solute_data From 55eb6b34e8a3111e5394e763b5a5eed787f927bc Mon Sep 17 00:00:00 2001 From: yunsiechung Date: Tue, 26 Nov 2019 21:36:35 -0500 Subject: [PATCH 2/3] simplified the existing solvation unit test I simplified some lines in the existing solvation unit test --- rmgpy/data/solvationTest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rmgpy/data/solvationTest.py b/rmgpy/data/solvationTest.py index e7771701e1..d837363762 100644 --- a/rmgpy/data/solvationTest.py +++ b/rmgpy/data/solvationTest.py @@ -112,8 +112,8 @@ def test_solute_generation(self): ] for name, smiles, S, B, E, L, A, V in self.testCases: - species = Species(molecule=[Molecule(smiles=smiles)]) - solute_data = self.database.get_solute_data_from_groups(Species(molecule=[species.molecule[0]])) + species = Species(smiles=smiles) + solute_data = self.database.get_solute_data_from_groups(species) self.assertAlmostEqual(solute_data.S, S, places=2) self.assertAlmostEqual(solute_data.B, B, places=2) self.assertAlmostEqual(solute_data.E, E, places=2) From cbf446f5499b51fd3f00367369bef3098a60acde Mon Sep 17 00:00:00 2001 From: yunsiechung Date: Tue, 26 Nov 2019 22:20:10 -0500 Subject: [PATCH 3/3] unit test for solute GAV with resonance structures A unit test is added to check that the solute data are estimated correctly using the GAV for the species with multiple resonance structures. For the species with resonance structures, the estimated solute data / solvation energy should match those estimated for the first item in the species's molecule list. --- rmgpy/data/solvationTest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rmgpy/data/solvationTest.py b/rmgpy/data/solvationTest.py index d837363762..c563bf6bcf 100644 --- a/rmgpy/data/solvationTest.py +++ b/rmgpy/data/solvationTest.py @@ -120,6 +120,28 @@ def test_solute_generation(self): self.assertAlmostEqual(solute_data.L, L, places=2) self.assertAlmostEqual(solute_data.A, A, places=2) + def test_solute_with_resonance_structures(self): + """ + Test we can estimate Abraham solute parameters correctly using group contributions + for the solute species with resonance structures. + """ + smiles = "CC1=CC=CC=C1N" + species = Species(smiles=smiles) + species.generate_resonance_structures() + solute_data = self.database.get_solute_data(species) + solvent_data = self.database.get_solvent_data('water') + solvation_correction = self.database.get_solvation_correction(solute_data, solvent_data) + dGsolv_spc = solvation_correction.gibbs / 1000 + for mol in species.molecule: + spc = Species(molecule=[mol]) + solute_data = self.database.get_solute_data_from_groups(spc) + solvation_correction = self.database.get_solvation_correction(solute_data, solvent_data) + dGsolv_mol = solvation_correction.gibbs / 1000 + if mol == species.molecule[0]: + self.assertEqual(dGsolv_spc, dGsolv_mol) + else: + self.assertNotAlmostEqual(dGsolv_spc, dGsolv_mol) + def test_lone_pair_solute_generation(self): """Test we can obtain solute parameters via group additivity for a molecule with lone pairs""" molecule = Molecule().from_adjacency_list(