Skip to content

Commit

Permalink
Merge pull request #333 from GOMC-WSU/revert-332-revert-327-brownian
Browse files Browse the repository at this point in the history
Revert "Revert "MultiParticle Brownian like motion""
  • Loading branch information
GregorySchwing authored Mar 15, 2021
2 parents a080dda + fa43416 commit 77f519a
Show file tree
Hide file tree
Showing 23 changed files with 1,447 additions and 119 deletions.
3 changes: 3 additions & 0 deletions CMake/FileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(sources
src/PDBOutput.cpp
src/PRNGSetup.cpp
src/PSFOutput.cpp
src/Random123Wrapper.cpp
src/Reader.cpp
src/Simulation.cpp
src/StaticVals.cpp
Expand Down Expand Up @@ -131,6 +132,7 @@ set(headers
src/PRNG.h
src/PRNGSetup.h
src/PSFOutput.h
src/Random123Wrapper.h
src/Reader.h
src/SeedReader.h
src/Setup.h
Expand Down Expand Up @@ -174,6 +176,7 @@ set(headers
src/moves/MoleculeTransfer.h
src/moves/MoveBase.h
src/moves/MultiParticle.h
src/moves/MultiParticleBrownianMotion.h
src/moves/Regrowth.h
src/moves/Rotation.h
src/moves/TargetedSwap.h
Expand Down
12 changes: 12 additions & 0 deletions lib/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ struct XYZ {
return true;
return false;
}
bool operator<(XYZ const& rhs)
{
if(x < rhs.x && y < rhs.y && z < rhs.z)
return true;
return false;
}
bool operator>(XYZ const& rhs)
{
if(x > rhs.x || y > rhs.y || z > rhs.z)
return true;
return false;
}
XYZ& operator+=(XYZ const& rhs)
{
x += rhs.x;
Expand Down
5 changes: 5 additions & 0 deletions src/BoxDimensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class BoxDimensions
{
return axis.Get(b);
}

XYZ GetHalfAxis(const uint b) const
{
return halfAx.Get(b);
}

double GetTotVolume(const uint b1, const uint b2) const;

Expand Down
35 changes: 29 additions & 6 deletions src/ConfigSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ ConfigSetup::ConfigSetup(void)
sys.moves.intraSwap = DBL_MAX;
sys.moves.multiParticleEnabled = false;
sys.moves.multiParticle = DBL_MAX;
sys.moves.multiParticleBrownian = DBL_MAX;
sys.moves.regrowth = DBL_MAX;
sys.moves.crankShaft = DBL_MAX;
sys.moves.intraMemc = DBL_MAX;
Expand Down Expand Up @@ -678,6 +679,14 @@ void ConfigSetup::Init(const char *fileName, MultiSim const*const& multisim)
printf("%-40s %-4.4f \n",
"Info: Multi-Particle move frequency",
sys.moves.multiParticle);
} else if(CheckString(line[0], "MultiParticleBrownianFreq")) {
sys.moves.multiParticleBrownian = stringtod(line[1]);
if(sys.moves.multiParticleBrownian > 0.00) {
sys.moves.multiParticleEnabled = true;
}
printf("%-40s %-4.4f \n",
"Info: Multi-Particle Brownian move frequency",
sys.moves.multiParticleBrownian);
} else if(CheckString(line[0], "IntraSwapFreq")) {
sys.moves.intraSwap = stringtod(line[1]);
printf("%-40s %-4.4f \n", "Info: Intra-Swap move frequency",
Expand Down Expand Up @@ -1251,6 +1260,13 @@ void ConfigSetup::fillDefaults(void)
sys.moves.multiParticle);
}

if(sys.moves.multiParticleBrownian == DBL_MAX) {
sys.moves.multiParticleBrownian = 0.000;
printf("%-40s %-4.4f \n",
"Default: Multi-Particle Brownian move frequency",
sys.moves.multiParticleBrownian);
}

if(sys.moves.intraMemc == DBL_MAX) {
sys.moves.intraMemc = 0.0;
printf("%-40s %-4.4f \n", "Default: Intra-MEMC move frequency",
Expand Down Expand Up @@ -1506,6 +1522,12 @@ void ConfigSetup::verifyInputs(void)
}
}
#endif
if(abs(sys.moves.multiParticle) > 0.0000001 &&
abs(sys.moves.multiParticleBrownian) > 0.0000001) {
std::cout << "Error: Both multi-Particle and multi-Particle Brownian! " <<
" cannot be used at the same time!" << std::endl;
exit(EXIT_FAILURE);
}

if(!sys.elect.enable && sys.elect.oneFourScale != DBL_MAX) {
printf("Warning: 1-4 Electrostatic scaling set, but will be ignored.\n");
Expand Down Expand Up @@ -1660,8 +1682,8 @@ void ConfigSetup::verifyInputs(void)
if(std::abs(sys.moves.displace + sys.moves.rotate + sys.moves.transfer +
sys.moves.intraSwap + sys.moves.volume + sys.moves.regrowth +
sys.moves.memc + sys.moves.intraMemc + sys.moves.crankShaft +
sys.moves.multiParticle + sys.moves.cfcmc +
sys.moves.targetedSwap - 1.0) > 0.001) {
sys.moves.multiParticle + sys.moves.multiParticleBrownian +
sys.moves.cfcmc + sys.moves.targetedSwap - 1.0) > 0.001) {
std::cout << "Error: Sum of move frequencies is not equal to one!\n";
exit(EXIT_FAILURE);
}
Expand All @@ -1673,7 +1695,8 @@ void ConfigSetup::verifyInputs(void)

if(std::abs(sys.moves.displace + sys.moves.rotate + sys.moves.intraSwap +
sys.moves.volume + sys.moves.regrowth + sys.moves.intraMemc +
sys.moves.crankShaft + sys.moves.multiParticle - 1.0) > 0.001) {
sys.moves.crankShaft + sys.moves.multiParticle +
sys.moves.multiParticleBrownian - 1.0) > 0.001) {
std::cout << "Error: Sum of move frequencies is not equal to one!\n";
exit(EXIT_FAILURE);
}
Expand All @@ -1686,15 +1709,15 @@ void ConfigSetup::verifyInputs(void)
if(std::abs(sys.moves.displace + sys.moves.rotate + sys.moves.intraSwap +
sys.moves.transfer + sys.moves.regrowth + sys.moves.memc +
sys.moves.intraMemc + sys.moves.crankShaft +
sys.moves.multiParticle + sys.moves.cfcmc +
sys.moves.targetedSwap - 1.0) > 0.001) {
sys.moves.multiParticle + sys.moves.multiParticleBrownian +
sys.moves.cfcmc + sys.moves.targetedSwap - 1.0) > 0.001) {
std::cout << "Error: Sum of move frequencies is not equal to one!!\n";
exit(EXIT_FAILURE);
}
#else
if(std::abs(sys.moves.displace + sys.moves.rotate + sys.moves.intraSwap +
sys.moves.regrowth + sys.moves.intraMemc + sys.moves.crankShaft +
sys.moves.multiParticle - 1.0) > 0.001) {
sys.moves.multiParticle + sys.moves.multiParticleBrownian - 1.0) > 0.001) {
std::cout << "Error: Sum of move frequencies is not equal to one!!\n";
exit(EXIT_FAILURE);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ConfigSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ struct Step {
//Holds the percentage of each kind of move for this ensemble.
struct MovePercents {
double displace, rotate, intraSwap, intraMemc, regrowth, crankShaft,
multiParticle;
bool multiParticleEnabled;
multiParticle, multiParticleBrownian;
bool multiParticleEnabled; // for both multiparticle and multiparticleBrownian
#ifdef VARIABLE_VOLUME
double volume;
#endif
Expand Down
13 changes: 13 additions & 0 deletions src/ConsoleOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ void ConsoleOutput::PrintMove(const uint box, const ulong step) const
printElement(var->GetAcceptPercent(box, sub), elementWidth);
}

if(var->Performed(mv::MULTIPARTICLE_BM)) {
sub = mv::MULTIPARTICLE_BM;
printElement(var->GetTries(box, sub), elementWidth);
printElement(var->GetAccepted(box, sub), elementWidth);
printElement(var->GetAcceptPercent(box, sub), elementWidth);
}

if(var->Performed(mv::INTRA_SWAP)) {
sub = mv::INTRA_SWAP;
printElement(var->GetTries(box, sub), elementWidth);
Expand Down Expand Up @@ -371,6 +378,12 @@ void ConsoleOutput::PrintMoveTitle()
printElement("MPACCEPT%", elementWidth);
}

if(var->Performed(mv::MULTIPARTICLE_BM)) {
printElement("MULTIPARTICLEBM", elementWidth);
printElement("MPBMACCEPT", elementWidth);
printElement("MPBMACCEPT%", elementWidth);
}

if(var->Performed(mv::INTRA_SWAP)) {
printElement("INTRASWAP", elementWidth);
printElement("INTACCEPT", elementWidth);
Expand Down
5 changes: 5 additions & 0 deletions src/GOMCEventsProfileDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GOMC_PROFILE_EVENT(FREE_ENERGY_OUTPUT, "free_energy_file")
GOMC_PROFILE_EVENT(DISPLACE, "translate_move")
GOMC_PROFILE_EVENT(ROTATE, "rotate_move")
GOMC_PROFILE_EVENT(MULTIPARTICLE, "multiParticle_move")
GOMC_PROFILE_EVENT(MULTIPARTICLE_BM, "multiParticleBM_move")
GOMC_PROFILE_EVENT(INTRA_SWAP, "intraSwap_move")
GOMC_PROFILE_EVENT(INTRA_MEMC, "intraMEMC_move")
GOMC_PROFILE_EVENT(CRANKSHAFT, "crankshaft_move")
Expand All @@ -33,6 +34,7 @@ GOMC_PROFILE_EVENT(CFCMC, "CFCMC_move")
GOMC_PROFILE_EVENT(PREP_DISPLACE, "prepare_translate_move")
GOMC_PROFILE_EVENT(PREP_ROTATE, "prepare_rotate_move")
GOMC_PROFILE_EVENT(PREP_MULTIPARTICLE, "prepare_multiParticle_move")
GOMC_PROFILE_EVENT(PREP_MULTIPARTICLE_BM, "prepare_multiParticleBM_move")
GOMC_PROFILE_EVENT(PREP_INTRA_SWAP, "prepare_intraSwap_move")
GOMC_PROFILE_EVENT(PREP_INTRA_MEMC, "prepare_intraMEMC_move")
GOMC_PROFILE_EVENT(PREP_CRANKSHAFT, "prepare_crankshaft_move")
Expand All @@ -46,6 +48,7 @@ GOMC_PROFILE_EVENT(PREP_CFCMC, "prepare_CFCMC_move")
GOMC_PROFILE_EVENT(TRANS_DISPLACE, "transform_translate_move")
GOMC_PROFILE_EVENT(TRANS_ROTATE, "transform_rotate_move")
GOMC_PROFILE_EVENT(TRANS_MULTIPARTICLE, "transform_multiParticle_move")
GOMC_PROFILE_EVENT(TRANS_MULTIPARTICLE_BM, "transform_multiParticleBM_move")
GOMC_PROFILE_EVENT(TRANS_INTRA_SWAP, "transform_intraSwap_move")
GOMC_PROFILE_EVENT(TRANS_INTRA_MEMC, "transform_intraMEMC_move")
GOMC_PROFILE_EVENT(TRANS_CRANKSHAFT, "transform_crankshaft_move")
Expand All @@ -59,6 +62,7 @@ GOMC_PROFILE_EVENT(TRANS_CFCMC, "transform_CFCMC_move")
GOMC_PROFILE_EVENT(CALC_EN_DISPLACE, "cal_energy_translate_move")
GOMC_PROFILE_EVENT(CALC_EN_ROTATE, "cal_energy_rotate_move")
GOMC_PROFILE_EVENT(CALC_EN_MULTIPARTICLE, "cal_energy_multiParticle_move")
GOMC_PROFILE_EVENT(CALC_EN_MULTIPARTICLE_BM, "cal_energy_multiParticleBM_move")
GOMC_PROFILE_EVENT(CALC_EN_INTRA_SWAP, "cal_energy_intraSwap_move")
GOMC_PROFILE_EVENT(CALC_EN_INTRA_MEMC, "cal_energy_intraMEMC_move")
GOMC_PROFILE_EVENT(CALC_EN_CRANKSHAFT, "cal_energy_crankshaft_move")
Expand All @@ -72,6 +76,7 @@ GOMC_PROFILE_EVENT(CALC_EN_CFCMC, "cal_energy_CFCMC_move")
GOMC_PROFILE_EVENT(ACC_DISPLACE, "accept_translate_move")
GOMC_PROFILE_EVENT(ACC_ROTATE, "accept_rotate_move")
GOMC_PROFILE_EVENT(ACC_MULTIPARTICLE, "accept_multiParticle_move")
GOMC_PROFILE_EVENT(ACC_MULTIPARTICLE_BM, "accept_multiParticleBM_move")
GOMC_PROFILE_EVENT(ACC_INTRA_SWAP, "accept_intraSwap_move")
GOMC_PROFILE_EVENT(ACC_INTRA_MEMC, "accept_intraMEMC_move")
GOMC_PROFILE_EVENT(ACC_CRANKSHAFT, "accept_crankshaft_move")
Expand Down
41 changes: 41 additions & 0 deletions src/GPU/CalculateMinImageCUDAKernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,47 @@ __device__ inline void TransformUnSlantGPU(double3 & dist,
dist.z = slant.x * gpu_Invcell_z[0] + slant.y * gpu_Invcell_z[1] + slant.z * gpu_Invcell_z[2];
}


__device__ inline void WrapPBC(double &v, double &ax)
{
if(v >= ax)
v -= ax;
else if(v < 0)
v += ax;
}

__device__ inline void WrapPBC_f3(double3 &v, double3 &ax)
{
WrapPBC(v.x, ax.x);
WrapPBC(v.y, ax.y);
WrapPBC(v.z, ax.z);
}

__device__ inline void UnwrapPBC(
double &v,
double &ref,
double &ax,
double &halfax)
{
if(abs(ref - v) > halfax) {
if(ref < halfax)
v -= ax;
else
v += ax;
}
}

__device__ inline void UnwrapPBC_f3(
double3 &v,
double3 &ref,
double3 &ax,
double3 &halfax)
{
UnwrapPBC(v.x, ref.x, ax.x, halfax.x);
UnwrapPBC(v.y, ref.y, ax.y, halfax.y);
UnwrapPBC(v.z, ref.z, ax.z, halfax.z);
}

__device__ inline double MinImageSignedGPU(double raw, double ax, double halfAx)
{
if (raw > halfAx)
Expand Down
1 change: 1 addition & 0 deletions src/GPU/ConstantDefinitionsCUDAKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ void DestroyCUDAVars(VariablesCUDA *vars)
CUFREE(vars->gpu_cellVector);
CUFREE(vars->gpu_mapParticleToCell);
CUFREE(vars->gpu_nonOrth);
CUFREE(vars->gpu_startAtomIdx);
for(uint b = 0; b < BOX_TOTAL; b++) {
CUFREE(vars->gpu_cell_x[b]);
CUFREE(vars->gpu_cell_y[b]);
Expand Down
Loading

0 comments on commit 77f519a

Please sign in to comment.