コード例 #1
0
- A + B -> C irreversible
- A + B <-> C reversible

"""

import pymcell as pm

# Make worlds:
world = pm.make_world()

# 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',
コード例 #2
0
Description: 
2D diffusion on a real 2D surface
- initial release on a patch by either density or Boolean intersection of e.g. a sphere with a plane

"""

import pymcell as pm

# Make worlds:
world = pm.make_world()

# Add objects:
box = pm.make_object(name='Box', type='CUBE')
# could also write: faces = ['BOTTOM']
surface = pm.redefine_object(name='Surface',
                             type='SURFACE',
                             objects=[box],
                             faces=[[0, 1, 2], [0, 2, 3]])
world.add_object(box, surface)

# Add species:
mol_a = pm.make_species(name='a', type='SURFACE', scale_factor=.5)
world.add_species(mol_a)

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

# Run simulations:
sim_1 = pm.make_simulation()  # using default iteration and time_step
world.run_simulation(sim_1)
コード例 #3
0
import pymcell as pm

# 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
コード例 #4
0
#-----------------------------------#
# Add species:
"""
Default Parameters:
    name = 'mol_1' # then mol_2, ...
    diffusion_const = 1e-6
    type = 'VOLUME'
    color = [1.0, 0, 0] # RGB spectrum
    scale_factor = 1
    shape = 'Sphere_1'

Other Parameters:

"""
# Example_1:
mol_a = pm.make_species(name='a', diffusion_const=1e-5, type='SURFACE')
world.add_species(mol_a)

# Example_2:
mol_b = pm.make_species(name='b', color=[1.0, 1.0, 0])  # yellow
world.add_species(mol_b)

#-----------------------------------#
# Add release patterns:
"""
Defaults:
    name = 'rel_1' # then rel_2, ...
    boundary = release_region

Other Parameters:
    release_region
コード例 #5
0
"""

import pymcell as pm

# Make worlds:
world = pm.make_world()

# Add objects:
x_len = 1
y_len = 1
z_len = 1
dynmc_box = pm.make_object(name = 'Dynamic_box', type = 'CUBE', edge_dimensions = [x_len,y_len,z_len]) # default position
world.add_object(dynmc_box)

# Add species:
diff_const = 1e-6
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 = dynmc_box)
world.add_release_pattern(rel_a)

# Run simulations:
iters = 500
sim_1 = pm.make_simulation(iterations = iters, time_step = 1e-5)
for i in range(0,iters):
    world.run_simulation_step(simulations = [sim_1], step_number = i) # step_duration = sim_1.time_step by default 
    # "name" is used to ID which object we're changing, then all "new_" parameters update the previous version
    world.modify_object(name = 'Dynamic_box', new_edge_dimensions = [1,1,1.0 + i/250]) # z dim growing slowly.
コード例 #6
0
"""
Description: 
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,
コード例 #7
0
"""

import pymcell as pm
import dynamic_diffusion as dd  # external .py file that defines different diff_consts at different times.

# Make worlds:
world = pm.make_world()

# Add objects:
box = pm.make_object(name='Box', type='CUBE')  # default size and position
world.add_object(box)

# Add species:
diff_const = 1e-6
mol_a = pm.make_species(
    name='a',
    diffusion_const=diff_const)  # 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=box)
world.add_release_pattern(rel_a)

# Run simulations:
iters = 1000
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)  # step_duration = time_step by default
コード例 #8
0
# 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)