enabled and apply clang-format
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -13,38 +12,40 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "compute_angle_local.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "angle.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
#include "molecule.h"
|
||||
#include "update.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "angle.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "molecule.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
static constexpr int DELTA = 10000;
|
||||
|
||||
enum{THETA,ENG,VARIABLE};
|
||||
enum { THETA, ENG, VARIABLE };
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
bstyle(nullptr), vvar(nullptr), tstr(nullptr), vstr(nullptr), vlocal(nullptr), alocal(nullptr)
|
||||
Compute(lmp, narg, arg), bstyle(nullptr), vvar(nullptr), tstr(nullptr), vstr(nullptr),
|
||||
vlocal(nullptr), alocal(nullptr)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute angle/local command");
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute angle/local command");
|
||||
|
||||
if (atom->avec->angles_allow == 0)
|
||||
error->all(FLERR,"Compute angle/local used when angles are not allowed");
|
||||
error->all(FLERR, "Compute angle/local used when angles are not allowed");
|
||||
|
||||
local_flag = 1;
|
||||
|
||||
@ -52,7 +53,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
nvalues = narg - 3;
|
||||
bstyle = new int[nvalues];
|
||||
vstr = new char*[nvalues];
|
||||
vstr = new char *[nvalues];
|
||||
vvar = new int[nvalues];
|
||||
|
||||
nvalues = 0;
|
||||
@ -61,16 +62,17 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int iarg;
|
||||
for (iarg = 3; iarg < narg; iarg++) {
|
||||
if (strcmp(arg[iarg],"theta") == 0) {
|
||||
if (strcmp(arg[iarg], "theta") == 0) {
|
||||
bstyle[nvalues++] = THETA;
|
||||
tflag = 1;
|
||||
} else if (strcmp(arg[iarg],"eng") == 0) {
|
||||
} else if (strcmp(arg[iarg], "eng") == 0) {
|
||||
bstyle[nvalues++] = ENG;
|
||||
} else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
} else if (strncmp(arg[iarg], "v_", 2) == 0) {
|
||||
bstyle[nvalues++] = VARIABLE;
|
||||
vstr[nvar] = utils::strdup(&arg[iarg][2]);
|
||||
nvar++;
|
||||
} else break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
// optional args
|
||||
@ -79,45 +81,46 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
tstr = nullptr;
|
||||
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"set") == 0) {
|
||||
if (strcmp(arg[iarg], "set") == 0) {
|
||||
setflag = 1;
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal compute angle/local command");
|
||||
if (strcmp(arg[iarg+1],"theta") == 0) {
|
||||
delete [] tstr;
|
||||
tstr = utils::strdup(arg[iarg+2]);
|
||||
if (iarg + 3 > narg) error->all(FLERR, "Illegal compute angle/local command");
|
||||
if (strcmp(arg[iarg + 1], "theta") == 0) {
|
||||
delete[] tstr;
|
||||
tstr = utils::strdup(arg[iarg + 2]);
|
||||
tflag = 1;
|
||||
} else error->all(FLERR,"Illegal compute angle/local command");
|
||||
} else
|
||||
error->all(FLERR, "Illegal compute angle/local command");
|
||||
iarg += 3;
|
||||
} else error->all(FLERR,"Illegal compute angle/local command");
|
||||
} else
|
||||
error->all(FLERR, "Illegal compute angle/local command");
|
||||
}
|
||||
|
||||
// error check
|
||||
|
||||
if (nvar) {
|
||||
if (!setflag)
|
||||
error->all(FLERR,"Compute angle/local variable requires a set variable");
|
||||
if (!setflag) error->all(FLERR, "Compute angle/local variable requires a set variable");
|
||||
for (int i = 0; i < nvar; i++) {
|
||||
vvar[i] = input->variable->find(vstr[i]);
|
||||
if (vvar[i] < 0)
|
||||
error->all(FLERR,"Variable name for copute angle/local does not exist");
|
||||
if (vvar[i] < 0) error->all(FLERR, "Variable name for copute angle/local does not exist");
|
||||
if (!input->variable->equalstyle(vvar[i]))
|
||||
error->all(FLERR,"Variable for compute angle/local is invalid style");
|
||||
error->all(FLERR, "Variable for compute angle/local is invalid style");
|
||||
}
|
||||
|
||||
if (tstr) {
|
||||
tvar = input->variable->find(tstr);
|
||||
if (tvar < 0)
|
||||
error->all(FLERR,"Variable name for compute angle/local does not exist");
|
||||
if (tvar < 0) error->all(FLERR, "Variable name for compute angle/local does not exist");
|
||||
if (!input->variable->internalstyle(tvar))
|
||||
error->all(FLERR,"Variable for compute angle/local is invalid style");
|
||||
error->all(FLERR, "Variable for compute angle/local is invalid style");
|
||||
}
|
||||
} else if (setflag)
|
||||
error->all(FLERR,"Compute angle/local set with no variable");
|
||||
error->all(FLERR, "Compute angle/local set with no variable");
|
||||
|
||||
// initialize output
|
||||
|
||||
if (nvalues == 1) size_local_cols = 0;
|
||||
else size_local_cols = nvalues;
|
||||
if (nvalues == 1)
|
||||
size_local_cols = 0;
|
||||
else
|
||||
size_local_cols = nvalues;
|
||||
|
||||
nmax = 0;
|
||||
vlocal = nullptr;
|
||||
@ -128,12 +131,12 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
ComputeAngleLocal::~ComputeAngleLocal()
|
||||
{
|
||||
delete [] bstyle;
|
||||
for (int i = 0; i < nvar; i++) delete [] vstr[i];
|
||||
delete [] vstr;
|
||||
delete [] vvar;
|
||||
delete[] bstyle;
|
||||
for (int i = 0; i < nvar; i++) delete[] vstr[i];
|
||||
delete[] vstr;
|
||||
delete[] vvar;
|
||||
|
||||
delete [] tstr;
|
||||
delete[] tstr;
|
||||
|
||||
memory->destroy(vlocal);
|
||||
memory->destroy(alocal);
|
||||
@ -144,19 +147,17 @@ ComputeAngleLocal::~ComputeAngleLocal()
|
||||
void ComputeAngleLocal::init()
|
||||
{
|
||||
if (force->angle == nullptr)
|
||||
error->all(FLERR,"No angle style is defined for compute angle/local");
|
||||
error->all(FLERR, "No angle style is defined for compute angle/local");
|
||||
|
||||
if (nvar) {
|
||||
for (int i = 0; i < nvar; i++) {
|
||||
vvar[i] = input->variable->find(vstr[i]);
|
||||
if (vvar[i] < 0)
|
||||
error->all(FLERR,"Variable name for compute angle/local does not exist");
|
||||
if (vvar[i] < 0) error->all(FLERR, "Variable name for compute angle/local does not exist");
|
||||
}
|
||||
|
||||
if (tstr) {
|
||||
tvar = input->variable->find(tstr);
|
||||
if (tvar < 0)
|
||||
error->all(FLERR,"Variable name for compute angle/local does not exist");
|
||||
if (tvar < 0) error->all(FLERR, "Variable name for compute angle/local does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,10 +195,10 @@ void ComputeAngleLocal::compute_local()
|
||||
|
||||
int ComputeAngleLocal::compute_angles(int flag)
|
||||
{
|
||||
int i,m,na,atom1,atom2,atom3,imol,iatom,atype,ivar;
|
||||
int i, m, na, atom1, atom2, atom3, imol, iatom, atype, ivar;
|
||||
tagint tagprev;
|
||||
double delx1,dely1,delz1,delx2,dely2,delz2;
|
||||
double rsq1,rsq2,r1,r2,c,theta;
|
||||
double delx1, dely1, delz1, delx2, dely2, delz2;
|
||||
double rsq1, rsq2, r1, r2, c, theta;
|
||||
double *ptr;
|
||||
|
||||
double **x = atom->x;
|
||||
@ -224,7 +225,8 @@ int ComputeAngleLocal::compute_angles(int flag)
|
||||
for (atom2 = 0; atom2 < nlocal; atom2++) {
|
||||
if (!(mask[atom2] & groupbit)) continue;
|
||||
|
||||
if (molecular == Atom::MOLECULAR) na = num_angle[atom2];
|
||||
if (molecular == Atom::MOLECULAR)
|
||||
na = num_angle[atom2];
|
||||
else {
|
||||
if (molindex[atom2] < 0) continue;
|
||||
imol = molindex[atom2];
|
||||
@ -242,8 +244,8 @@ int ComputeAngleLocal::compute_angles(int flag)
|
||||
if (tag[atom2] != onemols[imol]->angle_atom2[atom2][i]) continue;
|
||||
atype = onemols[imol]->angle_type[atom2][i];
|
||||
tagprev = tag[atom2] - iatom - 1;
|
||||
atom1 = atom->map(onemols[imol]->angle_atom1[atom2][i]+tagprev);
|
||||
atom3 = atom->map(onemols[imol]->angle_atom3[atom2][i]+tagprev);
|
||||
atom1 = atom->map(onemols[imol]->angle_atom1[atom2][i] + tagprev);
|
||||
atom3 = atom->map(onemols[imol]->angle_atom3[atom2][i] + tagprev);
|
||||
}
|
||||
|
||||
if (atom1 < 0 || !(mask[atom1] & groupbit)) continue;
|
||||
@ -261,50 +263,54 @@ int ComputeAngleLocal::compute_angles(int flag)
|
||||
delx1 = x[atom1][0] - x[atom2][0];
|
||||
dely1 = x[atom1][1] - x[atom2][1];
|
||||
delz1 = x[atom1][2] - x[atom2][2];
|
||||
domain->minimum_image(delx1,dely1,delz1);
|
||||
domain->minimum_image(delx1, dely1, delz1);
|
||||
|
||||
rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1;
|
||||
rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1;
|
||||
r1 = sqrt(rsq1);
|
||||
|
||||
delx2 = x[atom3][0] - x[atom2][0];
|
||||
dely2 = x[atom3][1] - x[atom2][1];
|
||||
delz2 = x[atom3][2] - x[atom2][2];
|
||||
domain->minimum_image(delx2,dely2,delz2);
|
||||
domain->minimum_image(delx2, dely2, delz2);
|
||||
|
||||
rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2;
|
||||
rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2;
|
||||
r2 = sqrt(rsq2);
|
||||
|
||||
// c = cosine of angle
|
||||
// theta = angle in radians
|
||||
|
||||
c = delx1*delx2 + dely1*dely2 + delz1*delz2;
|
||||
c /= r1*r2;
|
||||
c = delx1 * delx2 + dely1 * dely2 + delz1 * delz2;
|
||||
c /= r1 * r2;
|
||||
if (c > 1.0) c = 1.0;
|
||||
if (c < -1.0) c = -1.0;
|
||||
theta = acos(c);
|
||||
}
|
||||
|
||||
if (nvalues == 1) ptr = &vlocal[m];
|
||||
else ptr = alocal[m];
|
||||
if (nvalues == 1)
|
||||
ptr = &vlocal[m];
|
||||
else
|
||||
ptr = alocal[m];
|
||||
|
||||
if (nvar) {
|
||||
ivar = 0;
|
||||
if (tstr) input->variable->internal_set(tvar,theta);
|
||||
if (tstr) input->variable->internal_set(tvar, theta);
|
||||
}
|
||||
|
||||
for (int n = 0; n < nvalues; n++) {
|
||||
switch (bstyle[n]) {
|
||||
case THETA:
|
||||
ptr[n] = 180.0*theta/MY_PI;
|
||||
break;
|
||||
case ENG:
|
||||
if (atype > 0) ptr[n] = angle->single(atype,atom1,atom2,atom3);
|
||||
else ptr[n] = 0.0;
|
||||
break;
|
||||
case VARIABLE:
|
||||
ptr[n] = input->variable->compute_equal(vvar[ivar]);
|
||||
ivar++;
|
||||
break;
|
||||
case THETA:
|
||||
ptr[n] = 180.0 * theta / MY_PI;
|
||||
break;
|
||||
case ENG:
|
||||
if (atype > 0)
|
||||
ptr[n] = angle->single(atype, atom1, atom2, atom3);
|
||||
else
|
||||
ptr[n] = 0.0;
|
||||
break;
|
||||
case VARIABLE:
|
||||
ptr[n] = input->variable->compute_equal(vvar[ivar]);
|
||||
ivar++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,11 +331,11 @@ void ComputeAngleLocal::reallocate(int n)
|
||||
|
||||
if (nvalues == 1) {
|
||||
memory->destroy(vlocal);
|
||||
memory->create(vlocal,nmax,"angle/local:vector_local");
|
||||
memory->create(vlocal, nmax, "angle/local:vector_local");
|
||||
vector_local = vlocal;
|
||||
} else {
|
||||
memory->destroy(alocal);
|
||||
memory->create(alocal,nmax,nvalues,"angle/local:array_local");
|
||||
memory->create(alocal, nmax, nvalues, "angle/local:array_local");
|
||||
array_local = alocal;
|
||||
}
|
||||
}
|
||||
@ -340,6 +346,6 @@ void ComputeAngleLocal::reallocate(int n)
|
||||
|
||||
double ComputeAngleLocal::memory_usage()
|
||||
{
|
||||
double bytes = (double)nmax*nvalues * sizeof(double);
|
||||
double bytes = (double) nmax * nvalues * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -35,18 +34,35 @@ using namespace LAMMPS_NS;
|
||||
|
||||
static constexpr int DELTA = 10000;
|
||||
|
||||
enum{DIST,DX,DY,DZ,VELVIB,OMEGA,ENGTRANS,ENGVIB,ENGROT,ENGPOT,FORCE,FX,FY,FZ,VARIABLE,BN};
|
||||
enum {
|
||||
DIST,
|
||||
DX,
|
||||
DY,
|
||||
DZ,
|
||||
VELVIB,
|
||||
OMEGA,
|
||||
ENGTRANS,
|
||||
ENGVIB,
|
||||
ENGROT,
|
||||
ENGPOT,
|
||||
FORCE,
|
||||
FX,
|
||||
FY,
|
||||
FZ,
|
||||
VARIABLE,
|
||||
BN
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
bstyle(nullptr), vvar(nullptr), dstr(nullptr), vstr(nullptr), vlocal(nullptr), alocal(nullptr)
|
||||
Compute(lmp, narg, arg), bstyle(nullptr), vvar(nullptr), dstr(nullptr), vstr(nullptr),
|
||||
vlocal(nullptr), alocal(nullptr)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute bond/local command");
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute bond/local command");
|
||||
|
||||
if (atom->avec->bonds_allow == 0)
|
||||
error->all(FLERR,"Compute bond/local used when bonds are not allowed");
|
||||
error->all(FLERR, "Compute bond/local used when bonds are not allowed");
|
||||
|
||||
local_flag = 1;
|
||||
comm_forward = 3;
|
||||
@ -56,7 +72,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
nvalues = narg - 3;
|
||||
bstyle = new int[nvalues];
|
||||
bindex = new int[nvalues];
|
||||
vstr = new char*[nvalues];
|
||||
vstr = new char *[nvalues];
|
||||
vvar = new int[nvalues];
|
||||
|
||||
nvalues = 0;
|
||||
@ -64,30 +80,45 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int iarg;
|
||||
for (iarg = 3; iarg < narg; iarg++) {
|
||||
if (strcmp(arg[iarg],"dist") == 0) bstyle[nvalues++] = DIST;
|
||||
else if (strcmp(arg[iarg],"dx") == 0) bstyle[nvalues++] = DX;
|
||||
else if (strcmp(arg[iarg],"dy") == 0) bstyle[nvalues++] = DY;
|
||||
else if (strcmp(arg[iarg],"dz") == 0) bstyle[nvalues++] = DZ;
|
||||
else if (strcmp(arg[iarg],"engpot") == 0) bstyle[nvalues++] = ENGPOT;
|
||||
else if (strcmp(arg[iarg],"force") == 0) bstyle[nvalues++] = FORCE;
|
||||
else if (strcmp(arg[iarg],"fx") == 0) bstyle[nvalues++] = FX;
|
||||
else if (strcmp(arg[iarg],"fy") == 0) bstyle[nvalues++] = FY;
|
||||
else if (strcmp(arg[iarg],"fz") == 0) bstyle[nvalues++] = FZ;
|
||||
else if (strcmp(arg[iarg],"engvib") == 0) bstyle[nvalues++] = ENGVIB;
|
||||
else if (strcmp(arg[iarg],"engrot") == 0) bstyle[nvalues++] = ENGROT;
|
||||
else if (strcmp(arg[iarg],"engtrans") == 0) bstyle[nvalues++] = ENGTRANS;
|
||||
else if (strcmp(arg[iarg],"omega") == 0) bstyle[nvalues++] = OMEGA;
|
||||
else if (strcmp(arg[iarg],"velvib") == 0) bstyle[nvalues++] = VELVIB;
|
||||
else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
if (strcmp(arg[iarg], "dist") == 0)
|
||||
bstyle[nvalues++] = DIST;
|
||||
else if (strcmp(arg[iarg], "dx") == 0)
|
||||
bstyle[nvalues++] = DX;
|
||||
else if (strcmp(arg[iarg], "dy") == 0)
|
||||
bstyle[nvalues++] = DY;
|
||||
else if (strcmp(arg[iarg], "dz") == 0)
|
||||
bstyle[nvalues++] = DZ;
|
||||
else if (strcmp(arg[iarg], "engpot") == 0)
|
||||
bstyle[nvalues++] = ENGPOT;
|
||||
else if (strcmp(arg[iarg], "force") == 0)
|
||||
bstyle[nvalues++] = FORCE;
|
||||
else if (strcmp(arg[iarg], "fx") == 0)
|
||||
bstyle[nvalues++] = FX;
|
||||
else if (strcmp(arg[iarg], "fy") == 0)
|
||||
bstyle[nvalues++] = FY;
|
||||
else if (strcmp(arg[iarg], "fz") == 0)
|
||||
bstyle[nvalues++] = FZ;
|
||||
else if (strcmp(arg[iarg], "engvib") == 0)
|
||||
bstyle[nvalues++] = ENGVIB;
|
||||
else if (strcmp(arg[iarg], "engrot") == 0)
|
||||
bstyle[nvalues++] = ENGROT;
|
||||
else if (strcmp(arg[iarg], "engtrans") == 0)
|
||||
bstyle[nvalues++] = ENGTRANS;
|
||||
else if (strcmp(arg[iarg], "omega") == 0)
|
||||
bstyle[nvalues++] = OMEGA;
|
||||
else if (strcmp(arg[iarg], "velvib") == 0)
|
||||
bstyle[nvalues++] = VELVIB;
|
||||
else if (strncmp(arg[iarg], "v_", 2) == 0) {
|
||||
bstyle[nvalues++] = VARIABLE;
|
||||
vstr[nvar] = utils::strdup(&arg[iarg][2]);
|
||||
nvar++;
|
||||
} else if (utils::strmatch(arg[iarg], "^b\\d+$")) { // b1, b2, b3, ... bN
|
||||
} else if (utils::strmatch(arg[iarg], "^b\\d+$")) { // b1, b2, b3, ... bN
|
||||
int n = std::stoi(&arg[iarg][1]);
|
||||
if (n <= 0) error->all(FLERR, "Invalid keyword {} in compute bond/local command", arg[iarg]);
|
||||
bstyle[nvalues] = BN;
|
||||
bindex[nvalues++] = n - 1;
|
||||
} else break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
// optional args
|
||||
@ -96,40 +127,39 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
dstr = nullptr;
|
||||
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"set") == 0) {
|
||||
if (strcmp(arg[iarg], "set") == 0) {
|
||||
setflag = 1;
|
||||
if (iarg+3 > narg) utils::missing_cmd_args(FLERR,"compute bond/local set", error);
|
||||
if (strcmp(arg[iarg+1],"dist") == 0) {
|
||||
delete [] dstr;
|
||||
dstr = utils::strdup(arg[iarg+2]);
|
||||
} else error->all(FLERR,"Unknown compute bond/local set keyword: {}", arg[iarg+2]);
|
||||
if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "compute bond/local set", error);
|
||||
if (strcmp(arg[iarg + 1], "dist") == 0) {
|
||||
delete[] dstr;
|
||||
dstr = utils::strdup(arg[iarg + 2]);
|
||||
} else
|
||||
error->all(FLERR, "Unknown compute bond/local set keyword: {}", arg[iarg + 2]);
|
||||
iarg += 3;
|
||||
} else error->all(FLERR,"Unknown compute bond/local keyword: {}", arg[iarg]);
|
||||
} else
|
||||
error->all(FLERR, "Unknown compute bond/local keyword: {}", arg[iarg]);
|
||||
}
|
||||
|
||||
// error check
|
||||
|
||||
if (nvar) {
|
||||
if (!setflag)
|
||||
error->all(FLERR,"Compute bond/local variable requires a set variable");
|
||||
if (!setflag) error->all(FLERR, "Compute bond/local variable requires a set variable");
|
||||
for (int i = 0; i < nvar; i++) {
|
||||
vvar[i] = input->variable->find(vstr[i]);
|
||||
if (vvar[i] < 0)
|
||||
error->all(FLERR,"Variable name {} for copute bond/local does not exist", vstr[i]);
|
||||
error->all(FLERR, "Variable name {} for copute bond/local does not exist", vstr[i]);
|
||||
if (!input->variable->equalstyle(vvar[i]))
|
||||
error->all(FLERR,"Variable {} for compute bond/local is invalid style", vstr[i]);
|
||||
error->all(FLERR, "Variable {} for compute bond/local is invalid style", vstr[i]);
|
||||
}
|
||||
|
||||
if (dstr) {
|
||||
dvar = input->variable->find(dstr);
|
||||
if (dvar < 0)
|
||||
error->all(FLERR,"Variable name for compute bond/local does not exist");
|
||||
if (dvar < 0) error->all(FLERR, "Variable name for compute bond/local does not exist");
|
||||
if (!input->variable->internalstyle(dvar))
|
||||
error->all(FLERR,"Variable for compute bond/local is invalid style");
|
||||
error->all(FLERR, "Variable for compute bond/local is invalid style");
|
||||
}
|
||||
} else if (setflag)
|
||||
error->all(FLERR,"Compute bond/local set used with without a variable");
|
||||
|
||||
error->all(FLERR, "Compute bond/local set used with without a variable");
|
||||
|
||||
// set singleflag if need to call bond->single()
|
||||
// set velflag if compute any quantities based on velocities
|
||||
@ -137,16 +167,20 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
singleflag = 0;
|
||||
velflag = 0;
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (bstyle[i] == ENGPOT || bstyle[i] == FORCE || bstyle[i] == FX ||
|
||||
bstyle[i] == FY || bstyle[i] == FZ || bstyle[i] == BN) singleflag = 1;
|
||||
if (bstyle[i] == VELVIB || bstyle[i] == OMEGA || bstyle[i] == ENGTRANS ||
|
||||
bstyle[i] == ENGVIB || bstyle[i] == ENGROT) velflag = 1;
|
||||
if (bstyle[i] == ENGPOT || bstyle[i] == FORCE || bstyle[i] == FX || bstyle[i] == FY ||
|
||||
bstyle[i] == FZ || bstyle[i] == BN)
|
||||
singleflag = 1;
|
||||
if (bstyle[i] == VELVIB || bstyle[i] == OMEGA || bstyle[i] == ENGTRANS || bstyle[i] == ENGVIB ||
|
||||
bstyle[i] == ENGROT)
|
||||
velflag = 1;
|
||||
}
|
||||
|
||||
// initialize output
|
||||
|
||||
if (nvalues == 1) size_local_cols = 0;
|
||||
else size_local_cols = nvalues;
|
||||
if (nvalues == 1)
|
||||
size_local_cols = 0;
|
||||
else
|
||||
size_local_cols = nvalues;
|
||||
|
||||
nmax = 0;
|
||||
vlocal = nullptr;
|
||||
@ -157,13 +191,13 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
ComputeBondLocal::~ComputeBondLocal()
|
||||
{
|
||||
delete [] bstyle;
|
||||
delete [] bindex;
|
||||
for (int i = 0; i < nvar; i++) delete [] vstr[i];
|
||||
delete [] vstr;
|
||||
delete [] vvar;
|
||||
delete[] bstyle;
|
||||
delete[] bindex;
|
||||
for (int i = 0; i < nvar; i++) delete[] vstr[i];
|
||||
delete[] vstr;
|
||||
delete[] vvar;
|
||||
|
||||
delete [] dstr;
|
||||
delete[] dstr;
|
||||
|
||||
memory->destroy(vlocal);
|
||||
memory->destroy(alocal);
|
||||
@ -173,8 +207,7 @@ ComputeBondLocal::~ComputeBondLocal()
|
||||
|
||||
void ComputeBondLocal::init()
|
||||
{
|
||||
if (force->bond == nullptr)
|
||||
error->all(FLERR,"No bond style is defined for compute bond/local");
|
||||
if (force->bond == nullptr) error->all(FLERR, "No bond style is defined for compute bond/local");
|
||||
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
if (bstyle[i] == BN && bindex[i] >= force->bond->single_extra)
|
||||
@ -183,21 +216,21 @@ void ComputeBondLocal::init()
|
||||
if (nvar) {
|
||||
for (int i = 0; i < nvar; i++) {
|
||||
vvar[i] = input->variable->find(vstr[i]);
|
||||
if (vvar[i] < 0)
|
||||
error->all(FLERR,"Variable name for compute bond/local does not exist");
|
||||
if (vvar[i] < 0) error->all(FLERR, "Variable name for compute bond/local does not exist");
|
||||
}
|
||||
|
||||
if (dstr) {
|
||||
dvar = input->variable->find(dstr);
|
||||
if (dvar < 0)
|
||||
error->all(FLERR,"Variable name for compute bond/local does not exist");
|
||||
if (dvar < 0) error->all(FLERR, "Variable name for compute bond/local does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
// set ghostvelflag if need to acquire ghost atom velocities
|
||||
|
||||
if (velflag && !comm->ghost_velocity) ghostvelflag = 1;
|
||||
else ghostvelflag = 0;
|
||||
if (velflag && !comm->ghost_velocity)
|
||||
ghostvelflag = 1;
|
||||
else
|
||||
ghostvelflag = 0;
|
||||
|
||||
// do initial memory allocation so that memory_usage() is correct
|
||||
|
||||
@ -236,17 +269,17 @@ void ComputeBondLocal::compute_local()
|
||||
|
||||
int ComputeBondLocal::compute_bonds(int flag)
|
||||
{
|
||||
int i,m,nb,atom1,atom2,imol,iatom,btype,ivar;
|
||||
int i, m, nb, atom1, atom2, imol, iatom, btype, ivar;
|
||||
tagint tagprev;
|
||||
double dx,dy,dz,rsq;
|
||||
double mass1,mass2,masstotal,invmasstotal;
|
||||
double xcm[3],vcm[3];
|
||||
double delr1[3],delr2[3],delv1[3],delv2[3];
|
||||
double r12[3],vpar1,vpar2;
|
||||
double vvib,vrotsq;
|
||||
double inertia,omegasq;
|
||||
double dx, dy, dz, rsq;
|
||||
double mass1, mass2, masstotal, invmasstotal;
|
||||
double xcm[3], vcm[3];
|
||||
double delr1[3], delr2[3], delv1[3], delv2[3];
|
||||
double r12[3], vpar1, vpar2;
|
||||
double vvib, vrotsq;
|
||||
double inertia, omegasq;
|
||||
double mvv2e;
|
||||
double engpot,engtrans,engvib,engrot,fbond;
|
||||
double engpot, engtrans, engvib, engrot, fbond;
|
||||
double *ptr;
|
||||
|
||||
double **x = atom->x;
|
||||
@ -280,7 +313,8 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
for (atom1 = 0; atom1 < nlocal; atom1++) {
|
||||
if (!(mask[atom1] & groupbit)) continue;
|
||||
|
||||
if (molecular == Atom::MOLECULAR) nb = num_bond[atom1];
|
||||
if (molecular == Atom::MOLECULAR)
|
||||
nb = num_bond[atom1];
|
||||
else {
|
||||
if (molindex[atom1] < 0) continue;
|
||||
imol = molindex[atom1];
|
||||
@ -295,7 +329,7 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
} else {
|
||||
tagprev = tag[atom1] - iatom - 1;
|
||||
btype = onemols[imol]->bond_type[iatom][i];
|
||||
atom2 = atom->map(onemols[imol]->bond_atom[iatom][i]+tagprev);
|
||||
atom2 = atom->map(onemols[imol]->bond_atom[iatom][i] + tagprev);
|
||||
}
|
||||
|
||||
if (atom2 < 0 || !(mask[atom2] & groupbit)) continue;
|
||||
@ -310,55 +344,56 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
dx = x[atom1][0] - x[atom2][0];
|
||||
dy = x[atom1][1] - x[atom2][1];
|
||||
dz = x[atom1][2] - x[atom2][2];
|
||||
domain->minimum_image(dx,dy,dz);
|
||||
rsq = dx*dx + dy*dy + dz*dz;
|
||||
domain->minimum_image(dx, dy, dz);
|
||||
rsq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
if (btype == 0) {
|
||||
fbond = 0.0;
|
||||
} else {
|
||||
|
||||
if (singleflag) engpot = bond->single(btype,rsq,atom1,atom2,fbond);
|
||||
else fbond = engpot = 0.0;
|
||||
if (singleflag)
|
||||
engpot = bond->single(btype, rsq, atom1, atom2, fbond);
|
||||
else
|
||||
fbond = engpot = 0.0;
|
||||
engvib = engrot = engtrans = omegasq = vvib = 0.0;
|
||||
|
||||
if (velflag) {
|
||||
if (rmass) {
|
||||
mass1 = rmass[atom1];
|
||||
mass2 = rmass[atom2];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mass1 = mass[type[atom1]];
|
||||
mass2 = mass[type[atom2]];
|
||||
}
|
||||
masstotal = mass1+mass2;
|
||||
masstotal = mass1 + mass2;
|
||||
invmasstotal = 1.0 / (masstotal);
|
||||
xcm[0] = (mass1*x[atom1][0] + mass2*x[atom2][0]) * invmasstotal;
|
||||
xcm[1] = (mass1*x[atom1][1] + mass2*x[atom2][1]) * invmasstotal;
|
||||
xcm[2] = (mass1*x[atom1][2] + mass2*x[atom2][2]) * invmasstotal;
|
||||
vcm[0] = (mass1*v[atom1][0] + mass2*v[atom2][0]) * invmasstotal;
|
||||
vcm[1] = (mass1*v[atom1][1] + mass2*v[atom2][1]) * invmasstotal;
|
||||
vcm[2] = (mass1*v[atom1][2] + mass2*v[atom2][2]) * invmasstotal;
|
||||
xcm[0] = (mass1 * x[atom1][0] + mass2 * x[atom2][0]) * invmasstotal;
|
||||
xcm[1] = (mass1 * x[atom1][1] + mass2 * x[atom2][1]) * invmasstotal;
|
||||
xcm[2] = (mass1 * x[atom1][2] + mass2 * x[atom2][2]) * invmasstotal;
|
||||
vcm[0] = (mass1 * v[atom1][0] + mass2 * v[atom2][0]) * invmasstotal;
|
||||
vcm[1] = (mass1 * v[atom1][1] + mass2 * v[atom2][1]) * invmasstotal;
|
||||
vcm[2] = (mass1 * v[atom1][2] + mass2 * v[atom2][2]) * invmasstotal;
|
||||
|
||||
engtrans = 0.5 * masstotal * MathExtra::lensq3(vcm);
|
||||
|
||||
// r12 = unit bond vector from atom1 to atom2
|
||||
|
||||
MathExtra::sub3(x[atom2],x[atom1],r12);
|
||||
MathExtra::sub3(x[atom2], x[atom1], r12);
|
||||
MathExtra::norm3(r12);
|
||||
|
||||
// delr = vector from COM to each atom
|
||||
// delv = velocity of each atom relative to COM
|
||||
|
||||
MathExtra::sub3(x[atom1],xcm,delr1);
|
||||
MathExtra::sub3(x[atom2],xcm,delr2);
|
||||
MathExtra::sub3(v[atom1],vcm,delv1);
|
||||
MathExtra::sub3(v[atom2],vcm,delv2);
|
||||
MathExtra::sub3(x[atom1], xcm, delr1);
|
||||
MathExtra::sub3(x[atom2], xcm, delr2);
|
||||
MathExtra::sub3(v[atom1], vcm, delv1);
|
||||
MathExtra::sub3(v[atom2], vcm, delv2);
|
||||
|
||||
// vpar = component of delv parallel to bond vector
|
||||
|
||||
vpar1 = MathExtra::dot3(delv1,r12);
|
||||
vpar2 = MathExtra::dot3(delv2,r12);
|
||||
engvib = 0.5 * (mass1*vpar1*vpar1 + mass2*vpar2*vpar2);
|
||||
vpar1 = MathExtra::dot3(delv1, r12);
|
||||
vpar2 = MathExtra::dot3(delv2, r12);
|
||||
engvib = 0.5 * (mass1 * vpar1 * vpar1 + mass2 * vpar2 * vpar2);
|
||||
|
||||
// vvib = relative velocity of 2 atoms along bond direction
|
||||
// vvib < 0 for 2 atoms moving towards each other
|
||||
@ -369,9 +404,8 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
// vrotsq = tangential speed squared of atom1 only
|
||||
// omegasq = omega squared, and is the same for atom1 and atom2
|
||||
|
||||
inertia = mass1*MathExtra::lensq3(delr1) +
|
||||
mass2*MathExtra::lensq3(delr2);
|
||||
vrotsq = MathExtra::lensq3(delv1) - vpar1*vpar1;
|
||||
inertia = mass1 * MathExtra::lensq3(delr1) + mass2 * MathExtra::lensq3(delr2);
|
||||
vrotsq = MathExtra::lensq3(delv1) - vpar1 * vpar1;
|
||||
omegasq = vrotsq / MathExtra::lensq3(delr1);
|
||||
|
||||
engrot = 0.5 * inertia * omegasq;
|
||||
@ -384,12 +418,14 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
engrot *= mvv2e;
|
||||
}
|
||||
|
||||
if (nvalues == 1) ptr = &vlocal[m];
|
||||
else ptr = alocal[m];
|
||||
if (nvalues == 1)
|
||||
ptr = &vlocal[m];
|
||||
else
|
||||
ptr = alocal[m];
|
||||
|
||||
if (nvar) {
|
||||
ivar = 0;
|
||||
if (dstr) input->variable->internal_set(dvar,sqrt(rsq));
|
||||
if (dstr) input->variable->internal_set(dvar, sqrt(rsq));
|
||||
}
|
||||
|
||||
// to make sure dx, dy and dz are always from the lower to the higher id
|
||||
@ -397,55 +433,55 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
|
||||
for (int n = 0; n < nvalues; n++) {
|
||||
switch (bstyle[n]) {
|
||||
case DIST:
|
||||
ptr[n] = sqrt(rsq);
|
||||
break;
|
||||
case DX:
|
||||
ptr[n] = dx*directionCorrection;
|
||||
break;
|
||||
case DY:
|
||||
ptr[n] = dy*directionCorrection;
|
||||
break;
|
||||
case DZ:
|
||||
ptr[n] = dz*directionCorrection;
|
||||
break;
|
||||
case ENGPOT:
|
||||
ptr[n] = engpot;
|
||||
break;
|
||||
case FORCE:
|
||||
ptr[n] = sqrt(rsq)*fbond;
|
||||
break;
|
||||
case FX:
|
||||
ptr[n] = dx*fbond;
|
||||
break;
|
||||
case FY:
|
||||
ptr[n] = dy*fbond;
|
||||
break;
|
||||
case FZ:
|
||||
ptr[n] = dz*fbond;
|
||||
break;
|
||||
case ENGVIB:
|
||||
ptr[n] = engvib;
|
||||
break;
|
||||
case ENGROT:
|
||||
ptr[n] = engrot;
|
||||
break;
|
||||
case ENGTRANS:
|
||||
ptr[n] = engtrans;
|
||||
break;
|
||||
case OMEGA:
|
||||
ptr[n] = sqrt(omegasq);
|
||||
break;
|
||||
case VELVIB:
|
||||
ptr[n] = vvib;
|
||||
break;
|
||||
case VARIABLE:
|
||||
ptr[n] = input->variable->compute_equal(vvar[ivar]);
|
||||
ivar++;
|
||||
break;
|
||||
case BN:
|
||||
ptr[n] = bond->svector[bindex[n]];
|
||||
break;
|
||||
case DIST:
|
||||
ptr[n] = sqrt(rsq);
|
||||
break;
|
||||
case DX:
|
||||
ptr[n] = dx * directionCorrection;
|
||||
break;
|
||||
case DY:
|
||||
ptr[n] = dy * directionCorrection;
|
||||
break;
|
||||
case DZ:
|
||||
ptr[n] = dz * directionCorrection;
|
||||
break;
|
||||
case ENGPOT:
|
||||
ptr[n] = engpot;
|
||||
break;
|
||||
case FORCE:
|
||||
ptr[n] = sqrt(rsq) * fbond;
|
||||
break;
|
||||
case FX:
|
||||
ptr[n] = dx * fbond;
|
||||
break;
|
||||
case FY:
|
||||
ptr[n] = dy * fbond;
|
||||
break;
|
||||
case FZ:
|
||||
ptr[n] = dz * fbond;
|
||||
break;
|
||||
case ENGVIB:
|
||||
ptr[n] = engvib;
|
||||
break;
|
||||
case ENGROT:
|
||||
ptr[n] = engrot;
|
||||
break;
|
||||
case ENGTRANS:
|
||||
ptr[n] = engtrans;
|
||||
break;
|
||||
case OMEGA:
|
||||
ptr[n] = sqrt(omegasq);
|
||||
break;
|
||||
case VELVIB:
|
||||
ptr[n] = vvib;
|
||||
break;
|
||||
case VARIABLE:
|
||||
ptr[n] = input->variable->compute_equal(vvar[ivar]);
|
||||
ivar++;
|
||||
break;
|
||||
case BN:
|
||||
ptr[n] = bond->svector[bindex[n]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -459,10 +495,10 @@ int ComputeBondLocal::compute_bonds(int flag)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int ComputeBondLocal::pack_forward_comm(int n, int *list, double *buf,
|
||||
int /*pbc_flag*/, int * /*pbc*/)
|
||||
int ComputeBondLocal::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
|
||||
int * /*pbc*/)
|
||||
{
|
||||
int i,j,m;
|
||||
int i, j, m;
|
||||
|
||||
double **v = atom->v;
|
||||
|
||||
@ -481,7 +517,7 @@ int ComputeBondLocal::pack_forward_comm(int n, int *list, double *buf,
|
||||
|
||||
void ComputeBondLocal::unpack_forward_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
int i, m, last;
|
||||
|
||||
double **v = atom->v;
|
||||
|
||||
@ -504,11 +540,11 @@ void ComputeBondLocal::reallocate(int n)
|
||||
|
||||
if (nvalues == 1) {
|
||||
memory->destroy(vlocal);
|
||||
memory->create(vlocal,nmax,"bond/local:vector_local");
|
||||
memory->create(vlocal, nmax, "bond/local:vector_local");
|
||||
vector_local = vlocal;
|
||||
} else {
|
||||
memory->destroy(alocal);
|
||||
memory->create(alocal,nmax,nvalues,"bond/local:array_local");
|
||||
memory->create(alocal, nmax, nvalues, "bond/local:array_local");
|
||||
array_local = alocal;
|
||||
}
|
||||
}
|
||||
@ -519,6 +555,6 @@ void ComputeBondLocal::reallocate(int n)
|
||||
|
||||
double ComputeBondLocal::memory_usage()
|
||||
{
|
||||
double bytes = (double)nmax*nvalues * sizeof(double);
|
||||
double bytes = (double) nmax * nvalues * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -13,19 +12,21 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "compute_dihedral_local.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
#include "molecule.h"
|
||||
#include "update.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "molecule.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
@ -37,14 +38,13 @@ enum { PHI, VARIABLE };
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
bstyle(nullptr), vvar(nullptr), pstr(nullptr), vstr(nullptr), vlocal(nullptr), alocal(nullptr)
|
||||
Compute(lmp, narg, arg), bstyle(nullptr), vvar(nullptr), pstr(nullptr), vstr(nullptr),
|
||||
vlocal(nullptr), alocal(nullptr)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute dihedral/local command");
|
||||
|
||||
if (atom->avec->dihedrals_allow == 0)
|
||||
error->all(FLERR,
|
||||
"Compute dihedral/local used when dihedrals are not allowed");
|
||||
error->all(FLERR, "Compute dihedral/local used when dihedrals are not allowed");
|
||||
|
||||
local_flag = 1;
|
||||
|
||||
@ -52,7 +52,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
nvalues = narg - 3;
|
||||
bstyle = new int[nvalues];
|
||||
vstr = new char*[nvalues];
|
||||
vstr = new char *[nvalues];
|
||||
vvar = new int[nvalues];
|
||||
|
||||
nvalues = 0;
|
||||
@ -60,13 +60,14 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int iarg;
|
||||
for (iarg = 3; iarg < narg; iarg++) {
|
||||
if (strcmp(arg[iarg],"phi") == 0) {
|
||||
if (strcmp(arg[iarg], "phi") == 0) {
|
||||
bstyle[nvalues++] = PHI;
|
||||
} else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
} else if (strncmp(arg[iarg], "v_", 2) == 0) {
|
||||
bstyle[nvalues++] = VARIABLE;
|
||||
vstr[nvar] = utils::strdup(&arg[iarg][2]);
|
||||
nvar++;
|
||||
} else break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
// optional args
|
||||
@ -75,47 +76,45 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
pstr = nullptr;
|
||||
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"set") == 0) {
|
||||
if (strcmp(arg[iarg], "set") == 0) {
|
||||
setflag = 1;
|
||||
if (iarg+3 > narg)
|
||||
error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
if (strcmp(arg[iarg+1],"phi") == 0) {
|
||||
delete [] pstr;
|
||||
pstr = utils::strdup(arg[iarg+2]);
|
||||
} else error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
if (iarg + 3 > narg) error->all(FLERR, "Illegal compute dihedral/local command");
|
||||
if (strcmp(arg[iarg + 1], "phi") == 0) {
|
||||
delete[] pstr;
|
||||
pstr = utils::strdup(arg[iarg + 2]);
|
||||
} else
|
||||
error->all(FLERR, "Illegal compute dihedral/local command");
|
||||
iarg += 3;
|
||||
} else error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
} else
|
||||
error->all(FLERR, "Illegal compute dihedral/local command");
|
||||
}
|
||||
|
||||
// error check
|
||||
|
||||
if (nvar) {
|
||||
if (!setflag)
|
||||
error->all(FLERR,"Compute dihedral/local variable requires a set variable");
|
||||
if (!setflag) error->all(FLERR, "Compute dihedral/local variable requires a set variable");
|
||||
for (int i = 0; i < nvar; i++) {
|
||||
vvar[i] = input->variable->find(vstr[i]);
|
||||
if (vvar[i] < 0)
|
||||
error->all(FLERR,
|
||||
"Variable name for copute dihedral/local does not exist");
|
||||
if (vvar[i] < 0) error->all(FLERR, "Variable name for copute dihedral/local does not exist");
|
||||
if (!input->variable->equalstyle(vvar[i]))
|
||||
error->all(FLERR,"Variable for compute dihedral/local is invalid style");
|
||||
error->all(FLERR, "Variable for compute dihedral/local is invalid style");
|
||||
}
|
||||
|
||||
if (pstr) {
|
||||
pvar = input->variable->find(pstr);
|
||||
if (pvar < 0)
|
||||
error->all(FLERR,
|
||||
"Variable name for compute dihedral/local does not exist");
|
||||
if (pvar < 0) error->all(FLERR, "Variable name for compute dihedral/local does not exist");
|
||||
if (!input->variable->internalstyle(pvar))
|
||||
error->all(FLERR,"Variable for compute dihedral/local is invalid style");
|
||||
error->all(FLERR, "Variable for compute dihedral/local is invalid style");
|
||||
}
|
||||
} else if (setflag)
|
||||
error->all(FLERR,"Compute dihedral/local set with no variable");
|
||||
error->all(FLERR, "Compute dihedral/local set with no variable");
|
||||
|
||||
// initialize output
|
||||
|
||||
if (nvalues == 1) size_local_cols = 0;
|
||||
else size_local_cols = nvalues;
|
||||
if (nvalues == 1)
|
||||
size_local_cols = 0;
|
||||
else
|
||||
size_local_cols = nvalues;
|
||||
|
||||
nmax = 0;
|
||||
vlocal = nullptr;
|
||||
@ -126,12 +125,12 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
ComputeDihedralLocal::~ComputeDihedralLocal()
|
||||
{
|
||||
delete [] bstyle;
|
||||
for (int i = 0; i < nvar; i++) delete [] vstr[i];
|
||||
delete [] vstr;
|
||||
delete [] vvar;
|
||||
delete[] bstyle;
|
||||
for (int i = 0; i < nvar; i++) delete[] vstr[i];
|
||||
delete[] vstr;
|
||||
delete[] vvar;
|
||||
|
||||
delete [] pstr;
|
||||
delete[] pstr;
|
||||
|
||||
memory->destroy(vlocal);
|
||||
memory->destroy(alocal);
|
||||
@ -142,21 +141,17 @@ ComputeDihedralLocal::~ComputeDihedralLocal()
|
||||
void ComputeDihedralLocal::init()
|
||||
{
|
||||
if (force->dihedral == nullptr)
|
||||
error->all(FLERR,"No dihedral style is defined for compute dihedral/local");
|
||||
error->all(FLERR, "No dihedral style is defined for compute dihedral/local");
|
||||
|
||||
if (nvar) {
|
||||
for (int i = 0; i < nvar; i++) {
|
||||
vvar[i] = input->variable->find(vstr[i]);
|
||||
if (vvar[i] < 0)
|
||||
error->all(FLERR,
|
||||
"Variable name for compute dihedral/local does not exist");
|
||||
if (vvar[i] < 0) error->all(FLERR, "Variable name for compute dihedral/local does not exist");
|
||||
}
|
||||
|
||||
if (pstr) {
|
||||
pvar = input->variable->find(pstr);
|
||||
if (pvar < 0)
|
||||
error->all(FLERR,
|
||||
"Variable name for compute dihedral/local does not exist");
|
||||
if (pvar < 0) error->all(FLERR, "Variable name for compute dihedral/local does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,11 +186,11 @@ void ComputeDihedralLocal::compute_local()
|
||||
|
||||
int ComputeDihedralLocal::compute_dihedrals(int flag)
|
||||
{
|
||||
int i,m,nd,atom1,atom2,atom3,atom4,imol,iatom,ivar;
|
||||
int i, m, nd, atom1, atom2, atom3, atom4, imol, iatom, ivar;
|
||||
tagint tagprev;
|
||||
double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm;
|
||||
double ax,ay,az,bx,by,bz,rasq,rbsq,rgsq,rg,ra2inv,rb2inv,rabinv;
|
||||
double s,c,phi;
|
||||
double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z, vb2xm, vb2ym, vb2zm;
|
||||
double ax, ay, az, bx, by, bz, rasq, rbsq, rgsq, rg, ra2inv, rb2inv, rabinv;
|
||||
double s, c, phi;
|
||||
double *ptr;
|
||||
|
||||
double **x = atom->x;
|
||||
@ -220,7 +215,8 @@ int ComputeDihedralLocal::compute_dihedrals(int flag)
|
||||
for (atom2 = 0; atom2 < nlocal; atom2++) {
|
||||
if (!(mask[atom2] & groupbit)) continue;
|
||||
|
||||
if (molecular == Atom::MOLECULAR) nd = num_dihedral[atom2];
|
||||
if (molecular == Atom::MOLECULAR)
|
||||
nd = num_dihedral[atom2];
|
||||
else {
|
||||
if (molindex[atom2] < 0) continue;
|
||||
imol = molindex[atom2];
|
||||
@ -237,9 +233,9 @@ int ComputeDihedralLocal::compute_dihedrals(int flag)
|
||||
} else {
|
||||
if (tag[atom2] != onemols[imol]->dihedral_atom2[atom2][i]) continue;
|
||||
tagprev = tag[atom2] - iatom - 1;
|
||||
atom1 = atom->map(onemols[imol]->dihedral_atom1[atom2][i]+tagprev);
|
||||
atom3 = atom->map(onemols[imol]->dihedral_atom3[atom2][i]+tagprev);
|
||||
atom4 = atom->map(onemols[imol]->dihedral_atom4[atom2][i]+tagprev);
|
||||
atom1 = atom->map(onemols[imol]->dihedral_atom1[atom2][i] + tagprev);
|
||||
atom3 = atom->map(onemols[imol]->dihedral_atom3[atom2][i] + tagprev);
|
||||
atom4 = atom->map(onemols[imol]->dihedral_atom4[atom2][i] + tagprev);
|
||||
}
|
||||
|
||||
if (atom1 < 0 || !(mask[atom1] & groupbit)) continue;
|
||||
@ -256,64 +252,66 @@ int ComputeDihedralLocal::compute_dihedrals(int flag)
|
||||
vb1x = x[atom1][0] - x[atom2][0];
|
||||
vb1y = x[atom1][1] - x[atom2][1];
|
||||
vb1z = x[atom1][2] - x[atom2][2];
|
||||
domain->minimum_image(vb1x,vb1y,vb1z);
|
||||
domain->minimum_image(vb1x, vb1y, vb1z);
|
||||
|
||||
vb2x = x[atom3][0] - x[atom2][0];
|
||||
vb2y = x[atom3][1] - x[atom2][1];
|
||||
vb2z = x[atom3][2] - x[atom2][2];
|
||||
domain->minimum_image(vb2x,vb2y,vb2z);
|
||||
domain->minimum_image(vb2x, vb2y, vb2z);
|
||||
|
||||
vb2xm = -vb2x;
|
||||
vb2ym = -vb2y;
|
||||
vb2zm = -vb2z;
|
||||
domain->minimum_image(vb2xm,vb2ym,vb2zm);
|
||||
domain->minimum_image(vb2xm, vb2ym, vb2zm);
|
||||
|
||||
vb3x = x[atom4][0] - x[atom3][0];
|
||||
vb3y = x[atom4][1] - x[atom3][1];
|
||||
vb3z = x[atom4][2] - x[atom3][2];
|
||||
domain->minimum_image(vb3x,vb3y,vb3z);
|
||||
domain->minimum_image(vb3x, vb3y, vb3z);
|
||||
|
||||
ax = vb1y*vb2zm - vb1z*vb2ym;
|
||||
ay = vb1z*vb2xm - vb1x*vb2zm;
|
||||
az = vb1x*vb2ym - vb1y*vb2xm;
|
||||
bx = vb3y*vb2zm - vb3z*vb2ym;
|
||||
by = vb3z*vb2xm - vb3x*vb2zm;
|
||||
bz = vb3x*vb2ym - vb3y*vb2xm;
|
||||
ax = vb1y * vb2zm - vb1z * vb2ym;
|
||||
ay = vb1z * vb2xm - vb1x * vb2zm;
|
||||
az = vb1x * vb2ym - vb1y * vb2xm;
|
||||
bx = vb3y * vb2zm - vb3z * vb2ym;
|
||||
by = vb3z * vb2xm - vb3x * vb2zm;
|
||||
bz = vb3x * vb2ym - vb3y * vb2xm;
|
||||
|
||||
rasq = ax*ax + ay*ay + az*az;
|
||||
rbsq = bx*bx + by*by + bz*bz;
|
||||
rgsq = vb2xm*vb2xm + vb2ym*vb2ym + vb2zm*vb2zm;
|
||||
rasq = ax * ax + ay * ay + az * az;
|
||||
rbsq = bx * bx + by * by + bz * bz;
|
||||
rgsq = vb2xm * vb2xm + vb2ym * vb2ym + vb2zm * vb2zm;
|
||||
rg = sqrt(rgsq);
|
||||
|
||||
ra2inv = rb2inv = 0.0;
|
||||
if (rasq > 0) ra2inv = 1.0/rasq;
|
||||
if (rbsq > 0) rb2inv = 1.0/rbsq;
|
||||
rabinv = sqrt(ra2inv*rb2inv);
|
||||
if (rasq > 0) ra2inv = 1.0 / rasq;
|
||||
if (rbsq > 0) rb2inv = 1.0 / rbsq;
|
||||
rabinv = sqrt(ra2inv * rb2inv);
|
||||
|
||||
c = (ax*bx + ay*by + az*bz)*rabinv;
|
||||
s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z);
|
||||
c = (ax * bx + ay * by + az * bz) * rabinv;
|
||||
s = rg * rabinv * (ax * vb3x + ay * vb3y + az * vb3z);
|
||||
|
||||
if (c > 1.0) c = 1.0;
|
||||
if (c < -1.0) c = -1.0;
|
||||
phi = atan2(s,c);
|
||||
phi = atan2(s, c);
|
||||
|
||||
if (nvalues == 1) ptr = &vlocal[m];
|
||||
else ptr = alocal[m];
|
||||
if (nvalues == 1)
|
||||
ptr = &vlocal[m];
|
||||
else
|
||||
ptr = alocal[m];
|
||||
|
||||
if (nvar) {
|
||||
ivar = 0;
|
||||
if (pstr) input->variable->internal_set(pvar,phi);
|
||||
if (pstr) input->variable->internal_set(pvar, phi);
|
||||
}
|
||||
|
||||
for (int n = 0; n < nvalues; n++) {
|
||||
switch (bstyle[n]) {
|
||||
case PHI:
|
||||
ptr[n] = 180.0*phi/MY_PI;
|
||||
break;
|
||||
case VARIABLE:
|
||||
ptr[n] = input->variable->compute_equal(vvar[ivar]);
|
||||
ivar++;
|
||||
break;
|
||||
case PHI:
|
||||
ptr[n] = 180.0 * phi / MY_PI;
|
||||
break;
|
||||
case VARIABLE:
|
||||
ptr[n] = input->variable->compute_equal(vvar[ivar]);
|
||||
ivar++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,11 +332,11 @@ void ComputeDihedralLocal::reallocate(int n)
|
||||
|
||||
if (nvalues == 1) {
|
||||
memory->destroy(vlocal);
|
||||
memory->create(vlocal,nmax,"dihedral/local:vector_local");
|
||||
memory->create(vlocal, nmax, "dihedral/local:vector_local");
|
||||
vector_local = vlocal;
|
||||
} else {
|
||||
memory->destroy(alocal);
|
||||
memory->create(alocal,nmax,nvalues,"dihedral/local:array_local");
|
||||
memory->create(alocal, nmax, nvalues, "dihedral/local:array_local");
|
||||
array_local = alocal;
|
||||
}
|
||||
}
|
||||
@ -349,6 +347,6 @@ void ComputeDihedralLocal::reallocate(int n)
|
||||
|
||||
double ComputeDihedralLocal::memory_usage()
|
||||
{
|
||||
double bytes = (double)nmax*nvalues * sizeof(double);
|
||||
double bytes = (double) nmax * nvalues * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -13,36 +12,35 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "compute_improper_local.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
#include "molecule.h"
|
||||
#include "update.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "molecule.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
static constexpr int DELTA = 10000;
|
||||
|
||||
static constexpr double SMALL = 0.001;
|
||||
static constexpr double SMALL = 0.001;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeImproperLocal::ComputeImproperLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
vlocal(nullptr), alocal(nullptr)
|
||||
Compute(lmp, narg, arg), vlocal(nullptr), alocal(nullptr)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute improper/local command");
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute improper/local command");
|
||||
|
||||
if (atom->avec->impropers_allow == 0)
|
||||
error->all(FLERR,
|
||||
"Compute improper/local used when impropers are not allowed");
|
||||
error->all(FLERR, "Compute improper/local used when impropers are not allowed");
|
||||
|
||||
local_flag = 1;
|
||||
nvalues = narg - 3;
|
||||
@ -50,12 +48,16 @@ ComputeImproperLocal::ComputeImproperLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
nvalues = 0;
|
||||
|
||||
for (int iarg = 3; iarg < narg; iarg++) {
|
||||
if (strcmp(arg[iarg],"chi") == 0) cflag = nvalues++;
|
||||
else error->all(FLERR,"Invalid keyword in compute improper/local command");
|
||||
if (strcmp(arg[iarg], "chi") == 0)
|
||||
cflag = nvalues++;
|
||||
else
|
||||
error->all(FLERR, "Invalid keyword in compute improper/local command");
|
||||
}
|
||||
|
||||
if (nvalues == 1) size_local_cols = 0;
|
||||
else size_local_cols = nvalues;
|
||||
if (nvalues == 1)
|
||||
size_local_cols = 0;
|
||||
else
|
||||
size_local_cols = nvalues;
|
||||
|
||||
nmax = 0;
|
||||
vlocal = nullptr;
|
||||
@ -75,7 +77,7 @@ ComputeImproperLocal::~ComputeImproperLocal()
|
||||
void ComputeImproperLocal::init()
|
||||
{
|
||||
if (force->improper == nullptr)
|
||||
error->all(FLERR,"No improper style is defined for compute improper/local");
|
||||
error->all(FLERR, "No improper style is defined for compute improper/local");
|
||||
|
||||
// do initial memory allocation so that memory_usage() is correct
|
||||
|
||||
@ -108,11 +110,11 @@ void ComputeImproperLocal::compute_local()
|
||||
|
||||
int ComputeImproperLocal::compute_impropers(int flag)
|
||||
{
|
||||
int i,m,n,ni,atom1,atom2,atom3,atom4,imol,iatom;
|
||||
int i, m, n, ni, atom1, atom2, atom3, atom4, imol, iatom;
|
||||
tagint tagprev;
|
||||
double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z;
|
||||
double ss1,ss2,ss3,r1,r2,r3,c0,c1,c2,s1,s2;
|
||||
double s12,c;
|
||||
double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z;
|
||||
double ss1, ss2, ss3, r1, r2, r3, c0, c1, c2, s1, s2;
|
||||
double s12, c;
|
||||
double *cbuf;
|
||||
|
||||
double **x = atom->x;
|
||||
@ -135,8 +137,10 @@ int ComputeImproperLocal::compute_impropers(int flag)
|
||||
if (nvalues == 1) {
|
||||
if (cflag >= 0) cbuf = vlocal;
|
||||
} else {
|
||||
if (cflag >= 0 && alocal) cbuf = &alocal[0][cflag];
|
||||
else cbuf = nullptr;
|
||||
if (cflag >= 0 && alocal)
|
||||
cbuf = &alocal[0][cflag];
|
||||
else
|
||||
cbuf = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +148,8 @@ int ComputeImproperLocal::compute_impropers(int flag)
|
||||
for (atom2 = 0; atom2 < nlocal; atom2++) {
|
||||
if (!(mask[atom2] & groupbit)) continue;
|
||||
|
||||
if (molecular == Atom::MOLECULAR) ni = num_improper[atom2];
|
||||
if (molecular == Atom::MOLECULAR)
|
||||
ni = num_improper[atom2];
|
||||
else {
|
||||
if (molindex[atom2] < 0) continue;
|
||||
imol = molindex[atom2];
|
||||
@ -161,9 +166,9 @@ int ComputeImproperLocal::compute_impropers(int flag)
|
||||
} else {
|
||||
if (tag[atom2] != onemols[imol]->improper_atom2[atom2][i]) continue;
|
||||
tagprev = tag[atom2] - iatom - 1;
|
||||
atom1 = atom->map(onemols[imol]->improper_atom1[atom2][i]+tagprev);
|
||||
atom3 = atom->map(onemols[imol]->improper_atom3[atom2][i]+tagprev);
|
||||
atom4 = atom->map(onemols[imol]->improper_atom4[atom2][i]+tagprev);
|
||||
atom1 = atom->map(onemols[imol]->improper_atom1[atom2][i] + tagprev);
|
||||
atom3 = atom->map(onemols[imol]->improper_atom3[atom2][i] + tagprev);
|
||||
atom4 = atom->map(onemols[imol]->improper_atom4[atom2][i] + tagprev);
|
||||
}
|
||||
|
||||
if (atom1 < 0 || !(mask[atom1] & groupbit)) continue;
|
||||
@ -178,21 +183,21 @@ int ComputeImproperLocal::compute_impropers(int flag)
|
||||
vb1x = x[atom1][0] - x[atom2][0];
|
||||
vb1y = x[atom1][1] - x[atom2][1];
|
||||
vb1z = x[atom1][2] - x[atom2][2];
|
||||
domain->minimum_image(vb1x,vb1y,vb1z);
|
||||
domain->minimum_image(vb1x, vb1y, vb1z);
|
||||
|
||||
vb2x = x[atom3][0] - x[atom2][0];
|
||||
vb2y = x[atom3][1] - x[atom2][1];
|
||||
vb2z = x[atom3][2] - x[atom2][2];
|
||||
domain->minimum_image(vb2x,vb2y,vb2z);
|
||||
domain->minimum_image(vb2x, vb2y, vb2z);
|
||||
|
||||
vb3x = x[atom4][0] - x[atom3][0];
|
||||
vb3y = x[atom4][1] - x[atom3][1];
|
||||
vb3z = x[atom4][2] - x[atom3][2];
|
||||
domain->minimum_image(vb3x,vb3y,vb3z);
|
||||
domain->minimum_image(vb3x, vb3y, vb3z);
|
||||
|
||||
ss1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z);
|
||||
ss2 = 1.0 / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z);
|
||||
ss3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z);
|
||||
ss1 = 1.0 / (vb1x * vb1x + vb1y * vb1y + vb1z * vb1z);
|
||||
ss2 = 1.0 / (vb2x * vb2x + vb2y * vb2y + vb2z * vb2z);
|
||||
ss3 = 1.0 / (vb3x * vb3x + vb3y * vb3y + vb3z * vb3z);
|
||||
|
||||
r1 = sqrt(ss1);
|
||||
r2 = sqrt(ss2);
|
||||
@ -202,20 +207,20 @@ int ComputeImproperLocal::compute_impropers(int flag)
|
||||
c1 = (vb1x * vb2x + vb1y * vb2y + vb1z * vb2z) * r1 * r2;
|
||||
c2 = -(vb3x * vb2x + vb3y * vb2y + vb3z * vb2z) * r3 * r2;
|
||||
|
||||
s1 = 1.0 - c1*c1;
|
||||
s1 = 1.0 - c1 * c1;
|
||||
if (s1 < SMALL) s1 = SMALL;
|
||||
s1 = 1.0 / s1;
|
||||
|
||||
s2 = 1.0 - c2*c2;
|
||||
s2 = 1.0 - c2 * c2;
|
||||
if (s2 < SMALL) s2 = SMALL;
|
||||
s2 = 1.0 / s2;
|
||||
|
||||
s12 = sqrt(s1*s2);
|
||||
c = (c1*c2 + c0) * s12;
|
||||
s12 = sqrt(s1 * s2);
|
||||
c = (c1 * c2 + c0) * s12;
|
||||
|
||||
if (c > 1.0) c = 1.0;
|
||||
if (c < -1.0) c = -1.0;
|
||||
cbuf[n] = 180.0*acos(c)/MY_PI;
|
||||
cbuf[n] = 180.0 * acos(c) / MY_PI;
|
||||
}
|
||||
n += nvalues;
|
||||
}
|
||||
@ -237,11 +242,11 @@ void ComputeImproperLocal::reallocate(int n)
|
||||
|
||||
if (nvalues == 1) {
|
||||
memory->destroy(vlocal);
|
||||
memory->create(vlocal,nmax,"improper/local:vector_local");
|
||||
memory->create(vlocal, nmax, "improper/local:vector_local");
|
||||
vector_local = vlocal;
|
||||
} else {
|
||||
memory->destroy(alocal);
|
||||
memory->create(alocal,nmax,nvalues,"improper/local:array_local");
|
||||
memory->create(alocal, nmax, nvalues, "improper/local:array_local");
|
||||
array_local = alocal;
|
||||
}
|
||||
}
|
||||
@ -252,6 +257,6 @@ void ComputeImproperLocal::reallocate(int n)
|
||||
|
||||
double ComputeImproperLocal::memory_usage()
|
||||
{
|
||||
double bytes = (double)nmax*nvalues * sizeof(double);
|
||||
double bytes = (double) nmax * nvalues * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user