add clang-format support to plugin examples

This commit is contained in:
Axel Kohlmeyer
2021-05-05 23:51:12 -04:00
parent 5fcd0d8b79
commit 49a7bb57de
21 changed files with 376 additions and 326 deletions

View File

@ -0,0 +1,32 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -1
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: true
BraceWrapping:
AfterFunction: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
ColumnLimit: 80
IndentCaseLabels: true
IndentWidth: 2
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 2
PenaltyBreakAssignment: 4
ReflowComments: false
SpaceAfterCStyleCast: true
SpacesBeforeTrailingComments: 4
SpacesInContainerLiterals: false
Standard: Cpp11
TabWidth: 2
UseTab: Never
...

View File

@ -19,9 +19,9 @@
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "math_const.h"
#include "memory.h"
#include "error.h"
#include <cstring>
@ -46,7 +46,7 @@ AngleZero2::~AngleZero2()
void AngleZero2::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ---------------------------------------------------------------------- */
@ -54,11 +54,13 @@ void AngleZero2::compute(int eflag, int vflag)
void AngleZero2::settings(int narg, char **arg)
{
if ((narg != 0) && (narg != 1))
error->all(FLERR,"Illegal angle_style command");
error->all(FLERR, "Illegal angle_style command");
if (narg == 1) {
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal angle_style command");
if (strcmp("nocoeff", arg[0]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal angle_style command");
}
}
@ -69,8 +71,8 @@ void AngleZero2::allocate()
allocated = 1;
int n = atom->nangletypes;
memory->create(theta0,n+1,"angle:theta0");
memory->create(setflag,n+1,"angle:setflag");
memory->create(theta0, n + 1, "angle:theta0");
memory->create(setflag, n + 1, "angle:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0;
}
@ -81,27 +83,27 @@ void AngleZero2::allocate()
void AngleZero2::coeff(int narg, char **arg)
{
if ((narg < 1) || (coeffflag && narg > 2))
error->all(FLERR,"Incorrect args for angle coefficients");
error->all(FLERR, "Incorrect args for angle coefficients");
if (!allocated) allocate();
int ilo,ihi;
utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error);
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->nangletypes, ilo, ihi, error);
double theta0_one = 0.0;
if (coeffflag && (narg == 2))
theta0_one = utils::numeric(FLERR,arg[1],false,lmp);
theta0_one = utils::numeric(FLERR, arg[1], false, lmp);
// convert theta0 from degrees to radians
int count = 0;
for (int i = ilo; i <= ihi; i++) {
setflag[i] = 1;
theta0[i] = theta0_one/180.0 * MY_PI;
theta0[i] = theta0_one / 180.0 * MY_PI;
count++;
}
if (count == 0) error->all(FLERR,"Incorrect args for angle coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for angle coefficients");
}
/* ---------------------------------------------------------------------- */
@ -115,8 +117,9 @@ double AngleZero2::equilibrium_angle(int i)
proc 0 writes out coeffs to restart file
------------------------------------------------------------------------- */
void AngleZero2::write_restart(FILE *fp) {
fwrite(&theta0[1],sizeof(double),atom->nangletypes,fp);
void AngleZero2::write_restart(FILE *fp)
{
fwrite(&theta0[1], sizeof(double), atom->nangletypes, fp);
}
/* ----------------------------------------------------------------------
@ -128,9 +131,10 @@ void AngleZero2::read_restart(FILE *fp)
allocate();
if (comm->me == 0) {
utils::sfread(FLERR,&theta0[1],sizeof(double),atom->nangletypes,fp,nullptr,error);
utils::sfread(FLERR, &theta0[1], sizeof(double), atom->nangletypes, fp,
nullptr, error);
}
MPI_Bcast(&theta0[1],atom->nangletypes,MPI_DOUBLE,0,world);
MPI_Bcast(&theta0[1], atom->nangletypes, MPI_DOUBLE, 0, world);
for (int i = 1; i <= atom->nangletypes; i++) setflag[i] = 1;
}
@ -141,7 +145,7 @@ void AngleZero2::read_restart(FILE *fp)
void AngleZero2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->nangletypes; i++)
fprintf(fp,"%d %g\n",i,theta0[i]/MY_PI*180.0);
fprintf(fp, "%d %g\n", i, theta0[i] / MY_PI * 180.0);
}
/* ---------------------------------------------------------------------- */

View File

@ -40,7 +40,7 @@ class AngleZero2 : public Angle {
void allocate();
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -44,7 +44,7 @@ BondZero2::~BondZero2()
void BondZero2::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ---------------------------------------------------------------------- */
@ -52,11 +52,13 @@ void BondZero2::compute(int eflag, int vflag)
void BondZero2::settings(int narg, char **arg)
{
if ((narg != 0) && (narg != 1))
error->all(FLERR,"Illegal bond_style command");
error->all(FLERR, "Illegal bond_style command");
if (narg == 1) {
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal bond_style command");
if (strcmp("nocoeff", arg[0]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal bond_style command");
}
}
@ -67,8 +69,8 @@ void BondZero2::allocate()
allocated = 1;
int n = atom->nbondtypes;
memory->create(r0,n+1,"bond:r0");
memory->create(setflag,n+1,"bond:setflag");
memory->create(r0, n + 1, "bond:r0");
memory->create(setflag, n + 1, "bond:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0;
}
@ -79,16 +81,16 @@ void BondZero2::allocate()
void BondZero2::coeff(int narg, char **arg)
{
if ((narg < 1) || (coeffflag && narg > 2))
error->all(FLERR,"Incorrect args for bond coefficients");
error->all(FLERR, "Incorrect args for bond coefficients");
if (!allocated) allocate();
int ilo,ihi;
utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error);
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error);
double r0_one = 0.0;
if (coeffflag && (narg == 2))
r0_one = utils::numeric(FLERR,arg[1],false,lmp);
r0_one = utils::numeric(FLERR, arg[1], false, lmp);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
@ -97,7 +99,7 @@ void BondZero2::coeff(int narg, char **arg)
count++;
}
if (count == 0) error->all(FLERR,"Incorrect args for bond coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients");
}
/* ----------------------------------------------------------------------
@ -113,8 +115,9 @@ double BondZero2::equilibrium_distance(int i)
proc 0 writes out coeffs to restart file
------------------------------------------------------------------------- */
void BondZero2::write_restart(FILE *fp) {
fwrite(&r0[1],sizeof(double),atom->nbondtypes,fp);
void BondZero2::write_restart(FILE *fp)
{
fwrite(&r0[1], sizeof(double), atom->nbondtypes, fp);
}
/* ----------------------------------------------------------------------
@ -126,9 +129,10 @@ void BondZero2::read_restart(FILE *fp)
allocate();
if (comm->me == 0) {
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(&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;
}
@ -139,8 +143,7 @@ void BondZero2::read_restart(FILE *fp)
void BondZero2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->nbondtypes; i++)
fprintf(fp,"%d %g\n",i,r0[i]);
for (int i = 1; i <= atom->nbondtypes; i++) fprintf(fp, "%d %g\n", i, r0[i]);
}
/* ---------------------------------------------------------------------- */
@ -156,6 +159,6 @@ double BondZero2::single(int /*type*/, double /*rsq*/, int /*i*/, int /*j*/,
void *BondZero2::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"r0")==0) return (void*) r0;
if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr;
}

