From 14260aae13fd27adf20d04ec490945e8b812908f Mon Sep 17 00:00:00 2001 From: Chris Maffeo <cmaffeo2@illinois.edu> Date: Mon, 21 Aug 2017 10:24:52 -0500 Subject: [PATCH] Added option for copying coordinates to all replicas; by default this is on --- src/Configuration.cpp | 5 ++++- src/Configuration.h | 1 + src/GrandBrownTown.cu | 12 +++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 51679b9..df7d842 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -541,6 +541,7 @@ void Configuration::setDefaults() { inputCoordinates = ""; restartCoordinates = ""; + copyReplicaCoordinates = 1; numberFluct = 0; numberFluctPeriod = 200; interparticleForce = 1; @@ -674,6 +675,8 @@ int Configuration::readParameters(const char * config_file) { inputCoordinates = value; else if (param == String("restartCoordinates")) restartCoordinates = value; + else if (param == String("copyReplicaCoordinates")) + copyReplicaCoordinates = atoi(value.val()); else if (param == String("temperature")) temperature = (float) strtod(value.val(),NULL); else if (param == String("temperatureGrid")) @@ -1612,7 +1615,7 @@ bool Configuration::loadCoordinates(const char* file_name) { return false; } - if (count >= num) { + if (count >= num*simNum) { printf("WARNING: Too many coordinates in coordinate file %s.\n", file_name); fclose(inp); return true; diff --git a/src/Configuration.h b/src/Configuration.h index 4e8bad2..b4d4587 100644 --- a/src/Configuration.h +++ b/src/Configuration.h @@ -139,6 +139,7 @@ public: String temperatureGridFile; String inputCoordinates; String inputRBCoordinates; + int copyReplicaCoordinates; String restartCoordinates; int numberFluct; int interparticleForce; diff --git a/src/GrandBrownTown.cu b/src/GrandBrownTown.cu index e474b7d..216486e 100644 --- a/src/GrandBrownTown.cu +++ b/src/GrandBrownTown.cu @@ -60,13 +60,15 @@ GrandBrownTown::GrandBrownTown(const Configuration& c, const char* outArg, // Replicate identical initial conditions across all replicas - // TODO: add an option to generate random initial conditions for all replicas for (int r = 0; r < numReplicas; ++r) { - std::copy(c.pos, c.pos + num, pos + r*num); - std::copy(c.type, c.type + num, type + r*num); - std::copy(c.serial, c.serial + num, serial + r*num); + std::copy(c.type, c.type + num, type + r*num); + std::copy(c.serial, c.serial + num, serial + r*num); + if (c.copyReplicaCoordinates > 0) + std::copy(c.pos, c.pos + num, pos + r*num); } - + if (c.copyReplicaCoordinates <= 0) + std::copy(c.pos, c.pos + numReplicas*num, pos); + currSerial = c.currSerial; // serial number of the next new particle name = c.name; // list of particle types! useful when 'numFluct == 1' posLast = c.posLast; // previous positions of particles (used for computing ionic current) -- GitLab