Merge branch 'develop' into acks2_bug

This commit is contained in:
Axel Kohlmeyer
2022-04-04 15:39:44 -04:00
18 changed files with 1152 additions and 411 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,17 +18,17 @@
#include "compute_msd_nongauss.h"
#include "atom.h"
#include "update.h"
#include "group.h"
#include "domain.h"
#include "fix_store.h"
#include "group.h"
#include "update.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeMSDNonGauss::ComputeMSDNonGauss(LAMMPS *lmp, int narg, char **arg) :
ComputeMSD(lmp, narg, arg)
ComputeMSD(lmp, narg, arg)
{
size_vector = 3;
}
@ -43,8 +42,10 @@ void ComputeMSDNonGauss::compute_vector()
// cm = current center of mass
double cm[3];
if (comflag) group->xcm(igroup,masstotal,cm);
else cm[0] = cm[1] = cm[2] = 0.0;
if (comflag)
group->xcm(igroup, masstotal, cm);
else
cm[0] = cm[1] = cm[2] = 0.0;
// dx,dy,dz = displacement of atom from original position
// original unwrapped position is stored by fix
@ -63,8 +64,8 @@ void ComputeMSDNonGauss::compute_vector()
double yprd = domain->yprd;
double zprd = domain->zprd;
double dx,dy,dz;
int xbox,ybox,zbox;
double dx, dy, dz;
int xbox, ybox, zbox;
double msd[2];
msd[0] = msd[1] = 0.0;
@ -75,11 +76,11 @@ void ComputeMSDNonGauss::compute_vector()
xbox = (image[i] & IMGMASK) - IMGMAX;
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
zbox = (image[i] >> IMG2BITS) - IMGMAX;
dx = x[i][0] + xbox*xprd - cm[0] - xoriginal[i][0];
dy = x[i][1] + ybox*yprd - cm[1] - xoriginal[i][1];
dz = x[i][2] + zbox*zprd - cm[2] - xoriginal[i][2];
msd[0] += dx*dx + dy*dy + dz*dz;
msd[1] += (dx*dx + dy*dy + dz*dz)*(dx*dx + dy*dy + dz*dz);
dx = x[i][0] + xbox * xprd - cm[0] - xoriginal[i][0];
dy = x[i][1] + ybox * yprd - cm[1] - xoriginal[i][1];
dz = x[i][2] + zbox * zprd - cm[2] - xoriginal[i][2];
msd[0] += dx * dx + dy * dy + dz * dz;
msd[1] += (dx * dx + dy * dy + dz * dz) * (dx * dx + dy * dy + dz * dz);
}
} else {
@ -88,19 +89,18 @@ void ComputeMSDNonGauss::compute_vector()
xbox = (image[i] & IMGMASK) - IMGMAX;
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
zbox = (image[i] >> IMG2BITS) - IMGMAX;
dx = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox -
cm[0] - xoriginal[i][0];
dy = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1] - xoriginal[i][1];
dz = x[i][2] + h[2]*zbox - cm[2] - xoriginal[i][2];
msd[0] += dx*dx + dy*dy + dz*dz;
msd[1] += (dx*dx + dy*dy + dz*dz)*(dx*dx + dy*dy + dz*dz);
dx = x[i][0] + h[0] * xbox + h[5] * ybox + h[4] * zbox - cm[0] - xoriginal[i][0];
dy = x[i][1] + h[1] * ybox + h[3] * zbox - cm[1] - xoriginal[i][1];
dz = x[i][2] + h[2] * zbox - cm[2] - xoriginal[i][2];
msd[0] += dx * dx + dy * dy + dz * dz;
msd[1] += (dx * dx + dy * dy + dz * dz) * (dx * dx + dy * dy + dz * dz);
}
}
MPI_Allreduce(msd,vector,2,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(msd, vector, 2, MPI_DOUBLE, MPI_SUM, world);
if (nmsd) {
vector[0] /= nmsd;
vector[1] /= nmsd;
vector[2] = (3*vector[1])/(5*vector[0]*vector[0]) - 1;
vector[2] = (3 * vector[1]) / (5 * vector[0] * vector[0]) - 1;
}
}

View File