View File

@ -41,7 +41,7 @@ class BondZero2 : public Bond {
virtual void allocate();
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -36,16 +36,14 @@ DihedralZero2::DihedralZero2(LAMMPS *lmp) : Dihedral(lmp), coeffflag(1)
DihedralZero2::~DihedralZero2()
{
if (allocated && !copymode) {
memory->destroy(setflag);
}
if (allocated && !copymode) { memory->destroy(setflag); }
}
/* ---------------------------------------------------------------------- */
void DihedralZero2::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ---------------------------------------------------------------------- */
@ -53,11 +51,13 @@ void DihedralZero2::compute(int eflag, int vflag)
void DihedralZero2::settings(int narg, char **arg)
{
if ((narg != 0) && (narg != 1))
error->all(FLERR,"Illegal dihedral_style command");
error->all(FLERR, "Illegal dihedral_style command");
if (narg == 1) {
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal dihedral_style command");
if (strcmp("nocoeff", arg[0]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal dihedral_style command");
}
}
@ -68,7 +68,7 @@ void DihedralZero2::allocate()
allocated = 1;
int n = atom->ndihedraltypes;
memory->create(setflag,n+1,"dihedral:setflag");
memory->create(setflag, n + 1, "dihedral:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0;
}
@ -79,12 +79,12 @@ void DihedralZero2::allocate()
void DihedralZero2::coeff(int narg, char **arg)
{
if ((narg < 1) || (coeffflag && narg > 1))
error->all(FLERR,"Incorrect args for dihedral coefficients");
error->all(FLERR, "Incorrect args for dihedral coefficients");
if (!allocated) allocate();
int ilo,ihi;
utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error);
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->ndihedraltypes, ilo, ihi, error);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
@ -92,7 +92,7 @@ void DihedralZero2::coeff(int narg, char **arg)
count++;
}
if (count == 0) error->all(FLERR,"Incorrect args for dihedral coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for dihedral coefficients");
}
/* ----------------------------------------------------------------------
@ -115,7 +115,7 @@ void DihedralZero2::read_restart(FILE * /*fp*/)
proc 0 writes to data file
------------------------------------------------------------------------- */
void DihedralZero2::write_data(FILE *fp) {
for (int i = 1; i <= atom->ndihedraltypes; i++)
fprintf(fp,"%d\n",i);
void DihedralZero2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->ndihedraltypes; i++) fprintf(fp, "%d\n", i);
}

