apply clang-format to packages

This commit is contained in:
Axel Kohlmeyer
2021-08-23 21:05:48 -04:00
parent 686f41731f
commit 9a19a814e4
97 changed files with 2029 additions and 2038 deletions

View File

@ -49,7 +49,8 @@ AtomVecOxdna::AtomVecOxdna(LAMMPS *lmp) : AtomVec(lmp)
setup_fields(); setup_fields();
if(!force->newton_bond) error->warning(FLERR,"Write_data command requires newton on to preserve 3'->5' bond polarity"); if (!force->newton_bond)
error->warning(FLERR, "Write_data command requires newton on to preserve 3'->5' bond polarity");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -17,12 +17,12 @@
#include "bond_oxdna_fene.h" #include "bond_oxdna_fene.h"
#include "atom.h" #include "atom.h"
#include "neighbor.h"
#include "comm.h" #include "comm.h"
#include "update.h" #include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "neighbor.h"
#include "update.h"
#include "atom_vec_ellipsoid.h" #include "atom_vec_ellipsoid.h"
#include "math_extra.h" #include "math_extra.h"
@ -43,54 +43,52 @@ BondOxdnaFene::~BondOxdnaFene()
} }
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
compute vector COM-sugar-phosphate backbone interaction site in oxDNA compute vector COM-sugar-phosphate backbone interaction site in oxDNA
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void BondOxdnaFene::compute_interaction_sites(double e1[3], double /*e2*/[3], void BondOxdnaFene::compute_interaction_sites(double e1[3], double /*e2*/[3], double /*e3*/[3],
double /*e3*/[3], double r[3]) const double r[3]) const
{ {
constexpr double d_cs=-0.4; constexpr double d_cs = -0.4;
r[0] = d_cs*e1[0]; r[0] = d_cs * e1[0];
r[1] = d_cs*e1[1]; r[1] = d_cs * e1[1];
r[2] = d_cs*e1[2]; r[2] = d_cs * e1[2];
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
tally energy and virial into global and per-atom accumulators tally energy and virial into global and per-atom accumulators
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void BondOxdnaFene::ev_tally_xyz(int i, int j, int nlocal, int newton_bond, void BondOxdnaFene::ev_tally_xyz(int i, int j, int nlocal, int newton_bond, double ebond, double fx,
double ebond, double fy, double fz, double delx, double dely, double delz)
double fx, double fy, double fz,
double delx, double dely, double delz)
{ {
double ebondhalf,v[6]; double ebondhalf, v[6];
if (eflag_either) { if (eflag_either) {
if (eflag_global) { if (eflag_global) {
if (newton_bond) energy += ebond; if (newton_bond)
energy += ebond;
else { else {
ebondhalf = 0.5*ebond; ebondhalf = 0.5 * ebond;
if (i < nlocal) energy += ebondhalf; if (i < nlocal) energy += ebondhalf;
if (j < nlocal) energy += ebondhalf; if (j < nlocal) energy += ebondhalf;
} }
} }
if (eflag_atom) { if (eflag_atom) {
ebondhalf = 0.5*ebond; ebondhalf = 0.5 * ebond;
if (newton_bond || i < nlocal) eatom[i] += ebondhalf; if (newton_bond || i < nlocal) eatom[i] += ebondhalf;
if (newton_bond || j < nlocal) eatom[j] += ebondhalf; if (newton_bond || j < nlocal) eatom[j] += ebondhalf;
} }
} }
if (vflag_either) { if (vflag_either) {
v[0] = delx*fx; v[0] = delx * fx;
v[1] = dely*fy; v[1] = dely * fy;
v[2] = delz*fz; v[2] = delz * fz;
v[3] = delx*fy; v[3] = delx * fy;
v[4] = delx*fz; v[4] = delx * fz;
v[5] = dely*fz; v[5] = dely * fz;
if (vflag_global) { if (vflag_global) {
if (newton_bond) { if (newton_bond) {
@ -102,40 +100,40 @@ void BondOxdnaFene::ev_tally_xyz(int i, int j, int nlocal, int newton_bond,
virial[5] += v[5]; virial[5] += v[5];
} else { } else {
if (i < nlocal) { if (i < nlocal) {
virial[0] += 0.5*v[0]; virial[0] += 0.5 * v[0];
virial[1] += 0.5*v[1]; virial[1] += 0.5 * v[1];
virial[2] += 0.5*v[2]; virial[2] += 0.5 * v[2];
virial[3] += 0.5*v[3]; virial[3] += 0.5 * v[3];
virial[4] += 0.5*v[4]; virial[4] += 0.5 * v[4];
virial[5] += 0.5*v[5]; virial[5] += 0.5 * v[5];
} }
if (j < nlocal) { if (j < nlocal) {
virial[0] += 0.5*v[0]; virial[0] += 0.5 * v[0];
virial[1] += 0.5*v[1]; virial[1] += 0.5 * v[1];
virial[2] += 0.5*v[2]; virial[2] += 0.5 * v[2];
virial[3] += 0.5*v[3]; virial[3] += 0.5 * v[3];
virial[4] += 0.5*v[4]; virial[4] += 0.5 * v[4];
virial[5] += 0.5*v[5]; virial[5] += 0.5 * v[5];
} }
} }
} }
if (vflag_atom) { if (vflag_atom) {
if (newton_bond || i < nlocal) { if (newton_bond || i < nlocal) {
vatom[i][0] += 0.5*v[0]; vatom[i][0] += 0.5 * v[0];
vatom[i][1] += 0.5*v[1]; vatom[i][1] += 0.5 * v[1];
vatom[i][2] += 0.5*v[2]; vatom[i][2] += 0.5 * v[2];
vatom[i][3] += 0.5*v[3]; vatom[i][3] += 0.5 * v[3];
vatom[i][4] += 0.5*v[4]; vatom[i][4] += 0.5 * v[4];
vatom[i][5] += 0.5*v[5]; vatom[i][5] += 0.5 * v[5];
} }
if (newton_bond || j < nlocal) { if (newton_bond || j < nlocal) {
vatom[j][0] += 0.5*v[0]; vatom[j][0] += 0.5 * v[0];
vatom[j][1] += 0.5*v[1]; vatom[j][1] += 0.5 * v[1];
vatom[j][2] += 0.5*v[2]; vatom[j][2] += 0.5 * v[2];
vatom[j][3] += 0.5*v[3]; vatom[j][3] += 0.5 * v[3];
vatom[j][4] += 0.5*v[4]; vatom[j][4] += 0.5 * v[4];
vatom[j][5] += 0.5*v[5]; vatom[j][5] += 0.5 * v[5];
} }
} }
} }
@ -147,16 +145,16 @@ void BondOxdnaFene::ev_tally_xyz(int i, int j, int nlocal, int newton_bond,
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void BondOxdnaFene::compute(int eflag, int vflag) void BondOxdnaFene::compute(int eflag, int vflag)
{ {
int a,b,in,type; int a, b, in, type;
double delf[3],delta[3],deltb[3]; // force, torque increment;; double delf[3], delta[3], deltb[3]; // force, torque increment;;
double delr[3],ebond,fbond; double delr[3], ebond, fbond;
double rsq,Deltasq,rlogarg; double rsq, Deltasq, rlogarg;
double r,rr0,rr0sq; double r, rr0, rr0sq;
// vectors COM-backbone site in lab frame // vectors COM-backbone site in lab frame
double ra_cs[3],rb_cs[3]; double ra_cs[3], rb_cs[3];
double *qa,ax[3],ay[3],az[3]; double *qa, ax[3], ay[3], az[3];
double *qb,bx[3],by[3],bz[3]; double *qb, bx[3], by[3], bz[3];
double **x = atom->x; double **x = atom->x;
double **f = atom->f; double **f = atom->f;
@ -172,7 +170,7 @@ void BondOxdnaFene::compute(int eflag, int vflag)
int newton_bond = force->newton_bond; int newton_bond = force->newton_bond;
ebond = 0.0; ebond = 0.0;
ev_init(eflag,vflag); ev_init(eflag, vflag);
// loop over FENE bonds // loop over FENE bonds
@ -182,47 +180,45 @@ void BondOxdnaFene::compute(int eflag, int vflag)
b = bondlist[in][0]; b = bondlist[in][0];
type = bondlist[in][2]; type = bondlist[in][2];
qa=bonus[ellipsoid[a]].quat; qa = bonus[ellipsoid[a]].quat;
MathExtra::q_to_exyz(qa,ax,ay,az); MathExtra::q_to_exyz(qa, ax, ay, az);
qb=bonus[ellipsoid[b]].quat; qb = bonus[ellipsoid[b]].quat;
MathExtra::q_to_exyz(qb,bx,by,bz); MathExtra::q_to_exyz(qb, bx, by, bz);
// vector COM-backbone site a and b // vector COM-backbone site a and b
compute_interaction_sites(ax,ay,az,ra_cs); compute_interaction_sites(ax, ay, az, ra_cs);
compute_interaction_sites(bx,by,bz,rb_cs); compute_interaction_sites(bx, by, bz, rb_cs);
// vector backbone site b to a // vector backbone site b to a
delr[0] = x[a][0] + ra_cs[0] - x[b][0] - rb_cs[0]; delr[0] = x[a][0] + ra_cs[0] - x[b][0] - rb_cs[0];
delr[1] = x[a][1] + ra_cs[1] - x[b][1] - rb_cs[1]; delr[1] = x[a][1] + ra_cs[1] - x[b][1] - rb_cs[1];
delr[2] = x[a][2] + ra_cs[2] - x[b][2] - rb_cs[2]; delr[2] = x[a][2] + ra_cs[2] - x[b][2] - rb_cs[2];
rsq = delr[0]*delr[0] + delr[1]*delr[1] + delr[2]*delr[2]; rsq = delr[0] * delr[0] + delr[1] * delr[1] + delr[2] * delr[2];
r = sqrt(rsq); r = sqrt(rsq);
rr0 = r - r0[type]; rr0 = r - r0[type];
rr0sq = rr0*rr0; rr0sq = rr0 * rr0;
Deltasq = Delta[type] * Delta[type]; Deltasq = Delta[type] * Delta[type];
rlogarg = 1.0 - rr0sq/Deltasq; rlogarg = 1.0 - rr0sq / Deltasq;
// if r -> Delta, then rlogarg < 0.0 which is an error // if r -> Delta, then rlogarg < 0.0 which is an error
// issue a warning and reset rlogarg = epsilon // issue a warning and reset rlogarg = epsilon
// if r > 2*Delta something serious is wrong, abort // if r > 2*Delta something serious is wrong, abort
if (rlogarg < 0.1) { if (rlogarg < 0.1) {
error->warning(FLERR,"FENE bond too long: {} {} {} {}", error->warning(FLERR, "FENE bond too long: {} {} {} {}", update->ntimestep, atom->tag[a],
update->ntimestep,atom->tag[a],atom->tag[b],r); atom->tag[b], r);
rlogarg = 0.1; rlogarg = 0.1;
} }
fbond = -k[type]*rr0/rlogarg/Deltasq/r; fbond = -k[type] * rr0 / rlogarg / Deltasq / r;
delf[0] = delr[0]*fbond; delf[0] = delr[0] * fbond;
delf[1] = delr[1]*fbond; delf[1] = delr[1] * fbond;
delf[2] = delr[2]*fbond; delf[2] = delr[2] * fbond;
// energy // energy
if (eflag) { if (eflag) { ebond = -0.5 * k[type] * log(rlogarg); }
ebond = -0.5 * k[type]*log(rlogarg);
}
// apply force and torque to each of 2 atoms // apply force and torque to each of 2 atoms
@ -232,12 +228,11 @@ void BondOxdnaFene::compute(int eflag, int vflag)
f[a][1] += delf[1]; f[a][1] += delf[1];
f[a][2] += delf[2]; f[a][2] += delf[2];
MathExtra::cross3(ra_cs,delf,delta); MathExtra::cross3(ra_cs, delf, delta);
torque[a][0] += delta[0]; torque[a][0] += delta[0];
torque[a][1] += delta[1]; torque[a][1] += delta[1];
torque[a][2] += delta[2]; torque[a][2] += delta[2];
} }
if (newton_bond || b < nlocal) { if (newton_bond || b < nlocal) {
@ -246,23 +241,21 @@ void BondOxdnaFene::compute(int eflag, int vflag)
f[b][1] -= delf[1]; f[b][1] -= delf[1];
f[b][2] -= delf[2]; f[b][2] -= delf[2];
MathExtra::cross3(rb_cs,delf,deltb); MathExtra::cross3(rb_cs, delf, deltb);
torque[b][0] -= deltb[0]; torque[b][0] -= deltb[0];
torque[b][1] -= deltb[1]; torque[b][1] -= deltb[1];
torque[b][2] -= deltb[2]; torque[b][2] -= deltb[2];
} }
// increment energy and virial // increment energy and virial
// NOTE: The virial is calculated on the 'molecular' basis. // NOTE: The virial is calculated on the 'molecular' basis.
// (see G. Ciccotti and J.P. Ryckaert, Comp. Phys. Rep. 4, 345-392 (1986)) // (see G. Ciccotti and J.P. Ryckaert, Comp. Phys. Rep. 4, 345-392 (1986))
if (evflag) ev_tally_xyz(a,b,nlocal,newton_bond,ebond, if (evflag)
delf[0],delf[1],delf[2],x[a][0]-x[b][0],x[a][1]-x[b][1],x[a][2]-x[b][2]); ev_tally_xyz(a, b, nlocal, newton_bond, ebond, delf[0], delf[1], delf[2], x[a][0] - x[b][0],
x[a][1] - x[b][1], x[a][2] - x[b][2]);
} }
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -272,13 +265,12 @@ void BondOxdnaFene::allocate()
allocated = 1; allocated = 1;
int n = atom->nbondtypes; int n = atom->nbondtypes;
memory->create(k,n+1,"bond:k"); memory->create(k, n + 1, "bond:k");
memory->create(Delta,n+1,"bond:Delta"); memory->create(Delta, n + 1, "bond:Delta");
memory->create(r0,n+1,"bond:r0"); memory->create(r0, n + 1, "bond:r0");
memory->create(setflag,n+1,"bond:setflag"); memory->create(setflag, n + 1, "bond:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0; for (int i = 1; i <= n; i++) setflag[i] = 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -287,15 +279,15 @@ void BondOxdnaFene::allocate()
void BondOxdnaFene::coeff(int narg, char **arg) void BondOxdnaFene::coeff(int narg, char **arg)
{ {
if (narg != 4) error->all(FLERR,"Incorrect args for bond coefficients in oxdna/fene"); if (narg != 4) error->all(FLERR, "Incorrect args for bond coefficients in oxdna/fene");
if (!allocated) allocate(); if (!allocated) allocate();
int ilo,ihi; int ilo, ihi;
utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error); utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error);
double k_one = utils::numeric(FLERR,arg[1],false,lmp); double k_one = utils::numeric(FLERR, arg[1], false, lmp);
double Delta_one = utils::numeric(FLERR,arg[2],false,lmp); double Delta_one = utils::numeric(FLERR, arg[2], false, lmp);
double r0_one = utils::numeric(FLERR,arg[3],false,lmp); double r0_one = utils::numeric(FLERR, arg[3], false, lmp);
int count = 0; int count = 0;
@ -307,8 +299,7 @@ void BondOxdnaFene::coeff(int narg, char **arg)
count++; count++;
} }
if (count == 0) error->all(FLERR,"Incorrect args for bond coefficients in oxdna/fene"); if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients in oxdna/fene");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -318,7 +309,9 @@ void BondOxdnaFene::coeff(int narg, char **arg)
void BondOxdnaFene::init_style() void BondOxdnaFene::init_style()
{ {
if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0)
error->all(FLERR,"Must use 'special_bonds lj 0 1 1' with bond style oxdna/fene, oxdna2/fene or oxrna2/fene"); error->all(
FLERR,
"Must use 'special_bonds lj 0 1 1' with bond style oxdna/fene, oxdna2/fene or oxrna2/fene");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -334,9 +327,9 @@ double BondOxdnaFene::equilibrium_distance(int i)
void BondOxdnaFene::write_restart(FILE *fp) void BondOxdnaFene::write_restart(FILE *fp)
{ {
fwrite(&k[1],sizeof(double),atom->nbondtypes,fp); fwrite(&k[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Delta[1],sizeof(double),atom->nbondtypes,fp); fwrite(&Delta[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&r0[1],sizeof(double),atom->nbondtypes,fp); fwrite(&r0[1], sizeof(double), atom->nbondtypes, fp);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -348,13 +341,13 @@ void BondOxdnaFene::read_restart(FILE *fp)
allocate(); allocate();
if (comm->me == 0) { if (comm->me == 0) {
utils::sfread(FLERR,&k[1],sizeof(double),atom->nbondtypes,fp,nullptr,error); utils::sfread(FLERR, &k[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR,&Delta[1],sizeof(double),atom->nbondtypes,fp,nullptr,error); utils::sfread(FLERR, &Delta[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR,&r0[1],sizeof(double),atom->nbondtypes,fp,nullptr,error); utils::sfread(FLERR, &r0[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
} }
MPI_Bcast(&k[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&k[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Delta[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&Delta[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&r0[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&r0[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1; for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1;
} }
@ -366,32 +359,30 @@ void BondOxdnaFene::read_restart(FILE *fp)
void BondOxdnaFene::write_data(FILE *fp) void BondOxdnaFene::write_data(FILE *fp)
{ {
for (int i = 1; i <= atom->nbondtypes; i++) for (int i = 1; i <= atom->nbondtypes; i++)
fprintf(fp,"%d %g %g %g\n",i,k[i],r0[i],Delta[i]); fprintf(fp, "%d %g %g %g\n", i, k[i], r0[i], Delta[i]);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double BondOxdnaFene::single(int type, double rsq, int /*i*/, int /*j*/, double BondOxdnaFene::single(int type, double rsq, int /*i*/, int /*j*/, double &fforce)
double &fforce)
{ {
double r = sqrt(rsq); double r = sqrt(rsq);
double rr0 = r - r0[type]; double rr0 = r - r0[type];
double rr0sq = rr0*rr0; double rr0sq = rr0 * rr0;
double Deltasq = Delta[type] * Delta[type]; double Deltasq = Delta[type] * Delta[type];
double rlogarg = 1.0 - rr0sq/Deltasq; double rlogarg = 1.0 - rr0sq / Deltasq;
// if r -> Delta, then rlogarg < 0.0 which is an error // if r -> Delta, then rlogarg < 0.0 which is an error
// issue a warning and reset rlogarg = epsilon // issue a warning and reset rlogarg = epsilon
// if r > 2*Delta something serious is wrong, abort // if r > 2*Delta something serious is wrong, abort
if (rlogarg < 0.1) { if (rlogarg < 0.1) {
error->warning(FLERR,"FENE bond too long: {} {:.8}", error->warning(FLERR, "FENE bond too long: {} {:.8}", update->ntimestep, sqrt(rsq));
update->ntimestep,sqrt(rsq));
rlogarg = 0.1; rlogarg = 0.1;
} }
double eng = -0.5 * k[type]*log(rlogarg); double eng = -0.5 * k[type] * log(rlogarg);
fforce = -k[type]*rr0/rlogarg/Deltasq/r; fforce = -k[type] * rr0 / rlogarg / Deltasq / r;
return eng; return eng;
} }

View File

@ -29,7 +29,6 @@
#error must have at least zstd version 1.4 to compile with -DLAMMPS_ZSTD #error must have at least zstd version 1.4 to compile with -DLAMMPS_ZSTD
#endif #endif
namespace LAMMPS_NS { namespace LAMMPS_NS {
class ZstdFileWriter : public FileWriter { class ZstdFileWriter : public FileWriter {

View File

@ -431,7 +431,7 @@ void FixPolarizeBEMGMRES::gmres_solve(double *x, double *r)
// fill up h with zero // fill up h with zero
memset(h, 0, (size_t)(mr + 1) * mr * sizeof(double)); memset(h, 0, (size_t) (mr + 1) * mr * sizeof(double));
// the inner loop k = 1..(n-1) // the inner loop k = 1..(n-1)
// build up the k-th Krylov space, // build up the k-th Krylov space,
@ -524,7 +524,7 @@ void FixPolarizeBEMGMRES::gmres_solve(double *x, double *r)
#ifdef _POLARIZE_DEBUG #ifdef _POLARIZE_DEBUG
if (comm->me == 0) if (comm->me == 0)
error->warning(FLERR,"itr = {}: k = {}, norm(r) = {} norm(b) = {}", itr, k, rho, normb); error->warning(FLERR, "itr = {}: k = {}, norm(r) = {} norm(b) = {}", itr, k, rho, normb);
#endif #endif
if (rho <= rho_tol && rho <= tol_abs) break; if (rho <= rho_tol && rho <= tol_abs) break;
} }
@ -742,17 +742,17 @@ double FixPolarizeBEMGMRES::vec_dot(const double *a1, const double *a2, int n)
double FixPolarizeBEMGMRES::memory_usage() double FixPolarizeBEMGMRES::memory_usage()
{ {
double bytes = 0; double bytes = 0;
bytes += mat_dim * sizeof(double); // induced_charges bytes += mat_dim * sizeof(double); // induced_charges
bytes += mat_dim * sizeof(double); // buffer bytes += mat_dim * sizeof(double); // buffer
bytes += mat_dim * sizeof(double); // rhs bytes += mat_dim * sizeof(double); // rhs
bytes += atom->nmax * sizeof(double); // induced_charge_idx bytes += atom->nmax * sizeof(double); // induced_charge_idx
bytes += atom->nmax * sizeof(double); // q_backup bytes += atom->nmax * sizeof(double); // q_backup
bytes += mr * sizeof(double); // c bytes += mr * sizeof(double); // c
bytes += (mr + 1) * sizeof(double); // g bytes += (mr + 1) * sizeof(double); // g
bytes += (double) (mr + 1) * mr * sizeof(double); // h bytes += (double) (mr + 1) * mr * sizeof(double); // h
bytes += mat_dim * sizeof(double); // r bytes += mat_dim * sizeof(double); // r
bytes += (double) mr * (mr + 1) * sizeof(double); // s bytes += (double) mr * (mr + 1) * sizeof(double); // s
bytes += mat_dim * sizeof(double); // v bytes += mat_dim * sizeof(double); // v
bytes += (double) (mr + 1) * mr * sizeof(double); // y bytes += (double) (mr + 1) * mr * sizeof(double); // y
return bytes; return bytes;
} }
@ -868,7 +868,8 @@ void FixPolarizeBEMGMRES::set_arrays(int i)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixPolarizeBEMGMRES::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) int FixPolarizeBEMGMRES::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
int * /*pbc*/)
{ {
int m; int m;
for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; for (m = 0; m < n; m++) buf[m] = atom->q[list[m]];

View File

@ -396,7 +396,8 @@ int FixPolarizeBEMICC::modify_param(int narg, char **arg)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixPolarizeBEMICC::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) int FixPolarizeBEMICC::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
int * /*pbc*/)
{ {
int m; int m;
for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; for (m = 0; m < n; m++) buf[m] = atom->q[list[m]];

View File

@ -538,7 +538,8 @@ int FixPolarizeFunctional::unpack_exchange(int nlocal, double *buf)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixPolarizeFunctional::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) int FixPolarizeFunctional::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
int * /*pbc*/)
{ {
int m; int m;
for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; for (m = 0; m < n; m++) buf[m] = atom->q[list[m]];
@ -591,21 +592,21 @@ void FixPolarizeFunctional::set_arrays(int i)
double FixPolarizeFunctional::memory_usage() double FixPolarizeFunctional::memory_usage()
{ {
double bytes = 0; double bytes = 0;
bytes += square(num_induced_charges) * sizeof(double); // inverse_matrix bytes += square(num_induced_charges) * sizeof(double); // inverse_matrix
bytes += square(num_induced_charges) * sizeof(double); // Rww bytes += square(num_induced_charges) * sizeof(double); // Rww
bytes += square(num_induced_charges) * sizeof(double); // G1ww bytes += square(num_induced_charges) * sizeof(double); // G1ww
bytes += square(num_induced_charges) * sizeof(double); // ndotGww bytes += square(num_induced_charges) * sizeof(double); // ndotGww
bytes += square(num_induced_charges) * sizeof(double); // G2ww bytes += square(num_induced_charges) * sizeof(double); // G2ww
bytes += square(num_induced_charges) * sizeof(double); // G3ww bytes += square(num_induced_charges) * sizeof(double); // G3ww
bytes += num_induced_charges * sizeof(double); // qiRqwVector bytes += num_induced_charges * sizeof(double); // qiRqwVector
bytes += num_induced_charges * sizeof(double); // sum2G2wq bytes += num_induced_charges * sizeof(double); // sum2G2wq
bytes += num_induced_charges * sizeof(double); // sum1G2qw bytes += num_induced_charges * sizeof(double); // sum1G2qw
bytes += num_induced_charges * sizeof(double); // sum1G1qw_epsilon bytes += num_induced_charges * sizeof(double); // sum1G1qw_epsilon
bytes += num_induced_charges * sizeof(double); // sum2ndotGwq_epsilon bytes += num_induced_charges * sizeof(double); // sum2ndotGwq_epsilon
bytes += (double)num_ions * num_induced_charges * sizeof(double); // G1qw_real bytes += (double) num_ions * num_induced_charges * sizeof(double); // G1qw_real
bytes += nmax * sizeof(int); // induced_charge_idx bytes += nmax * sizeof(int); // induced_charge_idx
bytes += nmax * sizeof(int); // ion_idx bytes += nmax * sizeof(int); // ion_idx
bytes += num_induced_charges * sizeof(double); // induced_charges bytes += num_induced_charges * sizeof(double); // induced_charges
return bytes; return bytes;
} }

View File

@ -22,11 +22,11 @@
#include "comm.h" #include "comm.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "neighbor.h" #include "math_const.h"
#include "memory.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "memory.h" #include "neighbor.h"
#include "math_const.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
@ -55,28 +55,28 @@ PairCoulCutDielectric::~PairCoulCutDielectric()
void PairCoulCutDielectric::compute(int eflag, int vflag) void PairCoulCutDielectric::compute(int eflag, int vflag)
{ {
int i,j,ii,jj,inum,jnum,itype,jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double qtmp,etmp,xtmp,ytmp,ztmp,delx,dely,delz,ecoul; double qtmp, etmp, xtmp, ytmp, ztmp, delx, dely, delz, ecoul;
double fpair_i,fpair_j; double fpair_i, fpair_j;
double rsq,r2inv,rinv,forcecoul,factor_coul,efield_i; double rsq, r2inv, rinv, forcecoul, factor_coul, efield_i;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist, *jlist, *numneigh, **firstneigh;
if (atom->nmax > nmax) { if (atom->nmax > nmax) {
memory->destroy(efield); memory->destroy(efield);
nmax = atom->nmax; nmax = atom->nmax;
memory->create(efield,nmax,3,"pair:efield"); memory->create(efield, nmax, 3, "pair:efield");
} }
ecoul = 0.0; ecoul = 0.0;
ev_init(eflag,vflag); ev_init(eflag, vflag);
double **x = atom->x; double **x = atom->x;
double **f = atom->f; double **f = atom->f;
double *q = atom->q; double *q = atom->q;
double* eps = atom->epsilon; double *eps = atom->epsilon;
double** norm = atom->mu; double **norm = atom->mu;
double* curvature = atom->curvature; double *curvature = atom->curvature;
double* area = atom->area; double *area = atom->area;
int *type = atom->type; int *type = atom->type;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double *special_coul = force->special_coul; double *special_coul = force->special_coul;
@ -105,10 +105,10 @@ void PairCoulCutDielectric::compute(int eflag, int vflag)
double curvature_threshold = sqrt(area[i]); double curvature_threshold = sqrt(area[i]);
if (curvature[i] < curvature_threshold) { if (curvature[i] < curvature_threshold) {
double sf = curvature[i]/(4.0*MY_PIS*curvature_threshold) * area[i]*q[i]; double sf = curvature[i] / (4.0 * MY_PIS * curvature_threshold) * area[i] * q[i];
efield[i][0] = sf*norm[i][0]; efield[i][0] = sf * norm[i][0];
efield[i][1] = sf*norm[i][1]; efield[i][1] = sf * norm[i][1];
efield[i][2] = sf*norm[i][2]; efield[i][2] = sf * norm[i][2];
} else { } else {
efield[i][0] = efield[i][1] = efield[i][2] = 0; efield[i][0] = efield[i][1] = efield[i][2] = 0;
} }
@ -121,37 +121,37 @@ void PairCoulCutDielectric::compute(int eflag, int vflag)
delx = xtmp - x[j][0]; delx = xtmp - x[j][0];
dely = ytmp - x[j][1]; dely = ytmp - x[j][1];
delz = ztmp - x[j][2]; delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz; rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j]; jtype = type[j];
if (rsq < cutsq[itype][jtype] && rsq > EPSILON) { if (rsq < cutsq[itype][jtype] && rsq > EPSILON) {
r2inv = 1.0/rsq; r2inv = 1.0 / rsq;
rinv = sqrt(r2inv); rinv = sqrt(r2inv);
efield_i = scale[itype][jtype] * q[j]*rinv; efield_i = scale[itype][jtype] * q[j] * rinv;
forcecoul = qtmp*efield_i; forcecoul = qtmp * efield_i;
fpair_i = factor_coul*etmp*forcecoul*r2inv; fpair_i = factor_coul * etmp * forcecoul * r2inv;
f[i][0] += delx*fpair_i; f[i][0] += delx * fpair_i;
f[i][1] += dely*fpair_i; f[i][1] += dely * fpair_i;
f[i][2] += delz*fpair_i; f[i][2] += delz * fpair_i;
efield_i *= (factor_coul*etmp*r2inv); efield_i *= (factor_coul * etmp * r2inv);
efield[i][0] += delx*efield_i; efield[i][0] += delx * efield_i;
efield[i][1] += dely*efield_i; efield[i][1] += dely * efield_i;
efield[i][2] += delz*efield_i; efield[i][2] += delz * efield_i;
if (newton_pair && j >= nlocal) { if (newton_pair && j >= nlocal) {
fpair_j = factor_coul*eps[j]*forcecoul*r2inv; fpair_j = factor_coul * eps[j] * forcecoul * r2inv;
f[j][0] -= delx*fpair_j; f[j][0] -= delx * fpair_j;
f[j][1] -= dely*fpair_j; f[j][1] -= dely * fpair_j;
f[j][2] -= delz*fpair_j; f[j][2] -= delz * fpair_j;
} }
if (eflag) { if (eflag) {
ecoul = factor_coul * qqrd2e * scale[itype][jtype] * qtmp*q[j]*(etmp+eps[j])*rinv; ecoul = factor_coul * qqrd2e * scale[itype][jtype] * qtmp * q[j] * (etmp + eps[j]) * rinv;
ecoul *= 0.5; ecoul *= 0.5;
} }
if (evflag) ev_tally_full(i,0.0,ecoul,fpair_i,delx,dely,delz); if (evflag) ev_tally_full(i, 0.0, ecoul, fpair_i, delx, dely, delz);
} }
} }
} }
@ -159,7 +159,6 @@ void PairCoulCutDielectric::compute(int eflag, int vflag)
if (vflag_fdotr) virial_fdotr_compute(); if (vflag_fdotr) virial_fdotr_compute();
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
init specific to this pair style init specific to this pair style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -167,34 +166,36 @@ void PairCoulCutDielectric::compute(int eflag, int vflag)
void PairCoulCutDielectric::init_style() void PairCoulCutDielectric::init_style()
{ {
avec = (AtomVecDielectric *) atom->style_match("dielectric"); avec = (AtomVecDielectric *) atom->style_match("dielectric");
if (!avec) error->all(FLERR,"Pair coul/cut/dielectric requires atom style dielectric"); if (!avec) error->all(FLERR, "Pair coul/cut/dielectric requires atom style dielectric");
int irequest = neighbor->request(this,instance_me); int irequest = neighbor->request(this, instance_me);
neighbor->requests[irequest]->half = 0; neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1; neighbor->requests[irequest]->full = 1;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairCoulCutDielectric::single(int i, int j, int /*itype*/, int /*jtype*/, double PairCoulCutDielectric::single(int i, int j, int /*itype*/, int /*jtype*/, double rsq,
double rsq, double factor_coul, double /*factor_lj*/, double &fforce)
double factor_coul, double /*factor_lj*/,
double &fforce)
{ {
double r2inv,phicoul,ei,ej; double r2inv, phicoul, ei, ej;
double* eps = atom->epsilon; double *eps = atom->epsilon;
r2inv = 1.0/rsq; r2inv = 1.0 / rsq;
fforce = force->qqrd2e * atom->q[i]*atom->q[j]*sqrt(r2inv)*eps[i]; fforce = force->qqrd2e * atom->q[i] * atom->q[j] * sqrt(r2inv) * eps[i];
double eng = 0.0; double eng = 0.0;
if (eps[i] == 1) ei = 0; if (eps[i] == 1)
else ei = eps[i]; ei = 0;
if (eps[j] == 1) ej = 0; else
else ej = eps[j]; ei = eps[i];
phicoul = force->qqrd2e * atom->q[i]*atom->q[j]*sqrt(r2inv); if (eps[j] == 1)
phicoul *= 0.5*(ei+ej); ej = 0;
eng += factor_coul*phicoul; else
ej = eps[j];
phicoul = force->qqrd2e * atom->q[i] * atom->q[j] * sqrt(r2inv);
phicoul *= 0.5 * (ei + ej);
eng += factor_coul * phicoul;
return eng; return eng;
} }

View File

@ -267,7 +267,8 @@ void PairLJLongCoulLongDielectric::compute(int eflag, int vflag)
if (eflag) evdwl = f * (rn * (rn * lj3i[jtype] - lj4i[jtype]) - offseti[jtype]); if (eflag) evdwl = f * (rn * (rn * lj3i[jtype] - lj4i[jtype]) - offseti[jtype]);
} }
} }
} else force_lj = evdwl = 0.0; } else
force_lj = evdwl = 0.0;
fpair_i = (force_coul * etmp + force_lj) * r2inv; fpair_i = (force_coul * etmp + force_lj) * r2inv;
f[i][0] += delx * fpair_i; f[i][0] += delx * fpair_i;

View File

@ -184,7 +184,7 @@ void AngleDipole::coeff(int narg, char **arg)
void AngleDipole::init_style() void AngleDipole::init_style()
{ {
if (!atom->mu_flag || !atom->torque_flag) if (!atom->mu_flag || !atom->torque_flag)
error->all(FLERR,"Angle style dipole requires atom attributes mu and torque"); error->all(FLERR, "Angle style dipole requires atom attributes mu and torque");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -15,11 +15,11 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "force.h"
#include "neigh_list.h"
#include "memory.h"
#include "math_special.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "math_special.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
@ -35,25 +35,23 @@ using namespace MathSpecial;
PairMorseSoft::~PairMorseSoft() PairMorseSoft::~PairMorseSoft()
{ {
if (allocated) { if (allocated) { memory->destroy(lambda); }
memory->destroy(lambda);
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairMorseSoft::compute(int eflag, int vflag) void PairMorseSoft::compute(int eflag, int vflag)
{ {
int i,j,ii,jj,inum,jnum,itype,jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
double rsq,r,dr,dexp,dexp2,dexp3,factor_lj; double rsq, r, dr, dexp, dexp2, dexp3, factor_lj;
double ea,phi,V0,iea2; double ea, phi, V0, iea2;
double D, a, x0, l, B, s1, llf; double D, a, x0, l, B, s1, llf;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist, *jlist, *numneigh, **firstneigh;
evdwl = 0.0; evdwl = 0.0;
ev_init(eflag,vflag); ev_init(eflag, vflag);
double **x = atom->x; double **x = atom->x;
double **f = atom->f; double **f = atom->f;
@ -86,68 +84,64 @@ void PairMorseSoft::compute(int eflag, int vflag)
delx = xtmp - x[j][0]; delx = xtmp - x[j][0];
dely = ytmp - x[j][1]; dely = ytmp - x[j][1];
delz = ztmp - x[j][2]; delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz; rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j]; jtype = type[j];
if (rsq < cutsq[itype][jtype]) { if (rsq < cutsq[itype][jtype]) {
r = sqrt(rsq); r = sqrt(rsq);
dr = r - r0[itype][jtype]; dr = r - r0[itype][jtype];
D = d0[itype][jtype]; D = d0[itype][jtype];
a = alpha[itype][jtype]; a = alpha[itype][jtype];
x0 = r0[itype][jtype]; x0 = r0[itype][jtype];
dexp = exp( -a * dr ); dexp = exp(-a * dr);
dexp2 = dexp*dexp; dexp2 = dexp * dexp;
dexp3 = dexp2*dexp; dexp3 = dexp2 * dexp;
l = lambda[itype][jtype]; l = lambda[itype][jtype];
ea = exp( a * x0 ); ea = exp(a * x0);
iea2 = exp( -2.*a*x0 ); iea2 = exp(-2. * a * x0);
V0 = D * dexp * ( dexp - 2.0 ); V0 = D * dexp * (dexp - 2.0);
B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; B = -2.0 * D * iea2 * (ea - 1.0) / 3.0;
if (l >= shift_range) { if (l >= shift_range) {
s1 = (l - 1.0) / (shift_range - 1.0); s1 = (l - 1.0) / (shift_range - 1.0);
phi = V0 + B*dexp3 * s1; phi = V0 + B * dexp3 * s1;
// Force computation: // Force computation:
fpair = 3.0*a*B*dexp3*s1 + 2.0*a*D*(dexp2 - dexp); fpair = 3.0 * a * B * dexp3 * s1 + 2.0 * a * D * (dexp2 - dexp);
fpair /= r; fpair /= r;
} else { } else {
llf = MathSpecial::powint( l / shift_range, nlambda ); llf = MathSpecial::powint(l / shift_range, nlambda);
phi = V0 + B*dexp3; phi = V0 + B * dexp3;
phi *= llf; phi *= llf;
// Force computation: // Force computation:
if (r == 0.0) { if (r == 0.0) {
fpair = 0.0; fpair = 0.0;
} else { } else {
fpair = 3.0*a*B*dexp3 + 2.0*a*D*(dexp2 - dexp); fpair = 3.0 * a * B * dexp3 + 2.0 * a * D * (dexp2 - dexp);
fpair *= llf / r; fpair *= llf / r;
} }
} }
fpair *= factor_lj; fpair *= factor_lj;
f[i][0] += delx * fpair;
f[i][0] += delx*fpair; f[i][1] += dely * fpair;
f[i][1] += dely*fpair; f[i][2] += delz * fpair;
f[i][2] += delz*fpair;
if (newton_pair || j < nlocal) { if (newton_pair || j < nlocal) {
f[j][0] -= delx*fpair; f[j][0] -= delx * fpair;
f[j][1] -= dely*fpair; f[j][1] -= dely * fpair;
f[j][2] -= delz*fpair; f[j][2] -= delz * fpair;
} }
if (eflag) { if (eflag) { evdwl = phi * factor_lj; }
evdwl = phi*factor_lj;
}
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }
} }
@ -163,7 +157,7 @@ void PairMorseSoft::allocate()
{ {
PairMorse::allocate(); PairMorse::allocate();
int n = atom->ntypes; int n = atom->ntypes;
memory->create(lambda,n+1,n+1,"pair:lambda"); memory->create(lambda, n + 1, n + 1, "pair:lambda");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -172,35 +166,35 @@ void PairMorseSoft::allocate()
void PairMorseSoft::coeff(int narg, char **arg) void PairMorseSoft::coeff(int narg, char **arg)
{ {
if (narg < 6 || narg > 7) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg < 6 || narg > 7) error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate(); if (!allocated) allocate();
int ilo,ihi,jlo,jhi; int ilo, ihi, jlo, jhi;
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error); utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
double d0_one = utils::numeric(FLERR,arg[2],false,lmp); double d0_one = utils::numeric(FLERR, arg[2], false, lmp);
double alpha_one = utils::numeric(FLERR,arg[3],false,lmp); double alpha_one = utils::numeric(FLERR, arg[3], false, lmp);
double r0_one = utils::numeric(FLERR,arg[4],false,lmp); double r0_one = utils::numeric(FLERR, arg[4], false, lmp);
double lambda_one = utils::numeric(FLERR,arg[5],false,lmp); double lambda_one = utils::numeric(FLERR, arg[5], false, lmp);
double cut_one = cut_global; double cut_one = cut_global;
if (narg == 7) cut_one = utils::numeric(FLERR,arg[6],false,lmp); if (narg == 7) cut_one = utils::numeric(FLERR, arg[6], false, lmp);
int count = 0; int count = 0;
for (int i = ilo; i <= ihi; i++) { for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo, i); j <= jhi; j++) {
d0[i][j] = d0_one; d0[i][j] = d0_one;
alpha[i][j] = alpha_one; alpha[i][j] = alpha_one;
r0[i][j] = r0_one; r0[i][j] = r0_one;
lambda[i][j] = lambda_one; lambda[i][j] = lambda_one;
cut[i][j] = cut_one; cut[i][j] = cut_one;
setflag[i][j] = 1; setflag[i][j] = 1;
count++; count++;
} }
} }
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -209,65 +203,64 @@ void PairMorseSoft::coeff(int narg, char **arg)
void PairMorseSoft::settings(int narg, char **arg) void PairMorseSoft::settings(int narg, char **arg)
{ {
if (narg != 3) error->all(FLERR,"Illegal pair_style command"); if (narg != 3) error->all(FLERR, "Illegal pair_style command");
nlambda = utils::inumeric(FLERR,arg[0],false,lmp); nlambda = utils::inumeric(FLERR, arg[0], false, lmp);
shift_range = utils::numeric(FLERR,arg[1],false,lmp); shift_range = utils::numeric(FLERR, arg[1], false, lmp);
cut_global = utils::numeric(FLERR,arg[2],false,lmp); cut_global = utils::numeric(FLERR, arg[2], false, lmp);
// reset cutoffs that have been explicitly set // reset cutoffs that have been explicitly set
if (allocated) { if (allocated) {
int i,j; int i, j;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) for (j = i; j <= atom->ntypes; j++)
if (setflag[i][j]) cut[i][j] = cut_global; if (setflag[i][j]) cut[i][j] = cut_global;
} }
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairMorseSoft::init_one(int i, int j) double PairMorseSoft::init_one(int i, int j)
{ {
if (setflag[i][j] == 0) if (setflag[i][j] == 0) error->all(FLERR, "All pair coeffs are not set");
error->all(FLERR,"All pair coeffs are not set");
morse1[i][j] = 2.0*d0[i][j]*alpha[i][j]; morse1[i][j] = 2.0 * d0[i][j] * alpha[i][j];
if (offset_flag) { if (offset_flag) {
double l, s1, V0, B, llf; double l, s1, V0, B, llf;
double alpha_dr = -alpha[i][j] * (cut[i][j] - r0[i][j]); double alpha_dr = -alpha[i][j] * (cut[i][j] - r0[i][j]);
double D = d0[i][j]; double D = d0[i][j];
double a = alpha[i][j]; double a = alpha[i][j];
double x0 = r0[i][j]; double x0 = r0[i][j];
double dexp = exp( alpha_dr ); double dexp = exp(alpha_dr);
double dexp2 = dexp*dexp; double dexp2 = dexp * dexp;
double dexp3 = dexp2*dexp; double dexp3 = dexp2 * dexp;
l = lambda[i][j]; l = lambda[i][j];
double ea = exp( a*x0 ); double ea = exp(a * x0);
double iea2 = exp( -2.*a*x0 ); double iea2 = exp(-2. * a * x0);
V0 = D * dexp * ( dexp - 2.0 ); V0 = D * dexp * (dexp - 2.0);
B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; B = -2.0 * D * iea2 * (ea - 1.0) / 3.0;
if (l >= shift_range) { if (l >= shift_range) {
s1 = (l - 1.0) / (shift_range - 1.0); s1 = (l - 1.0) / (shift_range - 1.0);
offset[i][j] = V0 + B*dexp3 * s1; offset[i][j] = V0 + B * dexp3 * s1;
} else { } else {
llf = MathSpecial::powint( l / shift_range, nlambda ); llf = MathSpecial::powint(l / shift_range, nlambda);
offset[i][j] = V0 + B*dexp3; offset[i][j] = V0 + B * dexp3;
offset[i][j] *= llf; offset[i][j] *= llf;
} }
} else offset[i][j] = 0.0; } else
offset[i][j] = 0.0;
d0[j][i] = d0[i][j]; d0[j][i] = d0[i][j];
alpha[j][i] = alpha[i][j]; alpha[j][i] = alpha[i][j];
r0[j][i] = r0[i][j]; r0[j][i] = r0[i][j];
morse1[j][i] = morse1[i][j]; morse1[j][i] = morse1[i][j];
lambda[j][i] = lambda[i][j]; lambda[j][i] = lambda[i][j];
offset[j][i] = offset[i][j]; offset[j][i] = offset[i][j];
@ -283,16 +276,16 @@ void PairMorseSoft::write_restart(FILE *fp)
{ {
write_restart_settings(fp); write_restart_settings(fp);
int i,j; int i, j;
for (i = 1; i <= atom->ntypes; i++) { for (i = 1; i <= atom->ntypes; i++) {
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
fwrite(&setflag[i][j],sizeof(int),1,fp); fwrite(&setflag[i][j], sizeof(int), 1, fp);
if (setflag[i][j]) { if (setflag[i][j]) {
fwrite(&d0[i][j],sizeof(double),1,fp); fwrite(&d0[i][j], sizeof(double), 1, fp);
fwrite(&alpha[i][j],sizeof(double),1,fp); fwrite(&alpha[i][j], sizeof(double), 1, fp);
fwrite(&r0[i][j],sizeof(double),1,fp); fwrite(&r0[i][j], sizeof(double), 1, fp);
fwrite(&lambda[i][j],sizeof(double),1,fp); fwrite(&lambda[i][j], sizeof(double), 1, fp);
fwrite(&cut[i][j],sizeof(double),1,fp); fwrite(&cut[i][j], sizeof(double), 1, fp);
} }
} }
} }
@ -308,25 +301,25 @@ void PairMorseSoft::read_restart(FILE *fp)
allocate(); allocate();
int i,j; int i, j;
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) { for (i = 1; i <= atom->ntypes; i++) {
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error); if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
utils::sfread(FLERR,&d0[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &d0[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&alpha[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &alpha[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&r0[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &r0[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&lambda[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &lambda[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error);
} }
MPI_Bcast(&d0[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&d0[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&alpha[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&alpha[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&r0[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&r0[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&lambda[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&lambda[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
} }
} }
} }
@ -338,11 +331,11 @@ void PairMorseSoft::read_restart(FILE *fp)
void PairMorseSoft::write_restart_settings(FILE *fp) void PairMorseSoft::write_restart_settings(FILE *fp)
{ {
fwrite(&nlambda,sizeof(double),1,fp); fwrite(&nlambda, sizeof(double), 1, fp);
fwrite(&shift_range,sizeof(double),1,fp); fwrite(&shift_range, sizeof(double), 1, fp);
fwrite(&cut_global,sizeof(double),1,fp); fwrite(&cut_global, sizeof(double), 1, fp);
fwrite(&offset_flag,sizeof(int),1,fp); fwrite(&offset_flag, sizeof(int), 1, fp);
fwrite(&mix_flag,sizeof(int),1,fp); fwrite(&mix_flag, sizeof(int), 1, fp);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -353,20 +346,19 @@ void PairMorseSoft::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
utils::sfread(FLERR,&nlambda,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &nlambda, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&shift_range,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &shift_range, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &cut_global, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error); utils::sfread(FLERR, &offset_flag, sizeof(int), 1, fp, nullptr, error);
utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error); utils::sfread(FLERR, &mix_flag, sizeof(int), 1, fp, nullptr, error);
} }
MPI_Bcast(&nlambda,1,MPI_DOUBLE,0,world); MPI_Bcast(&nlambda, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&shift_range,1,MPI_DOUBLE,0,world); MPI_Bcast(&shift_range, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag, 1, MPI_INT, 0, world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag, 1, MPI_INT, 0, world);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
proc 0 writes to data file proc 0 writes to data file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -374,8 +366,7 @@ void PairMorseSoft::read_restart_settings(FILE *fp)
void PairMorseSoft::write_data(FILE *fp) void PairMorseSoft::write_data(FILE *fp)
{ {
for (int i = 1; i <= atom->ntypes; i++) for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp,"%d %g %g %g %g\n",i,d0[i][i],alpha[i][i],r0[i][i], fprintf(fp, "%d %g %g %g %g\n", i, d0[i][i], alpha[i][i], r0[i][i], lambda[i][i]);
lambda[i][i]);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -386,61 +377,60 @@ void PairMorseSoft::write_data_all(FILE *fp)
{ {
for (int i = 1; i <= atom->ntypes; i++) for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++) for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %d %g %g %g %g %g\n",i,j,d0[i][j],alpha[i][j],r0[i][j], fprintf(fp, "%d %d %g %g %g %g %g\n", i, j, d0[i][j], alpha[i][j], r0[i][j], lambda[i][j],
lambda[i][j],cut[i][j]); cut[i][j]);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double rsq, double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double rsq,
double /*factor_coul*/, double factor_lj, double /*factor_coul*/, double factor_lj, double &fforce)
double &fforce)
{ {
double r, dr, dexp, dexp2, dexp3, phi; double r, dr, dexp, dexp2, dexp3, phi;
double B, D, a, ea, iea2; double B, D, a, ea, iea2;
double x0, V0, s1, l, llf; double x0, V0, s1, l, llf;
D = d0[itype][jtype]; D = d0[itype][jtype];
a = alpha[itype][jtype]; a = alpha[itype][jtype];
x0 = r0[itype][jtype]; x0 = r0[itype][jtype];
r = sqrt(rsq); r = sqrt(rsq);
dr = r - r0[itype][jtype]; dr = r - r0[itype][jtype];
dexp = exp( -a * dr ); dexp = exp(-a * dr);
dexp2 = dexp*dexp; dexp2 = dexp * dexp;
dexp3 = dexp2*dexp; dexp3 = dexp2 * dexp;
l = lambda[itype][jtype]; l = lambda[itype][jtype];
ea = exp( a * x0 ); ea = exp(a * x0);
iea2 = exp( -2.*a*x0 ); iea2 = exp(-2. * a * x0);
V0 = D * dexp * ( dexp - 2.0 ); V0 = D * dexp * (dexp - 2.0);
B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; B = -2.0 * D * iea2 * (ea - 1.0) / 3.0;
if (l >= shift_range) { if (l >= shift_range) {
s1 = (l - 1.0) / (shift_range - 1.0); s1 = (l - 1.0) / (shift_range - 1.0);
phi = V0 + B*dexp3 * s1; phi = V0 + B * dexp3 * s1;
// Force computation: // Force computation:
fforce = 3.0*a*B*dexp3*s1 + 2.0*a*D*(dexp2 - dexp); fforce = 3.0 * a * B * dexp3 * s1 + 2.0 * a * D * (dexp2 - dexp);
fforce /= r; fforce /= r;
} else { } else {
llf = MathSpecial::powint( l / shift_range, nlambda ); llf = MathSpecial::powint(l / shift_range, nlambda);
phi = V0 + B*dexp3; phi = V0 + B * dexp3;
phi *= llf; phi *= llf;
// Force computation: // Force computation:
if (r == 0.0) { if (r == 0.0) {
fforce = 0.0; fforce = 0.0;
} else { } else {
fforce = 3.0*a*B*dexp3 + 2.0*a*D*(dexp2 - dexp); fforce = 3.0 * a * B * dexp3 + 2.0 * a * D * (dexp2 - dexp);
fforce *= llf / r; fforce *= llf / r;
} }
} }
fforce *= factor_lj; fforce *= factor_lj;
phi -= offset[itype][jtype]; phi -= offset[itype][jtype];
return factor_lj*phi; return factor_lj * phi;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -448,9 +438,9 @@ double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double
void *PairMorseSoft::extract(const char *str, int &dim) void *PairMorseSoft::extract(const char *str, int &dim)
{ {
dim = 2; dim = 2;
if (strcmp(str,"d0") == 0) return (void *) d0; if (strcmp(str, "d0") == 0) return (void *) d0;
if (strcmp(str,"r0") == 0) return (void *) r0; if (strcmp(str, "r0") == 0) return (void *) r0;
if (strcmp(str,"alpha") == 0) return (void *) alpha; if (strcmp(str, "alpha") == 0) return (void *) alpha;
if (strcmp(str,"lambda") == 0) return (void *) lambda; if (strcmp(str, "lambda") == 0) return (void *) lambda;
return nullptr; return nullptr;
} }

View File

@ -592,4 +592,3 @@ double ComputeFabric::compute_scalar()
scalar = nc; scalar = nc;
return nc; return nc;
} }

View File

@ -67,8 +67,8 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp)
// this is so final order of Modify:fix will conform to input script // this is so final order of Modify:fix will conform to input script
fix_history = nullptr; fix_history = nullptr;
fix_dummy = (FixDummy *) modify->add_fix("NEIGH_HISTORY_HH_DUMMY" fix_dummy = (FixDummy *) modify->add_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me) +
+ std::to_string(instance_me) + " all DUMMY"); " all DUMMY");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -77,19 +77,21 @@ PairGranHookeHistory::~PairGranHookeHistory()
{ {
if (copymode) return; if (copymode) return;
delete [] svector; delete[] svector;
if (!fix_history) modify->delete_fix("NEIGH_HISTORY_HH_DUMMY"+std::to_string(instance_me)); if (!fix_history)
else modify->delete_fix("NEIGH_HISTORY_HH"+std::to_string(instance_me)); modify->delete_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me));
else
modify->delete_fix("NEIGH_HISTORY_HH" + std::to_string(instance_me));
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
delete [] onerad_dynamic; delete[] onerad_dynamic;
delete [] onerad_frozen; delete[] onerad_frozen;
delete [] maxrad_dynamic; delete[] maxrad_dynamic;
delete [] maxrad_frozen; delete[] maxrad_frozen;
} }
memory->destroy(mass_rigid); memory->destroy(mass_rigid);
@ -99,20 +101,20 @@ PairGranHookeHistory::~PairGranHookeHistory()
void PairGranHookeHistory::compute(int eflag, int vflag) void PairGranHookeHistory::compute(int eflag, int vflag)
{ {
int i,j,ii,jj,inum,jnum; int i, j, ii, jj, inum, jnum;
double xtmp,ytmp,ztmp,delx,dely,delz,fx,fy,fz; double xtmp, ytmp, ztmp, delx, dely, delz, fx, fy, fz;
double radi,radj,radsum,rsq,r,rinv,rsqinv; double radi, radj, radsum, rsq, r, rinv, rsqinv;
double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3; double vr1, vr2, vr3, vnnr, vn1, vn2, vn3, vt1, vt2, vt3;
double wr1,wr2,wr3; double wr1, wr2, wr3;
double vtr1,vtr2,vtr3,vrel; double vtr1, vtr2, vtr3, vrel;
double mi,mj,meff,damp,ccel,tor1,tor2,tor3; double mi, mj, meff, damp, ccel, tor1, tor2, tor3;
double fn,fs,fs1,fs2,fs3; double fn, fs, fs1, fs2, fs3;
double shrmag,rsht; double shrmag, rsht;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist, *jlist, *numneigh, **firstneigh;
int *touch,**firsttouch; int *touch, **firsttouch;
double *shear,*allshear,**firstshear; double *shear, *allshear, **firstshear;
ev_init(eflag,vflag); ev_init(eflag, vflag);
int shearupdate = 1; int shearupdate = 1;
if (update->setupflag) shearupdate = 0; if (update->setupflag) shearupdate = 0;
@ -123,17 +125,19 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
if (fix_rigid && neighbor->ago == 0) { if (fix_rigid && neighbor->ago == 0) {
int tmp; int tmp;
int *body = (int *) fix_rigid->extract("body",tmp); int *body = (int *) fix_rigid->extract("body", tmp);
double *mass_body = (double *) fix_rigid->extract("masstotal",tmp); double *mass_body = (double *) fix_rigid->extract("masstotal", tmp);
if (atom->nmax > nmax) { if (atom->nmax > nmax) {
memory->destroy(mass_rigid); memory->destroy(mass_rigid);
nmax = atom->nmax; nmax = atom->nmax;
memory->create(mass_rigid,nmax,"pair:mass_rigid"); memory->create(mass_rigid, nmax, "pair:mass_rigid");
} }
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (body[i] >= 0) mass_rigid[i] = mass_body[body[i]]; if (body[i] >= 0)
else mass_rigid[i] = 0.0; mass_rigid[i] = mass_body[body[i]];
else
mass_rigid[i] = 0.0;
comm->forward_comm_pair(this); comm->forward_comm_pair(this);
} }
@ -175,24 +179,24 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
delx = xtmp - x[j][0]; delx = xtmp - x[j][0];
dely = ytmp - x[j][1]; dely = ytmp - x[j][1];
delz = ztmp - x[j][2]; delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz; rsq = delx * delx + dely * dely + delz * delz;
radj = radius[j]; radj = radius[j];
radsum = radi + radj; radsum = radi + radj;
if (rsq >= radsum*radsum) { if (rsq >= radsum * radsum) {
// unset non-touching neighbors // unset non-touching neighbors
touch[jj] = 0; touch[jj] = 0;
shear = &allshear[3*jj]; shear = &allshear[3 * jj];
shear[0] = 0.0; shear[0] = 0.0;
shear[1] = 0.0; shear[1] = 0.0;
shear[2] = 0.0; shear[2] = 0.0;
} else { } else {
r = sqrt(rsq); r = sqrt(rsq);
rinv = 1.0/r; rinv = 1.0 / r;
rsqinv = 1.0/rsq; rsqinv = 1.0 / rsq;
// relative translational velocity // relative translational velocity
@ -202,10 +206,10 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
// normal component // normal component
vnnr = vr1*delx + vr2*dely + vr3*delz; vnnr = vr1 * delx + vr2 * dely + vr3 * delz;
vn1 = delx*vnnr * rsqinv; vn1 = delx * vnnr * rsqinv;
vn2 = dely*vnnr * rsqinv; vn2 = dely * vnnr * rsqinv;
vn3 = delz*vnnr * rsqinv; vn3 = delz * vnnr * rsqinv;
// tangential component // tangential component
@ -215,9 +219,9 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
// relative rotational velocity // relative rotational velocity
wr1 = (radi*omega[i][0] + radj*omega[j][0]) * rinv; wr1 = (radi * omega[i][0] + radj * omega[j][0]) * rinv;
wr2 = (radi*omega[i][1] + radj*omega[j][1]) * rinv; wr2 = (radi * omega[i][1] + radj * omega[j][1]) * rinv;
wr3 = (radi*omega[i][2] + radj*omega[j][2]) * rinv; wr3 = (radi * omega[i][2] + radj * omega[j][2]) * rinv;
// meff = effective mass of pair of particles // meff = effective mass of pair of particles
// if I or J part of rigid body, use body mass // if I or J part of rigid body, use body mass
@ -230,99 +234,98 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
if (mass_rigid[j] > 0.0) mj = mass_rigid[j]; if (mass_rigid[j] > 0.0) mj = mass_rigid[j];
} }
meff = mi*mj / (mi+mj); meff = mi * mj / (mi + mj);
if (mask[i] & freeze_group_bit) meff = mj; if (mask[i] & freeze_group_bit) meff = mj;
if (mask[j] & freeze_group_bit) meff = mi; if (mask[j] & freeze_group_bit) meff = mi;
// normal forces = Hookian contact + normal velocity damping // normal forces = Hookian contact + normal velocity damping
damp = meff*gamman*vnnr*rsqinv; damp = meff * gamman * vnnr * rsqinv;
ccel = kn*(radsum-r)*rinv - damp; ccel = kn * (radsum - r) * rinv - damp;
if (limit_damping && (ccel < 0.0)) ccel = 0.0; if (limit_damping && (ccel < 0.0)) ccel = 0.0;
// relative velocities // relative velocities
vtr1 = vt1 - (delz*wr2-dely*wr3); vtr1 = vt1 - (delz * wr2 - dely * wr3);
vtr2 = vt2 - (delx*wr3-delz*wr1); vtr2 = vt2 - (delx * wr3 - delz * wr1);
vtr3 = vt3 - (dely*wr1-delx*wr2); vtr3 = vt3 - (dely * wr1 - delx * wr2);
vrel = vtr1*vtr1 + vtr2*vtr2 + vtr3*vtr3; vrel = vtr1 * vtr1 + vtr2 * vtr2 + vtr3 * vtr3;
vrel = sqrt(vrel); vrel = sqrt(vrel);
// shear history effects // shear history effects
touch[jj] = 1; touch[jj] = 1;
shear = &allshear[3*jj]; shear = &allshear[3 * jj];
if (shearupdate) { if (shearupdate) {
shear[0] += vtr1*dt; shear[0] += vtr1 * dt;
shear[1] += vtr2*dt; shear[1] += vtr2 * dt;
shear[2] += vtr3*dt; shear[2] += vtr3 * dt;
} }
shrmag = sqrt(shear[0]*shear[0] + shear[1]*shear[1] + shrmag = sqrt(shear[0] * shear[0] + shear[1] * shear[1] + shear[2] * shear[2]);
shear[2]*shear[2]);
// rotate shear displacements // rotate shear displacements
rsht = shear[0]*delx + shear[1]*dely + shear[2]*delz; rsht = shear[0] * delx + shear[1] * dely + shear[2] * delz;
rsht *= rsqinv; rsht *= rsqinv;
if (shearupdate) { if (shearupdate) {
shear[0] -= rsht*delx; shear[0] -= rsht * delx;
shear[1] -= rsht*dely; shear[1] -= rsht * dely;
shear[2] -= rsht*delz; shear[2] -= rsht * delz;
} }
// tangential forces = shear + tangential velocity damping // tangential forces = shear + tangential velocity damping
fs1 = - (kt*shear[0] + meff*gammat*vtr1); fs1 = -(kt * shear[0] + meff * gammat * vtr1);
fs2 = - (kt*shear[1] + meff*gammat*vtr2); fs2 = -(kt * shear[1] + meff * gammat * vtr2);
fs3 = - (kt*shear[2] + meff*gammat*vtr3); fs3 = -(kt * shear[2] + meff * gammat * vtr3);
// rescale frictional displacements and forces if needed // rescale frictional displacements and forces if needed
fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); fs = sqrt(fs1 * fs1 + fs2 * fs2 + fs3 * fs3);
fn = xmu * fabs(ccel*r); fn = xmu * fabs(ccel * r);
if (fs > fn) { if (fs > fn) {
if (shrmag != 0.0) { if (shrmag != 0.0) {
shear[0] = (fn/fs) * (shear[0] + meff*gammat*vtr1/kt) - shear[0] =
meff*gammat*vtr1/kt; (fn / fs) * (shear[0] + meff * gammat * vtr1 / kt) - meff * gammat * vtr1 / kt;
shear[1] = (fn/fs) * (shear[1] + meff*gammat*vtr2/kt) - shear[1] =
meff*gammat*vtr2/kt; (fn / fs) * (shear[1] + meff * gammat * vtr2 / kt) - meff * gammat * vtr2 / kt;
shear[2] = (fn/fs) * (shear[2] + meff*gammat*vtr3/kt) - shear[2] =
meff*gammat*vtr3/kt; (fn / fs) * (shear[2] + meff * gammat * vtr3 / kt) - meff * gammat * vtr3 / kt;
fs1 *= fn/fs; fs1 *= fn / fs;
fs2 *= fn/fs; fs2 *= fn / fs;
fs3 *= fn/fs; fs3 *= fn / fs;
} else fs1 = fs2 = fs3 = 0.0; } else
fs1 = fs2 = fs3 = 0.0;
} }
// forces & torques // forces & torques
fx = delx*ccel + fs1; fx = delx * ccel + fs1;
fy = dely*ccel + fs2; fy = dely * ccel + fs2;
fz = delz*ccel + fs3; fz = delz * ccel + fs3;
f[i][0] += fx; f[i][0] += fx;
f[i][1] += fy; f[i][1] += fy;
f[i][2] += fz; f[i][2] += fz;
tor1 = rinv * (dely*fs3 - delz*fs2); tor1 = rinv * (dely * fs3 - delz * fs2);
tor2 = rinv * (delz*fs1 - delx*fs3); tor2 = rinv * (delz * fs1 - delx * fs3);
tor3 = rinv * (delx*fs2 - dely*fs1); tor3 = rinv * (delx * fs2 - dely * fs1);
torque[i][0] -= radi*tor1; torque[i][0] -= radi * tor1;
torque[i][1] -= radi*tor2; torque[i][1] -= radi * tor2;
torque[i][2] -= radi*tor3; torque[i][2] -= radi * tor3;
if (newton_pair || j < nlocal) { if (newton_pair || j < nlocal) {
f[j][0] -= fx; f[j][0] -= fx;
f[j][1] -= fy; f[j][1] -= fy;
f[j][2] -= fz; f[j][2] -= fz;
torque[j][0] -= radj*tor1; torque[j][0] -= radj * tor1;
torque[j][1] -= radj*tor2; torque[j][1] -= radj * tor2;
torque[j][2] -= radj*tor3; torque[j][2] -= radj * tor3;
} }
if (evflag) ev_tally_xyz(i,j,nlocal,newton_pair, if (evflag) ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, fx, fy, fz, delx, dely, delz);
0.0,0.0,fx,fy,fz,delx,dely,delz);
} }
} }
} }
@ -339,17 +342,16 @@ void PairGranHookeHistory::allocate()
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
memory->create(setflag,n+1,n+1,"pair:setflag"); memory->create(setflag, n + 1, n + 1, "pair:setflag");
for (int i = 1; i <= n; i++) for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++) for (int j = i; j <= n; j++) setflag[i][j] = 0;
setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq"); memory->create(cutsq, n + 1, n + 1, "pair:cutsq");
onerad_dynamic = new double[n+1]; onerad_dynamic = new double[n + 1];
onerad_frozen = new double[n+1]; onerad_frozen = new double[n + 1];
maxrad_dynamic = new double[n+1]; maxrad_dynamic = new double[n + 1];
maxrad_frozen = new double[n+1]; maxrad_frozen = new double[n + 1];
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -358,29 +360,35 @@ void PairGranHookeHistory::allocate()
void PairGranHookeHistory::settings(int narg, char **arg) void PairGranHookeHistory::settings(int narg, char **arg)
{ {
if (narg != 6 && narg != 7) error->all(FLERR,"Illegal pair_style command"); if (narg != 6 && narg != 7) error->all(FLERR, "Illegal pair_style command");
kn = utils::numeric(FLERR,arg[0],false,lmp); kn = utils::numeric(FLERR, arg[0], false, lmp);
if (strcmp(arg[1],"NULL") == 0) kt = kn * 2.0/7.0; if (strcmp(arg[1], "NULL") == 0)
else kt = utils::numeric(FLERR,arg[1],false,lmp); kt = kn * 2.0 / 7.0;
else
kt = utils::numeric(FLERR, arg[1], false, lmp);
gamman = utils::numeric(FLERR,arg[2],false,lmp); gamman = utils::numeric(FLERR, arg[2], false, lmp);
if (strcmp(arg[3],"NULL") == 0) gammat = 0.5 * gamman; if (strcmp(arg[3], "NULL") == 0)
else gammat = utils::numeric(FLERR,arg[3],false,lmp); gammat = 0.5 * gamman;
else
gammat = utils::numeric(FLERR, arg[3], false, lmp);
xmu = utils::numeric(FLERR,arg[4],false,lmp); xmu = utils::numeric(FLERR, arg[4], false, lmp);
dampflag = utils::inumeric(FLERR,arg[5],false,lmp); dampflag = utils::inumeric(FLERR, arg[5], false, lmp);
if (dampflag == 0) gammat = 0.0; if (dampflag == 0) gammat = 0.0;
limit_damping = 0; limit_damping = 0;
if (narg == 7) { if (narg == 7) {
if (strcmp(arg[6], "limit_damping") == 0) limit_damping = 1; if (strcmp(arg[6], "limit_damping") == 0)
else error->all(FLERR,"Illegal pair_style command"); limit_damping = 1;
else
error->all(FLERR, "Illegal pair_style command");
} }
if (kn < 0.0 || kt < 0.0 || gamman < 0.0 || gammat < 0.0 || if (kn < 0.0 || kt < 0.0 || gamman < 0.0 || gammat < 0.0 || xmu < 0.0 || xmu > 10000.0 ||
xmu < 0.0 || xmu > 10000.0 || dampflag < 0 || dampflag > 1) dampflag < 0 || dampflag > 1)
error->all(FLERR,"Illegal pair_style command"); error->all(FLERR, "Illegal pair_style command");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -389,22 +397,22 @@ void PairGranHookeHistory::settings(int narg, char **arg)
void PairGranHookeHistory::coeff(int narg, char **arg) void PairGranHookeHistory::coeff(int narg, char **arg)
{ {
if (narg > 2) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg > 2) error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate(); if (!allocated) allocate();
int ilo,ihi,jlo,jhi; int ilo, ihi, jlo, jhi;
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error); utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
int count = 0; int count = 0;
for (int i = ilo; i <= ihi; i++) { for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo, i); j <= jhi; j++) {
setflag[i][j] = 1; setflag[i][j] = 1;
count++; count++;
} }
} }
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -418,13 +426,13 @@ void PairGranHookeHistory::init_style()
// error and warning checks // error and warning checks
if (!atom->radius_flag || !atom->rmass_flag) if (!atom->radius_flag || !atom->rmass_flag)
error->all(FLERR,"Pair granular requires atom attributes radius, rmass"); error->all(FLERR, "Pair granular requires atom attributes radius, rmass");
if (comm->ghost_velocity == 0) if (comm->ghost_velocity == 0)
error->all(FLERR,"Pair granular requires ghost atoms store velocity"); error->all(FLERR, "Pair granular requires ghost atoms store velocity");
// need a granular neigh list // need a granular neigh list
int irequest = neighbor->request(this,instance_me); int irequest = neighbor->request(this, instance_me);
neighbor->requests[irequest]->size = 1; neighbor->requests[irequest]->size = 1;
if (history) neighbor->requests[irequest]->history = 1; if (history) neighbor->requests[irequest]->history = 1;
@ -436,16 +444,18 @@ void PairGranHookeHistory::init_style()
if (history && (fix_history == nullptr)) { if (history && (fix_history == nullptr)) {
auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history); auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history);
fix_history = (FixNeighHistory *) modify->replace_fix("NEIGH_HISTORY_HH_DUMMY" fix_history = (FixNeighHistory *) modify->replace_fix(
+ std::to_string(instance_me),cmd,1); "NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1);
fix_history->pair = this; fix_history->pair = this;
} }
// check for FixFreeze and set freeze_group_bit // check for FixFreeze and set freeze_group_bit
int ifreeze = modify->find_fix_by_style("^freeze"); int ifreeze = modify->find_fix_by_style("^freeze");
if (ifreeze < 0) freeze_group_bit = 0; if (ifreeze < 0)
else freeze_group_bit = modify->fix[ifreeze]->groupbit; freeze_group_bit = 0;
else
freeze_group_bit = modify->fix[ifreeze]->groupbit;
// check for FixRigid so can extract rigid body masses // check for FixRigid so can extract rigid body masses
// FIXME: this only catches the first rigid fix, there may be multiple. // FIXME: this only catches the first rigid fix, there may be multiple.
@ -458,7 +468,7 @@ void PairGranHookeHistory::init_style()
// check for FixPour and FixDeposit so can extract particle radii // check for FixPour and FixDeposit so can extract particle radii
int ipour = modify->find_fix_by_style("^pour"); int ipour = modify->find_fix_by_style("^pour");
int idep = modify->find_fix_by_style("^deposit"); int idep = modify->find_fix_by_style("^deposit");
// set maxrad_dynamic and maxrad_frozen for each type // set maxrad_dynamic and maxrad_frozen for each type
// include future FixPour and FixDeposit particles as dynamic // include future FixPour and FixDeposit particles as dynamic
@ -468,13 +478,11 @@ void PairGranHookeHistory::init_style()
onerad_dynamic[i] = onerad_frozen[i] = 0.0; onerad_dynamic[i] = onerad_frozen[i] = 0.0;
if (ipour >= 0) { if (ipour >= 0) {
itype = i; itype = i;
onerad_dynamic[i] = onerad_dynamic[i] = *((double *) modify->fix[ipour]->extract("radius", itype));
*((double *) modify->fix[ipour]->extract("radius",itype));
} }
if (idep >= 0) { if (idep >= 0) {
itype = i; itype = i;
onerad_dynamic[i] = onerad_dynamic[i] = *((double *) modify->fix[idep]->extract("radius", itype));
*((double *) modify->fix[idep]->extract("radius",itype));
} }
} }
@ -485,18 +493,18 @@ void PairGranHookeHistory::init_style()
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (mask[i] & freeze_group_bit) if (mask[i] & freeze_group_bit)
onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]],radius[i]); onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]], radius[i]);
else else
onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]],radius[i]); onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]);
MPI_Allreduce(&onerad_dynamic[1],&maxrad_dynamic[1],atom->ntypes,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world);
MPI_Allreduce(&onerad_frozen[1],&maxrad_frozen[1],atom->ntypes,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world);
// set fix which stores history info // set fix which stores history info
if (history) { if (history) {
int ifix = modify->find_fix("NEIGH_HISTORY_HH"+std::to_string(instance_me)); int ifix = modify->find_fix("NEIGH_HISTORY_HH" + std::to_string(instance_me));
if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID"); if (ifix < 0) error->all(FLERR, "Could not find pair fix neigh history ID");
fix_history = (FixNeighHistory *) modify->fix[ifix]; fix_history = (FixNeighHistory *) modify->fix[ifix];
} }
} }
@ -512,9 +520,9 @@ double PairGranHookeHistory::init_one(int i, int j)
// cutoff = sum of max I,J radii for // cutoff = sum of max I,J radii for
// dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen
double cutoff = maxrad_dynamic[i]+maxrad_dynamic[j]; double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j];
cutoff = MAX(cutoff,maxrad_frozen[i]+maxrad_dynamic[j]); cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]);
cutoff = MAX(cutoff,maxrad_dynamic[i]+maxrad_frozen[j]); cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]);
return cutoff; return cutoff;
} }
@ -526,10 +534,9 @@ void PairGranHookeHistory::write_restart(FILE *fp)
{ {
write_restart_settings(fp); write_restart_settings(fp);
int i,j; int i, j;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) for (j = i; j <= atom->ntypes; j++) fwrite(&setflag[i][j], sizeof(int), 1, fp);
fwrite(&setflag[i][j],sizeof(int),1,fp);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -541,12 +548,12 @@ void PairGranHookeHistory::read_restart(FILE *fp)
read_restart_settings(fp); read_restart_settings(fp);
allocate(); allocate();
int i,j; int i, j;
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error); if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
} }
} }
@ -556,12 +563,12 @@ void PairGranHookeHistory::read_restart(FILE *fp)
void PairGranHookeHistory::write_restart_settings(FILE *fp) void PairGranHookeHistory::write_restart_settings(FILE *fp)
{ {
fwrite(&kn,sizeof(double),1,fp); fwrite(&kn, sizeof(double), 1, fp);
fwrite(&kt,sizeof(double),1,fp); fwrite(&kt, sizeof(double), 1, fp);
fwrite(&gamman,sizeof(double),1,fp); fwrite(&gamman, sizeof(double), 1, fp);
fwrite(&gammat,sizeof(double),1,fp); fwrite(&gammat, sizeof(double), 1, fp);
fwrite(&xmu,sizeof(double),1,fp); fwrite(&xmu, sizeof(double), 1, fp);
fwrite(&dampflag,sizeof(int),1,fp); fwrite(&dampflag, sizeof(int), 1, fp);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -571,19 +578,19 @@ void PairGranHookeHistory::write_restart_settings(FILE *fp)
void PairGranHookeHistory::read_restart_settings(FILE *fp) void PairGranHookeHistory::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
utils::sfread(FLERR,&kn,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &kn, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&kt,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &kt, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&gamman,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &gamman, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&gammat,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &gammat, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&xmu,sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR, &xmu, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR,&dampflag,sizeof(int),1,fp,nullptr,error); utils::sfread(FLERR, &dampflag, sizeof(int), 1, fp, nullptr, error);
} }
MPI_Bcast(&kn,1,MPI_DOUBLE,0,world); MPI_Bcast(&kn, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&kt,1,MPI_DOUBLE,0,world); MPI_Bcast(&kt, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&gamman,1,MPI_DOUBLE,0,world); MPI_Bcast(&gamman, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&gammat,1,MPI_DOUBLE,0,world); MPI_Bcast(&gammat, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&xmu,1,MPI_DOUBLE,0,world); MPI_Bcast(&xmu, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&dampflag,1,MPI_INT,0,world); MPI_Bcast(&dampflag, 1, MPI_INT, 0, world);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -595,32 +602,30 @@ void PairGranHookeHistory::reset_dt()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/, double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/, double rsq,
double rsq, double /*factor_coul*/, double /*factor_lj*/, double &fforce)
double /*factor_coul*/, double /*factor_lj*/,
double &fforce)
{ {
double radi,radj,radsum; double radi, radj, radsum;
double r,rinv,rsqinv,delx,dely,delz; double r, rinv, rsqinv, delx, dely, delz;
double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3,wr1,wr2,wr3; double vr1, vr2, vr3, vnnr, vn1, vn2, vn3, vt1, vt2, vt3, wr1, wr2, wr3;
double mi,mj,meff,damp,ccel; double mi, mj, meff, damp, ccel;
double vtr1,vtr2,vtr3,vrel,shrmag,rsht; double vtr1, vtr2, vtr3, vrel, shrmag, rsht;
double fs1,fs2,fs3,fs,fn; double fs1, fs2, fs3, fs, fn;
double *radius = atom->radius; double *radius = atom->radius;
radi = radius[i]; radi = radius[i];
radj = radius[j]; radj = radius[j];
radsum = radi + radj; radsum = radi + radj;
if (rsq >= radsum*radsum) { if (rsq >= radsum * radsum) {
fforce = 0.0; fforce = 0.0;
for (int m = 0; m < single_extra; m++) svector[m] = 0.0; for (int m = 0; m < single_extra; m++) svector[m] = 0.0;
return 0.0; return 0.0;
} }
r = sqrt(rsq); r = sqrt(rsq);
rinv = 1.0/r; rinv = 1.0 / r;
rsqinv = 1.0/rsq; rsqinv = 1.0 / rsq;
// relative translational velocity // relative translational velocity
@ -636,10 +641,10 @@ double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/,
dely = x[i][1] - x[j][1]; dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2]; delz = x[i][2] - x[j][2];
vnnr = vr1*delx + vr2*dely + vr3*delz; vnnr = vr1 * delx + vr2 * dely + vr3 * delz;
vn1 = delx*vnnr * rsqinv; vn1 = delx * vnnr * rsqinv;
vn2 = dely*vnnr * rsqinv; vn2 = dely * vnnr * rsqinv;
vn3 = delz*vnnr * rsqinv; vn3 = delz * vnnr * rsqinv;
// tangential component // tangential component
@ -650,9 +655,9 @@ double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/,
// relative rotational velocity // relative rotational velocity
double **omega = atom->omega; double **omega = atom->omega;
wr1 = (radi*omega[i][0] + radj*omega[j][0]) * rinv; wr1 = (radi * omega[i][0] + radj * omega[j][0]) * rinv;
wr2 = (radi*omega[i][1] + radj*omega[j][1]) * rinv; wr2 = (radi * omega[i][1] + radj * omega[j][1]) * rinv;
wr3 = (radi*omega[i][2] + radj*omega[j][2]) * rinv; wr3 = (radi * omega[i][2] + radj * omega[j][2]) * rinv;
// meff = effective mass of pair of particles // meff = effective mass of pair of particles
// if I or J part of rigid body, use body mass // if I or J part of rigid body, use body mass
@ -669,22 +674,22 @@ double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/,
if (mass_rigid[j] > 0.0) mj = mass_rigid[j]; if (mass_rigid[j] > 0.0) mj = mass_rigid[j];
} }
meff = mi*mj / (mi+mj); meff = mi * mj / (mi + mj);
if (mask[i] & freeze_group_bit) meff = mj; if (mask[i] & freeze_group_bit) meff = mj;
if (mask[j] & freeze_group_bit) meff = mi; if (mask[j] & freeze_group_bit) meff = mi;
// normal forces = Hookian contact + normal velocity damping // normal forces = Hookian contact + normal velocity damping
damp = meff*gamman*vnnr*rsqinv; damp = meff * gamman * vnnr * rsqinv;
ccel = kn*(radsum-r)*rinv - damp; ccel = kn * (radsum - r) * rinv - damp;
if(limit_damping && (ccel < 0.0)) ccel = 0.0; if (limit_damping && (ccel < 0.0)) ccel = 0.0;
// relative velocities // relative velocities
vtr1 = vt1 - (delz*wr2-dely*wr3); vtr1 = vt1 - (delz * wr2 - dely * wr3);
vtr2 = vt2 - (delx*wr3-delz*wr1); vtr2 = vt2 - (delx * wr3 - delz * wr1);
vtr3 = vt3 - (dely*wr1-delx*wr2); vtr3 = vt3 - (dely * wr1 - delx * wr2);
vrel = vtr1*vtr1 + vtr2*vtr2 + vtr3*vtr3; vrel = vtr1 * vtr1 + vtr2 * vtr2 + vtr3 * vtr3;
vrel = sqrt(vrel); vrel = sqrt(vrel);
// shear history effects // shear history effects
@ -703,33 +708,33 @@ double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/,
if (jlist[neighprev] == j) break; if (jlist[neighprev] == j) break;
} }
double *shear = &allshear[3*neighprev]; double *shear = &allshear[3 * neighprev];
shrmag = sqrt(shear[0]*shear[0] + shear[1]*shear[1] + shrmag = sqrt(shear[0] * shear[0] + shear[1] * shear[1] + shear[2] * shear[2]);
shear[2]*shear[2]);
// rotate shear displacements // rotate shear displacements
rsht = shear[0]*delx + shear[1]*dely + shear[2]*delz; rsht = shear[0] * delx + shear[1] * dely + shear[2] * delz;
rsht *= rsqinv; rsht *= rsqinv;
// tangential forces = shear + tangential velocity damping // tangential forces = shear + tangential velocity damping
fs1 = - (kt*shear[0] + meff*gammat*vtr1); fs1 = -(kt * shear[0] + meff * gammat * vtr1);
fs2 = - (kt*shear[1] + meff*gammat*vtr2); fs2 = -(kt * shear[1] + meff * gammat * vtr2);
fs3 = - (kt*shear[2] + meff*gammat*vtr3); fs3 = -(kt * shear[2] + meff * gammat * vtr3);
// rescale frictional displacements and forces if needed // rescale frictional displacements and forces if needed
fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); fs = sqrt(fs1 * fs1 + fs2 * fs2 + fs3 * fs3);
fn = xmu * fabs(ccel*r); fn = xmu * fabs(ccel * r);
if (fs > fn) { if (fs > fn) {
if (shrmag != 0.0) { if (shrmag != 0.0) {
fs1 *= fn/fs; fs1 *= fn / fs;
fs2 *= fn/fs; fs2 *= fn / fs;
fs3 *= fn/fs; fs3 *= fn / fs;
fs *= fn/fs; fs *= fn / fs;
} else fs1 = fs2 = fs3 = fs = 0.0; } else
fs1 = fs2 = fs3 = fs = 0.0;
} }
// set force and return no energy // set force and return no energy
@ -754,10 +759,10 @@ double PairGranHookeHistory::single(int i, int j, int /*itype*/, int /*jtype*/,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int PairGranHookeHistory::pack_forward_comm(int n, int *list, double *buf, int PairGranHookeHistory::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
int /*pbc_flag*/, int * /*pbc*/) int * /*pbc*/)
{ {
int i,j,m; int i, j, m;
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -771,12 +776,11 @@ int PairGranHookeHistory::pack_forward_comm(int n, int *list, double *buf,
void PairGranHookeHistory::unpack_forward_comm(int n, int first, double *buf) void PairGranHookeHistory::unpack_forward_comm(int n, int first, double *buf)
{ {
int i,m,last; int i, m, last;
m = 0; m = 0;
last = first + n; last = first + n;
for (i = first; i < last; i++) for (i = first; i < last; i++) mass_rigid[i] = buf[m++];
mass_rigid[i] = buf[m++];
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -785,7 +789,7 @@ void PairGranHookeHistory::unpack_forward_comm(int n, int first, double *buf)
double PairGranHookeHistory::memory_usage() double PairGranHookeHistory::memory_usage()
{ {
double bytes = (double)nmax * sizeof(double); double bytes = (double) nmax * sizeof(double);
return bytes; return bytes;
} }
@ -795,7 +799,7 @@ double PairGranHookeHistory::memory_usage()
double PairGranHookeHistory::atom2cut(int i) double PairGranHookeHistory::atom2cut(int i)
{ {
double cut = atom->radius[i]*2; double cut = atom->radius[i] * 2;
return cut; return cut;
} }
@ -805,6 +809,6 @@ double PairGranHookeHistory::atom2cut(int i)
double PairGranHookeHistory::radii2cut(double r1, double r2) double PairGranHookeHistory::radii2cut(double r1, double r2)
{ {
double cut = r1+r2; double cut = r1 + r2;
return cut; return cut;
} }

View File

@ -42,26 +42,25 @@ class AngleCharmmIntel : public AngleCharmm {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k, theta0, k_ub, r_ub; } fc_packed1; typedef struct {
flt_t k, theta0, k_ub, r_ub;
} fc_packed1;
fc_packed1 *fc; fc_packed1 *fc;
ForceConst() : _nangletypes(0) {} ForceConst() : _nangletypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nangletypes, Memory *memory); void set_ntypes(const int nangletypes, Memory *memory);
@ -74,7 +73,7 @@ class AngleCharmmIntel : public AngleCharmm {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,26 +42,25 @@ class AngleHarmonicIntel : public AngleHarmonic {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k, theta0; } fc_packed1; typedef struct {
flt_t k, theta0;
} fc_packed1;
fc_packed1 *fc; fc_packed1 *fc;
ForceConst() : _nangletypes(0) {} ForceConst() : _nangletypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nangletypes, Memory *memory); void set_ntypes(const int nangletypes, Memory *memory);
@ -74,7 +73,7 @@ class AngleHarmonicIntel : public AngleHarmonic {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,26 +42,25 @@ class BondFENEIntel : public BondFENE {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k, ir0sq, sigma, epsilon; } fc_packed1; typedef struct {
flt_t k, ir0sq, sigma, epsilon;
} fc_packed1;
fc_packed1 *fc; fc_packed1 *fc;
ForceConst() : _nbondtypes(0) {} ForceConst() : _nbondtypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nbondtypes, Memory *memory); void set_ntypes(const int nbondtypes, Memory *memory);
@ -74,7 +73,7 @@ class BondFENEIntel : public BondFENE {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,26 +42,25 @@ class BondHarmonicIntel : public BondHarmonic {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k, r0; } fc_packed1; typedef struct {
flt_t k, r0;
} fc_packed1;
fc_packed1 *fc; fc_packed1 *fc;
ForceConst() : _nbondtypes(0) {} ForceConst() : _nbondtypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nbondtypes, Memory *memory); void set_ntypes(const int nbondtypes, Memory *memory);
@ -74,7 +73,7 @@ class BondHarmonicIntel : public BondHarmonic {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,31 +42,32 @@ class DihedralCharmmIntel : public DihedralCharmm {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t lj1, lj2, lj3, lj4; } fc_packed1; typedef struct {
typedef struct { flt_t cos_shift, sin_shift, k; flt_t lj1, lj2, lj3, lj4;
int multiplicity; } fc_packed3; } fc_packed1;
typedef struct {
flt_t cos_shift, sin_shift, k;
int multiplicity;
} fc_packed3;
fc_packed1 **ljp; fc_packed1 **ljp;
fc_packed3 *bp; fc_packed3 *bp;
flt_t *weight; flt_t *weight;
ForceConst() : _npairtypes(0), _nbondtypes(0) {} ForceConst() : _npairtypes(0), _nbondtypes(0) {}
~ForceConst() { set_ntypes(0, 0, nullptr); } ~ForceConst() { set_ntypes(0, 0, nullptr); }
void set_ntypes(const int npairtypes, const int nbondtypes, Memory *memory); void set_ntypes(const int npairtypes, const int nbondtypes, Memory *memory);
@ -79,7 +80,7 @@ class DihedralCharmmIntel : public DihedralCharmm {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,32 +42,30 @@ class DihedralFourierIntel : public DihedralFourier {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t cos_shift, sin_shift, k; typedef struct {
int multiplicity; } fc_packed1; flt_t cos_shift, sin_shift, k;
int multiplicity;
} fc_packed1;
fc_packed1 **bp; fc_packed1 **bp;
ForceConst() : _nbondtypes(0) {} ForceConst() : _nbondtypes(0) {}
~ForceConst() { set_ntypes(0, nullptr, nullptr, nullptr); } ~ForceConst() { set_ntypes(0, nullptr, nullptr, nullptr); }
void set_ntypes(const int nbondtypes, int *setflag, int *nterms, void set_ntypes(const int nbondtypes, int *setflag, int *nterms, Memory *memory);
Memory *memory);
private: private:
int _nbondtypes, _maxnterms; int _nbondtypes, _maxnterms;
@ -77,7 +75,7 @@ class DihedralFourierIntel : public DihedralFourier {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,28 +42,27 @@ class DihedralHarmonicIntel : public DihedralHarmonic {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t cos_shift, sin_shift, k; typedef struct {
int multiplicity; } fc_packed1; flt_t cos_shift, sin_shift, k;
int multiplicity;
} fc_packed1;
fc_packed1 *bp; fc_packed1 *bp;
ForceConst() : _nbondtypes(0) {} ForceConst() : _nbondtypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nbondtypes, Memory *memory); void set_ntypes(const int nbondtypes, Memory *memory);
@ -76,7 +75,7 @@ class DihedralHarmonicIntel : public DihedralHarmonic {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -42,27 +42,26 @@ class DihedralOPLSIntel : public DihedralOPLS {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k1, k2, k3, k4; } fc_packed1; typedef struct {
flt_t k1, k2, k3, k4;
} fc_packed1;
fc_packed1 *bp; fc_packed1 *bp;
ForceConst() : _nbondtypes(0) {} ForceConst() : _nbondtypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nbondtypes, Memory *memory); void set_ntypes(const int nbondtypes, Memory *memory);
@ -75,7 +74,7 @@ class DihedralOPLSIntel : public DihedralOPLS {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,11 +25,11 @@ FixStyle(INTEL,FixIntel);
#ifndef LMP_FIX_INTEL_H #ifndef LMP_FIX_INTEL_H
#define LMP_FIX_INTEL_H #define LMP_FIX_INTEL_H
#include "fix.h"
#include "intel_buffers.h"
#include "force.h"
#include "pair.h"
#include "error.h" #include "error.h"
#include "fix.h"
#include "force.h"
#include "intel_buffers.h"
#include "pair.h"
#include "update.h" #include "update.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -48,13 +48,12 @@ class FixIntel : public Fix {
void setup_pre_reverse(int eflag = 0, int vflag = 0); void setup_pre_reverse(int eflag = 0, int vflag = 0);
bool pair_hybrid_check(); bool pair_hybrid_check();
void pair_init_check(const bool cdmessage=false); void pair_init_check(const bool cdmessage = false);
void bond_init_check(); void bond_init_check();
void kspace_init_check(); void kspace_init_check();
void pre_reverse(int eflag = 0, int vflag = 0); void pre_reverse(int eflag = 0, int vflag = 0);
inline void min_pre_reverse(int eflag = 0, int vflag = 0) inline void min_pre_reverse(int eflag = 0, int vflag = 0) { pre_reverse(eflag, vflag); }
{ pre_reverse(eflag, vflag); }
void post_run() { _print_pkg_info = 1; } void post_run() { _print_pkg_info = 1; }
@ -63,45 +62,55 @@ class FixIntel : public Fix {
double memory_usage(); double memory_usage();
typedef struct { double x,y,z; } lmp_ft; typedef struct {
double x, y, z;
} lmp_ft;
enum {PREC_MODE_SINGLE, PREC_MODE_MIXED, PREC_MODE_DOUBLE}; enum { PREC_MODE_SINGLE, PREC_MODE_MIXED, PREC_MODE_DOUBLE };
inline int precision() { return _precision_mode; } inline int precision() { return _precision_mode; }
inline IntelBuffers<float,float> * get_single_buffers() inline IntelBuffers<float, float> *get_single_buffers() { return _single_buffers; }
{ return _single_buffers; } inline IntelBuffers<float, double> *get_mixed_buffers() { return _mixed_buffers; }
inline IntelBuffers<float,double> * get_mixed_buffers() inline IntelBuffers<double, double> *get_double_buffers() { return _double_buffers; }
{ return _mixed_buffers; }
inline IntelBuffers<double,double> * get_double_buffers()
{ return _double_buffers; }
inline int nbor_pack_width() const { return _nbor_pack_width; } inline int nbor_pack_width() const { return _nbor_pack_width; }
inline void nbor_pack_width(const int w) { _nbor_pack_width = w; } inline void nbor_pack_width(const int w) { _nbor_pack_width = w; }
inline int three_body_neighbor() { return _three_body_neighbor; } inline int three_body_neighbor() { return _three_body_neighbor; }
inline void three_body_neighbor(const int i) { _three_body_neighbor = i; } inline void three_body_neighbor(const int i) { _three_body_neighbor = i; }
inline int need_zero(const int tid) { inline int need_zero(const int tid)
if (_need_reduce == 0 && tid > 0) return 1; {
else if (_zero_master && tid == 0) { _zero_master = 0; return 1; } if (_need_reduce == 0 && tid > 0)
else return 0; return 1;
else if (_zero_master && tid == 0) {
_zero_master = 0;
return 1;
} else
return 0;
} }
inline void set_reduce_flag() { if (_nthreads > 1) _need_reduce = 1; } inline void set_reduce_flag()
inline int lrt() { {
if (_nthreads > 1) _need_reduce = 1;
}
inline int lrt()
{
if (force->kspace_match("^pppm/.*intel$", 0) && update->whichflag == 1) if (force->kspace_match("^pppm/.*intel$", 0) && update->whichflag == 1)
return _lrt; return _lrt;
else return 0; else
return 0;
} }
inline int pppm_table() { inline int pppm_table()
{
if (force->kspace_match("^pppm/.*intel$", 0)) if (force->kspace_match("^pppm/.*intel$", 0))
return INTEL_P3M_TABLE; return INTEL_P3M_TABLE;
else return 0; else
return 0;
} }
protected: protected:
IntelBuffers<float,float> *_single_buffers; IntelBuffers<float, float> *_single_buffers;
IntelBuffers<float,double> *_mixed_buffers; IntelBuffers<float, double> *_mixed_buffers;
IntelBuffers<double,double> *_double_buffers; IntelBuffers<double, double> *_double_buffers;
int _precision_mode, _nthreads, _nbor_pack_width, _three_body_neighbor; int _precision_mode, _nthreads, _nbor_pack_width, _three_body_neighbor;
int _pair_intel_count, _pair_hybrid_flag, _print_pkg_info; int _pair_intel_count, _pair_hybrid_flag, _print_pkg_info;
@ -109,24 +118,20 @@ class FixIntel : public Fix {
int _pair_hybrid_zero, _hybrid_nonpair, _zero_master; int _pair_hybrid_zero, _hybrid_nonpair, _zero_master;
public: public:
inline int* get_overflow_flag() { return _overflow_flag; } inline int *get_overflow_flag() { return _overflow_flag; }
inline int* get_off_overflow_flag() { return _off_overflow_flag; } inline int *get_off_overflow_flag() { return _off_overflow_flag; }
inline void add_result_array(IntelBuffers<double,double>::vec3_acc_t *f_in, inline void add_result_array(IntelBuffers<double, double>::vec3_acc_t *f_in, double *ev_in,
double *ev_in, const int offload, const int offload, const int eatom = 0, const int vatom = 0,
const int eatom = 0, const int vatom = 0,
const int rflag = 0); const int rflag = 0);
inline void add_result_array(IntelBuffers<float,double>::vec3_acc_t *f_in, inline void add_result_array(IntelBuffers<float, double>::vec3_acc_t *f_in, double *ev_in,
double *ev_in, const int offload, const int offload, const int eatom = 0, const int vatom = 0,
const int eatom = 0, const int vatom = 0,
const int rflag = 0); const int rflag = 0);
inline void add_result_array(IntelBuffers<float,float>::vec3_acc_t *f_in, inline void add_result_array(IntelBuffers<float, float>::vec3_acc_t *f_in, float *ev_in,
float *ev_in, const int offload, const int offload, const int eatom = 0, const int vatom = 0,
const int eatom = 0, const int vatom = 0,
const int rflag = 0); const int rflag = 0);
inline void get_buffern(const int offload, int &nlocal, int &nall, inline void get_buffern(const int offload, int &nlocal, int &nall, int &minlocal);
int &minlocal);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
void post_force(int vflag); void post_force(int vflag);
inline int coprocessor_number() { return _cop; } inline int coprocessor_number() { return _cop; }
inline int full_host_list() { return _full_host_list; } inline int full_host_list() { return _full_host_list; }
@ -135,9 +140,19 @@ class FixIntel : public Fix {
inline int offload_end_neighbor(); inline int offload_end_neighbor();
inline int offload_end_pair(); inline int offload_end_pair();
inline int host_start_neighbor() inline int host_start_neighbor()
{ if (_offload_noghost) return 0; else return offload_end_neighbor(); } {
if (_offload_noghost)
return 0;
else
return offload_end_neighbor();
}
inline int host_start_pair() inline int host_start_pair()
{ if (_offload_noghost) return 0; else return offload_end_pair(); } {
if (_offload_noghost)
return 0;
else
return offload_end_pair();
}
inline int offload_nlocal() { return _offload_nlocal; } inline int offload_nlocal() { return _offload_nlocal; }
inline int offload_nall() { return _offload_nall; } inline int offload_nall() { return _offload_nall; }
inline int offload_min_ghost() { return _offload_min_ghost; } inline int offload_min_ghost() { return _offload_min_ghost; }
@ -149,18 +164,19 @@ class FixIntel : public Fix {
inline int separate_buffers() { return _separate_buffers; } inline int separate_buffers() { return _separate_buffers; }
inline int offload_noghost() { return _offload_noghost; } inline int offload_noghost() { return _offload_noghost; }
inline void set_offload_noghost(const int v) inline void set_offload_noghost(const int v)
{ if (_offload_ghost < 0) _offload_noghost = v; } {
if (_offload_ghost < 0) _offload_noghost = v;
}
inline void set_neighbor_host_sizes(); inline void set_neighbor_host_sizes();
inline void zero_timers() inline void zero_timers() { memset(_timers, 0, sizeof(double) * NUM_ITIMERS); }
{ memset(_timers, 0, sizeof(double) * NUM_ITIMERS); }
inline void start_watch(const int which) { _stopwatch[which] = MPI_Wtime(); } inline void start_watch(const int which) { _stopwatch[which] = MPI_Wtime(); }
inline double stop_watch(const int which); inline double stop_watch(const int which);
inline double * off_watch_pair() { return _stopwatch_offload_pair; } inline double *off_watch_pair() { return _stopwatch_offload_pair; }
inline double * off_watch_neighbor() { return _stopwatch_offload_neighbor; } inline double *off_watch_neighbor() { return _stopwatch_offload_neighbor; }
inline void balance_stamp(); inline void balance_stamp();
inline void acc_timers(); inline void acc_timers();
#else #else
inline int offload_end_neighbor() { return 0; } inline int offload_end_neighbor() { return 0; }
inline int offload_end_pair() { return 0; } inline int offload_end_pair() { return 0; }
inline int host_start_neighbor() { return 0; } inline int host_start_neighbor() { return 0; }
@ -168,27 +184,27 @@ class FixIntel : public Fix {
inline void zero_timers() {} inline void zero_timers() {}
inline void start_watch(const int /*which*/) {} inline void start_watch(const int /*which*/) {}
inline double stop_watch(const int /*which*/) { return 0.0; } inline double stop_watch(const int /*which*/) { return 0.0; }
double * off_watch_pair() { return nullptr; } double *off_watch_pair() { return nullptr; }
double * off_watch_neighbor() { return nullptr; } double *off_watch_neighbor() { return nullptr; }
inline void balance_stamp() {} inline void balance_stamp() {}
inline void acc_timers() {} inline void acc_timers() {}
inline int separate_buffers() { return 0; } inline int separate_buffers() { return 0; }
#endif #endif
protected: protected:
int _overflow_flag[5]; int _overflow_flag[5];
_alignvar(int _off_overflow_flag[5],64); _alignvar(int _off_overflow_flag[5], 64);
int _allow_separate_buffers, _offload_ghost, _lrt; int _allow_separate_buffers, _offload_ghost, _lrt;
IntelBuffers<float,float>::vec3_acc_t *_force_array_s; IntelBuffers<float, float>::vec3_acc_t *_force_array_s;
IntelBuffers<float,double>::vec3_acc_t *_force_array_m; IntelBuffers<float, double>::vec3_acc_t *_force_array_m;
IntelBuffers<double,double>::vec3_acc_t *_force_array_d; IntelBuffers<double, double>::vec3_acc_t *_force_array_d;
float *_ev_array_s; float *_ev_array_s;
double *_ev_array_d; double *_ev_array_d;
int _results_eatom, _results_vatom; int _results_eatom, _results_vatom;
int _need_reduce; int _need_reduce;
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
double _balance_pair_time, _balance_other_time; double _balance_pair_time, _balance_other_time;
int _offload_nlocal, _offload_nall, _offload_min_ghost, _offload_nghost; int _offload_nlocal, _offload_nall, _offload_min_ghost, _offload_nghost;
int _host_min_local, _host_min_ghost, _host_nall; int _host_min_local, _host_min_ghost, _host_nall;
@ -198,9 +214,9 @@ class FixIntel : public Fix {
void output_timing_data(); void output_timing_data();
FILE *_tscreen; FILE *_tscreen;
IntelBuffers<float,float>::vec3_acc_t *_off_force_array_s; IntelBuffers<float, float>::vec3_acc_t *_off_force_array_s;
IntelBuffers<float,double>::vec3_acc_t *_off_force_array_m; IntelBuffers<float, double>::vec3_acc_t *_off_force_array_m;
IntelBuffers<double,double>::vec3_acc_t *_off_force_array_d; IntelBuffers<double, double>::vec3_acc_t *_off_force_array_d;
float *_off_ev_array_s; float *_off_ev_array_s;
double *_off_ev_array_d; double *_off_ev_array_d;
int _off_results_eatom, _off_results_vatom; int _off_results_eatom, _off_results_vatom;
@ -208,48 +224,42 @@ class FixIntel : public Fix {
int get_ppn(int &); int get_ppn(int &);
int set_host_affinity(const int); int set_host_affinity(const int);
#endif #endif
void check_neighbor_intel(); void check_neighbor_intel();
double _offload_balance, _balance_neighbor, _balance_pair, _balance_fixed; double _offload_balance, _balance_neighbor, _balance_pair, _balance_fixed;
double _timers[NUM_ITIMERS]; double _timers[NUM_ITIMERS];
double _stopwatch[NUM_ITIMERS]; double _stopwatch[NUM_ITIMERS];
_alignvar(double _stopwatch_offload_neighbor[1],64); _alignvar(double _stopwatch_offload_neighbor[1], 64);
_alignvar(double _stopwatch_offload_pair[1],64); _alignvar(double _stopwatch_offload_pair[1], 64);
void _sync_main_arrays(const int prereverse); void _sync_main_arrays(const int prereverse);
template <class ft> template <class ft> void reduce_results(ft *_noalias const f_in);
void reduce_results(ft * _noalias const f_in);
template <class ft, class acc_t> template <class ft, class acc_t>
inline void add_results(const ft * _noalias const f_in, inline void add_results(const ft *_noalias const f_in, const acc_t *_noalias const ev_global,
const acc_t * _noalias const ev_global, const int eatom, const int vatom, const int offload);
const int eatom, const int vatom,
const int offload);
template <class ft, class acc_t> template <class ft, class acc_t>
inline void add_oresults(const ft * _noalias const f_in, inline void add_oresults(const ft *_noalias const f_in, const acc_t *_noalias const ev_global,
const acc_t * _noalias const ev_global, const int eatom, const int vatom, const int out_offset, const int nall);
const int eatom, const int vatom,
const int out_offset, const int nall);
int _offload_affinity_balanced, _offload_threads, _offload_tpc; int _offload_affinity_balanced, _offload_threads, _offload_tpc;
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _max_offload_threads, _offload_cores, _offload_affinity_set; int _max_offload_threads, _offload_cores, _offload_affinity_set;
int _im_real_space_task; int _im_real_space_task;
MPI_Comm _real_space_comm; MPI_Comm _real_space_comm;
template <class ft, class acc_t> template <class ft, class acc_t>
inline void add_off_results(const ft * _noalias const f_in, inline void add_off_results(const ft *_noalias const f_in, const acc_t *_noalias const ev_global);
const acc_t * _noalias const ev_global); #endif
#endif
}; };
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIntel::get_buffern(const int offload, int &nlocal, int &nall, void FixIntel::get_buffern(const int offload, int &nlocal, int &nall, int &minlocal)
int &minlocal) { {
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
if (_separate_buffers) { if (_separate_buffers) {
if (offload) { if (offload) {
if (neighbor->ago != 0) { if (neighbor->ago != 0) {
@ -273,7 +283,7 @@ void FixIntel::get_buffern(const int offload, int &nlocal, int &nall,
if (_offload_noghost && offload) if (_offload_noghost && offload)
nall = atom->nlocal; nall = atom->nlocal;
else else
#endif #endif
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
nlocal = atom->nlocal; nlocal = atom->nlocal;
minlocal = 0; minlocal = 0;
@ -281,102 +291,97 @@ void FixIntel::get_buffern(const int offload, int &nlocal, int &nall,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIntel::add_result_array(IntelBuffers<double,double>::vec3_acc_t *f_in, void FixIntel::add_result_array(IntelBuffers<double, double>::vec3_acc_t *f_in, double *ev_in,
double *ev_in, const int offload, const int offload, const int eatom, const int vatom,
const int eatom, const int vatom, const int rflag)
const int rflag) { {
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
if (offload) { if (offload) {
_off_results_eatom = eatom; _off_results_eatom = eatom;
_off_results_vatom = vatom; _off_results_vatom = vatom;
_off_force_array_d = f_in; _off_force_array_d = f_in;
_off_ev_array_d = ev_in; _off_ev_array_d = ev_in;
if (_pair_hybrid_flag && force->pair->fdotr_is_set()) if (_pair_hybrid_flag && force->pair->fdotr_is_set()) _sync_main_arrays(1);
_sync_main_arrays(1);
return; return;
} }
#endif #endif
_force_array_d = f_in; _force_array_d = f_in;
_ev_array_d = ev_in; _ev_array_d = ev_in;
_results_eatom = eatom; _results_eatom = eatom;
_results_vatom = vatom; _results_vatom = vatom;
#ifndef _LMP_INTEL_OFFLOAD #ifndef _LMP_INTEL_OFFLOAD
if (rflag != 2 && _nthreads > 1 && force->newton) _need_reduce = 1; if (rflag != 2 && _nthreads > 1 && force->newton) _need_reduce = 1;
#endif #endif
if (_overflow_flag[LMP_OVERFLOW]) if (_overflow_flag[LMP_OVERFLOW])
error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
if (_pair_hybrid_flag > 1 || if (_pair_hybrid_flag > 1 || (_pair_hybrid_flag && force->pair->fdotr_is_set()))
(_pair_hybrid_flag && force->pair->fdotr_is_set())) _sync_main_arrays(0);
}
/* ---------------------------------------------------------------------- */
void FixIntel::add_result_array(IntelBuffers<float,double>::vec3_acc_t *f_in,
double *ev_in, const int offload,
const int eatom, const int vatom,
const int rflag) {
#ifdef _LMP_INTEL_OFFLOAD
if (offload) {
_off_results_eatom = eatom;
_off_results_vatom = vatom;
_off_force_array_m = f_in;
_off_ev_array_d = ev_in;
if (_pair_hybrid_flag && force->pair->fdotr_is_set())
_sync_main_arrays(1);
return;
}
#endif
_force_array_m = f_in;
_ev_array_d = ev_in;
_results_eatom = eatom;
_results_vatom = vatom;
#ifndef _LMP_INTEL_OFFLOAD
if (rflag != 2 && _nthreads > 1 && force->newton) _need_reduce = 1;
#endif
if (_overflow_flag[LMP_OVERFLOW])
error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
if (_pair_hybrid_flag > 1 ||
(_pair_hybrid_flag && force->pair->fdotr_is_set()))
_sync_main_arrays(0); _sync_main_arrays(0);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIntel::add_result_array(IntelBuffers<float,float>::vec3_acc_t *f_in, void FixIntel::add_result_array(IntelBuffers<float, double>::vec3_acc_t *f_in, double *ev_in,
float *ev_in, const int offload, const int offload, const int eatom, const int vatom,
const int eatom, const int vatom, const int rflag)
const int rflag) { {
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
if (offload) {
_off_results_eatom = eatom;
_off_results_vatom = vatom;
_off_force_array_m = f_in;
_off_ev_array_d = ev_in;
if (_pair_hybrid_flag && force->pair->fdotr_is_set()) _sync_main_arrays(1);
return;
}
#endif
_force_array_m = f_in;
_ev_array_d = ev_in;
_results_eatom = eatom;
_results_vatom = vatom;
#ifndef _LMP_INTEL_OFFLOAD
if (rflag != 2 && _nthreads > 1 && force->newton) _need_reduce = 1;
#endif
if (_overflow_flag[LMP_OVERFLOW])
error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
if (_pair_hybrid_flag > 1 || (_pair_hybrid_flag && force->pair->fdotr_is_set()))
_sync_main_arrays(0);
}
/* ---------------------------------------------------------------------- */
void FixIntel::add_result_array(IntelBuffers<float, float>::vec3_acc_t *f_in, float *ev_in,
const int offload, const int eatom, const int vatom,
const int rflag)
{
#ifdef _LMP_INTEL_OFFLOAD
if (offload) { if (offload) {
_off_results_eatom = eatom; _off_results_eatom = eatom;
_off_results_vatom = vatom; _off_results_vatom = vatom;
_off_force_array_s = f_in; _off_force_array_s = f_in;
_off_ev_array_s = ev_in; _off_ev_array_s = ev_in;
if (_pair_hybrid_flag && force->pair->fdotr_is_set()) if (_pair_hybrid_flag && force->pair->fdotr_is_set()) _sync_main_arrays(1);
_sync_main_arrays(1);
return; return;
} }
#endif #endif
_force_array_s = f_in; _force_array_s = f_in;
_ev_array_s = ev_in; _ev_array_s = ev_in;
_results_eatom = eatom; _results_eatom = eatom;
_results_vatom = vatom; _results_vatom = vatom;
#ifndef _LMP_INTEL_OFFLOAD #ifndef _LMP_INTEL_OFFLOAD
if (rflag != 2 && _nthreads > 1 && force->newton) _need_reduce = 1; if (rflag != 2 && _nthreads > 1 && force->newton) _need_reduce = 1;
#endif #endif
if (_overflow_flag[LMP_OVERFLOW]) if (_overflow_flag[LMP_OVERFLOW])
error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
if (_pair_hybrid_flag > 1 || if (_pair_hybrid_flag > 1 || (_pair_hybrid_flag && force->pair->fdotr_is_set()))
(_pair_hybrid_flag && force->pair->fdotr_is_set()))
_sync_main_arrays(0); _sync_main_arrays(0);
} }
@ -386,10 +391,10 @@ void FixIntel::add_result_array(IntelBuffers<float,float>::vec3_acc_t *f_in,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixIntel::offload_end_neighbor() { int FixIntel::offload_end_neighbor()
{
if (_offload_balance < 0.0) { if (_offload_balance < 0.0) {
if (atom->nlocal < 2) if (atom->nlocal < 2) error->one(FLERR, "Too few atoms for load balancing offload");
error->one(FLERR,"Too few atoms for load balancing offload");
double granularity = 1.0 / atom->nlocal; double granularity = 1.0 / atom->nlocal;
if (_balance_neighbor < granularity) if (_balance_neighbor < granularity)
_balance_neighbor = granularity + 1e-10; _balance_neighbor = granularity + 1e-10;
@ -399,14 +404,18 @@ int FixIntel::offload_end_neighbor() {
return _balance_neighbor * atom->nlocal; return _balance_neighbor * atom->nlocal;
} }
int FixIntel::offload_end_pair() { int FixIntel::offload_end_pair()
if (neighbor->ago == 0) return _balance_neighbor * atom->nlocal; {
else return _balance_pair * atom->nlocal; if (neighbor->ago == 0)
return _balance_neighbor * atom->nlocal;
else
return _balance_pair * atom->nlocal;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double FixIntel::stop_watch(const int which) { double FixIntel::stop_watch(const int which)
{
double elapsed = MPI_Wtime() - _stopwatch[which]; double elapsed = MPI_Wtime() - _stopwatch[which];
_timers[which] += elapsed; _timers[which] += elapsed;
return elapsed; return elapsed;
@ -414,7 +423,8 @@ double FixIntel::stop_watch(const int which) {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIntel::balance_stamp() { void FixIntel::balance_stamp()
{
if (_offload_balance < 0.0) { if (_offload_balance < 0.0) {
double ct = MPI_Wtime(); double ct = MPI_Wtime();
_balance_other_time = ct; _balance_other_time = ct;
@ -424,7 +434,8 @@ void FixIntel::balance_stamp() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIntel::acc_timers() { void FixIntel::acc_timers()
{
_timers[TIME_OFFLOAD_PAIR] += *_stopwatch_offload_pair; _timers[TIME_OFFLOAD_PAIR] += *_stopwatch_offload_pair;
if (neighbor->ago == 0) { if (neighbor->ago == 0) {
_timers[TIME_OFFLOAD_NEIGHBOR] += *_stopwatch_offload_neighbor; _timers[TIME_OFFLOAD_NEIGHBOR] += *_stopwatch_offload_neighbor;
@ -437,7 +448,8 @@ void FixIntel::acc_timers() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIntel::set_neighbor_host_sizes() { void FixIntel::set_neighbor_host_sizes()
{
_host_min_local = _overflow_flag[LMP_LOCAL_MIN]; _host_min_local = _overflow_flag[LMP_LOCAL_MIN];
_host_min_ghost = _overflow_flag[LMP_GHOST_MIN]; _host_min_ghost = _overflow_flag[LMP_GHOST_MIN];
_host_used_local = atom->nlocal - _host_min_local; _host_used_local = atom->nlocal - _host_min_local;
@ -450,7 +462,7 @@ void FixIntel::set_neighbor_host_sizes() {
#endif #endif
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -35,7 +35,7 @@ class FixNPTIntel : public FixNHIntel {
~FixNPTIntel() {} ~FixNPTIntel() {}
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -46,7 +46,7 @@ class FixNVEAsphereIntel : public FixNVE {
class AtomVecEllipsoid *avec; class AtomVecEllipsoid *avec;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -44,7 +44,7 @@ class FixNVEIntel : public FixNVE {
int _nlocal3, _nlocal_max; int _nlocal3, _nlocal_max;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -35,7 +35,7 @@ class FixNVTIntel : public FixNHIntel {
~FixNVTIntel() {} ~FixNVTIntel() {}
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -41,7 +41,7 @@ class FixNVTSllodIntel : public FixNHIntel {
void nh_v_temp(); void nh_v_temp();
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif
@ -70,4 +70,3 @@ E: Using fix nvt/sllod with no fix deform defined
Self-explanatory. Self-explanatory.
*/ */

View File

@ -25,8 +25,8 @@ ImproperStyle(cvff/intel,ImproperCvffIntel);
#ifndef LMP_IMPROPER_CVFF_INTEL_H #ifndef LMP_IMPROPER_CVFF_INTEL_H
#define LMP_IMPROPER_CVFF_INTEL_H #define LMP_IMPROPER_CVFF_INTEL_H
#include "improper_cvff.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "improper_cvff.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -42,27 +42,27 @@ class ImproperCvffIntel : public ImproperCvff {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k; int sign, multiplicity; } fc_packed1; typedef struct {
flt_t k;
int sign, multiplicity;
} fc_packed1;
fc_packed1 *fc; fc_packed1 *fc;
ForceConst() : _nimpropertypes(0) {} ForceConst() : _nimpropertypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nimpropertypes, Memory *memory); void set_ntypes(const int nimpropertypes, Memory *memory);
@ -75,7 +75,7 @@ class ImproperCvffIntel : public ImproperCvff {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ ImproperStyle(harmonic/intel,ImproperHarmonicIntel);
#ifndef LMP_IMPROPER_HARMONIC_INTEL_H #ifndef LMP_IMPROPER_HARMONIC_INTEL_H
#define LMP_IMPROPER_HARMONIC_INTEL_H #define LMP_IMPROPER_HARMONIC_INTEL_H
#include "improper_harmonic.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "improper_harmonic.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -42,27 +42,26 @@ class ImproperHarmonicIntel : public ImproperHarmonic {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, int NEWTON_BOND, class flt_t, class acc_t>
void eval(const int vflag, IntelBuffers<flt_t,acc_t> * buffers, void eval(const int vflag, IntelBuffers<flt_t, acc_t> *buffers, const ForceConst<flt_t> &fc);
const ForceConst<flt_t> &fc);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t k, chi; } fc_packed1; typedef struct {
flt_t k, chi;
} fc_packed1;
fc_packed1 *fc; fc_packed1 *fc;
ForceConst() : _nimpropertypes(0) {} ForceConst() : _nimpropertypes(0) {}
~ForceConst() { set_ntypes(0, nullptr); } ~ForceConst() { set_ntypes(0, nullptr); }
void set_ntypes(const int nimpropertypes, Memory *memory); void set_ntypes(const int nimpropertypes, Memory *memory);
@ -75,7 +74,7 @@ class ImproperHarmonicIntel : public ImproperHarmonic {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -23,9 +23,9 @@ NBinStyle(intel,
#ifndef LMP_NBIN_INTEL_H #ifndef LMP_NBIN_INTEL_H
#define LMP_NBIN_INTEL_H #define LMP_NBIN_INTEL_H
#include "nbin_standard.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "memory.h" #include "memory.h"
#include "nbin_standard.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -35,7 +35,7 @@ class NBinIntel : public NBinStandard {
~NBinIntel(); ~NBinIntel();
void bin_atoms_setup(int); void bin_atoms_setup(int);
void bin_atoms(); void bin_atoms();
int * get_binpacked() { return _binpacked; } int *get_binpacked() { return _binpacked; }
private: private:
FixIntel *_fix; FixIntel *_fix;
@ -43,15 +43,14 @@ class NBinIntel : public NBinStandard {
int _precision_mode; int _precision_mode;
double memory_usage(); double memory_usage();
template <class flt_t, class acc_t> template <class flt_t, class acc_t> void bin_atoms(IntelBuffers<flt_t, acc_t> *);
void bin_atoms(IntelBuffers<flt_t,acc_t> *);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _cop, _offload_alloc; int _cop, _offload_alloc;
#endif #endif
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -37,16 +37,16 @@ class NPairFullBinGhostIntel : public NPairIntel {
NPairFullBinGhostIntel(class LAMMPS *); NPairFullBinGhostIntel(class LAMMPS *);
~NPairFullBinGhostIntel() {} ~NPairFullBinGhostIntel() {}
void build(class NeighList *); void build(class NeighList *);
private: private:
template<class flt_t, class acc_t> template <class flt_t, class acc_t>
void fbi(NeighList * list, IntelBuffers<flt_t,acc_t> * buffers); void fbi(NeighList *list, IntelBuffers<flt_t, acc_t> *buffers);
template<class flt_t, class acc_t, int need_ic> template <class flt_t, class acc_t, int need_ic>
void fbi(const int offload, NeighList * list, void fbi(const int offload, NeighList *list, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const int astart, const int aend); const int astart, const int aend);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -24,8 +24,8 @@ NPairStyle(full/bin/intel,
#ifndef LMP_NPAIR_FULL_BIN_INTEL_H #ifndef LMP_NPAIR_FULL_BIN_INTEL_H
#define LMP_NPAIR_FULL_BIN_INTEL_H #define LMP_NPAIR_FULL_BIN_INTEL_H
#include "npair_intel.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "npair_intel.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -36,11 +36,10 @@ class NPairFullBinIntel : public NPairIntel {
void build(class NeighList *); void build(class NeighList *);
private: private:
template <class flt_t, class acc_t> template <class flt_t, class acc_t> void fbi(NeighList *, IntelBuffers<flt_t, acc_t> *);
void fbi(NeighList *, IntelBuffers<flt_t,acc_t> *);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -23,8 +23,8 @@ NPairStyle(half/bin/newton/intel,
#ifndef LMP_NPAIR_HALF_BIN_NEWTON_INTEL_H #ifndef LMP_NPAIR_HALF_BIN_NEWTON_INTEL_H
#define LMP_NPAIR_HALF_BIN_NEWTON_INTEL_H #define LMP_NPAIR_HALF_BIN_NEWTON_INTEL_H
#include "npair_intel.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "npair_intel.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -35,11 +35,10 @@ class NPairHalfBinNewtonIntel : public NPairIntel {
void build(class NeighList *); void build(class NeighList *);
private: private:
template <class flt_t, class acc_t> template <class flt_t, class acc_t> void hbni(NeighList *, IntelBuffers<flt_t, acc_t> *);
void hbni(NeighList *, IntelBuffers<flt_t,acc_t> *);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -23,8 +23,8 @@ NPairStyle(half/bin/newton/tri/intel,
#ifndef LMP_NPAIR_HALF_BIN_NEWTON_INTEL_TRI_H #ifndef LMP_NPAIR_HALF_BIN_NEWTON_INTEL_TRI_H
#define LMP_NPAIR_HALF_BIN_NEWTON_INTEL_TRI_H #define LMP_NPAIR_HALF_BIN_NEWTON_INTEL_TRI_H
#include "npair_intel.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "npair_intel.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -35,11 +35,10 @@ class NPairHalfBinNewtonTriIntel : public NPairIntel {
void build(class NeighList *); void build(class NeighList *);
private: private:
template <class flt_t, class acc_t> template <class flt_t, class acc_t> void hbnti(NeighList *, IntelBuffers<flt_t, acc_t> *);
void hbnti(NeighList *, IntelBuffers<flt_t,acc_t> *);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -33,14 +33,13 @@ NPairStyle(halffull/newton/skip/intel,
#ifndef LMP_NPAIR_HALFFULL_NEWTON_INTEL_H #ifndef LMP_NPAIR_HALFFULL_NEWTON_INTEL_H
#define LMP_NPAIR_HALFFULL_NEWTON_INTEL_H #define LMP_NPAIR_HALFFULL_NEWTON_INTEL_H
#include "npair.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "npair.h"
#if defined(_OPENMP) #if defined(_OPENMP)
#include <omp.h> #include <omp.h>
#endif #endif
namespace LAMMPS_NS { namespace LAMMPS_NS {
class NPairHalffullNewtonIntel : public NPair { class NPairHalffullNewtonIntel : public NPair {
@ -52,14 +51,12 @@ class NPairHalffullNewtonIntel : public NPair {
protected: protected:
FixIntel *_fix; FixIntel *_fix;
template<class flt_t, class acc_t> template <class flt_t, class acc_t> void build_t(NeighList *, IntelBuffers<flt_t, acc_t> *);
void build_t(NeighList *, IntelBuffers<flt_t,acc_t> *);
template<class flt_t> template <class flt_t> void build_t3(NeighList *, int *);
void build_t3(NeighList *, int *);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -31,14 +31,13 @@ NPairStyle(skip/ghost/intel,
#ifndef LMP_NPAIR_SKIP_INTEL_H #ifndef LMP_NPAIR_SKIP_INTEL_H
#define LMP_NPAIR_SKIP_INTEL_H #define LMP_NPAIR_SKIP_INTEL_H
#include "npair.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "npair.h"
#if defined(_OPENMP) #if defined(_OPENMP)
#include <omp.h> #include <omp.h>
#endif #endif
namespace LAMMPS_NS { namespace LAMMPS_NS {
class NPairSkipIntel : public NPair { class NPairSkipIntel : public NPair {
@ -52,11 +51,11 @@ class NPairSkipIntel : public NPair {
FixIntel *_fix; FixIntel *_fix;
int *_inum_starts, *_inum_counts, *_full_props; int *_inum_starts, *_inum_counts, *_full_props;
template<class flt_t, int THREE> template <class flt_t, int THREE>
void build_t(NeighList *, int *numhalf, int *cnumneigh, int *numhalf_skip); void build_t(NeighList *, int *numhalf, int *cnumneigh, int *numhalf_skip);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,14 +25,13 @@ PairStyle(airebo/intel,PairAIREBOIntel);
#ifndef LMP_PAIR_AIREBO_INTEL_H #ifndef LMP_PAIR_AIREBO_INTEL_H
#define LMP_PAIR_AIREBO_INTEL_H #define LMP_PAIR_AIREBO_INTEL_H
#include "pair.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair.h"
#include "pair_airebo.h" #include "pair_airebo.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
template<class flt_t, class acc_t> template <class flt_t, class acc_t> struct PairAIREBOIntelParam;
struct PairAIREBOIntelParam;
class PairAIREBOIntel : public PairAIREBO { class PairAIREBOIntel : public PairAIREBO {
public: public:
@ -40,32 +39,28 @@ class PairAIREBOIntel : public PairAIREBO {
virtual ~PairAIREBOIntel(); virtual ~PairAIREBOIntel();
virtual void compute(int, int); virtual void compute(int, int);
virtual void init_style(); virtual void init_style();
protected:
protected:
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers); void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers);
template <int EVFLAG, int EFLAG, class flt_t, class acc_t> template <int EVFLAG, int EFLAG, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const int astart, const int aend); const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t> void pack_force_const(IntelBuffers<flt_t, acc_t> *buffers);
void pack_force_const(IntelBuffers<flt_t,acc_t> * buffers);
template <class flt_t, class acc_t> template <class flt_t, class acc_t> PairAIREBOIntelParam<flt_t, acc_t> get_param();
PairAIREBOIntelParam<flt_t,acc_t> get_param();
FixIntel * fix; FixIntel *fix;
int _cop; int _cop;
int * REBO_cnumneigh; int *REBO_cnumneigh;
int * REBO_num_skin; int *REBO_num_skin;
int * REBO_list_data; int *REBO_list_data;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -35,7 +35,7 @@ class PairAIREBOMorseIntel : public PairAIREBOIntel {
virtual void settings(int, char **); virtual void settings(int, char **);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -26,8 +26,8 @@ PairStyle(buck/coul/cut/intel,PairBuckCoulCutIntel);
#ifndef LMP_PAIR_BUCK_COUL_CUT_INTEL_H #ifndef LMP_PAIR_BUCK_COUL_CUT_INTEL_H
#define LMP_PAIR_BUCK_COUL_CUT_INTEL_H #define LMP_PAIR_BUCK_COUL_CUT_INTEL_H
#include "pair_buck_coul_cut.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_buck_coul_cut.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -38,7 +38,10 @@ class PairBuckCoulCutIntel : public PairBuckCoulCut {
virtual ~PairBuckCoulCutIntel(); virtual ~PairBuckCoulCutIntel();
virtual void compute(int, int); virtual void compute(int, int);
void init_style(); void init_style();
typedef struct { float x, y, z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
@ -47,36 +50,38 @@ class PairBuckCoulCutIntel : public PairBuckCoulCut {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> * buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t buck1, buck2, rhoinv, pad; } c_force_t; typedef struct {
typedef struct { flt_t cutsq, cut_ljsq, cut_coulsq, pad; } c_cut_t; flt_t buck1, buck2, rhoinv, pad;
typedef struct { flt_t a, c, offset, pad; } c_energy_t; } c_force_t;
_alignvar(flt_t special_coul[4],64); typedef struct {
_alignvar(flt_t special_lj[4],64); flt_t cutsq, cut_ljsq, cut_coulsq, pad;
} c_cut_t;
typedef struct {
flt_t a, c, offset, pad;
} c_energy_t;
_alignvar(flt_t special_coul[4], 64);
_alignvar(flt_t special_lj[4], 64);
c_force_t **c_force; c_force_t **c_force;
c_energy_t **c_energy; c_energy_t **c_energy;
c_cut_t **c_cut; c_cut_t **c_cut;
ForceConst() : _ntypes(0), _ntable(0) {} ForceConst() : _ntypes(0), _ntable(0) {}
~ForceConst() { set_ntypes(0,0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int ntable, Memory *memory, void set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop);
const int cop);
private: private:
int _ntypes, _ntable, _cop; int _ntypes, _ntable, _cop;
@ -86,7 +91,7 @@ class PairBuckCoulCutIntel : public PairBuckCoulCut {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif // LMP_PAIR_BUCK_COUL_CUT_INTEL_H #endif // LMP_PAIR_BUCK_COUL_CUT_INTEL_H
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(buck/coul/long/intel,PairBuckCoulLongIntel);
#ifndef LMP_PAIR_BUCK_COUL_LONG_INTEL_H #ifndef LMP_PAIR_BUCK_COUL_LONG_INTEL_H
#define LMP_PAIR_BUCK_COUL_LONG_INTEL_H #define LMP_PAIR_BUCK_COUL_LONG_INTEL_H
#include "pair_buck_coul_long.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_buck_coul_long.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -37,7 +37,10 @@ class PairBuckCoulLongIntel : public PairBuckCoulLong {
virtual ~PairBuckCoulLongIntel(); virtual ~PairBuckCoulLongIntel();
virtual void compute(int, int); virtual void compute(int, int);
void init_style(); void init_style();
typedef struct { float x, y, z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
@ -46,26 +49,29 @@ class PairBuckCoulLongIntel : public PairBuckCoulLong {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> * buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t cutsq, cut_ljsq, buck1, buck2; } c_force_t; typedef struct {
typedef struct { flt_t a, c, offset, pad; } c_energy_t; flt_t cutsq, cut_ljsq, buck1, buck2;
typedef struct { flt_t r, dr, f, df; } table_t; } c_force_t;
_alignvar(flt_t special_coul[4],64); typedef struct {
_alignvar(flt_t special_lj[4],64); flt_t a, c, offset, pad;
} c_energy_t;
typedef struct {
flt_t r, dr, f, df;
} table_t;
_alignvar(flt_t special_coul[4], 64);
_alignvar(flt_t special_lj[4], 64);
flt_t g_ewald, tabinnersq; flt_t g_ewald, tabinnersq;
c_force_t **c_force; c_force_t **c_force;
c_energy_t **c_energy; c_energy_t **c_energy;
@ -74,10 +80,9 @@ class PairBuckCoulLongIntel : public PairBuckCoulLong {
flt_t *etable, *detable, *ctable, *dctable; flt_t *etable, *detable, *ctable, *dctable;
ForceConst() : _ntypes(0), _ntable(0) {} ForceConst() : _ntypes(0), _ntable(0) {}
~ForceConst() { set_ntypes(0,0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int ntable, Memory *memory, void set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop);
const int cop);
private: private:
int _ntypes, _ntable, _cop; int _ntypes, _ntable, _cop;
@ -87,7 +92,7 @@ class PairBuckCoulLongIntel : public PairBuckCoulLong {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif // LMP_PAIR_BUCK_COUL_LONG_INTEL_H #endif // LMP_PAIR_BUCK_COUL_LONG_INTEL_H
#endif #endif

View File

@ -25,57 +25,60 @@ PairStyle(buck/intel,PairBuckIntel);
#ifndef LMP_PAIR_BUCK_INTEL_H #ifndef LMP_PAIR_BUCK_INTEL_H
#define LMP_PAIR_BUCK_INTEL_H #define LMP_PAIR_BUCK_INTEL_H
#include "pair_buck.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_buck.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class PairBuckIntel : public PairBuck { class PairBuckIntel : public PairBuck {
public: public:
PairBuckIntel(class LAMMPS *); PairBuckIntel(class LAMMPS *);
virtual ~PairBuckIntel(); virtual ~PairBuckIntel();
virtual void compute(int, int); virtual void compute(int, int);
void init_style(); void init_style();
typedef struct { float x, y, z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
int _cop; int _cop;
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> * buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t buck1, buck2, rhoinv, cutsq; } c_force_t; typedef struct {
typedef struct { flt_t a, c, offset, pad; } c_energy_t; flt_t buck1, buck2, rhoinv, cutsq;
_alignvar(flt_t special_lj[4],64); } c_force_t;
typedef struct {
flt_t a, c, offset, pad;
} c_energy_t;
_alignvar(flt_t special_lj[4], 64);
c_force_t **c_force; c_force_t **c_force;
c_energy_t **c_energy; c_energy_t **c_energy;
ForceConst() : _ntypes(0) {} ForceConst() : _ntypes(0) {}
~ForceConst() { set_ntypes(0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, nullptr, _cop); }
void set_ntypes(const int ntypes, Memory *memory, void set_ntypes(const int ntypes, Memory *memory, const int cop);
const int cop);
private: private:
int _ntypes, _cop; int _ntypes, _cop;
Memory *_memory; Memory *_memory;
}; };
@ -84,7 +87,7 @@ private:
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif // LMP_PAIR_BUCK_INTEL_H #endif // LMP_PAIR_BUCK_INTEL_H
#endif #endif

View File

@ -26,8 +26,8 @@ PairStyle(dpd/intel,PairDPDIntel);
#ifndef LMP_PAIR_DPD_INTEL_H #ifndef LMP_PAIR_DPD_INTEL_H
#define LMP_PAIR_DPD_INTEL_H #define LMP_PAIR_DPD_INTEL_H
#include "pair_dpd.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_dpd.h"
#ifdef LMP_USE_MKL_RNG #ifdef LMP_USE_MKL_RNG
#include "mkl_vsl.h" #include "mkl_vsl.h"
@ -52,42 +52,41 @@ class PairDPDIntel : public PairDPD {
FixIntel *fix; FixIntel *fix;
int _cop, _onetype, _nrandom_thread; int _cop, _onetype, _nrandom_thread;
#ifdef LMP_USE_MKL_RNG #ifdef LMP_USE_MKL_RNG
VSLStreamStatePtr *random_thread; VSLStreamStatePtr *random_thread;
#else #else
RanMars **random_thread; RanMars **random_thread;
#endif #endif
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int ONETYPE, int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int ONETYPE, int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t icut, a0, gamma, sigma; } fc_packed1; typedef struct {
flt_t icut, a0, gamma, sigma;
} fc_packed1;
_alignvar(flt_t special_lj[4],64); _alignvar(flt_t special_lj[4], 64);
fc_packed1 **param; fc_packed1 **param;
flt_t **rand_buffer_thread; flt_t **rand_buffer_thread;
int *rngi; int *rngi;
ForceConst() : _ntypes(0) {} ForceConst() : _ntypes(0) {}
~ForceConst() { set_ntypes(0, 0, 0, nullptr, _cop); } ~ForceConst() { set_ntypes(0, 0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int nthreads, const int max_nbors, void set_ntypes(const int ntypes, const int nthreads, const int max_nbors, Memory *memory,
Memory *memory, const int cop); const int cop);
private: private:
int _ntypes, _cop; int _ntypes, _cop;
@ -97,7 +96,7 @@ class PairDPDIntel : public PairDPD {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -38,7 +38,7 @@ class PairEAMAlloyIntel : virtual public PairEAMIntel {
void file2array(); void file2array();
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -38,7 +38,7 @@ class PairEAMFSIntel : virtual public PairEAMIntel {
void file2array(); void file2array();
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -21,15 +21,14 @@ PairStyle(eam/intel,PairEAMIntel);
#ifndef LMP_PAIR_EAM_INTEL_H #ifndef LMP_PAIR_EAM_INTEL_H
#define LMP_PAIR_EAM_INTEL_H #define LMP_PAIR_EAM_INTEL_H
#include "pair_eam.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_eam.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class PairEAMIntel : public PairEAM { class PairEAMIntel : public PairEAM {
public: public:
friend class FixSemiGrandCanonicalMC; // Alex Stukowski option friend class FixSemiGrandCanonicalMC; // Alex Stukowski option
PairEAMIntel(class LAMMPS *); PairEAMIntel(class LAMMPS *);
virtual ~PairEAMIntel(); virtual ~PairEAMIntel();
@ -39,53 +38,49 @@ class PairEAMIntel : public PairEAM {
void unpack_forward_comm(int, int, double *); void unpack_forward_comm(int, int, double *);
protected: protected:
FixIntel *fix; FixIntel *fix;
int _cop, _onetype, _ccache_stride; int _cop, _onetype, _ccache_stride;
float *fp_float; float *fp_float;
template <class flt_t> template <class flt_t> int pack_forward_comm(int, int *, double *, flt_t *);
int pack_forward_comm(int, int *, double *, flt_t *); template <class flt_t> void unpack_forward_comm(int, int, double *, flt_t *);
template <class flt_t>
void unpack_forward_comm(int, int, double *, flt_t *);
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int ONETYPE, int EFLAG, int NEWTON_PAIR, class flt_t, template <int ONETYPE, int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
class acc_t> void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
void eval(const int offload, const int vflag,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst { public:
public: typedef struct {
typedef struct { flt_t a, b, c, d; } fc_packed1; flt_t a, b, c, d;
typedef struct { flt_t a, b, c, d, e, f, g, h; } fc_packed2; } fc_packed1;
typedef struct {
flt_t a, b, c, d, e, f, g, h;
} fc_packed2;
flt_t **scale_f; flt_t **scale_f;
fc_packed1 *rhor_spline_f, *rhor_spline_e; fc_packed1 *rhor_spline_f, *rhor_spline_e;
fc_packed1 *frho_spline_f, *frho_spline_e; fc_packed1 *frho_spline_f, *frho_spline_e;
fc_packed2 *z2r_spline_t; fc_packed2 *z2r_spline_t;
ForceConst() : _ntypes(0), _nr(0) {} ForceConst() : _ntypes(0), _nr(0) {}
~ForceConst() { set_ntypes(0, 0, 0, nullptr, _cop); } ~ForceConst() { set_ntypes(0, 0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int nr, const int nrho, void set_ntypes(const int ntypes, const int nr, const int nrho, Memory *memory, const int cop);
Memory *memory, const int cop);
inline int rhor_jstride() const { return _nr; } inline int rhor_jstride() const { return _nr; }
inline int rhor_istride() const { return _nr * _ntypes; } inline int rhor_istride() const { return _nr * _ntypes; }
inline int frho_stride() const { return _nrho; } inline int frho_stride() const { return _nrho; }
private: private:
int _ntypes, _nr, _nrho, _cop; int _ntypes, _nr, _nrho, _cop;
Memory *_memory; Memory *_memory;
}; };
@ -93,7 +88,7 @@ class PairEAMIntel : public PairEAM {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(gayberne/intel,PairGayBerneIntel);
#ifndef LMP_PAIR_GAYBERNE_INTEL_H #ifndef LMP_PAIR_GAYBERNE_INTEL_H
#define LMP_PAIR_GAYBERNE_INTEL_H #define LMP_PAIR_GAYBERNE_INTEL_H
#include "pair_gayberne.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_gayberne.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -42,31 +42,32 @@ class PairGayBerneIntel : public PairGayBerne {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { typedef struct {
flt_t cutsq, lj1, lj2, offset, sigma, epsilon, lshape; flt_t cutsq, lj1, lj2, offset, sigma, epsilon, lshape;
int form; int form;
} fc_packed1; } fc_packed1;
typedef struct { flt_t lj3, lj4; } fc_packed2; typedef struct {
typedef struct { flt_t shape2[4], well[4]; } fc_packed3; flt_t lj3, lj4;
} fc_packed2;
typedef struct {
flt_t shape2[4], well[4];
} fc_packed3;
_alignvar(flt_t special_lj[4],64); _alignvar(flt_t special_lj[4], 64);
_alignvar(flt_t gamma,64); _alignvar(flt_t gamma, 64);
_alignvar(flt_t upsilon,64); _alignvar(flt_t upsilon, 64);
_alignvar(flt_t mu,64); _alignvar(flt_t mu, 64);
fc_packed1 **ijc; fc_packed1 **ijc;
fc_packed2 **lj34; fc_packed2 **lj34;
fc_packed3 *ic; fc_packed3 *ic;
@ -74,11 +75,11 @@ class PairGayBerneIntel : public PairGayBerne {
flt_t **rsq_form, **delx_form, **dely_form, **delz_form; flt_t **rsq_form, **delx_form, **dely_form, **delz_form;
int **jtype_form, **jlist_form; int **jtype_form, **jlist_form;
ForceConst() : _ntypes(0) {} ForceConst() : _ntypes(0) {}
~ForceConst() { set_ntypes(0, 0, 0, nullptr, _cop); } ~ForceConst() { set_ntypes(0, 0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int one_length, void set_ntypes(const int ntypes, const int one_length, const int nthreads, Memory *memory,
const int nthreads, Memory *memory, const int cop); const int cop);
private: private:
int _ntypes, _cop; int _ntypes, _cop;
@ -89,15 +90,14 @@ class PairGayBerneIntel : public PairGayBerne {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
int _max_nbors; int _max_nbors;
double gayberne_lj(const int i, const int j, double a1[3][3], double gayberne_lj(const int i, const int j, double a1[3][3], double b1[3][3], double g1[3][3],
double b1[3][3], double g1[3][3], double *r12, double *r12, const double rsq, double *fforce, double *ttor);
const double rsq, double *fforce, double *ttor);
FixIntel *fix; FixIntel *fix;
int _cop; int _cop;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(lj/charmm/coul/charmm/intel,PairLJCharmmCoulCharmmIntel);
#ifndef LMP_PAIR_LJ_CHARMM_COUL_CHARMM_INTEL_H #ifndef LMP_PAIR_LJ_CHARMM_COUL_CHARMM_INTEL_H
#define LMP_PAIR_LJ_CHARMM_COUL_CHARMM_INTEL_H #define LMP_PAIR_LJ_CHARMM_COUL_CHARMM_INTEL_H
#include "pair_lj_charmm_coul_charmm.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_lj_charmm_coul_charmm.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -39,7 +39,10 @@ class PairLJCharmmCoulCharmmIntel : public PairLJCharmmCoulCharmm {
virtual void compute(int, int); virtual void compute(int, int);
void init_style(); void init_style();
typedef struct { float x,y,z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
@ -47,30 +50,27 @@ class PairLJCharmmCoulCharmmIntel : public PairLJCharmmCoulCharmm {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
_alignvar(flt_t special_coul[4],64); _alignvar(flt_t special_coul[4], 64);
_alignvar(flt_t special_lj[4],64); _alignvar(flt_t special_lj[4], 64);
flt_t **cutsq; flt_t **cutsq;
flt_t cut_coulsq, cut_ljsq; flt_t cut_coulsq, cut_ljsq;
flt_t cut_coul_innersq, cut_lj_innersq; flt_t cut_coul_innersq, cut_lj_innersq;
typename IntelBuffers<flt_t,flt_t>::vec4_t **lj; typename IntelBuffers<flt_t, flt_t>::vec4_t **lj;
ForceConst() : _ntypes(0) {} ForceConst() : _ntypes(0) {}
~ForceConst() { set_ntypes(0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, nullptr, _cop); }
void set_ntypes(const int ntypes, Memory *memory, const int cop); void set_ntypes(const int ntypes, Memory *memory, const int cop);
@ -82,7 +82,7 @@ class PairLJCharmmCoulCharmmIntel : public PairLJCharmmCoulCharmm {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(lj/charmm/coul/long/intel,PairLJCharmmCoulLongIntel);
#ifndef LMP_PAIR_LJ_CHARMM_COUL_LONG_INTEL_H #ifndef LMP_PAIR_LJ_CHARMM_COUL_LONG_INTEL_H
#define LMP_PAIR_LJ_CHARMM_COUL_LONG_INTEL_H #define LMP_PAIR_LJ_CHARMM_COUL_LONG_INTEL_H
#include "pair_lj_charmm_coul_long.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_lj_charmm_coul_long.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -39,7 +39,10 @@ class PairLJCharmmCoulLongIntel : public PairLJCharmmCoulLong {
virtual void compute(int, int); virtual void compute(int, int);
void init_style(); void init_style();
typedef struct { float x,y,z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
@ -47,36 +50,34 @@ class PairLJCharmmCoulLongIntel : public PairLJCharmmCoulLong {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t r, dr, f, df; } table_t; typedef struct {
_alignvar(flt_t special_coul[4],64); flt_t r, dr, f, df;
_alignvar(flt_t special_lj[4],64); } table_t;
_alignvar(flt_t special_coul[4], 64);
_alignvar(flt_t special_lj[4], 64);
flt_t **cutsq, g_ewald, tabinnersq; flt_t **cutsq, g_ewald, tabinnersq;
flt_t cut_coulsq, cut_ljsq; flt_t cut_coulsq, cut_ljsq;
flt_t cut_lj_innersq; flt_t cut_lj_innersq;
table_t *table; table_t *table;
flt_t *etable, *detable, *ctable, *dctable; flt_t *etable, *detable, *ctable, *dctable;
typename IntelBuffers<flt_t,flt_t>::vec2_t **lj; typename IntelBuffers<flt_t, flt_t>::vec2_t **lj;
ForceConst() : _ntypes(0), _ntable(0) {} ForceConst() : _ntypes(0), _ntable(0) {}
~ForceConst() { set_ntypes(0,0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int ntable, Memory *memory, void set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop);
const int cop);
private: private:
int _ntypes, _ntable, _cop; int _ntypes, _ntable, _cop;
@ -86,7 +87,7 @@ class PairLJCharmmCoulLongIntel : public PairLJCharmmCoulLong {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(lj/cut/coul/long/intel,PairLJCutCoulLongIntel);
#ifndef LMP_PAIR_LJ_CUT_COUL_LONG_INTEL_H #ifndef LMP_PAIR_LJ_CUT_COUL_LONG_INTEL_H
#define LMP_PAIR_LJ_CUT_COUL_LONG_INTEL_H #define LMP_PAIR_LJ_CUT_COUL_LONG_INTEL_H
#include "pair_lj_cut_coul_long.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_lj_cut_coul_long.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -39,7 +39,10 @@ class PairLJCutCoulLongIntel : public PairLJCutCoulLong {
virtual void compute(int, int); virtual void compute(int, int);
void init_style(); void init_style();
typedef struct { float x,y,z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
@ -47,26 +50,29 @@ class PairLJCutCoulLongIntel : public PairLJCutCoulLong {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t cutsq, cut_ljsq, lj1, lj2; } c_force_t; typedef struct {
typedef struct { flt_t lj3, lj4, offset, pad; } c_energy_t; flt_t cutsq, cut_ljsq, lj1, lj2;
typedef struct { flt_t r, dr, f, df; } table_t; } c_force_t;
_alignvar(flt_t special_coul[4],64); typedef struct {
_alignvar(flt_t special_lj[4],64); flt_t lj3, lj4, offset, pad;
} c_energy_t;
typedef struct {
flt_t r, dr, f, df;
} table_t;
_alignvar(flt_t special_coul[4], 64);
_alignvar(flt_t special_lj[4], 64);
flt_t g_ewald, tabinnersq; flt_t g_ewald, tabinnersq;
c_force_t **c_force; c_force_t **c_force;
c_energy_t **c_energy; c_energy_t **c_energy;
@ -74,10 +80,9 @@ class PairLJCutCoulLongIntel : public PairLJCutCoulLong {
flt_t *etable, *detable, *ctable, *dctable; flt_t *etable, *detable, *ctable, *dctable;
ForceConst() : _ntypes(0), _ntable(0) {} ForceConst() : _ntypes(0), _ntable(0) {}
~ForceConst() { set_ntypes(0,0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, 0, nullptr, _cop); }
void set_ntypes(const int ntypes, const int ntable, Memory *memory, void set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop);
const int cop);
private: private:
int _ntypes, _ntable, _cop; int _ntypes, _ntable, _cop;
@ -87,7 +92,7 @@ class PairLJCutCoulLongIntel : public PairLJCutCoulLong {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(lj/cut/intel,PairLJCutIntel);
#ifndef LMP_PAIR_LJ_CUT_INTEL_H #ifndef LMP_PAIR_LJ_CUT_INTEL_H
#define LMP_PAIR_LJ_CUT_INTEL_H #define LMP_PAIR_LJ_CUT_INTEL_H
#include "pair_lj_cut.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_lj_cut.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -44,30 +44,31 @@ class PairLJCutIntel : public PairLJCut {
template <class flt_t> class ForceConst; template <class flt_t> class ForceConst;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int ONETYPE, int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t> template <int ONETYPE, int EFLAG, int NEWTON_PAIR, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t cutsq, lj1, lj2, offset; } fc_packed1; typedef struct {
typedef struct { flt_t lj3, lj4; } fc_packed2; flt_t cutsq, lj1, lj2, offset;
} fc_packed1;
typedef struct {
flt_t lj3, lj4;
} fc_packed2;
_alignvar(flt_t special_lj[4],64); _alignvar(flt_t special_lj[4], 64);
fc_packed1 **ljc12o; fc_packed1 **ljc12o;
fc_packed2 **lj34; fc_packed2 **lj34;
ForceConst() : _ntypes(0) {} ForceConst() : _ntypes(0) {}
~ForceConst() { set_ntypes(0, nullptr, _cop); } ~ForceConst() { set_ntypes(0, nullptr, _cop); }
void set_ntypes(const int ntypes, Memory *memory, const int cop); void set_ntypes(const int ntypes, Memory *memory, const int cop);
@ -80,7 +81,7 @@ class PairLJCutIntel : public PairLJCut {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,16 +25,15 @@ PairStyle(lj/long/coul/long/intel,PairLJLongCoulLongIntel);
#ifndef LMP_PAIR_LJ_LONG_COUL_LONG_INTEL_H #ifndef LMP_PAIR_LJ_LONG_COUL_LONG_INTEL_H
#define LMP_PAIR_LJ_LONG_COUL_LONG_INTEL_H #define LMP_PAIR_LJ_LONG_COUL_LONG_INTEL_H
#include "pair_lj_long_coul_long.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_lj_long_coul_long.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class PairLJLongCoulLongIntel : public PairLJLongCoulLong { class PairLJLongCoulLongIntel : public PairLJLongCoulLong {
public: public:
PairLJLongCoulLongIntel(class LAMMPS *); PairLJLongCoulLongIntel(class LAMMPS *);
virtual ~PairLJLongCoulLongIntel(); virtual ~PairLJLongCoulLongIntel();
};
}; } // namespace LAMMPS_NS
}
#endif #endif
#endif #endif

View File

@ -35,7 +35,7 @@ class PairREBOIntel : public PairAIREBOIntel {
virtual void settings(int, char **); virtual void settings(int, char **);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -25,8 +25,8 @@ PairStyle(sw/intel,PairSWIntel);
#ifndef LMP_PAIR_SW_INTEL_H #ifndef LMP_PAIR_SW_INTEL_H
#define LMP_PAIR_SW_INTEL_H #define LMP_PAIR_SW_INTEL_H
#include "pair_sw.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair_sw.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -45,26 +45,23 @@ class PairSWIntel : public PairSW {
virtual void allocate(); virtual void allocate();
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int SPQ, int ONETYPE, int EFLAG, class flt_t, class acc_t> template <int SPQ, int ONETYPE, int EFLAG, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers, const ForceConst<flt_t> &fc, const ForceConst<flt_t> &fc, const int astart, const int aend);
const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
int _ccache_stride, _spq, _onetype, _onetype3; int _ccache_stride, _spq, _onetype, _onetype3;
#ifdef LMP_USE_AVXCD #ifdef LMP_USE_AVXCD
int _ccache_stride3; int _ccache_stride3;
#endif #endif
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { typedef struct {
flt_t cutsq, cut, sigma_gamma, pad; flt_t cutsq, cut, sigma_gamma, pad;
@ -88,7 +85,7 @@ class PairSWIntel : public PairSW {
fc_packed2 **p2e; fc_packed2 **p2e;
fc_packed3 ***p3; fc_packed3 ***p3;
ForceConst() : p2(0), p2f(0), p2f2(0), p2e(0), p3(0), _ntypes(0) {} ForceConst() : p2(0), p2f(0), p2f2(0), p2e(0), p3(0), _ntypes(0) {}
~ForceConst() { set_ntypes(0, nullptr, _cop); } ~ForceConst() { set_ntypes(0, nullptr, _cop); }
void set_ntypes(const int ntypes, Memory *memory, const int cop); void set_ntypes(const int ntypes, Memory *memory, const int cop);
@ -101,7 +98,7 @@ class PairSWIntel : public PairSW {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -24,8 +24,8 @@ PairStyle(tersoff/intel,PairTersoffIntel);
#ifndef LMP_PAIR_TERSOFF_INTEL_H #ifndef LMP_PAIR_TERSOFF_INTEL_H
#define LMP_PAIR_TERSOFF_INTEL_H #define LMP_PAIR_TERSOFF_INTEL_H
#include "pair.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pair.h"
#include "pair_tersoff.h" #include "pair_tersoff.h"
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
@ -39,38 +39,52 @@ class PairTersoffIntel : public PairTersoff {
void init_style(); void init_style();
protected: protected:
typedef struct { float x,y,z; int w; } sng4_t; typedef struct {
float x, y, z;
int w;
} sng4_t;
private: private:
FixIntel *fix; FixIntel *fix;
int _cop; int _cop;
public: // wo needs secrets? public: // wo needs secrets?
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
template <class flt_t> template <class flt_t> class ForceConst {
class ForceConst {
public: public:
typedef struct { flt_t cutsq; } c_cutoff_t; typedef struct {
typedef struct { flt_t bigr, bigd, lam1, biga; } c_first_loop_t; flt_t cutsq;
typedef struct { flt_t lam2, beta, bigb, powern, c1, c2, c3, c4; } c_second_loop_t; } c_cutoff_t;
typedef struct { flt_t lam3, bigr, bigd, c2, d2, h, gamma, powermint; } c_inner_loop_t; typedef struct {
typedef struct { flt_t cutsq, pad[3]; flt_t bigr, bigd, lam1, biga;
flt_t bigr, bigd, lam1, biga; } c_first_loop_t;
flt_t lam2, beta, bigb, powern; typedef struct {
flt_t c1, c2, c3, c4; } c_outer_t; flt_t lam2, beta, bigb, powern, c1, c2, c3, c4;
typedef struct { flt_t cutsq, pad[7]; } c_second_loop_t;
flt_t lam3, powermint, bigr, bigd; typedef struct {
flt_t c2, d2, h, gamma; } c_inner_t; flt_t lam3, bigr, bigd, c2, d2, h, gamma, powermint;
c_cutoff_t * * c_cutoff_outer; } c_inner_loop_t;
c_cutoff_t * * * c_cutoff_inner; typedef struct {
c_first_loop_t * * c_first_loop; flt_t cutsq, pad[3];
c_second_loop_t * * c_second_loop; flt_t bigr, bigd, lam1, biga;
c_inner_loop_t * * * c_inner_loop; flt_t lam2, beta, bigb, powern;
c_outer_t * * c_outer; flt_t c1, c2, c3, c4;
c_inner_t * * * c_inner; } c_outer_t;
typedef struct {
flt_t cutsq, pad[7];
flt_t lam3, powermint, bigr, bigd;
flt_t c2, d2, h, gamma;
} c_inner_t;
c_cutoff_t **c_cutoff_outer;
c_cutoff_t ***c_cutoff_inner;
c_first_loop_t **c_first_loop;
c_second_loop_t **c_second_loop;
c_inner_loop_t ***c_inner_loop;
c_outer_t **c_outer;
c_inner_t ***c_inner;
ForceConst() : _ntypes(0) {} ForceConst() : _ntypes(0) {}
~ForceConst() { set_ntypes(0,nullptr,_cop); } ~ForceConst() { set_ntypes(0, nullptr, _cop); }
void set_ntypes(const int ntypes, Memory *memory, const int cop); void set_ntypes(const int ntypes, Memory *memory, const int cop);
@ -82,20 +96,18 @@ class PairTersoffIntel : public PairTersoff {
ForceConst<double> force_const_double; ForceConst<double> force_const_double;
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void compute(int eflag, int vflag, IntelBuffers<flt_t,acc_t> *buffers, void compute(int eflag, int vflag, IntelBuffers<flt_t, acc_t> *buffers,
const ForceConst<flt_t> &fc); const ForceConst<flt_t> &fc);
template <int EFLAG, class flt_t, class acc_t> template <int EFLAG, class flt_t, class acc_t>
void eval(const int offload, const int vflag, void eval(const int offload, const int vflag, IntelBuffers<flt_t, acc_t> *buffers,
IntelBuffers<flt_t,acc_t> * buffers,
const ForceConst<flt_t> &fc, const int astart, const int aend); const ForceConst<flt_t> &fc, const int astart, const int aend);
template <class flt_t, class acc_t> template <class flt_t, class acc_t>
void pack_force_const(ForceConst<flt_t> &fc, void pack_force_const(ForceConst<flt_t> &fc, IntelBuffers<flt_t, acc_t> *buffers);
IntelBuffers<flt_t, acc_t> *buffers);
}; };
} } // namespace LAMMPS_NS
#endif // __INTEL_COMPILER #endif // __INTEL_COMPILER
#endif #endif
#endif #endif

View File

@ -25,212 +25,204 @@ KSpaceStyle(pppm/disp/intel,PPPMDispIntel);
#ifndef LMP_PPPMINTEL_DISP_H #ifndef LMP_PPPMINTEL_DISP_H
#define LMP_PPPMINTEL_DISP_H #define LMP_PPPMINTEL_DISP_H
#include "pppm_disp.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pppm_disp.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class PPPMDispIntel : public PPPMDisp { class PPPMDispIntel : public PPPMDisp {
public: public:
PPPMDispIntel(class LAMMPS *); PPPMDispIntel(class LAMMPS *);
virtual ~PPPMDispIntel(); virtual ~PPPMDispIntel();
virtual void init(); virtual void init();
virtual void compute(int, int); virtual void compute(int, int);
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int use_base(); int use_base();
#endif
protected:
FixIntel *fix;
int _use_lrt;
FFT_SCALAR **perthread_density;
FFT_SCALAR *particle_ekx;
FFT_SCALAR *particle_eky;
FFT_SCALAR *particle_ekz;
FFT_SCALAR *particle_ekx0;
FFT_SCALAR *particle_eky0;
FFT_SCALAR *particle_ekz0;
FFT_SCALAR *particle_ekx1;
FFT_SCALAR *particle_eky1;
FFT_SCALAR *particle_ekz1;
FFT_SCALAR *particle_ekx2;
FFT_SCALAR *particle_eky2;
FFT_SCALAR *particle_ekz2;
FFT_SCALAR *particle_ekx3;
FFT_SCALAR *particle_eky3;
FFT_SCALAR *particle_ekz3;
FFT_SCALAR *particle_ekx4;
FFT_SCALAR *particle_eky4;
FFT_SCALAR *particle_ekz4;
FFT_SCALAR *particle_ekx5;
FFT_SCALAR *particle_eky5;
FFT_SCALAR *particle_ekz5;
FFT_SCALAR *particle_ekx6;
FFT_SCALAR *particle_eky6;
FFT_SCALAR *particle_ekz6;
int _use_table;
int rho_points;
FFT_SCALAR **rho_lookup;
FFT_SCALAR **rho6_lookup;
FFT_SCALAR **drho_lookup;
FFT_SCALAR **drho6_lookup;
FFT_SCALAR half_rho_scale, half_rho_scale_plus;
int _use_packing;
#ifdef _LMP_INTEL_OFFLOAD
int _use_base;
#endif
template<class flt_t, class acc_t>
void particle_map(double, double, double,
double, int **, int, int,
int, int, int,
int, int, int,
IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t, int use_table>
void make_rho_c(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void make_rho_c(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
make_rho_c<flt_t,acc_t,1>(buffers);
} else {
make_rho_c<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void make_rho_g(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void make_rho_g(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
make_rho_g<flt_t,acc_t,1>(buffers);
} else {
make_rho_g<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void make_rho_a(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void make_rho_a(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
make_rho_a<flt_t,acc_t,1>(buffers);
} else {
make_rho_a<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void make_rho_none(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void make_rho_none(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
make_rho_none<flt_t,acc_t,1>(buffers);
} else {
make_rho_none<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_c_ik(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_c_ik(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_c_ik<flt_t,acc_t,1>(buffers);
} else {
fieldforce_c_ik<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_c_ad(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_c_ad(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_c_ad<flt_t,acc_t,1>(buffers);
} else {
fieldforce_c_ad<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_g_ik(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_g_ik(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_g_ik<flt_t,acc_t,1>(buffers);
} else {
fieldforce_g_ik<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_g_ad(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_g_ad(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_g_ad<flt_t,acc_t,1>(buffers);
} else {
fieldforce_g_ad<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_a_ik(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_a_ik(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_a_ik<flt_t,acc_t,1>(buffers);
} else {
fieldforce_a_ik<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_a_ad(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_a_ad(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_a_ad<flt_t,acc_t,1>(buffers);
} else {
fieldforce_a_ad<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_none_ik(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_none_ik(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_none_ik<flt_t,acc_t,1>(buffers);
} else {
fieldforce_none_ik<flt_t,acc_t,0>(buffers);
}
}
template<class flt_t, class acc_t, int use_table>
void fieldforce_none_ad(IntelBuffers<flt_t,acc_t> *buffers);
template<class flt_t, class acc_t>
void fieldforce_none_ad(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) {
fieldforce_none_ad<flt_t,acc_t,1>(buffers);
} else {
fieldforce_none_ad<flt_t,acc_t,0>(buffers);
}
}
void precompute_rho();
};
}
#endif
#endif #endif
protected:
FixIntel *fix;
int _use_lrt;
FFT_SCALAR **perthread_density;
FFT_SCALAR *particle_ekx;
FFT_SCALAR *particle_eky;
FFT_SCALAR *particle_ekz;
FFT_SCALAR *particle_ekx0;
FFT_SCALAR *particle_eky0;
FFT_SCALAR *particle_ekz0;
FFT_SCALAR *particle_ekx1;
FFT_SCALAR *particle_eky1;
FFT_SCALAR *particle_ekz1;
FFT_SCALAR *particle_ekx2;
FFT_SCALAR *particle_eky2;
FFT_SCALAR *particle_ekz2;
FFT_SCALAR *particle_ekx3;
FFT_SCALAR *particle_eky3;
FFT_SCALAR *particle_ekz3;
FFT_SCALAR *particle_ekx4;
FFT_SCALAR *particle_eky4;
FFT_SCALAR *particle_ekz4;
FFT_SCALAR *particle_ekx5;
FFT_SCALAR *particle_eky5;
FFT_SCALAR *particle_ekz5;
FFT_SCALAR *particle_ekx6;
FFT_SCALAR *particle_eky6;
FFT_SCALAR *particle_ekz6;
int _use_table;
int rho_points;
FFT_SCALAR **rho_lookup;
FFT_SCALAR **rho6_lookup;
FFT_SCALAR **drho_lookup;
FFT_SCALAR **drho6_lookup;
FFT_SCALAR half_rho_scale, half_rho_scale_plus;
int _use_packing;
#ifdef _LMP_INTEL_OFFLOAD
int _use_base;
#endif
template <class flt_t, class acc_t>
void particle_map(double, double, double, double, int **, int, int, int, int, int, int, int, int,
IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t, int use_table>
void make_rho_c(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void make_rho_c(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
make_rho_c<flt_t, acc_t, 1>(buffers);
} else {
make_rho_c<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void make_rho_g(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void make_rho_g(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
make_rho_g<flt_t, acc_t, 1>(buffers);
} else {
make_rho_g<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void make_rho_a(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void make_rho_a(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
make_rho_a<flt_t, acc_t, 1>(buffers);
} else {
make_rho_a<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void make_rho_none(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void make_rho_none(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
make_rho_none<flt_t, acc_t, 1>(buffers);
} else {
make_rho_none<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_c_ik(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_c_ik(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_c_ik<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_c_ik<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_c_ad(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_c_ad(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_c_ad<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_c_ad<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_g_ik(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_g_ik(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_g_ik<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_g_ik<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_g_ad(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_g_ad(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_g_ad<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_g_ad<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_a_ik(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_a_ik(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_a_ik<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_a_ik<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_a_ad(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_a_ad(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_a_ad<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_a_ad<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_none_ik(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_none_ik(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_none_ik<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_none_ik<flt_t, acc_t, 0>(buffers);
}
}
template <class flt_t, class acc_t, int use_table>
void fieldforce_none_ad(IntelBuffers<flt_t, acc_t> *buffers);
template <class flt_t, class acc_t> void fieldforce_none_ad(IntelBuffers<flt_t, acc_t> *buffers)
{
if (_use_table == 1) {
fieldforce_none_ad<flt_t, acc_t, 1>(buffers);
} else {
fieldforce_none_ad<flt_t, acc_t, 0>(buffers);
}
}
void precompute_rho();
};
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -28,8 +28,8 @@ KSpaceStyle(pppm/intel,PPPMIntel);
#ifndef LMP_PPPMINTEL_H #ifndef LMP_PPPMINTEL_H
#define LMP_PPPMINTEL_H #define LMP_PPPMINTEL_H
#include "pppm.h"
#include "fix_intel.h" #include "fix_intel.h"
#include "pppm.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -44,9 +44,9 @@ class PPPMIntel : public PPPM {
void compute_second(int, int); void compute_second(int, int);
void pack_buffers(); void pack_buffers();
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int use_base(); int use_base();
#endif #endif
protected: protected:
FixIntel *fix; FixIntel *fix;
@ -63,53 +63,50 @@ class PPPMIntel : public PPPM {
FFT_SCALAR **drho_lookup; FFT_SCALAR **drho_lookup;
FFT_SCALAR half_rho_scale, half_rho_scale_plus; FFT_SCALAR half_rho_scale, half_rho_scale_plus;
#ifdef _LMP_INTEL_OFFLOAD #ifdef _LMP_INTEL_OFFLOAD
int _use_base; int _use_base;
#endif #endif
virtual void allocate(); virtual void allocate();
template<class flt_t, class acc_t> template <class flt_t, class acc_t> void test_function(IntelBuffers<flt_t, acc_t> *buffers);
void test_function(IntelBuffers<flt_t,acc_t> *buffers);
void precompute_rho(); void precompute_rho();
template<class flt_t, class acc_t> template <class flt_t, class acc_t> void particle_map(IntelBuffers<flt_t, acc_t> *buffers);
void particle_map(IntelBuffers<flt_t,acc_t> *buffers); template <class flt_t, class acc_t, int use_table>
template<class flt_t, class acc_t, int use_table> void make_rho(IntelBuffers<flt_t, acc_t> *buffers);
void make_rho(IntelBuffers<flt_t,acc_t> *buffers); template <class flt_t, class acc_t> void make_rho(IntelBuffers<flt_t, acc_t> *buffers)
template<class flt_t, class acc_t> {
void make_rho(IntelBuffers<flt_t,acc_t> *buffers) {
if (_use_table == 1) { if (_use_table == 1) {
make_rho<flt_t,acc_t,1>(buffers); make_rho<flt_t, acc_t, 1>(buffers);
} else { } else {
make_rho<flt_t,acc_t,0>(buffers); make_rho<flt_t, acc_t, 0>(buffers);
} }
} }
template<class flt_t, class acc_t, int use_table> template <class flt_t, class acc_t, int use_table>
void fieldforce_ik(IntelBuffers<flt_t,acc_t> *buffers); void fieldforce_ik(IntelBuffers<flt_t, acc_t> *buffers);
template<class flt_t, class acc_t> template <class flt_t, class acc_t> void fieldforce_ik(IntelBuffers<flt_t, acc_t> *buffers)
void fieldforce_ik(IntelBuffers<flt_t,acc_t> *buffers) { {
if (_use_table == 1) { if (_use_table == 1) {
fieldforce_ik<flt_t, acc_t, 1>(buffers); fieldforce_ik<flt_t, acc_t, 1>(buffers);
} else { } else {
fieldforce_ik<flt_t, acc_t, 0>(buffers); fieldforce_ik<flt_t, acc_t, 0>(buffers);
} }
} }
template<class flt_t, class acc_t, int use_table> template <class flt_t, class acc_t, int use_table>
void fieldforce_ad(IntelBuffers<flt_t,acc_t> *buffers); void fieldforce_ad(IntelBuffers<flt_t, acc_t> *buffers);
template<class flt_t, class acc_t> template <class flt_t, class acc_t> void fieldforce_ad(IntelBuffers<flt_t, acc_t> *buffers)
void fieldforce_ad(IntelBuffers<flt_t,acc_t> *buffers) { {
if (_use_table == 1) { if (_use_table == 1) {
fieldforce_ad<flt_t,acc_t,1>(buffers); fieldforce_ad<flt_t, acc_t, 1>(buffers);
} else { } else {
fieldforce_ad<flt_t,acc_t,0>(buffers); fieldforce_ad<flt_t, acc_t, 0>(buffers);
} }
} }
FFT_SCALAR ***create3d_offset(FFT_SCALAR ***&, int, int, int, FFT_SCALAR ***create3d_offset(FFT_SCALAR ***&, int, int, int, int, int, int, const char *name);
int, int, int, const char *name);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -21,24 +21,24 @@ IntegrateStyle(verlet/lrt/intel,VerletLRTIntel);
#ifndef LMP_VERLET_LRT_INTEL_H #ifndef LMP_VERLET_LRT_INTEL_H
#define LMP_VERLET_LRT_INTEL_H #define LMP_VERLET_LRT_INTEL_H
#include "verlet.h"
#include "pppm_intel.h" #include "pppm_intel.h"
#include "verlet.h"
#ifdef LMP_INTEL_USELRT #ifdef LMP_INTEL_USELRT
#if defined(LMP_INTEL_LRT11) || defined(__APPLE__) #if defined(LMP_INTEL_LRT11) || defined(__APPLE__)
#if __cplusplus > 199711L #if __cplusplus > 199711L
#define _LMP_INTEL_LRT_11 #define _LMP_INTEL_LRT_11
#include <thread> #include <thread>
#else #else
#undef LMP_INTEL_USELRT #undef LMP_INTEL_USELRT
#ifdef LMP_INTEL_LRT11 #ifdef LMP_INTEL_LRT11
#error C++11 support required for LMP_INTEL_LRT11 define #error C++11 support required for LMP_INTEL_LRT11 define
#endif #endif
#endif #endif
#else #else
#define _LMP_INTEL_LRT_PTHREAD #define _LMP_INTEL_LRT_PTHREAD
#include <pthread.h> #include <pthread.h>
#endif #endif
#endif #endif
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -54,17 +54,17 @@ class VerletLRTIntel : public Verlet {
protected: protected:
PPPMIntel *_intel_kspace; PPPMIntel *_intel_kspace;
#if defined(_LMP_INTEL_LRT_PTHREAD) #if defined(_LMP_INTEL_LRT_PTHREAD)
static void *k_launch_loop(void *context); static void *k_launch_loop(void *context);
pthread_t _kspace_thread; pthread_t _kspace_thread;
pthread_attr_t _kspace_attr; pthread_attr_t _kspace_attr;
pthread_mutex_t _kmutex; pthread_mutex_t _kmutex;
pthread_cond_t _kcond; pthread_cond_t _kcond;
int _kspace_ready, _kspace_done, _krun_n; int _kspace_ready, _kspace_done, _krun_n;
#endif #endif
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -111,7 +111,7 @@ void AtomKokkos::map_init(int check)
// use "view" template method to avoid unnecessary deep_copy // use "view" template method to avoid unnecessary deep_copy
auto h_map_hash = k_map_hash.view<LMPHostType>(); // get type auto h_map_hash = k_map_hash.view<LMPHostType>(); // get type
h_map_hash = decltype(h_map_hash)(map_nhash); h_map_hash = decltype(h_map_hash)(map_nhash);
k_map_hash.view<LMPHostType>() = h_map_hash; k_map_hash.view<LMPHostType>() = h_map_hash;
} }
@ -261,7 +261,7 @@ void AtomKokkos::map_set()
if (modify->fix[n]->execution_space == Device) device_hash_flag = 1; if (modify->fix[n]->execution_space == Device) device_hash_flag = 1;
if (device_hash_flag) { if (device_hash_flag) {
Kokkos::deep_copy(d_map_hash,h_map_hash); Kokkos::deep_copy(d_map_hash, h_map_hash);
k_map_hash.view<LMPDeviceType>() = d_map_hash; k_map_hash.view<LMPDeviceType>() = d_map_hash;
} }
} }

View File

@ -20,7 +20,6 @@ FixStyle(nvt/kk/host,FixNVTKokkos<LMPHostType>);
// clang-format on // clang-format on
#else #else
// clang-format off // clang-format off
#ifndef LMP_FIX_NVT_KOKKOS_H #ifndef LMP_FIX_NVT_KOKKOS_H
#define LMP_FIX_NVT_KOKKOS_H #define LMP_FIX_NVT_KOKKOS_H

View File

@ -778,7 +778,7 @@ void PairEDIP::read_file(char *file)
if (comm->me == 0) { if (comm->me == 0) {
fp = utils::open_potential(file, lmp, nullptr); fp = utils::open_potential(file, lmp, nullptr);
if (fp == nullptr) if (fp == nullptr)
error->one(FLERR,"Cannot open EDIP potential file {}: {}", file,utils::getsyserror()); error->one(FLERR, "Cannot open EDIP potential file {}: {}", file, utils::getsyserror());
} }
// read each set of params from potential file // read each set of params from potential file

View File

@ -61,9 +61,9 @@ class FixChargeRegulation : public Fix {
double double
llength_unit_in_nm; // LAMMPS unit of length in nm, needed since chemical potentials are in units of mol/l llength_unit_in_nm; // LAMMPS unit of length in nm, needed since chemical potentials are in units of mol/l
double pH, pKa, pKb, pKs, pI_plus, double pH, pKa, pKb, pKs, pI_plus,
pI_minus; // chemical potentials and equilibrium constant in log10 base pI_minus; // chemical potentials and equilibrium constant in log10 base
double c10pH, c10pKa, c10pKb, c10pOH, c10pI_plus, double c10pH, c10pKa, c10pKb, c10pOH, c10pI_plus,
c10pI_minus; // 10 raised to chemical potential value, in units of concentration [mol/liter] c10pI_minus; // 10 raised to chemical potential value, in units of concentration [mol/liter]
double pmcmoves[3]; // mc move attempt probability: acid, base, ion pair exchange double pmcmoves[3]; // mc move attempt probability: acid, base, ion pair exchange
double pmcc; // mc move cumulative attempt probability double pmcc; // mc move cumulative attempt probability
int npart_xrd; // # of particles (ions) within xrd int npart_xrd; // # of particles (ions) within xrd
@ -71,17 +71,17 @@ class FixChargeRegulation : public Fix {
double vlocal_xrd; // # local volume within xrd double vlocal_xrd; // # local volume within xrd
bool bool
only_salt_flag; // true if performing only salt insertion/deletion, no acid/base dissociation. only_salt_flag; // true if performing only salt insertion/deletion, no acid/base dissociation.
bool add_tags_flag; // true if each inserted atom gets its unique atom tag bool add_tags_flag; // true if each inserted atom gets its unique atom tag
int groupbitall; // group bitmask for inserted atoms int groupbitall; // group bitmask for inserted atoms
int ngroups; // number of group-ids for inserted atoms int ngroups; // number of group-ids for inserted atoms
char **groupstrings; // list of group-ids for inserted atoms char **groupstrings; // list of group-ids for inserted atoms
// counters // counters
unsigned long int nacid_attempts, nacid_successes, nbase_attempts, nbase_successes, unsigned long int nacid_attempts, nacid_successes, nbase_attempts, nbase_successes,
nsalt_attempts, nsalt_successes; nsalt_attempts, nsalt_successes;
int nacid_neutral, nacid_charged, nbase_neutral, nbase_charged, ncation, int nacid_neutral, nacid_charged, nbase_neutral, nbase_charged, ncation,
nanion; // particle type counts nanion; // particle type counts
int cr_nmax; // max number of local particles int cr_nmax; // max number of local particles
double reservoir_temperature; double reservoir_temperature;
double beta, sigma, volume, double beta, sigma, volume,
volume_rx; // inverse temperature, speed, total volume, reacting volume volume_rx; // inverse temperature, speed, total volume, reacting volume

View File

@ -886,7 +886,8 @@ void FixMDIEngine::receive_cell(Error *error)
double small = std::numeric_limits<double>::min(); double small = std::numeric_limits<double>::min();
if (fabs(celldata[1]) > small or fabs(celldata[2]) > small or fabs(celldata[3]) > small or if (fabs(celldata[1]) > small or fabs(celldata[2]) > small or fabs(celldata[3]) > small or
fabs(celldata[5]) > small or fabs(celldata[6]) > small or fabs(celldata[7]) > small) { fabs(celldata[5]) > small or fabs(celldata[6]) > small or fabs(celldata[7]) > small) {
error->all(FLERR, "MDI: LAMMPS currently only supports the >CELL command for orthogonal cell vectors"); error->all(FLERR,
"MDI: LAMMPS currently only supports the >CELL command for orthogonal cell vectors");
} }
// set the new LAMMPS cell dimensions // set the new LAMMPS cell dimensions

View File

@ -340,6 +340,6 @@ char *MDIEngine::mdi_optg()
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command; if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
error->all(FLERR,"MDI reached end of OPTG simulation with invalid command: {}", command); error->all(FLERR, "MDI reached end of OPTG simulation with invalid command: {}", command);
return nullptr; return nullptr;
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* -*- c++ -*- ---------------------------------------------------------- /* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -28,6 +27,7 @@ PairStyle(mgpt,PairMGPT);
// clang-format on // clang-format on
#else #else
// clang-format off
#ifndef LMP_PAIR_MGPT_H #ifndef LMP_PAIR_MGPT_H
#define LMP_PAIR_MGPT_H #define LMP_PAIR_MGPT_H

View File

@ -435,7 +435,7 @@ void PairTracker::read_restart_settings(FILE *fp)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairTracker::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, double /*rsq*/, double PairTracker::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, double /*rsq*/,
double /*factor_coul*/, double /*factor_lj*/, double &/*fforce*/) double /*factor_coul*/, double /*factor_lj*/, double & /*fforce*/)
{ {
return 0.0; return 0.0;
} }

View File

@ -25,28 +25,29 @@
#include "comm.h" #include "comm.h"
#include "error.h" #include "error.h"
#include "memory.h" #include "memory.h"
#include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "neighbor.h"
#include "update.h" #include "update.h"
#include "InterfaceLammps.h" // n2p2 interface header #include "InterfaceLammps.h" // n2p2 interface header
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
static const char cite_user_hdnnp_package[] = static const char cite_user_hdnnp_package[] =
"ML-HDNNP package: 10.1021/acs.jctc.8b00770\n\n" "ML-HDNNP package: 10.1021/acs.jctc.8b00770\n\n"
"@Article{Singraber19,\n" "@Article{Singraber19,\n"
" author = {Singraber, Andreas and Behler, J{\"o}rg and Dellago, Christoph},\n" " author = {Singraber, Andreas and Behler, J{\"o}rg and Dellago, Christoph},\n"
" title = {Library-{{Based LAMMPS Implementation}} of {{High}}-{{Dimensional Neural Network Potentials}}},\n" " title = {Library-{{Based LAMMPS Implementation}} of {{High}}-{{Dimensional Neural Network "
" year = {2019},\n" "Potentials}}},\n"
" month = mar,\n" " year = {2019},\n"
" volume = {15},\n" " month = mar,\n"
" pages = {1827--1840},\n" " volume = {15},\n"
" doi = {10.1021/acs.jctc.8b00770},\n" " pages = {1827--1840},\n"
" journal = {J.~Chem.~Theory~Comput.},\n" " doi = {10.1021/acs.jctc.8b00770},\n"
" number = {3}\n" " journal = {J.~Chem.~Theory~Comput.},\n"
"}\n\n"; " number = {3}\n"
"}\n\n";
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -54,12 +55,13 @@ PairHDNNP::PairHDNNP(LAMMPS *lmp) : Pair(lmp)
{ {
if (lmp->citeme) lmp->citeme->add(cite_user_hdnnp_package); if (lmp->citeme) lmp->citeme->add(cite_user_hdnnp_package);
single_enable = 0; // 1 if single() routine exists single_enable = 0; // 1 if single() routine exists
restartinfo = 0; // 1 if pair style writes restart info restartinfo = 0; // 1 if pair style writes restart info
one_coeff = 1; // 1 if allows only one coeff * * call one_coeff = 1; // 1 if allows only one coeff * * call
manybody_flag = 1; // 1 if a manybody potential manybody_flag = 1; // 1 if a manybody potential
unit_convert_flag = 0; // TODO: Check possible values. value != 0 indicates support for unit conversion. unit_convert_flag =
reinitflag = 0; // 1 if compatible with fix adapt and alike 0; // TODO: Check possible values. value != 0 indicates support for unit conversion.
reinitflag = 0; // 1 if compatible with fix adapt and alike
interface = new nnp::InterfaceLammps(); interface = new nnp::InterfaceLammps();
} }
@ -77,10 +79,10 @@ PairHDNNP::~PairHDNNP()
void PairHDNNP::compute(int eflag, int vflag) void PairHDNNP::compute(int eflag, int vflag)
{ {
ev_init(eflag,vflag); ev_init(eflag, vflag);
// Set number of local atoms and add element. // Set number of local atoms and add element.
interface->setLocalAtoms(atom->nlocal,atom->type); interface->setLocalAtoms(atom->nlocal, atom->type);
// Transfer tags separately. Interface::setLocalTags is overloaded internally // Transfer tags separately. Interface::setLocalTags is overloaded internally
// to work with both -DLAMMPS_SMALLBIG (tagint = int) and -DLAMMPS_BIGBIG // to work with both -DLAMMPS_SMALLBIG (tagint = int) and -DLAMMPS_BIGBIG
// (tagint = int64_t) // (tagint = int64_t)
@ -93,21 +95,18 @@ void PairHDNNP::compute(int eflag, int vflag)
interface->process(); interface->process();
// Do all stuff related to extrapolation warnings. // Do all stuff related to extrapolation warnings.
if(showew == true || showewsum > 0 || maxew >= 0) { if (showew == true || showewsum > 0 || maxew >= 0) { handleExtrapolationWarnings(); }
handleExtrapolationWarnings();
}
// Calculate forces of local and ghost atoms. // Calculate forces of local and ghost atoms.
interface->getForces(atom->f); interface->getForces(atom->f);
// Add energy contribution to total energy. // Add energy contribution to total energy.
if (eflag_global) if (eflag_global)
ev_tally(0,0,atom->nlocal,1,interface->getEnergy(),0.0,0.0,0.0,0.0,0.0); ev_tally(0, 0, atom->nlocal, 1, interface->getEnergy(), 0.0, 0.0, 0.0, 0.0, 0.0);
// Add atomic energy if requested (CAUTION: no physical meaning!). // Add atomic energy if requested (CAUTION: no physical meaning!).
if (eflag_atom) if (eflag_atom)
for (int i = 0; i < atom->nlocal; ++i) for (int i = 0; i < atom->nlocal; ++i) eatom[i] = interface->getAtomicEnergy(i);
eatom[i] = interface->getAtomicEnergy(i);
// If virial needed calculate via F dot r. // If virial needed calculate via F dot r.
if (vflag_fdotr) virial_fdotr_compute(); if (vflag_fdotr) virial_fdotr_compute();
@ -121,9 +120,9 @@ void PairHDNNP::settings(int narg, char **arg)
{ {
int iarg = 0; int iarg = 0;
if (narg < 1) error->all(FLERR,"Illegal pair_style command"); if (narg < 1) error->all(FLERR, "Illegal pair_style command");
maxCutoffRadius = utils::numeric(FLERR,arg[0],false,lmp); maxCutoffRadius = utils::numeric(FLERR, arg[0], false, lmp);
iarg++; iarg++;
// default settings // default settings
@ -137,61 +136,55 @@ void PairHDNNP::settings(int narg, char **arg)
numExtrapolationWarningsTotal = 0; numExtrapolationWarningsTotal = 0;
numExtrapolationWarningsSummary = 0; numExtrapolationWarningsSummary = 0;
while(iarg < narg) { while (iarg < narg) {
// set HDNNP directory // set HDNNP directory
if (strcmp(arg[iarg],"dir") == 0) { if (strcmp(arg[iarg], "dir") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command");
delete[] directory; delete[] directory;
directory = utils::strdup(arg[iarg+1]); directory = utils::strdup(arg[iarg + 1]);
iarg += 2; iarg += 2;
// show extrapolation warnings // show extrapolation warnings
} else if (strcmp(arg[iarg],"showew") == 0) { } else if (strcmp(arg[iarg], "showew") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command"); if (strcmp(arg[iarg + 1], "yes") == 0)
if (strcmp(arg[iarg+1],"yes") == 0)
showew = true; showew = true;
else if (strcmp(arg[iarg+1],"no") == 0) else if (strcmp(arg[iarg + 1], "no") == 0)
showew = false; showew = false;
else else
error->all(FLERR,"Illegal pair_style command"); error->all(FLERR, "Illegal pair_style command");
iarg += 2; iarg += 2;
// show extrapolation warning summary // show extrapolation warning summary
} else if (strcmp(arg[iarg],"showewsum") == 0) { } else if (strcmp(arg[iarg], "showewsum") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command"); showewsum = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
showewsum = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2; iarg += 2;
// maximum allowed extrapolation warnings // maximum allowed extrapolation warnings
} else if (strcmp(arg[iarg],"maxew") == 0) { } else if (strcmp(arg[iarg], "maxew") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command"); maxew = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
maxew = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2; iarg += 2;
// reset extrapolation warning counter // reset extrapolation warning counter
} else if (strcmp(arg[iarg],"resetew") == 0) { } else if (strcmp(arg[iarg], "resetew") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command"); if (strcmp(arg[iarg + 1], "yes") == 0)
if (strcmp(arg[iarg+1],"yes") == 0)
resetew = true; resetew = true;
else if (strcmp(arg[iarg+1],"no") == 0) else if (strcmp(arg[iarg + 1], "no") == 0)
resetew = false; resetew = false;
else else
error->all(FLERR,"Illegal pair_style command"); error->all(FLERR, "Illegal pair_style command");
iarg += 2; iarg += 2;
// length unit conversion factor // length unit conversion factor
} else if (strcmp(arg[iarg],"cflength") == 0) { } else if (strcmp(arg[iarg], "cflength") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command"); cflength = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
cflength = utils::numeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2; iarg += 2;
// energy unit conversion factor // energy unit conversion factor
} else if (strcmp(arg[iarg],"cfenergy") == 0) { } else if (strcmp(arg[iarg], "cfenergy") == 0) {
if (iarg+2 > narg) if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command");
error->all(FLERR,"Illegal pair_style command"); cfenergy = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
cfenergy = utils::numeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2; iarg += 2;
} else error->all(FLERR,"Illegal pair_style command"); } else
error->all(FLERR, "Illegal pair_style command");
} }
} }
@ -205,21 +198,20 @@ void PairHDNNP::coeff(int narg, char **arg)
if (!allocated) allocate(); if (!allocated) allocate();
if (narg != 2 + n) if (narg != 2 + n) error->all(FLERR, "Incorrect args for pair coefficients");
error->all(FLERR,"Incorrect args for pair coefficients");
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) if (strcmp(arg[0], "*") != 0 || strcmp(arg[1], "*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients"); error->all(FLERR, "Incorrect args for pair coefficients");
int *map = new int[n+1]; int *map = new int[n + 1];
for (int i = 0; i < n; i++) map[i] = 0; for (int i = 0; i < n; i++) map[i] = 0;
emap = ""; emap = "";
for (int i = 2; i < narg; i++) { for (int i = 2; i < narg; i++) {
if (strcmp(arg[i],"NULL") != 0) { if (strcmp(arg[i], "NULL") != 0) {
if (i != 2) emap += ","; if (i != 2) emap += ",";
emap += std::to_string(i-1) + ":" + arg[i]; emap += std::to_string(i - 1) + ":" + arg[i];
map[i-1] = 1; map[i - 1] = 1;
} }
} }
@ -231,7 +223,7 @@ void PairHDNNP::coeff(int narg, char **arg)
count++; count++;
} }
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
delete[] map; delete[] map;
} }
@ -251,29 +243,18 @@ void PairHDNNP::init_style()
// Activate screen and logfile output only for rank 0. // Activate screen and logfile output only for rank 0.
if (comm->me == 0) { if (comm->me == 0) {
if (lmp->screen != nullptr) if (lmp->screen != nullptr) interface->log.registerCFilePointer(&(lmp->screen));
interface->log.registerCFilePointer(&(lmp->screen)); if (lmp->logfile != nullptr) interface->log.registerCFilePointer(&(lmp->logfile));
if (lmp->logfile != nullptr)
interface->log.registerCFilePointer(&(lmp->logfile));
} }
// Initialize interface on all processors. // Initialize interface on all processors.
interface->initialize(directory, interface->initialize(directory, emap.c_str(), showew, resetew, showewsum, maxew, cflength,
emap.c_str(), cfenergy, maxCutoffRadius, atom->ntypes, comm->me);
showew,
resetew,
showewsum,
maxew,
cflength,
cfenergy,
maxCutoffRadius,
atom->ntypes,
comm->me);
// LAMMPS cutoff radius (given via pair_coeff) should not be smaller than // LAMMPS cutoff radius (given via pair_coeff) should not be smaller than
// maximum symmetry function cutoff radius. // maximum symmetry function cutoff radius.
if (maxCutoffRadius < interface->getMaxCutoffRadius()) if (maxCutoffRadius < interface->getMaxCutoffRadius())
error->all(FLERR,"Inconsistent cutoff radius"); error->all(FLERR, "Inconsistent cutoff radius");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -294,12 +275,11 @@ void PairHDNNP::allocate()
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
memory->create(setflag,n+1,n+1,"pair:setflag"); memory->create(setflag, n + 1, n + 1, "pair:setflag");
for (int i = 1; i <= n; i++) for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++) for (int j = i; j <= n; j++) setflag[i][j] = 0;
setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq"); // TODO: Is this required? memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // TODO: Is this required?
} }
void PairHDNNP::transferNeighborList() void PairHDNNP::transferNeighborList()
@ -315,9 +295,7 @@ void PairHDNNP::transferNeighborList()
double dy = atom->x[i][1] - atom->x[j][1]; double dy = atom->x[i][1] - atom->x[j][1];
double dz = atom->x[i][2] - atom->x[j][2]; double dz = atom->x[i][2] - atom->x[j][2];
double d2 = dx * dx + dy * dy + dz * dz; double d2 = dx * dx + dy * dy + dz * dz;
if (d2 <= rc2) { if (d2 <= rc2) { interface->addNeighbor(i, j, atom->tag[j], atom->type[j], dx, dy, dz, d2); }
interface->addNeighbor(i,j,atom->tag[j],atom->type[j],dx,dy,dz,d2);
}
} }
} }
} }
@ -325,29 +303,29 @@ void PairHDNNP::transferNeighborList()
void PairHDNNP::handleExtrapolationWarnings() void PairHDNNP::handleExtrapolationWarnings()
{ {
// Get number of extrapolation warnings for local atoms. // Get number of extrapolation warnings for local atoms.
long numCurrentEW = (long)interface->getNumExtrapolationWarnings(); long numCurrentEW = (long) interface->getNumExtrapolationWarnings();
// Update (or set, resetew == true) total warnings counter. // Update (or set, resetew == true) total warnings counter.
if (resetew) numExtrapolationWarningsTotal = numCurrentEW; if (resetew)
else numExtrapolationWarningsTotal += numCurrentEW; numExtrapolationWarningsTotal = numCurrentEW;
else
numExtrapolationWarningsTotal += numCurrentEW;
// Update warnings summary counter. // Update warnings summary counter.
if(showewsum > 0) { if (showewsum > 0) { numExtrapolationWarningsSummary += numCurrentEW; }
numExtrapolationWarningsSummary += numCurrentEW;
}
// If requested write extrapolation warnings. // If requested write extrapolation warnings.
// Requires communication of all symmetry functions statistics entries to // Requires communication of all symmetry functions statistics entries to
// rank 0. // rank 0.
if(showew > 0) { if (showew > 0) {
// First collect an overview of extrapolation warnings per process. // First collect an overview of extrapolation warnings per process.
long *numEWPerProc = nullptr; long *numEWPerProc = nullptr;
if(comm->me == 0) numEWPerProc = new long[comm->nprocs]; if (comm->me == 0) numEWPerProc = new long[comm->nprocs];
MPI_Gather(&numCurrentEW, 1, MPI_LONG, numEWPerProc, 1, MPI_LONG, 0, world); MPI_Gather(&numCurrentEW, 1, MPI_LONG, numEWPerProc, 1, MPI_LONG, 0, world);
if(comm->me == 0) { if (comm->me == 0) {
for(int i=1;i<comm->nprocs;i++) { for (int i = 1; i < comm->nprocs; i++) {
if(numEWPerProc[i] > 0) { if (numEWPerProc[i] > 0) {
long bs = 0; long bs = 0;
MPI_Status ms; MPI_Status ms;
// Get buffer size. // Get buffer size.
@ -360,8 +338,7 @@ void PairHDNNP::handleExtrapolationWarnings()
} }
} }
interface->writeExtrapolationWarnings(); interface->writeExtrapolationWarnings();
} } else if (numCurrentEW > 0) {
else if(numCurrentEW > 0) {
// Get desired buffer length for all extrapolation warning entries. // Get desired buffer length for all extrapolation warning entries.
long bs = interface->getEWBufferSize(); long bs = interface->getEWBufferSize();
// Allocate and fill buffer. // Allocate and fill buffer.
@ -373,18 +350,17 @@ void PairHDNNP::handleExtrapolationWarnings()
delete[] buf; delete[] buf;
} }
if(comm->me == 0) delete[] numEWPerProc; if (comm->me == 0) delete[] numEWPerProc;
} }
// If requested gather number of warnings to display summary. // If requested gather number of warnings to display summary.
if(showewsum > 0 && update->ntimestep % showewsum == 0) { if (showewsum > 0 && update->ntimestep % showewsum == 0) {
long globalEW = 0; long globalEW = 0;
// Communicate the sum over all processors to proc 0. // Communicate the sum over all processors to proc 0.
MPI_Reduce(&numExtrapolationWarningsSummary, MPI_Reduce(&numExtrapolationWarningsSummary, &globalEW, 1, MPI_LONG, MPI_SUM, 0, world);
&globalEW, 1, MPI_LONG, MPI_SUM, 0, world);
// Write to screen or logfile. // Write to screen or logfile.
if(comm->me == 0) if (comm->me == 0)
utils::logmesg(lmp,"### NNP EW SUMMARY ### TS: {:10d} EW {:10d} EWPERSTEP {:10.3e}\n", utils::logmesg(lmp, "### NNP EW SUMMARY ### TS: {:10d} EW {:10d} EWPERSTEP {:10.3e}\n",
update->ntimestep, globalEW, double(globalEW) / showewsum); update->ntimestep, globalEW, double(globalEW) / showewsum);
// Reset summary counter. // Reset summary counter.
numExtrapolationWarningsSummary = 0; numExtrapolationWarningsSummary = 0;
@ -392,7 +368,7 @@ void PairHDNNP::handleExtrapolationWarnings()
// Stop if maximum number of extrapolation warnings is exceeded. // Stop if maximum number of extrapolation warnings is exceeded.
if (numExtrapolationWarningsTotal > maxew) { if (numExtrapolationWarningsTotal > maxew) {
error->one(FLERR,"Too many extrapolation warnings"); error->one(FLERR, "Too many extrapolation warnings");
} }
// Reset internal extrapolation warnings counters. // Reset internal extrapolation warnings counters.

View File

@ -30,7 +30,7 @@ PairStyle(hdnnp,PairHDNNP);
#include "pair.h" #include "pair.h"
namespace nnp { namespace nnp {
class InterfaceLammps; class InterfaceLammps;
} }
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -38,7 +38,6 @@ namespace LAMMPS_NS {
class PairHDNNP : public Pair { class PairHDNNP : public Pair {
public: public:
PairHDNNP(class LAMMPS *); PairHDNNP(class LAMMPS *);
virtual ~PairHDNNP(); virtual ~PairHDNNP();
virtual void compute(int, int); virtual void compute(int, int);
@ -48,7 +47,6 @@ class PairHDNNP : public Pair {
virtual double init_one(int, int); virtual double init_one(int, int);
protected: protected:
virtual void allocate(); virtual void allocate();
void transferNeighborList(); void transferNeighborList();
void handleExtrapolationWarnings(); void handleExtrapolationWarnings();
@ -67,7 +65,7 @@ class PairHDNNP : public Pair {
nnp::InterfaceLammps *interface; nnp::InterfaceLammps *interface;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -47,9 +47,9 @@ MLIAPDescriptor::~MLIAPDescriptor()
double MLIAPDescriptor::memory_usage() double MLIAPDescriptor::memory_usage()
{ {
double bytes = (double)nelements*sizeof(double); // radelem double bytes = (double) nelements * sizeof(double); // radelem
bytes += (double)nelements*sizeof(double); // welem bytes += (double) nelements * sizeof(double); // welem
bytes += (double)nelements*nelements*sizeof(double); // cutsq bytes += (double) nelements * nelements * sizeof(double); // cutsq
return bytes; return bytes;
} }

View File

@ -31,10 +31,10 @@ class MLIAPModel : protected Pointers {
virtual void compute_force_gradients(class MLIAPData *) = 0; virtual void compute_force_gradients(class MLIAPData *) = 0;
virtual void init(); virtual void init();
virtual double memory_usage() = 0; virtual double memory_usage() = 0;
int nelements; // # of unique elements int nelements; // # of unique elements
int nonlinearflag; // 1 if gradient() requires descriptors int nonlinearflag; // 1 if gradient() requires descriptors
int ndescriptors; // number of descriptors int ndescriptors; // number of descriptors
int nparams; // number of parameters per element int nparams; // number of parameters per element
double **coeffelem; // element coefficients double **coeffelem; // element coefficients
protected: protected:

View File

@ -32,9 +32,9 @@ class MLIAPModelNN : public MLIAPModel {
int nlayers; // number of layers per element int nlayers; // number of layers per element
protected: protected:
int *activation; // activation functions int *activation; // activation functions
int *nnodes; // number of nodes per layer int *nnodes; // number of nodes per layer
double ***scale; // element scale values double ***scale; // element scale values
virtual void read_coeffs(char *); virtual void read_coeffs(char *);
inline double sigm(double x, double &deriv) inline double sigm(double x, double &deriv)

View File

@ -39,128 +39,138 @@ PairStyle(rann,PairRANN);
#include "pair.h" #include "pair.h"
#include <vector>
#include <string> #include <string>
#include <vector>
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
//forward declarations //forward declarations
class Activation; class Activation;
class Fingerprint; class Fingerprint;
} } // namespace RANN
class PairRANN : public Pair { class PairRANN : public Pair {
public: public:
//inherited functions //inherited functions
PairRANN(class LAMMPS *); PairRANN(class LAMMPS *);
~PairRANN(); ~PairRANN();
void compute(int, int); void compute(int, int);
void settings(int, char **); void settings(int, char **);
void coeff(int, char **); void coeff(int, char **);
void init_style(); void init_style();
double init_one(int, int); double init_one(int, int);
void init_list(int , NeighList *); void init_list(int, NeighList *);
void errorf(const char*,int,const char*); void errorf(const char *, int, const char *);
int factorial(int); int factorial(int);
RANN::Fingerprint *create_fingerprint(const char *); RANN::Fingerprint *create_fingerprint(const char *);
RANN::Activation *create_activation(const char *); RANN::Activation *create_activation(const char *);
//global variables //global variables
int nelements; // # of elements (distinct from LAMMPS atom types since multiple atom types can be mapped to one element) int nelements; // # of elements (distinct from LAMMPS atom types since multiple atom types can be mapped to one element)
int nelementsp; // nelements+1 int nelementsp; // nelements+1
char **elements; // names of elements char **elements; // names of elements
char **elementsp; // names of elements with "all" appended as the last "element" char **elementsp; // names of elements with "all" appended as the last "element"
double *mass; // mass of each element double *mass; // mass of each element
double cutmax; // max radial distance for neighbor lists double cutmax; // max radial distance for neighbor lists
int *map; // mapping from atom types to elements int *map; // mapping from atom types to elements
int *fingerprintcount; // static variable used in initialization int *fingerprintcount; // static variable used in initialization
int *fingerprintlength; // # of input neurons defined by fingerprints of each element. int *fingerprintlength; // # of input neurons defined by fingerprints of each element.
int *fingerprintperelement; // # of fingerprints for each element int *fingerprintperelement; // # of fingerprints for each element
bool doscreen;//screening is calculated if any defined fingerprint uses it bool doscreen; //screening is calculated if any defined fingerprint uses it
bool allscreen;//all fingerprints use screening so screened neighbors can be completely ignored bool
bool dospin; allscreen; //all fingerprints use screening so screened neighbors can be completely ignored
int res;//Resolution of function tables for cubic interpolation. bool dospin;
int memguess; int res; //Resolution of function tables for cubic interpolation.
double *screening_min; int memguess;
double *screening_max; double *screening_min;
bool **weightdefined; double *screening_max;
bool **biasdefined; bool **weightdefined;
int nmax1; bool **biasdefined;
int nmax2; int nmax1;
int fmax; int nmax2;
int fnmax; int fmax;
//memory actively written to during each compute: int fnmax;
double *xn,*yn,*zn,*Sik,*dSikx,*dSiky,*dSikz,*dSijkx,*dSijky,*dSijkz,*sx,*sy,*sz,**dSijkxc,**dSijkyc,**dSijkzc,*dfeaturesx,*dfeaturesy,*dfeaturesz,*features; //memory actively written to during each compute:
double *layer,*sum,*sum1,**dlayerx,**dlayery,**dlayerz,**dlayersumx,**dlayersumy,**dlayersumz; double *xn, *yn, *zn, *Sik, *dSikx, *dSiky, *dSikz, *dSijkx, *dSijky, *dSijkz, *sx, *sy, *sz,
double **dsx,**dsy,**dsz,**dssumx,**dssumy,**dssumz; **dSijkxc, **dSijkyc, **dSijkzc, *dfeaturesx, *dfeaturesy, *dfeaturesz, *features;
int *tn,*jl; double *layer, *sum, *sum1, **dlayerx, **dlayery, **dlayerz, **dlayersumx, **dlayersumy,
bool *Bij; **dlayersumz;
double **dsx, **dsy, **dsz, **dssumx, **dssumy, **dssumz;
int *tn, *jl;
bool *Bij;
struct Simulation{ struct Simulation {
int *id; int *id;
bool forces; bool forces;
bool spins; bool spins;
double **x; double **x;
double **f; double **f;
double **s; double **s;
double box[3][3]; double box[3][3];
double origin[3]; double origin[3];
double **features; double **features;
double **dfx; double **dfx;
double **dfy; double **dfy;
double **dfz; double **dfz;
double **dsx; double **dsx;
double **dsy; double **dsy;
double **dsz; double **dsz;
int *ilist,*numneigh,**firstneigh,*type,inum,gnum; int *ilist, *numneigh, **firstneigh, *type, inum, gnum;
};
struct NNarchitecture{
int layers;
int *dimensions;//vector of length layers with entries for neurons per layer
double **Weights;
double **Biases;
int *activations;//unused
int maxlayer;//longest layer (for memory allocation)
};
Simulation *sims;
NNarchitecture *net;//array of networks, 1 for each element.
protected:
RANN::Activation ***activation;
RANN::Fingerprint ***fingerprints;
private:
//new functions
void allocate(const std::vector<std::string> &);//called after reading element list, but before reading the rest of the potential
void deallocate();
void read_file(char *);//read potential file
void read_atom_types(std::vector<std::string>,char*,int);
void read_fpe(std::vector<std::string>,std::vector<std::string>,char*,int);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations
void read_fingerprints(std::vector<std::string>,std::vector<std::string>,char*,int);
void read_fingerprint_constants(std::vector<std::string>,std::vector<std::string>,char*,int);
void read_network_layers(std::vector<std::string>,std::vector<std::string>,char*,int);//include input and output layer (hidden layers + 2)
void read_layer_size(std::vector<std::string>,std::vector<std::string>,char*,int);
void read_weight(std::vector<std::string>,std::vector<std::string>,FILE*,char*,int*);//weights should be formatted as properly shaped matrices
void read_bias(std::vector<std::string>,std::vector<std::string>,FILE*,char*,int*);//biases should be formatted as properly shaped vectors
void read_activation_functions(std::vector<std::string>,std::vector<std::string>,char*,int);
void read_screening(std::vector<std::string>,std::vector<std::string>,char*,int);
void read_mass(const std::vector<std::string> &, const std::vector<std::string> &,const char*,int);
bool check_potential();//after finishing reading potential file
void propagateforward(double *,double **,int,int);//called by compute to get force and energy
void propagateforwardspin(double *,double **,double**,int,int);//called by compute to get force and energy
void screening(int,int,int);
void cull_neighbor_list(int *,int,int);
void screen_neighbor_list(int *);
}; };
} struct NNarchitecture {
int layers;
int *dimensions; //vector of length layers with entries for neurons per layer
double **Weights;
double **Biases;
int *activations; //unused
int maxlayer; //longest layer (for memory allocation)
};
Simulation *sims;
NNarchitecture *net; //array of networks, 1 for each element.
protected:
RANN::Activation ***activation;
RANN::Fingerprint ***fingerprints;
private:
//new functions
void allocate(
const std::vector<std::string>
&); //called after reading element list, but before reading the rest of the potential
void deallocate();
void read_file(char *); //read potential file
void read_atom_types(std::vector<std::string>, char *, int);
void read_fpe(
std::vector<std::string>, std::vector<std::string>, char *,
int); //fingerprints per element. Count total fingerprints defined for each 1st element in element combinations
void read_fingerprints(std::vector<std::string>, std::vector<std::string>, char *, int);
void read_fingerprint_constants(std::vector<std::string>, std::vector<std::string>, char *, int);
void read_network_layers(std::vector<std::string>, std::vector<std::string>, char *,
int); //include input and output layer (hidden layers + 2)
void read_layer_size(std::vector<std::string>, std::vector<std::string>, char *, int);
void read_weight(std::vector<std::string>, std::vector<std::string>, FILE *, char *,
int *); //weights should be formatted as properly shaped matrices
void read_bias(std::vector<std::string>, std::vector<std::string>, FILE *, char *,
int *); //biases should be formatted as properly shaped vectors
void read_activation_functions(std::vector<std::string>, std::vector<std::string>, char *, int);
void read_screening(std::vector<std::string>, std::vector<std::string>, char *, int);
void read_mass(const std::vector<std::string> &, const std::vector<std::string> &, const char *,
int);
bool check_potential(); //after finishing reading potential file
void propagateforward(double *, double **, int,
int); //called by compute to get force and energy
void propagateforwardspin(double *, double **, double **, int,
int); //called by compute to get force and energy
void screening(int, int, int);
void cull_neighbor_list(int *, int, int);
void screen_neighbor_list(int *);
};
} // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -31,11 +31,10 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#ifndef LMP_RANN_ACTIVATION_H #ifndef LMP_RANN_ACTIVATION_H
#define LMP_RANN_ACTIVATION_H #define LMP_RANN_ACTIVATION_H
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Activation { class Activation {
public: public:
Activation(class PairRANN *); Activation(class PairRANN *);
virtual ~Activation(); virtual ~Activation();
virtual double activation_function(double); virtual double activation_function(double);
@ -43,30 +42,23 @@ namespace LAMMPS_NS {
virtual double ddactivation_function(double); virtual double ddactivation_function(double);
bool empty; bool empty;
const char *style; const char *style;
}; };
Activation::Activation(PairRANN *) { Activation::Activation(PairRANN *)
{
empty = true; empty = true;
style = "empty"; style = "empty";
}
Activation::~Activation() {
}
//default is linear activation (no change).
double Activation::activation_function(double A) {
return A;
}
double Activation::dactivation_function(double) {
return 1.0;
}
double Activation::ddactivation_function(double) {
return 0.0;
}
} }
}
Activation::~Activation() {}
//default is linear activation (no change).
double Activation::activation_function(double A) { return A; }
double Activation::dactivation_function(double) { return 1.0; }
double Activation::ddactivation_function(double) { return 0.0; }
} // namespace RANN
} // namespace LAMMPS_NS
#endif /* RANN_ACTIVATION_H_ */ #endif /* RANN_ACTIVATION_H_ */

View File

@ -33,35 +33,28 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_activation.h" #include "rann_activation.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Activation_linear : public Activation { class Activation_linear : public Activation {
public: public:
Activation_linear(class PairRANN *); Activation_linear(class PairRANN *);
double activation_function(double); double activation_function(double);
double dactivation_function(double); double dactivation_function(double);
double ddactivation_function(double); double ddactivation_function(double);
}; };
Activation_linear::Activation_linear(PairRANN *_pair) : Activation(_pair) { Activation_linear::Activation_linear(PairRANN *_pair) : Activation(_pair)
empty = false; {
style = "linear"; empty = false;
} style = "linear";
double Activation_linear::activation_function(double A)
{
return A;
}
double Activation_linear::dactivation_function(double)
{
return 1.0;
}
double Activation_linear::ddactivation_function(double) {
return 0.0;
}
} }
}
double Activation_linear::activation_function(double A) { return A; }
double Activation_linear::dactivation_function(double) { return 1.0; }
double Activation_linear::ddactivation_function(double) { return 0.0; }
} // namespace RANN
} // namespace LAMMPS_NS
#endif /* ACTIVATION_LINEAR_H_ */ #endif /* ACTIVATION_LINEAR_H_ */

View File

@ -34,37 +34,42 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_activation.h" #include "rann_activation.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Activation_sigI : public Activation { class Activation_sigI : public Activation {
public: public:
Activation_sigI(class PairRANN *); Activation_sigI(class PairRANN *);
double activation_function(double); double activation_function(double);
double dactivation_function(double); double dactivation_function(double);
double ddactivation_function(double); double ddactivation_function(double);
}; };
Activation_sigI::Activation_sigI(PairRANN *_pair) : Activation(_pair) { Activation_sigI::Activation_sigI(PairRANN *_pair) : Activation(_pair)
{
empty = false; empty = false;
style = "sigI"; style = "sigI";
}
double Activation_sigI::activation_function(double in) {
if (in>34)return in;
return 0.1*in + 0.9*log(exp(in) + 1);
}
double Activation_sigI::dactivation_function(double in) {
if (in>34)return 1;
return 0.1 + 0.9/(exp(in)+1)*exp(in);
}
double Activation_sigI::ddactivation_function(double in) {
if (in>34)return 0;
return 0.9*exp(in)/(exp(in)+1)/(exp(in)+1);;
}
} }
}
double Activation_sigI::activation_function(double in)
{
if (in > 34) return in;
return 0.1 * in + 0.9 * log(exp(in) + 1);
}
double Activation_sigI::dactivation_function(double in)
{
if (in > 34) return 1;
return 0.1 + 0.9 / (exp(in) + 1) * exp(in);
}
double Activation_sigI::ddactivation_function(double in)
{
if (in > 34) return 0;
return 0.9 * exp(in) / (exp(in) + 1) / (exp(in) + 1);
;
}
} // namespace RANN
} // namespace LAMMPS_NS
#endif /* ACTIVATION_SIGI_H_ */ #endif /* ACTIVATION_SIGI_H_ */

View File

@ -74,7 +74,7 @@ namespace RANN {
{ {
} }
virtual int get_length(){return 0;}; virtual int get_length() { return 0; };
virtual double cutofffunction(double, double, double); virtual double cutofffunction(double, double, double);
virtual void generate_rinvssqrttable(); virtual void generate_rinvssqrttable();
bool spin; bool spin;

View File

@ -34,39 +34,41 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_bond : public Fingerprint { class Fingerprint_bond : public Fingerprint {
public: public:
Fingerprint_bond(PairRANN *); Fingerprint_bond(PairRANN *);
~Fingerprint_bond(); ~Fingerprint_bond();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
void compute_fingerprint(double*,double*,double*,double*,int,int,double *,double *,double *,int *,int,int *); void compute_fingerprint(double *, double *, double *, double *, int, int, double *, double *,
void do3bodyfeatureset_doubleneighborloop(double *,double *,double *,double *,int,int,double *,double *,double *,int *,int,int *); double *, int *, int, int *);
void do3bodyfeatureset_singleneighborloop(double *,double *,double *,double *,int,int,double *,double *,double *,int *,int,int *); void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, int, int,
void generate_exp_cut_table(); double *, double *, double *, int *, int, int *);
void generate_coefficients(); void do3bodyfeatureset_singleneighborloop(double *, double *, double *, double *, int, int,
int get_length(); double *, double *, double *, int *, int, int *);
void generate_exp_cut_table();
void generate_coefficients();
int get_length();
double *expcuttable; double *expcuttable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha_k; double *alpha_k;
double re; double re;
int **coeff; int **coeff;
int **coeffx; int **coeffx;
int **coeffy; int **coeffy;
int **coeffz; int **coeffz;
int kmax; int kmax;
int mlength; int mlength;
int **Mf; int **Mf;
};
}; } // namespace RANN
} // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_BOND_H_ */ #endif /* FINGERPRINT_BOND_H_ */

View File

@ -34,39 +34,46 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_bondscreened : public Fingerprint { class Fingerprint_bondscreened : public Fingerprint {
public: public:
Fingerprint_bondscreened(PairRANN *); Fingerprint_bondscreened(PairRANN *);
~Fingerprint_bondscreened(); ~Fingerprint_bondscreened();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
void do3bodyfeatureset_doubleneighborloop(double *,double *,double *,double *,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); double *, double *, double *, double *, bool *, int, int, double *,
void do3bodyfeatureset_singleneighborloop(double *,double *,double *,double *,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); double *, double *, int *, int, int *);
void generate_exp_cut_table(); void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
void generate_coefficients(); double *, double *, double *, double *, double *,
int get_length(); double *, bool *, int, int, double *, double *,
double *, int *, int, int *);
void do3bodyfeatureset_singleneighborloop(double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *,
double *, bool *, int, int, double *, double *,
double *, int *, int, int *);
void generate_exp_cut_table();
void generate_coefficients();
int get_length();
double *expcuttable; double *expcuttable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha_k; double *alpha_k;
double re; double re;
int **coeff; int **coeff;
int **coeffx; int **coeffx;
int **coeffy; int **coeffy;
int **coeffz; int **coeffz;
int kmax; int kmax;
int mlength; int mlength;
int **Mf; int **Mf;
};
} // namespace RANN
}; } // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_BOND_H_ */ #endif /* FINGERPRINT_BOND_H_ */

View File

@ -34,39 +34,46 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_bondscreenedspin : public Fingerprint { class Fingerprint_bondscreenedspin : public Fingerprint {
public: public:
Fingerprint_bondscreenedspin(PairRANN *); Fingerprint_bondscreenedspin(PairRANN *);
~Fingerprint_bondscreenedspin(); ~Fingerprint_bondscreenedspin();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
void do3bodyfeatureset_doubleneighborloop(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int *); double *, double *, double *, double *, double *, double *, double *,
void do3bodyfeatureset_singleneighborloop(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); bool *, int, int, double *, double *, double *, int *, int, int *);
void generate_exp_cut_table(); void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
void generate_coefficients(); double *, double *, double *, double *, double *,
int get_length(); double *, double *, double *, double *, bool *, int,
int, double *, double *, double *, int *, int, int *);
void do3bodyfeatureset_singleneighborloop(double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *,
double *, double *, double *, double *, bool *, int,
int, double *, double *, double *, int *, int, int *);
void generate_exp_cut_table();
void generate_coefficients();
int get_length();
double *expcuttable; double *expcuttable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha_k; double *alpha_k;
double re; double re;
int **coeff; int **coeff;
int **coeffx; int **coeffx;
int **coeffy; int **coeffy;
int **coeffz; int **coeffz;
int kmax; int kmax;
int mlength; int mlength;
int **Mf; int **Mf;
};
}; } // namespace RANN
} // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_BOND_H_ */ #endif /* FINGERPRINT_BOND_H_ */

View File

@ -34,38 +34,43 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_bondspin : public Fingerprint { class Fingerprint_bondspin : public Fingerprint {
public: public:
Fingerprint_bondspin(PairRANN *); Fingerprint_bondspin(PairRANN *);
~Fingerprint_bondspin(); ~Fingerprint_bondspin();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//spin virtual void compute_fingerprint(double *, double *, double *, double *, double *, double *,
void do3bodyfeatureset_doubleneighborloop(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); double *, int, int, double *, double *, double *, int *, int,
void do3bodyfeatureset_singleneighborloop(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); int *); //spin
void generate_exp_cut_table(); void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
void generate_coefficients(); double *, double *, int, int, double *, double *,
int get_length(); double *, int *, int, int *);
void do3bodyfeatureset_singleneighborloop(double *, double *, double *, double *, double *,
double *, double *, int, int, double *, double *,
double *, int *, int, int *);
void generate_exp_cut_table();
void generate_coefficients();
int get_length();
double *expcuttable; double *expcuttable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha_k; double *alpha_k;
double re; double re;
int **coeff; int **coeff;
int **coeffx; int **coeffx;
int **coeffy; int **coeffy;
int **coeffz; int **coeffz;
int kmax; int kmax;
int mlength; int mlength;
int **Mf; int **Mf;
};
}; } // namespace RANN
} // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_BOND_H_ */ #endif /* FINGERPRINT_BOND_H_ */

View File

@ -34,30 +34,30 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_radial : public Fingerprint { class Fingerprint_radial : public Fingerprint {
public: public:
Fingerprint_radial(PairRANN *); Fingerprint_radial(PairRANN *);
~Fingerprint_radial(); ~Fingerprint_radial();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); void compute_fingerprint(double *, double *, double *, double *, int, int, double *, double *,
int get_length(); double *, int *, int, int *);
int get_length();
double *radialtable; double *radialtable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha; double *alpha;
double re; double re;
int nmax;//highest term int nmax; //highest term
int omin;//lowest term int omin; //lowest term
};
}; } // namespace RANN
} // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_RADIAL_H_ */ #endif /* FINGERPRINT_RADIAL_H_ */

View File

@ -34,29 +34,30 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_radialscreened : public Fingerprint { class Fingerprint_radialscreened : public Fingerprint {
public: public:
Fingerprint_radialscreened(PairRANN *); Fingerprint_radialscreened(PairRANN *);
~Fingerprint_radialscreened(); ~Fingerprint_radialscreened();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
int get_length(); double *, double *, double *, double *, bool *, int, int, double *,
double *, double *, int *, int, int *);
int get_length();
double *radialtable; double *radialtable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha; double *alpha;
double re; double re;
int nmax;//highest term int nmax; //highest term
int omin;//lowest term int omin; //lowest term
};
} // namespace RANN
}; } // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_RADIALSCREENED_H_ */ #endif /* FINGERPRINT_RADIALSCREENED_H_ */

View File

@ -34,29 +34,31 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_radialscreenedspin : public Fingerprint { class Fingerprint_radialscreenedspin : public Fingerprint {
public: public:
Fingerprint_radialscreenedspin(PairRANN *); Fingerprint_radialscreenedspin(PairRANN *);
~Fingerprint_radialscreenedspin(); ~Fingerprint_radialscreenedspin();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//spin,screen virtual void compute_fingerprint(double *, double *, double *, double *, double *, double *,
int get_length(); double *, double *, double *, double *, double *, double *,
double *, double *, bool *, int, int, double *, double *,
double *, int *, int, int *); //spin,screen
int get_length();
double *radialtable; double *radialtable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha; double *alpha;
double re; double re;
int nmax;//highest term int nmax; //highest term
int omin;//lowest term int omin; //lowest term
};
} // namespace RANN
}; } // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_RADIALSCREENED_H_ */ #endif /* FINGERPRINT_RADIALSCREENED_H_ */

View File

@ -34,29 +34,29 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "rann_fingerprint.h" #include "rann_fingerprint.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace RANN { namespace RANN {
class Fingerprint_radialspin : public Fingerprint { class Fingerprint_radialspin : public Fingerprint {
public: public:
Fingerprint_radialspin(PairRANN *); Fingerprint_radialspin(PairRANN *);
~Fingerprint_radialspin(); ~Fingerprint_radialspin();
bool parse_values(std::string,std::vector<std::string>); bool parse_values(std::string, std::vector<std::string>);
void write_values(FILE *); void write_values(FILE *);
void init(int*,int); void init(int *, int);
void allocate(); void allocate();
void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
int get_length(); int, int, double *, double *, double *, int *, int, int *);
int get_length();
double *radialtable; double *radialtable;
double *dfctable; double *dfctable;
double dr; double dr;
double *alpha; double *alpha;
double re; double re;
int nmax;//highest term int nmax; //highest term
int omin;//lowest term int omin; //lowest term
};
} // namespace RANN
}; } // namespace LAMMPS_NS
}
}
#endif /* FINGERPRINT_RADIAL_H_ */ #endif /* FINGERPRINT_RADIAL_H_ */

View File

@ -56,7 +56,7 @@ class PairSNAP : public Pair {
double **coeffelem; // element bispectrum coefficients double **coeffelem; // element bispectrum coefficients
double **beta; // betas for all atoms in list double **beta; // betas for all atoms in list
double **bispectrum; // bispectrum components for all atoms in list double **bispectrum; // bispectrum components for all atoms in list
double **scale; // for thermodynamic integration double **scale; // for thermodynamic integration
int twojmax, switchflag, bzeroflag, bnormflag; int twojmax, switchflag, bzeroflag, bnormflag;
int chemflag, wselfallflag; int chemflag, wselfallflag;
int chunksize; int chunksize;

View File

@ -114,7 +114,7 @@ void DumpAtomMPIIO::openfile()
mpifo = 0; mpifo = 0;
MPI_File_set_size(mpifh, (MPI_Offset)(headerSize + sumFileSize)); MPI_File_set_size(mpifh, (MPI_Offset) (headerSize + sumFileSize));
currentFileSize = (headerSize + sumFileSize); currentFileSize = (headerSize + sumFileSize);
} }
} }

View File

@ -129,7 +129,7 @@ void DumpCustomMPIIO::openfile()
mpifo = 0; mpifo = 0;
MPI_File_set_size(mpifh, (MPI_Offset)(headerSize + sumFileSize)); MPI_File_set_size(mpifh, (MPI_Offset) (headerSize + sumFileSize));
currentFileSize = (headerSize + sumFileSize); currentFileSize = (headerSize + sumFileSize);
} }
} }

View File

@ -221,7 +221,8 @@ void PairLJCutCoulCutDielectricOMP::eval(int iifrom, int iito, ThrData *const th
} }
if (EVFLAG) if (EVFLAG)
ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, ecoul, fpair_i, delx, dely, delz, thr); ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, ecoul, fpair_i, delx, dely, delz,
thr);
} }
} }
f[i].x += fxtmp; f[i].x += fxtmp;

View File

@ -33,10 +33,10 @@ class PairLJCutCoulCutDielectricOMP : public PairLJCutCoulCutDielectric, public
protected: protected:
template <int EVFLAG, int EFLAG, int NEWTON_PAIR> template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void eval(int ifrom, int ito, ThrData * const thr); void eval(int ifrom, int ito, ThrData *const thr);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -34,10 +34,10 @@ class PairLJCutCoulLongDielectricOMP : public PairLJCutCoulLongDielectric, publi
protected: protected:
template <int EVFLAG, int EFLAG, int NEWTON_PAIR> template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void eval(int ifrom, int ito, ThrData * const thr); void eval(int ifrom, int ito, ThrData *const thr);
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -48,31 +48,29 @@ class PairReaxFFOMP : public PairReaxFF, public ThrOMP {
reduce_thr(styleparm, eflagparm, vflagparm, thrparm); reduce_thr(styleparm, eflagparm, vflagparm, thrparm);
} }
inline void ev_tally_thr_proxy(const int iparm, const int jparm, inline void ev_tally_thr_proxy(const int iparm, const int jparm, const int nlocalparm,
const int nlocalparm, const int newton_pairparm, const int newton_pairparm, const double evdwlparm,
const double evdwlparm, const double ecoulparm, const double ecoulparm, const double fpairparm,
const double fpairparm, const double delxparm, const double delxparm, const double delyparm,
const double delyparm, const double delzparm, const double delzparm, ThrData *const thrparm)
ThrData *const thrparm)
{ {
ev_tally_thr(this, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, ev_tally_thr(this, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, fpairparm,
fpairparm, delxparm, delyparm, delzparm, thrparm); delxparm, delyparm, delzparm, thrparm);
} }
inline void ev_tally_xyz_thr_proxy(const int iparm, const int jparm, inline void ev_tally_xyz_thr_proxy(const int iparm, const int jparm, const int nlocalparm,
const int nlocalparm, const int newton_pairparm, const int newton_pairparm, const double evdwlparm,
const double evdwlparm, const double ecoulparm, const double ecoulparm, const double fxparm,
const double fxparm, const double fyparm, const double fzparm, const double fyparm, const double fzparm,
const double delxparm, const double delyparm, const double delxparm, const double delyparm,
const double delzparm, ThrData *const thrparm) const double delzparm, ThrData *const thrparm)
{ {
ev_tally_xyz_thr(this, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, ev_tally_xyz_thr(this, iparm, jparm, nlocalparm, newton_pairparm, evdwlparm, ecoulparm, fxparm,
fxparm, fyparm, fzparm, delxparm, delyparm, delzparm, thrparm); fyparm, fzparm, delxparm, delyparm, delzparm, thrparm);
} }
inline void ev_tally3_thr_proxy(int i, int j, int k, double evdwl, inline void ev_tally3_thr_proxy(int i, int j, int k, double evdwl, double ecoul, double *fj,
double ecoul, double *fj, double *fk, double *drji, double *drki, double *fk, double *drji, double *drki, ThrData *const thrparm)
ThrData *const thrparm)
{ {
ev_tally3_thr(this, i, j, k, evdwl, ecoul, fj, fk, drji, drki, thrparm); ev_tally3_thr(this, i, j, k, evdwl, ecoul, fj, fk, drji, drki, thrparm);
} }

View File

@ -27,77 +27,73 @@
#include <omp.h> #include <omp.h>
#endif #endif
namespace ReaxFF namespace ReaxFF {
// exported Functions
// bond orders OpenMP
extern void Add_dBond_to_ForcesOMP(reax_system *, int, int, storage *, reax_list **);
extern void Add_dBond_to_Forces_NPTOMP(reax_system *, int, int, storage *, reax_list **);
extern int BOp_OMP(storage *, reax_list *, double, int, int, far_neighbor_data *,
single_body_parameters *, single_body_parameters *, two_body_parameters *, int,
double, double, double, double, double, double, double);
extern void BOOMP(reax_system *, storage *, reax_list **);
// bonds OpenMP
extern void BondsOMP(reax_system *, simulation_data *, storage *, reax_list **);
// forces OpenMP
extern void Compute_ForcesOMP(reax_system *, control_params *, simulation_data *, storage *,
reax_list **);
// hydrogen bonds
extern void Hydrogen_BondsOMP(reax_system *, control_params *, simulation_data *, storage *,
reax_list **);
// init md OpenMP
extern void InitializeOMP(reax_system *, control_params *, simulation_data *, storage *,
reax_list **, MPI_Comm);
// multi body
extern void Atom_EnergyOMP(reax_system *, simulation_data *, storage *, reax_list **);
// nonbonded
extern void vdW_Coulomb_Energy_OMP(reax_system *, control_params *, simulation_data *, storage *,
reax_list **);
extern void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *, control_params *, simulation_data *,
storage *, reax_list **);
extern void LR_vdW_CoulombOMP(reax_system *, storage *, control_params *, int, int, double,
LR_data *);
// torsion angles
extern void Torsion_AnglesOMP(reax_system *, control_params *, simulation_data *, storage *,
reax_list **);
// valence angles
extern void Calculate_ThetaOMP(rvec, double, rvec, double, double *, double *);
extern void Calculate_dCos_ThetaOMP(rvec, double, rvec, double, rvec *, rvec *, rvec *);
extern void Valence_AnglesOMP(reax_system *, control_params *, simulation_data *, storage *,
reax_list **);
// OpenMP helpers
inline int get_tid()
{ {
// exported Functions
// bond orders OpenMP
extern void Add_dBond_to_ForcesOMP(reax_system *, int, int, storage *, reax_list **);
extern void Add_dBond_to_Forces_NPTOMP(reax_system *, int, int, storage *, reax_list **);
extern int BOp_OMP(storage *, reax_list *, double, int, int, far_neighbor_data *,
single_body_parameters *, single_body_parameters *,
two_body_parameters *, int, double, double, double,
double, double, double, double);
extern void BOOMP(reax_system *, storage *, reax_list **);
// bonds OpenMP
extern void BondsOMP(reax_system *, simulation_data *,
storage *, reax_list **);
// forces OpenMP
extern void Compute_ForcesOMP(reax_system *, control_params *,
simulation_data *, storage *, reax_list **);
// hydrogen bonds
extern void Hydrogen_BondsOMP(reax_system *, control_params *,
simulation_data *, storage *, reax_list **);
// init md OpenMP
extern void InitializeOMP(reax_system *, control_params *, simulation_data *,
storage *, reax_list **,MPI_Comm);
// multi body
extern void Atom_EnergyOMP(reax_system *, simulation_data *, storage *, reax_list **);
// nonbonded
extern void vdW_Coulomb_Energy_OMP(reax_system *, control_params *,
simulation_data *, storage *, reax_list **);
extern void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *, control_params *,
simulation_data *, storage *,
reax_list **);
extern void LR_vdW_CoulombOMP(reax_system *, storage *, control_params *,
int, int, double, LR_data *);
// torsion angles
extern void Torsion_AnglesOMP(reax_system *, control_params *,
simulation_data *, storage *, reax_list **);
// valence angles
extern void Calculate_ThetaOMP(rvec, double, rvec, double, double *, double *);
extern void Calculate_dCos_ThetaOMP(rvec, double, rvec, double,
rvec *, rvec *, rvec *);
extern void Valence_AnglesOMP(reax_system *, control_params *, simulation_data *,
storage *, reax_list **);
// OpenMP helpers
inline int get_tid() {
#if defined(_OPENMP) #if defined(_OPENMP)
return omp_get_thread_num(); return omp_get_thread_num();
#else #else
return 0; return 0;
#endif #endif
}
} }
} // namespace ReaxFF
#endif #endif

View File

@ -135,8 +135,10 @@ class ThrOMP {
void ev_tally_xyz_full_thr(Pair *const, const int, const double, const double, const double, void ev_tally_xyz_full_thr(Pair *const, const int, const double, const double, const double,
const double, const double, const double, const double, const double, const double, const double, const double, const double, const double,
ThrData *const); ThrData *const);
void v_tally2_thr(Pair *const, const int, const int, const double, const double *const, ThrData *const); void v_tally2_thr(Pair *const, const int, const int, const double, const double *const,
void v_tally2_newton_thr(Pair *const, const int, const double *const, const double *const, ThrData *const); ThrData *const);
void v_tally2_newton_thr(Pair *const, const int, const double *const, const double *const,
ThrData *const);
void ev_tally3_thr(Pair *const, const int, const int, const int, const double, const double, void ev_tally3_thr(Pair *const, const int, const int, const int, const double, const double,
const double *const, const double *const, const double *const, const double *const, const double *const, const double *const,
const double *const, ThrData *const); const double *const, ThrData *const);

View File

@ -1340,13 +1340,17 @@ void FixSRD::collisions_single()
std::string mesg; std::string mesg;
if (type != WALL) if (type != WALL)
mesg = fmt::format("SRD particle {} started inside big particle {} on step {} " mesg = fmt::format("SRD particle {} started inside big particle {} on step {} "
" bounce {}", tag[i], tag[j], update->ntimestep, ibounce + 1); " bounce {}",
tag[i], tag[j], update->ntimestep, ibounce + 1);
else else
mesg = fmt::format("SRD particle {} started inside wall {} on step {} " mesg = fmt::format("SRD particle {} started inside wall {} on step {} "
"bounce {}", tag[i], j, update->ntimestep, ibounce + 1); "bounce {}",
tag[i], j, update->ntimestep, ibounce + 1);
if (insideflag == INSIDE_ERROR) error->one(FLERR, mesg); if (insideflag == INSIDE_ERROR)
else error->warning(FLERR, mesg); error->one(FLERR, mesg);
else
error->warning(FLERR, mesg);
} }
break; break;
} }
@ -1490,10 +1494,12 @@ void FixSRD::collisions_multi()
std::string mesg; std::string mesg;
if (type != WALL) if (type != WALL)
mesg = fmt::format("SRD particle {} started inside big particle {} on step {} " mesg = fmt::format("SRD particle {} started inside big particle {} on step {} "
"bounce {}", tag[i], tag[j], update->ntimestep, ibounce + 1); "bounce {}",
tag[i], tag[j], update->ntimestep, ibounce + 1);
else else
mesg = fmt::format("SRD particle {} started inside wall {} on step {} " mesg = fmt::format("SRD particle {} started inside wall {} on step {} "
"bounce {}", tag[i], j, update->ntimestep, ibounce + 1); "bounce {}",
tag[i], j, update->ntimestep, ibounce + 1);
if (insideflag == INSIDE_ERROR) error->one(FLERR, mesg); if (insideflag == INSIDE_ERROR) error->one(FLERR, mesg);
error->warning(FLERR, mesg); error->warning(FLERR, mesg);

View File

@ -214,6 +214,6 @@ void ComputeForceTally::compute_peratom()
double ComputeForceTally::memory_usage() double ComputeForceTally::memory_usage()
{ {
double bytes = (nmax < 0) ? 0 : nmax * (double)size_peratom_cols * sizeof(double); double bytes = (nmax < 0) ? 0 : nmax * (double) size_peratom_cols * sizeof(double);
return bytes; return bytes;
} }

View File

@ -281,6 +281,6 @@ void ComputeHeatFluxTally::compute_vector()
double ComputeHeatFluxTally::memory_usage() double ComputeHeatFluxTally::memory_usage()
{ {
double bytes = (nmax < 0) ? 0 : nmax * (double)comm_reverse * sizeof(double); double bytes = (nmax < 0) ? 0 : nmax * (double) comm_reverse * sizeof(double);
return bytes; return bytes;
} }

View File

@ -233,6 +233,6 @@ void ComputeHeatFluxVirialTally::compute_peratom()
double ComputeHeatFluxVirialTally::memory_usage() double ComputeHeatFluxVirialTally::memory_usage()
{ {
double bytes = (nmax < 0) ? 0 : nmax * (double)size_peratom_cols * sizeof(double); double bytes = (nmax < 0) ? 0 : nmax * (double) size_peratom_cols * sizeof(double);
return bytes; return bytes;
} }

View File

@ -203,6 +203,6 @@ void ComputePETally::compute_peratom()
double ComputePETally::memory_usage() double ComputePETally::memory_usage()
{ {
double bytes = (nmax < 0) ? 0 : nmax * (double)size_peratom_cols * sizeof(double); double bytes = (nmax < 0) ? 0 : nmax * (double) size_peratom_cols * sizeof(double);
return bytes; return bytes;
} }

View File

@ -253,6 +253,6 @@ void ComputeStressTally::compute_peratom()
double ComputeStressTally::memory_usage() double ComputeStressTally::memory_usage()
{ {
double bytes = (nmax < 0) ? 0 : nmax * (double)size_peratom_cols * sizeof(double); double bytes = (nmax < 0) ? 0 : nmax * (double) size_peratom_cols * sizeof(double);
return bytes; return bytes;
} }