diff --git a/DLASystem.cpp b/DLASystem.cpp index 490927f..75cf08d 100644 --- a/DLASystem.cpp +++ b/DLASystem.cpp @@ -167,7 +167,7 @@ void DLASystem::moveLastParticle() { setGrid(lastP->pos, 1); // set the new grid site to be occupied // check if we stick - if (checkStick()) { + if (checkStick() && this->rgen.random01() <= this->stickProbability) { this->csv_out << frame << "," << lastP->pos[0] << "," << lastP->pos[1] << endl; setParticleInactive(); // make the particle inactive (stuck) updateClusterRadius(lastP->pos); // update the cluster radius, addCircle, etc. @@ -197,16 +197,17 @@ int DLASystem::checkStick() { // constructor -DLASystem::DLASystem(std::ofstream csv_out) { +DLASystem::DLASystem(std::ofstream csv_out, double stickProbability) + : stickProbability(stickProbability), csv_out(std::move(csv_out)) { cout << "creating system, gridSize " << gridSize << endl; endNum = 1000; - this->csv_out = std::move(csv_out); // allocate memory for the grid, remember to free the memory in destructor grid = new int *[gridSize]; for (int i = 0; i < gridSize; i++) { grid[i] = new int[gridSize]; } + // reset initial parameters Reset(); diff --git a/DLASystem.h b/DLASystem.h index 3fa3d56..22b1421 100644 --- a/DLASystem.h +++ b/DLASystem.h @@ -30,6 +30,8 @@ private: double addCircle; double killCircle; + double stickProbability; + // size of grid static const int gridSize = 1600; int **grid; // this will be a 2d array that stores whether each site is occupied @@ -64,7 +66,7 @@ public: int lastParticleIsActive; // constructor - DLASystem(std::ofstream csv_out); + DLASystem(std::ofstream csv_out, double stickProbability); // destructor ~DLASystem(); diff --git a/mainDLA.cpp b/mainDLA.cpp index 740580d..9e7437f 100644 --- a/mainDLA.cpp +++ b/mainDLA.cpp @@ -16,7 +16,7 @@ int main(int argc, char **argv) { std::ofstream csv_out("./out.csv"); // create the system - sys = new DLASystem(std::move(csv_out)); + sys = new DLASystem(std::move(csv_out), 0.5); // this is the seed for the random numbers int seed = 6;