View File

@ -40,7 +40,7 @@ class DihedralZero2 : public Dihedral {
virtual void allocate();
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -12,23 +12,22 @@
------------------------------------------------------------------------- */
#include "fix_nve2.h"
#include <cstring>
#include "atom.h"
#include "force.h"
#include "update.h"
#include "respa.h"
#include "error.h"
#include "force.h"
#include "respa.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNVE2::FixNVE2(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
FixNVE2::FixNVE2(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
{
if (strcmp(style,"nve/sphere") != 0 && narg < 3)
error->all(FLERR,"Illegal fix nve command");
if (strcmp(style, "nve/sphere") != 0 && narg < 3)
error->all(FLERR, "Illegal fix nve command");
dynamic_group_allow = 1;
time_integrate = 1;
@ -53,7 +52,7 @@ void FixNVE2::init()
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
if (strstr(update->integrate_style,"respa"))
if (strstr(update->integrate_style, "respa"))
step_respa = ((Respa *) update->integrate)->step;
}
@ -150,8 +149,10 @@ void FixNVE2::initial_integrate_respa(int vflag, int ilevel, int /*iloop*/)
// innermost level - NVE update of v and x
// all other levels - NVE update of v
if (ilevel == 0) initial_integrate(vflag);
else final_integrate();
if (ilevel == 0)
initial_integrate(vflag);
else
final_integrate();
}
/* ---------------------------------------------------------------------- */

View File

@ -13,7 +13,7 @@
#ifdef FIX_CLASS
FixStyle(nve2,FixNVE2)
FixStyle(nve2, FixNVE2)
#else
@ -37,17 +37,17 @@ class FixNVE2 : public Fix {
virtual void reset_dt();
protected:
double dtv,dtf;
double dtv, dtf;
double *step_respa;
int mass_require;
};
}
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
/* ERROR/WARNING messages:
E: Illegal ... command

View File

@ -9,20 +9,19 @@
#include <cstring>
namespace LAMMPS_NS {
class Hello : public Command {
class Hello : public Command {
public:
Hello(class LAMMPS *lmp) : Command(lmp) {};
Hello(class LAMMPS *lmp) : Command(lmp){};
void command(int, char **);
};
}
};
} // namespace LAMMPS_NS
using namespace LAMMPS_NS;
void Hello::command(int argc, char **argv)
{
if (argc != 1) error->all(FLERR,"Illegal hello command");
if (comm->me == 0)
utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0]));
if (argc != 1) error->all(FLERR, "Illegal hello command");
if (comm->me == 0) utils::logmesg(lmp, fmt::format("Hello, {}!\n", argv[0]));
}
static Command *hellocreator(LAMMPS *lmp)
@ -42,5 +41,5 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
plugin.creator.v1 = (lammpsplugin_factory1 *) &hellocreator;
plugin.handle = handle;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
}

View File

@ -36,16 +36,14 @@ ImproperZero2::ImproperZero2(LAMMPS *lmp) : Improper(lmp), coeffflag(1)
ImproperZero2::~ImproperZero2()
{
if (allocated && !copymode) {
memory->destroy(setflag);
}
if (allocated && !copymode) { memory->destroy(setflag); }
}
/* ---------------------------------------------------------------------- */
void ImproperZero2::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ---------------------------------------------------------------------- */
@ -53,11 +51,13 @@ void ImproperZero2::compute(int eflag, int vflag)
void ImproperZero2::settings(int narg, char **arg)
{
if ((narg != 0) && (narg != 1))
error->all(FLERR,"Illegal improper_style command");
error->all(FLERR, "Illegal improper_style command");
if (narg == 1) {
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal improper_style command");
if (strcmp("nocoeff", arg[0]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal improper_style command");
}
}
@ -68,7 +68,7 @@ void ImproperZero2::allocate()
allocated = 1;
int n = atom->nimpropertypes;
memory->create(setflag,n+1,"improper:setflag");
memory->create(setflag, n + 1, "improper:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0;
}
@ -79,12 +79,12 @@ void ImproperZero2::allocate()
void ImproperZero2::coeff(int narg, char **arg)
{
if ((narg < 1) || (coeffflag && narg > 1))
error->all(FLERR,"Incorrect args for improper coefficients");
error->all(FLERR, "Incorrect args for improper coefficients");
if (!allocated) allocate();
int ilo,ihi;
utils::bounds(FLERR,arg[0],1,atom->nimpropertypes,ilo,ihi,error);
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->nimpropertypes, ilo, ihi, error);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
@ -92,7 +92,7 @@ void ImproperZero2::coeff(int narg, char **arg)
count++;
}
if (count == 0) error->all(FLERR,"Incorrect args for improper coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for improper coefficients");
}
/* ----------------------------------------------------------------------
@ -115,8 +115,7 @@ void ImproperZero2::read_restart(FILE * /*fp*/)
proc 0 writes to data file
------------------------------------------------------------------------- */
void ImproperZero2::write_data(FILE *fp) {
for (int i = 1; i <= atom->nimpropertypes; i++)
fprintf(fp,"%d\n",i);
void ImproperZero2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->nimpropertypes; i++) fprintf(fp, "%d\n", i);
}

