Tips for making 2D simulations as computationally light as possible?


22
views
0
6 days ago by
This isn't for research, simply playing with the shapes and textures for some potential artistic works.
Questions for you brilliant scientists:
-What are your tips for making these simulations run as quickly as possible?
-Potential avenues to try?

Is GPU acceleration/ and or parallelization implementation even remotely feesable?

Any ideas or potential pitfalls would be greatly appreciated, before I go off and try something crazy and overly complicated.

I'm pretty adept with python and motivated to learn




Community: CompuCell3D

2 Answers


0
6 days ago by
CC3D already has parallelization built in and often works pretty well. You can also gain speed by limiting how much text is written to the console. The debug frequency in particular can slow down a simulation significantly.

To do both these things, add the lines below to your project's xml file (after the end of the <Potts> block);
<Metadata>
  <DebugOutputFrequency>100</DebugOutputFrequency>
  <NumberOfProcessors>    4</NumberOfProcessors>
</Metadata>

The above tells CC3D to only output the step info every 100 MCS and that it should try to use 4 CPUs (or threads, or cores). If your python script also writes to the terminal (with print statements) then remove or reduce how often that is done.

If a surface constraint isn't needed you can also remove that from the simulation, which helps speed. Check your xml for a chunk like;
<Plugin Name="Surface">
  <SurfaceEnergyParameters CellType="typeA" LambdaSurface="2.0" TargetSurface="79"/>
  <SurfaceEnergyParameters CellType="typeB" LambdaSurface="2.0" TargetSurface="79"/>
</Plugin>
and either comment it out or delete it. Also remove any reference in your python file to cells' surface parameters (targetSurface, lambdaSurface).

For artistic results you might consider using periodic boundary conditions, which will wrap the simulation around and removes the effects of the border on the simulation. If a cell drifts off the right side of the simulation box it reappears on the left. Cells on one side of the box interact with cells on the other via the wrapping. This will help to generate repetitive patterns. In the <Potts> section of the xml file add;
  <Boundary_x>Periodic</Boundary_x>
  <Boundary_y>Periodic</Boundary_y>
(You can also add an additional line if you want the Z-axis to be periodic as well.)

You can also explore removing an unneeded (for your simulation) Plugins. In your xml file look for things like <Plugin Name="CenterOfMass"> and remove them if they aren't needed.

One more thing to try is a hexagonal (instead of square) lattice. That probably won't help speed but a hexagonal lattice might give more interesting patterns since the symmetry goes from 4 to 6. In the <Potts> block of the xml file add;
  <LatticeType>Hexagonal</LatticeType>

There are a couple changes in the player that can also speed things up;
1. [visualization tab][cell borders] turn off if you don't need the cell borders. In large simulations (particularly in 3D) drawing cell borders takes a lot of time.
2. [Tools tab][Configuration...][output tab];
   a. increase the "update screen every Nth MCS" to a larger value so the screen isn't rewritten so often.
   b. uncheck the "save image every Nth MCS" or set to a large value
   c. uncheck the "Save lattice every Nth MCS"
3. [Tools tab][Configuration...][Axes'n'Decor tab];
   a. uncheck everything.

I hope these ideas help.
0
5 days ago by
Wow, what an incredibly in depth answer!  Thank you so much, Dr.Sulka!
Your welcome. Feel free to post any interesting or pleasing results you get with CC3D to this forum.
written 4 days ago by James Sluka  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »