# Make worlds: world = pm.make_world() # Add objects: # "CUBE" (perhaps we need a better name?) is defined first by declaring the [x,y,z] edge lendths ("dimensions"), then \ # the normal_vector is given to define it's rotational orientation about the center. box = pm.make_object(name='Box', type='CUBE', center=[0, 0, 0], edge_dimensions=[10, 10, 0.01]) world.add_object(box) # Add species: mol_a = pm.make_species(name='a') mol_b = pm.make_species(name='b') mol_c = pm.make_species(name='c') world.add_species(mol_a, mol_b, mol_c) # Add release patterns: rel_a_b = pm.make_release_pattern(species_list=[mol_a, mol_b], release_region=box) world.add_release_pattern(rel_a_b) # Add reactions: react_1 = pm.make_reaction(name='React_1', reaction='a + b -> c') world.add_reaction(react_1) # Run simulations: sim_1 = pm.make_simulation() # using default iteration and time_step world.run_simulation(sim_1)
# Add objects: box = pm.make_object(name='Box', type='CUBE') # default size and position world.add_object(box) # Add species: mol_a = pm.make_species(name='a') # red, Sphere_1, 1e-6, and VOLUME by default mol_b = pm.make_species(name='b', color=[0, 0, 1]) # blue mol_c = pm.make_species(name='c', color=[0, 1, 0]) # green world.add_species(mol_a, mol_b, mol_c) # Add release patterns: rel_a_b = pm.make_release_pattern(species_list=[mol_a, mol_b], release_region=box) world.add_release_pattern(rel_a_b) # Add reactions: react_1 = pm.make_reaction(name='React_1', reaction='a -> NULL') # 1e3 forward_rate by default react_2 = pm.make_reaction(name='React_2', reaction='a -> b', forward_rate=1e4) react_3 = pm.make_reaction(name='React_3', reaction='a + b -> c', forward_rate=5e3) # isn't this redundant? react_4 = pm.make_reaction(name='React_4', reaction='a + b <-> c', forward_rate=5e3, backward_rate=1e8) world.add_reaction(react_1, react_2, react_3, react_4) # Run simulations: sim_1 = pm.make_simulation() # using default iteration and time_step world.run_simulation(sim_1)
#-----------------------------------# # Add reactions: """ Default Parameters: name = 'react_1' # then react_2, ... forward_rate = 1e6 rate = forward_rate backward_rate = 1e6 Other Parameters: reaction """ # Example 1: react_1 = pm.make_reaction(name='a_to_null', reaction='a -> NULL', forward_rate=1e6) world.add_reaction(react_1) #-----------------------------------# # Run simulations: """ Default Parameters: name = 'sim_1' # then 'sim_2', ... iterations = 1000 time_step = 1e-6 Other Parameters: """ # Example 1:
0]) # 1x1 plane created on the x-z plane world.add_object(box, plane) # Add species: mol_a = pm.make_species(name='a') # red, Sphere_1, 1e-6, and VOLUME by default mol_b = pm.make_species(name='b', color=[0, 0, 1]) # blue mol_c = pm.make_species(name='c', color=[0, 1, 0]) # green world.add_species(mol_a, mol_b, mol_c) # Add release patterns: rel_a_b = pm.make_release_pattern(species_list=[mol_a, mol_b], release_region=box) world.add_release_pattern(rel_a_b) # Add reactions: react_a_b = pm.make_reaction(name='react_1', reaction='a + b -> c') world.add_reaction(react_a_b) # Run simulations: iters = 50 t_step = 1e-6 sim_1 = pm.make_simulation(iterations=iters, time_step=t_step) for i in range(0, iters): world.run_simulation_step(simulations=[sim_1], step_number=i) print 'Time: ', i * t_step print 'mol_a count: ', world.get_species_count(name='a', time=i * t_step) print 'mol_b count: ', world.get_species_count(name='b', time=i * t_step) print 'mol_c count: ', world.get_species_count(name='c', time=i * t_step) print 'Reaction a+b->c count: ', world.get_reaction_count(name='react_1', time=i * t_step) # ... and so on ... world.get_what_you_want_count()
Unbounded diffusion """ import pymcell as pm # Make worlds: world = pm.make_world() # Add species: mol_a = pm.make_species(name='a', diffusion_const=1e-6, type='VOLUME') world.add_species(mol_a) # Add release patterns: rel_a = pm.make_release_pattern(species_list=[mol_a], location=[0, 0, 0], shape='SPHERICAL', probablity=1, quantity=1000) world.add_release_pattern(rel_a) # Add reactions: react_1 = pm.make_reaction(name='React_1', reaction='a -> NULL', forward_rate=1e6) world.add_reaction(react_1) # Run simulations: sim_1 = pm.make_simulation(iterations=1000, time_step=1e-6) # these are the default parameters world.run_simulation(sim_1)
# Add species: mol_a = pm.make_species(name='a') # red, Sphere_1, 1e-6, and VOLUME by default mol_b = pm.make_species(name='b', color=[0, 0, 1]) # blue mol_c = pm.make_species(name='c', color=[0, 1, 0]) # green world.add_species(mol_a, mol_b, mol_c) # Add release patterns: rel_a_b = pm.make_release_pattern(species_list=[mol_a, mol_b], release_region=box) world.add_release_pattern(rel_a_b) # Add reactions: dynmc_rate = 1e5 react_dynmc = pm.make_reaction(name='react_1', reaction='a + b -> c', rate=dynmc_rate) world.add_reaction(react_dynmc) # Run simulations: iters = 1000 t_step = 1e-6 step_len = 10 sim_1 = pm.make_simulation(iterations=iters, time_step=t_step) for i in range(0, iters, step_len): world.run_simulation_step(simulations=[sim_1], step_number=i, step_duration=t_step(step_len)) dynmc_rate += 1e-6 # "name" is used to ID which object we're changing, then all "new_" parameters update the previous version world.modify_reaction(name='react_1',
# In make_object(), there are many input parameters, and if you don't include the necessary \ # parameters for the given object type, you'll get default values and perhaps a notification. cylinder = pm.make_object(name='Cylinder', type='CYLINDER', center=[0, 0, 0], radius=1, normal_vector=[1, 0, 0], extrude_length=20) plane = pm.make_object(name='Plane', type='PLANE', center=[0, 0, 0], normal_vector=[1, 0, 0]) world.add_object(cylinder, plane) # Add species: mol_a = pm.make_species(name='a', scale_factor=2) world.add_species(mol_a) # Add release patterns: rel_a = pm.make_release_pattern(species_list=[mol_a], release_region=plane, boundary=cylinder) world.add_release_pattern(rel_a) # Add reactions: react_1 = pm.make_reaction(name='React_1', reaction='a -> NULL') world.add_reaction(react_1) # Run simulations: sim_1 = pm.make_simulation() # using default iteration and time_step world.run_simulation(sim_1)