@ -2692,7 +2692,7 @@ int PairReaxFFKokkos<DeviceType>::preprocess_angular(int i, int itype, int j_sta
pack.i0 = i_index;
pack.i1 = j_index;
pack.i2 = k_index;
pack.i3 = j_end;
pack.i3 = j_end;
d_angular_pack(location_angular, 1) = pack;
location_angular++;
@ -3380,7 +3380,7 @@ void PairReaxFFKokkos<DeviceType>::operator()(TagPairReaxComputeTorsionPreproces
}
}
}
template<class DeviceType>
@ -3801,7 +3801,7 @@ void PairReaxFFKokkos<DeviceType>::operator()(TagPairReaxComputeBond2<NEIGHFLAG,
F_FLOAT d_dBOp_local = d_dBOp(i,j_index);
for (int d = 0; d < 3; d++) dBOp_i[d] = d_dBOp_local * delij[d];
// forces on i
for (int d = 0; d < 3; d++) temp[d] = coef_C1dbo * dBOp_i[d];
for (int d = 0; d < 3; d++) temp[d] += coef_C2dbo * d_dDeltap_self(i,d);

View File

@ -195,7 +195,7 @@ class PairReaxFFKokkos : public PairReaxFF {
// Isolated function that computes bond order parameters
// Returns BO_s, BO_pi, BO_pi2, C12, C34, C56 by reference
KOKKOS_INLINE_FUNCTION
void compute_bo(F_FLOAT, int, int, F_FLOAT, F_FLOAT, F_FLOAT,
void compute_bo(F_FLOAT, int, int, F_FLOAT, F_FLOAT, F_FLOAT,
F_FLOAT&, F_FLOAT&, F_FLOAT&, F_FLOAT&, F_FLOAT&, F_FLOAT&) const;
KOKKOS_INLINE_FUNCTION

View File

@ -102,13 +102,15 @@ void PairSNAPKokkos<DeviceType, real_type, vector_length>::init_style()
if (force->newton_pair == 0)
error->all(FLERR,"Pair style SNAP requires newton pair on");
// adjust neighbor list request for KOKKOS
// neighbor list request for KOKKOS
neighflag = lmp->kokkos->neighflag;
auto request = neighbor->add_request(this, NeighConst::REQ_FULL);
request->set_kokkos_host(std::is_same<DeviceType,LMPHostType>::value &&
!std::is_same<DeviceType,LMPDeviceType>::value);
request->set_kokkos_device(std::is_same<DeviceType,LMPDeviceType>::value);
if (lmp->kokkos->neighflag == FULL)
if (neighflag == FULL)
error->all(FLERR,"Must use half neighbor list style with pair snap/kk");
}

View File

@ -1916,7 +1916,12 @@ void DumpVTK::identify_vectors()
name.count(vector3_starts[v3s]+2) )
{
std::string vectorName = name[vector3_starts[v3s]];
vectorName.erase(vectorName.find_first_of('x'));
std::string::size_type erase_start = vectorName.find_first_of('x');
if (erase_start == 0) {
vectorName.erase(0,1);
} else {
vectorName.erase(erase_start);
}
name[vector3_starts[v3s]] = vectorName;
vector_set.insert(vector3_starts[v3s]);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -28,11 +27,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
id_fix(nullptr)
ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), id_fix(nullptr)
{
if (narg < 3) error->all(FLERR,"Illegal compute msd command");
if (narg < 3) error->all(FLERR, "Illegal compute msd command");
vector_flag = 1;
size_vector = 4;
@ -47,28 +44,33 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
int iarg = 3;
while (iarg < narg) {
if (strcmp(arg[iarg],"com") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal compute msd command");
comflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
if (strcmp(arg[iarg], "com") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command");
comflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"average") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal compute msd command");
avflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "average") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command");
avflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else error->all(FLERR,"Illegal compute msd command");
} else
error->all(FLERR, "Illegal compute msd command");
}
if (group->dynamic[igroup])
error->all(FLERR, "Compute {} is not compatible with dynamic groups", style);
// create a new fix STORE style for reference positions
// id = compute-ID + COMPUTE_STORE, fix group = compute group
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
fix = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 3",
id_fix, group->names[igroup]));
fix = (FixStore *) modify->add_fix(
fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup]));
// calculate xu,yu,zu for fix store array
// skip if reset from restart file
if (fix->restart_reset) fix->restart_reset = 0;
if (fix->restart_reset)
fix->restart_reset = 0;
else {
double **xoriginal = fix->astore;
@ -78,15 +80,17 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) domain->unmap(x[i],image[i],xoriginal[i]);
else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
if (mask[i] & groupbit)
domain->unmap(x[i], image[i], xoriginal[i]);
else
xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
// adjust for COM if requested
if (comflag) {
double cm[3];
masstotal = group->mass(igroup);
group->xcm(igroup,masstotal,cm);
group->xcm(igroup, masstotal, cm);
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
xoriginal[i][0] -= cm[0];
@ -124,7 +128,7 @@ void ComputeMSD::init()
// set fix which stores reference atom coords
fix = (FixStore *) modify->get_fix_by_id(id_fix);
if (!fix) error->all(FLERR,"Could not find compute msd fix with ID {}", id_fix);
if (!fix) error->all(FLERR, "Could not find compute msd fix with ID {}", id_fix);
// nmsd = # of atoms in group
@ -141,8 +145,10 @@ void ComputeMSD::compute_vector()
// cm = current center of mass
double cm[3];
if (comflag) group->xcm(igroup,masstotal,cm);
else cm[0] = cm[1] = cm[2] = 0.0;
if (comflag)
group->xcm(igroup, masstotal, cm);
else
cm[0] = cm[1] = cm[2] = 0.0;
// dx,dy,dz = displacement of atom from reference position
// reference unwrapped position is stored by fix
@ -161,8 +167,8 @@ void ComputeMSD::compute_vector()
double yprd = domain->yprd;
double zprd = domain->zprd;
double dx,dy,dz;
int xbox,ybox,zbox;
double dx, dy, dz;
int xbox, ybox, zbox;
double msd[4];
msd[0] = msd[1] = msd[2] = msd[3] = 0.0;
@ -174,36 +180,34 @@ void ComputeMSD::compute_vector()
double navfac;
if (avflag) {
naverage++;
navfac = 1.0/(naverage+1);
navfac = 1.0 / (naverage + 1);
}
if (domain->triclinic == 0) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
xbox = (image[i] & IMGMASK) - IMGMAX;
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
zbox = (image[i] >> IMG2BITS) - IMGMAX;
xtmp = x[i][0] + xbox*xprd - cm[0];
ytmp = x[i][1] + ybox*yprd - cm[1];
ztmp = x[i][2] + zbox*zprd - cm[2];
xtmp = x[i][0] + xbox * xprd - cm[0];
ytmp = x[i][1] + ybox * yprd - cm[1];
ztmp = x[i][2] + zbox * zprd - cm[2];
// use running average position for reference if requested
if (avflag) {
xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac;
xoriginal[i][1] = (xoriginal[i][1]*naverage + ytmp)*navfac;
xoriginal[i][2] = (xoriginal[i][2]*naverage + ztmp)*navfac;
xoriginal[i][0] = (xoriginal[i][0] * naverage + xtmp) * navfac;
xoriginal[i][1] = (xoriginal[i][1] * naverage + ytmp) * navfac;
xoriginal[i][2] = (xoriginal[i][2] * naverage + ztmp) * navfac;
}
dx = xtmp - xoriginal[i][0];
dy = ytmp - xoriginal[i][1];
dz = ztmp - xoriginal[i][2];
msd[0] += dx*dx;
msd[1] += dy*dy;
msd[2] += dz*dz;
msd[3] += dx*dx + dy*dy + dz*dz;
msd[0] += dx * dx;
msd[1] += dy * dy;
msd[2] += dz * dz;
msd[3] += dx * dx + dy * dy + dz * dz;
}
} else {
for (int i = 0; i < nlocal; i++)
@ -211,29 +215,29 @@ void ComputeMSD::compute_vector()
xbox = (image[i] & IMGMASK) - IMGMAX;
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
zbox = (image[i] >> IMG2BITS) - IMGMAX;
xtmp = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox - cm[0];
ytmp = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1];
ztmp = x[i][2] + h[2]*zbox - cm[2];
xtmp = x[i][0] + h[0] * xbox + h[5] * ybox + h[4] * zbox - cm[0];
ytmp = x[i][1] + h[1] * ybox + h[3] * zbox - cm[1];
ztmp = x[i][2] + h[2] * zbox - cm[2];
// use running average position for reference if requested
if (avflag) {
xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac;
xoriginal[i][1] = (xoriginal[i][0]*naverage + xtmp)*navfac;
xoriginal[i][2] = (xoriginal[i][0]*naverage + xtmp)*navfac;
xoriginal[i][0] = (xoriginal[i][0] * naverage + xtmp) * navfac;
xoriginal[i][1] = (xoriginal[i][0] * naverage + xtmp) * navfac;
xoriginal[i][2] = (xoriginal[i][0] * naverage + xtmp) * navfac;
}
dx = xtmp - xoriginal[i][0];
dy = ytmp - xoriginal[i][1];
dz = ztmp - xoriginal[i][2];
msd[0] += dx*dx;
msd[1] += dy*dy;
msd[2] += dz*dz;
msd[3] += dx*dx + dy*dy + dz*dz;
msd[0] += dx * dx;
msd[1] += dy * dy;
msd[2] += dz * dz;
msd[3] += dx * dx + dy * dy + dz * dz;
}
}
MPI_Allreduce(msd,vector,4,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(msd, vector, 4, MPI_DOUBLE, MPI_SUM, world);
if (nmsd) {
vector[0] /= nmsd;
vector[1] /= nmsd;

File diff suppressed because it is too large Load Diff