View File

@ -36,7 +36,7 @@ class ImproperZero2 : public Improper {
virtual void allocate();
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -33,11 +33,11 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
plugin.creator.v1 = (lammpsplugin_factory1 *) &morse2creator;
plugin.handle = handle;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
// also register morse2/omp pair style. only need to update changed fields
plugin.name = "morse2/omp";
plugin.info = "Morse2 variant pair style for OpenMP v1.0";
plugin.creator.v1 = (lammpsplugin_factory1 *) &morse2ompcreator;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
}

View File

@ -26,5 +26,5 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
plugin.creator.v2 = (lammpsplugin_factory2 *) &nve2creator;
plugin.handle = handle;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
}

View File

@ -13,14 +13,14 @@
#include "pair_morse2.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
@ -52,13 +52,13 @@ PairMorse2::~PairMorse2()
void PairMorse2::compute(int eflag, int vflag)
{
int i,j,ii,jj,inum,jnum,itype,jtype;
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair;
double rsq,r,dr,dexp,factor_lj;
int *ilist,*jlist,*numneigh,**firstneigh;
int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
double rsq, r, dr, dexp, factor_lj;
int *ilist, *jlist, *numneigh, **firstneigh;
evdwl = 0.0;
ev_init(eflag,vflag);
ev_init(eflag, vflag);
double **x = atom->x;
double **f = atom->f;
@ -91,32 +91,33 @@ void PairMorse2::compute(int eflag, int vflag)
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j];
if (rsq < cutsq[itype][jtype]) {
r = sqrt(rsq);
dr = r - r0[itype][jtype];
dexp = exp(-alpha[itype][jtype] * dr);
fpair = factor_lj * morse1[itype][jtype] * (dexp*dexp - dexp) / r;
fpair = factor_lj * morse1[itype][jtype] * (dexp * dexp - dexp) / r;
f[i][0] += delx*fpair;
f[i][1] += dely*fpair;
f[i][2] += delz*fpair;
f[i][0] += delx * fpair;
f[i][1] += dely * fpair;
f[i][2] += delz * fpair;
if (newton_pair || j < nlocal) {
f[j][0] -= delx*fpair;
f[j][1] -= dely*fpair;
f[j][2] -= delz*fpair;
f[j][0] -= delx * fpair;
f[j][1] -= dely * fpair;
f[j][2] -= delz * fpair;
}
if (eflag) {
evdwl = d0[itype][jtype] * (dexp*dexp - 2.0*dexp) -
evdwl = d0[itype][jtype] * (dexp * dexp - 2.0 * dexp) -
offset[itype][jtype];
evdwl *= factor_lj;
}
if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);
if (evflag)
ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely,
delz);
}
}
}
@ -133,19 +134,18 @@ void PairMorse2::allocate()
allocated = 1;
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 j = i; j <= n; j++)
setflag[i][j] = 0;
for (int j = i; j <= n; j++) setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq");
memory->create(cutsq, n + 1, n + 1, "pair:cutsq");
memory->create(cut,n+1,n+1,"pair:cut");
memory->create(d0,n+1,n+1,"pair:d0");
memory->create(alpha,n+1,n+1,"pair:alpha");
memory->create(r0,n+1,n+1,"pair:r0");
memory->create(morse1,n+1,n+1,"pair:morse1");
memory->create(offset,n+1,n+1,"pair:offset");
memory->create(cut, n + 1, n + 1, "pair:cut");
memory->create(d0, n + 1, n + 1, "pair:d0");
memory->create(alpha, n + 1, n + 1, "pair:alpha");
memory->create(r0, n + 1, n + 1, "pair:r0");
memory->create(morse1, n + 1, n + 1, "pair:morse1");
memory->create(offset, n + 1, n + 1, "pair:offset");
}
/* ----------------------------------------------------------------------
@ -154,14 +154,14 @@ void PairMorse2::allocate()
void PairMorse2::settings(int narg, char **arg)
{
if (narg != 1) error->all(FLERR,"Illegal pair_style command");
if (narg != 1) error->all(FLERR, "Illegal pair_style command");
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
cut_global = utils::numeric(FLERR, arg[0], false, lmp);
// reset cutoffs that have been explicitly set
if (allocated) {
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++)
if (setflag[i][j]) cut[i][j] = cut_global;
@ -175,23 +175,23 @@ void PairMorse2::settings(int narg, char **arg)
void PairMorse2::coeff(int narg, char **arg)
{
if (narg < 5 || narg > 6)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
int ilo, ihi, jlo, jhi;
utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
double d0_one = utils::numeric(FLERR,arg[2],false,lmp);
double alpha_one = utils::numeric(FLERR,arg[3],false,lmp);
double r0_one = utils::numeric(FLERR,arg[4],false,lmp);
double d0_one = utils::numeric(FLERR, arg[2], false, lmp);
double alpha_one = utils::numeric(FLERR, arg[3], false, lmp);
double r0_one = utils::numeric(FLERR, arg[4], false, lmp);
double cut_one = cut_global;
if (narg == 6) cut_one = utils::numeric(FLERR,arg[5],false,lmp);
if (narg == 6) cut_one = utils::numeric(FLERR, arg[5], false, lmp);
int count = 0;
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;
alpha[i][j] = alpha_one;
r0[i][j] = r0_one;
@ -201,24 +201,24 @@ void PairMorse2::coeff(int narg, char **arg)
}
}
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
double PairMorse2::init_one(int i, int j)
{
if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set");
if (setflag[i][j] == 0) 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) {
double alpha_dr = -alpha[i][j] * (cut[i][j] - r0[i][j]);
offset[i][j] = d0[i][j] * (exp(2.0*alpha_dr) - 2.0*exp(alpha_dr));
} else offset[i][j] = 0.0;
offset[i][j] = d0[i][j] * (exp(2.0 * alpha_dr) - 2.0 * exp(alpha_dr));
} else
offset[i][j] = 0.0;
d0[j][i] = d0[i][j];
alpha[j][i] = alpha[i][j];
@ -237,15 +237,15 @@ void PairMorse2::write_restart(FILE *fp)
{
write_restart_settings(fp);
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
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]) {
fwrite(&d0[i][j],sizeof(double),1,fp);
fwrite(&alpha[i][j],sizeof(double),1,fp);
fwrite(&r0[i][j],sizeof(double),1,fp);
fwrite(&cut[i][j],sizeof(double),1,fp);
fwrite(&d0[i][j], sizeof(double), 1, fp);
fwrite(&alpha[i][j], sizeof(double), 1, fp);
fwrite(&r0[i][j], sizeof(double), 1, fp);
fwrite(&cut[i][j], sizeof(double), 1, fp);
}
}
}
@ -260,23 +260,29 @@ void PairMorse2::read_restart(FILE *fp)
allocate();
int i,j;
int i, j;
int me = comm->me;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
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);
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);
if (setflag[i][j]) {
if (me == 0) {
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,&r0[i][j],sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&cut[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, &r0[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(&alpha[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&r0[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[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(&r0[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
}
}
}
@ -287,9 +293,9 @@ void PairMorse2::read_restart(FILE *fp)
void PairMorse2::write_restart_settings(FILE *fp)
{
fwrite(&cut_global,sizeof(double),1,fp);
fwrite(&offset_flag,sizeof(int),1,fp);
fwrite(&mix_flag,sizeof(int),1,fp);
fwrite(&cut_global, sizeof(double), 1, fp);
fwrite(&offset_flag, sizeof(int), 1, fp);
fwrite(&mix_flag, sizeof(int), 1, fp);
}
/* ----------------------------------------------------------------------
@ -299,13 +305,13 @@ void PairMorse2::write_restart_settings(FILE *fp)
void PairMorse2::read_restart_settings(FILE *fp)
{
if (comm->me == 0) {
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,&mix_flag,sizeof(int),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, &mix_flag, sizeof(int), 1, fp, nullptr, error);
}
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
MPI_Bcast(&cut_global, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&offset_flag, 1, MPI_INT, 0, world);
MPI_Bcast(&mix_flag, 1, MPI_INT, 0, world);
}
/* ----------------------------------------------------------------------
@ -315,7 +321,7 @@ void PairMorse2::read_restart_settings(FILE *fp)
void PairMorse2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp,"%d %g %g %g\n",i,d0[i][i],alpha[i][i],r0[i][i]);
fprintf(fp, "%d %g %g %g\n", i, d0[i][i], alpha[i][i], r0[i][i]);
}
/* ----------------------------------------------------------------------
@ -326,25 +332,25 @@ void PairMorse2::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %d %g %g %g %g\n",
i,j,d0[i][j],alpha[i][j],r0[i][j],cut[i][j]);
fprintf(fp, "%d %d %g %g %g %g\n", i, j, d0[i][j], alpha[i][j], r0[i][j],
cut[i][j]);
}
/* ---------------------------------------------------------------------- */
double PairMorse2::single(int /*i*/, int /*j*/, int itype, int jtype, double rsq,
double /*factor_coul*/, double factor_lj,
double PairMorse2::single(int /*i*/, int /*j*/, int itype, int jtype,
double rsq, double /*factor_coul*/, double factor_lj,
double &fforce)
{
double r,dr,dexp,phi;
double r, dr, dexp, phi;
r = sqrt(rsq);
dr = r - r0[itype][jtype];
dexp = exp(-alpha[itype][jtype] * dr);
fforce = factor_lj * morse1[itype][jtype] * (dexp*dexp - dexp) / r;
fforce = factor_lj * morse1[itype][jtype] * (dexp * dexp - dexp) / r;
phi = d0[itype][jtype] * (dexp*dexp - 2.0*dexp) - offset[itype][jtype];
return factor_lj*phi;
phi = d0[itype][jtype] * (dexp * dexp - 2.0 * dexp) - offset[itype][jtype];
return factor_lj * phi;
}
/* ---------------------------------------------------------------------- */
@ -352,8 +358,8 @@ double PairMorse2::single(int /*i*/, int /*j*/, int itype, int jtype, double rsq
void *PairMorse2::extract(const char *str, int &dim)
{
dim = 2;
if (strcmp(str,"d0") == 0) return (void *) d0;
if (strcmp(str,"r0") == 0) return (void *) r0;
if (strcmp(str,"alpha") == 0) return (void *) alpha;
if (strcmp(str, "d0") == 0) return (void *) d0;
if (strcmp(str, "r0") == 0) return (void *) r0;
if (strcmp(str, "alpha") == 0) return (void *) alpha;
return nullptr;
}

View File

@ -39,14 +39,14 @@ class PairMorse2 : public Pair {
protected:
double cut_global;
double **cut;
double **d0,**alpha,**r0;
double **d0, **alpha, **r0;
double **morse1;
double **offset;
virtual void allocate();
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -38,14 +38,14 @@ PairMorse2OMP::PairMorse2OMP(LAMMPS *lmp) :
void PairMorse2OMP::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
const int nall = atom->nlocal + atom->nghost;
const int nthreads = comm->nthreads;
const int inum = list->inum;
#if defined(_OPENMP)
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag)
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag, vflag)
#endif
{
int ifrom, ito, tid;
@ -57,15 +57,21 @@ void PairMorse2OMP::compute(int eflag, int vflag)
if (evflag) {
if (eflag) {
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
else eval<1,1,0>(ifrom, ito, thr);
if (force->newton_pair)
eval<1, 1, 1>(ifrom, ito, thr);
else
eval<1, 1, 0>(ifrom, ito, thr);
} else {
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
else eval<1,0,0>(ifrom, ito, thr);
if (force->newton_pair)
eval<1, 0, 1>(ifrom, ito, thr);
else
eval<1, 0, 0>(ifrom, ito, thr);
}
} else {
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
else eval<0,0,0>(ifrom, ito, thr);
if (force->newton_pair)
eval<0, 0, 1>(ifrom, ito, thr);
else
eval<0, 0, 0>(ifrom, ito, thr);
}
thr->timer(Timer::PAIR);
@ -74,21 +80,21 @@ void PairMorse2OMP::compute(int eflag, int vflag)
}
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairMorse2OMP::eval(int iifrom, int iito, ThrData * const thr)
void PairMorse2OMP::eval(int iifrom, int iito, ThrData *const thr)
{
int i,j,ii,jj,jnum,itype,jtype;
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair;
double rsq,r,dr,dexp,factor_lj;
int *ilist,*jlist,*numneigh,**firstneigh;
int i, j, ii, jj, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
double rsq, r, dr, dexp, factor_lj;
int *ilist, *jlist, *numneigh, **firstneigh;
evdwl = 0.0;
const dbl3_t * _noalias const x = (dbl3_t *) atom->x[0];
dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0];
const int * _noalias const type = atom->type;
const dbl3_t *_noalias const x = (dbl3_t *) atom->x[0];
dbl3_t *_noalias const f = (dbl3_t *) thr->get_f()[0];
const int *_noalias const type = atom->type;
const int nlocal = atom->nlocal;
const double * _noalias const special_lj = force->special_lj;
double fxtmp,fytmp,fztmp;
const double *_noalias const special_lj = force->special_lj;
double fxtmp, fytmp, fztmp;
ilist = list->ilist;
numneigh = list->numneigh;
@ -105,7 +111,7 @@ void PairMorse2OMP::eval(int iifrom, int iito, ThrData * const thr)
itype = type[i];
jlist = firstneigh[i];
jnum = numneigh[i];
fxtmp=fytmp=fztmp=0.0;
fxtmp = fytmp = fztmp = 0.0;
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
@ -115,32 +121,33 @@ void PairMorse2OMP::eval(int iifrom, int iito, ThrData * const thr)
delx = xtmp - x[j].x;
dely = ytmp - x[j].y;
delz = ztmp - x[j].z;
rsq = delx*delx + dely*dely + delz*delz;
rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j];
if (rsq < cutsq[itype][jtype]) {
r = sqrt(rsq);
dr = r - r0[itype][jtype];
dexp = exp(-alpha[itype][jtype] * dr);
fpair = factor_lj * morse1[itype][jtype] * (dexp*dexp - dexp) / r;
fpair = factor_lj * morse1[itype][jtype] * (dexp * dexp - dexp) / r;
fxtmp += delx*fpair;
fytmp += dely*fpair;
fztmp += delz*fpair;
fxtmp += delx * fpair;
fytmp += dely * fpair;
fztmp += delz * fpair;
if (NEWTON_PAIR || j < nlocal) {
f[j].x -= delx*fpair;
f[j].y -= dely*fpair;
f[j].z -= delz*fpair;
f[j].x -= delx * fpair;
f[j].y -= dely * fpair;
f[j].z -= delz * fpair;
}
if (EFLAG) {
evdwl = d0[itype][jtype] * (dexp*dexp - 2.0*dexp) -
evdwl = d0[itype][jtype] * (dexp * dexp - 2.0 * dexp) -
offset[itype][jtype];
evdwl *= factor_lj;
}
if (EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,
evdwl,0.0,fpair,delx,dely,delz,thr);
if (EVFLAG)
ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, 0.0, fpair, delx,
dely, delz, thr);
}
}
f[i].x += fxtmp;

