Skip to content

Commit

Permalink
make it possible to explicitly forbid molecules and groups in the inp…
Browse files Browse the repository at this point in the history
…ut file
  • Loading branch information
mjohnson541 authored and rwest committed Jul 2, 2023
1 parent 5badbd1 commit 92fad47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions rmgpy/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def fails_species_constraints(species):
if struct.is_isomorphic(molecule):
return False

explicitly_forbidden_molecules = species_constraints.get('explicitlyForbiddenMolecules', [])
for molecule in explicitly_forbidden_molecules:
if struct.is_isomorphic(molecule):
return True

explicitly_forbidden_groups = species_constraints.get('explicitlyForbiddenGroups', [])
for group in explicitly_forbidden_groups:
if struct.is_subgraph_isomorphic(group):
return True

max_carbon_atoms = species_constraints.get('maximumCarbonAtoms', -1)
if max_carbon_atoms != -1:
if struct.get_num_atoms('C') > max_carbon_atoms:
Expand Down
8 changes: 5 additions & 3 deletions rmgpy/rmg/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
from rmgpy import settings
from rmgpy.data.base import Entry
from rmgpy.exceptions import DatabaseError, InputError
from rmgpy.molecule import Molecule
from rmgpy.molecule.group import Group
from rmgpy.molecule import Molecule, Group
from rmgpy.quantity import Quantity, Energy, RateCoefficient, SurfaceConcentration
from rmgpy.rmg.model import CoreEdgeReactionModel
from rmgpy.rmg.settings import ModelSettings, SimulatorSettings
Expand Down Expand Up @@ -238,7 +237,7 @@ def inchi(string):
def adjacency_list(string):
return Molecule().from_adjacency_list(string)

def adjacency_list_group(string):
def group_adjacency_list(string):
return Group().from_adjacency_list(string)

def react(tups):
Expand Down Expand Up @@ -1381,6 +1380,8 @@ def generated_species_constraints(**kwargs):
'maximumCarbeneRadicals',
'allowSingletO2',
'speciesCuttingThreshold',
'explicitlyForbiddenMolecules',
'explicitlyForbiddenGroups',
]

for key, value in kwargs.items():
Expand Down Expand Up @@ -1528,6 +1529,7 @@ def read_input_file(path, rmg0):
'InChI': inchi,
'adjacencyList': adjacency_list,
'adjacencyListGroup': adjacency_list_group,
'groupAdjacencyList': group_adjacency_list,
'react': react,
'simpleReactor': simple_reactor,
'constantVIdealGasReactor' : constant_V_ideal_gas_reactor,
Expand Down
2 changes: 1 addition & 1 deletion rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from rmgpy.kinetics.diffusionLimited import diffusion_limiter
from rmgpy.data.vaporLiquidMassTransfer import vapor_liquid_mass_transfer
from rmgpy.kinetics import ThirdBody
from rmgpy.molecule import Molecule
from rmgpy.molecule import Molecule, Group
from rmgpy.qm.main import QMDatabaseWriter
from rmgpy.reaction import Reaction
from rmgpy.rmg.listener import SimulationProfileWriter, SimulationProfilePlotter
Expand Down

0 comments on commit 92fad47

Please sign in to comment.