Example #1
0
def main():
    world = m.mcell_create()
    m.mcell_init_state(world)

    dt = 1e-5
    iterations = 100
    m.mcell_set_time_step(world, dt)
    m.mcell_set_iterations(world, iterations)

    # Define one volume molecule
    vm1_sym = m.create_species(world, "vm1", 1e-6, False)
    sm1_sym = m.create_species(world, "sm1", 1e-6, True)

    scene_name = "Scene"
    scene = m.create_instance_object(world, scene_name)

    # Create box object
    box_name = "Box"
    box_mesh = m.create_box(world, scene, 1.0, box_name)

    # Release site object
    # One volume list
    (vol_rel_obj, success_vol) = m.create_list_release_site(
        world, scene, [vm1_sym, vm1_sym], [1.0, 0.0], [0.0, 0.0], [0.0, 0.0],
        "rel_name_vol")
    # One surface list
    (surf_rel_obj,
     success_surf) = m.create_list_release_site(world,
                                                scene, [sm1_sym, sm1_sym],
                                                [1.0, 0.0], [0.0, 1.0],
                                                [0.0, 0.0],
                                                "rel_name_surf",
                                                surf_flags=[True, True],
                                                orientations=[1, 1])

    # Create viz data
    viz_list = m.mcell_add_to_species_list(vm1_sym, False, 0, None)
    viz_list = m.mcell_add_to_species_list(sm1_sym, True, 1, viz_list)
    m.mcell_create_viz_output(world, "./test_release_list_viz/test", viz_list,
                              0, iterations, 1)

    m.mcell_init_simulation(world)
    m.mcell_init_output(world)

    output_freq = 1
    for i in range(iterations):
        m.mcell_run_iteration(world, output_freq, 0)
    m.mcell_flush_data(world)
    m.mcell_print_final_warnings(world)
    m.mcell_print_final_statistics(world)
Example #2
0
 def add_single_species(self, spec):
     if spec.name not in self._species:
         spec_sym = m.create_species(self._world, spec.name,
                                     spec.diffusion_constant, spec.surface)
         self._species[spec.name] = spec_sym
         self.species[spec.name] = spec
         logging.info("Add species '%s' to simulation" % spec.name)
Example #3
0
def main():

    # Create the MCell world
    world = m.mcell_create()
    m.mcell_init_state(world)

    # Set iterations, step size
    dt = 1e-5
    iterations = 100
    m.mcell_set_time_step(world, dt)
    m.mcell_set_iterations(world, iterations)

    # Define volume molecule
    vm1_sym = m.create_species(world, "vm1", 1e-6, False)

    # Create a scene
    scene_name = "Scene"
    scene = m.create_instance_object(world, scene_name)

    # Create release pattern with a delay
    rel_pattern = m.create_release_pattern(world,
                                           "Release Pattern",
                                           delay=5e-4)

    # Create box objects
    box_name = "Box_Union_Outer"
    r = (0.1, 0.1, 0.1)
    ctr = (-0.3, 0.3, 0)
    box_mesh = create_rectangle(world, scene, r, ctr, box_name)

    # List of mols to release
    mol_list = m.mcell_add_to_species_list(vm1_sym, False, 0, None)

    # Release
    rel_object = m.object()
    box_rel_object = m.mcell_create_region_release(world, scene, box_mesh,
                                                   "Box Release", "ALL",
                                                   mol_list, 1000, 0, 1,
                                                   rel_pattern, rel_object)
    m.mcell_delete_species_list(mol_list)

    # Create viz data
    viz_list = m.mcell_add_to_species_list(vm1_sym, False, 0, None)
    m.mcell_create_viz_output(world, "./viz_data/test", viz_list, 0,
                              iterations, 1)

    m.mcell_init_simulation(world)
    m.mcell_init_output(world)

    output_freq = 10
    for i in range(iterations):
        m.mcell_run_iteration(world, output_freq, 0)
    m.mcell_flush_data(world)
    m.mcell_print_final_warnings(world)
    m.mcell_print_final_statistics(world)
Example #4
0
###

# Create a box
box = m.create_simple_object(name="My box",
                             type="CUBE",
                             center=[0, 0, 0],
                             radius=[1, 1, 1])

