def convert(ri): reactants = [v.species() for pid, v in ri.reactants()] products = [v.species() for pid, v in ri.products()] assert len(products) > 0 pos = self.lhs.world.coordinate2position(ri.products()[0][1].coordinate()) coord = self.rhs.world.position2coordinate(pos) return meso.ReactionInfo(ri.t(), reactants, products, coord)
def convert(ri): reactants = ri.reactants() if len(reactants) < 2: coord = self.lhs.world.rng().uniform_int( 0, self.rhs.world.num_subvolumes() - 1) else: assert len(reactants) == 2 sp = self.lhs.owe(reactants[1]) if sp is None or not self.rhs.own(sp): coord = self.lhs.world.rng().uniform_int( 0, self.rhs.world.num_subvolumes() - 1) else: reactants[1] = sp coords = self.rhs.world.list_coordinates_exact(sp) coord = coords[self.lhs.world.rng().uniform_int(0, len(coords) - 1)] return meso.ReactionInfo(ri.t(), reactants, ri.products(), coord)
def convert(ri): reactants = ri.reactants() coord = ri.coordinate() g1 = self.lhs.world.coord2global(coord) if len(reactants) < 2: g2 = Integer3(*[int(rng.uniform(g1[i] * ratios[i], (g1[i] + 1) * ratios[i])) for i in range(3)]) newcoord = self.rhs.world.global2coord(g2) else: assert len(reactants) == 2 sp = self.lhs.owe(reactants[1]) if sp is None or not self.rhs.own(sp): g2 = Integer3(*[int(rng.uniform(g1[i] * ratios[i], (g1[i] + 1) * ratios[i])) for i in range(3)]) newcoord = self.rhs.world.global2coord(g2) else: coords = [c for c in self.rhs.world.list_coordinates_exact(sp) if all(g1[i] * ratios[i] <= self.rhs.world.coord2global(c)[i] < (g1[i] + 1) * ratios[i] for i in range(3))] assert len(coords) > 0 newcoord = coords[rng.uniform_int(0, len(coords) - 1)] reactants[1] = sp # print(tuple(self.lhs.world.coord2global(coord)), tuple(self.rhs.world.coord2global(newcoord))) return meso.ReactionInfo(ri.t(), reactants, ri.products(), newcoord)
def convert(ri): reactants = [p.species() for pid, p in ri.reactants()] products = [p.species() for pid, p in ri.products()] assert len(products) > 0 coord = self.rhs.world.position2coordinate(ri.products()[0][1].position()) return meso.ReactionInfo(ri.t(), reactants, products, coord)
def convert(ri): return meso.ReactionInfo( ri.t(), ri.reactants(), ri.products(), self.rng.uniform_int( 0, self.rhs.world.num_subvolumes() - 1))