# 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)
    
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:
sim_1 = pm.make_simulation()
world.run_simulation(sim_1)

#Example 2:
sim_1 = pm.make_simulation(iterations=200, time_step=5e-5)
world.run_simulation(sim_1)
world.modify_species(name='a', new_diffusion_const=1e-4)
world.run_simulation(sim_1)  # running modified simulation
Beispiel #3
0
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()
     [ 1, 4, 5 ],
     [ 2, 4, 0 ],
     [ 7, 1, 5 ],
     [ 3, 2, 0 ],
     [ 7, 6, 2 ],
     [ 5, 4, 6 ],
     [ 1, 0, 4 ],
     [ 2, 6, 4 ],
     [ 7, 3, 1 ] ]
"""
funky_shape = pm.make_object(name='Polyhedron',
                             type='POLYHEDRON',
                             vertices=verts_list,
                             faces=faces_list)
world.add_object(funky_shape)

# Add species:
mol_a = pm.make_species(name='a')  # red, Sphere_1, 1e-6, and VOLUME by default
world.add_species(mol_a)

# Add release patterns:
rel_a = pm.make_release_pattern(species_list=[mol_a],
                                release_region=funky_shape)
world.add_release_pattern(rel_a)

# Add reactions:

# Run simulations:
sim_1 = pm.make_simulation(
    time_step=1e-5)  # using default iteration and custom time_step
world.run_simulation(sim_1)
Beispiel #5
0
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)
                                   molecules=[mol_a])
world_trans.add_surface_class(surface_classes=[trans_surf],
                              objects=[box],
                              faces=[[0, 2, 4], [3, 4, 7]])
world_abs.add_surface_class(surface_classes=[abs_surf],
                            objects=[box],
                            faces=[[1, 3, 5], [2, 5, 6]])
world_clamp_abs.add_surface_class(surface_classes=[clamp_surf],
                                  objects=[box],
                                  faces=[[0, 2, 4], [3, 4, 7]])
world_clamp_abs.add_surface_class(surface_classes=[abs_surf],
                                  objects=[box],
                                  faces=[[1, 3, 5], [2, 5, 6]])

# Add release patterns:
rel_a = pm.make_release_pattern(species_list=[mol_a], release_region=box)
world_trans.add_release_pattern(rel_a)
world_abs.add_release_pattern(rel_a)
# assuming CLAMP_CONCENTRATION allows for diffusion, so we don't need to add an additional release in to world_clamp_abs

# Add reactions:
# nada que hacer aqui

# Run simulations:
sim_long = pm.make_simulation(
    iterations=200)  # using custom iterations and default time_step
sim_short = pm.make_simulation(
    iterations=1500)  # using custom iterations and default time_step
world_trans.run_simulation(sim_short)
world_abs.run_simulation(sim_short)
world_clamp_abs.run_simulation(sim_long)