def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", dc=1e-6) c = m.Species("c", dc=1e-6) a_mix = (a, m.Orient.mix) b_mix = (b, m.Orient.mix) c_mix = (c, m.Orient.mix) unimol1 = m.Reaction([a_mix], [b_mix], rate=1e4) unimol2 = m.Reaction([a_mix], rate=1e4) bimol_irrev = m.Reaction([a_mix, b_mix], [c_mix], rate=1e4) bimol_rev = m.Reaction([a_mix, b_mix], [c_mix], reversible=True, rate=1e4) rxns = [unimol1, unimol2, bimol_irrev, bimol_rev] box = m.import_obj(Path("./box.obj")) sim = m.Simulation(dt=1e-6, meshes=[box], reactions=rxns) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", volume=False, dc=1e-6) c = m.Species("c", volume=False, dc=1e-6) a_mix = (a, m.Orient.mix) b_up = (b, m.Orient.up) c_up = (c, m.Orient.up) bimol_irrev = m.Reaction([a_mix, b_up], [c_up], rate=1e4) box = m.import_obj(Path("./box.obj")) sim = m.Simulation(dt=1e-6, meshes=[box], reactions=[bimol_irrev]) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", dc=1e-6) c = m.Species("c", dc=1e-6) a_mix = (a, m.Orient.mix) b_mix = (b, m.Orient.mix) c_mix = (c, m.Orient.mix) bimol_irrev = m.Reaction([a_mix, b_mix], [c_mix], rate=0) box = m.create_box("box", 1.0, (0, 0, 0)) sim = m.Simulation(dt=1e-6, meshes=[box], reactions=[bimol_irrev]) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) for i in range(100): offs = 1e6 bimol_irrev.rate = math.sin(i * 0.1) * offs + offs sim.run_iteration()
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", dc=1e-6) c = m.Species("c", dc=1e-6) a_mix = (a, m.Orient.mix) b_mix = (b, m.Orient.mix) c_mix = (c, m.Orient.mix) bimol_irrev = m.Reaction([a_mix, b_mix], [c_mix], rate=1e4, name="rxn") box = m.create_box("box", 1.0, (0, 0, 0)) count_a_box = m.CountMolecules(a, box) count_a_rxn = m.CountReaction(bimol_irrev, box) sim_counts = [count_a_box, count_a_rxn] sim = m.Simulation(dt=1e-6, meshes=[box], reactions=[bimol_irrev], counts=sim_counts) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) sim.run_iterations(100)
def create_reactions_from_dm( data_model: Dict[str, Any], species: Dict[str, m.Species]) -> List[m.Reaction]: """ Create a dictionary of Reactions from a CB data model """ logging.info("Creating reactions from data model") rxn_dm_list = data_model['mcell']['define_reactions']['reaction_list'] rxn_list = [] for rxn_dm in rxn_dm_list: # rxn_name = rxn_dm['rxn_name'] fwd_rate = float(rxn_dm['fwd_rate']) # try: # bkwd_rate = float(rxn_dm['bkwd_rate']) # except ValueError: # pass reactants_str_list = rxn_dm['reactants'].split(" + ") products_str_list = rxn_dm['products'].split(" + ") r_list = make_spec_orient_list(reactants_str_list, species) p_list = make_spec_orient_list(products_str_list, species) # rxn_type = rxn_dm['rxn_type'] rxn_dm = m.Reaction(r_list, p_list, fwd_rate) rxn_list.append(rxn_dm) return rxn_list
def test_vm1sm1_to_vm2(self): rxn = m.Reaction((self.vm1.down(), self.sm1.up()), self.vm2.down(), 1e8)
def test_vm1_to_vm2(self): rxn = m.Reaction(self.vm1, self.vm2, 1e8)
def test_vm1_to_null(self): rxn = m.Reaction(self.vm1.down(), None, 1e8)
def main(): world = m.MCellSim(seed=1) world.set_time_step(time_step=1e-5) world.set_iterations(iterations=1000) world.enable_logging() world.silence_notifications() world.set_output_freq(1) slow_dc = 1e-9 fast_dc = 1e-5 # define species vm1 = m.Species("vm1", fast_dc) vm2 = m.Species("vm2", fast_dc) vm3 = m.Species("vm3", slow_dc) sm_list = [] for i in range(1, 11): sm_list.append(m.Species("sm{}".format(i), fast_dc, surface=True)) sm1 = sm_list[0] sm2 = sm_list[1] spec_orient_list = [sm.up() for sm in sm_list] all_mols = sm_list + [vm1, vm2, vm3] world.add_species(all_mols) # define reaction rxn = m.Reaction(sm1.up(), sm2.down(), 1e3, name="create_sm2") world.add_reaction(rxn) # create torus object torus_obj = m.MeshObj( "Torus", t.vert_list, t.face_list, translation=(0, 0, 0)) torus_reg = m.SurfaceRegion(torus_obj, 'half', t.surf_reg_face_list) world.add_geometry(torus_obj) # create box object box_obj = m.MeshObj( "Box", b.vert_list, b.face_list, translation=(0, 0, 0)) box_reg = m.SurfaceRegion(box_obj, 'top', b.surf_reg_face_list) world.add_geometry(box_obj) # create surface class to absorb vm1 # sc = m.SurfaceClass(SC.absorb, sm1.mix()) # world.assign_surf_class(sc, torus_reg) # world.assign_surf_class_to_all_surface_mols("abs_all_surfs", SC.absorb, torus_reg) world.assign_surface_property_to_all_mols( "abs_all_vols", SC.absorb, torus_reg, moltype=MolType.surface_mols) # release vm1, vm2, and sm1 molecules into/onto torus vm1_torus_rel = m.ObjectRelease(vm1, number=1000, mesh_obj=torus_obj) world.release(vm1_torus_rel) vm2_torus_rel = m.ObjectRelease(vm2, number=1000, mesh_obj=torus_obj) world.release(vm2_torus_rel) sm1_torus_rel = m.ObjectRelease(sm1.up(), number=1000, region=torus_reg) world.release(sm1_torus_rel) # release vm3 molecules in a line (list based release) vm3_pos = [(x*0.01, 0, 0) for x in range(-5, 5)] vm3_list_release = m.ListRelease(vm3, vm3_pos) world.release(vm3_list_release) # release sm molecules in a line on top of box (list based release) sm_pos = [(x*0.01, 0, 0.1) for x in range(-5, 5)] sm_list_release = m.ListRelease(spec_orient_list, sm_pos) world.release(sm_list_release) # pos_vec3 = m.Vector3() # diam_vec3 = m.Vector3(0.015, 0.015, 0.015) # world.create_release_site(vm1, 100, "spherical", diam_vec3=diam_vec3) # viz and reaction data world.add_viz(all_mols) world.add_count(vm1, torus_obj) world.add_count(vm2, torus_obj) world.add_count(sm1, torus_obj) # set partitions world.add_partitions('x', -1.3, 1.3, 0.05) world.add_partitions('y', -1.3, 1.3, 0.05) world.add_partitions('z', -0.275, 0.275, 0.05) # run the simulation! :) # for i in range(iterations+1): # vm3_count = world.get_species_count(vm3, torus_obj) # if (vm3_count > 50): # world.modify_rate_constant(rxn, 1e12) # world.run_iteration() world.run_sim() world.end_sim()