CompuCell3d manual and Tutorial Version 2



Download 6.67 Mb.
Page24/66
Date26.04.2018
Size6.67 Mb.
#46944
1   ...   20   21   22   23   24   25   26   27   ...   66
Figure 14. Detail of processed experimental image of flowing quasi-2D bubbles. Image size is 15 cm x 15 cm.

Generalized cells will represent bubbles in this simulation. To simulate this experiment in CompuCell3D we need to write Python steppables that 1) create bubbles at one end of the channel, 2) inject air into the bubble which includes a given location (the identity of this bubble will change in time due to the flow), 3) remove bubbles at the open end of the channel. We will store the source code in a file called 'foamairSteppables.py'. We will also need a main Python script to call these steppables appropriately.

We simulate bubble injection by creating generalized cells (bubbles) along the lattice edge corresponding to the left end of the channel (small-x values of the cell lattice). We simulate air injection into a bubble at the injection point, by identifying the bubble currently at the injection point and increasing its target volume at a fixed rate. Removing a bubble from the simulation simply requires assigning it a target volume of zero once it comes close to the right end of the channel (large-x values of the cell lattice).

We first define a CC3DML configuration file for the foam-flow simulation (Listing 10).






10000

5

Hexagonal





5

5

5

3

Listing 10. CC3DML configuration file for the foam-flow simulation. This file initializes needed plugins but all of the interesting work is done in Python.



The CC3DML configuration file is simple: it initializes the VolumeLocalFlex, CellType, Contact and CenterOfMass plugins. We do not use a cell-lattice-initializer steppable, because all bubbles are created as the simulation runs. We use VolumeLocalFlex because individual bubbles will change their target volumes during the simulation. We also include the CenterOfMass plugin to track the changing centroids of each bubble. The CenterOfMass plugin in CompuCell3D actually calculates , the centroid of the generalized cell multiplied by volume of the cell:

, 

so the actual centroid of the bubble is:



. 

The ability to track a generalized-cell’s centroid is useful if we need to pick a single reference point in the cell. In this example we will remove bubbles whose centroids have x-coordinate greater than a cutoff value.

We will implement the Python script in four sections: 1) a main script (Listing 11), which runs every MCS and calls the steppables to (2) create bubbles at the left end of the cell lattice (BubbleNucleator, Listing 12), (3) enlarge the target volume of the bubble at the injector site (AirInjector, Listing 13), and (4) set the target volume of bubbles at the right end of the cell lattice to zero (BubbleCellRemover, Listing 14). We store classes (2-4) in a separate file called 'foamairSteppables.py'.

import sys

from os import environ

import string

sys.path.append(environ["PYTHON_MODULE_PATH"])

import CompuCellSetup


sim,simthread = CompuCellSetup.getCoreSimulationObjects()
#Create extra player fields here

CompuCellSetup.initializeSimulationObjects(sim,simthread)


#Add Python steppables here

steppableRegistry=CompuCellSetup.getSteppableRegistry()



Download 6.67 Mb.

Share with your friends:
1   ...   20   21   22   23   24   25   26   27   ...   66




The database is protected by copyright ©ininet.org 2024
send message

    Main page