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

fixed the solvation GAV heuristic #1832

Merged
merged 3 commits into from
Dec 3, 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
34 changes: 8 additions & 26 deletions rmgpy/data/solvation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 24 additions & 2 deletions rmgpy/data/solvationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,36 @@ 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)
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(
Expand Down