Skip to content

Commit

Permalink
Unit test that Surface_Adsorption_vdW doesn't adsorb radicals.
Browse files Browse the repository at this point in the history
Trying to forbid them using the forbidden structures doesn't 
seem to be working (a bug in is_subgraph_isomorphic?) but
making the top level node have multiplicity [1,3] excludes
anything with multiplicity 2 and seems to work on a 
generate_reactions level. Probably a better solution anyway, 
as it's inefficient to match the node, apply the recipe, generate
the products, and *then* discard them as forbidden.
  • Loading branch information
rwest committed Mar 3, 2020
1 parent dd3be14 commit f11caa5
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 1 deletion.
48 changes: 47 additions & 1 deletion rmgpy/data/kinetics/familyTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def setUpClass(cls):
'Intra_R_Add_Exo_scission',
'intra_substitutionS_isomerization',
'R_Addition_COm',
'R_Recombination'
'R_Recombination',
'Surface_Adsorption_vdW',
],
)
cls.family = cls.database.families['intra_H_migration']
Expand Down Expand Up @@ -623,6 +624,51 @@ def test_r_addition_com(self):
self.assertEqual(len(products), 1)
self.assertTrue(expected_products[0].is_isomorphic(products[0]))

def test_surface_adsorption_vdw(self):
"""
Test that the Surface_Adsorption_vdW family doesn't adsorb radicals
"""
family = self.database.families['Surface_Adsorption_vdW']

# Test it with Oj as the *1 atom
reactants = [Molecule().from_adjacency_list("""
multiplicity 2
1 *1 O u1 p2 c0 {2,S}
2 H u0 p0 c0 {1,S}
"""),
Molecule().from_adjacency_list("""
1 *2 X u0 p0 c0
""")]
products = family.apply_recipe(reactants)
#self.assertTrue(family.is_molecule_forbidden(products[0]), "Radical product should be forbidden")
t1 = family.is_molecule_forbidden(products[0]) # Should be True (but currently broken)

# Now test it the other way around
reactants = [Molecule().from_adjacency_list("""
multiplicity 2
1 O u1 p2 c0 {2,S}
2 *1 H u0 p0 c0 {1,S}
"""),
Molecule().from_adjacency_list("""
1 *2 X u0 p0 c0
""")]
products = family.apply_recipe(reactants)
#self.assertTrue(family.is_molecule_forbidden(products[0]), "Radical product should be forbidden")
t2 = family.is_molecule_forbidden(products[0]) # Should be True (but currently broken)

# Now test it with no labeling
reactants = [Molecule().from_adjacency_list("""
multiplicity 2
1 O u1 p2 c0 {2,S}
2 H u0 p0 c0 {1,S}
"""),
Molecule().from_adjacency_list("""
1 X u0 p0 c0
""")]
reactions = family.generate_reactions(reactants)
self.assertEqual(len(reactions), 0, "Should have made 0 reactions.")


def test_save_family(self):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env python
# encoding: utf-8

name = "Surface_Adsorption_vdW/groups"
shortDesc = u""
longDesc = u"""
Physisorption of a gas-phase species onto the surface.
*1 *1
----> :
~*2~ ~*2~~
The rate, which should be in mol/m2/s,
will be given by k * (mol/m2) * (mol/m3)
so k should be in (m3/mol/s). We will use sticking coefficients.
"""

template(reactants=["Adsorbate", "VacantSite"], products=["Adsorbed"], ownReverse=False)

reverse = "Surface_Desorption_vdW"

reactantNum=2
productNum=1

recipe(actions=[
['FORM_BOND', '*1', 0, '*2']
])

entry(
index = 1,
label = "Adsorbate",
group =
"""
multiplicity [1,3]
1 *1 R u0 px c0
""",
kinetics = None,
)

entry(
index = 2,
label="VacantSite",
group =
"""
1 *2 Xv u0 p0 c0
""",
kinetics = None,
)



tree(
"""
L1: Adsorbate
L1: VacantSite
"""
)

forbidden(
label = "radical1",
group =
"""
1 R u[1,2,3]
""",
shortDesc = u"""Radicals not allowed""",
longDesc =
u"""
""",
)


forbidden(
label = "charge1",
group =
"""
1 R ux c+1
""",
shortDesc = u"""Charges not allowed""",
longDesc =
u"""
""",
)

forbidden(
label = "charge2",
group =
"""
1 R ux c-1
""",
shortDesc = u"""Charges not allowed""",
longDesc =
u"""
""",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# encoding: utf-8

name = "Surface_Adsorption_vdW/rules"
shortDesc = u""
longDesc = u"""
Surface adsorption of a closed-shell gas-phase species forming a van der Waals bond to the surface site
"""
entry(
index = 1,
label = "Adsorbate;VacantSite",
kinetics = StickingCoefficientBEP(
A = 0.1,
n = 0,
alpha = 0,
E0 = (0, 'kcal/mol'),
Tmin = (200, 'K'),
Tmax = (3000, 'K'),
),
rank = 0,
shortDesc = u"""Default""",
longDesc = u"""Made up"""
)



Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8

name = "Surface_Adsorption_vdW/training"
shortDesc = u"Reaction kinetics used to generate rate rules"
longDesc = u"""
Put kinetic parameters for specific reactions in this file to use as a
training set for generating rate rules to populate this kinetics family.
"""

0 comments on commit f11caa5

Please sign in to comment.