class Universe: """Universe contains all fundamental particles and laws needed to get the universe to spin""" def __init__(self): self.moelcules = dict() cml = Cml.Reactions() cml.parse("data/reactions.cml") self.reactor = Reactor(cml.reactions) def react(self, reactants, effects): if len(reactants) < 2: return temp = 298 effect_names = list() for effect in effects: effect_names.append(effect.name) if effect.supports("temp"): temp = effect.temp reaction = self.reactor.react(reactants, temp) if reaction == None: if Config.current.DEBUG: print("Did not react:", reactants) return None else: if Config.current.DEBUG: print(reaction.reactants, "+", effect_names, "->", reaction.products) return reaction
def setupSimpleReactor(): r1 = Cml.Reaction(["H2SO4(aq)", "NaCl(s)", "NaCl(s)"], ["HCl(g)", "HCl(g)", "Na2SO4(s)"]) r2 = Cml.Reaction(["OH-", "H+"], ["H2O(l)"]) return Reactor([r1, r2])
def __init__(self): self.moelcules = dict() cml = Cml.Reactions() cml.parse("data/reactions.cml") self.reactor = Reactor(cml.reactions)
def setupRealReactor(self): cml = Cml.Reactions() cml.parse("data/reactions.cml") reactor = Reactor(cml.reactions) return reactor
def setupSimpleReactor(self): r1 = Cml.Reaction(["O", "H+"], ["OH-(aq)"]) r2 = Cml.Reaction(["O", "O"], ["O2(g)"]) return Reactor([r1, r2])