Description: 
"2D diffusion" between two sheets
- initial release in a line source

"""

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:
Description:
Box of A & B with reactions:
- A -> 0 decay
- A -> B decay
- 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',
    normal_vector = [0,0,1]  # the x-y plane
    extrude_direction = normal_vector   
    display = 'SOLID' 
    triangulate = False
    
Other Parameters:
    type
    vertices = []
    faces = []
    radius
    extrude_length
    objects = [] # which objects the other parameters (such as "faces") are referencing
    etc. (see notebook, p.60)
"""
# Example_1:
box = pm.make_object(name='Box', type='CUBE')  # default size and position
world.add_object(box)

# Example_2:
box_surfaces = pm.make_object(name='Surfaces',
                              type='SURFACE',
                              objects=[box],
                              faces=[[0, 1, 2], [0, 2, 3], [4, 5, 6],
                                     [4, 6, 7]])
world.add_object(box_surfaces)

# Exmaple 3:
funky_shape = pm.make_object(name='Polyhedron',
                             type='POLYHEDRON',
                             vertices=verts_list,
                             faces=faces_list)
Example #4
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
Example #5
0
Description: 
Counting statements
- A box (maybe with some region definition) with A+B->C reaction where we count each of the following at each timestep:
    + What: molecule, reaction, event/trigger
    + Where: World, object, region
    + When: frequency of counting
    + How: Front hits/back hits, e.g. on a plane that goes through the box
"""

import pymcell as pm

# Make worlds:
world = pm.make_world()

# Add objects:
box = pm.make_object(type='CUBE')  # default size and position
plane = pm.make_object(type='SURFACE',
                       normal_vector=[0, 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)
Description:
Dynamic changes
- Dynamic geometry: an interface to change the mesh at each timestep
    + Example: An initial box that updates it's geometry at each timestep with some new list of vertices and faces
"""

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):
faces_list = [ 
     [ 3, 0, 1 ],
     [ 7, 2, 3 ],
     [ 5, 6, 7 ],
     [ 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:
Example #8
0
"""
Description:
Dynamic changes:
- Dynamic rate constants: changing the rate constant of a reaction
    + Example: A box with A+B->C that where the rate constant depends on the number of A,B, or C
"""

import pymcell as pm

# Make worlds:
world = pm.make_world()

# Add objects:
box = pm.make_object(type='CUBE')  # default name, 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:
dynmc_rate = 1e5
react_dynmc = pm.make_reaction(name='react_1',
                               reaction='a + b -> c',
Example #9
0
"1D diffusion" in a thin tube
- initial release in a plane in the middle

"""

import pymcell as pm

# Make worlds:
world = pm.make_world()

# Add objects:
# 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,