View File

@ -33,9 +33,9 @@ class PairMorse2OMP : public PairMorse2, public ThrOMP {
private:
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

View File

@ -19,8 +19,8 @@
#include "atom.h"
#include "comm.h"
#include "memory.h"
#include "error.h"
#include "memory.h"
#include <cstring>
@ -28,11 +28,12 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
PairZero2::PairZero2(LAMMPS *lmp) : Pair(lmp) {
coeffflag=1;
writedata=1;
single_enable=1;
respa_enable=1;
PairZero2::PairZero2(LAMMPS *lmp) : Pair(lmp)
{
coeffflag = 1;
writedata = 1;
single_enable = 1;
respa_enable = 1;
}
/* ---------------------------------------------------------------------- */
@ -50,7 +51,7 @@ PairZero2::~PairZero2()
void PairZero2::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
if (vflag_fdotr) virial_fdotr_compute();
}
@ -58,7 +59,7 @@ void PairZero2::compute(int eflag, int vflag)
void PairZero2::compute_outer(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ----------------------------------------------------------------------
@ -70,13 +71,12 @@ void PairZero2::allocate()
allocated = 1;
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 j = i; j <= n; j++)
setflag[i][j] = 0;
for (int j = i; j <= n; j++) setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq");
memory->create(cut,n+1,n+1,"pair:cut");
memory->create(cutsq, n + 1, n + 1, "pair:cutsq");
memory->create(cut, n + 1, n + 1, "pair:cut");
}
/* ----------------------------------------------------------------------
@ -86,21 +86,22 @@ void PairZero2::allocate()
void PairZero2::settings(int narg, char **arg)
{
if ((narg != 1) && (narg != 2))
error->all(FLERR,"Illegal pair_style command");
error->all(FLERR, "Illegal pair_style command");
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
cut_global = utils::numeric(FLERR, arg[0], false, lmp);
if (narg == 2) {
if (strcmp("nocoeff",arg[1]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal pair_style command");
if (strcmp("nocoeff", arg[1]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal pair_style command");
}
// reset cutoffs that have been explicitly set
if (allocated) {
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i+1; j <= atom->ntypes; j++)
cut[i][j] = cut_global;
for (j = i + 1; j <= atom->ntypes; j++) cut[i][j] = cut_global;
}
}
@ -111,27 +112,28 @@ void PairZero2::settings(int narg, char **arg)
void PairZero2::coeff(int narg, char **arg)
{
if ((narg < 2) || (coeffflag && narg > 3))
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
int ilo, ihi, jlo, jhi;
utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
double cut_one = cut_global;
if (coeffflag && (narg == 3)) cut_one = utils::numeric(FLERR,arg[2],false,lmp);
if (coeffflag && (narg == 3))
cut_one = utils::numeric(FLERR, arg[2], false, lmp);
int count = 0;
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++) {
cut[i][j] = cut_one;
setflag[i][j] = 1;
count++;
}
}
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
@ -140,9 +142,7 @@ void PairZero2::coeff(int narg, char **arg)
double PairZero2::init_one(int i, int j)
{
if (setflag[i][j] == 0) {
cut[i][j] = mix_distance(cut[i][i],cut[j][j]);
}
if (setflag[i][j] == 0) { cut[i][j] = mix_distance(cut[i][i], cut[j][j]); }
return cut[i][j];
}
@ -155,13 +155,11 @@ void PairZero2::write_restart(FILE *fp)
{
write_restart_settings(fp);
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
fwrite(&setflag[i][j],sizeof(int),1,fp);
if (setflag[i][j]) {
fwrite(&cut[i][j],sizeof(double),1,fp);
}
fwrite(&setflag[i][j], sizeof(int), 1, fp);
if (setflag[i][j]) { fwrite(&cut[i][j], sizeof(double), 1, fp); }
}
}
@ -174,17 +172,20 @@ void PairZero2::read_restart(FILE *fp)
read_restart_settings(fp);
allocate();
int i,j;
int i, j;
int me = comm->me;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
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);
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);
if (setflag[i][j]) {
if (me == 0) {
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(&cut[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
}
}
}
@ -195,8 +196,8 @@ void PairZero2::read_restart(FILE *fp)
void PairZero2::write_restart_settings(FILE *fp)
{
fwrite(&cut_global,sizeof(double),1,fp);
fwrite(&coeffflag,sizeof(int),1,fp);
fwrite(&cut_global, sizeof(double), 1, fp);
fwrite(&coeffflag, sizeof(int), 1, fp);
}
/* ----------------------------------------------------------------------
@ -207,11 +208,11 @@ void PairZero2::read_restart_settings(FILE *fp)
{
int me = comm->me;
if (me == 0) {
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&coeffflag,sizeof(int),1,fp,nullptr,error);
utils::sfread(FLERR, &cut_global, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &coeffflag, sizeof(int), 1, fp, nullptr, error);
}
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&coeffflag,1,MPI_INT,0,world);
MPI_Bcast(&cut_global, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&coeffflag, 1, MPI_INT, 0, world);
}
/* ----------------------------------------------------------------------
@ -220,8 +221,7 @@ void PairZero2::read_restart_settings(FILE *fp)
void PairZero2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp,"%d\n",i);
for (int i = 1; i <= atom->ntypes; i++) fprintf(fp, "%d\n", i);
}
/* ----------------------------------------------------------------------
@ -232,7 +232,7 @@ void PairZero2::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %d %g\n",i,j,cut[i][j]);
fprintf(fp, "%d %d %g\n", i, j, cut[i][j]);
}
/* ---------------------------------------------------------------------- */
@ -244,4 +244,3 @@ double PairZero2::single(int /*i*/, int /*j*/, int /* itype */, int /* jtype */,
fforce = 0.0;
return 0.0;
}

