def setUp(self): self.rates = {(("A", "B"), ("B", "C")): 2.0} self.net = ReactionNetwork(self.rates) self.othernet = ReactionNetwork(self.rates) self.wrongrates = {(("A", "B"), ("B", "C")): 3.0} self.wrongnet = ReactionNetwork(self.wrongrates)
def setUp(self): self.rates = { (OrderedFrozenBag(["A", "B"]), OrderedFrozenBag(["B", "C"])): 2.0 } self.net = ReactionNetwork(self.rates) self.othernet = ReactionNetwork(self.rates) self.wrongrates = { (OrderedFrozenBag(["A", "B"]), OrderedFrozenBag(["B", "C"])): 3.0 } self.wrongnet = ReactionNetwork(self.wrongrates)
def reactionnet(self): """ A property that generates and caches a :py:class:`~.ReactionNetwork` object representing the reaction network exhibited by this bucket. Rates are calculated based on repeats of events in this bucket. This may have a large sampling error depending on how many repeates there were. """ if self._reactionnet == None: #need to create a rates structure, then convert it to a reactionnet rates = {} seenreactants = {} for event in self.events: reactants = event.reactants products = event.products reaction = (reactants, products) if event.rateconstant is None: if reaction not in rates: rates[reaction] = 0 rates[reaction] += 1 else: if reaction not in rates: rates[reaction] = event.rateconstant else: assert rates[reaction] == event.rateconstant self._reactionnet = ReactionNetwork(rates) return self._reactionnet