# Add it to the mcell world
world.obj_list.append(box)

###
# Species
###

mol_A = m.create_species(name="A", dc=1)
world.species_list.append(mol_A)

mol_B = m.create_species(name="B", dc=1)
world.species_list.append(mol_B)

mol_C = m.create_species(name="C", dc=1)
world.species_list.append(mol_C)

###
# Define reactions
###

# A + B -> C
rxn = m.create_reaction("%m + %m -> %m" % (mol_A, mol_B, mol_C),
                        name="rxn",
Example #5
0
###

# Define surface region by it's elements
surf_reg = m.create_surface_region(name="My region",
                                   objects=[box],
                                   faces=[[5, 6]])

# Add it to the mcell world
world.reg_list.append(surf_reg)

###
# Species
###

# Create a species
mol_A = m.create_species(name="A", dc=1, type="SURFACE")

# Add to the mcell world
world.species_list.append(mol_A)

###
# Release molecules into the sheet_box
###

list_of_mols_to_release = [mol_A]
number_of_each_to_release = [100]
orientation_of_each_mol = [";"]
world.release_mols(list_of_mols_to_release,
                   nrel=number_of_each_to_release,
                   loc="%o[%r]" % (box, surf_reg),
                   orientations=orientation_of_each_mol)
Example #6
0
###
# Thin sheet/box
###

# Create a sheet_box
sheet_box = m.create_simple_object(name="My box", type="CUBE", center=[0,0,0], radius=[1,1,0.01])

# Add it to the mcell world
world.obj_list.append(sheet_box)

###
# Species
###

# Create a species
mol_A = m.create_species(name="A",dc=1) # Volume mol by default

# Add to the mcell world
world.species_list.append(mol_A)

###
# Release molecules into the sheet_box
###

list_of_mols_to_release = [mol_A]
number_of_each_to_release = [100]
world.release_mols(list_of_mols_to_release, 
	nrel = number_of_each_to_release, 
	loc = "%o" % (sheet_box))

###
###

# Define surface region by it's elements
surf_reg_1 = m.create_surface_region(name="My region 1",
                                     objects=[box],
                                     faces=[[1]])

surf_reg_2 = m.create_surface_region(name="My region 2",
                                     objects=[box],
                                     faces=[[6]])

###
# Create molecule
###

mol_A = m.create_species(name="A", dc=1)

###
# Create the different surface classes
###

# Create a transparent surface class
surf_class_t = m.create_surface_class(name="Transparent",
                                      molecules=[mol_A],
                                      type="TRANSPARENT")

# Create a absorptive surface class
surf_class_a = m.create_surface_class(name="Absorptive",
                                      molecules=[mol_A],
                                      type="ABSORPTIVE")
Example #8
0
def main(lexer, parser):

    # Create the MCell world
    world = m.mcell_create()
    m.mcell_init_state(world)

    # Set iterations, step size
    dt = 1e-5
    iterations = 100
    m.mcell_set_time_step(world, dt)
    m.mcell_set_iterations(world, iterations)

    # Define volume molecule
    vm1_sym = m.create_species(world, "vm1", 1e-6, False)

    # Create a scene
    scene_name = "Scene"
    scene = m.create_instance_object(world, scene_name)

    ##########
    # Create each of the three binary operations
    # Each example consists of two box objects
    ##########

    # Dictionary of release evaluator objects
    rel_eval_dict = {}

    ##########
    # Union
    ##########

    # Create box objects
    box_union_outer_name = "Box_Union_Outer"
    r_union_outer = (0.1, 0.1, 0.1)
    ctr_union_outer = (-0.3, 0.3, 0)
    box_union_outer_mesh = create_rectangle(world, scene, r_union_outer,
                                            ctr_union_outer,
                                            box_union_outer_name)

    box_union_inner_name = "Box_Union_Inner"
    r_union_inner = (0.1, 0.1, 0.12)
    ctr_union_inner = (-0.3 + 0.1, 0.3 + 0.1, 0.0)
    box_union_inner_mesh = create_rectangle(world, scene, r_union_inner,
                                            ctr_union_inner,
                                            box_union_inner_name)

    # Add to the dictionary of objects for the parser to see
    lexer.obj_dict[box_union_outer_name] = box_union_outer_mesh
    lexer.obj_dict[box_union_inner_name] = box_union_inner_mesh

    # We will use the "ALL" region specification
    # We could also define a surface region using the following code
    '''
	box_union_outer_region_name = "Box_Union_Outer_Reg"
	box_union_outer_face_list = [0,1,2,3,4,5,6,7,8,9,10,11]
	box_union_outer_region = m.create_surface_region(world, box_union_outer_mesh, box_union_outer_face_list, box_union_outer_region_name)
	box_union_inner_region_name = "Box_Union_Inner_Reg"
	box_union_inner_face_list = [0,1,2,3,4,5,6,7,8,9,10,11]
	box_union_inner_region = m.create_surface_region(world, box_union_inner_mesh, box_union_inner_face_list, box_union_inner_region_name)
	'''

    # Parse a string to create a release_evaluator
    s_union = box_union_outer_name + "[ALL]" + " + " + box_union_inner_name + "[ALL]"
    print("> Parsing: " + s_union)
    lexer.mcell_world = world
    parser.parse(s_union)
    rel_eval_dict[s_union] = lexer.release_evaluator
    print("> Finished parsing.")

    ##########
    # Subtraction
    ##########

    # Create box objects
    box_sub_outer_name = "Box_Sub_Outer"
    r_sub_outer = (0.1, 0.1, 0.1)
    ctr_sub_outer = (0.3, 0.3, 0)
    box_sub_outer_mesh = create_rectangle(world, scene, r_sub_outer,
                                          ctr_sub_outer, box_sub_outer_name)

    box_sub_inner_name = "Box_Sub_Inner"
    r_sub_inner = (0.1, 0.1, 0.12)
    ctr_sub_inner = (0.3 + 0.1, 0.3 + 0.1, 0.0)
    box_sub_inner_mesh = create_rectangle(world, scene, r_sub_inner,
                                          ctr_sub_inner, box_sub_inner_name)

    # Add to the dictionary of objects for the parser to see
    lexer.obj_dict[box_sub_outer_name] = box_sub_outer_mesh
    lexer.obj_dict[box_sub_inner_name] = box_sub_inner_mesh

    # Parse a string to create a release_evaluator
    s_sub = box_sub_outer_name + "[ALL]" + " - " + box_sub_inner_name + "[ALL]"
    print("> Parsing: " + s_sub)
    lexer.mcell_world = world
    parser.parse(s_sub)
    rel_eval_dict[s_sub] = lexer.release_evaluator
    print("> Finished parsing.")

    ##########
    # Intersection
    ##########

    # Create box objects
    box_inter_outer_name = "Box_Inter_Outer"
    r_inter_outer = (0.1, 0.1, 0.1)
    ctr_inter_outer = (0.0, -0.3, 0.0)
    box_inter_outer_mesh = create_rectangle(world, scene, r_inter_outer,
                                            ctr_inter_outer,
                                            box_inter_outer_name)

    box_inter_inner_name = "Box_Inter_Inner"
    r_inter_inner = (0.1, 0.1, 0.12)
    ctr_inter_inner = (0.1, -0.3 + 0.1, 0.0)
    box_inter_inner_mesh = create_rectangle(world, scene, r_inter_inner,
                                            ctr_inter_inner,
                                            box_inter_inner_name)

    # Add to the dictionary of objects for the parser to see
    lexer.obj_dict[box_inter_outer_name] = box_inter_outer_mesh
    lexer.obj_dict[box_inter_inner_name] = box_inter_inner_mesh

    # Parse a string to create a release_evaluator
    s_inter = box_inter_outer_name + "[ALL]" + " * " + box_inter_inner_name + "[ALL]"
    print("> Parsing: " + s_inter)
    lexer.mcell_world = world
    parser.parse(s_inter)
    rel_eval_dict[s_inter] = lexer.release_evaluator
    print("> Finished parsing.")

    ##########
    # Set up all the release sites for each: union/subtraction/intersection
    ##########

    # List of mols to release
    mol_list = m.mcell_add_to_species_list(vm1_sym, False, 0, None)

    # Union
    rel_object = m.object()
    box_union_outer_rel_object = m.mcell_create_region_release_boolean(
        world, scene, "Box Union Outer Release", mol_list, 1000, 0, 1, None,
        rel_eval_dict[s_union], rel_object)

    # Subtraction
    rel_object = m.object()
    box_sub_outer_rel_object = m.mcell_create_region_release_boolean(
        world, scene, "Box Subtraction Outer Release", mol_list, 1000, 0, 1,
        None, rel_eval_dict[s_sub], rel_object)

    # Union
    mol_list = m.mcell_add_to_species_list(vm1_sym, False, 0, None)
    rel_object = m.object()
    box_inter_outer_rel_object = m.mcell_create_region_release_boolean(
        world, scene, "Box Intersection Outer Release", mol_list, 1000, 0, 1,
        None, rel_eval_dict[s_inter], rel_object)

    m.mcell_delete_species_list(mol_list)

    ##########
    # Create viz data
    ##########

    viz_list = m.mcell_add_to_species_list(vm1_sym, False, 0, None)
    m.mcell_create_viz_output(world, "./viz_data/test", viz_list, 0,
                              iterations, 1)

    m.mcell_init_simulation(world)
    m.mcell_init_output(world)

    output_freq = 10
    for i in range(iterations):
        m.mcell_run_iteration(world, output_freq, 0)
    m.mcell_flush_data(world)
    m.mcell_print_final_warnings(world)
    m.mcell_print_final_statistics(world)
# Make a surface region over the dividing plane in the middle
###

surf_reg_plane = m.create_surface_region(name="Middle plane",
	objects = [box],
	faces = [4,5]
	)

# Add it to the mcell world
world.reg_list.append(surf_reg_plane)

###
# Species
###

mol_A = m.create_species(name="A",dc=1)
world.species_list.append(mol_A)

mol_B = m.create_species(name="B",dc=1,type="SURFACE")
world.species_list.append(mol_B)

mol_C = m.create_species(name="C",dc=1)
world.species_list.append(mol_C)

###
# Define reactions
###

# A' + B' @ surf_reg_plane -> C,
rxn = m.create_reaction("%m + %m @ %r -> %m" % (mol_A, mol_B, surf_reg_plane, mol_C), name="rxn", fwd_rate = 10)
import external_geometry_library as egl

# Make a world
sim = m.create_model()

# Set current time and timestep
sim.t = 0.0
sim.dt = 1e-6

# Add the standard iteration callback to capture molecule positions
sim.iteration_callback_list.append(callback=m.viz_output_callback,
                                   data={['ALL']},
                                   skip=0)

# Create the species and add to simulation
mol_A = m.create_species(name="A", dc=1e-5,
                         type=m.SURFACE_TYPE)  # Volume mol by default
sim.species_list.append(mol_A)

# Create a sheet at z=0 (the old-fashioned way)
points = [[-1, -1, 0], [1, -1, 0], [1, 1, 0], [-1, 1, 0]]

faces = [[0, 1, 2], [0, 2, 3]]

# Scale the points in the x,y dimension
for p in points:
    p[0] *= sheet_size
    p[1] *= sheet_size

release_points = []

use_outside_library = False
Example #11
0
# Define some functions fo the iteraction of mcell and neuron

# Main
if __name__ == "__main__":

    # Create pyMCell instance
    world = m.mcell_create()
    m.mcell_init_state(world)

    dt = 1e-6
    iterations = 300
    m.mcell_set_time_step(world, dt)
    m.mcell_set_iterations(world, iterations)

    # Define one surface molecule and three volume molecules
    vm1_sym = m.create_species(world, "vm1", 1e-6, False)

    # vm1 -> NULL [1e5]
    reactants2 = m.mcell_add_to_species_list(vm1_sym, False, 0, None)
    m.create_reaction(world, reactants2, None, 0.01, name="rxn")

    # Create Scene for simulation
    scene_name = "Scene"
    scene = m.create_instance_object(world, scene_name)

    # Create a spherical release site
    pos_vec3 = m.Vector3()
    diam_vec3 = m.Vector3(0.015, 0.015, 0.015)

    position, diameter, sphere_release_object = m.create_release_site(
        world, scene, pos_vec3, diam_vec3, m.SHAPE_SPHERICAL, 500, 0, vm1_sym,