View File

@ -53,7 +53,7 @@ class PairZero2 : public Pair {
virtual void allocate();
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -4,11 +4,11 @@
#include <cstring>
#include "pair_zero2.h"
#include "bond_zero2.h"
#include "angle_zero2.h"
#include "bond_zero2.h"
#include "dihedral_zero2.h"
#include "improper_zero2.h"
#include "pair_zero2.h"
using namespace LAMMPS_NS;
@ -50,29 +50,29 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
plugin.creator.v1 = (lammpsplugin_factory1 *) &pairzerocreator;
plugin.handle = handle;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
// register zero2 bond style
plugin.style = "bond";
plugin.info = "Zero2 variant bond style v1.0";
plugin.creator.v1 = (lammpsplugin_factory1 *) &bondzerocreator;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
// register zero2 angle style
plugin.style = "angle";
plugin.info = "Zero2 variant angle style v1.0";
plugin.creator.v1 = (lammpsplugin_factory1 *) &anglezerocreator;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
// register zero2 dihedral style
plugin.style = "dihedral";
plugin.info = "Zero2 variant dihedral style v1.0";
plugin.creator.v1 = (lammpsplugin_factory1 *) &dihedralzerocreator;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
// register zero2 improper style
plugin.style = "improper";
plugin.info = "Zero2 variant improper style v1.0";
plugin.creator.v1 = (lammpsplugin_factory1 *) &improperzerocreator;
(*register_plugin)(&plugin,lmp);
(*register_plugin)(&plugin, lmp);
}