Skip to content

Commit

Permalink
Update to incorporate latest Development branch patches
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed Jan 28, 2025
2 parents e834a57 + c7a79c5 commit f50f4ef
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
63 changes: 30 additions & 33 deletions lib/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,44 +104,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 @@ -174,26 +168,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 @@ -214,6 +208,9 @@ struct XYZ {
m = z;
return m;
}

public:
double x, y, z;
};

inline std::ostream &operator<<(std::ostream &stream, const XYZ &p) {
Expand Down
2 changes: 1 addition & 1 deletion 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
9 changes: 4 additions & 5 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ int main(int argc, char *argv[]) {
#if defined _OPENMP && _OPENMP < 201511
printf("Warning: OpenMP version < 4.5. GOMC will not run optimally!\n");
#endif
// Print OpenMP version if recognized or OpenMP date code if not recognized.
// Print the OpenMP version if recognized or instead the OpenMP date code.
#ifdef _OPENMP
std::unordered_map<int, std::string> omp_map{
{200505, "2.5"}, {200805, "3.0"}, {201107, "3.1"},
{201307, "4.0"}, {201511, "4.5"}, {201611, "5.0 Preview 1"},
{201811, "5.0"}, {202011, "5.1"}, {202111, "5.2"},
{202411, "6.0"}};
{200505, "2.5"}, {200805, "3.0"}, {201107, "3.1"}, {201307, "4.0"},
{201511, "4.5"}, {201611, "5.0 Preview 1"}, {201811, "5.0"},
{202011, "5.1"}, {202111, "5.2"}, {202411, "6.0"}};
auto match = omp_map.find(_OPENMP);
if (match == omp_map.end())
printf("%-40s %u\n", "Info: Compiled with OpenMP Version", _OPENMP);
Expand Down
8 changes: 8 additions & 0 deletions src/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ Simulation::~Simulation() {
void Simulation::RunSimulation(void) {
GOMC_EVENT_START(1, GomcProfileEvent::MC_RUN);
double startEnergy = system->potential.totalEnergy.total;
if (!std::isfinite(startEnergy)) {
std::cout
<< "Initial system has non-finite energy. This is usually caused"
" by two or more atoms in the initial configuration having "
"identical coordinates. Please correct your input file and rerun.\n";

exit(EXIT_FAILURE);
}
if (totalSteps == 0) {
for (int i = 0; i < (int)frameSteps.size(); i++) {
if (i == 0) {
Expand Down

0 comments on commit f50f4ef

Please sign in to comment.