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)
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)
def __init__(self, seed: int) -> None: self._world = m.mcell_create() self._started = False # the value for _species & _surface_classes is a swig wrapped sym_entry self._species = {} # type: Dict[str, Any] self._surface_classes = {} # type: Dict[str, Any] # the value for _mesh_objects is a swig wrapped "object" self._mesh_objects = {} # type: Dict[str, Any] # the value for _mesh_objects is a swig wrapped "region" self._regions = {} # type: Dict[str, Any] self._releases = {} # type: Dict[str, Any] self._counts = {} # type: Dict[str, Any] self._iterations = 0 self._current_iteration = 0 self._finished = False self._output_freq = 10 self._seed = seed m.mcell_set_seed(self._world, seed) # m.mcell_silence_notifications(self._world) m.mcell_init_state(self._world) # This is the top level instance object. We just call it "Scene" here # to be consistent with the MDL output from Blender. self.scene_name = "Scene" self._scene = m.create_instance_object(self._world, self.scene_name) # this is different than _species. instead of swig wrapped sym_entry, # this contains Species objects self.species = {} # These allow you to have surface properties affect all molecules. self._all_mol_sym = m.mcell_get_all_mol_sym(self._world) self._species['ALL_MOLECULES'] = self._all_mol_sym self._all_volume_mol_sym = m.mcell_get_all_volume_mol_sym(self._world) self._species['ALL_VOLUME_MOLECULES'] = self._all_volume_mol_sym self._all_surface_mol_sym = m.mcell_get_all_mol_sym(self._world) self._species['ALL_SURFACE_MOLECULES'] = self._all_surface_mol_sym
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)
""" import math import neuron import pymcell as m import torus # 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"