In principle it is possible to use STSE as a toolkit allowing for simulation of Dynamic Systems with Dynamic Structures (DS2). To provide an intuitive example we prepared an example model of phyllotaxis. The main difference to simulation on static structures are some additional components are useful: subcompartment divisions, subcomparment growht and subcompartment removal. All these rutines are predefined in STSE.
The sample code (in SVN: 11_06_16_meristem_tissue_01.py
):
def execute( self ):
def pre_fun( wt, cell ):
# before the division
mesh = wt
# store properties
p = {}
for (k,v) in mesh.const.cell_properties.items():
p[k]=wt.cell_property(cell, k)
return p
def post_fun( wt, pre_res, div_res ):
# post division
mesh = wt
a = div_res[2][0]["added_cell1"]
b = div_res[2][0]["added_cell2"]
for (k, v) in pre_res.items():
if k == self.c_prim_property:
mesh.cell_property(a, k, v)
mesh.cell_property(b, k, 0)
else:
mesh.cell_property(a, k, v)
mesh.cell_property(b, k, v)
mesh = self.window._voronoi_wt
i = 0
while i < self.c_steps:
# step of tissue growth
growth.tgs_linear_growth (mesh, self.center, 1, 0.03)
# select cells for division based on surface
# divide all selected cells according to division strategy
growth.chd_surface(mesh, self.c_cell_size, growth.dcs_shortest_wall_with_geometric_shrinking, pre_fun=pre_fun, post_fun=post_fun )
loctr = self.removeStrategy.cells_to_remove()
self.register_removed_primordia( loctr )
for c in loctr:
mesh.remove_cell(c)
# modify a zone of prim creation
self.central_ring()
# phyllotaxis
self.phyllotaxis.execute()
# update the view
i = i + 1
self.mark_cells()
self.window.update_properties_from_wt2d_to_pm( color = (0, 255, 0) )
self.window.scene_model.save_png("res/%.4d.png"%self.phyllotaxis.time)
def pre_fun( wt, cell ):
# before the division
mesh = wt
# store properties
p = {}
for (k,v) in mesh.const.cell_properties.items():
p[k]=wt.cell_property(cell, k)
return p
def post_fun( wt, pre_res, div_res ):
# post division
mesh = wt
a = div_res[2][0]["added_cell1"]
b = div_res[2][0]["added_cell2"]
for (k, v) in pre_res.items():
if k == self.c_prim_property:
mesh.cell_property(a, k, v)
mesh.cell_property(b, k, 0)
else:
mesh.cell_property(a, k, v)
mesh.cell_property(b, k, v)
mesh = self.window._voronoi_wt
i = 0
while i < self.c_steps:
# step of tissue growth
growth.tgs_linear_growth (mesh, self.center, 1, 0.03)
# select cells for division based on surface
# divide all selected cells according to division strategy
growth.chd_surface(mesh, self.c_cell_size, growth.dcs_shortest_wall_with_geometric_shrinking, pre_fun=pre_fun, post_fun=post_fun )
loctr = self.removeStrategy.cells_to_remove()
self.register_removed_primordia( loctr )
for c in loctr:
mesh.remove_cell(c)
# modify a zone of prim creation
self.central_ring()
# phyllotaxis
self.phyllotaxis.execute()
# update the view
i = i + 1
self.mark_cells()
self.window.update_properties_from_wt2d_to_pm( color = (0, 255, 0) )
self.window.scene_model.save_png("res/%.4d.png"%self.phyllotaxis.time)