Skip to content

Commit ce8c958

Browse files
committed
skip electrons in electrode reactor when creating reactant and product indicies matrix
1 parent 54f6cda commit ce8c958

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

rmgpy/solver/electrode.pyx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,25 @@ cdef class ElectrodeReactor(ReactionSystem):
127127
initial_surface_coverages[species_dict[label]] = surfaceCoverage
128128
self.initial_surface_coverages = initial_surface_coverages
129129

130+
def generate_reactant_product_indices(self, core_reactions, edge_reactions):
131+
"""
132+
Creates a matrix for the reactants and products.
133+
"""
134+
135+
self.reactant_indices = -np.ones((self.num_core_reactions + self.num_edge_reactions, 3), np.int)
136+
self.product_indices = -np.ones_like(self.reactant_indices)
137+
138+
for rxn in itertools.chain(core_reactions, edge_reactions):
139+
j = self.reaction_index[rxn]
140+
reacts = [r for r in rxn.reactants if not r.is_electron()]
141+
prods = [p for p in rxn.products if not p.is_electron()]
142+
for l, spec in enumerate(reacts):
143+
i = self.get_species_index(spec)
144+
self.reactant_indices[j, l] = i
145+
for l, spec in enumerate(prods):
146+
i = self.get_species_index(spec)
147+
self.product_indices[j, l] = i
148+
130149
cpdef initialize_model(self,
131150
list core_species,
132151
list core_reactions,

0 commit comments

Comments
 (0)