Add DEM kernel to parameter options
Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
parent
79483a446e
commit
9ffc09f497
@ -32,7 +32,7 @@
|
|||||||
// TODO: Joint common files for gromacs and lammps variants
|
// TODO: Joint common files for gromacs and lammps variants
|
||||||
#include "../gromacs/includes/simd.h"
|
#include "../gromacs/includes/simd.h"
|
||||||
|
|
||||||
double computeForceDEMFullNeigh_plain_c(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
double computeForceDemFullNeigh(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
||||||
int Nlocal = atom->Nlocal;
|
int Nlocal = atom->Nlocal;
|
||||||
int* neighs;
|
int* neighs;
|
||||||
MD_FLOAT k_s = param->k_s;
|
MD_FLOAT k_s = param->k_s;
|
||||||
@ -153,7 +153,7 @@ double computeForceDEMFullNeigh_plain_c(Parameter *param, Atom *atom, Neighbor *
|
|||||||
return E-S;
|
return E-S;
|
||||||
}
|
}
|
||||||
|
|
||||||
double computeForceDEMHalfNeigh(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
double computeForceDemHalfNeigh(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
||||||
int Nlocal = atom->Nlocal;
|
int Nlocal = atom->Nlocal;
|
||||||
int* neighs;
|
int* neighs;
|
||||||
#ifndef EXPLICIT_TYPES
|
#ifndef EXPLICIT_TYPES
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#define FF_LJ 0
|
#define FF_LJ 0
|
||||||
#define FF_EAM 1
|
#define FF_EAM 1
|
||||||
|
#define FF_DEM 2
|
||||||
|
|
||||||
extern double myrandom(int*);
|
extern double myrandom(int*);
|
||||||
extern void random_reset(int *seed, int ibase, double *coord);
|
extern void random_reset(int *seed, int ibase, double *coord);
|
||||||
|
@ -49,6 +49,8 @@ extern double computeForceLJFullNeigh_plain_c(Parameter*, Atom*, Neighbor*, Stat
|
|||||||
extern double computeForceLJFullNeigh_simd(Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceLJFullNeigh_simd(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
extern double computeForceLJHalfNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceLJHalfNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
extern double computeForceEam(Eam*, Parameter*, Atom*, Neighbor*, Stats*);
|
extern double computeForceEam(Eam*, Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
|
extern double computeForceDemFullNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
|
extern double computeForceDemHalfNeigh(Parameter*, Atom*, Neighbor*, Stats*);
|
||||||
|
|
||||||
#ifdef USE_SIMD_KERNEL
|
#ifdef USE_SIMD_KERNEL
|
||||||
# define KERNEL_NAME "SIMD"
|
# define KERNEL_NAME "SIMD"
|
||||||
@ -121,14 +123,29 @@ void finalIntegrate(Parameter *param, Atom *atom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printAtomState(Atom *atom) {
|
void printAtomState(Atom *atom) {
|
||||||
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n",
|
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n", atom->Natoms, atom->Nlocal, atom->Nghost, atom->Nmax);
|
||||||
atom->Natoms, atom->Nlocal, atom->Nghost, atom->Nmax);
|
// int nall = atom->Nlocal + atom->Nghost;
|
||||||
|
// for (int i=0; i<nall; i++) {
|
||||||
|
// printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
/* int nall = atom->Nlocal + atom->Nghost; */
|
double computeForce(Eam *eam, Parameter *param, Atom *atom, Neighbor *neighbor, Stats *stats) {
|
||||||
|
if(param->force_field == FF_EAM) {
|
||||||
|
return computeForceEam(eam, param, atom, neighbor, stats);
|
||||||
|
} else if(param->force_field == FF_DEM) {
|
||||||
|
if(param->half_neigh) {
|
||||||
|
return computeForceDemHalfNeigh(param, atom, neighbor, stats);
|
||||||
|
} else {
|
||||||
|
return computeForceDemFullNeigh(param, atom, neighbor, stats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* for (int i=0; i<nall; i++) { */
|
if(param->half_neigh) {
|
||||||
/* printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]); */
|
return computeForceLJHalfNeigh(param, atom, neighbor, stats);
|
||||||
/* } */
|
}
|
||||||
|
|
||||||
|
return computeForceLJFullNeigh(param, atom, neighbor, stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
@ -208,7 +225,7 @@ int main(int argc, char** argv) {
|
|||||||
printf("MD Bench: A minimalistic re-implementation of miniMD\n");
|
printf("MD Bench: A minimalistic re-implementation of miniMD\n");
|
||||||
printf(HLINE);
|
printf(HLINE);
|
||||||
printf("-p <string>: file to read parameters from (can be specified more than once)\n");
|
printf("-p <string>: file to read parameters from (can be specified more than once)\n");
|
||||||
printf("-f <string>: force field (lj or eam), default lj\n");
|
printf("-f <string>: force field (lj, eam or dem), default lj\n");
|
||||||
printf("-i <string>: input file with atom positions (dump)\n");
|
printf("-i <string>: input file with atom positions (dump)\n");
|
||||||
printf("-e <string>: input file for EAM\n");
|
printf("-e <string>: input file for EAM\n");
|
||||||
printf("-n / --nsteps <int>: set number of timesteps for simulation\n");
|
printf("-n / --nsteps <int>: set number of timesteps for simulation\n");
|
||||||
@ -231,16 +248,8 @@ int main(int argc, char** argv) {
|
|||||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER)
|
#if defined(MEM_TRACER) || defined(INDEX_TRACER)
|
||||||
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
||||||
#endif
|
#endif
|
||||||
if(param.force_field == FF_EAM) {
|
|
||||||
timer[FORCE] = computeForceEam(&eam, ¶m, &atom, &neighbor, &stats);
|
|
||||||
} else {
|
|
||||||
if(param.half_neigh) {
|
|
||||||
timer[FORCE] = computeForceLJHalfNeigh(¶m, &atom, &neighbor, &stats);
|
|
||||||
} else {
|
|
||||||
timer[FORCE] = computeForceLJFullNeigh(¶m, &atom, &neighbor, &stats);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
timer[FORCE] = computeForce(&eam, ¶m, &atom, &neighbor, &stats);
|
||||||
timer[NEIGH] = 0.0;
|
timer[NEIGH] = 0.0;
|
||||||
timer[TOTAL] = getTimeStamp();
|
timer[TOTAL] = getTimeStamp();
|
||||||
|
|
||||||
@ -250,7 +259,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
for(int n = 0; n < param.ntimes; n++) {
|
for(int n = 0; n < param.ntimes; n++) {
|
||||||
initialIntegrate(¶m, &atom);
|
initialIntegrate(¶m, &atom);
|
||||||
|
|
||||||
if((n + 1) % param.reneigh_every) {
|
if((n + 1) % param.reneigh_every) {
|
||||||
updatePbc(&atom, ¶m);
|
updatePbc(&atom, ¶m);
|
||||||
} else {
|
} else {
|
||||||
@ -261,16 +269,7 @@ int main(int argc, char** argv) {
|
|||||||
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
traceAddresses(¶m, &atom, &neighbor, n + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(param.force_field == FF_EAM) {
|
timer[FORCE] += computeForce(&eam, ¶m, &atom, &neighbor, &stats);
|
||||||
timer[FORCE] += computeForceEam(&eam, ¶m, &atom, &neighbor, &stats);
|
|
||||||
} else {
|
|
||||||
if(param.half_neigh) {
|
|
||||||
timer[FORCE] += computeForceLJHalfNeigh(¶m, &atom, &neighbor, &stats);
|
|
||||||
} else {
|
|
||||||
timer[FORCE] += computeForceLJFullNeigh(¶m, &atom, &neighbor, &stats);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalIntegrate(¶m, &atom);
|
finalIntegrate(¶m, &atom);
|
||||||
|
|
||||||
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
||||||
|
@ -84,6 +84,7 @@ int str2ff(const char *string)
|
|||||||
{
|
{
|
||||||
if(strncmp(string, "lj", 2) == 0) return FF_LJ;
|
if(strncmp(string, "lj", 2) == 0) return FF_LJ;
|
||||||
if(strncmp(string, "eam", 3) == 0) return FF_EAM;
|
if(strncmp(string, "eam", 3) == 0) return FF_EAM;
|
||||||
|
if(strncmp(string, "dem", 3) == 0) return FF_DEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,5 +92,6 @@ const char* ff2str(int ff)
|
|||||||
{
|
{
|
||||||
if(ff == FF_LJ) { return "lj"; }
|
if(ff == FF_LJ) { return "lj"; }
|
||||||
if(ff == FF_EAM) { return "eam"; }
|
if(ff == FF_EAM) { return "eam"; }
|
||||||
|
if(ff == FF_DEM) { return "dem"; }
|
||||||
return "invalid";
|
return "invalid";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user