Skip to content

Commit

Permalink
Merge branch 'MEMC_Liq' of https://github.com/GOMC-WSU/GOMC into MEMC…
Browse files Browse the repository at this point in the history
…_Liq

Merge updates into local MEMC_liq
  • Loading branch information
jpotoff committed Feb 10, 2025
2 parents 9320eea + 24a694b commit 88fd6a2
Show file tree
Hide file tree
Showing 25 changed files with 732 additions and 900 deletions.
63 changes: 30 additions & 33 deletions lib/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,44 +97,38 @@ inline void record_debug(uint *x, uint len, std::string filename,

//******************************************************************************

typedef unsigned int uint;
typedef unsigned long int ulong;

#define UNUSED(x) (void)(x)

// single XYZ for use as a temporary and return type
struct XYZ {
double x, y, z;

// single XYZ coordinate for use as a temporary and return type
class XYZ {
public:
XYZ() : x(0.0), y(0.0), z(0.0) {}
XYZ(double xVal, double yVal, double zVal) : x(xVal), y(yVal), z(zVal) {}

friend inline std::ostream &operator<<(std::ostream &stream, const XYZ &p);

inline double getX() const { return x; }
inline double getY() const { return y; }
inline double getZ() const { return z; }

void Reset() { x = y = z = 0.0; }
XYZ &operator=(XYZ const &rhs) {
x = rhs.x;
y = rhs.y;
z = rhs.z;
return *this;
}
bool operator==(XYZ const &rhs) {
if (x == rhs.x && y == rhs.y && z == rhs.z)
return true;
return false;
inline bool operator==(XYZ const &rhs) const {
return (x == rhs.x && y == rhs.y && z == rhs.z);
}
bool operator!=(XYZ const &rhs) {
if (x != rhs.x || y != rhs.y || z != rhs.z)
return true;
return false;
inline bool operator!=(XYZ const &rhs) const {
return (x != rhs.x || y != rhs.y || z != rhs.z);
}
bool operator<(XYZ const &rhs) {
if (x < rhs.x && y < rhs.y && z < rhs.z)
return true;
return false;
inline bool operator<(XYZ const &rhs) const {
return (x < rhs.x && y < rhs.y && z < rhs.z);
}
bool operator>(XYZ const &rhs) {
if (x > rhs.x || y > rhs.y || z > rhs.z)
return true;
return false;
inline bool operator>(XYZ const &rhs) const {
return (x > rhs.x || y > rhs.y || z > rhs.z);
}

XYZ &operator+=(XYZ const &rhs) {
x += rhs.x;
y += rhs.y;
Expand Down Expand Up @@ -167,26 +161,26 @@ struct XYZ {
return *this;
}

XYZ operator+(XYZ const &rhs) const { return XYZ(*this) += rhs; }
XYZ operator-(XYZ const &rhs) const { return XYZ(*this) -= rhs; }
XYZ operator*(XYZ const &rhs) const { return XYZ(*this) *= rhs; }
XYZ operator/(XYZ const &rhs) const { return XYZ(*this) /= rhs; }
XYZ operator+(XYZ const &rhs) const { return XYZ(x+rhs.x, y+rhs.y, z+rhs.z); }
XYZ operator-(XYZ const &rhs) const { return XYZ(x-rhs.x, y-rhs.y, z-rhs.z); }
XYZ operator*(XYZ const &rhs) const { return XYZ(x*rhs.x, y*rhs.y, z*rhs.z); }
XYZ operator/(XYZ const &rhs) const { return XYZ(x/rhs.x, y/rhs.y, z/rhs.z); }

XYZ operator*(const double a) const { return XYZ(*this) *= a; }
XYZ operator*(const double a) const { return XYZ(x*a, y*a, z*a); }

XYZ operator-() const { return XYZ(*this) * -1.0; }
XYZ operator-() const { return XYZ(-x, -y, -z); }

void Inverse() {
x = 1.0 / x;
y = 1.0 / y;
z = 1.0 / z;
}

double Length() const { return sqrt(LengthSq()); }
double LengthSq() const { return x * x + y * y + z * z; }
double Length() const { return std::sqrt(LengthSq()); }

XYZ &Normalize() {
*this *= (1 / Length());
*this *= (1.0 / Length());
return *this;
}

Expand All @@ -207,6 +201,9 @@ struct XYZ {
m = z;
return m;
}

public:
double x, y, z;
};

inline std::ostream &operator<<(std::ostream &stream, const XYZ &p) {
Expand Down
8 changes: 4 additions & 4 deletions src/BlockOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ struct BlockAverages : OutputableBase {
stepsPerOut = event.frequency;
invSteps = 1.0 / stepsPerOut;
firstInvSteps = invSteps;
//Handle the case where we are restarting from a checkpoint and the first
//interval is smaller than expected because we create a checkpoint more
//often than the Block output frequency.
// Handle the case where we are restarting from a checkpoint and the first
// interval is smaller than expected because we create a checkpoint more
// often than the Block output frequency.
if (startStep != 0 && (startStep % stepsPerOut) != 0) {
ulong diff;
diff = stepsPerOut - (startStep % stepsPerOut);
firstInvSteps = 1.0/diff;
firstInvSteps = 1.0 / diff;
}
enableOut = event.enable;
}
Expand Down
61 changes: 34 additions & 27 deletions src/ConfigSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ void ConfigSetup::Init(const char *fileName, MultiSim const *const &multisim) {
} else if (CheckString(line[0], "IntraMEMC-1Freq")) {
if (stringtod(line[1]) > 0.0) {
sys.moves.intraMemc = stringtod(line[1]);
printf("%-40s %-4.4f \n", "Info: IntraMEMC-2 move frequency",
printf("%-40s %-4.4f \n", "Info: IntraMEMC-1 move frequency",
sys.moves.intraMemc);
sys.intraMemcVal.enable = true;
sys.intraMemcVal.MEMC1 = true;
Expand Down Expand Up @@ -1913,15 +1913,13 @@ void ConfigSetup::verifyInputs(void) {
std::cout << "ERROR: Impulse Pressure Correction cannot be "
<< "used with LJ long-range corrections." << std::endl;
exit(EXIT_FAILURE);

}
if (((sys.ff.VDW_KIND == sys.ff.VDW_SHIFT_KIND) ||
(sys.ff.VDW_KIND == sys.ff.VDW_SWITCH_KIND)) &&
sys.ff.doImpulsePressureCorr) {
std::cout << "ERROR: Impulse Pressure Correction is not supported "
<< "for SWITCH or SHIFT potentials." << std::endl;
exit(EXIT_FAILURE);

}
if (sys.ff.doImpulsePressureCorr && sys.ff.doTailCorr) {
std::cout << "ERROR: Both LRC (Long Range Correction) and "
Expand Down Expand Up @@ -2120,9 +2118,10 @@ void ConfigSetup::verifyInputs(void) {
if (in.restart.restartFromBinaryCoorFile) {
for (i = 0; i < BOX_TOTAL; i++) {
if (!in.files.binaryCoorInput.defined[i]) {
std::cout << "ERROR: Binary coordinate file was not specified for box "
"number "
<< i << "!" << std::endl;
std::cout
<< "ERROR: Binary coordinate file was not specified for box "
"number "
<< i << "!" << std::endl;
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -2190,7 +2189,8 @@ void ConfigSetup::verifyInputs(void) {
if ((sys.memcVal.MEMC1 && sys.memcVal.MEMC2) ||
(sys.memcVal.MEMC1 && sys.memcVal.MEMC3) ||
(sys.memcVal.MEMC2 && sys.memcVal.MEMC3)) {
std::cout << "ERROR: Multiple MEMC methods were specified, but only one is allowed!\n";
std::cout << "ERROR: Multiple MEMC methods were specified, but only one "
"is allowed!\n";
exit(EXIT_FAILURE);
}
if ((sys.memcVal.MEMC1 && sys.memcVal.MEMC2) ||
Expand All @@ -2204,19 +2204,23 @@ void ConfigSetup::verifyInputs(void) {
if ((sys.intraMemcVal.MEMC1 && sys.intraMemcVal.MEMC2) ||
(sys.intraMemcVal.MEMC1 && sys.intraMemcVal.MEMC3) ||
(sys.intraMemcVal.MEMC2 && sys.intraMemcVal.MEMC3)) {
std::cout << "ERROR: Multiple Intra-MEMC methods are specified, but only one is allowed!\n";
std::cout << "ERROR: Multiple Intra-MEMC methods are specified, but only "
"one is allowed!\n";
exit(EXIT_FAILURE);
}
if (!sys.memcVal.readVol || !sys.intraMemcVal.readVol) {
std::cout << "ERROR: In the MEMC method, the Sub-Volume was not specified!\n";
std::cout
<< "ERROR: In the MEMC method, the Sub-Volume was not specified!\n";
exit(EXIT_FAILURE);
}
if (!sys.memcVal.readRatio || !sys.intraMemcVal.readRatio) {
std::cout << "ERROR: In the MEMC method, Exchange Ratio was not specified!\n";
std::cout
<< "ERROR: In the MEMC method, Exchange Ratio was not specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.largeKind.size() != sys.memcVal.exchangeRatio.size()) {
std::cout << "ERROR: In the MEMC method, the specified number of Large Kinds was "
std::cout << "ERROR: In the MEMC method, the specified number of Large "
"Kinds was "
<< sys.memcVal.largeKind.size() << ", but "
<< sys.memcVal.exchangeRatio.size()
<< " exchange ratio was specified!\n";
Expand All @@ -2233,36 +2237,37 @@ void ConfigSetup::verifyInputs(void) {
if ((sys.memcVal.largeKind.size() != sys.memcVal.smallKind.size()) ||
(sys.intraMemcVal.largeKind.size() !=
sys.intraMemcVal.smallKind.size())) {
std::cout
<< "ERROR: In the MEMC method, the specified number of Large Kinds is not "
<< " equal as specified number of Small Kinds!\n";
std::cout << "ERROR: In the MEMC method, the specified number of Large "
"Kinds is not "
<< " equal as specified number of Small Kinds!\n";
exit(EXIT_FAILURE);
}
if (!sys.memcVal.readLargeBB || !sys.intraMemcVal.readLargeBB) {
std::cout
<< "ERROR: In the MEMC method, Large Kind BackBone was not specified!\n";
std::cout << "ERROR: In the MEMC method, Large Kind BackBone was not "
"specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.largeKind.size() != sys.memcVal.largeBBAtom1.size()) {
std::cout << "ERROR: In the MEMC method, the specified number of Large Kinds was "
std::cout << "ERROR: In the MEMC method, the specified number of Large "
"Kinds was "
<< sys.memcVal.largeKind.size() << ", but "
<< sys.memcVal.largeBBAtom1.size()
<< " sets of Large Molecule BackBone was specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.MEMC2 && !sys.memcVal.readSmallBB) {
std::cout
<< "ERROR: In the MEMC-2 method, Small Kind BackBone was not specified!\n";
std::cout << "ERROR: In the MEMC-2 method, Small Kind BackBone was not "
"specified!\n";
exit(EXIT_FAILURE);
}

if (sys.memcVal.MEMC2 &&
(sys.memcVal.smallKind.size() != sys.memcVal.smallBBAtom1.size())) {
std::cout
<< "ERROR: In the MEMC-2 method, the specified number of Small Kinds was "
<< sys.memcVal.smallKind.size() << ", but "
<< sys.memcVal.smallBBAtom1.size()
<< " sets of Small Molecule BackBone was specified!\n";
std::cout << "ERROR: In the MEMC-2 method, the specified number of Small "
"Kinds was "
<< sys.memcVal.smallKind.size() << ", but "
<< sys.memcVal.smallBBAtom1.size()
<< " sets of Small Molecule BackBone was specified!\n";
exit(EXIT_FAILURE);
}
if(sys.memcVal.MEMC2Liq && !sys.memcVal.readSmallBB) {
Expand All @@ -2279,15 +2284,17 @@ void ConfigSetup::verifyInputs(void) {
}

if (sys.intraMemcVal.MEMC2 && !sys.intraMemcVal.readSmallBB) {
std::cout << "ERROR: In the Intra-MEMC-2 method, Small Kind BackBone was not "
"specified!\n";
std::cout
<< "ERROR: In the Intra-MEMC-2 method, Small Kind BackBone was not "
"specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.enable && sys.intraMemcVal.enable) {
if ((sys.memcVal.MEMC1 && !sys.intraMemcVal.MEMC1) ||
(sys.memcVal.MEMC2 && !sys.intraMemcVal.MEMC2) ||
(sys.memcVal.MEMC3 && !sys.intraMemcVal.MEMC3)) {
std::cout << "ERROR: The selected intra-MEMC method was not same as the inter-MEMC method!\n";
std::cout << "ERROR: The selected intra-MEMC method was not same as "
"the inter-MEMC method!\n";
exit(EXIT_FAILURE);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Ewald.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,7 @@ void Ewald::BoxForceReciprocal(XYZArray const &molCoords,
CallBoxForceReciprocalGPU(
ff.particles->getCUDAVars(), atomForceRec, molForceRec, particleCharge,
particleMol, particleHasNoCharge, particleUsed, startMol, lengthMol,
ff.alpha[box], ff.alphaSq[box], constValue, imageSizeRef[box],
molCoords, currentAxes, box);
constValue, imageSizeRef[box], molCoords, currentAxes, box);
delete[] particleUsed;
#else
// molecule iterator
Expand Down
7 changes: 4 additions & 3 deletions src/FFParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ void FFParticle::Init(ff_setup::Particle const &mie,
double diElectric_1 = 1.0 / forcefield.dielectric;
InitGPUForceField(*varCUDA, sigmaSq, epsilon_cn, n, forcefield.vdwKind,
forcefield.isMartini, count, forcefield.rCut,
forcefield.rCutCoulomb, forcefield.rCutLow,
forcefield.rswitch, forcefield.alpha, forcefield.ewald,
diElectric_1);
forcefield.rCutSq, forcefield.rCutCoulomb,
forcefield.rCutCoulombSq, forcefield.rCutLow,
forcefield.rswitch, forcefield.alpha, forcefield.alphaSq,
forcefield.ewald, diElectric_1);
#endif
}

Expand Down
Loading

0 comments on commit 88fd6a2

Please sign in to comment.