I am coding to simulate the growth of a sphere in a solution environment. I am doing in this way.
Create of space and put a cell in the center as a seed.
pSpace = new char[nXRange * nYRange * nZRange]; for (int i = 0; i < nZRange; i++) for (int j = 0; j < nYRange; j++) for (int k = 0; k < nXRange; k++) pSpace[i * nXRange * nYRange + j * nXRange + k] = 0; pSpace[nXRange * nYRange * nZRange / 2 + nXRange * nYRange / 2 + nXRange/2] = 1;
Create a cell in the solution. The position of the cell is created by a random number.
int nXPostion = (int)(((float)rand()/RAND_MAX) * (nXRange - 1)); int nYPostion = (int)(((float)rand()/RAND_MAX) * (nYRange - 1)); int nZPostion = (int)(((float)rand()/RAND_MAX) * (nZRange - 1));
Calculate the change of the potential for creation of the cell.Six neighbors of the new cell are checked as left (L), Right (R), Front (F), Behind(B), Top (T), and Bottom (B*). If the neighbors of the new cell is an old cell as L in the figure, the change of the potential is PA2A, else, if it is not an old cell but solution, as R, F, B, T, and B * in the figure, it is PA2S. The creation of the new cell change the potential with PCREATE. So, the change of the potential is
fPotential = PCREATE + P(Left) + p(Right) + p(Front) + p(Behind) + p(Top) + p(Bottom);
Use a random number to compare the change of the potential as following. If the random number is larger than the exponential of change of the potential, than create a new cell, else cancel.
Theoretically, a sphere will growth around the seed. However, in my experiment, the shape of the cluster is irregular. The attached image is a cluster of 50000 cells. Could anyone give me some comments. Is it related with the generation of the random number? Thanks.