Skip to content

Commit 1a73043

Browse files
committed
add uncertainty tests for some surface species
1 parent b1370cd commit 1a73043

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/rmgpy/tools/uncertaintyTest.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import os
3131

3232

33+
from arkane.input import species
3334
import numpy as np
3435

3536
import rmgpy
@@ -177,3 +178,46 @@ def test_uncertainty_assignment(self):
177178
[0.5, 1.118, 1.9783, 1.9783, 1.5363, 0.5, 2.0, 11.6312, 11.6312, 0.5],
178179
rtol=1e-4
179180
)
181+
182+
def test_specific_species_uncertainties(self):
183+
"""
184+
Test uncertainties for a few specific examples
185+
"""
186+
187+
expected_results = { # order is (total_uncertainty, [group_names], [group_counts])
188+
'CCCC': (2.5199409675625337, ['Cs-CsCsHH', 'Cs-CsHHH'], [2, 2]),
189+
'CCCCCCCCCC': (6.091048438487417, ['Cs-CsCsHH', 'Cs-CsHHH'], [8, 2]),
190+
'CC(OO)CC': (2.5199409675625337, ['O2s-OsCs', 'O2s-OsH', 'Cs-CsCsOsH', 'Cs-CsCsHH', 'Cs-CsHHH'], [1, 1, 1, 1, 2]),
191+
'C=NCC': (2.07365649035707, ['N3d-CdCs', 'Cs-(N3dCd)CsHH', 'Cs-CsHHH', 'Cd-N3dHH'], [1, 1, 1, 1]),
192+
'C=C': (2.07365649035707, ['Cds-CdsHH'], [2]),
193+
'C*': (7.271261019245562, ['CH3'], [1]), # Gas library + radical + adsorption correction
194+
'O=[CH]*': (7.150786643440007, ['Cds-OdHH', 'HCdsJO'], [1, 1]), # GAV + radical + adsorption correction
195+
}
196+
197+
uncertainty = rmgpy.tools.uncertainty.Uncertainty()
198+
uncertainty.database = self.uncertainty.database # use the same database as the main test
199+
new_species_list = [rmgpy.species.Species(smiles=spc) for spc in expected_results.keys()]
200+
for spc in new_species_list:
201+
spc.thermo = self.uncertainty.database.thermo.get_thermo_data(spc)
202+
if not isinstance(spc.thermo, rmgpy.thermo.NASA):
203+
spc.thermo = spc.thermo.to_nasa(Tmin=298, Tmax=3000, Tint=1000)
204+
uncertainty.species_list = new_species_list
205+
uncertainty.reaction_list = [] # no need to test kinetics here
206+
207+
uncertainty.extract_sources_from_model() # this will populate the sources dict with the new species
208+
uncertainty.assign_parameter_uncertainties() # this will assign the uncertainties based on the sources and the database
209+
210+
for i, sp in enumerate(uncertainty.species_list):
211+
source = uncertainty.species_sources_dict[sp]
212+
213+
group_counts = []
214+
group_names = []
215+
for group_type, group_entries in source['GAV'].items():
216+
for group, count in group_entries:
217+
group_names.append(group.label)
218+
group_counts.append(count)
219+
220+
result = expected_results[sp.smiles]
221+
assert np.isclose(uncertainty.thermo_input_uncertainties[i], result[0], rtol=1e-4)
222+
assert group_names == result[1]
223+
assert group_counts == result[2]

0 commit comments

Comments
 (0)