gcc flags changed
This commit is contained in:
parent
4c27b3c774
commit
763c84739f
3 changed files with 526 additions and 538 deletions
2
Makefile
2
Makefile
|
|
@ -6,7 +6,7 @@ ts := $(shell /usr/bin/date "+%d-%m__%H_%M_%S")
|
|||
.DEFAULT_GOAL = MD
|
||||
|
||||
MD: $(SRC)/MD.cpp
|
||||
$(CC) $(CFLAGS) $(SRC)MD.cpp -lm -O2 -ftree-vectorize -funroll-loops -pg -g -o ./out/MD
|
||||
$(CC) $(CFLAGS) $(SRC)MD.cpp -lm -march=native -mavx -O2 -ftree-vectorize -funroll-loops -pg -g -o ./out/MD
|
||||
|
||||
MDorig: $(SRC)/MD-original.cpp
|
||||
$(CC) $(CFLAGS) $(SRC)MD-original.cpp -lm -O2 -pg -o ./out/MD-original
|
||||
|
|
|
|||
BIN
out/MD
BIN
out/MD
Binary file not shown.
54
src/MD.cpp
54
src/MD.cpp
|
|
@ -85,8 +85,7 @@ double MeanSquaredVelocity ();
|
|||
// Compute total kinetic energy from particle mass and velocities
|
||||
double Kinetic();
|
||||
|
||||
int
|
||||
main () {
|
||||
int main() {
|
||||
|
||||
// variable delcarations
|
||||
int i;
|
||||
|
|
@ -246,7 +245,8 @@ main () {
|
|||
// Files that we can write different quantities to
|
||||
tfp = fopen(tfn, "w"); // The MD trajectory, coordinates of every
|
||||
// particle at each timestep
|
||||
ofp = fopen (ofn,
|
||||
ofp = fopen(
|
||||
ofn,
|
||||
"w"); // Output of other quantities (T, P, gc, etc) at every timestep
|
||||
afp = fopen(afn, "w"); // Average T, P, gc, etc from the simulation
|
||||
|
||||
|
|
@ -286,7 +286,8 @@ main () {
|
|||
Tavg = 0;
|
||||
|
||||
int tenp = floor(NumTime / 10);
|
||||
fprintf (ofp, " time (s) T(t) (K) P(t) (Pa) "
|
||||
fprintf(ofp,
|
||||
" time (s) T(t) (K) P(t) (Pa) "
|
||||
"Kinetic En. (n.u.) Potential En. (n.u.) Total En. (n.u.)\n");
|
||||
printf(" PERCENTAGE OF CALCULATION COMPLETE:\n [");
|
||||
for (i = 0; i < NumTime + 1; i++) {
|
||||
|
|
@ -344,8 +345,8 @@ main () {
|
|||
Tavg += Temp;
|
||||
Pavg += Press;
|
||||
|
||||
fprintf (ofp, " %8.4e %20.12f %20.12f %20.12f %20.12f %20.12f \n", i * dt * timefac,
|
||||
Temp, Press, KE, PE, KE + PE);
|
||||
fprintf(ofp, " %8.4e %20.12f %20.12f %20.12f %20.12f %20.12f \n",
|
||||
i * dt * timefac, Temp, Press, KE, PE, KE + PE);
|
||||
}
|
||||
|
||||
// Because we have calculated the instantaneous temperature and pressure,
|
||||
|
|
@ -356,7 +357,8 @@ main () {
|
|||
gc = NA * Pavg * (Vol * VolFac) / (N * Tavg);
|
||||
fprintf(afp, " Total Time (s) T (K) P (Pa) PV/nT "
|
||||
"(J/(mol K)) Z V (m^3) N\n");
|
||||
fprintf (afp, " -------------- ----------- --------------- "
|
||||
fprintf(afp,
|
||||
" -------------- ----------- --------------- "
|
||||
"-------------- --------------- ------------ -----------\n");
|
||||
fprintf(afp,
|
||||
" %8.4e %15.5f %15.5f %10.5f %10.5f %10.5e "
|
||||
|
|
@ -379,7 +381,8 @@ main () {
|
|||
printf("\n PERCENT ERROR of pV/nT AND GAS CONSTANT: %15.5f\n",
|
||||
100 * fabs(gc - 8.3144598) / 8.3144598);
|
||||
printf("\n THE COMPRESSIBILITY (unitless): %15.5f \n", Z);
|
||||
printf ("\n TOTAL VOLUME (m^3): %10.5e \n", Vol * VolFac);
|
||||
printf("\n TOTAL VOLUME (m^3): %10.5e \n",
|
||||
Vol * VolFac);
|
||||
printf("\n NUMBER OF PARTICLES (unitless): %i \n", N);
|
||||
|
||||
fclose(tfp);
|
||||
|
|
@ -389,8 +392,7 @@ main () {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
initialize () {
|
||||
void initialize() {
|
||||
int n, p, i, j, k;
|
||||
double pos;
|
||||
|
||||
|
|
@ -434,8 +436,7 @@ initialize () {
|
|||
}
|
||||
|
||||
// Function to calculate the averaged velocity squared
|
||||
double
|
||||
MeanSquaredVelocity () {
|
||||
double MeanSquaredVelocity() {
|
||||
|
||||
double vx2 = 0;
|
||||
double vy2 = 0;
|
||||
|
|
@ -455,8 +456,7 @@ MeanSquaredVelocity () {
|
|||
}
|
||||
|
||||
// Function to calculate the kinetic energy of the system
|
||||
double
|
||||
Kinetic () { // Write Function here!
|
||||
double Kinetic() { // Write Function here!
|
||||
|
||||
double v2, kin;
|
||||
|
||||
|
|
@ -475,12 +475,6 @@ Kinetic () { // Write Function here!
|
|||
return kin;
|
||||
}
|
||||
|
||||
double
|
||||
getF (double dist) {}
|
||||
|
||||
double
|
||||
getLocalPot (double dist) {}
|
||||
|
||||
// void
|
||||
// transposeMatrix (double mat[MAXPART][3], double matT[3][MAXPART]) {
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
|
|
@ -490,8 +484,7 @@ getLocalPot (double dist) {}
|
|||
// }
|
||||
// }
|
||||
|
||||
double
|
||||
PotentialAndAcceleration () {
|
||||
double PotentialAndAcceleration() {
|
||||
memset(a, 0, sizeof(a));
|
||||
double Pot = 0.;
|
||||
// double rT[3][MAXPART];
|
||||
|
|
@ -521,7 +514,7 @@ PotentialAndAcceleration () {
|
|||
double distSqd = dist * dist;
|
||||
double rSqd_inv4 = 1.0 / (distSqd * distSqd);
|
||||
double rSqd_inv7 = rSqd_inv4 / (distSqd * dist);
|
||||
double f = 24.0 * (2.0 * rSqd_inv7 - rSqd_inv4);
|
||||
double f = 48.0 * rSqd_inv7 - 24 * rSqd_inv4;
|
||||
// from F = ma, where m = 1 in natural units!
|
||||
for (int k = 0; k < 3; k++) {
|
||||
double tmp = posItoJ[k] * f;
|
||||
|
|
@ -534,8 +527,7 @@ PotentialAndAcceleration () {
|
|||
}
|
||||
|
||||
// Function to calculate the potential energy of the system
|
||||
double
|
||||
Potential () {
|
||||
double Potential() {
|
||||
double quot, r2, rnorm, term1, term2, Pot;
|
||||
int i, j;
|
||||
|
||||
|
|
@ -564,8 +556,7 @@ Potential () {
|
|||
// Uses the derivative of the Lennard-Jones potential to calculate
|
||||
// the forces on each atom. Then uses a = F/m to calculate the
|
||||
// accelleration of each atom.
|
||||
void
|
||||
computeAccelerations () {
|
||||
void computeAccelerations() {
|
||||
int i, j, k;
|
||||
double f, rSqd, tmp = 0.;
|
||||
double rij[3]; // position of i relative to j
|
||||
|
|
@ -600,8 +591,7 @@ computeAccelerations () {
|
|||
}
|
||||
|
||||
// returns sum of dv/dt*m/A (aka Pressure) from elastic collisions with walls
|
||||
double
|
||||
VelocityVerlet (double dt, int iter, double *PE, FILE *fp) {
|
||||
double VelocityVerlet(double dt, int iter, double *PE, FILE *fp) {
|
||||
int i, j, k;
|
||||
|
||||
double psum = 0.;
|
||||
|
|
@ -658,8 +648,7 @@ VelocityVerlet (double dt, int iter, double *PE, FILE *fp) {
|
|||
return psum / (6 * L * L);
|
||||
}
|
||||
|
||||
void
|
||||
initializeVelocities () {
|
||||
void initializeVelocities() {
|
||||
|
||||
int i, j;
|
||||
|
||||
|
|
@ -718,8 +707,7 @@ initializeVelocities () {
|
|||
}
|
||||
|
||||
// Numerical recipes Gaussian distribution number generator
|
||||
double
|
||||
gaussdist () {
|
||||
double gaussdist() {
|
||||
static bool available = false;
|
||||
static double gset;
|
||||
double fac, rsq, v1, v2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue