From 21079b3ac2d11af619518f27051d0c20a1a62123 Mon Sep 17 00:00:00 2001 From: "Dan S. Bolintineanu" Date: Fri, 2 Oct 2020 16:15:30 -0600 Subject: [PATCH 001/187] Added multi-stencil files from Ishan --- .../npair_half_size_multi_newtoff.cpp | 119 +++ .../npair_half_size_multi_newtoff.h | 43 + .../npair_half_size_multi_newton.cpp | 145 +++ src/from_ishan/npair_half_size_multi_newton.h | 43 + .../npair_half_size_multi_newton_tri.cpp | 126 +++ .../npair_half_size_multi_newton_tri.h | 43 + .../pair_gran_hooke_history_multi.cpp | 885 ++++++++++++++++++ .../pair_gran_hooke_history_multi.h | 109 +++ 8 files changed, 1513 insertions(+) create mode 100644 src/from_ishan/npair_half_size_multi_newtoff.cpp create mode 100644 src/from_ishan/npair_half_size_multi_newtoff.h create mode 100644 src/from_ishan/npair_half_size_multi_newton.cpp create mode 100644 src/from_ishan/npair_half_size_multi_newton.h create mode 100644 src/from_ishan/npair_half_size_multi_newton_tri.cpp create mode 100644 src/from_ishan/npair_half_size_multi_newton_tri.h create mode 100644 src/from_ishan/pair_gran_hooke_history_multi.cpp create mode 100644 src/from_ishan/pair_gran_hooke_history_multi.h diff --git a/src/from_ishan/npair_half_size_multi_newtoff.cpp b/src/from_ishan/npair_half_size_multi_newtoff.cpp new file mode 100644 index 0000000000..ec4ff805e2 --- /dev/null +++ b/src/from_ishan/npair_half_size_multi_newtoff.cpp @@ -0,0 +1,119 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include +#include "npair_half_size_multi_newtoff.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairHalfSizeMultiNewtoff::NPairHalfSizeMultiNewtoff(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + binned neighbor list construction with partial Newton's 3rd law + each owned atom i checks own bin and other bins in stencil + multi-type stencil is itype dependent and is distance checked + pair stored once if i,j are both owned and i < j + pair stored by me if j is ghost (also stored by proc owning j) +------------------------------------------------------------------------- */ + +void NPairHalfSizeMultiNewtoff::build(NeighList *list) +{ + int i,j,k,m,n,itype,jtype,ibin,ns; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radi,radsum,cutdistsq; + int *neighptr,*s; + double *cutsq,*distsq; + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + int history = list->history; + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int mask_history = 3 << SBBITS; + + int inum = 0; + ipage->reset(); + + for (i = 0; i < nlocal; i++) { + n = 0; + neighptr = ipage->vget(); + + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + radi = radius[i]; + + // loop over all atoms in other bins in stencil including self + // only store pair if i < j + // skip if i,j neighbor cutoff is less than bin distance + // stores own/own pairs only once + // stores own/ghost pairs on both procs + + ibin = atom2bin[i]; + s = stencil_multi[itype]; + distsq = distsq_multi[itype]; + cutsq = cutneighsq[itype]; + ns = nstencil_multi[itype]; + for (k = 0; k < ns; k++) { + for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { + if (j <= i) continue; + jtype = type[j]; + if (cutsq[jtype] < distsq[k]) continue; + + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + ilist[inum++] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + ipage->vgot(n); + if (ipage->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + list->inum = inum; +} diff --git a/src/from_ishan/npair_half_size_multi_newtoff.h b/src/from_ishan/npair_half_size_multi_newtoff.h new file mode 100644 index 0000000000..8abe5b5456 --- /dev/null +++ b/src/from_ishan/npair_half_size_multi_newtoff.h @@ -0,0 +1,43 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef NPAIR_CLASS + +NPairStyle(half/size/multi/newtoff, + NPairHalfSizeMultiNewtoff, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI) + +#else + +#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_H +#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairHalfSizeMultiNewtoff : public NPair { + public: + NPairHalfSizeMultiNewtoff(class LAMMPS *); + ~NPairHalfSizeMultiNewtoff() {} + void build(class NeighList *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/from_ishan/npair_half_size_multi_newton.cpp b/src/from_ishan/npair_half_size_multi_newton.cpp new file mode 100644 index 0000000000..01aea66632 --- /dev/null +++ b/src/from_ishan/npair_half_size_multi_newton.cpp @@ -0,0 +1,145 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include +#include "npair_half_size_multi_newton.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairHalfSizeMultiNewton::NPairHalfSizeMultiNewton(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + binned neighbor list construction with full Newton's 3rd law + each owned atom i checks its own bin and other bins in Newton stencil + multi-type stencil is itype dependent and is distance checked + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +void NPairHalfSizeMultiNewton::build(NeighList *list) +{ + int i,j,k,m,n,itype,jtype,ibin,ns; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radi,radsum,cutdistsq; + int *neighptr,*s; + double *cutsq,*distsq; + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + int history = list->history; + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int mask_history = 3 << SBBITS; + + int inum = 0; + ipage->reset(); + + for (i = 0; i < nlocal; i++) { + n = 0; + neighptr = ipage->vget(); + + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + radi = radius[i]; + + // loop over rest of atoms in i's bin, ghosts are at end of linked list + // if j is owned atom, store it, since j is beyond i in linked list + // if j is ghost, only store if j coords are "above and to the right" of i + + for (j = bins[i]; j >= 0; j = bins[j]) { + if (j >= nlocal) { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + } + + jtype = type[j]; + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + + // loop over all atoms in other bins in stencil, store every pair + // skip if i,j neighbor cutoff is less than bin distance + + ibin = atom2bin[i]; + s = stencil_multi[itype]; + distsq = distsq_multi[itype]; + cutsq = cutneighsq[itype]; + ns = nstencil_multi[itype]; + for (k = 0; k < ns; k++) { + for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { + jtype = type[j]; + if (cutsq[jtype] < distsq[k]) continue; + + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + ilist[inum++] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + ipage->vgot(n); + if (ipage->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + list->inum = inum; +} diff --git a/src/from_ishan/npair_half_size_multi_newton.h b/src/from_ishan/npair_half_size_multi_newton.h new file mode 100644 index 0000000000..109fe78c2b --- /dev/null +++ b/src/from_ishan/npair_half_size_multi_newton.h @@ -0,0 +1,43 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef NPAIR_CLASS + +NPairStyle(half/size/multi/newton, + NPairHalfSizeMultiNewton, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_ORTHO) + +#else + +#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_H +#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairHalfSizeMultiNewton : public NPair { + public: + NPairHalfSizeMultiNewton(class LAMMPS *); + ~NPairHalfSizeMultiNewton() {} + void build(class NeighList *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/from_ishan/npair_half_size_multi_newton_tri.cpp b/src/from_ishan/npair_half_size_multi_newton_tri.cpp new file mode 100644 index 0000000000..f7123a958d --- /dev/null +++ b/src/from_ishan/npair_half_size_multi_newton_tri.cpp @@ -0,0 +1,126 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include +#include "npair_half_size_multi_newton_tri.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairHalfSizeMultiNewtonTri::NPairHalfSizeMultiNewtonTri(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + binned neighbor list construction with Newton's 3rd law for triclinic + each owned atom i checks its own bin and other bins in triclinic stencil + multi-type stencil is itype dependent and is distance checked + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +void NPairHalfSizeMultiNewtonTri::build(NeighList *list) +{ + int i,j,k,m,n,itype,jtype,ibin,ns; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radi,radsum,cutdistsq; + int *neighptr,*s; + double *cutsq,*distsq; + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + int history = list->history; + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int mask_history = 3 << SBBITS; + + int inum = 0; + ipage->reset(); + + for (i = 0; i < nlocal; i++) { + n = 0; + neighptr = ipage->vget(); + + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + radi = radius[i]; + + + // loop over all atoms in bins in stencil + // pairs for atoms j "below" i are excluded + // below = lower z or (equal z and lower y) or (equal zy and lower x) + // (equal zyx and j <= i) + // latter excludes self-self interaction but allows superposed atoms + + ibin = atom2bin[i]; + s = stencil_multi[itype]; + distsq = distsq_multi[itype]; + cutsq = cutneighsq[itype]; + ns = nstencil_multi[itype]; + for (k = 0; k < ns; k++) { + for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { + jtype = type[j]; + if (cutsq[jtype] < distsq[k]) continue; + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp) { + if (x[j][0] < xtmp) continue; + if (x[j][0] == xtmp && j <= i) continue; + } + } + + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + ilist[inum++] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + ipage->vgot(n); + if (ipage->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + list->inum = inum; +} diff --git a/src/from_ishan/npair_half_size_multi_newton_tri.h b/src/from_ishan/npair_half_size_multi_newton_tri.h new file mode 100644 index 0000000000..15fbaba0f7 --- /dev/null +++ b/src/from_ishan/npair_half_size_multi_newton_tri.h @@ -0,0 +1,43 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef NPAIR_CLASS + +NPairStyle(half/size/multi/newton/tri, + NPairHalfSizeMultiNewtonTri, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_TRI) + +#else + +#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_H +#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairHalfSizeMultiNewtonTri : public NPair { + public: + NPairHalfSizeMultiNewtonTri(class LAMMPS *); + ~NPairHalfSizeMultiNewtonTri() {} + void build(class NeighList *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/from_ishan/pair_gran_hooke_history_multi.cpp b/src/from_ishan/pair_gran_hooke_history_multi.cpp new file mode 100644 index 0000000000..83f5221741 --- /dev/null +++ b/src/from_ishan/pair_gran_hooke_history_multi.cpp @@ -0,0 +1,885 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Leo Silbert (SNL), Gary Grest (SNL) +------------------------------------------------------------------------- */ + +#include +#include +#include +#include +#include "pair_gran_hooke_history_multi.h" +#include "atom.h" +#include "atom_vec.h" +#include "domain.h" +#include "force.h" +#include "update.h" +#include "modify.h" +#include "fix.h" +#include "fix_neigh_history.h" +#include "comm.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +PairGranHookeHistoryMulti::PairGranHookeHistoryMulti(LAMMPS *lmp) : Pair(lmp) +{ + single_enable = 1; + no_virial_fdotr_compute = 1; + history = 1; + fix_history = NULL; + + single_extra = 10; + svector = new double[10]; + + neighprev = 0; + + nmax = 0; + mass_rigid = NULL; + + // set comm size needed by this Pair if used with fix rigid + + comm_forward = 1; +} + +/* ---------------------------------------------------------------------- */ + +PairGranHookeHistoryMulti::~PairGranHookeHistoryMulti() +{ + delete [] svector; + if (fix_history) modify->delete_fix("NEIGH_HISTORY"); + + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(kn); + memory->destroy(kt); + memory->destroy(gamman); + memory->destroy(gammat); + memory->destroy(xmu); + memory->destroy(dampflag); + + delete [] onerad_dynamic; + delete [] onerad_frozen; + delete [] maxrad_dynamic; + delete [] maxrad_frozen; + } + + memory->destroy(mass_rigid); +} + +/* ---------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,fx,fy,fz; + double radi,radj,radsum,rsq,r,rinv,rsqinv; + double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3; + double wr1,wr2,wr3; + double vtr1,vtr2,vtr3,vrel; + double mi,mj,meff,damp,ccel,tor1,tor2,tor3; + double fn,fs,fs1,fs2,fs3; + double shrmag,rsht; + int *ilist,*jlist,*numneigh,**firstneigh; + int *touch,**firsttouch; + double *shear,*allshear,**firstshear; + + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = 0; + + int shearupdate = 1; + if (update->setupflag) shearupdate = 0; + + // update rigid body info for owned & ghost atoms if using FixRigid masses + // body[i] = which body atom I is in, -1 if none + // mass_body = mass of each rigid body + + if (fix_rigid && neighbor->ago == 0) { + int tmp; + int *body = (int *) fix_rigid->extract("body",tmp); + double *mass_body = (double *) fix_rigid->extract("masstotal",tmp); + if (atom->nmax > nmax) { + memory->destroy(mass_rigid); + nmax = atom->nmax; + memory->create(mass_rigid,nmax,"pair:mass_rigid"); + } + int nlocal = atom->nlocal; + for (i = 0; i < nlocal; i++) + if (body[i] >= 0) mass_rigid[i] = mass_body[body[i]]; + else mass_rigid[i] = 0.0; + comm->forward_comm_pair(this); + } + + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + int *type = atom->type; + double **omega = atom->omega; + double **torque = atom->torque; + double *radius = atom->radius; + double *rmass = atom->rmass; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int newton_pair = force->newton_pair; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + firsttouch = fix_history->firstflag; + firstshear = fix_history->firstvalue; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + radi = radius[i]; + touch = firsttouch[i]; + allshear = firstshear[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + jtype = type[j]; + radj = radius[j]; + radsum = radi + radj; + + if (rsq >= radsum*radsum) { + + // unset non-touching neighbors + + touch[jj] = 0; + shear = &allshear[3*jj]; + shear[0] = 0.0; + shear[1] = 0.0; + shear[2] = 0.0; + + } else { + r = sqrt(rsq); + rinv = 1.0/r; + rsqinv = 1.0/rsq; + + // relative translational velocity + + vr1 = v[i][0] - v[j][0]; + vr2 = v[i][1] - v[j][1]; + vr3 = v[i][2] - v[j][2]; + + // normal component + + vnnr = vr1*delx + vr2*dely + vr3*delz; + vn1 = delx*vnnr * rsqinv; + vn2 = dely*vnnr * rsqinv; + vn3 = delz*vnnr * rsqinv; + + // tangential component + + vt1 = vr1 - vn1; + vt2 = vr2 - vn2; + vt3 = vr3 - vn3; + + // relative rotational velocity + + wr1 = (radi*omega[i][0] + radj*omega[j][0]) * rinv; + wr2 = (radi*omega[i][1] + radj*omega[j][1]) * rinv; + wr3 = (radi*omega[i][2] + radj*omega[j][2]) * rinv; + + // meff = effective mass of pair of particles + // if I or J part of rigid body, use body mass + // if I or J is frozen, meff is other particle + + mi = rmass[i]; + mj = rmass[j]; + if (fix_rigid) { + if (mass_rigid[i] > 0.0) mi = mass_rigid[i]; + if (mass_rigid[j] > 0.0) mj = mass_rigid[j]; + } + + meff = mi*mj / (mi+mj); + if (mask[i] & freeze_group_bit) meff = mj; + if (mask[j] & freeze_group_bit) meff = mi; + + // normal forces = Hookian contact + normal velocity damping + + damp = meff*gamman[itype][jtype]*vnnr*rsqinv; + ccel = kn[itype][jtype]*(radsum-r)*rinv - damp; + + // relative velocities + + vtr1 = vt1 - (delz*wr2-dely*wr3); + vtr2 = vt2 - (delx*wr3-delz*wr1); + vtr3 = vt3 - (dely*wr1-delx*wr2); + vrel = vtr1*vtr1 + vtr2*vtr2 + vtr3*vtr3; + vrel = sqrt(vrel); + + // shear history effects + + touch[jj] = 1; + shear = &allshear[3*jj]; + + if (shearupdate) { + shear[0] += vtr1*dt; + shear[1] += vtr2*dt; + shear[2] += vtr3*dt; + } + shrmag = sqrt(shear[0]*shear[0] + shear[1]*shear[1] + + shear[2]*shear[2]); + + // rotate shear displacements + + rsht = shear[0]*delx + shear[1]*dely + shear[2]*delz; + rsht *= rsqinv; + if (shearupdate) { + shear[0] -= rsht*delx; + shear[1] -= rsht*dely; + shear[2] -= rsht*delz; + } + + // tangential forces = shear + tangential velocity damping + + fs1 = - (kt[itype][jtype]*shear[0] + meff*gammat[itype][jtype]*vtr1); + fs2 = - (kt[itype][jtype]*shear[1] + meff*gammat[itype][jtype]*vtr2); + fs3 = - (kt[itype][jtype]*shear[2] + meff*gammat[itype][jtype]*vtr3); + + // rescale frictional displacements and forces if needed + + fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); + fn = xmu[itype][jtype] * fabs(ccel*r); + + if (fs > fn) { + if (shrmag != 0.0) { + shear[0] = (fn/fs) * (shear[0] + + meff*gammat[itype][jtype]*vtr1/kt[itype][jtype]) - + meff*gammat[itype][jtype]*vtr1/kt[itype][jtype]; + shear[1] = (fn/fs) * (shear[1] + + meff*gammat[itype][jtype]*vtr2/kt[itype][jtype]) - + meff*gammat[itype][jtype]*vtr2/kt[itype][jtype]; + shear[2] = (fn/fs) * (shear[2] + + meff*gammat[itype][jtype]*vtr3/kt[itype][jtype]) - + meff*gammat[itype][jtype]*vtr3/kt[itype][jtype]; + fs1 *= fn/fs; + fs2 *= fn/fs; + fs3 *= fn/fs; + } else fs1 = fs2 = fs3 = 0.0; + } + + // forces & torques + + fx = delx*ccel + fs1; + fy = dely*ccel + fs2; + fz = delz*ccel + fs3; + f[i][0] += fx; + f[i][1] += fy; + f[i][2] += fz; + + tor1 = rinv * (dely*fs3 - delz*fs2); + tor2 = rinv * (delz*fs1 - delx*fs3); + tor3 = rinv * (delx*fs2 - dely*fs1); + torque[i][0] -= radi*tor1; + torque[i][1] -= radi*tor2; + torque[i][2] -= radi*tor3; + + if (newton_pair || j < nlocal) { + f[j][0] -= fx; + f[j][1] -= fy; + f[j][2] -= fz; + torque[j][0] -= radj*tor1; + torque[j][1] -= radj*tor2; + torque[j][2] -= radj*tor3; + } + + if (evflag) ev_tally_xyz(i,j,nlocal,newton_pair, + 0.0,0.0,fx,fy,fz,delx,dely,delz); + } + } + } + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + 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; + + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + + memory->create(cut,n+1,n+1,"pair:cut"); + memory->create(kn,n+1,n+1,"pair:kn"); + memory->create(kt,n+1,n+1,"pair:kt"); + memory->create(gamman,n+1,n+1,"pair:gamman"); + memory->create(gammat,n+1,n+1,"pair:gammat"); + memory->create(xmu,n+1,n+1,"pair:xmu"); + memory->create(dampflag,n+1,n+1,"pair:dampflag"); + + onerad_dynamic = new double[n+1]; + onerad_frozen = new double[n+1]; + maxrad_dynamic = new double[n+1]; + maxrad_frozen = new double[n+1]; +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::settings(int narg, char **arg) +{ + if (narg != 1) error->all(FLERR,"Illegal pair_style command"); + + if (strcmp(arg[0],"NULL") == 0 ) cut_global = -1.0; + else cut_global = force->numeric(FLERR,arg[0]); + + // reset cutoffs that have been explicitly set + if (allocated) { + 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; + } +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::coeff(int narg, char **arg) +{ + if (narg < 8 || narg > 9) + error->all(FLERR,"Incorrect args for pair coefficients"); + + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi); + force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi); + + double kn_one = force->numeric(FLERR,arg[2]); + double kt_one; + if (strcmp(arg[3],"NULL") == 0) kt_one = kn_one * 2.0/7.0; + else kt_one = force->numeric(FLERR,arg[3]); + + double gamman_one = force->numeric(FLERR,arg[4]); + double gammat_one; + if (strcmp(arg[5],"NULL") == 0) gammat_one = 0.5 * gamman_one; + else gammat_one = force->numeric(FLERR,arg[5]); + + double xmu_one = force->numeric(FLERR,arg[6]); + int dampflag_one = force->inumeric(FLERR,arg[7]); + if (dampflag_one == 0) gammat_one = 0.0; + + if (kn_one < 0.0 || kt_one < 0.0 || gamman_one < 0.0 || gammat_one < 0.0 || + xmu_one < 0.0 || xmu_one > 10000.0 || dampflag_one < 0 || dampflag_one > 1) + error->all(FLERR,"Illegal pair_style command"); + + // convert Kn and Kt from pressure units to force/distance^2 + kn_one /= force->nktv2p; + kt_one /= force->nktv2p; + + double cut_one = cut_global; + if (narg==9) { + if (strcmp(arg[8],"NULL") == 0) cut_one = -1.0; + else cut_one = force->numeric(FLERR,arg[8]); + } + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + kn[i][j] = kn_one; + kt[i][j] = kt_one; + gamman[i][j] = gamman_one; + gammat[i][j] = gammat_one; + xmu[i][j] = xmu_one; + dampflag[i][j] = dampflag_one; + cut[i][j] = cut_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::init_style() +{ + int i; + + // error and warning checks + + if (!atom->radius_flag || !atom->rmass_flag) + error->all(FLERR,"Pair granular requires atom attributes radius, rmass"); + if (comm->ghost_velocity == 0) + error->all(FLERR,"Pair granular requires ghost atoms store velocity"); + + // need a granular neigh list + + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->size = 1; + if (history) neighbor->requests[irequest]->history = 1; + + dt = update->dt; + + // if shear history is stored: + // if first init, create Fix needed for storing shear history + + if (history && fix_history == NULL) { + char dnumstr[16]; + sprintf(dnumstr,"%d",3); + char **fixarg = new char*[4]; + fixarg[0] = (char *) "NEIGH_HISTORY"; + fixarg[1] = (char *) "all"; + fixarg[2] = (char *) "NEIGH_HISTORY"; + fixarg[3] = dnumstr; + modify->add_fix(4,fixarg,1); + delete [] fixarg; + fix_history = (FixNeighHistory *) modify->fix[modify->nfix-1]; + fix_history->pair = this; + } + + // check for FixFreeze and set freeze_group_bit + + for (i = 0; i < modify->nfix; i++) + if (strcmp(modify->fix[i]->style,"freeze") == 0) break; + if (i < modify->nfix) freeze_group_bit = modify->fix[i]->groupbit; + else freeze_group_bit = 0; + + // check for FixRigid so can extract rigid body masses + + fix_rigid = NULL; + for (i = 0; i < modify->nfix; i++) + if (modify->fix[i]->rigid_flag) break; + if (i < modify->nfix) fix_rigid = modify->fix[i]; + + // check for FixPour and FixDeposit so can extract particle radii + + int ipour; + for (ipour = 0; ipour < modify->nfix; ipour++) + if (strcmp(modify->fix[ipour]->style,"pour") == 0) break; + if (ipour == modify->nfix) ipour = -1; + + int idep; + for (idep = 0; idep < modify->nfix; idep++) + if (strcmp(modify->fix[idep]->style,"deposit") == 0) break; + if (idep == modify->nfix) idep = -1; + + // set maxrad_dynamic and maxrad_frozen for each type + // include future FixPour and FixDeposit particles as dynamic + + int itype; + for (i = 1; i <= atom->ntypes; i++) { + onerad_dynamic[i] = onerad_frozen[i] = 0.0; + if (ipour >= 0) { + itype = i; + onerad_dynamic[i] = + *((double *) modify->fix[ipour]->extract("radius",itype)); + } + if (idep >= 0) { + itype = i; + onerad_dynamic[i] = + *((double *) modify->fix[idep]->extract("radius",itype)); + } + } + + double *radius = atom->radius; + int *mask = atom->mask; + int *type = atom->type; + int nlocal = atom->nlocal; + + for (i = 0; i < nlocal; i++) + if (mask[i] & freeze_group_bit) + onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]],radius[i]); + else + onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]],radius[i]); + + MPI_Allreduce(&onerad_dynamic[1],&maxrad_dynamic[1],atom->ntypes, + MPI_DOUBLE,MPI_MAX,world); + MPI_Allreduce(&onerad_frozen[1],&maxrad_frozen[1],atom->ntypes, + MPI_DOUBLE,MPI_MAX,world); + + // set fix which stores history info + + if (history) { + int ifix = modify->find_fix("NEIGH_HISTORY"); + if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID"); + fix_history = (FixNeighHistory *) modify->fix[ifix]; + } +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairGranHookeHistoryMulti::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + kn[i][j] = mix_stiffness(kn[i][i],kn[j][j]); + kt[i][j] = mix_stiffness(kt[i][i],kt[j][j]); + gamman[i][j] = mix_damping(gamman[i][i],gamman[j][j]); + gammat[i][j] = mix_damping(gammat[i][i],gammat[j][j]); + xmu[i][j] = mix_friction(xmu[i][i],xmu[j][j]); + + dampflag[i][j] = 0; + if (dampflag[i][i] || dampflag[j][j]) dampflag[i][j] = 1; + + } + + kn[j][i] = kn[i][j]; + kt[j][i] = kt[i][j]; + gamman[j][i] = gamman[i][j]; + gammat[j][i] = gammat[i][j]; + xmu[j][i] = xmu[i][j]; + dampflag[j][i] = dampflag[i][j]; + + // cutoff = sum of max I,J radii for + // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen + double cutoff = cut[i][j]; + if (cut[i][j] < 0.0) cutoff = maxrad_dynamic[i]+maxrad_dynamic[j]; + if (cut[i][j] < 0.0) cutoff = MAX(cutoff,maxrad_frozen[i]+maxrad_dynamic[j]); + if (cut[i][j] < 0.0) cutoff = MAX(cutoff,maxrad_dynamic[i]+maxrad_frozen[j]); + + // cut[i][j] = MAX(maxrad_dynamic[i],maxrad_dynamic[j]); + // double cutoff = maxrad_dynamic[i]+maxrad_dynamic[j]; + // cutoff = MAX(cutoff,maxrad_frozen[i]+maxrad_dynamic[j]); + // cutoff = MAX(cutoff,maxrad_dynamic[i]+maxrad_frozen[j]); + return cutoff; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + 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); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::write_restart_settings(FILE *fp) +{ + fwrite(&kn,sizeof(double),1,fp); + fwrite(&kt,sizeof(double),1,fp); + fwrite(&gamman,sizeof(double),1,fp); + fwrite(&gammat,sizeof(double),1,fp); + fwrite(&xmu,sizeof(double),1,fp); + fwrite(&dampflag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::read_restart_settings(FILE *fp) +{ + if (comm->me == 0) { + fread(&kn,sizeof(double),1,fp); + fread(&kt,sizeof(double),1,fp); + fread(&gamman,sizeof(double),1,fp); + fread(&gammat,sizeof(double),1,fp); + fread(&xmu,sizeof(double),1,fp); + fread(&dampflag,sizeof(int),1,fp); + } + MPI_Bcast(&kn,1,MPI_DOUBLE,0,world); + MPI_Bcast(&kt,1,MPI_DOUBLE,0,world); + MPI_Bcast(&gamman,1,MPI_DOUBLE,0,world); + MPI_Bcast(&gammat,1,MPI_DOUBLE,0,world); + MPI_Bcast(&xmu,1,MPI_DOUBLE,0,world); + MPI_Bcast(&dampflag,1,MPI_INT,0,world); +} + +/* ---------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::reset_dt() +{ + dt = update->dt; +} + +/* ---------------------------------------------------------------------- */ + +double PairGranHookeHistoryMulti::single(int i, int j, int itype, int jtype, + double rsq, + double factor_coul, double factor_lj, + double &fforce) +{ + double radi,radj,radsum; + double r,rinv,rsqinv,delx,dely,delz; + double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3,wr1,wr2,wr3; + double mi,mj,meff,damp,ccel; + double vtr1,vtr2,vtr3,vrel,shrmag,rsht; + double fs1,fs2,fs3,fs,fn; + + double *radius = atom->radius; + radi = radius[i]; + radj = radius[j]; + radsum = radi + radj; + + if (rsq >= radsum*radsum) { + fforce = 0.0; + for (int m = 0; m < single_extra; m++) svector[m] = 0.0; + return 0.0; + } + + r = sqrt(rsq); + rinv = 1.0/r; + rsqinv = 1.0/rsq; + + // relative translational velocity + + double **v = atom->v; + vr1 = v[i][0] - v[j][0]; + vr2 = v[i][1] - v[j][1]; + vr3 = v[i][2] - v[j][2]; + + // normal component + + double **x = atom->x; + delx = x[i][0] - x[j][0]; + dely = x[i][1] - x[j][1]; + delz = x[i][2] - x[j][2]; + + vnnr = vr1*delx + vr2*dely + vr3*delz; + vn1 = delx*vnnr * rsqinv; + vn2 = dely*vnnr * rsqinv; + vn3 = delz*vnnr * rsqinv; + + // tangential component + + vt1 = vr1 - vn1; + vt2 = vr2 - vn2; + vt3 = vr3 - vn3; + + // relative rotational velocity + + double **omega = atom->omega; + wr1 = (radi*omega[i][0] + radj*omega[j][0]) * rinv; + wr2 = (radi*omega[i][1] + radj*omega[j][1]) * rinv; + wr3 = (radi*omega[i][2] + radj*omega[j][2]) * rinv; + + // meff = effective mass of pair of particles + // if I or J part of rigid body, use body mass + // if I or J is frozen, meff is other particle + + double *rmass = atom->rmass; + int *mask = atom->mask; + + mi = rmass[i]; + mj = rmass[j]; + if (fix_rigid) { + // NOTE: insure mass_rigid is current for owned+ghost atoms? + if (mass_rigid[i] > 0.0) mi = mass_rigid[i]; + if (mass_rigid[j] > 0.0) mj = mass_rigid[j]; + } + + meff = mi*mj / (mi+mj); + if (mask[i] & freeze_group_bit) meff = mj; + if (mask[j] & freeze_group_bit) meff = mi; + + // normal forces = Hookian contact + normal velocity damping + + damp = meff*gamman[itype][jtype]*vnnr*rsqinv; + ccel = kn[itype][jtype]*(radsum-r)*rinv - damp; + + // relative velocities + + vtr1 = vt1 - (delz*wr2-dely*wr3); + vtr2 = vt2 - (delx*wr3-delz*wr1); + vtr3 = vt3 - (dely*wr1-delx*wr2); + vrel = vtr1*vtr1 + vtr2*vtr2 + vtr3*vtr3; + vrel = sqrt(vrel); + + // shear history effects + // neighprev = index of found neigh on previous call + // search entire jnum list of neighbors of I for neighbor J + // start from neighprev, since will typically be next neighbor + // reset neighprev to 0 as necessary + + int jnum = list->numneigh[i]; + int *jlist = list->firstneigh[i]; + double *allshear = fix_history->firstvalue[i]; + + for (int jj = 0; jj < jnum; jj++) { + neighprev++; + if (neighprev >= jnum) neighprev = 0; + if (jlist[neighprev] == j) break; + } + + double *shear = &allshear[3*neighprev]; + shrmag = sqrt(shear[0]*shear[0] + shear[1]*shear[1] + + shear[2]*shear[2]); + + // rotate shear displacements + + rsht = shear[0]*delx + shear[1]*dely + shear[2]*delz; + rsht *= rsqinv; + + // tangential forces = shear + tangential velocity damping + + fs1 = - (kt[itype][jtype]*shear[0] + meff*gammat[itype][jtype]*vtr1); + fs2 = - (kt[itype][jtype]*shear[1] + meff*gammat[itype][jtype]*vtr2); + fs3 = - (kt[itype][jtype]*shear[2] + meff*gammat[itype][jtype]*vtr3); + + // rescale frictional displacements and forces if needed + + fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); + fn = xmu[itype][jtype] * fabs(ccel*r); + + if (fs > fn) { + if (shrmag != 0.0) { + fs1 *= fn/fs; + fs2 *= fn/fs; + fs3 *= fn/fs; + fs *= fn/fs; + } else fs1 = fs2 = fs3 = fs = 0.0; + } + + // set force and return no energy + + fforce = ccel; + + // set single_extra quantities + + svector[0] = fs1; + svector[1] = fs2; + svector[2] = fs3; + svector[3] = fs; + svector[4] = vn1; + svector[5] = vn2; + svector[6] = vn3; + svector[7] = vt1; + svector[8] = vt2; + svector[9] = vt3; + + return 0.0; +} + +/* ---------------------------------------------------------------------- */ + +int PairGranHookeHistoryMulti::pack_forward_comm(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = mass_rigid[j]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void PairGranHookeHistoryMulti::unpack_forward_comm(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) + mass_rigid[i] = buf[m++]; +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based arrays +------------------------------------------------------------------------- */ + +double PairGranHookeHistoryMulti::memory_usage() +{ + double bytes = nmax * sizeof(double); + return bytes; +} + +/* ---------------------------------------------------------------------- + mixing of stiffness +------------------------------------------------------------------------- */ + +double PairGranHookeHistoryMulti::mix_stiffness(double kii, double kjj) +{ + return kii*kjj/(kii + kjj); +} + +/* ---------------------------------------------------------------------- + mixing of damping +------------------------------------------------------------------------- */ + +double PairGranHookeHistoryMulti::mix_damping(double gammaii, double gammajj) +{ + return sqrt(gammaii*gammajj); +} + +/* ---------------------------------------------------------------------- + mixing of friction +------------------------------------------------------------------------- */ + +double PairGranHookeHistoryMulti::mix_friction(double xmuii, double xmujj) +{ + return MAX(xmuii,xmujj); +} + diff --git a/src/from_ishan/pair_gran_hooke_history_multi.h b/src/from_ishan/pair_gran_hooke_history_multi.h new file mode 100644 index 0000000000..f302ede96c --- /dev/null +++ b/src/from_ishan/pair_gran_hooke_history_multi.h @@ -0,0 +1,109 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS + +PairStyle(gran/hooke/history/multi,PairGranHookeHistoryMulti) + +#else + +#ifndef LMP_PAIR_GRAN_HOOKE_HISTORY_MULTI_H +#define LMP_PAIR_GRAN_HOOKE_HISTORY_MULTI_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairGranHookeHistoryMulti : public Pair { + public: + PairGranHookeHistoryMulti(class LAMMPS *); + virtual ~PairGranHookeHistoryMulti(); + virtual void compute(int, int); + virtual void settings(int, char **); + virtual void coeff(int, char **); // Made Virtual by IS Oct 7 2017 + void init_style(); + double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); + void reset_dt(); + virtual double single(int, int, int, int, double, double, double, double &); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + double memory_usage(); + + protected: + double cut_global; + double **kn,**kt,**gamman,**gammat,**xmu,**cut; + int **dampflag; + double dt; + int freeze_group_bit; + int history; + + int neighprev; + double *onerad_dynamic,*onerad_frozen; + double *maxrad_dynamic,*maxrad_frozen; + + class FixNeighHistory *fix_history; + + // storage of rigid body masses for use in granular interactions + + class Fix *fix_rigid; // ptr to rigid body fix, NULL if none + double *mass_rigid; // rigid mass for owned+ghost atoms + int nmax; // allocated size of mass_rigid + + virtual void allocate(); // Made Virtual by IS Oct 7 2017 + +private: + double mix_stiffness(double kii, double kjj); + double mix_damping(double gammaii, double gammajj); + double mix_friction(double xmuii, double xmujj); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Incorrect args for pair coefficients + +Self-explanatory. Check the input script or data file. + +E: Pair granular requires atom attributes radius, rmass + +The atom style defined does not have these attributes. + +E: Pair granular requires ghost atoms store velocity + +Use the comm_modify vel yes command to enable this. + +E: Pair granular with shear history requires newton pair off + +This is a current restriction of the implementation of pair +granular styles with history. + +E: Could not find pair fix ID + +A fix is created internally by the pair style to store shear +history information. You cannot delete it. + +*/ From dfb5cd3262bfa0a45eb4989391c1a62d2756232d Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Fri, 2 Oct 2020 16:37:01 -0600 Subject: [PATCH 002/187] merged with mastered, copied Ishan's files --- src/{from_ishan => }/npair_half_size_multi_newtoff.cpp | 0 src/{from_ishan => }/npair_half_size_multi_newtoff.h | 0 src/{from_ishan => }/npair_half_size_multi_newton.cpp | 0 src/{from_ishan => }/npair_half_size_multi_newton.h | 0 src/{from_ishan => }/npair_half_size_multi_newton_tri.cpp | 0 src/{from_ishan => }/npair_half_size_multi_newton_tri.h | 0 src/{from_ishan => }/pair_gran_hooke_history_multi.cpp | 0 src/{from_ishan => }/pair_gran_hooke_history_multi.h | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename src/{from_ishan => }/npair_half_size_multi_newtoff.cpp (100%) rename src/{from_ishan => }/npair_half_size_multi_newtoff.h (100%) rename src/{from_ishan => }/npair_half_size_multi_newton.cpp (100%) rename src/{from_ishan => }/npair_half_size_multi_newton.h (100%) rename src/{from_ishan => }/npair_half_size_multi_newton_tri.cpp (100%) rename src/{from_ishan => }/npair_half_size_multi_newton_tri.h (100%) rename src/{from_ishan => }/pair_gran_hooke_history_multi.cpp (100%) rename src/{from_ishan => }/pair_gran_hooke_history_multi.h (100%) diff --git a/src/from_ishan/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp similarity index 100% rename from src/from_ishan/npair_half_size_multi_newtoff.cpp rename to src/npair_half_size_multi_newtoff.cpp diff --git a/src/from_ishan/npair_half_size_multi_newtoff.h b/src/npair_half_size_multi_newtoff.h similarity index 100% rename from src/from_ishan/npair_half_size_multi_newtoff.h rename to src/npair_half_size_multi_newtoff.h diff --git a/src/from_ishan/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp similarity index 100% rename from src/from_ishan/npair_half_size_multi_newton.cpp rename to src/npair_half_size_multi_newton.cpp diff --git a/src/from_ishan/npair_half_size_multi_newton.h b/src/npair_half_size_multi_newton.h similarity index 100% rename from src/from_ishan/npair_half_size_multi_newton.h rename to src/npair_half_size_multi_newton.h diff --git a/src/from_ishan/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp similarity index 100% rename from src/from_ishan/npair_half_size_multi_newton_tri.cpp rename to src/npair_half_size_multi_newton_tri.cpp diff --git a/src/from_ishan/npair_half_size_multi_newton_tri.h b/src/npair_half_size_multi_newton_tri.h similarity index 100% rename from src/from_ishan/npair_half_size_multi_newton_tri.h rename to src/npair_half_size_multi_newton_tri.h diff --git a/src/from_ishan/pair_gran_hooke_history_multi.cpp b/src/pair_gran_hooke_history_multi.cpp similarity index 100% rename from src/from_ishan/pair_gran_hooke_history_multi.cpp rename to src/pair_gran_hooke_history_multi.cpp diff --git a/src/from_ishan/pair_gran_hooke_history_multi.h b/src/pair_gran_hooke_history_multi.h similarity index 100% rename from src/from_ishan/pair_gran_hooke_history_multi.h rename to src/pair_gran_hooke_history_multi.h From bc1c16d1a632e4ec5a0b3efaa0b88a92c286e33e Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Mon, 5 Oct 2020 16:14:01 -0600 Subject: [PATCH 003/187] Removing gran/multi pairstyles --- src/pair_gran_hooke_history_multi.cpp | 885 -------------------------- src/pair_gran_hooke_history_multi.h | 109 ---- 2 files changed, 994 deletions(-) delete mode 100644 src/pair_gran_hooke_history_multi.cpp delete mode 100644 src/pair_gran_hooke_history_multi.h diff --git a/src/pair_gran_hooke_history_multi.cpp b/src/pair_gran_hooke_history_multi.cpp deleted file mode 100644 index 83f5221741..0000000000 --- a/src/pair_gran_hooke_history_multi.cpp +++ /dev/null @@ -1,885 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing authors: Leo Silbert (SNL), Gary Grest (SNL) -------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include "pair_gran_hooke_history_multi.h" -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "force.h" -#include "update.h" -#include "modify.h" -#include "fix.h" -#include "fix_neigh_history.h" -#include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "memory.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -PairGranHookeHistoryMulti::PairGranHookeHistoryMulti(LAMMPS *lmp) : Pair(lmp) -{ - single_enable = 1; - no_virial_fdotr_compute = 1; - history = 1; - fix_history = NULL; - - single_extra = 10; - svector = new double[10]; - - neighprev = 0; - - nmax = 0; - mass_rigid = NULL; - - // set comm size needed by this Pair if used with fix rigid - - comm_forward = 1; -} - -/* ---------------------------------------------------------------------- */ - -PairGranHookeHistoryMulti::~PairGranHookeHistoryMulti() -{ - delete [] svector; - if (fix_history) modify->delete_fix("NEIGH_HISTORY"); - - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - - memory->destroy(kn); - memory->destroy(kt); - memory->destroy(gamman); - memory->destroy(gammat); - memory->destroy(xmu); - memory->destroy(dampflag); - - delete [] onerad_dynamic; - delete [] onerad_frozen; - delete [] maxrad_dynamic; - delete [] maxrad_frozen; - } - - memory->destroy(mass_rigid); -} - -/* ---------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::compute(int eflag, int vflag) -{ - int i,j,ii,jj,inum,jnum,itype,jtype; - double xtmp,ytmp,ztmp,delx,dely,delz,fx,fy,fz; - double radi,radj,radsum,rsq,r,rinv,rsqinv; - double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3; - double wr1,wr2,wr3; - double vtr1,vtr2,vtr3,vrel; - double mi,mj,meff,damp,ccel,tor1,tor2,tor3; - double fn,fs,fs1,fs2,fs3; - double shrmag,rsht; - int *ilist,*jlist,*numneigh,**firstneigh; - int *touch,**firsttouch; - double *shear,*allshear,**firstshear; - - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; - - int shearupdate = 1; - if (update->setupflag) shearupdate = 0; - - // update rigid body info for owned & ghost atoms if using FixRigid masses - // body[i] = which body atom I is in, -1 if none - // mass_body = mass of each rigid body - - if (fix_rigid && neighbor->ago == 0) { - int tmp; - int *body = (int *) fix_rigid->extract("body",tmp); - double *mass_body = (double *) fix_rigid->extract("masstotal",tmp); - if (atom->nmax > nmax) { - memory->destroy(mass_rigid); - nmax = atom->nmax; - memory->create(mass_rigid,nmax,"pair:mass_rigid"); - } - int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) - if (body[i] >= 0) mass_rigid[i] = mass_body[body[i]]; - else mass_rigid[i] = 0.0; - comm->forward_comm_pair(this); - } - - double **x = atom->x; - double **v = atom->v; - double **f = atom->f; - int *type = atom->type; - double **omega = atom->omega; - double **torque = atom->torque; - double *radius = atom->radius; - double *rmass = atom->rmass; - int *mask = atom->mask; - int nlocal = atom->nlocal; - int newton_pair = force->newton_pair; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - firsttouch = fix_history->firstflag; - firstshear = fix_history->firstvalue; - - // loop over neighbors of my atoms - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - radi = radius[i]; - touch = firsttouch[i]; - allshear = firstshear[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; - jtype = type[j]; - radj = radius[j]; - radsum = radi + radj; - - if (rsq >= radsum*radsum) { - - // unset non-touching neighbors - - touch[jj] = 0; - shear = &allshear[3*jj]; - shear[0] = 0.0; - shear[1] = 0.0; - shear[2] = 0.0; - - } else { - r = sqrt(rsq); - rinv = 1.0/r; - rsqinv = 1.0/rsq; - - // relative translational velocity - - vr1 = v[i][0] - v[j][0]; - vr2 = v[i][1] - v[j][1]; - vr3 = v[i][2] - v[j][2]; - - // normal component - - vnnr = vr1*delx + vr2*dely + vr3*delz; - vn1 = delx*vnnr * rsqinv; - vn2 = dely*vnnr * rsqinv; - vn3 = delz*vnnr * rsqinv; - - // tangential component - - vt1 = vr1 - vn1; - vt2 = vr2 - vn2; - vt3 = vr3 - vn3; - - // relative rotational velocity - - wr1 = (radi*omega[i][0] + radj*omega[j][0]) * rinv; - wr2 = (radi*omega[i][1] + radj*omega[j][1]) * rinv; - wr3 = (radi*omega[i][2] + radj*omega[j][2]) * rinv; - - // meff = effective mass of pair of particles - // if I or J part of rigid body, use body mass - // if I or J is frozen, meff is other particle - - mi = rmass[i]; - mj = rmass[j]; - if (fix_rigid) { - if (mass_rigid[i] > 0.0) mi = mass_rigid[i]; - if (mass_rigid[j] > 0.0) mj = mass_rigid[j]; - } - - meff = mi*mj / (mi+mj); - if (mask[i] & freeze_group_bit) meff = mj; - if (mask[j] & freeze_group_bit) meff = mi; - - // normal forces = Hookian contact + normal velocity damping - - damp = meff*gamman[itype][jtype]*vnnr*rsqinv; - ccel = kn[itype][jtype]*(radsum-r)*rinv - damp; - - // relative velocities - - vtr1 = vt1 - (delz*wr2-dely*wr3); - vtr2 = vt2 - (delx*wr3-delz*wr1); - vtr3 = vt3 - (dely*wr1-delx*wr2); - vrel = vtr1*vtr1 + vtr2*vtr2 + vtr3*vtr3; - vrel = sqrt(vrel); - - // shear history effects - - touch[jj] = 1; - shear = &allshear[3*jj]; - - if (shearupdate) { - shear[0] += vtr1*dt; - shear[1] += vtr2*dt; - shear[2] += vtr3*dt; - } - shrmag = sqrt(shear[0]*shear[0] + shear[1]*shear[1] + - shear[2]*shear[2]); - - // rotate shear displacements - - rsht = shear[0]*delx + shear[1]*dely + shear[2]*delz; - rsht *= rsqinv; - if (shearupdate) { - shear[0] -= rsht*delx; - shear[1] -= rsht*dely; - shear[2] -= rsht*delz; - } - - // tangential forces = shear + tangential velocity damping - - fs1 = - (kt[itype][jtype]*shear[0] + meff*gammat[itype][jtype]*vtr1); - fs2 = - (kt[itype][jtype]*shear[1] + meff*gammat[itype][jtype]*vtr2); - fs3 = - (kt[itype][jtype]*shear[2] + meff*gammat[itype][jtype]*vtr3); - - // rescale frictional displacements and forces if needed - - fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); - fn = xmu[itype][jtype] * fabs(ccel*r); - - if (fs > fn) { - if (shrmag != 0.0) { - shear[0] = (fn/fs) * (shear[0] + - meff*gammat[itype][jtype]*vtr1/kt[itype][jtype]) - - meff*gammat[itype][jtype]*vtr1/kt[itype][jtype]; - shear[1] = (fn/fs) * (shear[1] + - meff*gammat[itype][jtype]*vtr2/kt[itype][jtype]) - - meff*gammat[itype][jtype]*vtr2/kt[itype][jtype]; - shear[2] = (fn/fs) * (shear[2] + - meff*gammat[itype][jtype]*vtr3/kt[itype][jtype]) - - meff*gammat[itype][jtype]*vtr3/kt[itype][jtype]; - fs1 *= fn/fs; - fs2 *= fn/fs; - fs3 *= fn/fs; - } else fs1 = fs2 = fs3 = 0.0; - } - - // forces & torques - - fx = delx*ccel + fs1; - fy = dely*ccel + fs2; - fz = delz*ccel + fs3; - f[i][0] += fx; - f[i][1] += fy; - f[i][2] += fz; - - tor1 = rinv * (dely*fs3 - delz*fs2); - tor2 = rinv * (delz*fs1 - delx*fs3); - tor3 = rinv * (delx*fs2 - dely*fs1); - torque[i][0] -= radi*tor1; - torque[i][1] -= radi*tor2; - torque[i][2] -= radi*tor3; - - if (newton_pair || j < nlocal) { - f[j][0] -= fx; - f[j][1] -= fy; - f[j][2] -= fz; - torque[j][0] -= radj*tor1; - torque[j][1] -= radj*tor2; - torque[j][2] -= radj*tor3; - } - - if (evflag) ev_tally_xyz(i,j,nlocal,newton_pair, - 0.0,0.0,fx,fy,fz,delx,dely,delz); - } - } - } - - if (vflag_fdotr) virial_fdotr_compute(); -} - -/* ---------------------------------------------------------------------- - allocate all arrays -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::allocate() -{ - allocated = 1; - int n = atom->ntypes; - - 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; - - memory->create(cutsq,n+1,n+1,"pair:cutsq"); - - memory->create(cut,n+1,n+1,"pair:cut"); - memory->create(kn,n+1,n+1,"pair:kn"); - memory->create(kt,n+1,n+1,"pair:kt"); - memory->create(gamman,n+1,n+1,"pair:gamman"); - memory->create(gammat,n+1,n+1,"pair:gammat"); - memory->create(xmu,n+1,n+1,"pair:xmu"); - memory->create(dampflag,n+1,n+1,"pair:dampflag"); - - onerad_dynamic = new double[n+1]; - onerad_frozen = new double[n+1]; - maxrad_dynamic = new double[n+1]; - maxrad_frozen = new double[n+1]; -} - -/* ---------------------------------------------------------------------- - global settings -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::settings(int narg, char **arg) -{ - if (narg != 1) error->all(FLERR,"Illegal pair_style command"); - - if (strcmp(arg[0],"NULL") == 0 ) cut_global = -1.0; - else cut_global = force->numeric(FLERR,arg[0]); - - // reset cutoffs that have been explicitly set - if (allocated) { - 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; - } -} - -/* ---------------------------------------------------------------------- - set coeffs for one or more type pairs -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::coeff(int narg, char **arg) -{ - if (narg < 8 || narg > 9) - error->all(FLERR,"Incorrect args for pair coefficients"); - - if (!allocated) allocate(); - - int ilo,ihi,jlo,jhi; - force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi); - force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi); - - double kn_one = force->numeric(FLERR,arg[2]); - double kt_one; - if (strcmp(arg[3],"NULL") == 0) kt_one = kn_one * 2.0/7.0; - else kt_one = force->numeric(FLERR,arg[3]); - - double gamman_one = force->numeric(FLERR,arg[4]); - double gammat_one; - if (strcmp(arg[5],"NULL") == 0) gammat_one = 0.5 * gamman_one; - else gammat_one = force->numeric(FLERR,arg[5]); - - double xmu_one = force->numeric(FLERR,arg[6]); - int dampflag_one = force->inumeric(FLERR,arg[7]); - if (dampflag_one == 0) gammat_one = 0.0; - - if (kn_one < 0.0 || kt_one < 0.0 || gamman_one < 0.0 || gammat_one < 0.0 || - xmu_one < 0.0 || xmu_one > 10000.0 || dampflag_one < 0 || dampflag_one > 1) - error->all(FLERR,"Illegal pair_style command"); - - // convert Kn and Kt from pressure units to force/distance^2 - kn_one /= force->nktv2p; - kt_one /= force->nktv2p; - - double cut_one = cut_global; - if (narg==9) { - if (strcmp(arg[8],"NULL") == 0) cut_one = -1.0; - else cut_one = force->numeric(FLERR,arg[8]); - } - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { - kn[i][j] = kn_one; - kt[i][j] = kt_one; - gamman[i][j] = gamman_one; - gammat[i][j] = gammat_one; - xmu[i][j] = xmu_one; - dampflag[i][j] = dampflag_one; - cut[i][j] = cut_one; - setflag[i][j] = 1; - count++; - } - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); -} - -/* ---------------------------------------------------------------------- - init specific to this pair style -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::init_style() -{ - int i; - - // error and warning checks - - if (!atom->radius_flag || !atom->rmass_flag) - error->all(FLERR,"Pair granular requires atom attributes radius, rmass"); - if (comm->ghost_velocity == 0) - error->all(FLERR,"Pair granular requires ghost atoms store velocity"); - - // need a granular neigh list - - int irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->size = 1; - if (history) neighbor->requests[irequest]->history = 1; - - dt = update->dt; - - // if shear history is stored: - // if first init, create Fix needed for storing shear history - - if (history && fix_history == NULL) { - char dnumstr[16]; - sprintf(dnumstr,"%d",3); - char **fixarg = new char*[4]; - fixarg[0] = (char *) "NEIGH_HISTORY"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "NEIGH_HISTORY"; - fixarg[3] = dnumstr; - modify->add_fix(4,fixarg,1); - delete [] fixarg; - fix_history = (FixNeighHistory *) modify->fix[modify->nfix-1]; - fix_history->pair = this; - } - - // check for FixFreeze and set freeze_group_bit - - for (i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"freeze") == 0) break; - if (i < modify->nfix) freeze_group_bit = modify->fix[i]->groupbit; - else freeze_group_bit = 0; - - // check for FixRigid so can extract rigid body masses - - fix_rigid = NULL; - for (i = 0; i < modify->nfix; i++) - if (modify->fix[i]->rigid_flag) break; - if (i < modify->nfix) fix_rigid = modify->fix[i]; - - // check for FixPour and FixDeposit so can extract particle radii - - int ipour; - for (ipour = 0; ipour < modify->nfix; ipour++) - if (strcmp(modify->fix[ipour]->style,"pour") == 0) break; - if (ipour == modify->nfix) ipour = -1; - - int idep; - for (idep = 0; idep < modify->nfix; idep++) - if (strcmp(modify->fix[idep]->style,"deposit") == 0) break; - if (idep == modify->nfix) idep = -1; - - // set maxrad_dynamic and maxrad_frozen for each type - // include future FixPour and FixDeposit particles as dynamic - - int itype; - for (i = 1; i <= atom->ntypes; i++) { - onerad_dynamic[i] = onerad_frozen[i] = 0.0; - if (ipour >= 0) { - itype = i; - onerad_dynamic[i] = - *((double *) modify->fix[ipour]->extract("radius",itype)); - } - if (idep >= 0) { - itype = i; - onerad_dynamic[i] = - *((double *) modify->fix[idep]->extract("radius",itype)); - } - } - - double *radius = atom->radius; - int *mask = atom->mask; - int *type = atom->type; - int nlocal = atom->nlocal; - - for (i = 0; i < nlocal; i++) - if (mask[i] & freeze_group_bit) - onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]],radius[i]); - else - onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]],radius[i]); - - MPI_Allreduce(&onerad_dynamic[1],&maxrad_dynamic[1],atom->ntypes, - MPI_DOUBLE,MPI_MAX,world); - MPI_Allreduce(&onerad_frozen[1],&maxrad_frozen[1],atom->ntypes, - MPI_DOUBLE,MPI_MAX,world); - - // set fix which stores history info - - if (history) { - int ifix = modify->find_fix("NEIGH_HISTORY"); - if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID"); - fix_history = (FixNeighHistory *) modify->fix[ifix]; - } -} - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i -------------------------------------------------------------------------- */ - -double PairGranHookeHistoryMulti::init_one(int i, int j) -{ - if (setflag[i][j] == 0) { - kn[i][j] = mix_stiffness(kn[i][i],kn[j][j]); - kt[i][j] = mix_stiffness(kt[i][i],kt[j][j]); - gamman[i][j] = mix_damping(gamman[i][i],gamman[j][j]); - gammat[i][j] = mix_damping(gammat[i][i],gammat[j][j]); - xmu[i][j] = mix_friction(xmu[i][i],xmu[j][j]); - - dampflag[i][j] = 0; - if (dampflag[i][i] || dampflag[j][j]) dampflag[i][j] = 1; - - } - - kn[j][i] = kn[i][j]; - kt[j][i] = kt[i][j]; - gamman[j][i] = gamman[i][j]; - gammat[j][i] = gammat[i][j]; - xmu[j][i] = xmu[i][j]; - dampflag[j][i] = dampflag[i][j]; - - // cutoff = sum of max I,J radii for - // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen - double cutoff = cut[i][j]; - if (cut[i][j] < 0.0) cutoff = maxrad_dynamic[i]+maxrad_dynamic[j]; - if (cut[i][j] < 0.0) cutoff = MAX(cutoff,maxrad_frozen[i]+maxrad_dynamic[j]); - if (cut[i][j] < 0.0) cutoff = MAX(cutoff,maxrad_dynamic[i]+maxrad_frozen[j]); - - // cut[i][j] = MAX(maxrad_dynamic[i],maxrad_dynamic[j]); - // double cutoff = maxrad_dynamic[i]+maxrad_dynamic[j]; - // cutoff = MAX(cutoff,maxrad_frozen[i]+maxrad_dynamic[j]); - // cutoff = MAX(cutoff,maxrad_dynamic[i]+maxrad_frozen[j]); - return cutoff; -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::write_restart(FILE *fp) -{ - write_restart_settings(fp); - - 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); -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::read_restart(FILE *fp) -{ - read_restart_settings(fp); - allocate(); - - int i,j; - int me = comm->me; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); - MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); - } -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::write_restart_settings(FILE *fp) -{ - fwrite(&kn,sizeof(double),1,fp); - fwrite(&kt,sizeof(double),1,fp); - fwrite(&gamman,sizeof(double),1,fp); - fwrite(&gammat,sizeof(double),1,fp); - fwrite(&xmu,sizeof(double),1,fp); - fwrite(&dampflag,sizeof(int),1,fp); -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::read_restart_settings(FILE *fp) -{ - if (comm->me == 0) { - fread(&kn,sizeof(double),1,fp); - fread(&kt,sizeof(double),1,fp); - fread(&gamman,sizeof(double),1,fp); - fread(&gammat,sizeof(double),1,fp); - fread(&xmu,sizeof(double),1,fp); - fread(&dampflag,sizeof(int),1,fp); - } - MPI_Bcast(&kn,1,MPI_DOUBLE,0,world); - MPI_Bcast(&kt,1,MPI_DOUBLE,0,world); - MPI_Bcast(&gamman,1,MPI_DOUBLE,0,world); - MPI_Bcast(&gammat,1,MPI_DOUBLE,0,world); - MPI_Bcast(&xmu,1,MPI_DOUBLE,0,world); - MPI_Bcast(&dampflag,1,MPI_INT,0,world); -} - -/* ---------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::reset_dt() -{ - dt = update->dt; -} - -/* ---------------------------------------------------------------------- */ - -double PairGranHookeHistoryMulti::single(int i, int j, int itype, int jtype, - double rsq, - double factor_coul, double factor_lj, - double &fforce) -{ - double radi,radj,radsum; - double r,rinv,rsqinv,delx,dely,delz; - double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3,wr1,wr2,wr3; - double mi,mj,meff,damp,ccel; - double vtr1,vtr2,vtr3,vrel,shrmag,rsht; - double fs1,fs2,fs3,fs,fn; - - double *radius = atom->radius; - radi = radius[i]; - radj = radius[j]; - radsum = radi + radj; - - if (rsq >= radsum*radsum) { - fforce = 0.0; - for (int m = 0; m < single_extra; m++) svector[m] = 0.0; - return 0.0; - } - - r = sqrt(rsq); - rinv = 1.0/r; - rsqinv = 1.0/rsq; - - // relative translational velocity - - double **v = atom->v; - vr1 = v[i][0] - v[j][0]; - vr2 = v[i][1] - v[j][1]; - vr3 = v[i][2] - v[j][2]; - - // normal component - - double **x = atom->x; - delx = x[i][0] - x[j][0]; - dely = x[i][1] - x[j][1]; - delz = x[i][2] - x[j][2]; - - vnnr = vr1*delx + vr2*dely + vr3*delz; - vn1 = delx*vnnr * rsqinv; - vn2 = dely*vnnr * rsqinv; - vn3 = delz*vnnr * rsqinv; - - // tangential component - - vt1 = vr1 - vn1; - vt2 = vr2 - vn2; - vt3 = vr3 - vn3; - - // relative rotational velocity - - double **omega = atom->omega; - wr1 = (radi*omega[i][0] + radj*omega[j][0]) * rinv; - wr2 = (radi*omega[i][1] + radj*omega[j][1]) * rinv; - wr3 = (radi*omega[i][2] + radj*omega[j][2]) * rinv; - - // meff = effective mass of pair of particles - // if I or J part of rigid body, use body mass - // if I or J is frozen, meff is other particle - - double *rmass = atom->rmass; - int *mask = atom->mask; - - mi = rmass[i]; - mj = rmass[j]; - if (fix_rigid) { - // NOTE: insure mass_rigid is current for owned+ghost atoms? - if (mass_rigid[i] > 0.0) mi = mass_rigid[i]; - if (mass_rigid[j] > 0.0) mj = mass_rigid[j]; - } - - meff = mi*mj / (mi+mj); - if (mask[i] & freeze_group_bit) meff = mj; - if (mask[j] & freeze_group_bit) meff = mi; - - // normal forces = Hookian contact + normal velocity damping - - damp = meff*gamman[itype][jtype]*vnnr*rsqinv; - ccel = kn[itype][jtype]*(radsum-r)*rinv - damp; - - // relative velocities - - vtr1 = vt1 - (delz*wr2-dely*wr3); - vtr2 = vt2 - (delx*wr3-delz*wr1); - vtr3 = vt3 - (dely*wr1-delx*wr2); - vrel = vtr1*vtr1 + vtr2*vtr2 + vtr3*vtr3; - vrel = sqrt(vrel); - - // shear history effects - // neighprev = index of found neigh on previous call - // search entire jnum list of neighbors of I for neighbor J - // start from neighprev, since will typically be next neighbor - // reset neighprev to 0 as necessary - - int jnum = list->numneigh[i]; - int *jlist = list->firstneigh[i]; - double *allshear = fix_history->firstvalue[i]; - - for (int jj = 0; jj < jnum; jj++) { - neighprev++; - if (neighprev >= jnum) neighprev = 0; - if (jlist[neighprev] == j) break; - } - - double *shear = &allshear[3*neighprev]; - shrmag = sqrt(shear[0]*shear[0] + shear[1]*shear[1] + - shear[2]*shear[2]); - - // rotate shear displacements - - rsht = shear[0]*delx + shear[1]*dely + shear[2]*delz; - rsht *= rsqinv; - - // tangential forces = shear + tangential velocity damping - - fs1 = - (kt[itype][jtype]*shear[0] + meff*gammat[itype][jtype]*vtr1); - fs2 = - (kt[itype][jtype]*shear[1] + meff*gammat[itype][jtype]*vtr2); - fs3 = - (kt[itype][jtype]*shear[2] + meff*gammat[itype][jtype]*vtr3); - - // rescale frictional displacements and forces if needed - - fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); - fn = xmu[itype][jtype] * fabs(ccel*r); - - if (fs > fn) { - if (shrmag != 0.0) { - fs1 *= fn/fs; - fs2 *= fn/fs; - fs3 *= fn/fs; - fs *= fn/fs; - } else fs1 = fs2 = fs3 = fs = 0.0; - } - - // set force and return no energy - - fforce = ccel; - - // set single_extra quantities - - svector[0] = fs1; - svector[1] = fs2; - svector[2] = fs3; - svector[3] = fs; - svector[4] = vn1; - svector[5] = vn2; - svector[6] = vn3; - svector[7] = vt1; - svector[8] = vt2; - svector[9] = vt3; - - return 0.0; -} - -/* ---------------------------------------------------------------------- */ - -int PairGranHookeHistoryMulti::pack_forward_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = mass_rigid[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void PairGranHookeHistoryMulti::unpack_forward_comm(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - mass_rigid[i] = buf[m++]; -} - -/* ---------------------------------------------------------------------- - memory usage of local atom-based arrays -------------------------------------------------------------------------- */ - -double PairGranHookeHistoryMulti::memory_usage() -{ - double bytes = nmax * sizeof(double); - return bytes; -} - -/* ---------------------------------------------------------------------- - mixing of stiffness -------------------------------------------------------------------------- */ - -double PairGranHookeHistoryMulti::mix_stiffness(double kii, double kjj) -{ - return kii*kjj/(kii + kjj); -} - -/* ---------------------------------------------------------------------- - mixing of damping -------------------------------------------------------------------------- */ - -double PairGranHookeHistoryMulti::mix_damping(double gammaii, double gammajj) -{ - return sqrt(gammaii*gammajj); -} - -/* ---------------------------------------------------------------------- - mixing of friction -------------------------------------------------------------------------- */ - -double PairGranHookeHistoryMulti::mix_friction(double xmuii, double xmujj) -{ - return MAX(xmuii,xmujj); -} - diff --git a/src/pair_gran_hooke_history_multi.h b/src/pair_gran_hooke_history_multi.h deleted file mode 100644 index f302ede96c..0000000000 --- a/src/pair_gran_hooke_history_multi.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef PAIR_CLASS - -PairStyle(gran/hooke/history/multi,PairGranHookeHistoryMulti) - -#else - -#ifndef LMP_PAIR_GRAN_HOOKE_HISTORY_MULTI_H -#define LMP_PAIR_GRAN_HOOKE_HISTORY_MULTI_H - -#include "pair.h" - -namespace LAMMPS_NS { - -class PairGranHookeHistoryMulti : public Pair { - public: - PairGranHookeHistoryMulti(class LAMMPS *); - virtual ~PairGranHookeHistoryMulti(); - virtual void compute(int, int); - virtual void settings(int, char **); - virtual void coeff(int, char **); // Made Virtual by IS Oct 7 2017 - void init_style(); - double init_one(int, int); - void write_restart(FILE *); - void read_restart(FILE *); - void write_restart_settings(FILE *); - void read_restart_settings(FILE *); - void reset_dt(); - virtual double single(int, int, int, int, double, double, double, double &); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); - double memory_usage(); - - protected: - double cut_global; - double **kn,**kt,**gamman,**gammat,**xmu,**cut; - int **dampflag; - double dt; - int freeze_group_bit; - int history; - - int neighprev; - double *onerad_dynamic,*onerad_frozen; - double *maxrad_dynamic,*maxrad_frozen; - - class FixNeighHistory *fix_history; - - // storage of rigid body masses for use in granular interactions - - class Fix *fix_rigid; // ptr to rigid body fix, NULL if none - double *mass_rigid; // rigid mass for owned+ghost atoms - int nmax; // allocated size of mass_rigid - - virtual void allocate(); // Made Virtual by IS Oct 7 2017 - -private: - double mix_stiffness(double kii, double kjj); - double mix_damping(double gammaii, double gammajj); - double mix_friction(double xmuii, double xmujj); -}; - -} - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Incorrect args for pair coefficients - -Self-explanatory. Check the input script or data file. - -E: Pair granular requires atom attributes radius, rmass - -The atom style defined does not have these attributes. - -E: Pair granular requires ghost atoms store velocity - -Use the comm_modify vel yes command to enable this. - -E: Pair granular with shear history requires newton pair off - -This is a current restriction of the implementation of pair -granular styles with history. - -E: Could not find pair fix ID - -A fix is created internally by the pair style to store shear -history information. You cannot delete it. - -*/ From dc86c37e2380e516a09e7569cc8564295f21e5bb Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Fri, 9 Oct 2020 11:38:18 -0600 Subject: [PATCH 004/187] Minor updates and documentation --- doc/src/comm_modify.rst | 6 ++++-- src/npair_half_size_multi_newtoff.cpp | 6 ++---- src/npair_half_size_multi_newtoff.h | 3 +++ src/npair_half_size_multi_newton.cpp | 4 +--- src/npair_half_size_multi_newton.h | 3 +++ src/npair_half_size_multi_newton_tri.cpp | 5 +++-- src/npair_half_size_multi_newton_tri.h | 3 +++ 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/src/comm_modify.rst b/doc/src/comm_modify.rst index 9a2ae60f1e..68d40281c1 100644 --- a/doc/src/comm_modify.rst +++ b/doc/src/comm_modify.rst @@ -84,13 +84,15 @@ information is available, then also a heuristic based on that bond length is computed. It is used as communication cutoff, if there is no pair style present and no *comm_modify cutoff* command used. Otherwise a warning is printed, if this bond based estimate is larger than the -communication cutoff used. A +communication cutoff used. The *cutoff/multi* option is equivalent to *cutoff*\ , but applies to communication mode *multi* instead. Since in this case the communication cutoffs are determined per atom type, a type specifier is needed and cutoff for one or multiple types can be extended. Also ranges of types -using the usual asterisk notation can be given. +using the usual asterisk notation can be given. For granular pairstyles, +the default cutoff is set to the sum of the current maximum atomic radii +for each type. These are simulation scenarios in which it may be useful or even necessary to set a ghost cutoff > neighbor cutoff: diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index ec4ff805e2..813a642b96 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -11,9 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include #include "npair_half_size_multi_newtoff.h" -#include "neighbor.h" #include "neigh_list.h" #include "atom.h" #include "atom_vec.h" @@ -27,6 +25,7 @@ using namespace LAMMPS_NS; NPairHalfSizeMultiNewtoff::NPairHalfSizeMultiNewtoff(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- + size particles binned neighbor list construction with partial Newton's 3rd law each owned atom i checks own bin and other bins in stencil multi-type stencil is itype dependent and is distance checked @@ -46,7 +45,6 @@ void NPairHalfSizeMultiNewtoff::build(NeighList *list) double *radius = atom->radius; int *type = atom->type; int *mask = atom->mask; - tagint *tag = atom->tag; tagint *molecule = atom->molecule; int nlocal = atom->nlocal; if (includegroup) nlocal = atom->nfirst; @@ -99,7 +97,7 @@ void NPairHalfSizeMultiNewtoff::build(NeighList *list) cutdistsq = (radsum+skin) * (radsum+skin); if (rsq <= cutdistsq) { - if (history && rsq < radsum*radsum) + if (history && rsq < radsum*radsum) neighptr[n++] = j ^ mask_history; else neighptr[n++] = j; diff --git a/src/npair_half_size_multi_newtoff.h b/src/npair_half_size_multi_newtoff.h index 8abe5b5456..f255f9a17d 100644 --- a/src/npair_half_size_multi_newtoff.h +++ b/src/npair_half_size_multi_newtoff.h @@ -40,4 +40,7 @@ class NPairHalfSizeMultiNewtoff : public NPair { /* ERROR/WARNING messages: +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED */ diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp index 01aea66632..0d12924629 100644 --- a/src/npair_half_size_multi_newton.cpp +++ b/src/npair_half_size_multi_newton.cpp @@ -11,9 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include #include "npair_half_size_multi_newton.h" -#include "neighbor.h" #include "neigh_list.h" #include "atom.h" #include "atom_vec.h" @@ -27,6 +25,7 @@ using namespace LAMMPS_NS; NPairHalfSizeMultiNewton::NPairHalfSizeMultiNewton(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- + size particles binned neighbor list construction with full Newton's 3rd law each owned atom i checks its own bin and other bins in Newton stencil multi-type stencil is itype dependent and is distance checked @@ -45,7 +44,6 @@ void NPairHalfSizeMultiNewton::build(NeighList *list) double *radius = atom->radius; int *type = atom->type; int *mask = atom->mask; - tagint *tag = atom->tag; tagint *molecule = atom->molecule; int nlocal = atom->nlocal; if (includegroup) nlocal = atom->nfirst; diff --git a/src/npair_half_size_multi_newton.h b/src/npair_half_size_multi_newton.h index 109fe78c2b..3e3d6f4180 100644 --- a/src/npair_half_size_multi_newton.h +++ b/src/npair_half_size_multi_newton.h @@ -40,4 +40,7 @@ class NPairHalfSizeMultiNewton : public NPair { /* ERROR/WARNING messages: +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED */ diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index f7123a958d..64b9659c8f 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -45,7 +45,6 @@ void NPairHalfSizeMultiNewtonTri::build(NeighList *list) double *radius = atom->radius; int *type = atom->type; int *mask = atom->mask; - tagint *tag = atom->tag; tagint *molecule = atom->molecule; int nlocal = atom->nlocal; if (includegroup) nlocal = atom->nfirst; @@ -72,7 +71,9 @@ void NPairHalfSizeMultiNewtonTri::build(NeighList *list) radi = radius[i]; - // loop over all atoms in bins in stencil + // loop over all atoms in bins, including self, in stencil + // skip if i,j neighbor cutoff is less than bin distance + // bins below self are excluded from stencil // pairs for atoms j "below" i are excluded // below = lower z or (equal z and lower y) or (equal zy and lower x) // (equal zyx and j <= i) diff --git a/src/npair_half_size_multi_newton_tri.h b/src/npair_half_size_multi_newton_tri.h index 15fbaba0f7..6afe8201a7 100644 --- a/src/npair_half_size_multi_newton_tri.h +++ b/src/npair_half_size_multi_newton_tri.h @@ -40,4 +40,7 @@ class NPairHalfSizeMultiNewtonTri : public NPair { /* ERROR/WARNING messages: +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED */ From d0981db66a6e244fb176929831c4a3fe2c44b077 Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Fri, 9 Oct 2020 13:51:35 -0600 Subject: [PATCH 005/187] Minor edits --- doc/src/comm_modify.rst | 2 +- src/npair_half_size_multi_newton_tri.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/src/comm_modify.rst b/doc/src/comm_modify.rst index 68d40281c1..1ccf77e995 100644 --- a/doc/src/comm_modify.rst +++ b/doc/src/comm_modify.rst @@ -84,7 +84,7 @@ information is available, then also a heuristic based on that bond length is computed. It is used as communication cutoff, if there is no pair style present and no *comm_modify cutoff* command used. Otherwise a warning is printed, if this bond based estimate is larger than the -communication cutoff used. +communication cutoff used. The *cutoff/multi* option is equivalent to *cutoff*\ , but applies to communication mode *multi* instead. Since in this case the communication diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index 64b9659c8f..adc4c080ec 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -11,9 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include #include "npair_half_size_multi_newton_tri.h" -#include "neighbor.h" #include "neigh_list.h" #include "atom.h" #include "atom_vec.h" From 0ae09c0f3b426ca7c82066359e0b79c4075e2523 Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Wed, 14 Oct 2020 15:52:20 -0600 Subject: [PATCH 006/187] Adding OMP classes --- .../npair_half_size_multi_newtoff_omp.cpp | 128 +++++++++++++++ .../npair_half_size_multi_newtoff_omp.h | 44 +++++ .../npair_half_size_multi_newton_omp.cpp | 151 ++++++++++++++++++ .../npair_half_size_multi_newton_omp.h | 43 +++++ .../npair_half_size_multi_newton_tri_omp.cpp | 136 ++++++++++++++++ .../npair_half_size_multi_newton_tri_omp.h | 43 +++++ 6 files changed, 545 insertions(+) create mode 100644 src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp create mode 100644 src/USER-OMP/npair_half_size_multi_newtoff_omp.h create mode 100644 src/USER-OMP/npair_half_size_multi_newton_omp.cpp create mode 100644 src/USER-OMP/npair_half_size_multi_newton_omp.h create mode 100644 src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp create mode 100644 src/USER-OMP/npair_half_size_multi_newton_tri_omp.h diff --git a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp new file mode 100644 index 0000000000..a72be3f982 --- /dev/null +++ b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp @@ -0,0 +1,128 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "omp_compat.h" +#include "npair_half_size_multi_newtoff_omp.h" +#include "npair_omp.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairHalfSizeMultiNewtoffOmp::NPairHalfSizeMultiNewtoffOmp(LAMMPS *lmp) : + NPair(lmp) {} + +/* ---------------------------------------------------------------------- + size particles + binned neighbor list construction with partial Newton's 3rd law + each owned atom i checks own bin and other bins in stencil + multi-type stencil is itype dependent and is distance checked + pair stored once if i,j are both owned and i < j + pair stored by me if j is ghost (also stored by proc owning j) +------------------------------------------------------------------------- */ + +void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) +{ + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int history = list->history; + const int mask_history = 3 << SBBITS; + + NPAIR_OMP_INIT; +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) +#endif + NPAIR_OMP_SETUP(nlocal); + + int i,j,k,m,n,itype,jtype,ibin,ns; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radi,radsum,cutdistsq; + int *neighptr,*s; + double *cutsq,*distsq; + + // loop over each atom, storing neighbors + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + + // each thread has its own page allocator + MyPage &ipage = list->ipage[tid]; + ipage.reset(); + + for (i = ifrom; i < ito; i++) { + + n = 0; + neighptr = ipage.vget(); + + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + radi = radius[i]; + + // loop over all atoms in other bins in stencil including self + // only store pair if i < j + // skip if i,j neighbor cutoff is less than bin distance + // stores own/own pairs only once + // stores own/ghost pairs on both procs + + ibin = atom2bin[i]; + s = stencil_multi[itype]; + distsq = distsq_multi[itype]; + cutsq = cutneighsq[itype]; + ns = nstencil_multi[itype]; + for (k = 0; k < ns; k++) { + for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { + if (j <= i) continue; + jtype = type[j]; + if (cutsq[jtype] < distsq[k]) continue; + + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + ilist[i] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + ipage.vgot(n); + if (ipage.status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + NPAIR_OMP_CLOSE; + list->inum = nlocal; +} diff --git a/src/USER-OMP/npair_half_size_multi_newtoff_omp.h b/src/USER-OMP/npair_half_size_multi_newtoff_omp.h new file mode 100644 index 0000000000..dd883d7f3c --- /dev/null +++ b/src/USER-OMP/npair_half_size_multi_newtoff_omp.h @@ -0,0 +1,44 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef NPAIR_CLASS + +NPairStyle(half/size/multi/newtoff/omp, + NPairHalfSizeMultiNewtoffOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTOFF | NP_OMP | + NP_ORTHO | NP_TRI) + +#else + +#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_OMP_H +#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairHalfSizeMultiNewtoffOmp : public NPair { + public: + NPairHalfSizeMultiNewtoffOmp(class LAMMPS *); + ~NPairHalfSizeMultiNewtoffOmp() {} + void build(class NeighList *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp new file mode 100644 index 0000000000..751805dce1 --- /dev/null +++ b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp @@ -0,0 +1,151 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "omp_compat.h" +#include "npair_half_size_multi_newton_omp.h" +#include "npair_omp.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairHalfSizeMultiNewtonOmp::NPairHalfSizeMultiNewtonOmp(LAMMPS *lmp) : + NPair(lmp) {} + +/* ---------------------------------------------------------------------- + size particles + binned neighbor list construction with full Newton's 3rd law + each owned atom i checks its own bin and other bins in Newton stencil + multi-type stencil is itype dependent and is distance checked + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) +{ + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int history = list->history; + const int mask_history = 3 << SBBITS; + + NPAIR_OMP_INIT; +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) +#endif + NPAIR_OMP_SETUP(nlocal); + + int i,j,k,n,m,itype,jtype,ibin,ns; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radi,radsum,cutdistsq; + int *neighptr,*s; + double *cutsq,*distsq; + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + + // each thread has its own page allocator + MyPage &ipage = list->ipage[tid]; + ipage.reset(); + + for (i = ifrom; i < ito; i++) { + + n = 0; + neighptr = ipage.vget(); + + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + radi = radius[i]; + + // loop over rest of atoms in i's bin, ghosts are at end of linked list + // if j is owned atom, store it, since j is beyond i in linked list + // if j is ghost, only store if j coords are "above and to the right" of i + + for (j = bins[i]; j >= 0; j = bins[j]) { + if (j >= nlocal) { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + } + + jtype = type[j]; + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + + // loop over all atoms in other bins in stencil, store every pair + // skip if i,j neighbor cutoff is less than bin distance + + ibin = atom2bin[i]; + s = stencil_multi[itype]; + distsq = distsq_multi[itype]; + cutsq = cutneighsq[itype]; + ns = nstencil_multi[itype]; + for (k = 0; k < ns; k++) { + for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { + jtype = type[j]; + if (cutsq[jtype] < distsq[k]) continue; + + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + ilist[i] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + ipage.vgot(n); + if (ipage.status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + NPAIR_OMP_CLOSE; + list->inum = nlocal; +} diff --git a/src/USER-OMP/npair_half_size_multi_newton_omp.h b/src/USER-OMP/npair_half_size_multi_newton_omp.h new file mode 100644 index 0000000000..15cc828629 --- /dev/null +++ b/src/USER-OMP/npair_half_size_multi_newton_omp.h @@ -0,0 +1,43 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef NPAIR_CLASS + +NPairStyle(half/size/bin/newton/omp, + NPairHalfSizeMultiNewtonOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_OMP | NP_ORTHO) + +#else + +#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_OMP_H +#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairHalfSizeMultiNewtonOmp : public NPair { + public: + NPairHalfSizeMultiNewtonOmp(class LAMMPS *); + ~NPairHalfSizeMultiNewtonOmp() {} + void build(class NeighList *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp new file mode 100644 index 0000000000..29832fba8d --- /dev/null +++ b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp @@ -0,0 +1,136 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "omp_compat.h" +#include "npair_half_size_multi_newton_tri_omp.h" +#include "npair_omp.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairHalfSizeMultiNewtonTriOmp::NPairHalfSizeMultiNewtonTriOmp(LAMMPS *lmp) : + NPair(lmp) {} + +/* ---------------------------------------------------------------------- + size particles + binned neighbor list construction with Newton's 3rd law for triclinic + each owned atom i checks its own bin and other bins in triclinic stencil + multi-type stencil is itype dependent and is distance checked + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +void NPairHalfSizeMultiNewtonTriOmp::build(NeighList *list) +{ + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int history = list->history; + const int mask_history = 3 << SBBITS; + + NPAIR_OMP_INIT; +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) +#endif + NPAIR_OMP_SETUP(nlocal); + + int i,j,k,m,n,itype,jtype,ibin,ns; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radi,radsum,cutdistsq; + int *neighptr,*s; + double *cutsq,*distsq; + + // loop over each atom, storing neighbors + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + + // each thread has its own page allocator + MyPage &ipage = list->ipage[tid]; + ipage.reset(); + + for (i = ifrom; i < ito; i++) { + + n = 0; + neighptr = ipage.vget(); + + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + radi = radius[i]; + + // loop over all atoms in bins, including self, in stencil + // skip if i,j neighbor cutoff is less than bin distance + // bins below self are excluded from stencil + // pairs for atoms j "below" i are excluded + // below = lower z or (equal z and lower y) or (equal zy and lower x) + // (equal zyx and j <= i) + // latter excludes self-self interaction but allows superposed atoms + + ibin = atom2bin[i]; + s = stencil_multi[itype]; + distsq = distsq_multi[itype]; + cutsq = cutneighsq[itype]; + ns = nstencil_multi[itype]; + for (k = 0; k < ns; k++) { + for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { + jtype = type[j]; + if (cutsq[jtype] < distsq[k]) continue; + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp) { + if (x[j][0] < xtmp) continue; + if (x[j][0] == xtmp && j <= i) continue; + } + } + + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + ilist[i] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + ipage.vgot(n); + if (ipage.status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + NPAIR_OMP_CLOSE; + list->inum = nlocal; +} diff --git a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.h b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.h new file mode 100644 index 0000000000..6e936c8da4 --- /dev/null +++ b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.h @@ -0,0 +1,43 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef NPAIR_CLASS + +NPairStyle(half/size/multi/newton/tri/omp, + NPairHalfSizeMultiNewtonTriOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_TRI | NP_OMP) + +#else + +#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_OMP_H +#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairHalfSizeMultiNewtonTriOmp : public NPair { + public: + NPairHalfSizeMultiNewtonTriOmp(class LAMMPS *); + ~NPairHalfSizeMultiNewtonTriOmp() {} + void build(class NeighList *); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ From d519f4fd4f0807c969c11e6c90ef52fcd8542459 Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Wed, 14 Oct 2020 16:06:14 -0600 Subject: [PATCH 007/187] Missed reference to bin, minor uniform style changes --- src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp | 2 -- src/USER-OMP/npair_half_size_multi_newton_omp.cpp | 2 +- src/USER-OMP/npair_half_size_multi_newton_omp.h | 2 +- src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp index a72be3f982..33722eb9d3 100644 --- a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp @@ -54,8 +54,6 @@ void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) int *neighptr,*s; double *cutsq,*distsq; - // loop over each atom, storing neighbors - double **x = atom->x; double *radius = atom->radius; int *type = atom->type; diff --git a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp index 751805dce1..0be87457e3 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp @@ -47,7 +47,7 @@ void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,n,m,itype,jtype,ibin,ns; + int i,j,k,m,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/USER-OMP/npair_half_size_multi_newton_omp.h b/src/USER-OMP/npair_half_size_multi_newton_omp.h index 15cc828629..03d712145f 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_omp.h +++ b/src/USER-OMP/npair_half_size_multi_newton_omp.h @@ -13,7 +13,7 @@ #ifdef NPAIR_CLASS -NPairStyle(half/size/bin/newton/omp, +NPairStyle(half/size/multi/newton/omp, NPairHalfSizeMultiNewtonOmp, NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_OMP | NP_ORTHO) diff --git a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp index 29832fba8d..ef26a5f2bd 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp @@ -53,8 +53,6 @@ void NPairHalfSizeMultiNewtonTriOmp::build(NeighList *list) int *neighptr,*s; double *cutsq,*distsq; - // loop over each atom, storing neighbors - double **x = atom->x; double *radius = atom->radius; int *type = atom->type; From 280e98b0743a6d15a5a79a5e0f25d09e1f15528d Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Tue, 3 Nov 2020 20:26:34 -0700 Subject: [PATCH 008/187] Added explicit energy updates --- src/MLIAP/mliap_data.cpp | 6 +++++- src/MLIAP/mliap_data.h | 4 +++- src/MLIAP/mliap_model_linear.cpp | 6 ++++-- src/MLIAP/mliap_model_quadratic.cpp | 6 ++++-- src/MLIAP/pair_mliap.cpp | 14 ++++++++++---- src/MLIAP/pair_mliap.h | 2 +- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index e6502d001a..3ada98e8c0 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -25,7 +25,8 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, class MLIAPModel* model_in, class MLIAPDescriptor* descriptor_in, class PairMLIAP* pairmliap_in) : - Pointers(lmp), gradforce(nullptr), betas(nullptr), descriptors(nullptr), gamma(nullptr), + Pointers(lmp), gradforce(nullptr), betas(nullptr), + descriptors(nullptr), eatoms(nullptr), gamma(nullptr), gamma_row_index(nullptr), gamma_col_index(nullptr), egradient(nullptr), numneighs(nullptr), iatoms(nullptr), ielems(nullptr), jatoms(nullptr), jelems(nullptr), rij(nullptr), graddesc(nullptr), model(nullptr), descriptor(nullptr), list(nullptr) @@ -64,6 +65,7 @@ MLIAPData::~MLIAPData() { memory->destroy(betas); memory->destroy(descriptors); + memory->destroy(eatoms); memory->destroy(gamma_row_index); memory->destroy(gamma_col_index); memory->destroy(gamma); @@ -133,6 +135,7 @@ void MLIAPData::generate_neighdata(NeighList* list_in, int eflag_in, int vflag_i if (natoms_max < natoms) { memory->grow(betas,natoms,ndescriptors,"MLIAPData:betas"); memory->grow(descriptors,natoms,ndescriptors,"MLIAPData:descriptors"); + memory->grow(eatoms,natoms,"MLIAPData:eatoms"); natoms_max = natoms; } @@ -267,6 +270,7 @@ double MLIAPData::memory_usage() bytes += natoms*ndescriptors*sizeof(int); // betas bytes += natoms*ndescriptors*sizeof(int); // descriptors + bytes += natoms*sizeof(double); // eatoms bytes += natomneigh_max*sizeof(int); // iatoms bytes += natomneigh_max*sizeof(int); // ielems diff --git a/src/MLIAP/mliap_data.h b/src/MLIAP/mliap_data.h index ffac9ccd4c..7fb60bd723 100644 --- a/src/MLIAP/mliap_data.h +++ b/src/MLIAP/mliap_data.h @@ -34,8 +34,10 @@ class MLIAPData : protected Pointers { int yoffset, zoffset; int ndims_force, ndims_virial; double **gradforce; - double** betas; // betas for all atoms in list + double** betas; // betas for all atoms in list double** descriptors; // descriptors for all atoms in list + double* eatoms; // energies for all atoms in list + double energy; // energy int ndescriptors; // number of descriptors int nparams; // number of model parameters per element int nelements; // number of elements diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp index b3224284e5..d3c8373708 100644 --- a/src/MLIAP/mliap_model_linear.cpp +++ b/src/MLIAP/mliap_model_linear.cpp @@ -51,8 +51,9 @@ int MLIAPModelLinear::get_nparams() void MLIAPModelLinear::compute_gradients(MLIAPData* data) { + data->energy = 0.0; + for (int ii = 0; ii < data->natoms; ii++) { - const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; double* coeffi = coeffelem[ielem]; @@ -74,7 +75,8 @@ void MLIAPModelLinear::compute_gradients(MLIAPData* data) for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) etmp += coeffi[icoeff+1]*data->descriptors[ii][icoeff]; - data->pairmliap->e_tally(i,etmp); + data->energy += etmp; + data->eatoms[ii] = etmp; } } } diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp index 481417078a..36642c1a87 100644 --- a/src/MLIAP/mliap_model_quadratic.cpp +++ b/src/MLIAP/mliap_model_quadratic.cpp @@ -52,8 +52,9 @@ int MLIAPModelQuadratic::get_nparams() void MLIAPModelQuadratic::compute_gradients(MLIAPData* data) { + data->energy = 0.0; + for (int ii = 0; ii < data->natoms; ii++) { - const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; double* coeffi = coeffelem[ielem]; @@ -99,7 +100,8 @@ void MLIAPModelQuadratic::compute_gradients(MLIAPData* data) etmp += coeffi[k++]*bveci*bvecj; } } - data->pairmliap->e_tally(i,etmp); + data->energy += etmp; + data->eatoms[ii] = etmp; } } } diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index f5895d6e5d..ef3ff40da5 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -78,6 +78,8 @@ void PairMLIAP::compute(int eflag, int vflag) model->compute_gradients(data); + e_tally(data); + // calculate force contributions beta_i*dB_i/dR_j descriptor->compute_forces(data); @@ -220,13 +222,17 @@ void PairMLIAP::coeff(int narg, char **arg) } /* ---------------------------------------------------------------------- - add energy of atom i to global and per-atom energy + add energies to eng_vdwl and per-atom energy ------------------------------------------------------------------------- */ -void PairMLIAP::e_tally(int i, double ei) +void PairMLIAP::e_tally(MLIAPData* data) { - if (eflag_global) eng_vdwl += ei; - if (eflag_atom) eatom[i] += ei; + if (eflag_global) eng_vdwl += data->energy; + if (eflag_atom) + for (int ii = 0; ii < data->natoms; ii++) { + const int i = data->iatoms[ii]; + eatom[i] += data->eatoms[ii]; + } } /* ---------------------------------------------------------------------- diff --git a/src/MLIAP/pair_mliap.h b/src/MLIAP/pair_mliap.h index 61acbbb278..c31634e923 100644 --- a/src/MLIAP/pair_mliap.h +++ b/src/MLIAP/pair_mliap.h @@ -31,7 +31,7 @@ public: virtual void compute(int, int); void settings(int, char **); virtual void coeff(int, char **); - void e_tally(int, double); + void e_tally(class MLIAPData*); void v_tally(int, int, double*, double*); virtual void init_style(); virtual double init_one(int, int); From 7c1634e57f0927f7ac09653dea8fb73ed07a40df Mon Sep 17 00:00:00 2001 From: Nicholas Lubbers Date: Fri, 6 Nov 2020 13:12:25 -0700 Subject: [PATCH 009/187] Squashed commit for MLIAPPY package Includes CMAKE install, doc updates, example files. --- .gitignore | 1 + cmake/CMakeLists.txt | 6 +- cmake/Modules/Packages/MLIAPPY.cmake | 12 ++ doc/src/Packages_details.rst | 32 +++++ doc/src/Packages_standard.rst | 2 + doc/src/compute_mliap.rst | 7 +- doc/src/pair_mliap.rst | 12 +- examples/mliappy/README.txt | 11 ++ examples/mliappy/Ta06A.mliap.descriptor | 21 +++ examples/mliappy/Ta06A.mliap.pytorch | 18 +++ examples/mliappy/convert_mliap_Ta06A.py | 33 +++++ examples/mliappy/in.mliap.pytorch.Ta06A | 67 +++++++++ src/MLIAP/compute_mliap.cpp | 13 +- src/MLIAP/mliap_model.cpp | 31 ++-- src/MLIAP/mliap_model.h | 17 ++- src/MLIAP/mliap_model_linear.cpp | 2 +- src/MLIAP/mliap_model_linear.h | 2 +- src/MLIAP/mliap_model_quadratic.cpp | 3 +- src/MLIAP/mliap_model_quadratic.h | 2 +- src/MLIAP/pair_mliap.cpp | 23 ++- src/MLIAPPY/mliap_model_python.cpp | 163 ++++++++++++++++++++++ src/MLIAPPY/mliap_model_python.h | 42 ++++++ src/MLIAPPY/mliap_model_python_couple.pyx | 85 +++++++++++ src/MLIAPPY/mliappy_pytorch.py | 46 ++++++ src/Makefile | 2 +- src/PYTHON/python_impl.cpp | 14 +- 26 files changed, 635 insertions(+), 32 deletions(-) create mode 100644 cmake/Modules/Packages/MLIAPPY.cmake create mode 100644 examples/mliappy/README.txt create mode 100644 examples/mliappy/Ta06A.mliap.descriptor create mode 100644 examples/mliappy/Ta06A.mliap.pytorch create mode 100644 examples/mliappy/convert_mliap_Ta06A.py create mode 100644 examples/mliappy/in.mliap.pytorch.Ta06A create mode 100644 src/MLIAPPY/mliap_model_python.cpp create mode 100644 src/MLIAPPY/mliap_model_python.h create mode 100644 src/MLIAPPY/mliap_model_python_couple.pyx create mode 100644 src/MLIAPPY/mliappy_pytorch.py diff --git a/.gitignore b/.gitignore index 0f1b01775d..92fae19766 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ Thumbs.db /Makefile /cmake_install.cmake /lmp + diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 42e6d12ffb..fab10bfdef 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -105,7 +105,7 @@ install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR}) option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE - GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE PERI POEMS + GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MLIAPPY MOLECULE PERI POEMS QEQ REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB @@ -194,6 +194,8 @@ endif() # "hard" dependencies between packages resulting # in an error instead of skipping over files pkg_depends(MLIAP SNAP) +pkg_depends(MLIAPPY MLIAP) +pkg_depends(MLIAPPY PYTHON) pkg_depends(MPIIO MPI) pkg_depends(USER-ATC MANYBODY) pkg_depends(USER-LB MPI) @@ -372,7 +374,7 @@ else() set(CUDA_REQUEST_PIC) endif() -foreach(PKG_WITH_INCL KSPACE PYTHON VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM +foreach(PKG_WITH_INCL KSPACE PYTHON MLIAPPY VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS) if(PKG_${PKG_WITH_INCL}) include(Packages/${PKG_WITH_INCL}) diff --git a/cmake/Modules/Packages/MLIAPPY.cmake b/cmake/Modules/Packages/MLIAPPY.cmake new file mode 100644 index 0000000000..842c43bd96 --- /dev/null +++ b/cmake/Modules/Packages/MLIAPPY.cmake @@ -0,0 +1,12 @@ +if(CMAKE_VERSION VERSION_LESS 3.12) + #This block was not tested, mimmicks PYTHON.cmake. + find_package(PythonLibs REQUIRED) # Deprecated since version 3.12 + target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIR}) + target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARY}) + target_include_directories(lammps PRIVATE ${Python_NumPy_INCLUDE_DIRS}) +else() + find_package(Python REQUIRED COMPONENTS NumPy) + target_include_directories(lammps PRIVATE ${Python_NumPy_INCLUDE_DIRS}) +endif() +target_compile_definitions(lammps PRIVATE -DLMP_MLIAPPY) + diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index 74214e2e0e..edce17b9ab 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -45,6 +45,7 @@ page gives those details. * :ref:`MESSAGE ` * :ref:`MISC ` * :ref:`MLIAP ` + * :ref:`MLIAPPY ` * :ref:`MOLECULE ` * :ref:`MPIIO ` * :ref:`MSCG ` @@ -678,6 +679,37 @@ To use this package, also the :ref:`SNAP package ` needs to be install ---------- +.. _PKG-MLIAPPY: + +MLIAPPY package +------------- + +**Contents:** + +Extension to the MLIAP package for coupling with python models. + +**Install:** + +To use this package, also the :ref:`MLIAP package ` needs to be installed. +To use this package, also the :ref:`PYTHON package ` needs to be installed. +The version of python must be >3.5, and has been tested only with 3.8. +Compiling this package has only been tested using CMake, not with pure makefiles.s +The python interpreter linked to LAMMPS will need cython and numpy installed. + +Before compiling, run cythonize on /src/MLIAPPY/mliap_model_python_couple.pyx. +This will produce /src/MLIAPPY/mliap_model_python_couple.cpp and /src/MLIAPPY/mliap_model_python_couple.h files. + +This package includes more options for the mliap compute and pair style. + +**Author:** Nicholas Lubbers (LANL). + +**Supporting info:** + +* src/MLIAPPY: filenames -> commands +* :doc:`pair_style mliap ` +* examples/mliappy (see README) +---------- + .. _PKG-MOLECULE: MOLECULE package diff --git a/doc/src/Packages_standard.rst b/doc/src/Packages_standard.rst index ab9be69ab3..800fd3c501 100644 --- a/doc/src/Packages_standard.rst +++ b/doc/src/Packages_standard.rst @@ -61,6 +61,8 @@ package: +----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ | :ref:`MLIAP ` | multiple machine learning potentials | :doc:`pair_style mliap ` | mliap | no | +----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ +| :ref:`MLIAPPY ` | enable python ML models for mliap | :doc:`pair_style mliap ` | mliap | no | ++----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ | :ref:`MOLECULE ` | molecular system force fields | :doc:`Howto bioFF ` | peptide | no | +----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ | :ref:`MPIIO ` | MPI parallel I/O dump and restart | :doc:`dump ` | n/a | no | diff --git a/doc/src/compute_mliap.rst b/doc/src/compute_mliap.rst index fcc336e682..e4e6603cdc 100644 --- a/doc/src/compute_mliap.rst +++ b/doc/src/compute_mliap.rst @@ -18,7 +18,7 @@ Syntax .. parsed-literal:: *model* values = style - style = *linear* or *quadratic* + style = *linear* or *quadratic* or *mliappy* *descriptor* values = style filename style = *sna* filename = name of file containing descriptor definitions @@ -57,7 +57,8 @@ The compute *mliap* command must be followed by two keywords *model* and *descriptor* in either order. The *model* keyword is followed by a model style, currently limited to -either *linear* or *quadratic*. +either *linear* or *quadratic*. The *mliappy* model is only available +if lammps is built with MLIAPPY package. The *descriptor* keyword is followed by a descriptor style, and additional arguments. Currently the only descriptor style is *sna*, indicating the bispectrum component @@ -167,6 +168,8 @@ LAMMPS was built with that package. In addition, building LAMMPS with the MLIAP requires building LAMMPS with the SNAP package. See the :doc:`Build package ` doc page for more info. +Python models such as neural networks can be used if the MLIAPPY package is built. + Related commands """""""""""""""" diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index 09295cd8be..aeba2d9fd2 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -16,7 +16,7 @@ Syntax .. parsed-literal:: *model* values = style filename - style = *linear* or *quadratic* + style = *linear* or *quadratic* or *mliappy* filename = name of file containing model definitions *descriptor* values = style filename style = *sna* @@ -43,9 +43,10 @@ it is possible to use many different models with a given descriptor, or many different descriptors with a given model. Currently, the pair_style supports just two models, *linear* and *quadratic*, and one descriptor, *sna*, the SNAP descriptor used by :doc:`pair_style snap `, including the linear, quadratic, -and chem variants. Work is currently underway to extend -the interface to handle neural network energy models, -and it is also straightforward to add new descriptor styles. +and chem variants. With the MLIAPPY package installed, the *mliappy* model +is available which can be used to couple python models such as neural network +energy models. +It is also straightforward to add new descriptor styles. In order to train a model, it is useful to know the gradient or derivative of energy, force, and stress w.r.t. model parameters. This information can be accessed using the related :doc:`compute mliap ` command. @@ -143,6 +144,9 @@ was built with that package. In addition, building LAMMPS with the MLIAP package requires building LAMMPS with the SNAP package. See the :doc:`Build package ` doc page for more info. +Python models such as neural networks can be used if the MLIAPPY package is built. + + Related commands """""""""""""""" diff --git a/examples/mliappy/README.txt b/examples/mliappy/README.txt new file mode 100644 index 0000000000..f624acd657 --- /dev/null +++ b/examples/mliappy/README.txt @@ -0,0 +1,11 @@ +README for MLIAPPY Example + +This example runs the Ta06 example from the MLIAP example, but using the python coupling. + +To run this, first run convert_mliap_Ta06A.py, which will convert the Ta06 potential into a pytorch model. +It will be saved as "Ta06A.mliap.pytorch.model.pkl". + +It will also copy the "torchlink.py" file into the current working directory. torchlink.py contains +class definitions suitable for wrapping an arbitrary energy model MLIAPPY. + +From that point you can run the example lmp -in in.mliap.snap.Ta06A -echo both \ No newline at end of file diff --git a/examples/mliappy/Ta06A.mliap.descriptor b/examples/mliappy/Ta06A.mliap.descriptor new file mode 100644 index 0000000000..481ebf7e44 --- /dev/null +++ b/examples/mliappy/Ta06A.mliap.descriptor @@ -0,0 +1,21 @@ +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# LAMMPS SNAP parameters for Ta_Cand06A + +# required +rcutfac 4.67637 +twojmax 6 + +# elements + +nelems 1 +elems Ta +radelems 0.5 +welems 1 + +# optional + +rfac0 0.99363 +rmin0 0 +bzeroflag 0 + diff --git a/examples/mliappy/Ta06A.mliap.pytorch b/examples/mliappy/Ta06A.mliap.pytorch new file mode 100644 index 0000000000..c6c6bc653d --- /dev/null +++ b/examples/mliappy/Ta06A.mliap.pytorch @@ -0,0 +1,18 @@ +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay & +zbl ${zblcutinner} ${zblcutouter} & +mliap model mliappy Ta06A.mliap.pytorch.model.pkl & +descriptor sna Ta06A.mliap.descriptor +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff * * mliap Ta + diff --git a/examples/mliappy/convert_mliap_Ta06A.py b/examples/mliappy/convert_mliap_Ta06A.py new file mode 100644 index 0000000000..bdc3887282 --- /dev/null +++ b/examples/mliappy/convert_mliap_Ta06A.py @@ -0,0 +1,33 @@ +import sys +import numpy as np +import torch +import pickle +import os +import shutil + +shutil.copyfile('../../src/MLIAPPY/mliappy_pytorch.py','./mliappy_pytorch.py') + +import mliappy_pytorch + +# Read coefficients +coeffs = np.genfromtxt("../mliap/Ta06A.mliap.model",skip_header=6) + +# Write coefficiets to a pytorch linear model +bias = coeffs[0] +weights = coeffs[1:] +lin = torch.nn.Linear(weights.shape[0],1) +lin.to(torch.float64) +with torch.autograd.no_grad(): + lin.weight.set_(torch.from_numpy(weights).unsqueeze(0)) + lin.bias.set_(torch.as_tensor(bias,dtype=torch.float64).unsqueeze(0)) + +# Wrap the pytorch model for usage with MLIAPPY +model = mliappy_pytorch.IgnoreTypes(lin) +n_descriptors = lin.weight.shape[1] +n_params = mliappy_pytorch.calc_n_params(model) +n_types = 1 +linked_model = mliappy_pytorch.TorchWrapper64(model,n_descriptors=n_descriptors,n_elements=n_types) + +# Save the result. +with open("Ta06A.mliap.pytorch.model.pkl",'wb') as pfile: + pickle.dump(linked_model,pfile) \ No newline at end of file diff --git a/examples/mliappy/in.mliap.pytorch.Ta06A b/examples/mliappy/in.mliap.pytorch.Ta06A new file mode 100644 index 0000000000..526c24ab23 --- /dev/null +++ b/examples/mliappy/in.mliap.pytorch.Ta06A @@ -0,0 +1,67 @@ +# Demonstrate MLIAP interface to kinear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable ny equal ${nrep} +variable nz equal ${nrep} + +boundary p p p + +lattice bcc $a +region box block 0 ${nx} 0 ${ny} 0 ${nz} +create_box 1 box +create_atoms 1 box + +mass 1 180.88 + +python simple here """ +from __future__ import print_function + +def simple(): + foo = 0 + print("Inside simple function") + try: + foo += 1 + except Exception as e: + print("FOO error:", e) +""" + +python simple invoke + +# choose potential + +include Ta06A.mliap.pytorch + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} + diff --git a/src/MLIAP/compute_mliap.cpp b/src/MLIAP/compute_mliap.cpp index 34d086462f..64753fe64f 100644 --- a/src/MLIAP/compute_mliap.cpp +++ b/src/MLIAP/compute_mliap.cpp @@ -17,6 +17,10 @@ #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" #include "mliap_descriptor_snap.h" +#ifdef LMP_MLIAPPY +#include "mliap_model_python.h" +#endif + #include "compute_mliap.h" #include "atom.h" #include "update.h" @@ -65,7 +69,14 @@ ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg+1],"quadratic") == 0) { model = new MLIAPModelQuadratic(lmp); iarg += 2; - } else error->all(FLERR,"Illegal compute mliap command"); + } + #ifdef LMP_MLIAPPY + else if (strcmp(arg[iarg+1],"mliappy") == 0) { + model = new MLIAPModelPython(lmp); + iarg += 2; + } + #endif + else error->all(FLERR,"Illegal compute mliap command"); modelflag = 1; } else if (strcmp(arg[iarg],"descriptor") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute mliap command"); diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index 04b2ac663a..a4f5cdc86c 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -28,13 +28,9 @@ using namespace LAMMPS_NS; MLIAPModel::MLIAPModel(LAMMPS* lmp, char* coefffilename) : Pointers(lmp) { - coeffelem = nullptr; - if (coefffilename) read_coeffs(coefffilename); - else { - nparams = 0; - nelements = 0; - ndescriptors = 0; - } + nparams = 0; + nelements = 0; + ndescriptors = 0; nonlinearflag = 0; } @@ -42,9 +38,9 @@ MLIAPModel::MLIAPModel(LAMMPS* lmp, char* coefffilename) : Pointers(lmp) MLIAPModel::~MLIAPModel() { - memory->destroy(coeffelem); } + /* ---------------------------------------------------------------------- placeholder ------------------------------------------------------------------------- */ @@ -73,7 +69,22 @@ void MLIAPModel::set_ndescriptors(int ndescriptors_in) /* ---------------------------------------------------------------------- */ -void MLIAPModel::read_coeffs(char *coefffilename) + +MLIAPModelSimple::MLIAPModelSimple(LAMMPS* lmp, char* coefffilename) : MLIAPModel(lmp, coefffilename) +{ + coeffelem = nullptr; + if (coefffilename) read_coeffs(coefffilename); +} + +/* ---------------------------------------------------------------------- */ + +MLIAPModelSimple::~MLIAPModelSimple() +{ + memory->destroy(coeffelem); +} + + +void MLIAPModelSimple::read_coeffs(char *coefffilename) { // open coefficient file on proc 0 @@ -165,7 +176,7 @@ void MLIAPModel::read_coeffs(char *coefffilename) memory usage ------------------------------------------------------------------------- */ -double MLIAPModel::memory_usage() +double MLIAPModelSimple::memory_usage() { double bytes = 0; diff --git a/src/MLIAP/mliap_model.h b/src/MLIAP/mliap_model.h index b2f7312897..96cfff0a3d 100644 --- a/src/MLIAP/mliap_model.h +++ b/src/MLIAP/mliap_model.h @@ -30,15 +30,26 @@ public: virtual void compute_gradgrads(class MLIAPData*)=0; virtual void compute_force_gradients(class MLIAPData*)=0; virtual void init(); - virtual double memory_usage(); + virtual double memory_usage()=0; int nelements; // # of unique elements - int nonlinearflag; // 1 if gradient() requires escriptors + int nonlinearflag; // 1 if gradient() requires descriptors int ndescriptors; // number of descriptors int nparams; // number of parameters per element protected: - void read_coeffs(char *); + virtual void read_coeffs(char *)=0; +}; + +class MLIAPModelSimple : public MLIAPModel { +public: + MLIAPModelSimple(LAMMPS*, char*); + ~MLIAPModelSimple(); + virtual double memory_usage(); + +protected: double **coeffelem; // element coefficients + virtual void read_coeffs(char *); + }; } diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp index d3c8373708..428d163166 100644 --- a/src/MLIAP/mliap_model_linear.cpp +++ b/src/MLIAP/mliap_model_linear.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ MLIAPModelLinear::MLIAPModelLinear(LAMMPS* lmp, char* coefffilename) : - MLIAPModel(lmp, coefffilename) + MLIAPModelSimple(lmp, coefffilename) { if (nparams > 0) ndescriptors = nparams - 1; } diff --git a/src/MLIAP/mliap_model_linear.h b/src/MLIAP/mliap_model_linear.h index 326407faa8..89c69d3537 100644 --- a/src/MLIAP/mliap_model_linear.h +++ b/src/MLIAP/mliap_model_linear.h @@ -18,7 +18,7 @@ namespace LAMMPS_NS { -class MLIAPModelLinear : public MLIAPModel { +class MLIAPModelLinear : public MLIAPModelSimple { public: MLIAPModelLinear(LAMMPS*, char* = nullptr); ~MLIAPModelLinear(); diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp index 36642c1a87..222f6ad0ae 100644 --- a/src/MLIAP/mliap_model_quadratic.cpp +++ b/src/MLIAP/mliap_model_quadratic.cpp @@ -22,8 +22,9 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ MLIAPModelQuadratic::MLIAPModelQuadratic(LAMMPS* lmp, char* coefffilename) : - MLIAPModel(lmp, coefffilename) + MLIAPModelSimple(lmp, coefffilename) { + if (coefffilename) read_coeffs(coefffilename); if (nparams > 0) ndescriptors = sqrt(2*nparams)-1; nonlinearflag = 1; } diff --git a/src/MLIAP/mliap_model_quadratic.h b/src/MLIAP/mliap_model_quadratic.h index b41df18a07..28f1732f9b 100644 --- a/src/MLIAP/mliap_model_quadratic.h +++ b/src/MLIAP/mliap_model_quadratic.h @@ -18,7 +18,7 @@ namespace LAMMPS_NS { -class MLIAPModelQuadratic : public MLIAPModel { +class MLIAPModelQuadratic : public MLIAPModelSimple { public: MLIAPModelQuadratic(LAMMPS*, char* = nullptr); ~MLIAPModelQuadratic(); diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index ef3ff40da5..9fd7b483af 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -17,6 +17,9 @@ #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" #include "mliap_descriptor_snap.h" +#ifdef LMP_MLIAPPY +#include "mliap_model_python.h" +#endif #include "atom.h" #include "error.h" @@ -27,6 +30,7 @@ #include #include +#include "error.h" using namespace LAMMPS_NS; @@ -109,6 +113,7 @@ void PairMLIAP::allocate() void PairMLIAP::settings(int narg, char ** arg) { + if (narg < 4) error->all(FLERR,"Illegal pair_style command"); @@ -132,6 +137,13 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelQuadratic(lmp,arg[iarg+2]); iarg += 3; + } + #ifdef LMP_MLIAPPY + else if (strcmp(arg[iarg+1],"mliappy") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); + model = new MLIAPModelPython(lmp,arg[iarg+2]); + iarg += 3; + #endif } else error->all(FLERR,"Illegal pair_style mliap command"); modelflag = 1; } else if (strcmp(arg[iarg],"descriptor") == 0) { @@ -215,10 +227,13 @@ void PairMLIAP::coeff(int narg, char **arg) // consistency checks - if (data->ndescriptors != model->ndescriptors) - error->all(FLERR,"Incompatible model and descriptor definitions"); - if (data->nelements != model->nelements) - error->all(FLERR,"Incompatible model and descriptor definitions"); + if (data->ndescriptors != model->ndescriptors) { + error->all(FLERR,"Incompatible model and descriptor definitions (different number of descriptors)"); + }; + + if (data->nelements != model->nelements) { + error->all(FLERR,"Incompatible model and descriptor definitions (different number of elements)"); + }; } /* ---------------------------------------------------------------------- diff --git a/src/MLIAPPY/mliap_model_python.cpp b/src/MLIAPPY/mliap_model_python.cpp new file mode 100644 index 0000000000..13e5a85e83 --- /dev/null +++ b/src/MLIAPPY/mliap_model_python.cpp @@ -0,0 +1,163 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include +#include "mliap_model_python.h" +#include "mliap_model_python_couple.h" +#include "pair_mliap.h" +#include "mliap_data.h" +#include "error.h" +#include "utils.h" +#include "lmppython.h" +#include "python_compat.h" + + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +MLIAPModelPython::MLIAPModelPython(LAMMPS* lmp, char* coefffilename) : + MLIAPModel(lmp, coefffilename) +{ + int err; + + python->init(); + + PyGILState_STATE gstate = PyGILState_Ensure(); + + PyObject * pyMain = PyImport_AddModule("__main__"); + + PyImport_ImportModule("mliap_model_python_couple"); + if (!pyMain) { + PyGILState_Release(gstate); + error->all(FLERR,"Could not initialize embedded Python"); + } + + PyObject* coupling_module = PyImport_ImportModule("mliap_model_python_couple"); + if (!coupling_module) { + PyErr_Print(); + PyErr_Clear(); + PyGILState_Release(gstate); + error->all(FLERR,"Loading MLIAPPY coupling module failure."); + } + + // Recipe from lammps/src/pair_python.cpp : + // add current directory to PYTHONPATH + PyObject * py_path = PySys_GetObject((char *)"path"); + PyList_Append(py_path, PY_STRING_FROM_STRING(".")); + + // if LAMMPS_POTENTIALS environment variable is set, add it to PYTHONPATH as well + const char * potentials_path = getenv("LAMMPS_POTENTIALS"); + if (potentials_path != NULL) { + PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path)); + } + + PyGILState_Release(gstate); + + if (coefffilename) read_coeffs(coefffilename); + + nonlinearflag=1; +} + +/* ---------------------------------------------------------------------- */ + +MLIAPModelPython::~MLIAPModelPython(){ + MLIAPPY_unload_model(this); +} + +/* ---------------------------------------------------------------------- + get number of parameters + ---------------------------------------------------------------------- */ + + +int MLIAPModelPython::get_nparams() +{ + if (nparams == 0) { + if (ndescriptors == 0) error->all(FLERR,"ndescriptors not defined"); + else nparams = ndescriptors + 1; + } + return nparams; +} + + +void MLIAPModelPython::read_coeffs(char * fname) +{ + PyGILState_STATE gstate = PyGILState_Ensure(); + int err = MLIAPPY_load_model(this, fname); + if (err) { + PyErr_Print(); + PyErr_Clear(); + PyGILState_Release(gstate); + error->all(FLERR,"Loading python model failure."); + } + nelements = MLIAPPY_nelements(this); + nparams = MLIAPPY_nparams(this); + ndescriptors = MLIAPPY_ndescriptors(this); +} + +/* ---------------------------------------------------------------------- + Calculate model gradients w.r.t descriptors + for each atom beta_i = dE(B_i)/dB_i + ---------------------------------------------------------------------- */ + +void MLIAPModelPython::compute_gradients(MLIAPData* data) +{ + MLIAPPY_model_callback(this, data); +} + +/* ---------------------------------------------------------------------- + Calculate model double gradients w.r.t descriptors and parameters + for each atom energy gamma_lk = d2E(B)/dB_k/dsigma_l, + where sigma_l is a parameter, B_k a descriptor, + and atom subscript i is omitted + + gamma is in CSR format: + nnz = number of non-zero values + gamma_row_index[inz] = l indices, 0 <= l < nparams + gamma_col_indexiinz] = k indices, 0 <= k < ndescriptors + gamma[i][inz] = non-zero values, 0 <= inz < nnz + + egradient is derivative of energy w.r.t. parameters + ---------------------------------------------------------------------- */ + +void MLIAPModelPython::compute_gradgrads(class MLIAPData* data) +{ + error->all(FLERR,"compute_gradgrads not implemented"); +} + +/* ---------------------------------------------------------------------- + calculate gradients of forces w.r.t. parameters + egradient is derivative of energy w.r.t. parameters + ---------------------------------------------------------------------- */ + +void MLIAPModelPython::compute_force_gradients(class MLIAPData* data) +{ + error->all(FLERR,"compute_force_gradients not implemented"); +} + +/* ---------------------------------------------------------------------- + count the number of non-zero entries in gamma matrix + ---------------------------------------------------------------------- */ + +int MLIAPModelPython::get_gamma_nnz(class MLIAPData* data) +{ + // todo: get_gamma_nnz + return 0; +} + + +double MLIAPModelPython::memory_usage() +{ + // todo: get approximate memory usage in coupling code. + return 0; +} diff --git a/src/MLIAPPY/mliap_model_python.h b/src/MLIAPPY/mliap_model_python.h new file mode 100644 index 0000000000..3b162509f7 --- /dev/null +++ b/src/MLIAPPY/mliap_model_python.h @@ -0,0 +1,42 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_MLIAP_MODEL_PYTHON_H +#define LMP_MLIAP_MODEL_PYTHON_H + +#include "mliap_model.h" + +namespace LAMMPS_NS { + + +class MLIAPModelPython : public MLIAPModel { +public: + MLIAPModelPython(LAMMPS*, char* = NULL); + ~MLIAPModelPython(); + virtual int get_nparams(); + virtual int get_gamma_nnz(class MLIAPData*); + virtual void compute_gradients(class MLIAPData*); + virtual void compute_gradgrads(class MLIAPData*); + virtual void compute_force_gradients(class MLIAPData*); + virtual double memory_usage(); +protected: + virtual void read_coeffs(char *); + +private: + +}; + +} + +#endif + diff --git a/src/MLIAPPY/mliap_model_python_couple.pyx b/src/MLIAPPY/mliap_model_python_couple.pyx new file mode 100644 index 0000000000..3e03247fa7 --- /dev/null +++ b/src/MLIAPPY/mliap_model_python_couple.pyx @@ -0,0 +1,85 @@ +# cython: language_level=3 +# distutils: language = c++ + +cimport cython + +import pickle + +# For converting C arrays to numpy arrays +import numpy as np +cimport numpy as cnp + +# For converting void * to integer for tracking object identity +from libc.stdint cimport uintptr_t + +from libcpp.string cimport string + + +cdef extern from "mliap_data.h" namespace "LAMMPS_NS": + cdef cppclass MLIAPData: + # Array shapes + int natoms + int ndescriptors + + # Input data + int * ielems # types for all atoms in list + double ** descriptors # descriptors for all atoms in list + + # Output data to write to + double ** betas # betas for all atoms in list + double * eatoms # energy for all atoms in list + double energy + +cdef extern from "mliap_model_python.h" namespace "LAMMPS_NS": + cdef cppclass MLIAPModelPython: + ctypedef void (*CBPtr)(void * , MLIAPData); + void set_model(CBPtr, void *); + + +LOADED_MODELS = {} +cdef public int MLIAPPY_load_model(MLIAPModelPython * c_model, char* fname) except 1 with gil: + str_fname = fname.decode('utf-8') # Python 3 only; not Python 2 not supported. + + with open(str_fname,'rb') as pfile: + model = pickle.load(pfile) + + LOADED_MODELS[int( c_model)] = model + return 0 + +cdef public void MLIAPPY_unload_model(MLIAPModelPython * c_model) with gil: + del LOADED_MODELS[int( c_model)] + +cdef public int MLIAPPY_nparams(MLIAPModelPython * c_model) with gil: + model = LOADED_MODELS[int( c_model)] + n_params = int(model.n_params) + return n_params + +cdef public int MLIAPPY_nelements(MLIAPModelPython * c_model) with gil: + model = LOADED_MODELS[int( c_model)] + n_elements = int(model.n_elements) + return n_elements + +cdef public int MLIAPPY_ndescriptors(MLIAPModelPython * c_model) with gil: + model = LOADED_MODELS[int( c_model)] + n_descriptors = int(model.n_descriptors) + return n_descriptors + +cdef public MLIAPPY_model_callback(MLIAPModelPython * c_model, MLIAPData * data) with gil: + model = LOADED_MODELS[int( c_model)] + + n_d = data.ndescriptors + n_a = data.natoms + + # Make numpy arrays from pointers + beta_np = np.asarray( &data.betas[0][0]) + desc_np = np.asarray( &data.descriptors[0][0]) + type_np = np.asarray( &data.ielems[0]) + en_np = np.asarray( &data.eatoms[0]) + + # Invoke python model on numpy arrays. + model(type_np,desc_np,beta_np,en_np) + + # Get the total energy from the atom energy. + energy = np.sum(en_np) + data.energy = energy + return diff --git a/src/MLIAPPY/mliappy_pytorch.py b/src/MLIAPPY/mliappy_pytorch.py new file mode 100644 index 0000000000..b9f7ac3dcc --- /dev/null +++ b/src/MLIAPPY/mliappy_pytorch.py @@ -0,0 +1,46 @@ +import numpy as np +import torch + +def calc_n_params(model): + return sum(p.nelement() for p in model.parameters()) + +class TorchWrapper(torch.nn.Module): + def __init__(self, model,n_descriptors,n_elements,n_params=None): + super().__init__() + self.model = model + self.model.to(self.dtype) + if n_params is None: + n_params = calc_n_params(model) + self.n_params = n_params + self.n_descriptors = n_descriptors + self.n_elements = n_elements + + def __call__(self, types, bispectrum, beta, energy): + + bispectrum = torch.from_numpy(bispectrum).to(self.dtype).requires_grad_(True) + types = torch.from_numpy(types).to(torch.long) - 1 + + with torch.autograd.enable_grad(): + + energy_nn = self.model(bispectrum, types) + if energy_nn.ndim > 1: + energy_nn = energy_nn.flatten() + + beta_nn = torch.autograd.grad(energy_nn.sum(), bispectrum)[0] + + beta[:] = beta_nn.detach().cpu().numpy().astype(np.float64) + energy[:] = energy_nn.detach().cpu().numpy().astype(np.float64) + +class TorchWrapper32(TorchWrapper): + dtype = torch.float32 + +class TorchWrapper64(TorchWrapper): + dtype = torch.float64 + +class IgnoreTypes(torch.nn.Module): + def __init__(self,subnet): + super().__init__() + self.subnet = subnet + + def forward(self,bispectrum,types): + return self.subnet(bispectrum) diff --git a/src/Makefile b/src/Makefile index 149dedd35b..8667f3f725 100644 --- a/src/Makefile +++ b/src/Makefile @@ -48,7 +48,7 @@ endif PACKAGE = asphere body class2 colloid compress coreshell dipole gpu \ granular kim kokkos kspace latte manybody mc message misc \ - mliap molecule mpiio mscg opt peri poems \ + mliap mliappy molecule mpiio mscg opt peri poems \ python qeq replica rigid shock snap spin srd voronoi PACKUSER = user-adios user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-colvars \ diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 22bf8e77fb..9f54822c47 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -26,6 +26,11 @@ #include #include // IWYU pragma: export +#ifdef LMP_MLIAPPY +#include "mliap_model_python.h" +#include "mliap_model_python_couple.h" +#endif + using namespace LAMMPS_NS; enum{NONE,INT,DOUBLE,STRING,PTR}; @@ -51,7 +56,14 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // one-time initialization of Python interpreter // pyMain stores pointer to main module external_interpreter = Py_IsInitialized(); - + + #ifdef LMP_MLIAPPY + // Inform python intialization scheme of the mliappy module. + // This -must- happen before python is initialized. + int err = PyImport_AppendInittab("mliap_model_python_couple", PyInit_mliap_model_python_couple); + // todo: catch if error and report problem. + #endif + Py_Initialize(); PyEval_InitThreads(); From 862bf643f32c3d6859a564b6ae55705f7b225994 Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Mon, 9 Nov 2020 16:53:24 +0100 Subject: [PATCH 010/187] Add fix for TGNH thermostat. Copy doc file from fix nh. --- doc/src/fix_tgnh_drude.rst | 698 +++++++++ src/USER-DRUDE/fix_tgnh_drude.cpp | 2355 ++++++++++++++++++++++++++++ src/USER-DRUDE/fix_tgnh_drude.h | 294 ++++ src/USER-DRUDE/fix_tgnpt_drude.cpp | 68 + src/USER-DRUDE/fix_tgnpt_drude.h | 48 + src/USER-DRUDE/fix_tgnvt_drude.cpp | 49 + src/USER-DRUDE/fix_tgnvt_drude.h | 48 + 7 files changed, 3560 insertions(+) create mode 100644 doc/src/fix_tgnh_drude.rst create mode 100644 src/USER-DRUDE/fix_tgnh_drude.cpp create mode 100644 src/USER-DRUDE/fix_tgnh_drude.h create mode 100644 src/USER-DRUDE/fix_tgnpt_drude.cpp create mode 100644 src/USER-DRUDE/fix_tgnpt_drude.h create mode 100644 src/USER-DRUDE/fix_tgnvt_drude.cpp create mode 100644 src/USER-DRUDE/fix_tgnvt_drude.h diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst new file mode 100644 index 0000000000..3b6984ec83 --- /dev/null +++ b/doc/src/fix_tgnh_drude.rst @@ -0,0 +1,698 @@ +.. index:: fix tgnvt/drude +.. index:: fix tgnpt/drude + +fix tgnvt/drude command +======================= + +fix tgnpt/drude command +======================= + + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID style_name keyword value ... + +* ID, group-ID are documented in :doc:`fix ` command +* style_name = *tgnvt/drude* or *tgnpt/drude* +* one or more keyword/value pairs may be appended + + .. parsed-literal:: + + keyword = *temp* or *iso* or *aniso* or *tri* or *x* or *y* or *z* or *xy* or *yz* or *xz* or *couple* or *tchain* or *pchain* or *mtk* or *tloop* or *ploop* or *nreset* or *drag* or *ptemp* or *dilate* or *scalexy* or *scaleyz* or *scalexz* or *flip* or *fixedpoint* or *update* + *temp* values = Tstart Tstop Tdamp + Tstart,Tstop = external temperature at start/end of run + Tdamp = temperature damping parameter (time units) + *iso* or *aniso* or *tri* values = Pstart Pstop Pdamp + Pstart,Pstop = scalar external pressure at start/end of run (pressure units) + Pdamp = pressure damping parameter (time units) + *x* or *y* or *z* or *xy* or *yz* or *xz* values = Pstart Pstop Pdamp + Pstart,Pstop = external stress tensor component at start/end of run (pressure units) + Pdamp = stress damping parameter (time units) + *couple* = *none* or *xyz* or *xy* or *yz* or *xz* + *tchain* value = N + N = length of thermostat chain (1 = single thermostat) + *pchain* value = N + N length of thermostat chain on barostat (0 = no thermostat) + *mtk* value = *yes* or *no* = add in MTK adjustment term or not + *tloop* value = M + M = number of sub-cycles to perform on thermostat + *ploop* value = M + M = number of sub-cycles to perform on barostat thermostat + *nreset* value = reset reference cell every this many timesteps + *drag* value = Df + Df = drag factor added to barostat/thermostat (0.0 = no drag) + *ptemp* value = Ttarget + Ttarget = target temperature for barostat + *dilate* value = dilate-group-ID + dilate-group-ID = only dilate atoms in this group due to barostat volume changes + *scalexy* value = *yes* or *no* = scale xy with ly + *scaleyz* value = *yes* or *no* = scale yz with lz + *scalexz* value = *yes* or *no* = scale xz with lz + *flip* value = *yes* or *no* = allow or disallow box flips when it becomes highly skewed + *fixedpoint* values = x y z + x,y,z = perform barostat dilation/contraction around this point (distance units) + *update* value = *dipole* or *dipole/dlm* + dipole = update dipole orientation (only for sphere variants) + dipole/dlm = use DLM integrator to update dipole orientation (only for sphere variants) + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all nvt temp 300.0 300.0 100.0 + fix 1 water npt temp 300.0 300.0 100.0 iso 0.0 0.0 1000.0 + fix 2 jello npt temp 300.0 300.0 100.0 tri 5.0 5.0 1000.0 + fix 2 ice nph x 1.0 1.0 0.5 y 2.0 2.0 0.5 z 3.0 3.0 0.5 yz 0.1 0.1 0.5 xz 0.2 0.2 0.5 xy 0.3 0.3 0.5 nreset 1000 + +Description +""""""""""" + +These commands perform time integration on Nose-Hoover style +non-Hamiltonian equations of motion which are designed to generate +positions and velocities sampled from the canonical (nvt), +isothermal-isobaric (npt), and isenthalpic (nph) ensembles. This +updates the position and velocity for atoms in the group each +timestep. + +The thermostatting and barostatting is achieved by adding some dynamic +variables which are coupled to the particle velocities +(thermostatting) and simulation domain dimensions (barostatting). In +addition to basic thermostatting and barostatting, these fixes can +also create a chain of thermostats coupled to the particle thermostat, +and another chain of thermostats coupled to the barostat +variables. The barostat can be coupled to the overall box volume, or +to individual dimensions, including the *xy*\ , *xz* and *yz* tilt +dimensions. The external pressure of the barostat can be specified as +either a scalar pressure (isobaric ensemble) or as components of a +symmetric stress tensor (constant stress ensemble). When used +correctly, the time-averaged temperature and stress tensor of the +particles will match the target values specified by Tstart/Tstop and +Pstart/Pstop. + +The equations of motion used are those of Shinoda et al in +:ref:`(Shinoda) `, which combine the hydrostatic equations of +Martyna, Tobias and Klein in :ref:`(Martyna) ` with the strain +energy proposed by Parrinello and Rahman in +:ref:`(Parrinello) `. The time integration schemes closely +follow the time-reversible measure-preserving Verlet and rRESPA +integrators derived by Tuckerman et al in :ref:`(Tuckerman) `. + +---------- + +The thermostat parameters for fix styles *nvt* and *npt* are specified +using the *temp* keyword. Other thermostat-related keywords are +*tchain*\ , *tloop* and *drag*\ , which are discussed below. + +The thermostat is applied to only the translational degrees of freedom +for the particles. The translational degrees of freedom can also have +a bias velocity removed before thermostatting takes place; see the +description below. The desired temperature at each timestep is a +ramped value during the run from *Tstart* to *Tstop*\ . The *Tdamp* +parameter is specified in time units and determines how rapidly the +temperature is relaxed. For example, a value of 10.0 means to relax +the temperature in a timespan of (roughly) 10 time units (e.g. :math:`\tau` +or fs or ps - see the :doc:`units ` command). The atoms in the +fix group are the only ones whose velocities and positions are updated +by the velocity/position update portion of the integration. + +.. note:: + + A Nose-Hoover thermostat will not work well for arbitrary values + of *Tdamp*\ . If *Tdamp* is too small, the temperature can fluctuate + wildly; if it is too large, the temperature will take a very long time + to equilibrate. A good choice for many models is a *Tdamp* of around + 100 timesteps. Note that this is NOT the same as 100 time units for + most :doc:`units ` settings. A simple way to ensure this, is + via using an :doc:`immediate variable ` expression accessing + the thermo property 'dt', which is the length of the time step. Example: + +.. code-block:: LAMMPS + + fix 1 all nvt temp 300.0 300.0 $(100.0*dt) + +---------- + +The barostat parameters for fix styles *npt* and *nph* is specified +using one or more of the *iso*\ , *aniso*\ , *tri*\ , *x*\ , *y*\ , *z*\ , *xy*\ , +*xz*\ , *yz*\ , and *couple* keywords. These keywords give you the +ability to specify all 6 components of an external stress tensor, and +to couple various of these components together so that the dimensions +they represent are varied together during a constant-pressure +simulation. + +Other barostat-related keywords are *pchain*\ , *mtk*\ , *ploop*\ , +*nreset*\ , *drag*\ , and *dilate*\ , which are discussed below. + +Orthogonal simulation boxes have 3 adjustable dimensions (x,y,z). +Triclinic (non-orthogonal) simulation boxes have 6 adjustable +dimensions (x,y,z,xy,xz,yz). The :doc:`create_box `, :doc:`read data `, and :doc:`read_restart ` commands +specify whether the simulation box is orthogonal or non-orthogonal +(triclinic) and explain the meaning of the xy,xz,yz tilt factors. + +The target pressures for each of the 6 components of the stress tensor +can be specified independently via the *x*\ , *y*\ , *z*\ , *xy*\ , *xz*\ , *yz* +keywords, which correspond to the 6 simulation box dimensions. For +each component, the external pressure or tensor component at each +timestep is a ramped value during the run from *Pstart* to *Pstop*\ . +If a target pressure is specified for a component, then the +corresponding box dimension will change during a simulation. For +example, if the *y* keyword is used, the y-box length will change. If +the *xy* keyword is used, the xy tilt factor will change. A box +dimension will not change if that component is not specified, although +you have the option to change that dimension via the :doc:`fix deform ` command. + +Note that in order to use the *xy*\ , *xz*\ , or *yz* keywords, the +simulation box must be triclinic, even if its initial tilt factors are +0.0. + +For all barostat keywords, the *Pdamp* parameter operates like the +*Tdamp* parameter, determining the time scale on which pressure is +relaxed. For example, a value of 10.0 means to relax the pressure in +a timespan of (roughly) 10 time units (e.g. :math:`\tau` or fs or ps +- see the :doc:`units ` command). + +.. note:: + + A Nose-Hoover barostat will not work well for arbitrary values + of *Pdamp*\ . If *Pdamp* is too small, the pressure and volume can + fluctuate wildly; if it is too large, the pressure will take a very + long time to equilibrate. A good choice for many models is a *Pdamp* + of around 1000 timesteps. However, note that *Pdamp* is specified in + time units, and that timesteps are NOT the same as time units for most + :doc:`units ` settings. + +The relaxation rate of the barostat is set by its inertia :math:`W`: + +.. math:: + + W = (N + 1) k T_{\rm target} P_{\rm damp}^2 + +where :math:`N` is the number of atoms, :math:`k` is the Boltzmann constant, +and :math:`T_{\rm target}` is the target temperature of the barostat :ref:`(Martyna) `. +If a thermostat is defined, :math:`T_{\rm target}` is the target temperature +of the thermostat. If a thermostat is not defined, :math:`T_{\rm target}` +is set to the current temperature of the system when the barostat is initialized. +If this temperature is too low the simulation will quit with an error. +Note: in previous versions of LAMMPS, :math:`T_{\rm target}` would default to +a value of 1.0 for *lj* units and 300.0 otherwise if the system had a temperature +of exactly zero. + +If a thermostat is not specified by this fix, :math:`T_{\rm target}` can be +manually specified using the *Ptemp* parameter. This may be useful if the +barostat is initialized when the current temperature does not reflect the +steady state temperature of the system. This keyword may also be useful in +athermal simulations where the temperature is not well defined. + +Regardless of what atoms are in the fix group (the only atoms which +are time integrated), a global pressure or stress tensor is computed +for all atoms. Similarly, when the size of the simulation box is +changed, all atoms are re-scaled to new positions, unless the keyword +*dilate* is specified with a *dilate-group-ID* for a group that +represents a subset of the atoms. This can be useful, for example, to +leave the coordinates of atoms in a solid substrate unchanged and +controlling the pressure of a surrounding fluid. This option should +be used with care, since it can be unphysical to dilate some atoms and +not others, because it can introduce large, instantaneous +displacements between a pair of atoms (one dilated, one not) that are +far from the dilation origin. Also note that for atoms not in the fix +group, a separate time integration fix like :doc:`fix nve ` or +:doc:`fix nvt ` can be used on them, independent of whether they +are dilated or not. + +---------- + +The *couple* keyword allows two or three of the diagonal components of +the pressure tensor to be "coupled" together. The value specified +with the keyword determines which are coupled. For example, *xz* +means the *Pxx* and *Pzz* components of the stress tensor are coupled. +*Xyz* means all 3 diagonal components are coupled. Coupling means two +things: the instantaneous stress will be computed as an average of the +corresponding diagonal components, and the coupled box dimensions will +be changed together in lockstep, meaning coupled dimensions will be +dilated or contracted by the same percentage every timestep. The +*Pstart*\ , *Pstop*\ , *Pdamp* parameters for any coupled dimensions must +be identical. *Couple xyz* can be used for a 2d simulation; the *z* +dimension is simply ignored. + +---------- + +The *iso*\ , *aniso*\ , and *tri* keywords are simply shortcuts that are +equivalent to specifying several other keywords together. + +The keyword *iso* means couple all 3 diagonal components together when +pressure is computed (hydrostatic pressure), and dilate/contract the +dimensions together. Using "iso Pstart Pstop Pdamp" is the same as +specifying these 4 keywords: + +.. parsed-literal:: + + x Pstart Pstop Pdamp + y Pstart Pstop Pdamp + z Pstart Pstop Pdamp + couple xyz + +The keyword *aniso* means *x*\ , *y*\ , and *z* dimensions are controlled +independently using the *Pxx*\ , *Pyy*\ , and *Pzz* components of the +stress tensor as the driving forces, and the specified scalar external +pressure. Using "aniso Pstart Pstop Pdamp" is the same as specifying +these 4 keywords: + +.. parsed-literal:: + + x Pstart Pstop Pdamp + y Pstart Pstop Pdamp + z Pstart Pstop Pdamp + couple none + +The keyword *tri* means *x*\ , *y*\ , *z*\ , *xy*\ , *xz*\ , and *yz* dimensions +are controlled independently using their individual stress components +as the driving forces, and the specified scalar pressure as the +external normal stress. Using "tri Pstart Pstop Pdamp" is the same as +specifying these 7 keywords: + +.. parsed-literal:: + + x Pstart Pstop Pdamp + y Pstart Pstop Pdamp + z Pstart Pstop Pdamp + xy 0.0 0.0 Pdamp + yz 0.0 0.0 Pdamp + xz 0.0 0.0 Pdamp + couple none + +---------- + +In some cases (e.g. for solids) the pressure (volume) and/or +temperature of the system can oscillate undesirably when a Nose/Hoover +barostat and thermostat is applied. The optional *drag* keyword will +damp these oscillations, although it alters the Nose/Hoover equations. +A value of 0.0 (no drag) leaves the Nose/Hoover formalism unchanged. +A non-zero value adds a drag term; the larger the value specified, the +greater the damping effect. Performing a short run and monitoring the +pressure and temperature is the best way to determine if the drag term +is working. Typically a value between 0.2 to 2.0 is sufficient to +damp oscillations after a few periods. Note that use of the drag +keyword will interfere with energy conservation and will also change +the distribution of positions and velocities so that they do not +correspond to the nominal NVT, NPT, or NPH ensembles. + +An alternative way to control initial oscillations is to use chain +thermostats. The keyword *tchain* determines the number of thermostats +in the particle thermostat. A value of 1 corresponds to the original +Nose-Hoover thermostat. The keyword *pchain* specifies the number of +thermostats in the chain thermostatting the barostat degrees of +freedom. A value of 0 corresponds to no thermostatting of the +barostat variables. + +The *mtk* keyword controls whether or not the correction terms due to +Martyna, Tuckerman, and Klein are included in the equations of motion +:ref:`(Martyna) `. Specifying *no* reproduces the original +Hoover barostat, whose volume probability distribution function +differs from the true NPT and NPH ensembles by a factor of 1/V. Hence +using *yes* is more correct, but in many cases the difference is +negligible. + +The keyword *tloop* can be used to improve the accuracy of integration +scheme at little extra cost. The initial and final updates of the +thermostat variables are broken up into *tloop* sub-steps, each of +length *dt*\ /\ *tloop*\ . This corresponds to using a first-order +Suzuki-Yoshida scheme :ref:`(Tuckerman) `. The keyword *ploop* +does the same thing for the barostat thermostat. + +The keyword *nreset* controls how often the reference dimensions used +to define the strain energy are reset. If this keyword is not used, +or is given a value of zero, then the reference dimensions are set to +those of the initial simulation domain and are never changed. If the +simulation domain changes significantly during the simulation, then +the final average pressure tensor will differ significantly from the +specified values of the external stress tensor. A value of *nstep* +means that every *nstep* timesteps, the reference dimensions are set +to those of the current simulation domain. + +The *scaleyz*\ , *scalexz*\ , and *scalexy* keywords control whether or +not the corresponding tilt factors are scaled with the associated box +dimensions when barostatting triclinic periodic cells. The default +values *yes* will turn on scaling, which corresponds to adjusting the +linear dimensions of the cell while preserving its shape. Choosing +*no* ensures that the tilt factors are not scaled with the box +dimensions. See below for restrictions and default values in different +situations. In older versions of LAMMPS, scaling of tilt factors was +not performed. The old behavior can be recovered by setting all three +scale keywords to *no*\ . + +The *flip* keyword allows the tilt factors for a triclinic box to +exceed half the distance of the parallel box length, as discussed +below. If the *flip* value is set to *yes*\ , the bound is enforced by +flipping the box when it is exceeded. If the *flip* value is set to +*no*\ , the tilt will continue to change without flipping. Note that if +applied stress induces large deformations (e.g. in a liquid), this +means the box shape can tilt dramatically and LAMMPS will run less +efficiently, due to the large volume of communication needed to +acquire ghost atoms around a processor's irregular-shaped sub-domain. +For extreme values of tilt, LAMMPS may also lose atoms and generate an +error. + +The *fixedpoint* keyword specifies the fixed point for barostat volume +changes. By default, it is the center of the box. Whatever point is +chosen will not move during the simulation. For example, if the lower +periodic boundaries pass through (0,0,0), and this point is provided +to *fixedpoint*\ , then the lower periodic boundaries will remain at +(0,0,0), while the upper periodic boundaries will move twice as +far. In all cases, the particle trajectories are unaffected by the +chosen value, except for a time-dependent constant translation of +positions. + +If the *update* keyword is used with the *dipole* value, then the +orientation of the dipole moment of each particle is also updated +during the time integration. This option should be used for models +where a dipole moment is assigned to finite-size particles, +e.g. spheroids via use of the :doc:`atom_style hybrid sphere dipole ` command. + +The default dipole orientation integrator can be changed to the +Dullweber-Leimkuhler-McLachlan integration scheme +:ref:`(Dullweber) ` when using *update* with the value +*dipole/dlm*\ . This integrator is symplectic and time-reversible, +giving better energy conservation and allows slightly longer timesteps +at only a small additional computational cost. + +---------- + +.. note:: + + Using a barostat coupled to tilt dimensions *xy*\ , *xz*\ , *yz* can + sometimes result in arbitrarily large values of the tilt dimensions, + i.e. a dramatically deformed simulation box. LAMMPS allows the tilt + factors to grow a small amount beyond the normal limit of half the box + length (0.6 times the box length), and then performs a box "flip" to + an equivalent periodic cell. See the discussion of the *flip* keyword + above, to allow this bound to be exceeded, if desired. + +The flip operation is described in more detail in the doc page for +:doc:`fix deform `. Both the barostat dynamics and the atom +trajectories are unaffected by this operation. However, if a tilt +factor is incremented by a large amount (1.5 times the box length) on +a single timestep, LAMMPS can not accommodate this event and will +terminate the simulation with an error. This error typically indicates +that there is something badly wrong with how the simulation was +constructed, such as specifying values of *Pstart* that are too far +from the current stress value, or specifying a timestep that is too +large. Triclinic barostatting should be used with care. This also is +true for other barostat styles, although they tend to be more +forgiving of insults. In particular, it is important to recognize that +equilibrium liquids can not support a shear stress and that +equilibrium solids can not support shear stresses that exceed the +yield stress. + +One exception to this rule is if the first dimension in the tilt factor +(x for xy) is non-periodic. In that case, the limits on the tilt +factor are not enforced, since flipping the box in that dimension does +not change the atom positions due to non-periodicity. In this mode, +if you tilt the system to extreme angles, the simulation will simply +become inefficient due to the highly skewed simulation box. + +.. note:: + + Unlike the :doc:`fix temp/berendsen ` command + which performs thermostatting but NO time integration, these fixes + perform thermostatting/barostatting AND time integration. Thus you + should not use any other time integration fix, such as :doc:`fix nve ` on atoms to which this fix is applied. Likewise, + fix nvt and fix npt should not normally be used on atoms that also + have their temperature controlled by another fix - e.g. by :doc:`fix langevin ` or :doc:`fix temp/rescale ` + commands. + +See the :doc:`Howto thermostat ` and :doc:`Howto barostat ` doc pages for a discussion of different +ways to compute temperature and perform thermostatting and +barostatting. + +---------- + +These fixes compute a temperature and pressure each timestep. To do +this, the thermostat and barostat fixes create their own computes of +style "temp" and "pressure", as if one of these sets of commands had +been issued: + +For fix nvt: + +.. code-block:: LAMMPS + + compute fix-ID_temp group-ID temp + +For fix npt and fix nph: + +.. code-block:: LAMMPS + + compute fix-ID_temp all temp + compute fix-ID_press all pressure fix-ID_temp + +For fix nvt, the group for the new temperature compute is the same as +the fix group. For fix npt and fix nph, the group for both the new +temperature and pressure compute is "all" since pressure is computed +for the entire system. In the case of fix nph, the temperature +compute is not used for thermostatting, but just for a kinetic-energy +contribution to the pressure. See the :doc:`compute temp ` and :doc:`compute pressure ` +commands for details. Note that the IDs of the new computes are the +fix-ID + underscore + "temp" or fix_ID + underscore + "press". + +Note that these are NOT the computes used by thermodynamic output (see +the :doc:`thermo_style ` command) with ID = *thermo_temp* +and *thermo_press*. This means you can change the attributes of these +fix's temperature or pressure via the +:doc:`compute_modify ` command. Or you can print this +temperature or pressure during thermodynamic output via the +:doc:`thermo_style custom ` command using the appropriate +compute-ID. It also means that changing attributes of *thermo_temp* +or *thermo_press* will have no effect on this fix. + +Like other fixes that perform thermostatting, fix nvt and fix npt can +be used with :doc:`compute commands ` that calculate a +temperature after removing a "bias" from the atom velocities. +E.g. removing the center-of-mass velocity from a group of atoms or +only calculating temperature on the x-component of velocity or only +calculating temperature for atoms in a geometric region. This is not +done by default, but only if the :doc:`fix_modify ` command +is used to assign a temperature compute to this fix that includes such +a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In +this case, the thermostat works in the following manner: the current +temperature is calculated taking the bias into account, bias is +removed from each atom, thermostatting is performed on the remaining +thermal degrees of freedom, and the bias is added back in. + +---------- + +These fixes can be used with either the *verlet* or *respa* +:doc:`integrators `. When using one of the barostat fixes +with *respa*\ , LAMMPS uses an integrator constructed +according to the following factorization of the Liouville propagator +(for two rRESPA levels): + +.. math:: + + \exp \left(\mathrm{i} L \Delta t \right) = & \hat{E} + \exp \left(\mathrm{i} L_{\rm T\textrm{-}baro} \frac{\Delta t}{2} \right) + \exp \left(\mathrm{i} L_{\rm T\textrm{-}part} \frac{\Delta t}{2} \right) + \exp \left(\mathrm{i} L_{\epsilon , 2} \frac{\Delta t}{2} \right) + \exp \left(\mathrm{i} L_{2}^{(2)} \frac{\Delta t}{2} \right) \\ + &\times \left[ + \exp \left(\mathrm{i} L_{2}^{(1)} \frac{\Delta t}{2n} \right) + \exp \left(\mathrm{i} L_{\epsilon , 1} \frac{\Delta t}{2n} \right) + \exp \left(\mathrm{i} L_1 \frac{\Delta t}{n} \right) + \exp \left(\mathrm{i} L_{\epsilon , 1} \frac{\Delta t}{2n} \right) + \exp \left(\mathrm{i} L_{2}^{(1)} \frac{\Delta t}{2n} \right) + \right]^n \\ + &\times + \exp \left(\mathrm{i} L_{2}^{(2)} \frac{\Delta t}{2} \right) + \exp \left(\mathrm{i} L_{\epsilon , 2} \frac{\Delta t}{2} \right) + \exp \left(\mathrm{i} L_{\rm T\textrm{-}part} \frac{\Delta t}{2} \right) + \exp \left(\mathrm{i} L_{\rm T\textrm{-}baro} \frac{\Delta t}{2} \right) \\ + &+ \mathcal{O} \left(\Delta t^3 \right) + +This factorization differs somewhat from that of Tuckerman et al, in +that the barostat is only updated at the outermost rRESPA level, +whereas Tuckerman's factorization requires splitting the pressure into +pieces corresponding to the forces computed at each rRESPA level. In +theory, the latter method will exhibit better numerical stability. In +practice, because Pdamp is normally chosen to be a large multiple of +the outermost rRESPA timestep, the barostat dynamics are not the +limiting factor for numerical stability. Both factorizations are +time-reversible and can be shown to preserve the phase space measure +of the underlying non-Hamiltonian equations of motion. + +.. note:: + + This implementation has been shown to conserve linear momentum + up to machine precision under NVT dynamics. Under NPT dynamics, + for a system with zero initial total linear momentum, the total + momentum fluctuates close to zero. It may occasionally undergo brief + excursions to non-negligible values, before returning close to zero. + Over long simulations, this has the effect of causing the center-of-mass + to undergo a slow random walk. This can be mitigated by resetting + the momentum at infrequent intervals using the + :doc:`fix momentum ` command. + +---------- + +The fix npt and fix nph commands can be used with rigid bodies or +mixtures of rigid bodies and non-rigid particles (e.g. solvent). But +there are also :doc:`fix rigid/npt ` and :doc:`fix rigid/nph ` commands, which are typically a more natural +choice. See the doc page for those commands for more discussion of +the various ways to do this. + +---------- + +.. include:: accel_styles.rst + +---------- + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +These fixes writes the state of all the thermostat and barostat +variables to :doc:`binary restart files `. See the +:doc:`read_restart ` command for info on how to re-specify +a fix in an input script that reads a restart file, so that the +operation of the fix continues in an uninterrupted fashion. + +The :doc:`fix_modify ` *temp* and *press* options are +supported by these fixes. You can use them to assign a +:doc:`compute ` you have defined to this fix which will be used +in its thermostatting or barostatting procedure, as described above. +If you do this, note that the kinetic energy derived from the compute +temperature should be consistent with the virial term computed using +all atoms for the pressure. LAMMPS will warn you if you choose to +compute temperature on a subset of atoms. + +.. note:: + + If both the *temp* and *press* keywords are used in a single + thermo_modify command (or in two separate commands), then the order in + which the keywords are specified is important. Note that a :doc:`pressure compute ` defines its own temperature compute as + an argument when it is specified. The *temp* keyword will override + this (for the pressure compute being used by fix npt), but only if the + *temp* keyword comes after the *press* keyword. If the *temp* keyword + comes before the *press* keyword, then the new pressure compute + specified by the *press* keyword will be unaffected by the *temp* + setting. + +The :doc:`fix_modify ` *energy* option is supported by these +fixes to add the energy change induced by Nose/Hoover thermostatting +and barostatting to the system's potential energy as part of +:doc:`thermodynamic output `. + +These fixes compute a global scalar and a global vector of quantities, +which can be accessed by various :doc:`output commands `. +The scalar value calculated by these fixes is "extensive"; the vector +values are "intensive". + +The scalar is the cumulative energy change due to the fix. + +The vector stores internal Nose/Hoover thermostat and barostat +variables. The number and meaning of the vector values depends on +which fix is used and the settings for keywords *tchain* and *pchain*\ , +which specify the number of Nose/Hoover chains for the thermostat and +barostat. If no thermostatting is done, then *tchain* is 0. If no +barostatting is done, then *pchain* is 0. In the following list, +"ndof" is 0, 1, 3, or 6, and is the number of degrees of freedom in +the barostat. Its value is 0 if no barostat is used, else its value +is 6 if any off-diagonal stress tensor component is barostatted, else +its value is 1 if *couple xyz* is used or *couple xy* for a 2d +simulation, otherwise its value is 3. + +The order of values in the global vector and their meaning is as +follows. The notation means there are tchain values for eta, followed +by tchain for eta_dot, followed by ndof for omega, etc: + +* eta[tchain] = particle thermostat displacements (unitless) +* eta_dot[tchain] = particle thermostat velocities (1/time units) +* omega[ndof] = barostat displacements (unitless) +* omega_dot[ndof] = barostat velocities (1/time units) +* etap[pchain] = barostat thermostat displacements (unitless) +* etap_dot[pchain] = barostat thermostat velocities (1/time units) +* PE_eta[tchain] = potential energy of each particle thermostat displacement (energy units) +* KE_eta_dot[tchain] = kinetic energy of each particle thermostat velocity (energy units) +* PE_omega[ndof] = potential energy of each barostat displacement (energy units) +* KE_omega_dot[ndof] = kinetic energy of each barostat velocity (energy units) +* PE_etap[pchain] = potential energy of each barostat thermostat displacement (energy units) +* KE_etap_dot[pchain] = kinetic energy of each barostat thermostat velocity (energy units) +* PE_strain[1] = scalar strain energy (energy units) + +These fixes can ramp their external temperature and pressure over +multiple runs, using the *start* and *stop* keywords of the +:doc:`run ` command. See the :doc:`run ` command for details of +how to do this. + +These fixes are not invoked during :doc:`energy minimization `. + +---------- + +Restrictions +"""""""""""" + +*X*\ , *y*\ , *z* cannot be barostatted if the associated dimension is not +periodic. *Xy*\ , *xz*\ , and *yz* can only be barostatted if the +simulation domain is triclinic and the second dimension in the keyword +(\ *y* dimension in *xy*\ ) is periodic. *Z*\ , *xz*\ , and *yz*\ , cannot be +barostatted for 2D simulations. The :doc:`create_box `, +:doc:`read data `, and :doc:`read_restart ` +commands specify whether the simulation box is orthogonal or +non-orthogonal (triclinic) and explain the meaning of the xy,xz,yz +tilt factors. + +For the *temp* keyword, the final Tstop cannot be 0.0 since it would +make the external T = 0.0 at some timestep during the simulation which +is not allowed in the Nose/Hoover formulation. + +The *scaleyz yes* and *scalexz yes* keyword/value pairs can not be used +for 2D simulations. *scaleyz yes*\ , *scalexz yes*\ , and *scalexy yes* options +can only be used if the second dimension in the keyword is periodic, +and if the tilt factor is not coupled to the barostat via keywords +*tri*\ , *yz*\ , *xz*\ , and *xy*\ . + +These fixes can be used with dynamic groups as defined by the +:doc:`group ` command. Likewise they can be used with groups to +which atoms are added or deleted over time, e.g. a deposition +simulation. However, the conservation properties of the thermostat +and barostat are defined for systems with a static set of atoms. You +may observe odd behavior if the atoms in a group vary dramatically +over time or the atom count becomes very small. + +Related commands +"""""""""""""""" + +:doc:`fix nve `, :doc:`fix_modify `, +:doc:`run_style ` + +Default +""""""" + +The keyword defaults are tchain = 3, pchain = 3, mtk = yes, tloop = 1, +ploop = 1, nreset = 0, drag = 0.0, dilate = all, couple = none, +flip = yes, scaleyz = scalexz = scalexy = yes if periodic in second +dimension and not coupled to barostat, otherwise no. + +---------- + +.. _nh-Martyna: + +**(Martyna)** Martyna, Tobias and Klein, J Chem Phys, 101, 4177 (1994). + +.. _nh-Parrinello: + +**(Parrinello)** Parrinello and Rahman, J Appl Phys, 52, 7182 (1981). + +.. _nh-Tuckerman: + +**(Tuckerman)** Tuckerman, Alejandre, Lopez-Rendon, Jochim, and +Martyna, J Phys A: Math Gen, 39, 5629 (2006). + +.. _nh-Shinoda: + +**(Shinoda)** Shinoda, Shiga, and Mikami, Phys Rev B, 69, 134103 (2004). + +.. _nh-Dullweber: + +**(Dullweber)** Dullweber, Leimkuhler and McLachlan, J Chem Phys, 107, +5840 (1997). diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp new file mode 100644 index 0000000000..8b9e2035a0 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -0,0 +1,2355 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Mark Stevens (SNL), Aidan Thompson (SNL), Zheng Gong (ENS Lyon) +------------------------------------------------------------------------- */ + +#include "fix_tgnh_drude.h" +#include +#include +#include "atom.h" +#include "force.h" +#include "group.h" +#include "comm.h" +#include "neighbor.h" +#include "irregular.h" +#include "modify.h" +#include "fix_deform.h" +#include "compute.h" +#include "kspace.h" +#include "update.h" +#include "respa.h" +#include "domain.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +#define DELTAFLIP 0.1 +#define TILTMAX 1.5 + +enum{NOBIAS,BIAS}; +enum{NONE,XYZ,XY,YZ,XZ}; +enum{ISO,ANISO,TRICLINIC}; + +/* ---------------------------------------------------------------------- + NVT,NPH,NPT integrators for improved Nose-Hoover equations of motion + ---------------------------------------------------------------------- */ + +FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), + rfix(NULL), irregular(NULL), id_temp(NULL), id_press(NULL) +{ + if (narg < 4) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + + restart_global = 1; + dynamic_group_allow = 0; + time_integrate = 1; + scalar_flag = 1; + vector_flag = 1; + global_freq = 1; + extscalar = 1; + extvector = 0; + + // default values + + pcouple = NONE; + mtchain = mpchain = 3; + nc_tchain = nc_pchain = 1; + mtk_flag = 1; + deviatoric_flag = 0; + nreset_h0 = 0; + flipflag = 1; + + tcomputeflag = 0; + pcomputeflag = 0; + id_temp = NULL; + id_press = NULL; + + // turn on tilt factor scaling, whenever applicable + + dimension = domain->dimension; + + scaleyz = scalexz = scalexy = 0; + if (domain->yperiodic && domain->xy != 0.0) scalexy = 1; + if (domain->zperiodic && dimension == 3) { + if (domain->yz != 0.0) scaleyz = 1; + if (domain->xz != 0.0) scalexz = 1; + } + + // set fixed-point to default = center of cell + + fixedpoint[0] = 0.5*(domain->boxlo[0]+domain->boxhi[0]); + fixedpoint[1] = 0.5*(domain->boxlo[1]+domain->boxhi[1]); + fixedpoint[2] = 0.5*(domain->boxlo[2]+domain->boxhi[2]); + + tstat_flag = 0; + double t_period = 0.0, tdrude_period = 0.0; + + double p_period[6]; + for (int i = 0; i < 6; i++) { + p_start[i] = p_stop[i] = p_period[i] = p_target[i] = 0.0; + p_flag[i] = 0; + } + + // process keywords + + int iarg = 3; + + while (iarg < narg) { + if (strcmp(arg[iarg],"temp") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + tstat_flag = 1; + t_start = force->numeric(FLERR,arg[iarg+1]); + t_target = t_start; + t_stop = force->numeric(FLERR,arg[iarg+2]); + t_period = force->numeric(FLERR,arg[iarg+3]); + if (t_start <= 0.0 || t_stop <= 0.0) + error->all(FLERR, + "Target temperature for fix nvt/npt/nph cannot be 0.0"); + tdrude_target = force->numeric(FLERR,arg[iarg+4]); + tdrude_period = force->numeric(FLERR,arg[iarg+5]); + iarg += 6; + + } else if (strcmp(arg[iarg],"iso") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + pcouple = XYZ; + p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); + p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); + p_period[0] = p_period[1] = p_period[2] = + force->numeric(FLERR,arg[iarg+3]); + p_flag[0] = p_flag[1] = p_flag[2] = 1; + if (dimension == 2) { + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; + } + iarg += 4; + } else if (strcmp(arg[iarg],"aniso") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + pcouple = NONE; + p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); + p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); + p_period[0] = p_period[1] = p_period[2] = + force->numeric(FLERR,arg[iarg+3]); + p_flag[0] = p_flag[1] = p_flag[2] = 1; + if (dimension == 2) { + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; + } + iarg += 4; + } else if (strcmp(arg[iarg],"tri") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + pcouple = NONE; + scalexy = scalexz = scaleyz = 0; + p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); + p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); + p_period[0] = p_period[1] = p_period[2] = + force->numeric(FLERR,arg[iarg+3]); + p_flag[0] = p_flag[1] = p_flag[2] = 1; + p_start[3] = p_start[4] = p_start[5] = 0.0; + p_stop[3] = p_stop[4] = p_stop[5] = 0.0; + p_period[3] = p_period[4] = p_period[5] = + force->numeric(FLERR,arg[iarg+3]); + p_flag[3] = p_flag[4] = p_flag[5] = 1; + if (dimension == 2) { + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; + p_start[3] = p_stop[3] = p_period[3] = 0.0; + p_flag[3] = 0; + p_start[4] = p_stop[4] = p_period[4] = 0.0; + p_flag[4] = 0; + } + iarg += 4; + } else if (strcmp(arg[iarg],"x") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[0] = force->numeric(FLERR,arg[iarg+1]); + p_stop[0] = force->numeric(FLERR,arg[iarg+2]); + p_period[0] = force->numeric(FLERR,arg[iarg+3]); + p_flag[0] = 1; + deviatoric_flag = 1; + iarg += 4; + } else if (strcmp(arg[iarg],"y") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[1] = force->numeric(FLERR,arg[iarg+1]); + p_stop[1] = force->numeric(FLERR,arg[iarg+2]); + p_period[1] = force->numeric(FLERR,arg[iarg+3]); + p_flag[1] = 1; + deviatoric_flag = 1; + iarg += 4; + } else if (strcmp(arg[iarg],"z") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[2] = force->numeric(FLERR,arg[iarg+1]); + p_stop[2] = force->numeric(FLERR,arg[iarg+2]); + p_period[2] = force->numeric(FLERR,arg[iarg+3]); + p_flag[2] = 1; + deviatoric_flag = 1; + iarg += 4; + if (dimension == 2) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + + } else if (strcmp(arg[iarg],"yz") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[3] = force->numeric(FLERR,arg[iarg+1]); + p_stop[3] = force->numeric(FLERR,arg[iarg+2]); + p_period[3] = force->numeric(FLERR,arg[iarg+3]); + p_flag[3] = 1; + deviatoric_flag = 1; + scaleyz = 0; + iarg += 4; + if (dimension == 2) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + } else if (strcmp(arg[iarg],"xz") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[4] = force->numeric(FLERR,arg[iarg+1]); + p_stop[4] = force->numeric(FLERR,arg[iarg+2]); + p_period[4] = force->numeric(FLERR,arg[iarg+3]); + p_flag[4] = 1; + deviatoric_flag = 1; + scalexz = 0; + iarg += 4; + if (dimension == 2) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + } else if (strcmp(arg[iarg],"xy") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[5] = force->numeric(FLERR,arg[iarg+1]); + p_stop[5] = force->numeric(FLERR,arg[iarg+2]); + p_period[5] = force->numeric(FLERR,arg[iarg+3]); + p_flag[5] = 1; + deviatoric_flag = 1; + scalexy = 0; + iarg += 4; + + } else if (strcmp(arg[iarg],"couple") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"xyz") == 0) pcouple = XYZ; + else if (strcmp(arg[iarg+1],"xy") == 0) pcouple = XY; + else if (strcmp(arg[iarg+1],"yz") == 0) pcouple = YZ; + else if (strcmp(arg[iarg+1],"xz") == 0) pcouple = XZ; + else if (strcmp(arg[iarg+1],"none") == 0) pcouple = NONE; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"tchain") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + mtchain = force->inumeric(FLERR,arg[iarg+1]); + if (mtchain < 1) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"pchain") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + mpchain = force->inumeric(FLERR,arg[iarg+1]); + if (mpchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"mtk") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"tloop") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + nc_tchain = force->inumeric(FLERR,arg[iarg+1]); + if (nc_tchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"ploop") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + nc_pchain = force->inumeric(FLERR,arg[iarg+1]); + if (nc_pchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"nreset") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + nreset_h0 = force->inumeric(FLERR,arg[iarg+1]); + if (nreset_h0 < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scalexy") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1; + else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scalexz") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1; + else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scaleyz") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1; + else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"flip") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"fixedpoint") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + fixedpoint[0] = force->numeric(FLERR,arg[iarg+1]); + fixedpoint[1] = force->numeric(FLERR,arg[iarg+2]); + fixedpoint[2] = force->numeric(FLERR,arg[iarg+3]); + iarg += 4; + } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + } + + // error checks + + if (dimension == 2 && (p_flag[2] || p_flag[3] || p_flag[4])) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + if (dimension == 2 && (pcouple == YZ || pcouple == XZ)) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + if (dimension == 2 && (scalexz == 1 || scaleyz == 1 )) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + + if (pcouple == XYZ && (p_flag[0] == 0 || p_flag[1] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == XYZ && dimension == 3 && p_flag[2] == 0) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == XY && (p_flag[0] == 0 || p_flag[1] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == YZ && (p_flag[1] == 0 || p_flag[2] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == XZ && (p_flag[0] == 0 || p_flag[2] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + + // require periodicity in tensile dimension + + if (p_flag[0] && domain->xperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph on a non-periodic dimension"); + if (p_flag[1] && domain->yperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph on a non-periodic dimension"); + if (p_flag[2] && domain->zperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph on a non-periodic dimension"); + + // require periodicity in 2nd dim of off-diagonal tilt component + + if (p_flag[3] && domain->zperiodic == 0) + error->all(FLERR, + "Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension"); + if (p_flag[4] && domain->zperiodic == 0) + error->all(FLERR, + "Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension"); + if (p_flag[5] && domain->yperiodic == 0) + error->all(FLERR, + "Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension"); + + if (scaleyz == 1 && domain->zperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph " + "with yz scaling when z is non-periodic dimension"); + if (scalexz == 1 && domain->zperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph " + "with xz scaling when z is non-periodic dimension"); + if (scalexy == 1 && domain->yperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph " + "with xy scaling when y is non-periodic dimension"); + + if (p_flag[3] && scaleyz == 1) + error->all(FLERR,"Cannot use fix nvt/npt/nph with " + "both yz dynamics and yz scaling"); + if (p_flag[4] && scalexz == 1) + error->all(FLERR,"Cannot use fix nvt/npt/nph with " + "both xz dynamics and xz scaling"); + if (p_flag[5] && scalexy == 1) + error->all(FLERR,"Cannot use fix nvt/npt/nph with " + "both xy dynamics and xy scaling"); + + if (!domain->triclinic && (p_flag[3] || p_flag[4] || p_flag[5])) + error->all(FLERR,"Can not specify Pxy/Pxz/Pyz in " + "fix nvt/npt/nph with non-triclinic box"); + + if (pcouple == XYZ && dimension == 3 && + (p_start[0] != p_start[1] || p_start[0] != p_start[2] || + p_stop[0] != p_stop[1] || p_stop[0] != p_stop[2] || + p_period[0] != p_period[1] || p_period[0] != p_period[2])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == XYZ && dimension == 2 && + (p_start[0] != p_start[1] || p_stop[0] != p_stop[1] || + p_period[0] != p_period[1])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == XY && + (p_start[0] != p_start[1] || p_stop[0] != p_stop[1] || + p_period[0] != p_period[1])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == YZ && + (p_start[1] != p_start[2] || p_stop[1] != p_stop[2] || + p_period[1] != p_period[2])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == XZ && + (p_start[0] != p_start[2] || p_stop[0] != p_stop[2] || + p_period[0] != p_period[2])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + + if ((tstat_flag && t_period <= 0.0) || + (p_flag[0] && p_period[0] <= 0.0) || + (p_flag[1] && p_period[1] <= 0.0) || + (p_flag[2] && p_period[2] <= 0.0) || + (p_flag[3] && p_period[3] <= 0.0) || + (p_flag[4] && p_period[4] <= 0.0) || + (p_flag[5] && p_period[5] <= 0.0)) + error->all(FLERR,"Fix nvt/npt/nph damping parameters must be > 0.0"); + + // set pstat_flag and box change and restart_pbc variables + + pre_exchange_flag = 0; + pstat_flag = 0; + pstyle = ISO; + + for (int i = 0; i < 6; i++) + if (p_flag[i]) pstat_flag = 1; + + if (pstat_flag) { + if (p_flag[0] || p_flag[1] || p_flag[2]) box_change_size = 1; + if (p_flag[3] || p_flag[4] || p_flag[5]) box_change_shape = 1; + no_change_box = 1; + + // pstyle = TRICLINIC if any off-diagonal term is controlled -> 6 dof + // else pstyle = ISO if XYZ coupling or XY coupling in 2d -> 1 dof + // else pstyle = ANISO -> 3 dof + + if (p_flag[3] || p_flag[4] || p_flag[5]) pstyle = TRICLINIC; + else if (pcouple == XYZ || (dimension == 2 && pcouple == XY)) pstyle = ISO; + else pstyle = ANISO; + + // pre_exchange only required if flips can occur due to shape changes + + if (flipflag && (p_flag[3] || p_flag[4] || p_flag[5])) + pre_exchange_flag = 1; + if (flipflag && (domain->yz != 0.0 || domain->xz != 0.0 || + domain->xy != 0.0)) + pre_exchange_flag = 1; + } + + // convert input periods to frequencies + + t_freq = tdrude_freq = 0.0; + p_freq[0] = p_freq[1] = p_freq[2] = p_freq[3] = p_freq[4] = p_freq[5] = 0.0; + + if (tstat_flag) { + t_freq = 1.0 / t_period; + tdrude_freq = 1.0 / tdrude_period; + } + if (p_flag[0]) p_freq[0] = 1.0 / p_period[0]; + if (p_flag[1]) p_freq[1] = 1.0 / p_period[1]; + if (p_flag[2]) p_freq[2] = 1.0 / p_period[2]; + if (p_flag[3]) p_freq[3] = 1.0 / p_period[3]; + if (p_flag[4]) p_freq[4] = 1.0 / p_period[4]; + if (p_flag[5]) p_freq[5] = 1.0 / p_period[5]; + + // Nose/Hoover temp and pressure init + + size_vector = 3; + + if (tstat_flag) { + int ich; + + etaint = new double[mtchain]; + // add one extra dummy thermostat for eta_dot, set to zero + etaint_dot = new double[mtchain+1]; + etaint_dot[mtchain] = 0.0; + etaint_dotdot = new double[mtchain]; + for (ich = 0; ich < mtchain; ich++) { + etaint[ich] = etaint_dot[ich] = etaint_dotdot[ich] = 0.0; + } + etaint_mass = new double[mtchain]; + + etamol = new double[mtchain]; + // add one extra dummy thermostat for eta_dot, set to zero + etamol_dot = new double[mtchain+1]; + etamol_dot[mtchain] = 0.0; + etamol_dotdot = new double[mtchain]; + for (ich = 0; ich < mtchain; ich++) { + etamol[ich] = etamol_dot[ich] = etamol_dotdot[ich] = 0.0; + } + etamol_mass = new double[mtchain]; + + etadrude = new double[mtchain]; + // add one extra dummy thermostat for eta_dot, set to zero + etadrude_dot = new double[mtchain+1]; + etadrude_dot[mtchain] = 0.0; + etadrude_dotdot = new double[mtchain]; + for (ich = 0; ich < mtchain; ich++) { + etadrude[ich] = etadrude_dot[ich] = etadrude_dotdot[ich] = 0.0; + } + etadrude_mass = new double[mtchain]; + } + + if (pstat_flag) { + omega[0] = omega[1] = omega[2] = 0.0; + omega_dot[0] = omega_dot[1] = omega_dot[2] = 0.0; + omega_mass[0] = omega_mass[1] = omega_mass[2] = 0.0; + omega[3] = omega[4] = omega[5] = 0.0; + omega_dot[3] = omega_dot[4] = omega_dot[5] = 0.0; + omega_mass[3] = omega_mass[4] = omega_mass[5] = 0.0; + + if (mpchain) { + int ich; + etap = new double[mpchain]; + + // add one extra dummy thermostat, set to zero + + etap_dot = new double[mpchain+1]; + etap_dot[mpchain] = 0.0; + etap_dotdot = new double[mpchain]; + for (ich = 0; ich < mpchain; ich++) { + etap[ich] = etap_dot[ich] = + etap_dotdot[ich] = 0.0; + } + etap_mass = new double[mpchain]; + } + } + + nrigid = 0; + rfix = NULL; + + if (pre_exchange_flag) irregular = new Irregular(lmp); + else irregular = NULL; + + // initialize vol0,t0 to zero to signal uninitialized + // values then assigned in init(), if necessary + + vol0 = t0 = 0.0; + + // find fix drude + int ifix; + for (ifix = 0; ifix < modify->nfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; + if (ifix == modify->nfix) error->all(FLERR, "fix tgnh/drude requires fix drude"); + fix_drude = (FixDrude *) modify->fix[ifix]; + + // make sure ghost atoms have velocity + if (!comm->ghost_velocity) + error->all(FLERR,"fix tgnh/drude requires ghost velocities. Use comm_modify vel yes"); +} + +/* ---------------------------------------------------------------------- */ + +FixTGNHDrude::~FixTGNHDrude() +{ + if (copymode) return; + + delete [] rfix; + + delete irregular; + + // delete temperature and pressure if fix created them + + if (tcomputeflag) modify->delete_compute(id_temp); + delete [] id_temp; + + if (tstat_flag) { + delete [] etaint; + delete [] etaint_dot; + delete [] etaint_dotdot; + delete [] etaint_mass; + delete [] etamol; + delete [] etamol_dot; + delete [] etamol_dotdot; + delete [] etamol_mass; + delete [] etadrude; + delete [] etadrude_dot; + delete [] etadrude_dotdot; + delete [] etadrude_mass; + } + + if (pstat_flag) { + if (pcomputeflag) modify->delete_compute(id_press); + delete [] id_press; + if (mpchain) { + delete [] etap; + delete [] etap_dot; + delete [] etap_dotdot; + delete [] etap_mass; + } + } +} + +/* ---------------------------------------------------------------------- */ + +int FixTGNHDrude::setmask() +{ + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= FINAL_INTEGRATE; + mask |= THERMO_ENERGY; + mask |= INITIAL_INTEGRATE_RESPA; + mask |= FINAL_INTEGRATE_RESPA; + if (pre_exchange_flag) mask |= PRE_EXCHANGE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::init() +{ + // ensure no conflict with fix deform + + if (pstat_flag) + for (int i = 0; i < modify->nfix; i++) + if (strcmp(modify->fix[i]->style,"deform") == 0) { + int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || + (p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) || + (p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5])) + error->all(FLERR,"Cannot use fix npt and fix deform on " + "same component of stress tensor"); + } + + // set temperature and pressure ptrs + + int icompute = modify->find_compute(id_temp); + if (icompute < 0) + error->all(FLERR,"Temperature ID for fix nvt/npt does not exist"); + temperature = modify->compute[icompute]; + + if (temperature->tempbias) which = BIAS; + else which = NOBIAS; + + if (pstat_flag) { + icompute = modify->find_compute(id_press); + if (icompute < 0) + error->all(FLERR,"Pressure ID for fix npt/nph does not exist"); + pressure = modify->compute[icompute]; + } + + // set timesteps and frequencies + + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dthalf = 0.5 * update->dt; + dt4 = 0.25 * update->dt; + dt8 = 0.125 * update->dt; + dto = dthalf; + + p_freq_max = 0.0; + if (pstat_flag) { + p_freq_max = MAX(p_freq[0],p_freq[1]); + p_freq_max = MAX(p_freq_max,p_freq[2]); + if (pstyle == TRICLINIC) { + p_freq_max = MAX(p_freq_max,p_freq[3]); + p_freq_max = MAX(p_freq_max,p_freq[4]); + p_freq_max = MAX(p_freq_max,p_freq[5]); + } + } + + // tally the number of dimensions that are barostatted + // set initial volume and reference cell, if not already done + + if (pstat_flag) { + pdim = p_flag[0] + p_flag[1] + p_flag[2]; + if (vol0 == 0.0) { + if (dimension == 3) vol0 = domain->xprd * domain->yprd * domain->zprd; + else vol0 = domain->xprd * domain->yprd; + h0_inv[0] = domain->h_inv[0]; + h0_inv[1] = domain->h_inv[1]; + h0_inv[2] = domain->h_inv[2]; + h0_inv[3] = domain->h_inv[3]; + h0_inv[4] = domain->h_inv[4]; + h0_inv[5] = domain->h_inv[5]; + } + } + + boltz = force->boltz; + nktv2p = force->nktv2p; + + if (force->kspace) kspace_flag = 1; + else kspace_flag = 0; + + if (strstr(update->integrate_style,"respa")) { + nlevels_respa = ((Respa *) update->integrate)->nlevels; + step_respa = ((Respa *) update->integrate)->step; + dto = 0.5*step_respa[0]; + } + + // detect if any rigid fixes exist so rigid bodies move when box is remapped + // rfix[] = indices to each fix rigid + + delete [] rfix; + nrigid = 0; + rfix = NULL; + + for (int i = 0; i < modify->nfix; i++) + if (modify->fix[i]->rigid_flag) nrigid++; + if (nrigid) { + rfix = new int[nrigid]; + nrigid = 0; + for (int i = 0; i < modify->nfix; i++) + if (modify->fix[i]->rigid_flag) rfix[nrigid++] = i; + } +} + +/* ---------------------------------------------------------------------- + compute T,P before integrator starts +------------------------------------------------------------------------- */ + +void FixTGNHDrude::setup_mol_mass_dof() { + double *mass = atom->mass; + int *mask = atom->mask; + int *molecule = atom->molecule; + int *type = atom->type; + int *drudetype = fix_drude->drudetype; + int n_drude, n_drude_tmp = 0; + tagint id_mol = 0, n_mol_in_group = 0; + + for (int i = 0; i < atom->nlocal; i++) { + // molecule id starts from 1. max(id_mol) equals to the number of molecules in the system + id_mol = std::max(id_mol, molecule[i]); + if (mask[i] & groupbit) { + if (drudetype[type[i]] == DRUDE_TYPE) + n_drude_tmp += 1; + } + } + MPI_Allreduce(&n_drude_tmp, &n_drude, 1, MPI_LMP_TAGINT, MPI_SUM, world); + MPI_Allreduce(&id_mol, &n_mol, 1, MPI_LMP_TAGINT, MPI_MAX, world); + + // use flag_mol to determin the number of molecules in the fix group + int *flag_mol = new int[n_mol + 1]; + int *flag_mol_tmp = new int[n_mol + 1]; + memset(flag_mol_tmp, 0, sizeof(int) * (n_mol + 1)); + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + flag_mol_tmp[molecule[i]] = 1; + } + } + MPI_Allreduce(flag_mol_tmp, flag_mol, n_mol + 1, MPI_INT, MPI_SUM, world); + for (int i = 1; i < n_mol + 1; i++) { + if (flag_mol[i]) + n_mol_in_group++; + } + + // length of v_mol set to n_mol+1, so that the subscript start from 1, we can call v_mol[n_mol] + memory->create(v_mol, n_mol + 1, 3, "fix_tgnh_drude::v_mol"); + memory->create(v_mol_tmp, n_mol + 1, 3, "fix_tgnh_drude::v_mol_tmp"); + memory->create(mass_mol, n_mol + 1, "fix_tgnh_drude::mass_mol"); + + double *mass_tmp = new double[n_mol + 1]; + memset(mass_tmp, 0, sizeof(double) * (n_mol + 1)); + for (int i = 0; i < atom->nlocal; i++) { + id_mol = molecule[i]; + mass_tmp[id_mol] += mass[type[i]]; + } + MPI_Allreduce(mass_tmp, mass_mol, n_mol + 1, MPI_DOUBLE, MPI_SUM, world); + + // DOFs + t_current = temperature->compute_scalar(); + _tdof = temperature->dof; + dof_mol = 3 * n_mol_in_group; + // remove DOFs of COM motion based on the number of atoms in the group + if (n_mol_in_group > 1) + dof_mol -= ((double) 3) * group->count(igroup) / atom->natoms; + dof_drude = 3 * n_drude; + dof_int = _tdof - dof_mol - dof_drude; + + if (comm->me == 0) { + if (screen) { + fprintf(screen, "TGNHC thermostat for Drude model\n"); + fprintf(screen, " DOFs of molecules, atoms and dipoles: %.1f %.1f %.1f\n", + dof_mol, dof_int, dof_drude); + } + if (logfile) { + fprintf(logfile, "TGNHC thermostat for Drude model\n"); + fprintf(logfile, " DOFs of molecules, atoms and dipoles: %.1f %.1f %.1f\n", + dof_mol, dof_int, dof_drude); + } + } + if (dof_mol <=0 or dof_int <=0 or dof_drude <=0) + error->all(FLERR, "TGNHC thermostat requires DOFs of molecules, atoms and dipoles larger than 0"); +} + +void FixTGNHDrude::setup(int /*vflag*/) +{ + setup_mol_mass_dof(); + // t_target is needed by NVT and NPT in compute_scalar() + // If no thermostat or using fix nphug, + // t_target must be defined by other means. + + if (tstat_flag && strstr(style,"nphug") == NULL) { + compute_temp_target(); + } else if (pstat_flag) { + + // t0 = reference temperature for masses + // cannot be done in init() b/c temperature cannot be called there + // is b/c Modify::init() inits computes after fixes due to dof dependence + // guesstimate a unit-dependent t0 if actual T = 0.0 + // if it was read in from a restart file, leave it be + + if (t0 == 0.0) { + t0 = temperature->compute_scalar(); + if (t0 == 0.0) { + if (strcmp(update->unit_style,"lj") == 0) t0 = 1.0; + else t0 = 300.0; + } + } + t_target = t0; + } + + if (pstat_flag) compute_press_target(); + + if (pstat_flag) { + if (pstyle == ISO) pressure->compute_scalar(); + else pressure->compute_vector(); + couple(); + pressure->addstep(update->ntimestep+1); + } + + // masses and initial forces on thermostat variables + + if (tstat_flag) { + etaint_mass[0] = ke2int_target / (t_freq * t_freq); + etamol_mass[0] = ke2mol_target / (t_freq * t_freq); + etadrude_mass[0] = ke2drude_target / (tdrude_freq * tdrude_freq); + for (int ich = 1; ich < mtchain; ich++) { + etaint_mass[ich] = boltz * t_target / (t_freq * t_freq); + etamol_mass[ich] = boltz * t_target / (t_freq * t_freq); + etadrude_mass[ich] = boltz * tdrude_target / (tdrude_freq * tdrude_freq); + + etaint_dotdot[ich] = (etaint_mass[ich - 1] * etaint_dot[ich - 1] * etaint_dot[ich - 1] - + boltz * t_target) / etaint_mass[ich]; + etamol_dotdot[ich] = (etamol_mass[ich - 1] * etamol_dot[ich - 1] * etamol_dot[ich - 1] - + boltz * t_target) / etamol_mass[ich]; + etadrude_dotdot[ich] = (etadrude_mass[ich - 1] * etadrude_dot[ich - 1] * etadrude_dot[ich - 1] - + boltz * tdrude_target) / etadrude_mass[ich]; + } + } + + // masses and initial forces on barostat variables + + if (pstat_flag) { + double kt = boltz * t_target; + double nkt = (atom->natoms + 1) * kt; + + for (int i = 0; i < 3; i++) + if (p_flag[i]) + omega_mass[i] = nkt/(p_freq[i]*p_freq[i]); + + if (pstyle == TRICLINIC) { + for (int i = 3; i < 6; i++) + if (p_flag[i]) omega_mass[i] = nkt/(p_freq[i]*p_freq[i]); + } + + // masses and initial forces on barostat thermostat variables + + if (mpchain) { + etap_mass[0] = boltz * t_target / (p_freq_max*p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_mass[ich] = boltz * t_target / (p_freq_max*p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_dotdot[ich] = + (etap_mass[ich-1]*etap_dot[ich-1]*etap_dot[ich-1] - + boltz * t_target) / etap_mass[ich]; + } + } +} + +/* ---------------------------------------------------------------------- + 1st half of Verlet update +------------------------------------------------------------------------- */ + +void FixTGNHDrude::initial_integrate(int /*vflag*/) +{ + // update eta_press_dot + + if (pstat_flag && mpchain) nhc_press_integrate(); + + // update eta_dot + + if (tstat_flag) { + compute_temp_target(); + nhc_temp_integrate(); + } + + // need to recompute pressure to account for change in KE + // t_current is up-to-date, but compute_temperature is not + // compute appropriately coupled elements of mvv_current + + if (pstat_flag) { + if (pstyle == ISO) { + temperature->compute_scalar(); + pressure->compute_scalar(); + } else { + temperature->compute_vector(); + pressure->compute_vector(); + } + couple(); + pressure->addstep(update->ntimestep+1); + } + + if (pstat_flag) { + compute_press_target(); + nh_omega_dot(); + nh_v_press(); + } + + nve_v(); + + // remap simulation box by 1/2 step + + if (pstat_flag) remap(); + + nve_x(); + + // remap simulation box by 1/2 step + // redo KSpace coeffs since volume has changed + + if (pstat_flag) { + remap(); + if (kspace_flag) force->kspace->setup(); + } +} + +/* ---------------------------------------------------------------------- + 2nd half of Verlet update +------------------------------------------------------------------------- */ + +void FixTGNHDrude::final_integrate() +{ + nve_v(); + + // re-compute temp before nh_v_press() + // only needed for temperature computes with BIAS on reneighboring steps: + // b/c some biases store per-atom values (e.g. temp/profile) + // per-atom values are invalid if reneigh/comm occurred + // since temp->compute() in initial_integrate() + + if (which == BIAS && neighbor->ago == 0) + t_current = temperature->compute_scalar(); + + if (pstat_flag) nh_v_press(); + + // compute new T,P after velocities rescaled by nh_v_press() + // compute appropriately coupled elements of mvv_current + + t_current = temperature->compute_scalar(); + _tdof = temperature->dof; + + // need to recompute pressure to account for change in KE + // t_current is up-to-date, but compute_temperature is not + // compute appropriately coupled elements of mvv_current + + if (pstat_flag) { + if (pstyle == ISO) pressure->compute_scalar(); + else { + temperature->compute_vector(); + pressure->compute_vector(); + } + couple(); + pressure->addstep(update->ntimestep+1); + } + + if (pstat_flag) nh_omega_dot(); + + // update eta_dot + // update eta_press_dot + + if (tstat_flag) nhc_temp_integrate(); + if (pstat_flag && mpchain) nhc_press_integrate(); +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::initial_integrate_respa(int /*vflag*/, int ilevel, int /*iloop*/) +{ + // set timesteps by level + + dtv = step_respa[ilevel]; + dtf = 0.5 * step_respa[ilevel] * force->ftm2v; + dthalf = 0.5 * step_respa[ilevel]; + + // outermost level - update eta_dot and omega_dot, apply to v + // all other levels - NVE update of v + // x,v updates only performed for atoms in group + + if (ilevel == nlevels_respa-1) { + + // update eta_press_dot + + if (pstat_flag && mpchain) nhc_press_integrate(); + + // update eta_dot + + if (tstat_flag) { + compute_temp_target(); + nhc_temp_integrate(); + } + + // recompute pressure to account for change in KE + // t_current is up-to-date, but compute_temperature is not + // compute appropriately coupled elements of mvv_current + + if (pstat_flag) { + if (pstyle == ISO) { + temperature->compute_scalar(); + pressure->compute_scalar(); + } else { + temperature->compute_vector(); + pressure->compute_vector(); + } + couple(); + pressure->addstep(update->ntimestep+1); + } + + if (pstat_flag) { + compute_press_target(); + nh_omega_dot(); + nh_v_press(); + } + + nve_v(); + + } else nve_v(); + + // innermost level - also update x only for atoms in group + // if barostat, perform 1/2 step remap before and after + + if (ilevel == 0) { + if (pstat_flag) remap(); + nve_x(); + if (pstat_flag) remap(); + } + + // if barostat, redo KSpace coeffs at outermost level, + // since volume has changed + + if (ilevel == nlevels_respa-1 && kspace_flag && pstat_flag) + force->kspace->setup(); +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::final_integrate_respa(int ilevel, int /*iloop*/) +{ + // set timesteps by level + + dtf = 0.5 * step_respa[ilevel] * force->ftm2v; + dthalf = 0.5 * step_respa[ilevel]; + + // outermost level - update eta_dot and omega_dot, apply via final_integrate + // all other levels - NVE update of v + + if (ilevel == nlevels_respa-1) final_integrate(); + else nve_v(); +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::couple() +{ + double *tensor = pressure->vector; + + if (pstyle == ISO) + p_current[0] = p_current[1] = p_current[2] = pressure->scalar; + else if (pcouple == XYZ) { + double ave = 1.0/3.0 * (tensor[0] + tensor[1] + tensor[2]); + p_current[0] = p_current[1] = p_current[2] = ave; + } else if (pcouple == XY) { + double ave = 0.5 * (tensor[0] + tensor[1]); + p_current[0] = p_current[1] = ave; + p_current[2] = tensor[2]; + } else if (pcouple == YZ) { + double ave = 0.5 * (tensor[1] + tensor[2]); + p_current[1] = p_current[2] = ave; + p_current[0] = tensor[0]; + } else if (pcouple == XZ) { + double ave = 0.5 * (tensor[0] + tensor[2]); + p_current[0] = p_current[2] = ave; + p_current[1] = tensor[1]; + } else { + p_current[0] = tensor[0]; + p_current[1] = tensor[1]; + p_current[2] = tensor[2]; + } + + if (!std::isfinite(p_current[0]) || !std::isfinite(p_current[1]) || !std::isfinite(p_current[2])) + error->all(FLERR,"Non-numeric pressure - simulation unstable"); + + // switch order from xy-xz-yz to Voigt + + if (pstyle == TRICLINIC) { + p_current[3] = tensor[5]; + p_current[4] = tensor[4]; + p_current[5] = tensor[3]; + + if (!std::isfinite(p_current[3]) || !std::isfinite(p_current[4]) || !std::isfinite(p_current[5])) + error->all(FLERR,"Non-numeric pressure - simulation unstable"); + } +} + +/* ---------------------------------------------------------------------- + change box size + remap all atoms or dilate group atoms depending on allremap flag + if rigid bodies exist, scale rigid body centers-of-mass +------------------------------------------------------------------------- */ + +void FixTGNHDrude::remap() +{ + int i; + double oldlo,oldhi; + double expfac; + + double **x = atom->x; + int *mask = atom->mask; + int nlocal = atom->nlocal; + double *h = domain->h; + + // omega is not used, except for book-keeping + + for (int i = 0; i < 6; i++) omega[i] += dto*omega_dot[i]; + + // convert pertinent atoms and rigid bodies to lamda coords + + domain->x2lamda(nlocal); + + if (nrigid) + for (i = 0; i < nrigid; i++) + modify->fix[rfix[i]]->deform(0); + + // reset global and local box to new size/shape + + // this operation corresponds to applying the + // translate and scale operations + // corresponding to the solution of the following ODE: + // + // h_dot = omega_dot * h + // + // where h_dot, omega_dot and h are all upper-triangular + // 3x3 tensors. In Voigt notation, the elements of the + // RHS product tensor are: + // h_dot = [0*0, 1*1, 2*2, 1*3+3*2, 0*4+5*3+4*2, 0*5+5*1] + // + // Ordering of operations preserves time symmetry. + + double dto2 = dto/2.0; + double dto4 = dto/4.0; + double dto8 = dto/8.0; + + // off-diagonal components, first half + + if (pstyle == TRICLINIC) { + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + + if (p_flag[3]) { + expfac = exp(dto4*omega_dot[1]); + h[3] *= expfac; + h[3] += dto2*(omega_dot[3]*h[2]); + h[3] *= expfac; + } + + if (p_flag[5]) { + expfac = exp(dto4*omega_dot[0]); + h[5] *= expfac; + h[5] += dto2*(omega_dot[5]*h[1]); + h[5] *= expfac; + } + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + } + + // scale diagonal components + // scale tilt factors with cell, if set + + if (p_flag[0]) { + oldlo = domain->boxlo[0]; + oldhi = domain->boxhi[0]; + expfac = exp(dto*omega_dot[0]); + domain->boxlo[0] = (oldlo-fixedpoint[0])*expfac + fixedpoint[0]; + domain->boxhi[0] = (oldhi-fixedpoint[0])*expfac + fixedpoint[0]; + } + + if (p_flag[1]) { + oldlo = domain->boxlo[1]; + oldhi = domain->boxhi[1]; + expfac = exp(dto*omega_dot[1]); + domain->boxlo[1] = (oldlo-fixedpoint[1])*expfac + fixedpoint[1]; + domain->boxhi[1] = (oldhi-fixedpoint[1])*expfac + fixedpoint[1]; + if (scalexy) h[5] *= expfac; + } + + if (p_flag[2]) { + oldlo = domain->boxlo[2]; + oldhi = domain->boxhi[2]; + expfac = exp(dto*omega_dot[2]); + domain->boxlo[2] = (oldlo-fixedpoint[2])*expfac + fixedpoint[2]; + domain->boxhi[2] = (oldhi-fixedpoint[2])*expfac + fixedpoint[2]; + if (scalexz) h[4] *= expfac; + if (scaleyz) h[3] *= expfac; + } + + // off-diagonal components, second half + + if (pstyle == TRICLINIC) { + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + + if (p_flag[3]) { + expfac = exp(dto4*omega_dot[1]); + h[3] *= expfac; + h[3] += dto2*(omega_dot[3]*h[2]); + h[3] *= expfac; + } + + if (p_flag[5]) { + expfac = exp(dto4*omega_dot[0]); + h[5] *= expfac; + h[5] += dto2*(omega_dot[5]*h[1]); + h[5] *= expfac; + } + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + + } + + domain->yz = h[3]; + domain->xz = h[4]; + domain->xy = h[5]; + + // tilt factor to cell length ratio can not exceed TILTMAX in one step + + if (domain->yz < -TILTMAX*domain->yprd || + domain->yz > TILTMAX*domain->yprd || + domain->xz < -TILTMAX*domain->xprd || + domain->xz > TILTMAX*domain->xprd || + domain->xy < -TILTMAX*domain->xprd || + domain->xy > TILTMAX*domain->xprd) + error->all(FLERR,"Fix npt/nph has tilted box too far in one step - " + "periodic cell is too far from equilibrium state"); + + domain->set_global_box(); + domain->set_local_box(); + + // convert pertinent atoms and rigid bodies back to box coords + + domain->lamda2x(nlocal); + + if (nrigid) + for (i = 0; i < nrigid; i++) + modify->fix[rfix[i]]->deform(1); +} + +/* ---------------------------------------------------------------------- + pack entire state of Fix into one write +------------------------------------------------------------------------- */ + +void FixTGNHDrude::write_restart(FILE *fp) +{ + int nsize = size_restart_global(); + + double *list; + memory->create(list,nsize,"nh:list"); + + pack_restart_data(list); + + if (comm->me == 0) { + int size = nsize * sizeof(double); + fwrite(&size,sizeof(int),1,fp); + fwrite(list,sizeof(double),nsize,fp); + } + + memory->destroy(list); +} + +/* ---------------------------------------------------------------------- + calculate the number of data to be packed +------------------------------------------------------------------------- */ + +int FixTGNHDrude::size_restart_global() +{ + int nsize = 2; + if (tstat_flag) nsize += 1 + 6*mtchain; + if (pstat_flag) { + nsize += 16 + 2*mpchain; + if (deviatoric_flag) nsize += 6; + } + + return nsize; +} + +/* ---------------------------------------------------------------------- + pack restart data +------------------------------------------------------------------------- */ + +int FixTGNHDrude::pack_restart_data(double *list) +{ + int n = 0; + + list[n++] = tstat_flag; + if (tstat_flag) { + list[n++] = mtchain; + for (int ich = 0; ich < mtchain; ich++){ + list[n++] = etamol[ich]; + list[n++] = etaint[ich]; + list[n++] = etadrude[ich]; + } + for (int ich = 0; ich < mtchain; ich++) { + list[n++] = etamol_dot[ich]; + list[n++] = etaint_dot[ich]; + list[n++] = etadrude_dot[ich]; + } + } + + list[n++] = pstat_flag; + if (pstat_flag) { + list[n++] = omega[0]; + list[n++] = omega[1]; + list[n++] = omega[2]; + list[n++] = omega[3]; + list[n++] = omega[4]; + list[n++] = omega[5]; + list[n++] = omega_dot[0]; + list[n++] = omega_dot[1]; + list[n++] = omega_dot[2]; + list[n++] = omega_dot[3]; + list[n++] = omega_dot[4]; + list[n++] = omega_dot[5]; + list[n++] = vol0; + list[n++] = t0; + list[n++] = mpchain; + if (mpchain) { + for (int ich = 0; ich < mpchain; ich++) + list[n++] = etap[ich]; + for (int ich = 0; ich < mpchain; ich++) + list[n++] = etap_dot[ich]; + } + + list[n++] = deviatoric_flag; + if (deviatoric_flag) { + list[n++] = h0_inv[0]; + list[n++] = h0_inv[1]; + list[n++] = h0_inv[2]; + list[n++] = h0_inv[3]; + list[n++] = h0_inv[4]; + list[n++] = h0_inv[5]; + } + } + + return n; +} + +/* ---------------------------------------------------------------------- + use state info from restart file to restart the Fix +------------------------------------------------------------------------- */ + +void FixTGNHDrude::restart(char *buf) +{ + int n = 0; + double *list = (double *) buf; + int flag = static_cast (list[n++]); + if (flag) { + int m = static_cast (list[n++]); + if (tstat_flag && m == mtchain) { + for (int ich = 0; ich < mtchain; ich++){ + etamol[ich] = list[n++]; + etaint[ich] = list[n++]; + etadrude[ich] = list[n++]; + } + for (int ich = 0; ich < mtchain; ich++){ + etamol_dot[ich] = list[n++]; + etaint_dot[ich] = list[n++]; + etadrude_dot[ich] = list[n++]; + } + } else n += 2*m; + } + flag = static_cast (list[n++]); + if (flag) { + omega[0] = list[n++]; + omega[1] = list[n++]; + omega[2] = list[n++]; + omega[3] = list[n++]; + omega[4] = list[n++]; + omega[5] = list[n++]; + omega_dot[0] = list[n++]; + omega_dot[1] = list[n++]; + omega_dot[2] = list[n++]; + omega_dot[3] = list[n++]; + omega_dot[4] = list[n++]; + omega_dot[5] = list[n++]; + vol0 = list[n++]; + t0 = list[n++]; + int m = static_cast (list[n++]); + if (pstat_flag && m == mpchain) { + for (int ich = 0; ich < mpchain; ich++) + etap[ich] = list[n++]; + for (int ich = 0; ich < mpchain; ich++) + etap_dot[ich] = list[n++]; + } else n+=2*m; + flag = static_cast (list[n++]); + if (flag) { + h0_inv[0] = list[n++]; + h0_inv[1] = list[n++]; + h0_inv[2] = list[n++]; + h0_inv[3] = list[n++]; + h0_inv[4] = list[n++]; + h0_inv[5] = list[n++]; + } + } +} + +/* ---------------------------------------------------------------------- */ + +int FixTGNHDrude::modify_param(int narg, char **arg) +{ + if (strcmp(arg[0],"temp") == 0) { + if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + if (tcomputeflag) { + modify->delete_compute(id_temp); + tcomputeflag = 0; + } + delete [] id_temp; + int n = strlen(arg[1]) + 1; + id_temp = new char[n]; + strcpy(id_temp,arg[1]); + + int icompute = modify->find_compute(arg[1]); + if (icompute < 0) + error->all(FLERR,"Could not find fix_modify temperature ID"); + temperature = modify->compute[icompute]; + + if (temperature->tempflag == 0) + error->all(FLERR, + "Fix_modify temperature ID does not compute temperature"); + if (temperature->igroup != 0 && comm->me == 0) + error->warning(FLERR,"Temperature for fix modify is not for group all"); + + // reset id_temp of pressure to new temperature ID + + if (pstat_flag) { + icompute = modify->find_compute(id_press); + if (icompute < 0) + error->all(FLERR,"Pressure ID for fix modify does not exist"); + modify->compute[icompute]->reset_extra_compute_fix(id_temp); + } + + return 2; + + } else if (strcmp(arg[0],"press") == 0) { + if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + if (!pstat_flag) error->all(FLERR,"Illegal fix_modify command"); + if (pcomputeflag) { + modify->delete_compute(id_press); + pcomputeflag = 0; + } + delete [] id_press; + int n = strlen(arg[1]) + 1; + id_press = new char[n]; + strcpy(id_press,arg[1]); + + int icompute = modify->find_compute(arg[1]); + if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); + pressure = modify->compute[icompute]; + + if (pressure->pressflag == 0) + error->all(FLERR,"Fix_modify pressure ID does not compute pressure"); + return 2; + } + + return 0; +} + +/* ---------------------------------------------------------------------- */ + +double FixTGNHDrude::compute_scalar() +{ + int i; + double volume; + double energy; + double kt = boltz * t_target; + double kt_drude = boltz * tdrude_target; + double lkt_press = 0.0; + int ich; + if (dimension == 3) volume = domain->xprd * domain->yprd * domain->zprd; + else volume = domain->xprd * domain->yprd; + + energy = 0.0; + + // thermostat chain energy is equivalent to Eq. (2) in + // Martyna, Tuckerman, Tobias, Klein, Mol Phys, 87, 1117 + // Sum(0.5*p_eta_k^2/Q_k,k=1,M) + L*k*T*eta_1 + Sum(k*T*eta_k,k=2,M), + // where L = tdof + // M = mtchain + // p_eta_k = Q_k*eta_dot[k-1] + // Q_1 = L*k*T/t_freq^2 + // Q_k = k*T/t_freq^2, k > 1 + + if (tstat_flag) { + energy += ke2mol_target * etamol[0] + 0.5 * etamol_mass[0] * etamol_dot[0] * etamol_dot[0]; + energy += ke2int_target * etaint[0] + 0.5 * etaint_mass[0] * etaint_dot[0] * etaint_dot[0]; + energy += ke2drude_target * etadrude[0] + 0.5 * etadrude_mass[0] * etadrude_dot[0] * etadrude_dot[0]; + for (ich = 1; ich < mtchain; ich++){ + energy += kt * etamol[ich] + 0.5*etamol_mass[ich]*etamol_dot[ich]*etamol_dot[ich]; + energy += kt * etaint[ich] + 0.5*etaint_mass[ich]*etaint_dot[ich]*etaint_dot[ich]; + energy += kt_drude * etadrude[ich] + 0.5*etadrude_mass[ich]*etadrude_dot[ich]*etadrude_dot[ich]; + } + } + + // barostat energy is equivalent to Eq. (8) in + // Martyna, Tuckerman, Tobias, Klein, Mol Phys, 87, 1117 + // Sum(0.5*p_omega^2/W + P*V), + // where N = natoms + // p_omega = W*omega_dot + // W = N*k*T/p_freq^2 + // sum is over barostatted dimensions + + if (pstat_flag) { + for (i = 0; i < 3; i++) { + if (p_flag[i]) { + energy += 0.5*omega_dot[i]*omega_dot[i]*omega_mass[i] + + p_hydro*(volume-vol0) / (pdim*nktv2p); + lkt_press += kt; + } + } + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) { + if (p_flag[i]) { + energy += 0.5*omega_dot[i]*omega_dot[i]*omega_mass[i]; + lkt_press += kt; + } + } + } + + // extra contributions from thermostat chain for barostat + + if (mpchain) { + energy += lkt_press * etap[0] + 0.5*etap_mass[0]*etap_dot[0]*etap_dot[0]; + for (ich = 1; ich < mpchain; ich++) + energy += kt * etap[ich] + + 0.5*etap_mass[ich]*etap_dot[ich]*etap_dot[ich]; + } + + // extra contribution from strain energy + + if (deviatoric_flag) energy += compute_strain_energy(); + } + + return energy; +} + +/* ---------------------------------------------------------------------- */ + +double FixTGNHDrude::compute_vector(int n) +{ + switch (n){ + case 0: + return t_mol; + case 1: + return t_int; + case 2: + return t_drude; + default: + return 0.0; + } +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::reset_target(double t_new) +{ + t_target = t_start = t_stop = t_new; +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dthalf = 0.5 * update->dt; + dt4 = 0.25 * update->dt; + dt8 = 0.125 * update->dt; + dto = dthalf; + + // If using respa, then remap is performed in innermost level + + if (strstr(update->integrate_style,"respa")) + dto = 0.5*step_respa[0]; +} + +void FixTGNHDrude::compute_temp_mol_int_drude() { + double **v = atom->v; + double *mass = atom->mass; + int *molecule = atom->molecule; + int *type = atom->type; + int *mask = atom->mask; + int *drudetype = fix_drude->drudetype; + int *drudeid = fix_drude->drudeid; + int imol, ci, di; + double mass_com, mass_reduced, mass_core, mass_drude; + double vint, vcom, vrel; + // use array instead of two numbers to save MPI_Allreduce() + double ke2_int_drude_tmp[2] = {0.0, 0.0}; + double ke2_int_drude[2]; + + memset(*v_mol_tmp, 0, sizeof(double) * (n_mol + 1) * 3); // the length of v_mol is n_mol+1 + + /** + * If there are velocity bias, need to remove them before calculate kinetic energies + */ + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + if (which == BIAS) + temperature->remove_bias(i, v[i]); + + imol = molecule[i]; + for (int k = 0; k < 3; k++) + v_mol_tmp[imol][k] += v[i][k] * mass[type[i]]; + + if (which == BIAS) + temperature->restore_bias(i, v[i]); + } + } + MPI_Allreduce(*v_mol_tmp, *v_mol, (n_mol + 1) * 3, MPI_DOUBLE, MPI_SUM, world); + + ke2mol = 0; + for (int i = 1; i < n_mol + 1; i++) { + for (int k = 0; k < 3; k++) { + v_mol[i][k] /= mass_mol[i]; + ke2mol += mass_mol[i] * (v_mol[i][k] * v_mol[i][k]); + } + } + ke2mol *= force->mvv2e; + t_mol = ke2mol / dof_mol / boltz; + + /** + * Have to call remove_bias at the innermost loop, because drude atom may be a ghost + */ + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + imol = molecule[i]; + if (drudetype[type[i]] == NOPOL_TYPE) { + if (which == BIAS) + temperature->remove_bias(i, v[i]); + for (int k = 0; k < 3; k++) { + vint = v[i][k] - v_mol[imol][k]; + ke2_int_drude_tmp[0] += mass[type[i]] * vint * vint; + } + if (which == BIAS) + temperature->restore_bias(i, v[i]); + } else if (drudetype[type[i]] == CORE_TYPE) { + /** + * have to use closet_image() + * even though all images have the same velocity and it's sort of read-only + * but the bias velocity may depends on it's position like in compute vis/pp + */ + ci = i; + di = domain->closest_image(i, atom->map(drudeid[i])); + if (which == BIAS) { + temperature->remove_bias(ci, v[ci]); + temperature->remove_bias(di, v[di]); + } + mass_core = mass[type[ci]]; + mass_drude = mass[type[di]]; + mass_com = mass_core + mass_drude; + mass_reduced = mass_core * mass_drude / mass_com; + for (int k = 0; k < 3; k++) { + vcom = (mass_core * v[ci][k] + mass_drude * v[di][k]) / mass_com; + vint = vcom - v_mol[imol][k]; + ke2_int_drude_tmp[0] += mass_com * vint * vint; + vrel = v[di][k] - v[ci][k]; + ke2_int_drude_tmp[1] += mass_reduced * vrel * vrel; + } + if (which == BIAS) { + temperature->restore_bias(ci, v[ci]); + temperature->restore_bias(di, v[di]); + } + } + } + } + MPI_Allreduce(ke2_int_drude_tmp, ke2_int_drude, 2, MPI_DOUBLE, MPI_SUM, world); + ke2int = ke2_int_drude[0] * force->mvv2e; + ke2drude = ke2_int_drude[1] * force->mvv2e; + t_int = ke2int / dof_int / boltz; + t_drude = ke2drude / dof_drude / boltz; +} + +/* ---------------------------------------------------------------------- + perform half-step update of chain thermostat variables +------------------------------------------------------------------------- */ + +void FixTGNHDrude::nhc_temp_integrate() +{ + compute_temp_mol_int_drude(); + + // update masses of thermostat in case target temperature changes + etamol_mass[0] = ke2mol_target / (t_freq*t_freq); + etaint_mass[0] = ke2int_target / (t_freq*t_freq); + for (int ich = 1; ich < mtchain; ich++){ + etamol_mass[ich] = boltz * t_target / (t_freq*t_freq); + etaint_mass[ich] = boltz * t_target / (t_freq*t_freq); + } + + // thermostat for molecular COM + factor_eta_mol = propagate(etamol, etamol_dot, etamol_dotdot, etamol_mass, + ke2mol, ke2mol_target, t_target); + factor_eta_int = propagate(etaint, etaint_dot, etaint_dotdot, etaint_mass, + ke2int, ke2int_target, t_target); + factor_eta_drude = propagate(etadrude, etadrude_dot, etadrude_dotdot, etadrude_mass, + ke2drude, ke2drude_target, tdrude_target); + + nh_v_temp(); +} + +double FixTGNHDrude::propagate(double *eta, double *eta_dot, double *eta_dotdot, const double *eta_mass, + double ke2, double ke2_target, double tt) { + int ich; + double expfac; + double ncfac = 1.0 / nc_tchain; + double factor_eta = 1.0; + + eta_dotdot[0] = (ke2 - ke2_target) / eta_mass[0]; + for (int iloop = 0; iloop < nc_tchain; iloop++) { + for (ich = mtchain - 1; ich > 0; ich--) { + expfac = exp(-ncfac * dt8 * eta_dot[ich + 1]); + eta_dot[ich] *= expfac; + eta_dot[ich] += eta_dotdot[ich] * ncfac * dt4; + eta_dot[ich] *= expfac; + } + expfac = exp(-ncfac * dt8 * eta_dot[1]); + eta_dot[0] *= expfac; + eta_dot[0] += eta_dotdot[0] * ncfac * dt4; + eta_dot[0] *= expfac; + factor_eta *= exp(-ncfac * dthalf * eta_dot[0]); + + for (ich = 0; ich < mtchain; ich++) + eta[ich] += ncfac * dthalf * eta_dot[ich]; + + eta_dotdot[0] = (ke2 * factor_eta * factor_eta - ke2_target) / eta_mass[0]; + eta_dot[0] *= expfac; + eta_dot[0] += eta_dotdot[0] * ncfac * dt4; + eta_dot[0] *= expfac; + for (ich = 1; ich < mtchain; ich++) { + expfac = exp(-ncfac * dt8 * eta_dot[ich + 1]); + eta_dot[ich] *= expfac; + eta_dotdot[ich] = (eta_mass[ich - 1] * eta_dot[ich - 1] * eta_dot[ich - 1] + - boltz * tt) / eta_mass[ich]; + eta_dot[ich] += eta_dotdot[ich] * ncfac * dt4; + eta_dot[ich] *= expfac; + } + } + return factor_eta; +} + +/* ---------------------------------------------------------------------- + perform half-step update of chain thermostat variables for barostat + scale barostat velocities +------------------------------------------------------------------------- */ + +void FixTGNHDrude::nhc_press_integrate() +{ + int ich,i,pdof; + double expfac,factor_etap,kecurrent; + double kt = boltz * t_target; + double lkt_press; + + // Update masses, to preserve initial freq, if t_target changed + double nkt = (atom->natoms + 1) * kt; + for (int i = 0; i < 3; i++) + if (p_flag[i]) + omega_mass[i] = nkt / (p_freq[i] * p_freq[i]); + if (pstyle == TRICLINIC) { + for (int i = 3; i < 6; i++) + if (p_flag[i]) omega_mass[i] = nkt / (p_freq[i] * p_freq[i]); + } + if (mpchain) { + etap_mass[0] = kt / (p_freq_max * p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_mass[ich] = kt / (p_freq_max * p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_dotdot[ich] = (etap_mass[ich - 1] * etap_dot[ich - 1] * etap_dot[ich - 1] + - kt) / etap_mass[ich]; + } + + kecurrent = 0.0; + pdof = 0; + for (i = 0; i < 3; i++) + if (p_flag[i]) { + kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + pdof++; + } + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) + if (p_flag[i]) { + kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + pdof++; + } + } + + if (pstyle == ISO) lkt_press = kt; + else lkt_press = pdof * kt; + etap_dotdot[0] = (kecurrent - lkt_press)/etap_mass[0]; + + double ncfac = 1.0/nc_pchain; + for (int iloop = 0; iloop < nc_pchain; iloop++) { + + for (ich = mpchain-1; ich > 0; ich--) { + expfac = exp(-ncfac*dt8*etap_dot[ich+1]); + etap_dot[ich] *= expfac; + etap_dot[ich] += etap_dotdot[ich] * ncfac*dt4; + etap_dot[ich] *= expfac; + } + + expfac = exp(-ncfac*dt8*etap_dot[1]); + etap_dot[0] *= expfac; + etap_dot[0] += etap_dotdot[0] * ncfac*dt4; + etap_dot[0] *= expfac; + + for (ich = 0; ich < mpchain; ich++) + etap[ich] += ncfac*dthalf*etap_dot[ich]; + + factor_etap = exp(-ncfac*dthalf*etap_dot[0]); + for (i = 0; i < 3; i++) + if (p_flag[i]) omega_dot[i] *= factor_etap; + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) + if (p_flag[i]) omega_dot[i] *= factor_etap; + } + + kecurrent = 0.0; + for (i = 0; i < 3; i++) + if (p_flag[i]) kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) + if (p_flag[i]) kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + } + + etap_dotdot[0] = (kecurrent - lkt_press)/etap_mass[0]; + + etap_dot[0] *= expfac; + etap_dot[0] += etap_dotdot[0] * ncfac*dt4; + etap_dot[0] *= expfac; + + for (ich = 1; ich < mpchain; ich++) { + expfac = exp(-ncfac*dt8*etap_dot[ich+1]); + etap_dot[ich] *= expfac; + etap_dotdot[ich] = + (etap_mass[ich-1]*etap_dot[ich-1]*etap_dot[ich-1] - kt) / etap_mass[ich]; + etap_dot[ich] += etap_dotdot[ich] * ncfac*dt4; + etap_dot[ich] *= expfac; + } + } +} + +/* ---------------------------------------------------------------------- + perform half-step barostat scaling of velocities +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nh_v_press() +{ + double factor[3]; + double **v = atom->v; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + + factor[0] = exp(-dt4*(omega_dot[0]+mtk_term2)); + factor[1] = exp(-dt4*(omega_dot[1]+mtk_term2)); + factor[2] = exp(-dt4*(omega_dot[2]+mtk_term2)); + + if (which == NOBIAS) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + if (pstyle == TRICLINIC) { + v[i][0] += -dthalf*(v[i][1]*omega_dot[5] + v[i][2]*omega_dot[4]); + v[i][1] += -dthalf*v[i][2]*omega_dot[3]; + } + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + } + } + } else if (which == BIAS) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + temperature->remove_bias(i,v[i]); + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + if (pstyle == TRICLINIC) { + v[i][0] += -dthalf*(v[i][1]*omega_dot[5] + v[i][2]*omega_dot[4]); + v[i][1] += -dthalf*v[i][2]*omega_dot[3]; + } + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + temperature->restore_bias(i,v[i]); + } + } + } +} + +/* ---------------------------------------------------------------------- + perform half-step update of velocities +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nve_v() +{ + double dtfm; + double **v = atom->v; + double **f = atom->f; + double *rmass = atom->rmass; + double *mass = atom->mass; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + + if (rmass) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / rmass[i]; + v[i][0] += dtfm*f[i][0]; + v[i][1] += dtfm*f[i][1]; + v[i][2] += dtfm*f[i][2]; + } + } + } else { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / mass[type[i]]; + v[i][0] += dtfm*f[i][0]; + v[i][1] += dtfm*f[i][1]; + v[i][2] += dtfm*f[i][2]; + } + } + } +} + +/* ---------------------------------------------------------------------- + perform full-step update of positions +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nve_x() +{ + double **x = atom->x; + double **v = atom->v; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + + // x update by full step only for atoms in group + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + x[i][0] += dtv * v[i][0]; + x[i][1] += dtv * v[i][1]; + x[i][2] += dtv * v[i][2]; + } + } +} + +/* ---------------------------------------------------------------------- + perform half-step thermostat scaling of velocities +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nh_v_temp() +{ + double **v = atom->v; + double *mass = atom->mass; + int *mask = atom->mask; + int *type = atom->type; + int *molecule = atom->molecule; + int *drudetype = fix_drude->drudetype; + int *drudeid = fix_drude->drudeid; + + int imol, i, j, ci, di, itype; + double mass_com, mass_core, mass_drude; + double vint, vcom, vrel; + + /** + * If there are velocity bias, need to remove them before scale velocity + * Have to call remove_bias at the innermost loop, because drude atom may be a ghost + */ + for (i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + imol = molecule[i]; + itype = drudetype[type[i]]; + if (itype == NOPOL_TYPE) { + if (which == BIAS) + temperature->remove_bias(i, v[i]); + for (int k = 0; k < 3; k++) { + vint = v[i][k] - v_mol[imol][k]; + vint *= factor_eta_int; + v[i][k] = v_mol[imol][k] * factor_eta_mol + vint; + } + if (which == BIAS) + temperature->restore_bias(i, v[i]); + } else { + // have to use closest_image() because we are manipulating the velocity + j = domain->closest_image(i, atom->map(drudeid[i])); + if (itype == DRUDE_TYPE && j < atom->nlocal) continue; + if (itype == CORE_TYPE) { + ci = i; + di = j; + } else { + ci = j; + di = i; + } + if (which == BIAS) { + temperature->remove_bias(ci, v[ci]); + temperature->remove_bias(di, v[di]); + } + mass_core = mass[type[ci]]; + mass_drude = mass[type[di]]; + mass_com = mass_core + mass_drude; + for (int k = 0; k < 3; k++) { + vcom = (mass_core * v[ci][k] + mass_drude * v[di][k]) / mass_com; + vint = vcom - v_mol[imol][k]; + vrel = v[di][k] - v[ci][k]; + vint *= factor_eta_int; + vrel *= factor_eta_drude; + v[ci][k] = v_mol[imol][k] * factor_eta_mol + vint - vrel * mass_drude / mass_com; + v[di][k] = v_mol[imol][k] * factor_eta_mol + vint + vrel * mass_core / mass_com; + } + if (which == BIAS) { + temperature->restore_bias(ci, v[ci]); + temperature->restore_bias(di, v[di]); + } + } + } + } +} + +/* ---------------------------------------------------------------------- + compute sigma tensor + needed whenever p_target or h0_inv changes +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_sigma() +{ + // if nreset_h0 > 0, reset vol0 and h0_inv + // every nreset_h0 timesteps + + if (nreset_h0 > 0) { + int delta = update->ntimestep - update->beginstep; + if (delta % nreset_h0 == 0) { + if (dimension == 3) vol0 = domain->xprd * domain->yprd * domain->zprd; + else vol0 = domain->xprd * domain->yprd; + h0_inv[0] = domain->h_inv[0]; + h0_inv[1] = domain->h_inv[1]; + h0_inv[2] = domain->h_inv[2]; + h0_inv[3] = domain->h_inv[3]; + h0_inv[4] = domain->h_inv[4]; + h0_inv[5] = domain->h_inv[5]; + } + } + + // generate upper-triangular half of + // sigma = vol0*h0inv*(p_target-p_hydro)*h0inv^t + // units of sigma are are PV/L^2 e.g. atm.A + // + // [ 0 5 4 ] [ 0 5 4 ] [ 0 5 4 ] [ 0 - - ] + // [ 5 1 3 ] = [ - 1 3 ] [ 5 1 3 ] [ 5 1 - ] + // [ 4 3 2 ] [ - - 2 ] [ 4 3 2 ] [ 4 3 2 ] + + sigma[0] = + vol0*(h0_inv[0]*((p_target[0]-p_hydro)*h0_inv[0] + + p_target[5]*h0_inv[5]+p_target[4]*h0_inv[4]) + + h0_inv[5]*(p_target[5]*h0_inv[0] + + (p_target[1]-p_hydro)*h0_inv[5]+p_target[3]*h0_inv[4]) + + h0_inv[4]*(p_target[4]*h0_inv[0]+p_target[3]*h0_inv[5] + + (p_target[2]-p_hydro)*h0_inv[4])); + sigma[1] = + vol0*(h0_inv[1]*((p_target[1]-p_hydro)*h0_inv[1] + + p_target[3]*h0_inv[3]) + + h0_inv[3]*(p_target[3]*h0_inv[1] + + (p_target[2]-p_hydro)*h0_inv[3])); + sigma[2] = + vol0*(h0_inv[2]*((p_target[2]-p_hydro)*h0_inv[2])); + sigma[3] = + vol0*(h0_inv[1]*(p_target[3]*h0_inv[2]) + + h0_inv[3]*((p_target[2]-p_hydro)*h0_inv[2])); + sigma[4] = + vol0*(h0_inv[0]*(p_target[4]*h0_inv[2]) + + h0_inv[5]*(p_target[3]*h0_inv[2]) + + h0_inv[4]*((p_target[2]-p_hydro)*h0_inv[2])); + sigma[5] = + vol0*(h0_inv[0]*(p_target[5]*h0_inv[1]+p_target[4]*h0_inv[3]) + + h0_inv[5]*((p_target[1]-p_hydro)*h0_inv[1]+p_target[3]*h0_inv[3]) + + h0_inv[4]*(p_target[3]*h0_inv[1]+(p_target[2]-p_hydro)*h0_inv[3])); +} + +/* ---------------------------------------------------------------------- + compute strain energy +-----------------------------------------------------------------------*/ + +double FixTGNHDrude::compute_strain_energy() +{ + // compute strain energy = 0.5*Tr(sigma*h*h^t) in energy units + + double* h = domain->h; + double d0,d1,d2; + + d0 = + sigma[0]*(h[0]*h[0]+h[5]*h[5]+h[4]*h[4]) + + sigma[5]*( h[1]*h[5]+h[3]*h[4]) + + sigma[4]*( h[2]*h[4]); + d1 = + sigma[5]*( h[5]*h[1]+h[4]*h[3]) + + sigma[1]*( h[1]*h[1]+h[3]*h[3]) + + sigma[3]*( h[2]*h[3]); + d2 = + sigma[4]*( h[4]*h[2]) + + sigma[3]*( h[3]*h[2]) + + sigma[2]*( h[2]*h[2]); + + double energy = 0.5*(d0+d1+d2)/nktv2p; + return energy; +} + +/* ---------------------------------------------------------------------- + compute deviatoric barostat force = h*sigma*h^t +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_deviatoric() +{ + // generate upper-triangular part of h*sigma*h^t + // units of fdev are are PV, e.g. atm*A^3 + // [ 0 5 4 ] [ 0 5 4 ] [ 0 5 4 ] [ 0 - - ] + // [ 5 1 3 ] = [ - 1 3 ] [ 5 1 3 ] [ 5 1 - ] + // [ 4 3 2 ] [ - - 2 ] [ 4 3 2 ] [ 4 3 2 ] + + double* h = domain->h; + + fdev[0] = + h[0]*(sigma[0]*h[0]+sigma[5]*h[5]+sigma[4]*h[4]) + + h[5]*(sigma[5]*h[0]+sigma[1]*h[5]+sigma[3]*h[4]) + + h[4]*(sigma[4]*h[0]+sigma[3]*h[5]+sigma[2]*h[4]); + fdev[1] = + h[1]*( sigma[1]*h[1]+sigma[3]*h[3]) + + h[3]*( sigma[3]*h[1]+sigma[2]*h[3]); + fdev[2] = + h[2]*( sigma[2]*h[2]); + fdev[3] = + h[1]*( sigma[3]*h[2]) + + h[3]*( sigma[2]*h[2]); + fdev[4] = + h[0]*( sigma[4]*h[2]) + + h[5]*( sigma[3]*h[2]) + + h[4]*( sigma[2]*h[2]); + fdev[5] = + h[0]*( sigma[5]*h[1]+sigma[4]*h[3]) + + h[5]*( sigma[1]*h[1]+sigma[3]*h[3]) + + h[4]*( sigma[3]*h[1]+sigma[2]*h[3]); +} + +/* ---------------------------------------------------------------------- + compute target temperature and kinetic energy +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_temp_target() +{ + double delta = update->ntimestep - update->beginstep; + if (delta != 0.0) delta /= update->endstep - update->beginstep; + + t_target = t_start + delta * (t_stop-t_start); + ke2mol_target = dof_mol * boltz * t_target; + ke2int_target = dof_int * boltz * t_target; + ke2drude_target = dof_drude * boltz * tdrude_target; +} + +/* ---------------------------------------------------------------------- + compute hydrostatic target pressure +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_press_target() +{ + double delta = update->ntimestep - update->beginstep; + if (delta != 0.0) delta /= update->endstep - update->beginstep; + + p_hydro = 0.0; + for (int i = 0; i < 3; i++) + if (p_flag[i]) { + p_target[i] = p_start[i] + delta * (p_stop[i]-p_start[i]); + p_hydro += p_target[i]; + } + if (pdim > 0) p_hydro /= pdim; + + if (pstyle == TRICLINIC) + for (int i = 3; i < 6; i++) + p_target[i] = p_start[i] + delta * (p_stop[i]-p_start[i]); + + // if deviatoric, recompute sigma each time p_target changes + + if (deviatoric_flag) compute_sigma(); +} + +/* ---------------------------------------------------------------------- + update omega_dot, omega +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nh_omega_dot() +{ + double f_omega,volume; + + if (dimension == 3) volume = domain->xprd*domain->yprd*domain->zprd; + else volume = domain->xprd*domain->yprd; + + if (deviatoric_flag) compute_deviatoric(); + + mtk_term1 = 0.0; + if (mtk_flag) { + if (pstyle == ISO) { + mtk_term1 = _tdof * boltz * t_current; + mtk_term1 /= pdim * atom->natoms; + } else { + double *mvv_current = temperature->vector; + for (int i = 0; i < 3; i++) + if (p_flag[i]) + mtk_term1 += mvv_current[i]; + mtk_term1 /= pdim * atom->natoms; + } + } + + for (int i = 0; i < 3; i++) + if (p_flag[i]) { + f_omega = (p_current[i]-p_hydro)*volume / + (omega_mass[i] * nktv2p) + mtk_term1 / omega_mass[i]; + if (deviatoric_flag) f_omega -= fdev[i]/(omega_mass[i] * nktv2p); + omega_dot[i] += f_omega*dthalf; + } + + mtk_term2 = 0.0; + if (mtk_flag) { + for (int i = 0; i < 3; i++) + if (p_flag[i]) + mtk_term2 += omega_dot[i]; + if (pdim > 0) mtk_term2 /= pdim * atom->natoms; + } + + if (pstyle == TRICLINIC) { + for (int i = 3; i < 6; i++) { + if (p_flag[i]) { + f_omega = p_current[i]*volume/(omega_mass[i] * nktv2p); + if (deviatoric_flag) + f_omega -= fdev[i]/(omega_mass[i] * nktv2p); + omega_dot[i] += f_omega*dthalf; + } + } + } +} + +/* ---------------------------------------------------------------------- + if any tilt ratios exceed limits, set flip = 1 and compute new tilt values + do not flip in x or y if non-periodic (can tilt but not flip) + this is b/c the box length would be changed (dramatically) by flip + if yz tilt exceeded, adjust C vector by one B vector + if xz tilt exceeded, adjust C vector by one A vector + if xy tilt exceeded, adjust B vector by one A vector + check yz first since it may change xz, then xz check comes after + if any flip occurs, create new box in domain + image_flip() adjusts image flags due to box shape change induced by flip + remap() puts atoms outside the new box back into the new box + perform irregular on atoms in lamda coords to migrate atoms to new procs + important that image_flip comes before remap, since remap may change + image flags to new values, making eqs in doc of Domain:image_flip incorrect +------------------------------------------------------------------------- */ + +void FixTGNHDrude::pre_exchange() +{ + double xprd = domain->xprd; + double yprd = domain->yprd; + + // flip is only triggered when tilt exceeds 0.5 by DELTAFLIP + // this avoids immediate re-flipping due to tilt oscillations + + double xtiltmax = (0.5+DELTAFLIP)*xprd; + double ytiltmax = (0.5+DELTAFLIP)*yprd; + + int flipxy,flipxz,flipyz; + flipxy = flipxz = flipyz = 0; + + if (domain->yperiodic) { + if (domain->yz < -ytiltmax) { + domain->yz += yprd; + domain->xz += domain->xy; + flipyz = 1; + } else if (domain->yz >= ytiltmax) { + domain->yz -= yprd; + domain->xz -= domain->xy; + flipyz = -1; + } + } + + if (domain->xperiodic) { + if (domain->xz < -xtiltmax) { + domain->xz += xprd; + flipxz = 1; + } else if (domain->xz >= xtiltmax) { + domain->xz -= xprd; + flipxz = -1; + } + if (domain->xy < -xtiltmax) { + domain->xy += xprd; + flipxy = 1; + } else if (domain->xy >= xtiltmax) { + domain->xy -= xprd; + flipxy = -1; + } + } + + int flip = 0; + if (flipxy || flipxz || flipyz) flip = 1; + + if (flip) { + domain->set_global_box(); + domain->set_local_box(); + + domain->image_flip(flipxy,flipxz,flipyz); + + double **x = atom->x; + imageint *image = atom->image; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) domain->remap(x[i],image[i]); + + domain->x2lamda(atom->nlocal); + irregular->migrate_atoms(); + domain->lamda2x(atom->nlocal); + } +} + +/* ---------------------------------------------------------------------- + memory usage of Irregular +------------------------------------------------------------------------- */ + +double FixTGNHDrude::memory_usage() +{ + double bytes = 0.0; + if (irregular) bytes += irregular->memory_usage(); + return bytes; +} diff --git a/src/USER-DRUDE/fix_tgnh_drude.h b/src/USER-DRUDE/fix_tgnh_drude.h new file mode 100644 index 0000000000..c86ca1f56f --- /dev/null +++ b/src/USER-DRUDE/fix_tgnh_drude.h @@ -0,0 +1,294 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_FIX_TGNH_DRUDE_H +#define LMP_FIX_TGNH_DRUDE_H + +#include "fix.h" +#include "fix_drude.h" + +namespace LAMMPS_NS { + +class FixTGNHDrude : public Fix { + public: + FixTGNHDrude(class LAMMPS *, int, char **); + virtual ~FixTGNHDrude(); + int setmask(); + virtual void init(); + virtual void setup(int); + virtual void initial_integrate(int); + virtual void final_integrate(); + void initial_integrate_respa(int, int, int); + void final_integrate_respa(int, int); + virtual void pre_exchange(); + double compute_scalar(); + virtual double compute_vector(int); + void write_restart(FILE *); + virtual int pack_restart_data(double *); // pack restart data + virtual void restart(char *); + int modify_param(int, char **); + void reset_target(double); + void reset_dt(); + double memory_usage(); + + protected: + int dimension,which; + double dtv,dtf,dthalf,dt4,dt8,dto; + double boltz,nktv2p,_tdof; + double vol0; // reference volume + double t0; // reference temperature + // used for barostat mass + double t_start,t_stop; + double t_current,t_target; + double t_freq; + + int tstat_flag; // 1 if control T + int pstat_flag; // 1 if control P + + int pstyle,pcouple; + int p_flag[6]; // 1 if control P on this dim, 0 if not + double p_start[6],p_stop[6]; + double p_freq[6],p_target[6]; + double omega[6],omega_dot[6]; + double omega_mass[6]; + double p_current[6]; + int kspace_flag; // 1 if KSpace invoked, 0 if not + int nrigid; // number of rigid fixes + int *rfix; // indices of rigid fixes + class Irregular *irregular; // for migrating atoms after box flips + + int nlevels_respa; + double *step_respa; + + char *id_temp,*id_press; + class Compute *temperature,*pressure; + int tcomputeflag,pcomputeflag; // 1 = compute was created by fix + // 0 = created externally + + double *etamol; + double *etamol_dot; // chain thermostat for motion of whole molecules + double *etamol_dotdot; + double *etamol_mass; + + double *etaint; + double *etaint_dot; // chain thermostat for internal DOFs + double *etaint_dotdot; + double *etaint_mass; + + double *etadrude; + double *etadrude_dot; // chain thermostat for Drude relative motions + double *etadrude_dotdot; + double *etadrude_mass; + + double *etap; // chain thermostat for barostat + double *etap_dot; + double *etap_dotdot; + double *etap_mass; + + int mtchain; // length of chain + int mpchain; // length of chain + + int mtk_flag; // 0 if using Hoover barostat + int pdim; // number of barostatted dims + double p_freq_max; // maximum barostat frequency + + double p_hydro; // hydrostatic target pressure + + int nc_tchain,nc_pchain; + double sigma[6]; // scaled target stress + double fdev[6]; // deviatoric force on barostat + int deviatoric_flag; // 0 if target stress tensor is hydrostatic + double h0_inv[6]; // h_inv of reference (zero strain) box + int nreset_h0; // interval for resetting h0 + + double mtk_term1,mtk_term2; // Martyna-Tobias-Klein corrections + + int scaleyz; // 1 if yz scaled with lz + int scalexz; // 1 if xz scaled with lz + int scalexy; // 1 if xy scaled with ly + int flipflag; // 1 if box flips are invoked as needed + + int pre_exchange_flag; // set if pre_exchange needed for box flips + + double fixedpoint[3]; // location of dilation fixed-point + + void couple(); + virtual void remap(); + void nhc_temp_integrate(); + void nhc_press_integrate(); + + virtual void nve_x(); // may be overwritten by child classes + virtual void nve_v(); + virtual void nh_v_press(); + virtual void nh_v_temp(); + virtual void compute_temp_target(); + virtual int size_restart_global(); + + void compute_sigma(); + void compute_deviatoric(); + double compute_strain_energy(); + void compute_press_target(); + void nh_omega_dot(); + + + class FixDrude * fix_drude; + int n_mol; // number of molecules in the system + double *mass_mol; + double dof_mol, dof_int, dof_drude; // DOFs of different modes in the fix group + void setup_mol_mass_dof(); + double **v_mol, **v_mol_tmp; + void compute_temp_mol_int_drude(); + double tdrude_target, tdrude_freq; + double t_mol, t_int, t_drude; + double ke2mol, ke2int, ke2drude; + double ke2mol_target, ke2int_target, ke2drude_target; + double factor_eta_mol, factor_eta_int, factor_eta_drude; + double propagate(double *, double *, double *, const double *, double , double, double); +}; + +} + +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Target temperature for fix nvt/npt/nph cannot be 0.0 + +Self-explanatory. + +E: Invalid fix nvt/npt/nph command for a 2d simulation + +Cannot control z dimension in a 2d model. + +E: Fix nvt/npt/nph dilate group ID does not exist + +Self-explanatory. + +E: Invalid fix nvt/npt/nph command pressure settings + +If multiple dimensions are coupled, those dimensions must be +specified. + +E: Cannot use fix nvt/npt/nph on a non-periodic dimension + +When specifying a diagonal pressure component, the dimension must be +periodic. + +E: Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension + +When specifying an off-diagonal pressure component, the 2nd of the two +dimensions must be periodic. E.g. if the xy component is specified, +then the y dimension must be periodic. + +E: Cannot use fix nvt/npt/nph with yz scaling when z is non-periodic dimension + +The 2nd dimension in the barostatted tilt factor must be periodic. + +E: Cannot use fix nvt/npt/nph with xz scaling when z is non-periodic dimension + +The 2nd dimension in the barostatted tilt factor must be periodic. + +E: Cannot use fix nvt/npt/nph with xy scaling when y is non-periodic dimension + +The 2nd dimension in the barostatted tilt factor must be periodic. + +E: Cannot use fix nvt/npt/nph with both yz dynamics and yz scaling + +Self-explanatory. + +E: Cannot use fix nvt/npt/nph with both xz dynamics and xz scaling + +Self-explanatory. + +E: Cannot use fix nvt/npt/nph with both xy dynamics and xy scaling + +Self-explanatory. + +E: Can not specify Pxy/Pxz/Pyz in fix nvt/npt/nph with non-triclinic box + +Only triclinic boxes can be used with off-diagonal pressure components. +See the region prism command for details. + +E: Invalid fix nvt/npt/nph pressure settings + +Settings for coupled dimensions must be the same. + +E: Using update dipole flag requires atom style sphere + +Self-explanatory. + +E: Using update dipole flag requires atom attribute mu + +Self-explanatory. + +E: Fix nvt/npt/nph damping parameters must be > 0.0 + +Self-explanatory. + +E: Cannot use fix npt and fix deform on same component of stress tensor + +This would be changing the same box dimension twice. + +E: Temperature ID for fix nvt/npt does not exist + +Self-explanatory. + +E: Pressure ID for fix npt/nph does not exist + +Self-explanatory. + +E: Non-numeric pressure - simulation unstable + +UNDOCUMENTED + +E: Fix npt/nph has tilted box too far in one step - periodic cell is too far from equilibrium state + +Self-explanatory. The change in the box tilt is too extreme +on a short timescale. + +E: Could not find fix_modify temperature ID + +The compute ID for computing temperature does not exist. + +E: Fix_modify temperature ID does not compute temperature + +The compute ID assigned to the fix must compute temperature. + +W: Temperature for fix modify is not for group all + +The temperature compute is being used with a pressure calculation +which does operate on group all, so this may be inconsistent. + +E: Pressure ID for fix modify does not exist + +Self-explanatory. + +E: Could not find fix_modify pressure ID + +The compute ID for computing pressure does not exist. + +E: Fix_modify pressure ID does not compute pressure + +The compute ID assigned to the fix must compute pressure. + +U: The dlm flag must be used with update dipole + +Self-explanatory. + +*/ diff --git a/src/USER-DRUDE/fix_tgnpt_drude.cpp b/src/USER-DRUDE/fix_tgnpt_drude.cpp new file mode 100644 index 0000000000..2e6202f81b --- /dev/null +++ b/src/USER-DRUDE/fix_tgnpt_drude.cpp @@ -0,0 +1,68 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "fix_tgnpt_drude.h" +#include +#include "modify.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixTGNPTDrude::FixTGNPTDrude(LAMMPS *lmp, int narg, char **arg) : + FixTGNHDrude(lmp, narg, arg) +{ + if (!tstat_flag) + error->all(FLERR,"Temperature control must be used with fix npt"); + if (!pstat_flag) + error->all(FLERR,"Pressure control must be used with fix npt"); + + // create a new compute temp style + // id = fix-ID + temp + // compute group = all since pressure is always global (group all) + // and thus its KE/temperature contribution should use group all + + int n = strlen(id) + 6; + id_temp = new char[n]; + strcpy(id_temp,id); + strcat(id_temp,"_temp"); + + char **newarg = new char*[3]; + newarg[0] = id_temp; + newarg[1] = (char *) "all"; + newarg[2] = (char *) "temp"; + + modify->add_compute(3,newarg); + delete [] newarg; + tcomputeflag = 1; + + // create a new compute pressure style + // id = fix-ID + press, compute group = all + // pass id_temp as 4th arg to pressure constructor + + n = strlen(id) + 7; + id_press = new char[n]; + strcpy(id_press,id); + strcat(id_press,"_press"); + + newarg = new char*[4]; + newarg[0] = id_press; + newarg[1] = (char *) "all"; + newarg[2] = (char *) "pressure"; + newarg[3] = id_temp; + modify->add_compute(4,newarg); + delete [] newarg; + pcomputeflag = 1; +} diff --git a/src/USER-DRUDE/fix_tgnpt_drude.h b/src/USER-DRUDE/fix_tgnpt_drude.h new file mode 100644 index 0000000000..afb55ae0d7 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnpt_drude.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(tgnpt/drude,FixTGNPTDrude) + +#else + +#ifndef LMP_FIX_TGNPT_DRUDE_H +#define LMP_FIX_TGNPT_DRUDE_H + +#include "fix_tgnh_drude.h" + +namespace LAMMPS_NS { + +class FixTGNPTDrude : public FixTGNHDrude { + public: + FixTGNPTDrude(class LAMMPS *, int, char **); + ~FixTGNPTDrude() {} +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Temperature control must be used with fix npt + +Self-explanatory. + +E: Pressure control must be used with fix npt + +Self-explanatory. + +*/ diff --git a/src/USER-DRUDE/fix_tgnvt_drude.cpp b/src/USER-DRUDE/fix_tgnvt_drude.cpp new file mode 100644 index 0000000000..05d247b303 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnvt_drude.cpp @@ -0,0 +1,49 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "fix_tgnvt_drude.h" +#include +#include "group.h" +#include "modify.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixTGNVTDrude::FixTGNVTDrude(LAMMPS *lmp, int narg, char **arg) : + FixTGNHDrude(lmp, narg, arg) +{ + if (!tstat_flag) + error->all(FLERR,"Temperature control must be used with fix nvt"); + if (pstat_flag) + error->all(FLERR,"Pressure control can not be used with fix nvt"); + + // create a new compute temp style + // id = fix-ID + temp + + int n = strlen(id) + 6; + id_temp = new char[n]; + strcpy(id_temp,id); + strcat(id_temp,"_temp"); + + char **newarg = new char*[3]; + newarg[0] = id_temp; + newarg[1] = group->names[igroup]; + newarg[2] = (char *) "temp"; + + modify->add_compute(3,newarg); + delete [] newarg; + tcomputeflag = 1; +} diff --git a/src/USER-DRUDE/fix_tgnvt_drude.h b/src/USER-DRUDE/fix_tgnvt_drude.h new file mode 100644 index 0000000000..64f2e52e9c --- /dev/null +++ b/src/USER-DRUDE/fix_tgnvt_drude.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(tgnvt/drude,FixTGNVTDrude) + +#else + +#ifndef LMP_FIX_TGNVT_DRUDE_H +#define LMP_FIX_TGNVT_DRUDE_H + +#include "fix_tgnh_drude.h" + +namespace LAMMPS_NS { + +class FixTGNVTDrude: public FixTGNHDrude { + public: + FixTGNVTDrude(class LAMMPS *, int, char **); + ~FixTGNVTDrude() {} +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Temperature control must be used with fix nvt + +Self-explanatory. + +E: Pressure control can not be used with fix nvt + +Self-explanatory. + +*/ From 6740f8dbabd975ce52bec547774cc67f3fca4419 Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Thu, 12 Nov 2020 18:12:23 +0100 Subject: [PATCH 011/187] Fix the compatibility issue with latest LAMMPS. Add examples. --- examples/USER/drude/README | 4 +- examples/USER/drude/butane/in.butane.tgnh | 57 ++++ .../butane/log.12Nov20.butane.tgnh.g++.1 | 203 +++++++++++++ .../butane/log.12Nov20.butane.tgnh.g++.4 | 203 +++++++++++++ examples/USER/drude/ethanol/in.ethanol.tgnh | 79 +++++ .../ethanol/log.12Nov20.ethanol.tgnh.g++.1 | 287 ++++++++++++++++++ .../ethanol/log.12Nov20.ethanol.tgnh.g++.4 | 287 ++++++++++++++++++ src/USER-DRUDE/fix_tgnh_drude.cpp | 137 +++++---- src/USER-DRUDE/fix_tgnh_drude.h | 5 +- src/USER-DRUDE/fix_tgnpt_drude.cpp | 35 +-- src/USER-DRUDE/fix_tgnvt_drude.cpp | 19 +- 11 files changed, 1210 insertions(+), 106 deletions(-) create mode 100644 examples/USER/drude/butane/in.butane.tgnh create mode 100644 examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 create mode 100644 examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 create mode 100644 examples/USER/drude/ethanol/in.ethanol.tgnh create mode 100644 examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 create mode 100644 examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 diff --git a/examples/USER/drude/README b/examples/USER/drude/README index a305999e89..1a9593ed37 100644 --- a/examples/USER/drude/README +++ b/examples/USER/drude/README @@ -1,8 +1,8 @@ Example simulations of polarizable systems using Drude oscillators ================================================================== -Each example comes in two versions for demonstrating the use of -Nosé-Hoover or Langevin thermostats. +Each example comes in several versions for demonstrating the use of +Langevin, Nosé-Hoover and temperature-grouped Nosé-Hoover thermostats. * `butane` -- simulation in NVT ensemble with Thole damping diff --git a/examples/USER/drude/butane/in.butane.tgnh b/examples/USER/drude/butane/in.butane.tgnh new file mode 100644 index 0000000000..79b9d2dfc5 --- /dev/null +++ b/examples/USER/drude/butane/in.butane.tgnh @@ -0,0 +1,57 @@ +# 250 butane system for drude polarizability example (Langevin) + +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.089 8.0 +pair_modify mix geometric tail yes +kspace_style pppm 1.0e-4 + +read_data data.butane + +comm_modify vel yes + +group gBUTANE molecule 1:250 +group gCORES type 1 2 3 +group gDRUDES type 4 5 + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H C2H +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # C2H C2H +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # C2H H +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff * 4*5 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 * thole 1.368000 +pair_coeff 2 * thole 1.368000 +pair_coeff 4 * thole 1.368000 +pair_coeff 5 * thole 1.368000 + +neighbor 2.0 bin + +variable vTEMP equal 260.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gCORES create ${vTEMP} 12345 +velocity gDRUDES create ${vTEMP_D} 12345 + +fix fDRUDE all drude C C N D D + +fix fSHAKE gCORES shake 0.0001 20 0 b 2 4 + +fix fNVT all tgnvt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] +thermo 50 + +timestep 0.5 +run 2000 diff --git a/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 new file mode 100644 index 0000000000..7d64a2e939 --- /dev/null +++ b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 @@ -0,0 +1,203 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +# 250 butane system for drude polarizability example (Langevin) + +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.089 8.0 +pair_modify mix geometric tail yes +kspace_style pppm 1.0e-4 + +read_data data.butane +Reading data file ... + orthogonal box = (-19.099988 -19.099913 -19.099998) to (19.099998 19.099999 19.099987) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 4500 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 4250 bonds + reading angles ... + 6000 angles + reading dihedrals ... + 6750 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 8 = max # of 1-3 neighbors + 12 = max # of 1-4 neighbors + 17 = max # of special neighbors + special bonds CPU = 0.005 seconds + read_data CPU = 0.107 seconds + +comm_modify vel yes + +group gBUTANE molecule 1:250 +4500 atoms in group gBUTANE +group gCORES type 1 2 3 +3500 atoms in group gCORES +group gDRUDES type 4 5 +1000 atoms in group gDRUDES + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H C2H +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # C2H C2H +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # C2H H +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff * 4*5 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 * thole 1.368000 +pair_coeff 2 * thole 1.368000 +pair_coeff 4 * thole 1.368000 +pair_coeff 5 * thole 1.368000 + +neighbor 2.0 bin + +variable vTEMP equal 260.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gCORES create ${vTEMP} 12345 +velocity gCORES create 260 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N D D + +fix fSHAKE gCORES shake 0.0001 20 0 b 2 4 + 0 = # of size 2 clusters + 500 = # of size 3 clusters + 500 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.002 seconds + +fix fNVT all tgnvt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 1 20.0 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] +thermo 50 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.36786669 + grid = 36 36 36 + stencil order = 5 + estimated absolute RMS force accuracy = 0.031353958 + estimated relative force accuracy = 9.4421513e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 79507 46656 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 17 +New max number of 1-2 to 1-4 neighbors: 17 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 8 8 8 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 7250.0 3000.0 +Per MPI rank memory allocation (min/avg/max) = 26.74 | 26.74 | 26.74 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] + 0 0 6535.5187 2714.74 248.45112 3820.7787 3724.3278 140.75328 1.4735401 0 -518.77975 595169.42 -594696.41 4439.7916 55742.797 334.61375 18.435655 235.53872 344.96036 18.435655 + 50 3.1687763 2088.2827 1463.7181 133.95847 624.56452 190.24602 660.52157 113.41252 0 -767.94561 595300.94 -594872.61 2824.2625 55742.797 183.94884 0.5168738 309.18564 171.12124 0.5168738 + 100 6.392197 2119.741 1619.097 148.17863 500.64399 180.00042 696.41212 164.28885 0 -972.75524 595305.17 -594872.47 1212.6136 55742.797 203.63725 0.14080733 399.49069 183.54186 0.14080733 + 150 9.5800587 2141.3837 1671.6283 152.98627 469.75531 135.1638 703.8743 168.6738 0 -966.11416 595300.45 -594872.29 4391.1694 55742.797 210.25781 0.10918071 418.15558 188.92417 0.10918071 + 200 12.853705 2171.9506 1663.8326 152.27281 508.11794 189.68939 718.42616 166.2915 0 -990.53041 595295.36 -594871.12 2071.4055 55742.797 209.24314 0.19965091 435.49843 186.01763 0.19965091 + 250 16.067977 2208.7064 1678.7069 153.6341 529.99951 152.56393 831.36872 167.05009 0 -1047.6813 595297.24 -594870.54 1092.2375 55742.797 210.84693 0.91289443 438.53468 187.47449 0.91289443 + 300 19.290601 2251.9246 1764.9742 161.52921 486.95043 145.17235 805.81497 155.39025 0 -1045.9572 595297.21 -594870.68 2438.7801 55742.797 220.85043 3.177778 427.70756 199.6284 3.177778 + 350 22.523101 2270.9632 1684.9306 154.20368 586.03264 186.29543 828.98436 164.45539 0 -1016.9035 595293.56 -594870.36 2804.0926 55742.797 211.53678 1.1611927 408.91355 191.2877 1.1611927 + 400 25.747934 2299.236 1742.1505 159.44041 557.0855 171.75438 844.97783 181.89643 0 -1068.3059 595296.85 -594870.09 346.86959 55742.797 219.02792 0.38093991 392.66374 201.22808 0.38093991 + 450 28.921993 2335.9622 1666.2461 152.49369 669.71602 137.8956 986.46039 179.59582 0 -1060.189 595295.82 -594869.86 -125.83593 55742.797 209.50259 0.31748182 376.15783 192.41804 0.31748182 + 500 32.312988 2377.923 1744.8977 159.69183 633.02533 192.86619 865.11335 173.23166 0 -1020.1061 595291.45 -594869.53 3306.7537 55742.797 219.29509 0.59010722 361.05703 204.77946 0.59010722 + 550 36.691992 2428.1816 1631.766 149.33809 796.41562 183.75276 1043.9175 175.64604 0 -1030.3844 595293.08 -594869.6 1566.0362 55742.797 204.67411 1.6260367 344.40559 190.36165 1.6260367 + 600 41.042781 2475.0304 1615.769 147.87406 859.26146 195.35951 1102.8743 185.82441 0 -1049.7179 595293.93 -594869 751.07631 55742.797 202.5711 1.8674049 324.5681 190.08503 1.8674049 + 650 45.328915 2516.5445 1706.6033 156.18716 809.94113 177.34479 1029.3219 186.91492 0 -1005.4619 595290.9 -594869.08 2456.1336 55742.797 214.42466 0.73094758 306.66872 205.00907 0.73094758 + 700 49.764606 2566.0671 1658.8261 151.81461 907.24102 186.97528 1088.6916 184.51371 0 -976.01174 595292.41 -594869.33 403.91053 55742.797 208.52534 0.43420426 292.04619 200.0061 0.43420426 + 750 54.232008 2621.7889 1798.1047 164.5613 823.68424 181.39689 1029.9425 187.40871 0 -1005.4402 595300.06 -594869.68 93.345406 55742.797 226.01979 0.50741755 278.62961 220.69269 0.50741755 + 800 58.691111 2682.2116 1697.0698 155.31465 985.14182 215.09199 1113.1134 201.785 0 -975.13212 595300.04 -594869.76 -978.97822 55742.797 213.08116 1.115316 269.45572 207.36081 1.115316 + 850 63.191067 2745.8302 1887.0667 172.70304 858.76349 213.25376 980.55106 184.54859 0 -948.21117 595298.22 -594869.6 -1842.9661 55742.797 236.69142 1.8946563 265.28903 233.84282 1.8946563 + 900 68.297608 2799.3194 1855.1338 169.78056 944.1856 201.04167 1103.4608 183.6645 0 -978.27382 595303.89 -594869.59 -1771.6573 55742.797 232.95614 1.1425454 262.10904 230.04879 1.1425454 + 950 72.791466 2852.8885 1809.5899 165.61241 1043.2986 249.1926 1129.6516 191.5705 0 -961.04118 595303.8 -594869.88 -2342.8998 55742.797 227.44427 0.56184866 253.71617 224.83147 0.56184866 + 1000 77.035667 2910.6565 1900.2429 173.90892 1010.4136 196.79043 1117.444 178.94619 0 -911.75161 595298.72 -594869.74 -30.451099 55742.797 238.87602 0.48940683 245.53211 238.28906 0.48940683 + 1050 81.411119 2970.473 1950.8452 178.54 1019.6278 226.17987 1113.3407 186.50456 0 -935.79287 595298.24 -594868.85 -835.03656 55742.797 245.11923 0.81684119 243.27893 245.41028 0.81684119 + 1100 85.352255 3032.1777 1913.2921 175.10317 1118.8856 252.39337 1183.7624 209.49478 0 -958.58165 595300.89 -594869.07 -2339.7573 55742.797 240.10633 1.5863163 244.29251 239.77436 1.5863163 + 1150 88.542324 3088.7233 2015.1572 184.4258 1073.5661 215.84757 1132.2268 209.14846 0 -912.58909 595297.76 -594868.83 53.404069 55742.797 252.92982 1.5639609 247.6541 253.57807 1.5639609 + 1200 92.122601 3137.9447 1895.1546 173.44324 1242.7901 238.97673 1266.308 207.46165 0 -898.18367 595297.09 -594868.86 -940.55827 55742.797 238.13441 0.75999751 245.44164 237.48006 0.75999751 + 1250 95.311451 3187.5696 2117.7204 193.81231 1069.8492 181.35781 1173.5116 216.10446 0 -933.15422 595300.81 -594868.78 -1638.23 55742.797 266.21428 0.54658889 243.60628 268.65384 0.54658889 + 1300 98.511654 3238.1405 2050.9414 187.70074 1187.1991 249.20898 1196.3016 223.50078 0 -909.6591 595296.3 -594868.46 -1547.4617 55742.797 257.76705 0.6695258 252.14097 258.4534 0.6695258 + 1350 101.52721 3288.0387 2035.6917 186.3051 1252.347 218.31874 1254.421 222.85512 0 -868.43705 595293.49 -594868.3 390.90212 55742.797 255.64252 1.2189872 257.21253 255.58654 1.2189872 + 1400 104.52829 3334.0324 2200.7086 201.40733 1133.3238 203.591 1213.1272 225.86605 0 -936.79465 595295.53 -594868 1372.2474 55742.797 276.25415 1.6144005 265.70225 277.45567 1.6144005 + 1450 107.57536 3365.7397 2053.535 187.9381 1312.2047 229.27407 1349.3993 233.25524 0 -924.22271 595292.17 -594867.67 -836.52213 55742.797 257.94919 1.053914 270.4816 256.76466 1.053914 + 1500 110.67807 3391.6801 2142.1349 196.04671 1249.5452 216.36803 1271.289 236.65847 0 -894.899 595287.51 -594867.38 1789.6923 55742.797 269.25236 0.63559736 274.68538 268.80398 0.63559736 + 1550 113.65872 3411.9839 2115.0942 193.57196 1296.8897 192.92659 1363.4027 230.98652 0 -914.70137 595291.47 -594867.19 2191.6084 55742.797 265.85125 0.63359087 272.59399 265.26653 0.63359087 + 1600 116.66477 3424.9783 2002.6546 183.28156 1422.3237 261.62038 1419.7862 242.17905 0 -928.05995 595294.38 -594867.58 -1278.1217 55742.797 251.58666 0.95135757 265.94171 250.2117 0.95135757 + 1650 119.69122 3429.9661 2102.8573 192.45205 1327.1088 253.88883 1296.8164 239.01537 0 -888.25345 595293.11 -594867.47 948.16575 55742.797 263.99864 1.4686915 261.93718 264.32028 1.4686915 + 1700 122.69838 3421.465 2141.4791 195.98669 1279.9859 181.31236 1326.081 226.54243 0 -878.86521 595292.19 -594867.28 241.93125 55742.797 268.9293 1.2770595 262.79349 269.67278 1.2770595 + 1750 125.70436 3402.5396 2090.1999 191.29365 1312.3397 263.74025 1296.4274 228.60032 0 -905.54661 595296.37 -594867.25 -1707.3557 55742.797 262.65583 0.80319616 257.84463 263.26023 0.80319616 + 1800 128.64288 3381.1607 2133.1735 195.22657 1247.9872 234.93738 1242.035 231.34689 0 -887.78079 595295.05 -594867.6 -6.7713651 55742.797 268.11425 0.66416955 258.06107 269.26102 0.66416955 + 1850 131.64553 3358.3375 2097.2908 191.9426 1261.0467 207.32514 1269.9582 225.83462 0 -867.84477 595293.05 -594867.28 1032.3077 55742.797 263.55741 0.77783532 261.21918 263.90739 0.77783532 + 1900 134.66459 3335.0634 2130.3209 194.96549 1204.7425 244.28549 1208.9691 209.87044 0 -885.54671 595293.8 -594866.63 -302.54262 55742.797 267.53309 1.2569444 256.95232 268.73397 1.2569444 + 1950 137.77487 3309.5009 2065.148 189.00092 1244.3529 244.25407 1240.7976 222.92873 0 -891.58467 595294.86 -594866.9 -2000.0789 55742.797 259.29344 1.3652015 254.19331 259.92622 1.3652015 + 2000 140.88126 3284.0767 2005.7474 183.56462 1278.3292 226.17277 1236.5565 225.16671 0 -837.57878 595295.52 -594867.51 942.09961 55742.797 251.97128 0.96329477 250.4516 252.23212 0.96329477 +Loop time of 140.882 on 1 procs for 2000 steps with 4500 atoms + +Performance: 0.613 ns/day, 39.134 hours/ns, 14.196 timesteps/s +100.0% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 90.189 | 90.189 | 90.189 | 0.0 | 64.02 +Bond | 5.0432 | 5.0432 | 5.0432 | 0.0 | 3.58 +Kspace | 39.478 | 39.478 | 39.478 | 0.0 | 28.02 +Neigh | 2.4322 | 2.4322 | 2.4322 | 0.0 | 1.73 +Comm | 0.62876 | 0.62876 | 0.62876 | 0.0 | 0.45 +Output | 0.021652 | 0.021652 | 0.021652 | 0.0 | 0.02 +Modify | 2.9918 | 2.9918 | 2.9918 | 0.0 | 2.12 +Other | | 0.09631 | | | 0.07 + +Nlocal: 4500.00 ave 4500 max 4500 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 9440.00 ave 9440 max 9440 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 811251.0 ave 811251 max 811251 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 811251 +Ave neighs/atom = 180.27800 +Ave special neighs/atom = 13.333333 +Neighbor list builds = 31 +Dangerous builds = 0 +Total wall time: 0:02:21 diff --git a/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 new file mode 100644 index 0000000000..5cadbab3d2 --- /dev/null +++ b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 @@ -0,0 +1,203 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +# 250 butane system for drude polarizability example (Langevin) + +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.089 8.0 +pair_modify mix geometric tail yes +kspace_style pppm 1.0e-4 + +read_data data.butane +Reading data file ... + orthogonal box = (-19.099988 -19.099913 -19.099998) to (19.099998 19.099999 19.099987) + 2 by 1 by 2 MPI processor grid + reading atoms ... + 4500 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 4250 bonds + reading angles ... + 6000 angles + reading dihedrals ... + 6750 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 8 = max # of 1-3 neighbors + 12 = max # of 1-4 neighbors + 17 = max # of special neighbors + special bonds CPU = 0.002 seconds + read_data CPU = 0.135 seconds + +comm_modify vel yes + +group gBUTANE molecule 1:250 +4500 atoms in group gBUTANE +group gCORES type 1 2 3 +3500 atoms in group gCORES +group gDRUDES type 4 5 +1000 atoms in group gDRUDES + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H C2H +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # C2H C2H +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # C2H H +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff * 4*5 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 * thole 1.368000 +pair_coeff 2 * thole 1.368000 +pair_coeff 4 * thole 1.368000 +pair_coeff 5 * thole 1.368000 + +neighbor 2.0 bin + +variable vTEMP equal 260.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gCORES create ${vTEMP} 12345 +velocity gCORES create 260 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N D D + +fix fSHAKE gCORES shake 0.0001 20 0 b 2 4 + 0 = # of size 2 clusters + 500 = # of size 3 clusters + 500 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.003 seconds + +fix fNVT all tgnvt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 1 20.0 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] +thermo 50 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.36786669 + grid = 36 36 36 + stencil order = 5 + estimated absolute RMS force accuracy = 0.031353958 + estimated relative force accuracy = 9.4421513e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 26875 11664 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 17 +New max number of 1-2 to 1-4 neighbors: 17 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 8 8 8 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 7250.0 3000.0 +Per MPI rank memory allocation (min/avg/max) = 17.33 | 17.61 | 17.71 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] + 0 0 6535.5187 2714.74 248.45112 3820.7787 3724.3278 140.75328 1.4735401 0 -518.77975 595169.42 -594696.41 4439.7916 55742.797 334.61375 18.435655 235.53872 344.96036 18.435655 + 50 1.2808116 2088.3442 1463.7416 133.96062 624.60259 190.28732 660.54143 113.40785 0 -767.95454 595300.93 -594872.61 2824.0523 55742.797 183.9497 0.52468068 309.23594 171.11764 0.52468068 + 100 2.5584104 2119.7471 1619.1466 148.18318 500.60051 180.0129 696.37693 164.27736 0 -972.76956 595305.17 -594872.47 1212.1148 55742.797 203.64285 0.14251823 399.52878 183.54411 0.14251823 + 150 3.8010236 2141.3696 1671.6877 152.99171 469.68182 135.1764 703.84494 168.6598 0 -966.14516 595300.44 -594872.29 4390.752 55742.797 210.26485 0.11034179 418.18146 188.92927 0.11034179 + 200 5.1283429 2171.9547 1663.9057 152.2795 508.04901 189.69207 718.41361 166.26728 0 -990.56316 595295.36 -594871.12 2071.2788 55742.797 209.25133 0.20233224 435.53114 186.0233 0.20233224 + 250 6.4042978 2208.7763 1678.8339 153.64571 529.94239 152.60724 831.35366 166.99449 0 -1047.7147 595297.24 -594870.54 1092.02 55742.797 210.85827 0.9252592 438.54342 187.4861 0.9252592 + 300 7.6759895 2251.8197 1764.844 161.5173 486.97577 145.12518 805.82891 155.36767 0 -1045.8941 595297.22 -594870.68 2440.3181 55742.797 220.83898 3.1684561 427.70245 199.61611 3.1684561 + 350 8.9352416 2270.8953 1684.8322 154.19468 586.06305 186.26267 828.9806 164.47014 0 -1016.8664 595293.58 -594870.36 2805.0915 55742.797 211.52748 1.151954 408.90784 191.27829 1.151954 + 400 10.226474 2299.1993 1742.2608 159.4505 556.93851 171.73982 844.94626 181.87018 0 -1068.3641 595296.84 -594870.09 346.42411 55742.797 219.04152 0.38166821 392.61871 201.24772 0.38166821 + 450 11.460384 2335.947 1666.1971 152.4892 669.74994 137.90858 986.43107 179.60302 0 -1060.1348 595295.81 -594869.87 -124.88535 55742.797 209.49545 0.32005879 376.11474 192.41461 0.32005879 + 500 12.727526 2377.9345 1744.9374 159.69546 632.99715 192.8966 865.02273 173.24203 0 -1020.0569 595291.42 -594869.52 3307.6909 55742.797 219.29743 0.59718599 361.06132 204.78161 0.59718599 + 550 14.002285 2428.2193 1631.8271 149.34369 796.3922 183.78402 1043.8511 175.66575 0 -1030.3885 595293.08 -594869.6 1565.6449 55742.797 204.6776 1.6372397 344.46071 190.35982 1.6372397 + 600 15.309195 2474.8599 1615.6237 147.86076 859.23616 195.26628 1102.8384 185.89393 0 -1049.6659 595293.91 -594869.01 751.15809 55742.797 202.55856 1.8521167 324.58977 190.06895 1.8521167 + 650 16.528946 2516.5107 1706.7483 156.20043 809.76241 177.33665 1029.1545 186.8922 0 -1005.4741 595290.93 -594869.08 2457.4736 55742.797 214.44458 0.72647262 306.69821 205.02801 0.72647262 + 700 17.788857 2566.0306 1658.7538 151.808 907.27687 187.0133 1088.6084 184.61388 0 -976.00491 595292.38 -594869.33 403.14977 55742.797 208.51586 0.43547213 292.00328 200.00013 0.43547213 + 750 19.056136 2621.8108 1798.0665 164.5578 823.74429 181.38067 1030.1211 187.24746 0 -1005.3911 595300.06 -594869.68 92.552993 55742.797 226.01327 0.51200863 278.52415 220.69636 0.51200863 + 800 20.328816 2682.2638 1697.1503 155.32202 985.11349 215.11037 1113.1057 201.61206 0 -974.97574 595300.02 -594869.76 -976.02218 55742.797 213.08709 1.1265124 269.37146 207.37604 1.1265124 + 850 21.675028 2745.7956 1887.1133 172.70731 858.68222 213.20281 980.38605 184.58101 0 -948.10772 595298.22 -594869.6 -1838.829 55742.797 236.69968 1.8882632 265.22854 233.85817 1.8882632 + 900 22.973234 2799.2121 1855.3963 169.80459 943.81573 200.99559 1103.2167 183.64073 0 -978.26954 595303.83 -594869.59 -1773.6417 55742.797 232.99302 1.1323134 262.06588 230.09392 1.1323134 + 950 24.248459 2852.9103 1809.6345 165.6165 1043.2758 249.23659 1129.5155 191.54177 0 -960.95833 595303.82 -594869.88 -2343.6579 55742.797 227.45041 0.56047502 253.63589 224.84652 0.56047502 + 1000 25.536354 2910.7011 1900.5669 173.93856 1010.1343 196.76213 1117.2835 179.06956 0 -911.9529 595298.71 -594869.74 -33.375682 55742.797 238.91568 0.49230975 245.54917 238.33106 0.49230975 + 1050 27.032801 2970.593 1950.7545 178.53171 1019.8385 226.09391 1113.2803 186.61907 0 -935.59614 595298.29 -594868.85 -832.86686 55742.797 245.10467 0.82528071 243.25364 245.39681 0.82528071 + 1100 28.276849 3032.248 1914.0097 175.16884 1118.2383 252.4222 1183.4081 209.13741 0 -958.53105 595300.88 -594869.07 -2341.1239 55742.797 240.19374 1.5939531 244.2841 239.87168 1.5939531 + 1150 29.492505 3088.6987 2014.6006 184.37485 1074.0982 215.76487 1132.4575 209.01044 0 -912.08646 595297.78 -594868.83 59.335425 55742.797 252.86479 1.5506297 247.67435 253.50422 1.5506297 + 1200 30.792128 3137.976 1895.5574 173.4801 1242.4187 239.01663 1266.2435 206.94828 0 -898.01399 595297.09 -594868.87 -935.85119 55742.797 238.18675 0.75585601 245.80184 237.50082 0.75585601 + 1250 32.351654 3187.6007 2118.7576 193.90723 1068.8431 181.27841 1173.4284 215.72666 0 -933.61935 595300.82 -594868.79 -1641.4966 55742.797 266.34429 0.54783845 244.09536 268.74691 0.54783845 + 1300 34.279555 3238.1339 2050.9128 187.69812 1187.2212 249.09831 1195.8579 223.95802 0 -909.52255 595296.29 -594868.46 -1548.7665 55742.797 257.76137 0.67507496 252.48992 258.41118 0.67507496 + 1350 36.142639 3287.8996 2035.6486 186.30115 1252.251 218.35091 1254.3488 223.36318 0 -868.93347 595293.43 -594868.31 385.64561 55742.797 255.63367 1.2281317 257.51447 255.54567 1.2281317 + 1400 37.680265 3333.7702 2200.7264 201.40895 1133.0439 203.40304 1213.391 225.99045 0 -937.20521 595295.47 -594868.01 1368.2351 55742.797 276.25818 1.6096154 265.82263 277.44771 1.6096154 + 1450 38.930719 3365.4323 2053.468 187.93197 1311.9643 229.10608 1350.1009 232.99574 0 -924.67313 595292.11 -594867.67 -844.05749 55742.797 257.94445 1.0440927 270.14303 256.79431 1.0440927 + 1500 40.161434 3391.3707 2141.7727 196.01356 1249.598 216.2106 1271.1542 236.52415 0 -894.39832 595287.52 -594867.41 1800.4964 55742.797 269.20769 0.63415006 273.93125 268.83182 0.63415006 + 1550 41.331434 3411.6894 2114.0335 193.47488 1297.6559 192.9656 1363.167 231.27359 0 -913.98645 595291.45 -594867.21 2209.1641 55742.797 265.71649 0.63741948 271.92193 265.18682 0.63741948 + 1600 42.514856 3424.7938 2003.2634 183.33728 1421.5305 261.67378 1419.189 241.66354 0 -927.77417 595294.37 -594867.6 -1282.8296 55742.797 251.6594 0.96160577 265.79668 250.30691 0.96160577 + 1650 43.712954 3429.9764 2104.4785 192.60041 1325.4979 253.75783 1296.7732 237.25083 0 -887.95744 595293.15 -594867.48 966.66903 55742.797 264.20211 1.4699573 262.83185 264.45262 1.4699573 + 1700 44.988869 3421.4427 2141.3199 195.97211 1280.1228 180.56711 1326.1422 227.27194 0 -878.75929 595292.2 -594867.3 269.33339 55742.797 268.91342 1.2659937 264.28353 269.50173 1.2659937 + 1750 46.32512 3402.6047 2089.4689 191.22675 1313.1357 263.71155 1295.9383 229.85515 0 -905.40883 595296.3 -594867.26 -1711.6299 55742.797 262.56648 0.79625261 258.49733 263.09439 0.79625261 + 1800 47.626741 3381.3633 2132.4465 195.16003 1248.9167 234.45582 1241.8128 232.64927 0 -887.43322 595295.06 -594867.63 6.1750563 55742.797 268.02308 0.66339407 257.61935 269.20593 0.66339407 + 1850 48.859097 3358.9769 2090.1997 191.29363 1268.7772 207.84877 1271.8504 229.08032 0 -865.66614 595292.95 -594867.29 1046.4693 55742.797 262.66189 0.78698303 260.47063 262.99635 0.78698303 + 1900 50.086851 3336.417 2129.6659 194.90555 1206.7511 244.28118 1211.1819 208.93923 0 -884.87319 595293.88 -594866.65 -289.20276 55742.797 267.44697 1.2668343 256.868 268.64764 1.2668343 + 1950 51.245913 3311.0369 2068.2384 189.28375 1242.7985 243.85893 1242.1317 220.07989 0 -891.04779 595294.68 -594866.91 -1991.6618 55742.797 259.6859 1.3553911 254.54251 260.3233 1.3553911 + 2000 52.444694 3285.8337 2003.2382 183.33497 1282.5955 227.01654 1237.0479 227.77755 0 -837.34967 595295.6 -594867.49 937.91227 55742.797 251.65869 0.95505158 250.48617 251.88363 0.95505158 +Loop time of 52.4449 on 4 procs for 2000 steps with 4500 atoms + +Performance: 1.647 ns/day, 14.568 hours/ns, 38.135 timesteps/s +98.1% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 26.398 | 27.961 | 29.034 | 18.3 | 53.31 +Bond | 1.3959 | 1.5762 | 1.7169 | 9.5 | 3.01 +Kspace | 17.592 | 18.436 | 19.757 | 18.9 | 35.15 +Neigh | 0.8492 | 0.85015 | 0.85101 | 0.1 | 1.62 +Comm | 1.311 | 1.6626 | 2.0789 | 22.0 | 3.17 +Output | 0.010571 | 0.011494 | 0.013821 | 1.3 | 0.02 +Modify | 1.8078 | 1.8237 | 1.8372 | 0.8 | 3.48 +Other | | 0.1236 | | | 0.24 + +Nlocal: 1125.00 ave 1220 max 1043 min +Histogram: 1 0 1 0 0 0 1 0 0 1 +Nghost: 5813.50 ave 5907 max 5699 min +Histogram: 1 0 0 1 0 0 0 0 1 1 +Neighs: 202807.0 ave 217353 max 190808 min +Histogram: 1 1 0 0 0 0 1 0 0 1 + +Total # of neighbors = 811227 +Ave neighs/atom = 180.27267 +Ave special neighs/atom = 13.333333 +Neighbor list builds = 31 +Dangerous builds = 0 +Total wall time: 0:00:52 diff --git a/examples/USER/drude/ethanol/in.ethanol.tgnh b/examples/USER/drude/ethanol/in.ethanol.tgnh new file mode 100644 index 0000000000..8d476da68a --- /dev/null +++ b/examples/USER/drude/ethanol/in.ethanol.tgnh @@ -0,0 +1,79 @@ +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.600 8.0 +kspace_style pppm 1.0e-4 + +comm_modify vel yes +read_data data.ethanol + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H CTO +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 1 4 lj/cut/coul/long 0.105921 3.304542 # C3H OH +pair_coeff 1 5 lj/cut/coul/long 0.000000 0.000000 # C3H HO +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # CTO CTO +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # CTO H +pair_coeff 2 4 lj/cut/coul/long 0.105921 3.304542 # CTO OH +pair_coeff 2 5 lj/cut/coul/long 0.000000 0.000000 # CTO HO +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff 3 4 lj/cut/coul/long 0.071413 2.792848 # H OH +pair_coeff 3 5 lj/cut/coul/long 0.000000 0.000000 # H HO +pair_coeff 4 4 lj/cut/coul/long 0.169996 3.120000 # OH OH +pair_coeff 4 5 lj/cut/coul/long 0.000000 0.000000 # OH HO +pair_coeff 5 5 lj/cut/coul/long 0.000000 0.000000 # HO HO +pair_coeff * 6*8 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 1 thole 2.051000 +pair_coeff 1 2 thole 1.580265 +pair_coeff 1 4 thole 1.416087 +pair_coeff 1 6 thole 2.051000 +pair_coeff 1 7 thole 1.580265 +pair_coeff 1 8 thole 1.416087 +pair_coeff 2 2 thole 1.217570 +pair_coeff 2 4 thole 1.091074 +pair_coeff 2 6 thole 1.580265 +pair_coeff 2 7 thole 1.217570 +pair_coeff 2 8 thole 1.091074 +pair_coeff 4 4 thole 0.977720 +pair_coeff 4 6 thole 1.416087 +pair_coeff 4 7 thole 1.091074 +pair_coeff 4 8 thole 0.977720 +pair_coeff 6 6 thole 2.051000 +pair_coeff 6 7 thole 1.580265 +pair_coeff 6 8 thole 1.416087 +pair_coeff 7 7 thole 1.217570 +pair_coeff 7 8 thole 1.091074 +pair_coeff 8 8 thole 0.977720 + +group gETHANOL molecule 1:250 +group gATOMS type 1 2 3 4 5 +group gDRUDES type 6 7 8 + +neighbor 2.0 bin + +variable vTEMP equal 300.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gATOMS create ${vTEMP} 12345 +velocity gDRUDES create ${vTEMP_D} 12345 + +fix fDRUDE all drude C C N C N D D D + +fix fSHAKE gATOMS shake 0.0001 20 0 b 2 3 5 + +fix fNPT all tgnpt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] +thermo 20 + +timestep 0.5 +run 2000 diff --git a/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 new file mode 100644 index 0000000000..d6c39edb32 --- /dev/null +++ b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 @@ -0,0 +1,287 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.600 8.0 +kspace_style pppm 1.0e-4 + +comm_modify vel yes +read_data data.ethanol +Reading data file ... + orthogonal box = (-14.013845 -14.027809 -14.018882) to (14.016930 14.017730 14.085730) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 3000 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 2750 bonds + reading angles ... + 3250 angles + reading dihedrals ... + 3000 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 6 = max # of 1-3 neighbors + 10 = max # of 1-4 neighbors + 11 = max # of special neighbors + special bonds CPU = 0.003 seconds + read_data CPU = 0.062 seconds + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H CTO +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 1 4 lj/cut/coul/long 0.105921 3.304542 # C3H OH +pair_coeff 1 5 lj/cut/coul/long 0.000000 0.000000 # C3H HO +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # CTO CTO +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # CTO H +pair_coeff 2 4 lj/cut/coul/long 0.105921 3.304542 # CTO OH +pair_coeff 2 5 lj/cut/coul/long 0.000000 0.000000 # CTO HO +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff 3 4 lj/cut/coul/long 0.071413 2.792848 # H OH +pair_coeff 3 5 lj/cut/coul/long 0.000000 0.000000 # H HO +pair_coeff 4 4 lj/cut/coul/long 0.169996 3.120000 # OH OH +pair_coeff 4 5 lj/cut/coul/long 0.000000 0.000000 # OH HO +pair_coeff 5 5 lj/cut/coul/long 0.000000 0.000000 # HO HO +pair_coeff * 6*8 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 1 thole 2.051000 +pair_coeff 1 2 thole 1.580265 +pair_coeff 1 4 thole 1.416087 +pair_coeff 1 6 thole 2.051000 +pair_coeff 1 7 thole 1.580265 +pair_coeff 1 8 thole 1.416087 +pair_coeff 2 2 thole 1.217570 +pair_coeff 2 4 thole 1.091074 +pair_coeff 2 6 thole 1.580265 +pair_coeff 2 7 thole 1.217570 +pair_coeff 2 8 thole 1.091074 +pair_coeff 4 4 thole 0.977720 +pair_coeff 4 6 thole 1.416087 +pair_coeff 4 7 thole 1.091074 +pair_coeff 4 8 thole 0.977720 +pair_coeff 6 6 thole 2.051000 +pair_coeff 6 7 thole 1.580265 +pair_coeff 6 8 thole 1.416087 +pair_coeff 7 7 thole 1.217570 +pair_coeff 7 8 thole 1.091074 +pair_coeff 8 8 thole 0.977720 + +group gETHANOL molecule 1:250 +3000 atoms in group gETHANOL +group gATOMS type 1 2 3 4 5 +2250 atoms in group gATOMS +group gDRUDES type 6 7 8 +750 atoms in group gDRUDES + +neighbor 2.0 bin + +variable vTEMP equal 300.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gATOMS create ${vTEMP} 12345 +velocity gATOMS create 300 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N C N D D D + +fix fSHAKE gATOMS shake 0.0001 20 0 b 2 3 5 + 250 = # of size 2 clusters + 250 = # of size 3 clusters + 250 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.001 seconds + +fix fNPT all tgnpt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 1 1000 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] +thermo 20 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.37973843 + grid = 30 30 30 + stencil order = 5 + estimated absolute RMS force accuracy = 0.028997858 + estimated relative force accuracy = 8.7326188e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 50653 27000 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 11 +New max number of 1-2 to 1-4 neighbors: 11 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 6 6 6 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 4500.0 2250.0 +Per MPI rank memory allocation (min/avg/max) = 22.99 | 22.99 | 22.99 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] + 0 0 13868.828 2013.3852 270.28772 11855.443 3145.896 51.880809 0.00019113234 0 8481.5109 514734.14 -514557.98 170210.19 22094.109 381.62759 10.134301 291.07893 396.91308 10.134301 + 20 1.299002 9802.0013 5175.0939 694.7326 4626.9074 1138.6388 2334.7257 132.32135 0 1890.1205 514082.52 -514951.42 83148.665 22175.038 987.97886 9.5650257 2458.1912 744.58226 9.5650257 + 40 2.6585262 9235.2784 5579.5869 749.03392 3655.6915 905.50827 1897.9797 277.48003 0 1696.6242 513843.84 -514965.74 60300.581 22359.787 1068.9505 1.5632512 2851.9591 773.68368 1.5632512 + 60 4.0767848 8671.8892 5504.7567 738.98831 3167.1326 829.06537 2052.5827 330.50295 0 997.94126 513948.25 -514991.2 48878.532 22600.438 1054.9063 0.8609188 3046.3154 725.0357 0.8609188 + 80 5.4198065 8041.4551 5718.4601 767.67701 2322.9951 733.58679 1714.9273 332.16847 0 607.45721 513906.05 -514971.19 46156.9 22855.703 1095.9536 0.67476425 2911.1504 795.36156 0.67476425 + 100 6.8445274 7424.1846 5485.2445 736.36888 1938.9402 725.61122 1556.2473 334.28427 0 311.33112 513993.29 -514981.82 35649.376 23094.997 1051.3109 0.5222695 2722.3778 774.61471 0.5222695 + 120 8.1987147 6864.2981 5106.0869 685.46872 1758.2112 639.80517 1608.9702 330.7119 0 225.63755 513930.12 -514977.04 28592.139 23302.575 978.67156 0.41481306 2531.1524 721.61219 0.41481306 + 140 9.6125531 6355.2419 4782.2344 641.99302 1573.0074 692.8178 1572.2236 329.75157 0 62.526757 513879.29 -514963.61 24166.914 23482.684 916.61358 0.35571984 2382.5955 673.87165 0.35571984 + 160 10.981043 5871.6552 4610.4861 618.9366 1261.169 680.52384 1414.3474 329.28182 0 -159.78058 513987.52 -514990.72 27542.211 23647.419 883.68752 0.35918951 2123.8994 678.40147 0.35918951 + 180 12.332621 5435.5691 4279.3184 574.47885 1156.2507 684.91656 1423.9511 309.44801 0 -233.41405 513945.61 -514974.26 18688.318 23808.753 820.22155 0.31322062 1867.6728 646.89147 0.31322062 + 200 13.684023 5063.6933 3974.692 533.58416 1089.0012 610.82746 1398.9423 299.55778 0 -238.71277 514006.42 -514988.03 14346.596 23962.516 761.81108 0.34323344 1649.6269 614.94153 0.34323344 + 220 15.025737 4729.6345 3862.1044 518.46979 867.53006 589.15408 1361.5835 291.68077 0 -382.15023 514000.76 -514993.5 14084.228 24106.002 740.21384 0.37572015 1480.8499 617.76172 0.37572015 + 240 16.361954 4425.17 3701.2817 496.88008 723.88831 584.37459 1295.507 282.13297 0 -468.19466 514014.29 -514984.22 13175.309 24240.893 709.36164 0.42725973 1335.0379 605.97228 0.42725973 + 260 17.686205 4147.8236 3444.1814 462.36555 703.6422 561.69812 1304.6664 277.46507 0 -505.18688 514062.51 -514997.51 9960.5444 24367.441 660.03654 0.51674844 1202.6787 570.39815 0.51663293 + 280 19.001433 3906.0499 3263.3789 438.09363 642.67099 612.03629 1258.9736 278.79088 0 -503.36734 513978.2 -514981.97 5911.2321 24482.777 625.29586 0.70431199 1076.194 550.86363 0.70431199 + 300 20.239475 3688.6521 3138.7761 421.36628 549.87595 589.66541 1229.0183 274.52568 0 -529.41366 513980.02 -514993.93 8818.9035 24585 601.19081 1.2138917 967.42544 540.79666 1.2138917 + 320 21.55208 3484.9768 3041.6682 408.32999 443.30859 581.36133 1221.761 276.40415 0 -581.91733 513938.29 -514992.59 9181.7725 24679.377 582.27807 1.9067083 865.20562 535.70028 1.9067083 + 340 22.866527 3301.111 2892.7326 388.33607 408.3784 575.39496 1150.6761 289.75308 0 -522.13929 513897.14 -514982.44 7705.6777 24768.367 553.48144 2.4790842 782.86323 515.77305 2.4790842 + 360 24.169391 3134.601 2727.1786 366.11121 407.42236 560.04836 1167.7896 290.8151 0 -534.37256 513917.26 -514994.12 5173.1603 24851.201 521.90957 2.0935593 720.9275 489.22054 2.0935593 + 380 25.499891 2978.9742 2626.4574 352.58985 352.51679 565.92745 1159.8532 276.01665 0 -574.15206 513906.53 -514981.66 5406.7601 24926.52 502.85217 1.5076664 663.92569 476.44959 1.5078823 + 400 26.749513 2830.4515 2571.0905 345.15709 259.36106 608.49648 1122.7921 254.35509 0 -631.46578 513898.27 -514993.09 6598.5441 24996.189 492.43661 1.0446762 619.49263 471.67242 1.0443567 + 420 28.295841 2690.9016 2510.0923 336.96837 180.80925 579.44132 1054.4508 246.41333 0 -619.58628 513907.01 -514986.92 3344.148 25062.431 480.89086 0.69994647 565.8201 467.11319 0.69994647 + 440 29.740652 2568.0899 2415.0979 324.2158 152.99201 549.56174 1062.4133 248.3112 0 -625.52103 513895.56 -514977.34 1508.2507 25122.432 462.77313 0.4830629 522.5615 453.15678 0.4830629 + 460 31.033999 2452.8301 2374.2562 318.73299 78.573926 560.62424 1025.2699 241.11159 0 -664.87807 513904.81 -514988.36 2645.1623 25175.119 454.98091 0.39620035 489.058 449.62743 0.39620035 + 480 32.287371 2343.6513 2309.9229 310.09654 33.728418 543.67605 1036.735 236.6691 0 -646.19525 513846.07 -514983.23 4840.3297 25223.454 442.64176 0.41089885 466.91678 438.90721 0.41089885 + 500 33.575452 2237.0869 2186.7578 293.56219 50.329153 569.29753 1077.789 237.78011 0 -644.2024 513802.59 -514992.93 3147.641 25270.717 419.03821 0.39338041 448.26725 414.46511 0.39352695 + 520 34.882586 2139.9267 2184.6613 293.28075 -44.734618 598.44589 949.76187 230.75426 0 -639.80829 513811.79 -514995.68 89.417432 25315.104 418.62009 0.43123772 424.93066 417.85161 0.43123772 + 540 36.099168 2047.6906 2096.7059 281.47314 -49.015331 603.23512 994.03336 236.23878 0 -642.85411 513760.61 -515000.28 2488.0247 25353.845 401.6824 0.6095642 402.80198 401.76434 0.6095642 + 560 37.392444 1959.8223 2108.0902 283.00143 -148.26783 556.77844 933.83445 228.23222 0 -640.71325 513772.73 -514999.13 3943.0471 25390.643 403.78476 0.79631768 387.29154 406.79182 0.79631768 + 580 38.599277 1877.9441 2032.3004 272.827 -154.35632 567.35925 915.88654 217.432 0 -638.21268 513777.18 -514994 990.21765 25427.432 389.08915 1.184871 380.81536 390.72199 1.184871 + 600 39.880662 1802.0089 2025.4302 271.90471 -223.42134 546.62696 900.79592 214.83879 0 -668.01506 513782.41 -515000.08 13.167029 25461.023 387.51997 1.7732181 375.29493 389.80736 1.773544 + 620 41.151704 1729.2181 1934.4658 259.69315 -205.24769 550.82063 913.19495 217.45935 0 -675.32746 513791.35 -515002.74 241.52954 25490.189 369.99117 1.9848435 365.94576 370.90937 1.9848435 + 640 42.367107 1658.2621 1869.4172 250.96067 -211.15505 560.62227 911.72129 213.95368 0 -665.21833 513766.85 -514999.08 3632.223 25516.498 357.58414 1.8379694 353.567 358.48938 1.8379694 + 660 43.641386 1588.4137 1852.2333 248.65382 -263.8196 577.15612 856.06817 203.8208 0 -643.32076 513743.58 -515001.12 1748.9053 25544.141 354.40947 1.5590879 342.18406 356.67449 1.5598187 + 680 44.916294 1522.8833 1803.3756 242.0949 -280.4923 569.2594 868.20962 207.92742 0 -667.28233 513741.85 -515000.45 -707.71197 25570.844 345.28497 0.99527257 329.41069 348.14899 0.99572941 + 700 46.126721 1461.9096 1769.8128 237.58924 -307.90315 542.7914 861.81473 203.22264 0 -674.68634 513754.76 -514995.8 1167.0096 25593.851 338.95839 0.74443058 320.56652 342.23742 0.74427874 + 720 47.342692 1403.7901 1774.9009 238.2723 -371.11079 533.63282 871.2916 186.94204 0 -661.24368 513696.56 -514998.29 1734.2343 25615.595 339.99734 0.59618884 315.31635 344.32074 0.59612251 + 740 48.606886 1347.7019 1788.1767 240.05451 -440.47482 551.44173 832.07818 173.00046 0 -679.31011 513685.34 -515003.03 1108.3607 25637.321 342.57548 0.51883795 311.99896 347.87957 0.51883795 + 760 49.886167 1294.2014 1732.3399 232.55868 -438.13849 563.187 825.18662 175.50788 0 -672.34818 513677.51 -515007.18 -2118.7763 25657.738 331.88911 0.47758368 305.31362 336.52173 0.47757969 + 780 51.181176 1243.7936 1720.77 231.00547 -476.9764 565.28094 800.5385 187.89263 0 -663.7818 513643.08 -515009.99 142.9942 25673.523 329.66915 0.48221433 293.10673 335.95739 0.48257178 + 800 52.501053 1195.7584 1713.4482 230.02255 -517.6898 575.29743 793.40588 182.96177 0 -652.3437 513594.18 -515011.19 2569.2035 25687.829 328.22734 0.57136512 282.06342 336.10937 0.57136512 + 820 53.730285 1149.3704 1688.6401 226.69218 -539.26966 566.02535 783.51259 170.42752 0 -645.21365 513596.56 -515010.58 158.43243 25703.753 323.41372 0.70633792 274.90722 331.6814 0.70633792 + 840 55.059346 1107.3402 1626.7277 218.38072 -519.38749 557.00463 817.13283 161.18356 0 -661.6802 513616.64 -515009.67 -859.99932 25718.477 311.42538 0.98533165 274.36623 317.78482 0.98533165 + 860 56.26804 1067.0989 1619.5401 217.41582 -552.44114 567.51474 819.44456 157.01002 0 -653.65749 513563.92 -515006.67 -110.22037 25730.521 309.90587 1.3158099 279.28284 315.1959 1.3158099 + 880 57.552129 1028.7737 1622.6482 217.83307 -593.87455 579.7559 769.38822 163.25737 0 -641.48094 513545.77 -515010.56 2044.3918 25741.489 310.33341 1.7085038 277.85767 315.93127 1.7085038 + 900 58.752011 990.85148 1635.8709 219.60816 -645.01941 590.07687 741.99946 160.20976 0 -648.65733 513521.95 -515010.6 -616.21441 25753.742 312.82551 1.8081896 279.97773 318.48679 1.8081896 + 920 60.02342 953.65737 1657.228 222.47525 -703.57061 574.2732 734.42873 151.5283 0 -657.51865 513506.29 -515012.57 -2391.2196 25763.907 316.97803 1.6721323 286.84832 322.1911 1.6717714 + 940 61.246864 917.3708 1532.2653 205.69958 -614.89448 576.8991 775.3663 162.78532 0 -639.35069 513524.45 -515015.04 564.89367 25770.107 293.21271 1.2280076 293.75433 293.31884 1.2282942 + 960 62.520232 883.18364 1537.9463 206.46223 -654.76268 563.51425 761.32405 161.47799 0 -631.38061 513503.44 -515013.14 1374.3226 25776.278 294.40866 0.9786147 300.31219 293.62423 0.97818807 + 980 63.72859 851.43088 1538.0246 206.47273 -686.59368 565.62724 756.61795 152.08723 0 -645.22417 513500.66 -515016.36 -203.76984 25783.711 294.53876 0.71003563 300.78246 293.69924 0.71029723 + 1000 65.325249 822.29342 1546.1186 207.55932 -723.82514 573.24707 705.27714 145.40402 0 -627.3824 513491.87 -515012.24 -1482.5195 25790.098 296.12917 0.61958842 301.40343 295.45106 0.61958842 + 1020 67.066265 795.41337 1551.6368 208.30012 -756.22343 597.40466 700.03219 143.14559 0 -631.02663 513445.32 -515011.1 748.62224 25794.159 297.21498 0.5543604 297.93873 297.29299 0.5543604 + 1040 68.784411 769.92029 1548.9081 207.9338 -778.9878 581.53993 723.87795 137.61133 0 -624.63041 513420.31 -515017.7 1356.2174 25798.811 296.7141 0.50251818 294.64447 297.25547 0.50251818 + 1060 70.531164 745.98628 1514.0024 203.24787 -768.0161 590.02417 718.13714 148.25485 0 -620.67061 513412.77 -515016.53 -984.90789 25804.672 289.98962 0.57944566 296.06714 289.17408 0.57944566 + 1080 72.339286 724.41988 1468.7378 197.17131 -744.31795 587.12574 750.82761 166.43289 0 -611.54088 513376.94 -515014.1 -1369.9774 25808.741 281.26901 0.68044534 297.86474 278.70146 0.68043227 + 1100 74.081078 705.1492 1475.7507 198.11275 -770.60147 596.03939 703.74275 166.87407 0 -604.94878 513382.71 -515015.02 322.11458 25810.632 282.54351 0.84350846 304.3263 279.11613 0.84359917 + 1120 75.92559 688.04772 1517.3948 203.70329 -829.34708 589.83314 688.24666 158.8665 0 -610.41803 513358.01 -515013.88 1171.4548 25812.799 290.41298 1.1090646 307.74167 287.73002 1.1090646 + 1140 77.724149 672.36504 1512.4831 203.04391 -840.11804 611.8019 686.11567 154.1589 0 -600.4798 513325.18 -515016.9 -1129.2791 25816.098 289.32063 1.4608372 307.70226 286.46216 1.4608372 + 1160 79.533442 657.64948 1524.9394 204.71611 -867.2899 614.09367 686.86805 145.77079 0 -587.50349 513287.47 -515013.99 -1405.9783 25817.666 291.61223 1.6855491 302.37391 290.02089 1.6855106 + 1180 81.243201 643.07936 1483.2148 199.11478 -840.13545 607.70554 729.46823 145.73396 0 -581.12793 513268.2 -515010.11 951.82863 25817.313 283.62844 1.6507547 296.31179 281.7127 1.6507678 + 1200 83.124235 628.84892 1508.103 202.45591 -879.25413 610.27958 699.47204 146.65751 0 -581.22705 513258.98 -515013.42 845.8635 25818.085 288.47775 1.4683346 288.26595 288.70552 1.4687429 + 1220 84.861868 615.48595 1506.3938 202.22645 -890.90781 640.61601 705.74981 149.24915 0 -568.44006 513197.45 -515015.53 -989.87699 25819.897 288.2897 1.1425522 284.47457 289.11499 1.1433225 + 1240 86.657973 603.46611 1521.8 204.29466 -918.3339 627.93094 681.9999 147.50604 0 -563.03024 513206.69 -515019.43 -1294.0886 25820.275 291.33208 0.93495852 284.52005 292.65658 0.93566845 + 1260 88.527368 592.83025 1550.0222 208.08336 -957.19193 638.74876 684.27892 144.10419 0 -567.28292 513161.98 -515019.02 366.82518 25818.88 296.84123 0.70423253 289.40784 298.27306 0.70423253 + 1280 90.26083 583.62238 1500.3203 201.41111 -916.69791 658.39007 717.40575 149.49357 0 -560.74831 513138.12 -515019.36 468.99306 25817.909 287.36089 0.59306602 294.54267 286.36029 0.59306602 + 1300 92.13165 575.42151 1519.3082 203.96014 -943.88664 655.72041 704.25181 141.32573 0 -550.47558 513125.5 -515020.21 -1022.3924 25817.559 291.00356 0.58689962 300.73954 289.58167 0.58691655 + 1320 93.894194 568.3477 1518.4074 203.83922 -950.05966 670.96379 726.82052 139.93925 0 -527.97883 513058.34 -515018.15 -972.06273 25815.822 290.83615 0.57457637 307.54777 288.256 0.57459152 + 1340 95.719114 562.07892 1523.1375 204.47422 -961.05857 677.25051 688.02873 138.64793 0 -528.35304 513081.3 -515017.94 1058.9949 25813.039 291.70253 0.66885112 312.02785 288.52311 0.66873042 + 1360 97.524416 556.93389 1560.3959 209.47598 -1003.462 665.73523 686.80959 139.77318 0 -523.04289 513045.29 -515018.03 937.16072 25811.796 298.7948 0.7861094 312.82634 296.66456 0.78666076 + 1380 99.357452 553.33396 1516.3062 203.55714 -962.97224 678.04454 713.74957 137.42774 0 -517.91272 513044.03 -515018.31 -292.99291 25811.915 290.25807 0.98357958 308.02329 287.50255 0.98357958 + 1400 101.09848 550.59887 1532.5676 205.74016 -981.9687 668.87709 700.85053 135.12927 0 -539.20798 513074.89 -515022.51 -1158.8487 25811.561 293.25245 1.2705054 302.5546 291.90379 1.2705054 + 1420 102.92972 548.73321 1476.7658 198.24903 -928.03261 677.96546 739.35433 145.56163 0 -552.34431 513084.77 -515023.34 9.5625031 25809.75 282.48418 1.436009 300.29464 279.71597 1.436009 + 1440 104.66752 547.12666 1527.8761 205.11036 -980.74947 650.61377 711.8671 147.59824 0 -556.66671 513090.53 -515024.69 1019.1836 25808.157 292.23402 1.5483375 300.12772 291.11848 1.5483375 + 1460 106.50314 545.65053 1490.3999 200.07935 -944.74941 670.75445 719.7737 150.18449 0 -549.39105 513087.25 -515023.32 -1319.4425 25807.672 285.07809 1.4821899 301.34029 282.56847 1.4823299 + 1480 108.28741 544.77516 1526.097 204.87152 -981.32183 652.3433 696.79415 149.20209 0 -556.6563 513098.18 -515021.18 -742.16174 25805.656 292.01497 1.2636175 302.51451 290.4664 1.2639932 + 1500 110.12511 545.19541 1545.583 207.48742 -1000.3876 645.73389 715.44716 136.9985 0 -567.26011 513090.87 -515022.18 -400.28471 25802.486 295.86865 0.987897 302.34922 294.99013 0.987897 + 1520 111.89057 546.1418 1523.2045 204.48322 -977.06274 643.78664 737.65713 128.87884 0 -556.6123 513087.83 -515018.61 382.6378 25799.004 291.65193 0.81691637 299.79434 290.49472 0.81691637 + 1540 113.68915 548.12322 1532.5317 205.73534 -984.40845 662.00085 713.14115 141.83628 0 -546.54637 513065.85 -515020.69 -558.02865 25796.128 293.49257 0.69415483 292.07299 293.92389 0.69415483 + 1560 115.74426 551.58749 1524.0291 204.59391 -972.44159 662.89347 709.62799 163.91089 0 -538.91833 513050.59 -515020.55 -1648.6737 25792.534 291.9015 0.60340834 283.91962 293.42109 0.60340834 + 1580 118.02455 556.31359 1557.1932 209.04604 -1000.8797 650.22504 703.18471 164.34921 0 -547.76291 513048.79 -515019.67 218.40066 25787.071 298.26162 0.59762744 279.75915 301.53187 0.59762744 + 1600 119.98362 561.8489 1536.2864 206.2394 -974.4375 650.4012 725.52549 152.37926 0 -524.6233 513039.24 -515017.36 724.91327 25782.038 294.23674 0.63726972 276.89513 297.31161 0.63726972 + 1620 121.24569 568.29298 1516.8518 203.6304 -948.55886 669.43634 758.17152 141.59579 0 -508.64869 513005.84 -515014.95 305.45057 25778.393 290.46698 0.74019001 276.01771 293.0592 0.74019001 + 1640 122.52086 575.42679 1531.3719 205.57965 -955.94515 683.26836 731.47049 143.09022 0 -504.62735 513005.89 -515015.04 -1258.1839 25775.243 293.18351 0.89655264 276.95868 296.07228 0.89655264 + 1660 123.85319 583.33428 1520.971 204.18338 -937.63676 670.138 752.36615 158.20486 0 -497.10065 512993.63 -515014.87 990.4476 25771.018 291.11283 1.0757415 276.8874 293.66833 1.0757415 + 1680 125.13263 591.99646 1532.4661 205.72654 -940.46967 689.25478 743.16987 168.03522 0 -502.0189 512975.1 -515014.01 1349.4251 25768.301 293.2049 1.3360644 279.26444 295.71449 1.3360644 + 1700 126.41729 600.72595 1576.928 211.69534 -976.20204 698.82384 728.20266 164.32429 0 -509.63109 512960.78 -515018.71 -714.74537 25767.499 301.65964 1.4963853 288.03969 304.12166 1.4963853 + 1720 127.8002 608.72776 1572.2293 211.06457 -963.50155 686.50487 751.5254 162.66596 0 -520.30848 512974.4 -515018.29 -1233.7505 25765.895 300.75432 1.507047 296.46478 301.66689 1.507047 + 1740 129.05369 615.86972 1571.5987 210.97992 -955.72903 672.03255 760.03518 170.57691 0 -531.78859 512987.74 -515014.32 -5.6954413 25762.646 300.66959 1.422713 303.78613 300.35269 1.422713 + 1760 130.46587 622.55796 1579.5377 212.04568 -956.97974 706.80226 734.80437 178.63803 0 -529.02192 512966.71 -515014.91 1439.5408 25759.728 302.30266 1.1633531 310.55359 301.13515 1.1641118 + 1780 131.77476 628.52662 1584.4407 212.70388 -955.91404 676.79766 773.29727 172.22703 0 -534.56221 512976.35 -515020.03 -1144.3707 25758.632 303.36936 0.86750014 314.93649 301.6529 0.86760316 + 1800 133.12003 634.21603 1614.4896 216.73781 -980.27353 677.17437 758.17735 157.86038 0 -522.96761 512972.14 -515022.66 -952.36111 25756.246 309.15671 0.80472277 318.00054 307.89448 0.80488217 + 1820 134.41588 639.49479 1633.2745 219.2596 -993.77971 706.25176 736.76382 153.75695 0 -523.32693 512955.21 -515022.44 534.27821 25752.618 312.8094 0.68438418 326.33448 310.77281 0.68437053 + 1840 135.69809 643.87101 1634.8429 219.47015 -990.97185 701.84421 766.76216 151.35177 0 -502.94871 512911.91 -515019.89 654.67154 25749.912 313.13395 0.62866073 330.35595 310.48258 0.62856511 + 1860 137.01849 646.9769 1624.5262 218.08519 -977.54933 717.81093 788.02881 151.94179 0 -495.90915 512881.92 -515021.34 -1064.2782 25748.146 311.14125 0.66359764 330.55161 308.12656 0.66359764 + 1880 138.29577 648.32991 1639.5616 220.10361 -991.23166 726.93665 759.79041 159.81907 0 -493.81895 512873.87 -515017.83 -1411.6366 25744.916 313.99078 0.74007658 329.3198 311.65549 0.74007658 + 1900 139.67366 648.89417 1644.4291 220.75706 -995.53493 724.72865 762.39029 163.96612 0 -495.61342 512866.53 -515017.54 1351.1833 25740.228 314.85836 0.89300573 324.54001 313.46241 0.89316115 + 1920 140.93714 648.51479 1660.4204 222.90381 -1011.9056 683.6849 759.17365 164.85228 0 -494.26512 512891.03 -515016.38 401.57284 25737.361 317.86954 1.0199045 319.35529 317.83552 1.0202343 + 1940 142.29997 646.69169 1612.2108 216.43189 -965.51908 714.97385 778.57354 175.15205 0 -508.7717 512893.53 -515018.97 -1076.6986 25735.181 308.53939 1.2258299 312.47436 308.09188 1.2258299 + 1960 143.5485 643.66804 1612.4723 216.467 -968.80423 729.94319 778.86473 177.62474 0 -483.88964 512849.44 -515020.79 -696.10678 25731.708 308.50602 1.4206534 300.71602 310.00483 1.4206534 + 1980 144.89715 639.49991 1600.0251 214.79602 -960.52514 725.68053 773.8468 176.16615 0 -469.86188 512851.09 -515017.45 822.18174 25727.586 306.08335 1.5058554 291.63271 308.68799 1.505066 + 2000 146.15013 633.86554 1648.9263 221.36078 -1015.0607 703.29388 761.03433 170.08933 0 -468.34451 512835.81 -515016.94 763.74636 25724.778 315.51687 1.3681009 284.57812 320.86295 1.3683497 +Loop time of 146.15 on 1 procs for 2000 steps with 3000 atoms + +Performance: 0.591 ns/day, 40.597 hours/ns, 13.685 timesteps/s +100.0% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 92.462 | 92.462 | 92.462 | 0.0 | 63.26 +Bond | 2.9377 | 2.9377 | 2.9377 | 0.0 | 2.01 +Kspace | 28.493 | 28.493 | 28.493 | 0.0 | 19.50 +Neigh | 4.3811 | 4.3811 | 4.3811 | 0.0 | 3.00 +Comm | 0.86167 | 0.86167 | 0.86167 | 0.0 | 0.59 +Output | 0.040132 | 0.040132 | 0.040132 | 0.0 | 0.03 +Modify | 16.886 | 16.886 | 16.886 | 0.0 | 11.55 +Other | | 0.08886 | | | 0.06 + +Nlocal: 3000.00 ave 3000 max 3000 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 10696.0 ave 10696 max 10696 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 737603.0 ave 737603 max 737603 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 737603 +Ave neighs/atom = 245.86767 +Ave special neighs/atom = 10.500000 +Neighbor list builds = 59 +Dangerous builds = 0 +Total wall time: 0:02:26 diff --git a/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 new file mode 100644 index 0000000000..d8b7046fbc --- /dev/null +++ b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 @@ -0,0 +1,287 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.600 8.0 +kspace_style pppm 1.0e-4 + +comm_modify vel yes +read_data data.ethanol +Reading data file ... + orthogonal box = (-14.013845 -14.027809 -14.018882) to (14.016930 14.017730 14.085730) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 3000 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 2750 bonds + reading angles ... + 3250 angles + reading dihedrals ... + 3000 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 6 = max # of 1-3 neighbors + 10 = max # of 1-4 neighbors + 11 = max # of special neighbors + special bonds CPU = 0.003 seconds + read_data CPU = 0.115 seconds + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H CTO +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 1 4 lj/cut/coul/long 0.105921 3.304542 # C3H OH +pair_coeff 1 5 lj/cut/coul/long 0.000000 0.000000 # C3H HO +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # CTO CTO +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # CTO H +pair_coeff 2 4 lj/cut/coul/long 0.105921 3.304542 # CTO OH +pair_coeff 2 5 lj/cut/coul/long 0.000000 0.000000 # CTO HO +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff 3 4 lj/cut/coul/long 0.071413 2.792848 # H OH +pair_coeff 3 5 lj/cut/coul/long 0.000000 0.000000 # H HO +pair_coeff 4 4 lj/cut/coul/long 0.169996 3.120000 # OH OH +pair_coeff 4 5 lj/cut/coul/long 0.000000 0.000000 # OH HO +pair_coeff 5 5 lj/cut/coul/long 0.000000 0.000000 # HO HO +pair_coeff * 6*8 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 1 thole 2.051000 +pair_coeff 1 2 thole 1.580265 +pair_coeff 1 4 thole 1.416087 +pair_coeff 1 6 thole 2.051000 +pair_coeff 1 7 thole 1.580265 +pair_coeff 1 8 thole 1.416087 +pair_coeff 2 2 thole 1.217570 +pair_coeff 2 4 thole 1.091074 +pair_coeff 2 6 thole 1.580265 +pair_coeff 2 7 thole 1.217570 +pair_coeff 2 8 thole 1.091074 +pair_coeff 4 4 thole 0.977720 +pair_coeff 4 6 thole 1.416087 +pair_coeff 4 7 thole 1.091074 +pair_coeff 4 8 thole 0.977720 +pair_coeff 6 6 thole 2.051000 +pair_coeff 6 7 thole 1.580265 +pair_coeff 6 8 thole 1.416087 +pair_coeff 7 7 thole 1.217570 +pair_coeff 7 8 thole 1.091074 +pair_coeff 8 8 thole 0.977720 + +group gETHANOL molecule 1:250 +3000 atoms in group gETHANOL +group gATOMS type 1 2 3 4 5 +2250 atoms in group gATOMS +group gDRUDES type 6 7 8 +750 atoms in group gDRUDES + +neighbor 2.0 bin + +variable vTEMP equal 300.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gATOMS create ${vTEMP} 12345 +velocity gATOMS create 300 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N C N D D D + +fix fSHAKE gATOMS shake 0.0001 20 0 b 2 3 5 + 250 = # of size 2 clusters + 250 = # of size 3 clusters + 250 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.001 seconds + +fix fNPT all tgnpt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 1 1000 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] +thermo 20 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.37973843 + grid = 30 30 30 + stencil order = 5 + estimated absolute RMS force accuracy = 0.028997858 + estimated relative force accuracy = 8.7326188e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 17908 7200 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 11 +New max number of 1-2 to 1-4 neighbors: 11 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 6 6 6 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 4500.0 2250.0 +Per MPI rank memory allocation (min/avg/max) = 16.30 | 16.32 | 16.34 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] + 0 0 13868.828 2013.3852 270.28772 11855.443 3145.896 51.880809 0.00019113234 0 8481.5109 514734.14 -514557.98 170210.19 22094.109 381.62759 10.134301 291.07893 396.91308 10.134301 + 20 0.5489804 9803.4819 5175.7976 694.82706 4627.6843 1139.1179 2334.7381 132.32214 0 1890.1377 514082.74 -514951.37 83147.098 22175.037 987.97841 9.8830686 2458.1459 744.58371 9.8830686 + 40 1.1305859 9235.5604 5579.723 749.0522 3655.8374 905.64066 1897.9743 277.47993 0 1696.6152 513843.93 -514965.8 60300.791 22359.784 1068.9531 1.6180875 2851.9045 773.69577 1.6180875 + 60 1.7763265 8672.0018 5504.7529 738.98781 3167.2488 829.16747 2052.5807 330.50296 0 997.97233 513948.23 -514991.2 48877.822 22600.434 1054.8974 0.8814188 3046.2785 725.0302 0.8814188 + 80 2.3974232 8041.5241 5718.5668 767.69134 2322.9573 733.63486 1714.8909 332.16188 0 607.44872 513906.01 -514971.19 46157.199 22855.699 1095.9682 0.68487797 2911.1669 795.37545 0.68487797 + 100 3.0302813 7424.2386 5485.3388 736.38155 1938.8999 725.65842 1556.2309 334.30067 0 311.29882 513993.24 -514981.83 35648.625 23094.994 1051.3251 0.52778467 2722.3899 774.63067 0.52778467 + 120 3.6273007 6864.3426 5106.0771 685.46741 1758.2655 639.83956 1608.9962 330.73079 0 225.62345 513930.12 -514977.04 28591.458 23302.572 978.66797 0.41866327 2531.1648 721.6052 0.41866327 + 140 4.196656 6355.3019 4782.0272 641.9652 1573.2747 692.74007 1572.242 329.76251 0 62.485696 513879.64 -514963.6 24167.635 23482.68 916.57384 0.35834425 2382.631 673.81858 0.35834425 + 160 4.779717 5871.7118 4610.7111 618.9668 1261.0006 680.57069 1414.3177 329.24321 0 -159.81123 513987.38 -514990.7 27541.231 23647.415 883.72945 0.36200572 2123.9268 678.44584 0.36200572 + 180 5.338641 5435.6217 4279.7314 574.5343 1155.8903 684.86021 1423.9782 309.42239 0 -233.49805 513945.42 -514974.29 18687.102 23808.747 820.29876 0.31648848 1867.6601 646.98347 0.31648848 + 200 5.9102262 5063.7313 3974.8766 533.60893 1088.8548 610.8373 1399.1355 299.45065 0 -238.66713 514006.14 -514988.04 14346.964 23962.508 761.84531 0.34591369 1649.624 614.98194 0.34591369 + 220 6.4670983 4729.6679 3862.1203 518.47192 867.54758 589.19356 1361.7383 291.57325 0 -382.16606 514000.72 -514993.51 14083.524 24105.992 740.21525 0.37963928 1480.8429 617.76448 0.37963928 + 240 7.0337756 4425.2126 3701.4126 496.89765 723.79998 584.3439 1295.3888 282.13205 0 -468.28082 514014.44 -514984.22 13173.086 24240.879 709.38377 0.43418988 1335.0115 606.00249 0.43418988 + 260 7.6151553 4147.9089 3443.8677 462.32342 704.04123 561.65864 1304.8745 277.43914 0 -505.26328 514062.78 -514997.45 9958.5179 24367.421 659.97189 0.52765671 1202.5793 570.33937 0.52753359 + 280 8.1803862 3906.1678 3262.9801 438.0401 643.18765 611.98615 1259.2636 278.89902 0 -503.31011 513978.3 -514981.95 5914.4091 24482.749 625.21285 0.7191852 1076.0582 550.78956 0.7191852 + 300 8.7043311 3688.7789 3139.2097 421.42449 549.56918 589.70836 1228.8579 274.66549 0 -529.44562 513979.71 -514993.93 8820.6294 24584.968 601.2678 1.2327257 967.30569 540.9051 1.2327257 + 320 9.2828722 3485.0301 3041.6251 408.32421 443.40492 581.268 1221.8962 276.57911 0 -581.90861 513938.2 -514992.63 9180.621 24679.345 582.26671 1.9139563 865.07721 535.70848 1.9139563 + 340 9.8440863 3301.0782 2892.3054 388.27872 408.77286 575.63973 1150.7154 289.94072 0 -522.07034 513896.97 -514982.42 7703.8271 24768.334 553.40856 2.4558958 782.77492 515.70254 2.4558958 + 360 10.398275 3134.468 2727.432 366.14522 407.03603 560.03929 1167.6565 290.68699 0 -534.30813 513917.05 -514994.09 5177.6501 24851.165 521.97249 2.0603668 720.8089 489.31359 2.0603668 + 380 10.971208 2978.8927 2626.9512 352.65614 351.94143 566.26677 1159.7933 275.53948 0 -574.10697 513905.99 -514981.54 5406.9463 24926.487 502.95796 1.4831172 663.80755 476.59194 1.4833313 + 400 11.487591 2830.3779 2572.5528 345.3534 257.82518 609.13682 1122.447 253.59547 0 -631.51589 513897.17 -514993.01 6594.5632 24996.158 492.72116 1.0347263 619.38728 472.02151 1.0352452 + 420 12.147771 2690.8114 2511.4485 337.15043 179.36289 580.62912 1054.4972 245.98614 0 -619.15187 513904.39 -514986.98 3340.3887 25062.398 481.15102 0.69884987 565.60536 467.45245 0.69884987 + 440 12.683915 2567.8386 2417.1223 324.48758 150.71626 550.84021 1061.6154 248.79898 0 -625.11745 513892.15 -514977.57 1516.8529 25122.396 463.15967 0.48668891 522.23117 453.66261 0.48668891 + 460 13.219765 2452.4983 2377.8819 319.21973 74.616329 562.85065 1024.1437 240.77499 0 -664.71238 513899.97 -514988.41 2625.4899 25175.085 455.6735 0.40127583 488.72927 450.48999 0.40127583 + 480 13.734817 2343.3317 2306.9816 309.70169 36.35008 544.98865 1036.7003 239.14437 0 -646.5969 513844.75 -514982.63 4826.9949 25223.402 442.07562 0.41558073 466.54905 438.30802 0.41558073 + 500 14.2704 2236.968 2183.0006 293.0578 53.967445 569.68824 1077.5153 241.06612 0 -644.36418 513802.58 -514992.52 3137.1149 25270.633 418.31485 0.39923526 447.67208 413.72065 0.39935381 + 520 14.830149 2139.9757 2184.3136 293.23408 -44.337922 598.68848 949.68592 231.65813 0 -640.55841 513811.34 -514995.15 74.532539 25314.977 418.54937 0.44074429 424.27621 417.87775 0.44074429 + 540 15.342945 2047.7713 2097.3453 281.55898 -49.574068 603.65225 992.19405 234.95516 0 -644.08949 513763.2 -514999.49 2503.1827 25353.667 401.80131 0.61813129 402.19428 402.00395 0.61813129 + 560 15.876281 1959.9733 2106.7002 282.81483 -146.72689 554.39132 933.09924 226.68229 0 -642.41154 513779.76 -514998.25 3929.9055 25390.434 403.5098 0.81842484 386.57171 406.59055 0.81842484 + 580 16.38257 1878.3658 2030.0966 272.53115 -151.7308 563.56362 914.74758 216.22925 0 -639.68928 513785.76 -514992.34 1013.3048 25427.188 388.65548 1.2108332 381.10541 390.16777 1.2108332 + 600 16.920685 1802.551 2017.1476 270.7928 -214.59656 542.55586 900.05624 215.01335 0 -670.18556 513796.03 -514998.07 18.493782 25460.775 385.93337 1.7700661 377.13463 387.65116 1.7700661 + 620 17.474131 1730.0309 1927.5545 258.76534 -197.52353 548.09305 912.68313 219.66229 0 -677.86412 513801.32 -515001.42 211.58879 25489.947 368.6727 1.9725715 368.40356 368.96285 1.9725715 + 640 17.983631 1659.1463 1874.5489 251.64958 -215.40256 560.91381 910.47755 215.67628 0 -668.88025 513765.74 -514999.33 3576.6139 25516.217 358.58525 1.8035012 356.22593 359.21531 1.8035012 + 660 18.557287 1589.2837 1850.4075 248.40872 -261.12386 578.2925 854.48492 205.27001 0 -645.94735 513747.59 -515000.82 1704.7835 25543.749 354.0776 1.5147284 344.22319 355.94967 1.5157289 + 680 19.099188 1523.7572 1809.2809 242.88766 -285.52371 571.10597 870.42753 209.32749 0 -670.04285 513734.83 -515001.17 -730.02178 25570.285 346.40935 1.010892 331.62309 349.09523 1.010892 + 700 19.606934 1462.426 1781.0971 239.10411 -318.67111 547.9598 858.22372 204.5839 0 -674.26004 513742.06 -514997.24 1193.1019 25593.123 341.12225 0.74301975 322.22823 344.48583 0.74301975 + 720 20.138988 1403.965 1772.7176 237.9792 -368.75257 537.38813 872.15383 187.31368 0 -658.83726 513691.57 -514998.34 1717.9835 25614.736 339.57934 0.59520661 315.58412 343.78893 0.59520661 + 740 20.654731 1347.9142 1778.2063 238.71603 -430.29207 554.12065 833.24568 175.13397 0 -676.57227 513685.79 -515002.01 1164.2855 25636.35 340.66194 0.52336173 311.70411 345.69611 0.52336173 + 760 21.20085 1294.8201 1727.5363 231.91382 -432.71627 562.83637 826.41881 177.39944 0 -670.89859 513677.68 -515006.15 -2179.3296 25656.719 330.96325 0.48927201 305.61756 335.39128 0.48927201 + 780 21.736798 1244.1479 1729.459 232.17193 -485.31103 563.29093 800.45744 179.65918 0 -660.60078 513641.9 -515010.01 140.35372 25672.399 331.32725 0.49993893 293.14787 337.88591 0.49993893 + 800 22.313875 1195.9276 1716.8118 230.47411 -520.8842 572.20526 790.59915 174.22123 0 -646.04585 513597.21 -515009.08 2706.2932 25686.61 328.8596 0.60065349 282.54175 336.7676 0.60065349 + 820 22.880819 1149.3267 1681.646 225.75325 -532.31925 564.24784 783.06404 168.40012 0 -638.53799 513598.2 -515007.69 291.5994 25702.646 322.07401 0.70343079 279.53588 329.34955 0.70332477 + 840 23.400356 1107.2877 1640.6002 220.24304 -533.31252 558.56409 815.12167 157.71519 0 -653.87313 513597.92 -515008.76 -762.24777 25717.669 314.07832 1.0007715 278.89623 320.12842 1.0010942 + 860 23.930137 1066.5896 1621.3757 217.66224 -554.78609 569.30332 821.05893 152.83409 0 -645.45431 513552.23 -515004.75 100.50325 25730.157 310.25167 1.3271389 283.08497 314.96823 1.3271389 + 880 24.425549 1027.6567 1624.8454 218.12803 -597.18868 587.96681 765.45362 159.91238 0 -628.42404 513525.88 -515007.98 2270.6911 25741.827 310.74777 1.7225758 280.31191 316.00736 1.7225758 + 900 24.945527 989.67183 1619.7368 217.44223 -630.06494 605.34666 753.15286 166.12808 0 -637.67643 513491.85 -515008.87 -504.34781 25755.03 309.75098 1.7673447 280.95321 314.73839 1.7673447 + 920 25.481976 952.75609 1646.0573 220.97563 -693.30118 586.10824 737.80362 161.44982 0 -645.91448 513480.65 -515013.4 -2245.0436 25766.26 314.83888 1.6620102 286.24272 319.79545 1.6618169 + 940 26.009417 916.27341 1558.2262 209.18472 -641.95282 584.88671 784.61327 161.29551 0 -636.55462 513482.98 -515019.17 351.20595 25773.56 298.17626 1.2572795 293.25423 299.19214 1.2573671 + 960 26.54868 881.26579 1570.5631 210.84088 -689.29727 567.48803 757.85558 154.89763 0 -628.37927 513476.62 -515017.78 1224.7198 25780.472 300.67272 0.95167357 297.40913 301.41483 0.95167357 + 980 27.082306 848.00567 1563.3504 209.87262 -715.34478 576.51161 766.15302 148.2325 0 -637.27495 513450.83 -515019.79 -304.57224 25788.336 299.38564 0.72910884 295.89994 300.16415 0.72910884 + 1000 27.619404 817.47747 1553.8221 208.59349 -736.34466 586.86696 709.60783 150.55877 0 -608.57994 513440.8 -515015.6 -1422.5332 25794.968 297.60262 0.62762006 294.24682 298.35812 0.62773318 + 1020 28.12313 789.1786 1563.9655 209.95519 -774.78691 608.04057 694.03517 152.80101 0 -605.61567 513386.72 -515010.76 1005.4938 25799.349 299.58342 0.54306229 290.32557 301.31971 0.54293571 + 1040 28.647646 762.65087 1534.0005 205.93252 -771.3496 587.61838 735.74998 150.09823 0 -603.04152 513371.63 -515013.4 1470.8094 25804.634 293.84005 0.54036941 291.28531 294.46003 0.54036941 + 1060 29.166844 737.77923 1518.4576 203.84597 -780.67842 594.18573 720.72071 149.63679 0 -601.17736 513365.82 -515009.86 -729.10372 25811.329 290.84548 0.57532052 295.86391 290.20631 0.57532052 + 1080 29.694185 715.33941 1497.4861 201.03063 -782.14665 601.83156 732.61956 157.72044 0 -593.12281 513331.09 -515012.29 -1329.475 25816.507 286.76945 0.70534246 298.86373 284.95298 0.70534246 + 1100 30.187888 694.69953 1511.5454 202.91803 -816.84589 616.66719 703.13897 158.99611 0 -577.76244 513295.95 -515013.83 324.57282 25819.509 289.39998 0.85625823 302.74025 287.37843 0.85625823 + 1120 30.72232 675.80012 1511.985 202.97705 -836.18488 604.64779 695.06693 153.9432 0 -584.60486 513304.31 -515009.54 1125.7488 25822.677 289.3669 1.1300709 304.44007 287.0563 1.1300629 + 1140 31.225571 658.36551 1521.8389 204.29988 -863.47335 629.12728 674.88861 150.24405 0 -590.89933 513286.66 -515013.49 -980.39731 25826.849 291.15043 1.376207 307.33908 288.65717 1.3761333 + 1160 31.744542 641.31431 1531.9582 205.65836 -890.64389 626.42495 680.62653 148.56061 0 -577.09298 513242.55 -515011.72 -1275.5851 25829.398 292.96469 1.6693561 303.6583 291.38487 1.6693561 + 1180 32.314241 624.85166 1471.4431 197.53448 -846.59145 617.3346 711.86666 153.07391 0 -572.06725 513251.25 -515008.05 1129.9547 25830.175 281.38976 1.6087801 294.57721 279.38824 1.6087801 + 1200 32.836834 609.19491 1498.3739 201.14982 -889.17902 629.25511 684.67985 160.94667 0 -569.8543 513217.89 -515012.1 714.83828 25832.193 286.64705 1.3880783 283.02115 287.44058 1.3888122 + 1220 33.330996 594.74278 1478.8355 198.52688 -884.09277 636.92004 698.39685 160.32561 0 -562.35565 513195.99 -515013.37 -758.81758 25835.054 283.01514 1.1229017 278.46407 283.95841 1.1229296 + 1240 33.860993 582.31866 1493.1918 200.45414 -910.87313 618.74977 681.25809 152.31533 0 -562.54483 513217.1 -515017.75 -1008.5931 25836.703 285.8671 0.88995954 281.0699 286.85402 0.88995954 + 1260 34.359886 571.65412 1485.3064 199.39557 -913.6523 627.02685 698.36302 149.47819 0 -579.83549 513207.17 -515015.85 -191.59975 25836.765 284.43438 0.70581205 287.41841 284.12865 0.70581205 + 1280 34.886036 563.01807 1489.0976 199.90452 -926.07957 639.7656 697.32018 156.99221 0 -585.76217 513181.62 -515016.02 169.07813 25836.47 285.20229 0.61087596 293.46017 284.02179 0.61087596 + 1300 35.37543 555.84411 1527.2006 205.01966 -971.35646 641.09274 662.1865 159.13537 0 -579.97157 513161.92 -515015.72 -1463.4981 25836.182 292.51734 0.58590366 295.34409 292.24276 0.58590366 + 1320 35.905183 550.05933 1490.5448 200.09879 -940.48543 625.52991 696.21744 165.64927 0 -566.29494 513152.4 -515013.99 -1001.3282 25833.961 285.49188 0.58134778 295.28397 284.05681 0.58136859 + 1340 36.400304 545.82552 1477.3653 198.3295 -931.53974 649.76738 698.13673 166.18782 0 -561.79356 513131.65 -515015.49 256.39573 25830.414 282.92884 0.6685389 293.55866 281.35291 0.66910289 + 1360 36.922034 543.45958 1491.565 200.23575 -948.10541 625.58496 716.94864 163.71131 0 -571.55519 513134.22 -515017.02 297.35038 25827.363 285.59777 0.79202277 296.88495 283.9144 0.79202277 + 1380 37.451357 542.88076 1508.4282 202.49956 -965.54741 646.84583 717.12486 157.01613 0 -570.9963 513101.79 -515017.33 -727.70264 25824.817 288.73715 1.0078391 299.43294 287.15417 1.0078391 + 1400 37.973437 543.25917 1541.9768 207.00331 -998.71768 642.88473 676.64442 147.18972 0 -575.45961 513127.78 -515017.75 -1351.9224 25821.311 295.05395 1.2758201 298.33888 294.70535 1.2758201 + 1420 38.477087 544.25328 1494.226 200.59298 -949.97275 637.44698 691.08413 146.44269 0 -570.05548 513163.4 -515018.29 -270.25101 25816.213 285.82275 1.45608 293.72434 284.70163 1.45608 + 1440 39.004978 546.23983 1496.1396 200.84988 -949.89981 631.74619 738.457 152.80933 0 -573.9543 513118.44 -515017.39 211.73327 25811.001 286.12443 1.60978 287.34634 286.11175 1.60978 + 1460 39.506582 548.84457 1466.6766 196.8946 -917.83206 633.37692 721.14643 162.99807 0 -556.88904 513139.89 -515018.35 -423.45238 25806.343 280.53109 1.4808771 287.46457 279.56727 1.4808771 + 1480 40.013021 551.95616 1529.776 205.3654 -977.81982 643.3714 687.91646 168.45052 0 -559.19128 513096.53 -515014.9 -1060.0608 25801.347 292.71931 1.2657554 295.62549 292.43217 1.2657554 + 1500 40.538129 555.97974 1537.2966 206.37501 -981.31688 625.22061 717.66026 158.35427 0 -572.42591 513106.71 -515016.83 -521.38973 25795.193 294.26369 1.0278009 305.22402 292.64051 1.0278009 + 1520 41.025889 561.04463 1546.2574 207.57796 -985.21278 635.77714 721.02166 143.98506 0 -562.3667 513090.07 -515013.7 480.66458 25788.679 296.07983 0.80049966 308.03207 294.29295 0.80049966 + 1540 41.55805 566.68767 1533.2704 205.83452 -966.58278 654.42171 733.05018 143.06827 0 -536.78594 513051.91 -515012.25 -13.266306 25783.154 293.62787 0.70845158 300.7356 292.64315 0.70845158 + 1560 42.081834 573.47741 1545.9514 207.53687 -972.47397 667.35837 705.11749 148.50883 0 -511.03863 513035.3 -515017.72 -1128.9314 25777.865 296.082 0.65411382 299.13367 295.77283 0.65411382 + 1580 42.665773 580.84578 1594.8648 214.10328 -1014.0191 665.14281 711.19644 150.09976 0 -528.59268 513008.73 -515020.6 202.40236 25771.588 305.48503 0.59346496 305.13087 305.74762 0.59346496 + 1600 43.198806 587.93053 1593.0533 213.8601 -1005.1228 667.00914 717.18229 154.08514 0 -518.43498 512998.02 -515022.99 1129.067 25765.95 305.11474 0.64754135 305.66863 305.22598 0.64754135 + 1620 43.714818 594.73059 1540.0228 206.74099 -945.29217 676.98346 739.79112 155.99494 0 -494.24155 512994.51 -515018.33 526.11962 25762.249 294.90314 0.75499506 297.8325 294.6134 0.75499506 + 1640 44.259458 602.01816 1574.0462 211.30848 -972.02805 663.3896 727.17417 151.24073 0 -494.0956 513000.57 -515020.3 -575.47503 25759.514 301.37613 0.86690808 296.74738 302.34638 0.86686227 + 1660 44.764134 609.8688 1585.4465 212.83891 -975.57766 664.90151 754.20462 143.39975 0 -512.60013 512995.21 -515020.69 120.01767 25756.288 303.44799 1.1375937 302.29356 303.8427 1.1375483 + 1680 45.295079 617.0121 1599.4294 214.71606 -982.41735 673.71348 740.31978 139.29744 0 -523.39592 513004.17 -515016.52 1018.995 25753.537 306.06349 1.2857605 306.24911 306.23701 1.2851446 + 1700 45.797194 622.7816 1587.5062 213.11542 -964.72461 681.14985 737.5354 142.64373 0 -527.89471 513016.69 -515014.85 -762.54382 25752.152 303.67113 1.5346092 313.56414 302.2316 1.5344941 + 1720 46.320299 627.3514 1607.6889 215.82486 -980.33755 664.85413 752.47086 151.63477 0 -558.53514 513025.83 -515016.59 -1533.2781 25749.855 307.5455 1.5204255 324.85436 304.8785 1.5204255 + 1740 46.830115 630.51695 1598.6908 214.6169 -968.17382 653.58364 747.05167 160.79211 0 -580.54509 513063.86 -515012.91 -682.94257 25745.444 305.87278 1.3989272 333.2609 301.5297 1.3989272 + 1760 47.394788 632.38111 1593.237 213.88475 -960.85589 650.78705 764.11644 167.2889 0 -573.51639 513045.53 -515015.07 563.26755 25740.336 304.94629 1.1225547 334.94227 300.17035 1.1225547 + 1780 47.922889 633.30997 1598.6499 214.61141 -965.33996 653.54119 765.83593 164.00427 0 -562.23222 513033.51 -515020 -1327.8381 25735.912 306.08499 0.88668411 334.15679 301.62884 0.88668411 + 1800 48.463113 633.70382 1649.9701 221.50091 -1016.2663 659.96781 745.28779 159.23213 0 -549.62971 512990.43 -515021.55 -1220.9829 25730.022 315.99137 0.72802345 326.79654 314.40852 0.72802345 + 1820 48.984029 633.58292 1659.156 222.73407 -1025.573 665.57877 731.85128 149.46328 0 -533.84488 512983.77 -515022.39 259.29033 25722.788 317.77089 0.68459607 313.70692 318.65732 0.68459607 + 1840 49.535432 632.84896 1602.3796 215.1121 -969.53059 677.68273 790.85762 153.52845 0 -510.95603 512938.27 -515018.91 271.83168 25716.16 306.91304 0.62307528 301.73642 307.97704 0.62193772 + 1860 50.131212 631.44034 1614.3342 216.71695 -982.89384 704.07775 755.95641 164.4832 0 -496.35082 512910.85 -515021.91 193.91175 25710.384 309.1988 0.63700741 295.94067 311.60525 0.63654587 + 1880 50.855644 629.18958 1597.9323 214.51508 -968.74275 705.91154 777.10222 163.27419 0 -490.72673 512895.73 -515020.04 -974.53867 25705.004 306.00767 0.74633313 296.65573 307.7641 0.74633313 + 1900 51.442767 625.97644 1641.4591 220.35835 -1015.4827 686.52567 770.03702 156.74058 0 -497.98541 512884.62 -515015.42 634.14021 25698.897 314.30703 0.85093529 303.58173 316.29697 0.85093529 + 1920 52.143124 621.81199 1629.0055 218.68651 -1007.1935 697.66793 744.88149 154.37261 0 -496.80305 512905.46 -515012.77 706.77423 25693.859 311.83949 1.0371868 309.16955 312.48998 1.0372355 + 1940 52.903306 616.46004 1627.6423 218.50351 -1011.1823 701.93564 779.10792 151.5545 0 -486.4562 512854.72 -515012.04 -356.74685 25690.093 311.50393 1.2116518 310.99764 311.79486 1.2113866 + 1960 53.626542 609.78344 1638.9504 220.02157 -1029.167 696.4213 776.28011 154.35764 0 -474.71134 512832.29 -515013.81 -303.73538 25686.165 313.59711 1.3852662 315.5116 313.48837 1.3852662 + 1980 54.31028 600.96661 1637.173 219.78295 -1036.2064 718.42192 759.0789 153.6092 0 -472.50282 512815.84 -515010.66 -151.6766 25681.92 313.21609 1.4792586 321.24113 312.09275 1.4792586 + 2000 54.986641 589.81965 1648.0734 221.24629 -1058.2538 690.75922 747.98481 160.84305 0 -487.54224 512840.7 -515011 980.73982 25677.907 315.36457 1.3399431 321.77651 314.51049 1.3399431 +Loop time of 54.9868 on 4 procs for 2000 steps with 3000 atoms + +Performance: 1.571 ns/day, 15.274 hours/ns, 36.372 timesteps/s +98.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 27.901 | 28.34 | 29.027 | 7.9 | 51.54 +Bond | 0.92918 | 0.94546 | 0.97217 | 1.7 | 1.72 +Kspace | 14.647 | 15.356 | 15.836 | 11.2 | 27.93 +Neigh | 1.6543 | 1.6584 | 1.6622 | 0.2 | 3.02 +Comm | 1.5279 | 1.6227 | 1.7184 | 5.6 | 2.95 +Output | 0.022354 | 0.027337 | 0.040941 | 4.8 | 0.05 +Modify | 5.7813 | 6.226 | 6.5243 | 12.2 | 11.32 +Other | | 0.8108 | | | 1.47 + +Nlocal: 750.000 ave 763 max 736 min +Histogram: 1 0 0 0 1 0 1 0 0 1 +Nghost: 6184.00 ave 6204 max 6165 min +Histogram: 1 0 0 1 0 0 1 0 0 1 +Neighs: 185088.0 ave 189615 max 180533 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 740354 +Ave neighs/atom = 246.78467 +Ave special neighs/atom = 10.500000 +Neighbor list builds = 63 +Dangerous builds = 0 +Total wall time: 0:00:55 diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index 8b9e2035a0..148a23a92f 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://lammps.sandia.gov/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -11,9 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- +/* ------------------------------------------------------------------------------------- Contributing authors: Mark Stevens (SNL), Aidan Thompson (SNL), Zheng Gong (ENS Lyon) -------------------------------------------------------------------------- */ +---------------------------------------------------------------------------------------- */ #include "fix_tgnh_drude.h" #include @@ -50,7 +50,7 @@ enum{ISO,ANISO,TRICLINIC}; FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - rfix(NULL), irregular(NULL), id_temp(NULL), id_press(NULL) + rfix(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix nvt/npt/nph command"); @@ -75,8 +75,8 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : tcomputeflag = 0; pcomputeflag = 0; - id_temp = NULL; - id_press = NULL; + id_temp = nullptr; + id_press = nullptr; // turn on tilt factor scaling, whenever applicable @@ -112,24 +112,23 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg],"temp") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); tstat_flag = 1; - t_start = force->numeric(FLERR,arg[iarg+1]); + t_start = utils::numeric(FLERR,arg[iarg+1],false,lmp); t_target = t_start; - t_stop = force->numeric(FLERR,arg[iarg+2]); - t_period = force->numeric(FLERR,arg[iarg+3]); + t_stop = utils::numeric(FLERR,arg[iarg+2],false,lmp); + t_period = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (t_start <= 0.0 || t_stop <= 0.0) error->all(FLERR, "Target temperature for fix nvt/npt/nph cannot be 0.0"); - tdrude_target = force->numeric(FLERR,arg[iarg+4]); - tdrude_period = force->numeric(FLERR,arg[iarg+5]); + tdrude_target = utils::numeric(FLERR,arg[iarg+4],false,lmp); + tdrude_period = utils::numeric(FLERR,arg[iarg+5],false,lmp); iarg += 6; } else if (strcmp(arg[iarg],"iso") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); pcouple = XYZ; - p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); - p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); - p_period[0] = p_period[1] = p_period[2] = - force->numeric(FLERR,arg[iarg+3]); + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[0] = p_flag[1] = p_flag[2] = 1; if (dimension == 2) { p_start[2] = p_stop[2] = p_period[2] = 0.0; @@ -139,10 +138,9 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"aniso") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); pcouple = NONE; - p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); - p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); - p_period[0] = p_period[1] = p_period[2] = - force->numeric(FLERR,arg[iarg+3]); + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[0] = p_flag[1] = p_flag[2] = 1; if (dimension == 2) { p_start[2] = p_stop[2] = p_period[2] = 0.0; @@ -153,15 +151,13 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); pcouple = NONE; scalexy = scalexz = scaleyz = 0; - p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); - p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); - p_period[0] = p_period[1] = p_period[2] = - force->numeric(FLERR,arg[iarg+3]); + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[0] = p_flag[1] = p_flag[2] = 1; p_start[3] = p_start[4] = p_start[5] = 0.0; p_stop[3] = p_stop[4] = p_stop[5] = 0.0; - p_period[3] = p_period[4] = p_period[5] = - force->numeric(FLERR,arg[iarg+3]); + p_period[3] = p_period[4] = p_period[5] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[3] = p_flag[4] = p_flag[5] = 1; if (dimension == 2) { p_start[2] = p_stop[2] = p_period[2] = 0.0; @@ -174,25 +170,25 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : iarg += 4; } else if (strcmp(arg[iarg],"x") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - p_start[0] = force->numeric(FLERR,arg[iarg+1]); - p_stop[0] = force->numeric(FLERR,arg[iarg+2]); - p_period[0] = force->numeric(FLERR,arg[iarg+3]); + p_start[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[0] = 1; deviatoric_flag = 1; iarg += 4; } else if (strcmp(arg[iarg],"y") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - p_start[1] = force->numeric(FLERR,arg[iarg+1]); - p_stop[1] = force->numeric(FLERR,arg[iarg+2]); - p_period[1] = force->numeric(FLERR,arg[iarg+3]); + p_start[1] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[1] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[1] = 1; deviatoric_flag = 1; iarg += 4; } else if (strcmp(arg[iarg],"z") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - p_start[2] = force->numeric(FLERR,arg[iarg+1]); - p_stop[2] = force->numeric(FLERR,arg[iarg+2]); - p_period[2] = force->numeric(FLERR,arg[iarg+3]); + p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[2] = 1; deviatoric_flag = 1; iarg += 4; @@ -201,9 +197,9 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"yz") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - p_start[3] = force->numeric(FLERR,arg[iarg+1]); - p_stop[3] = force->numeric(FLERR,arg[iarg+2]); - p_period[3] = force->numeric(FLERR,arg[iarg+3]); + p_start[3] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[3] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[3] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[3] = 1; deviatoric_flag = 1; scaleyz = 0; @@ -212,9 +208,9 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"xz") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - p_start[4] = force->numeric(FLERR,arg[iarg+1]); - p_stop[4] = force->numeric(FLERR,arg[iarg+2]); - p_period[4] = force->numeric(FLERR,arg[iarg+3]); + p_start[4] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[4] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[4] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[4] = 1; deviatoric_flag = 1; scalexz = 0; @@ -223,9 +219,9 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"xy") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - p_start[5] = force->numeric(FLERR,arg[iarg+1]); - p_stop[5] = force->numeric(FLERR,arg[iarg+2]); - p_period[5] = force->numeric(FLERR,arg[iarg+3]); + p_start[5] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[5] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[5] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[5] = 1; deviatoric_flag = 1; scalexy = 0; @@ -242,12 +238,12 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"tchain") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - mtchain = force->inumeric(FLERR,arg[iarg+1]); + mtchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (mtchain < 1) error->all(FLERR,"Illegal fix nvt/npt/nph command"); iarg += 2; } else if (strcmp(arg[iarg],"pchain") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - mpchain = force->inumeric(FLERR,arg[iarg+1]); + mpchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (mpchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { @@ -258,17 +254,17 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - nc_tchain = force->inumeric(FLERR,arg[iarg+1]); + nc_tchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (nc_tchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); iarg += 2; } else if (strcmp(arg[iarg],"ploop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - nc_pchain = force->inumeric(FLERR,arg[iarg+1]); + nc_pchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (nc_pchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); iarg += 2; } else if (strcmp(arg[iarg],"nreset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - nreset_h0 = force->inumeric(FLERR,arg[iarg+1]); + nreset_h0 = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (nreset_h0 < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { @@ -297,9 +293,9 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"fixedpoint") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - fixedpoint[0] = force->numeric(FLERR,arg[iarg+1]); - fixedpoint[1] = force->numeric(FLERR,arg[iarg+2]); - fixedpoint[2] = force->numeric(FLERR,arg[iarg+3]); + fixedpoint[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + fixedpoint[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + fixedpoint[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); iarg += 4; } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); } @@ -410,8 +406,12 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : if (p_flag[i]) pstat_flag = 1; if (pstat_flag) { - if (p_flag[0] || p_flag[1] || p_flag[2]) box_change_size = 1; - if (p_flag[3] || p_flag[4] || p_flag[5]) box_change_shape = 1; + if (p_flag[0]) box_change |= BOX_CHANGE_X; + if (p_flag[1]) box_change |= BOX_CHANGE_Y; + if (p_flag[2]) box_change |= BOX_CHANGE_Z; + if (p_flag[3]) box_change |= BOX_CHANGE_YZ; + if (p_flag[4]) box_change |= BOX_CHANGE_XZ; + if (p_flag[5]) box_change |= BOX_CHANGE_XY; no_change_box = 1; // pstyle = TRICLINIC if any off-diagonal term is controlled -> 6 dof @@ -425,10 +425,9 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : // pre_exchange only required if flips can occur due to shape changes if (flipflag && (p_flag[3] || p_flag[4] || p_flag[5])) - pre_exchange_flag = 1; - if (flipflag && (domain->yz != 0.0 || domain->xz != 0.0 || - domain->xy != 0.0)) - pre_exchange_flag = 1; + pre_exchange_flag = pre_exchange_migrate = 1; + if (flipflag && (domain->yz != 0.0 || domain->xz != 0.0 || domain->xy != 0.0)) + pre_exchange_flag = pre_exchange_migrate = 1; } // convert input periods to frequencies @@ -511,10 +510,10 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : } nrigid = 0; - rfix = NULL; + rfix = nullptr; if (pre_exchange_flag) irregular = new Irregular(lmp); - else irregular = NULL; + else irregular = nullptr; // initialize vol0,t0 to zero to signal uninitialized // values then assigned in init(), if necessary @@ -677,7 +676,7 @@ void FixTGNHDrude::init() delete [] rfix; nrigid = 0; - rfix = NULL; + rfix = nullptr; for (int i = 0; i < modify->nfix; i++) if (modify->fix[i]->rigid_flag) nrigid++; @@ -743,13 +742,13 @@ void FixTGNHDrude::setup_mol_mass_dof() { // DOFs t_current = temperature->compute_scalar(); - _tdof = temperature->dof; + tdof = temperature->dof; dof_mol = 3 * n_mol_in_group; // remove DOFs of COM motion based on the number of atoms in the group if (n_mol_in_group > 1) dof_mol -= ((double) 3) * group->count(igroup) / atom->natoms; dof_drude = 3 * n_drude; - dof_int = _tdof - dof_mol - dof_drude; + dof_int = tdof - dof_mol - dof_drude; if (comm->me == 0) { if (screen) { @@ -774,7 +773,7 @@ void FixTGNHDrude::setup(int /*vflag*/) // If no thermostat or using fix nphug, // t_target must be defined by other means. - if (tstat_flag && strstr(style,"nphug") == NULL) { + if (tstat_flag && strstr(style,"nphug") == nullptr) { compute_temp_target(); } else if (pstat_flag) { @@ -931,7 +930,7 @@ void FixTGNHDrude::final_integrate() // compute appropriately coupled elements of mvv_current t_current = temperature->compute_scalar(); - _tdof = temperature->dof; + tdof = temperature->dof; // need to recompute pressure to account for change in KE // t_current is up-to-date, but compute_temperature is not @@ -1559,6 +1558,8 @@ double FixTGNHDrude::compute_scalar() double FixTGNHDrude::compute_vector(int n) { + if (!temp_computed_end_of_step) + compute_temp_mol_int_drude(true); switch (n){ case 0: return t_mol; @@ -1595,7 +1596,7 @@ void FixTGNHDrude::reset_dt() dto = 0.5*step_respa[0]; } -void FixTGNHDrude::compute_temp_mol_int_drude() { +void FixTGNHDrude::compute_temp_mol_int_drude(bool end_of_step) { double **v = atom->v; double *mass = atom->mass; int *molecule = atom->molecule; @@ -1690,6 +1691,8 @@ void FixTGNHDrude::compute_temp_mol_int_drude() { ke2drude = ke2_int_drude[1] * force->mvv2e; t_int = ke2int / dof_int / boltz; t_drude = ke2drude / dof_drude / boltz; + + temp_computed_end_of_step = end_of_step; } /* ---------------------------------------------------------------------- @@ -1698,7 +1701,7 @@ void FixTGNHDrude::compute_temp_mol_int_drude() { void FixTGNHDrude::nhc_temp_integrate() { - compute_temp_mol_int_drude(); + compute_temp_mol_int_drude(false); // update masses of thermostat in case target temperature changes etamol_mass[0] = ke2mol_target / (t_freq*t_freq); @@ -2225,7 +2228,7 @@ void FixTGNHDrude::nh_omega_dot() mtk_term1 = 0.0; if (mtk_flag) { if (pstyle == ISO) { - mtk_term1 = _tdof * boltz * t_current; + mtk_term1 = tdof * boltz * t_current; mtk_term1 /= pdim * atom->natoms; } else { double *mvv_current = temperature->vector; diff --git a/src/USER-DRUDE/fix_tgnh_drude.h b/src/USER-DRUDE/fix_tgnh_drude.h index c86ca1f56f..944e5e1f4c 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.h +++ b/src/USER-DRUDE/fix_tgnh_drude.h @@ -44,7 +44,7 @@ class FixTGNHDrude : public Fix { protected: int dimension,which; double dtv,dtf,dthalf,dt4,dt8,dto; - double boltz,nktv2p,_tdof; + double boltz,nktv2p,tdof; double vol0; // reference volume double t0; // reference temperature // used for barostat mass @@ -147,7 +147,8 @@ class FixTGNHDrude : public Fix { double dof_mol, dof_int, dof_drude; // DOFs of different modes in the fix group void setup_mol_mass_dof(); double **v_mol, **v_mol_tmp; - void compute_temp_mol_int_drude(); + void compute_temp_mol_int_drude(bool); // calculate the temperatures of three sets of DOFs + bool temp_computed_end_of_step = false; double tdrude_target, tdrude_freq; double t_mol, t_int, t_drude; double ke2mol, ke2int, ke2drude; diff --git a/src/USER-DRUDE/fix_tgnpt_drude.cpp b/src/USER-DRUDE/fix_tgnpt_drude.cpp index 2e6202f81b..987af367c3 100644 --- a/src/USER-DRUDE/fix_tgnpt_drude.cpp +++ b/src/USER-DRUDE/fix_tgnpt_drude.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://lammps.sandia.gov/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -13,6 +13,7 @@ #include "fix_tgnpt_drude.h" #include + #include "modify.h" #include "error.h" @@ -34,35 +35,23 @@ FixTGNPTDrude::FixTGNPTDrude(LAMMPS *lmp, int narg, char **arg) : // compute group = all since pressure is always global (group all) // and thus its KE/temperature contribution should use group all - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp, tcmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp"; - - modify->add_compute(3,newarg); - delete [] newarg; + tcmd += " all temp"; + modify->add_compute(tcmd); tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all // pass id_temp as 4th arg to pressure constructor - n = strlen(id) + 7; - id_press = new char[n]; - strcpy(id_press,id); - strcat(id_press,"_press"); + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press, pcmd.c_str()); - newarg = new char*[4]; - newarg[0] = id_press; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pressure"; - newarg[3] = id_temp; - modify->add_compute(4,newarg); - delete [] newarg; + pcmd += " all pressure " + std::string(id_temp); + modify->add_compute(pcmd); pcomputeflag = 1; } diff --git a/src/USER-DRUDE/fix_tgnvt_drude.cpp b/src/USER-DRUDE/fix_tgnvt_drude.cpp index 05d247b303..bd6809aaed 100644 --- a/src/USER-DRUDE/fix_tgnvt_drude.cpp +++ b/src/USER-DRUDE/fix_tgnvt_drude.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://lammps.sandia.gov/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -13,6 +13,7 @@ #include "fix_tgnvt_drude.h" #include + #include "group.h" #include "modify.h" #include "error.h" @@ -33,17 +34,11 @@ FixTGNVTDrude::FixTGNVTDrude(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp, tcmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "temp"; - - modify->add_compute(3,newarg); - delete [] newarg; + tcmd += fmt::format(" {} temp", group->names[igroup]); + modify->add_compute(tcmd); tcomputeflag = 1; } From 4de5b1b61240ab531b459249b0c4ca6844b03714 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 13 Nov 2020 16:30:05 -0700 Subject: [PATCH 012/187] Added README explaining how to run cythonize --- src/MLIAPPY/README | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/MLIAPPY/README diff --git a/src/MLIAPPY/README b/src/MLIAPPY/README new file mode 100644 index 0000000000..12f162da5a --- /dev/null +++ b/src/MLIAPPY/README @@ -0,0 +1,9 @@ +This package provides a coupling to PyTorch energy models +via the MLIAP package. + +Before compiling LAMMPS with either make or cmake, you have +to run cythoniz to create the coupling source files +in the src/MLIAPPY directory e.g. + +cd MLIAPPY +~/anaconda3/bin/cythonize mliap_model_python_couple.pyx From af785039f4a9880824b07f3462b277f0bc8da85b Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Sat, 14 Nov 2020 17:08:26 +0100 Subject: [PATCH 013/187] Update docs for TGNH --- doc/src/Howto_drude.rst | 5 +- doc/src/Howto_drude2.rst | 46 ++- doc/src/fix.rst | 2 + doc/src/fix_tgnh_drude.rst | 609 +++++++------------------------------ 4 files changed, 150 insertions(+), 512 deletions(-) diff --git a/doc/src/Howto_drude.rst b/doc/src/Howto_drude.rst index c866340e77..7c1022b784 100644 --- a/doc/src/Howto_drude.rst +++ b/doc/src/Howto_drude.rst @@ -42,10 +42,11 @@ screening. It may be necessary to use the *extra/special/per/atom* keyword of the :doc:`read_data ` command. If using :doc:`fix shake `, make sure no Drude particle is in this fix group. -There are two ways to thermostat the Drude particles at a low +There are three ways to thermostat the Drude particles at a low temperature: use either :doc:`fix langevin/drude ` for a Langevin thermostat, or :doc:`fix drude/transform/\* ` for a Nose-Hoover -thermostat. The former requires use of the command :doc:`comm_modify vel yes `. The latter requires two separate integration +thermostat, or :doc:`fix tgnvt/drude ` for a temperature-grouped Nose-Hoover thermostat. +The first and third require use of the command :doc:`comm_modify vel yes `. The second requires two separate integration fixes like *nvt* or *npt*\ . The correct temperatures of the reduced degrees of freedom can be calculated using the :doc:`compute temp/drude `. This requires also to use the command *comm_modify vel yes*. diff --git a/doc/src/Howto_drude2.rst b/doc/src/Howto_drude2.rst index 3dacf99dec..7817450b73 100644 --- a/doc/src/Howto_drude2.rst +++ b/doc/src/Howto_drude2.rst @@ -221,6 +221,14 @@ modification of forces but no position/velocity updates), the fix fix NVE all nve +To avoid the flying ice cube artifact, where the atoms progressively freeze and the +center of mass of the whole system drifts faster and faster, the *fix momentum* +can be used. For instance: + +.. code-block:: LAMMPS + + fix MOMENTUM all momentum 100 linear 1 1 1 + Finally, do not forget to update the atom type elements if you use them in a *dump_modify ... element ...* command, by adding the element type of the DPs. Here for instance @@ -376,14 +384,7 @@ For our phenol example, the groups would be defined as Note that with the fixes *drude/transform*\ , it is not required to specify *comm_modify vel yes* because the fixes do it anyway (several -times and for the forces also). To avoid the flying ice cube artifact -:ref:`(Lamoureux and Roux) `, where the atoms progressively freeze and the -center of mass of the whole system drifts faster and faster, the *fix -momentum* can be used. For instance: - -.. code-block:: LAMMPS - - fix MOMENTUM all momentum 100 linear 1 1 1 +times and for the forces also). It is a bit more tricky to run a NPT simulation with Nose-Hoover barostat and thermostat. First, the volume should be integrated only @@ -404,6 +405,31 @@ instructions for thermostatting and barostatting will look like fix NVT DRUDES nvt temp 1. 1. 20 fix INVERSE all drude/transform/inverse +Another option for thermalizing the Drude model is to use the +temperature-grouped Nose-Hoover (TGNH) thermostat proposed by :ref:`(Son) `. +This is implemented as :doc:`fix tgnvt/drude ` and :doc:`fix tgnpt/drude `. +It separates the kinetic energy into three contributions: +the molecular center of mass (COM) motion, the motion of atoms or atom-Drude pairs relative to molecular COMs, +and the relative motion of atom-Drude pairs. +An independent Nose-Hoover chain is applied to each type of motion. +When TGNH is used, the temperatures of molecular, atomic and Drude motion can be printed out with :doc:`thermo_style` command. + +NVT simulation with TGNH thermostat + +.. code-block:: LAMMPS + + comm_modify vel yes + fix TGNVT all tgnvt/drude temp 300. 300. 100 1. 20 + thermo_style custom f_TGNVT[1] f_TGNVT[2] f_TGNVT[3] + +NPT simulation with TGNH thermostat + +.. code-block:: LAMMPS + + comm_modify vel yes + fix TGNPT all tgnpt/drude temp 300. 300. 100 1. 20 iso 1. 1. 500 + thermo_style custom f_TGNPT[1] f_TGNPT[2] f_TGNPT[3] + ---------- **Rigid bodies** @@ -480,3 +506,7 @@ NPT ensemble using Nose-Hoover thermostat: **(SWM4-NDP)** Lamoureux, Harder, Vorobyov, Roux, MacKerell, Chem Phys Let, 418, 245-249 (2006) + +.. _TGNH-Son: + +**(Son)** Son, McDaniel, Cui and Yethiraj, J Phys Chem Lett, 10, 7523 (2019). diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 4d026f462f..6475e01003 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -363,6 +363,8 @@ accelerated styles exist. * :doc:`temp/rescale ` - temperature control by velocity rescaling * :doc:`temp/rescale/eff ` - temperature control by velocity rescaling in the electron force field model * :doc:`tfmc ` - perform force-bias Monte Carlo with time-stamped method +* :doc:`tgnvt/drude ` - NVT time integration for Drude polarizable model via temperature-grouped Nose-Hoover +* :doc:`tgnpt/drude ` - NPT time integration for Drude polarizable model via temperature-grouped Nose-Hoover * :doc:`thermal/conductivity ` - Muller-Plathe kinetic energy exchange for thermal conductivity calculation * :doc:`ti/spring ` - * :doc:`tmd ` - guide a group of atoms to a new configuration diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst index 3b6984ec83..5c7a112ab7 100644 --- a/doc/src/fix_tgnh_drude.rst +++ b/doc/src/fix_tgnh_drude.rst @@ -13,18 +13,20 @@ Syntax .. parsed-literal:: - fix ID group-ID style_name keyword value ... + fix ID group-ID style_name keyword values ... * ID, group-ID are documented in :doc:`fix ` command * style_name = *tgnvt/drude* or *tgnpt/drude* -* one or more keyword/value pairs may be appended +* one or more keyword/values pairs may be appended .. parsed-literal:: - keyword = *temp* or *iso* or *aniso* or *tri* or *x* or *y* or *z* or *xy* or *yz* or *xz* or *couple* or *tchain* or *pchain* or *mtk* or *tloop* or *ploop* or *nreset* or *drag* or *ptemp* or *dilate* or *scalexy* or *scaleyz* or *scalexz* or *flip* or *fixedpoint* or *update* - *temp* values = Tstart Tstop Tdamp - Tstart,Tstop = external temperature at start/end of run + keyword = *temp* *iso* or *aniso* or *tri* or *x* or *y* or *z* or *xy* or *yz* or *xz* or *couple* or *tchain* or *pchain* or *mtk* or *tloop* or *ploop* or *nreset* or *scalexy* or *scaleyz* or *scalexz* or *flip* or *fixedpoint* + *temp* values = Tstart Tstop Tdamp Tdrude Tdamp_drude + Tstart, Tstop = external temperature at start/end of run (temperature units) Tdamp = temperature damping parameter (time units) + Tdrude = desired temperature of Drude oscillators (temperature units) + Tdamp_drude = temperature damping parameter for Drude oscillators (time units) *iso* or *aniso* or *tri* values = Pstart Pstop Pdamp Pstart,Pstop = scalar external pressure at start/end of run (pressure units) Pdamp = pressure damping parameter (time units) @@ -42,82 +44,99 @@ Syntax *ploop* value = M M = number of sub-cycles to perform on barostat thermostat *nreset* value = reset reference cell every this many timesteps - *drag* value = Df - Df = drag factor added to barostat/thermostat (0.0 = no drag) - *ptemp* value = Ttarget - Ttarget = target temperature for barostat - *dilate* value = dilate-group-ID - dilate-group-ID = only dilate atoms in this group due to barostat volume changes *scalexy* value = *yes* or *no* = scale xy with ly *scaleyz* value = *yes* or *no* = scale yz with lz *scalexz* value = *yes* or *no* = scale xz with lz *flip* value = *yes* or *no* = allow or disallow box flips when it becomes highly skewed *fixedpoint* values = x y z x,y,z = perform barostat dilation/contraction around this point (distance units) - *update* value = *dipole* or *dipole/dlm* - dipole = update dipole orientation (only for sphere variants) - dipole/dlm = use DLM integrator to update dipole orientation (only for sphere variants) Examples """""""" .. code-block:: LAMMPS - fix 1 all nvt temp 300.0 300.0 100.0 - fix 1 water npt temp 300.0 300.0 100.0 iso 0.0 0.0 1000.0 - fix 2 jello npt temp 300.0 300.0 100.0 tri 5.0 5.0 1000.0 - fix 2 ice nph x 1.0 1.0 0.5 y 2.0 2.0 0.5 z 3.0 3.0 0.5 yz 0.1 0.1 0.5 xz 0.2 0.2 0.5 xy 0.3 0.3 0.5 nreset 1000 + comm_modify vel yes + fix 1 all tgnvt/drude temp 300.0 300.0 100.0 1.0 20.0 + fix 1 water tgnpt/drude temp 300.0 300.0 100.0 1.0 20.0 iso 0.0 0.0 1000.0 + fix 2 jello tgnpt/drude temp 300.0 300.0 100.0 1.0 20.0 tri 5.0 5.0 1000.0 + fix 2 ice tgnpt/drude temp 250.0 250.0 100.0 1.0 20.0 x 1.0 1.0 0.5 y 2.0 2.0 0.5 z 3.0 3.0 0.5 yz 0.1 0.1 0.5 xz 0.2 0.2 0.5 xy 0.3 0.3 0.5 nreset 1000 Description """"""""""" -These commands perform time integration on Nose-Hoover style -non-Hamiltonian equations of motion which are designed to generate -positions and velocities sampled from the canonical (nvt), -isothermal-isobaric (npt), and isenthalpic (nph) ensembles. This -updates the position and velocity for atoms in the group each -timestep. +These commands are variants of the Nose-Hoover fix styles :doc:`fix nvt ` and :doc:`fix npt ` for thermalized Drude polarizable models. +They apply temperature-grouped Nose-Hoover thermostat (TGNH) proposed by :ref:`(Son) `. +When there are fast vibrational modes with frequencies close to Drude oscillators (e.g. double bonds or out-of-plane torsions), +this thermostat can provide better kinetic energy equipartition. -The thermostatting and barostatting is achieved by adding some dynamic -variables which are coupled to the particle velocities -(thermostatting) and simulation domain dimensions (barostatting). In -addition to basic thermostatting and barostatting, these fixes can -also create a chain of thermostats coupled to the particle thermostat, -and another chain of thermostats coupled to the barostat -variables. The barostat can be coupled to the overall box volume, or -to individual dimensions, including the *xy*\ , *xz* and *yz* tilt -dimensions. The external pressure of the barostat can be specified as -either a scalar pressure (isobaric ensemble) or as components of a -symmetric stress tensor (constant stress ensemble). When used -correctly, the time-averaged temperature and stress tensor of the -particles will match the target values specified by Tstart/Tstop and -Pstart/Pstop. +The difference between TGNH and the original Nose-Hoover thermostat is that, +TGNH separates the kinetic energy of the group into three contributions: +molecular center of mass (COM) motion, +motion of COM of atom-Drude pairs or non-polarizable atoms relative to molecular COM, +and relative motion of atom-Drude pairs. +An independent Nose-Hoover chain is applied to each type of motion. +The temperatures for these three types of motion are denoted as +molecular translational temperature (:math:`T_\mathrm{M}`), real atomic temperature (:math:`T_\mathrm{R}`) and Drude temperature (:math:`T_\mathrm{D}`), +which are defined in terms of their associated degrees of freedom (DOF): -The equations of motion used are those of Shinoda et al in -:ref:`(Shinoda) `, which combine the hydrostatic equations of -Martyna, Tobias and Klein in :ref:`(Martyna) ` with the strain -energy proposed by Parrinello and Rahman in -:ref:`(Parrinello) `. The time integration schemes closely -follow the time-reversible measure-preserving Verlet and rRESPA -integrators derived by Tuckerman et al in :ref:`(Tuckerman) `. +.. math:: + + T_\mathrm{M}=\frac{\Sigma_{i}^{N_\mathrm{mol}} M_i V_i^2}{3 ( N_\mathrm{mol} - \frac{N_\mathrm{real} + N_\mathrm{drude}}{N_\mathrm{system}}) k_\mathrm{B}} + +.. math:: + + T_\mathrm{R}=\frac{\Sigma_{i}^{N_\mathrm{real}} m_i (v_i-v_{M,i})^2}{(N_\mathrm{DOF} - 3 N_\mathrm{mol} - 3 N_\mathrm{drude}) k_\mathrm{B}} + +.. math:: + + T_\mathrm{D}=\frac{\Sigma_{i}^{N_\mathrm{drude}} m_i^{\prime} v_i^{\prime 2}}{3 N_\mathrm{drude} k_\mathrm{B}} + +Here :math:`N_\mathrm{mol}` is the number of molecules in the group, +:math:`N_\mathrm{real}` is the number of atom-Drude pairs and non-polarizable atoms in the group, +:math:`N_\mathrm{drude}` is the number of Drude particles in the group, +:math:`N_\mathrm{system}` is the number of particles (including real atoms and Drude particles) in the whole system. +:math:`N_\mathrm{DOF}` is the DOF of the group. +:math:`M_i` and :math:`V_i` are the mass and the COM velocity of the i-th molecule, +:math:`m_i` is the mass of the i-th atom-Drude pair or non-polarizable atom, +:math:`v_i` is the velocity of COM of i-th atom-Drude pair or non-polarizable atom, +:math:`v_{M,i}` is the COM velocity of the molecule the i-th atom-Drude pair or non-polarizable atom belongs to, +:math:`m_i^\prime` and :math:`v_i^\prime` are the reduced mass and the relative velocity of the i-th atom-Drude pair. + +.. note:: + + These fixes require that each atom knows whether it is a Drude particle or + not. You must therefore use the :doc:`fix drude ` command to + specify the Drude status of each atom type. + + Because that TGNH thermostat thermalizes the molecular COM motion, + all atoms belong to the same molecule must be in the same group. + That is, these fixes can not be applied to a subset of a molecule. + + For this fix to act correctly, ghost atoms need to know their velocity. + You must use the :doc:`comm_modify ` command to enable this. + + These fixes assume that the translational DOF of the whole system is removed. + It is therefore recommended to invoke :doc:`fix momentum ` command so that the :math:`T_\mathrm{M}` is calculated correctly. ---------- -The thermostat parameters for fix styles *nvt* and *npt* are specified -using the *temp* keyword. Other thermostat-related keywords are -*tchain*\ , *tloop* and *drag*\ , which are discussed below. - -The thermostat is applied to only the translational degrees of freedom -for the particles. The translational degrees of freedom can also have +The thermostat parameters are specified using the *temp* keyword. +The thermostat is applied to only the translational DOF +for the particles. The translational DOF can also have a bias velocity removed before thermostatting takes place; see the -description below. The desired temperature at each timestep is a +description below. The desired temperature for molecular and real atomic motion is a ramped value during the run from *Tstart* to *Tstop*\ . The *Tdamp* parameter is specified in time units and determines how rapidly the temperature is relaxed. For example, a value of 10.0 means to relax the temperature in a timespan of (roughly) 10 time units (e.g. :math:`\tau` -or fs or ps - see the :doc:`units ` command). The atoms in the -fix group are the only ones whose velocities and positions are updated +or fs or ps - see the :doc:`units ` command). +The parameter *Tdrude* is the desired temperature for Drude motion at each timestep. +Similar to *Tdamp*, the *Tdamp_drude* parameter determines the relaxation speed for Drude motion. +Fix group are the only ones whose velocities and positions are updated by the velocity/position update portion of the integration. +Other thermostat-related keywords are *tchain*\ and *tloop*\ , +which are detailed in :doc:`fix nvt `. .. note:: @@ -125,304 +144,38 @@ by the velocity/position update portion of the integration. of *Tdamp*\ . If *Tdamp* is too small, the temperature can fluctuate wildly; if it is too large, the temperature will take a very long time to equilibrate. A good choice for many models is a *Tdamp* of around - 100 timesteps. Note that this is NOT the same as 100 time units for - most :doc:`units ` settings. A simple way to ensure this, is - via using an :doc:`immediate variable ` expression accessing - the thermo property 'dt', which is the length of the time step. Example: + 100 timesteps. A smaller *Tdamp_drude* value would be required + to maintain Drude motion at low temperature. .. code-block:: LAMMPS - fix 1 all nvt temp 300.0 300.0 $(100.0*dt) + fix 1 all nvt temp 300.0 300.0 $(100.0*dt) 1.0 $(20.0*dt) ---------- -The barostat parameters for fix styles *npt* and *nph* is specified +The barostat parameters for fix style *tgnpt/drude* is specified using one or more of the *iso*\ , *aniso*\ , *tri*\ , *x*\ , *y*\ , *z*\ , *xy*\ , *xz*\ , *yz*\ , and *couple* keywords. These keywords give you the ability to specify all 6 components of an external stress tensor, and to couple various of these components together so that the dimensions they represent are varied together during a constant-pressure -simulation. - -Other barostat-related keywords are *pchain*\ , *mtk*\ , *ploop*\ , -*nreset*\ , *drag*\ , and *dilate*\ , which are discussed below. - -Orthogonal simulation boxes have 3 adjustable dimensions (x,y,z). -Triclinic (non-orthogonal) simulation boxes have 6 adjustable -dimensions (x,y,z,xy,xz,yz). The :doc:`create_box `, :doc:`read data `, and :doc:`read_restart ` commands -specify whether the simulation box is orthogonal or non-orthogonal -(triclinic) and explain the meaning of the xy,xz,yz tilt factors. - -The target pressures for each of the 6 components of the stress tensor -can be specified independently via the *x*\ , *y*\ , *z*\ , *xy*\ , *xz*\ , *yz* -keywords, which correspond to the 6 simulation box dimensions. For -each component, the external pressure or tensor component at each -timestep is a ramped value during the run from *Pstart* to *Pstop*\ . -If a target pressure is specified for a component, then the -corresponding box dimension will change during a simulation. For -example, if the *y* keyword is used, the y-box length will change. If -the *xy* keyword is used, the xy tilt factor will change. A box -dimension will not change if that component is not specified, although -you have the option to change that dimension via the :doc:`fix deform ` command. - -Note that in order to use the *xy*\ , *xz*\ , or *yz* keywords, the -simulation box must be triclinic, even if its initial tilt factors are -0.0. - -For all barostat keywords, the *Pdamp* parameter operates like the -*Tdamp* parameter, determining the time scale on which pressure is -relaxed. For example, a value of 10.0 means to relax the pressure in -a timespan of (roughly) 10 time units (e.g. :math:`\tau` or fs or ps -- see the :doc:`units ` command). - -.. note:: - - A Nose-Hoover barostat will not work well for arbitrary values - of *Pdamp*\ . If *Pdamp* is too small, the pressure and volume can - fluctuate wildly; if it is too large, the pressure will take a very - long time to equilibrate. A good choice for many models is a *Pdamp* - of around 1000 timesteps. However, note that *Pdamp* is specified in - time units, and that timesteps are NOT the same as time units for most - :doc:`units ` settings. - -The relaxation rate of the barostat is set by its inertia :math:`W`: - -.. math:: - - W = (N + 1) k T_{\rm target} P_{\rm damp}^2 - -where :math:`N` is the number of atoms, :math:`k` is the Boltzmann constant, -and :math:`T_{\rm target}` is the target temperature of the barostat :ref:`(Martyna) `. -If a thermostat is defined, :math:`T_{\rm target}` is the target temperature -of the thermostat. If a thermostat is not defined, :math:`T_{\rm target}` -is set to the current temperature of the system when the barostat is initialized. -If this temperature is too low the simulation will quit with an error. -Note: in previous versions of LAMMPS, :math:`T_{\rm target}` would default to -a value of 1.0 for *lj* units and 300.0 otherwise if the system had a temperature -of exactly zero. - -If a thermostat is not specified by this fix, :math:`T_{\rm target}` can be -manually specified using the *Ptemp* parameter. This may be useful if the -barostat is initialized when the current temperature does not reflect the -steady state temperature of the system. This keyword may also be useful in -athermal simulations where the temperature is not well defined. +simulation. Other barostat-related keywords are *pchain*\ , *mtk*\ , *ploop*\ , +*nreset*\ , *scalexy*\ , *scaleyz*\ , *scalexz*\ , *flip*\ and *fixedpoint*. +The meaning of barostat parameters are detailed in :doc:`fix npt `. Regardless of what atoms are in the fix group (the only atoms which are time integrated), a global pressure or stress tensor is computed for all atoms. Similarly, when the size of the simulation box is -changed, all atoms are re-scaled to new positions, unless the keyword -*dilate* is specified with a *dilate-group-ID* for a group that -represents a subset of the atoms. This can be useful, for example, to -leave the coordinates of atoms in a solid substrate unchanged and -controlling the pressure of a surrounding fluid. This option should -be used with care, since it can be unphysical to dilate some atoms and -not others, because it can introduce large, instantaneous -displacements between a pair of atoms (one dilated, one not) that are -far from the dilation origin. Also note that for atoms not in the fix -group, a separate time integration fix like :doc:`fix nve ` or -:doc:`fix nvt ` can be used on them, independent of whether they -are dilated or not. - ----------- - -The *couple* keyword allows two or three of the diagonal components of -the pressure tensor to be "coupled" together. The value specified -with the keyword determines which are coupled. For example, *xz* -means the *Pxx* and *Pzz* components of the stress tensor are coupled. -*Xyz* means all 3 diagonal components are coupled. Coupling means two -things: the instantaneous stress will be computed as an average of the -corresponding diagonal components, and the coupled box dimensions will -be changed together in lockstep, meaning coupled dimensions will be -dilated or contracted by the same percentage every timestep. The -*Pstart*\ , *Pstop*\ , *Pdamp* parameters for any coupled dimensions must -be identical. *Couple xyz* can be used for a 2d simulation; the *z* -dimension is simply ignored. - ----------- - -The *iso*\ , *aniso*\ , and *tri* keywords are simply shortcuts that are -equivalent to specifying several other keywords together. - -The keyword *iso* means couple all 3 diagonal components together when -pressure is computed (hydrostatic pressure), and dilate/contract the -dimensions together. Using "iso Pstart Pstop Pdamp" is the same as -specifying these 4 keywords: - -.. parsed-literal:: - - x Pstart Pstop Pdamp - y Pstart Pstop Pdamp - z Pstart Pstop Pdamp - couple xyz - -The keyword *aniso* means *x*\ , *y*\ , and *z* dimensions are controlled -independently using the *Pxx*\ , *Pyy*\ , and *Pzz* components of the -stress tensor as the driving forces, and the specified scalar external -pressure. Using "aniso Pstart Pstop Pdamp" is the same as specifying -these 4 keywords: - -.. parsed-literal:: - - x Pstart Pstop Pdamp - y Pstart Pstop Pdamp - z Pstart Pstop Pdamp - couple none - -The keyword *tri* means *x*\ , *y*\ , *z*\ , *xy*\ , *xz*\ , and *yz* dimensions -are controlled independently using their individual stress components -as the driving forces, and the specified scalar pressure as the -external normal stress. Using "tri Pstart Pstop Pdamp" is the same as -specifying these 7 keywords: - -.. parsed-literal:: - - x Pstart Pstop Pdamp - y Pstart Pstop Pdamp - z Pstart Pstop Pdamp - xy 0.0 0.0 Pdamp - yz 0.0 0.0 Pdamp - xz 0.0 0.0 Pdamp - couple none - ----------- - -In some cases (e.g. for solids) the pressure (volume) and/or -temperature of the system can oscillate undesirably when a Nose/Hoover -barostat and thermostat is applied. The optional *drag* keyword will -damp these oscillations, although it alters the Nose/Hoover equations. -A value of 0.0 (no drag) leaves the Nose/Hoover formalism unchanged. -A non-zero value adds a drag term; the larger the value specified, the -greater the damping effect. Performing a short run and monitoring the -pressure and temperature is the best way to determine if the drag term -is working. Typically a value between 0.2 to 2.0 is sufficient to -damp oscillations after a few periods. Note that use of the drag -keyword will interfere with energy conservation and will also change -the distribution of positions and velocities so that they do not -correspond to the nominal NVT, NPT, or NPH ensembles. - -An alternative way to control initial oscillations is to use chain -thermostats. The keyword *tchain* determines the number of thermostats -in the particle thermostat. A value of 1 corresponds to the original -Nose-Hoover thermostat. The keyword *pchain* specifies the number of -thermostats in the chain thermostatting the barostat degrees of -freedom. A value of 0 corresponds to no thermostatting of the -barostat variables. - -The *mtk* keyword controls whether or not the correction terms due to -Martyna, Tuckerman, and Klein are included in the equations of motion -:ref:`(Martyna) `. Specifying *no* reproduces the original -Hoover barostat, whose volume probability distribution function -differs from the true NPT and NPH ensembles by a factor of 1/V. Hence -using *yes* is more correct, but in many cases the difference is -negligible. - -The keyword *tloop* can be used to improve the accuracy of integration -scheme at little extra cost. The initial and final updates of the -thermostat variables are broken up into *tloop* sub-steps, each of -length *dt*\ /\ *tloop*\ . This corresponds to using a first-order -Suzuki-Yoshida scheme :ref:`(Tuckerman) `. The keyword *ploop* -does the same thing for the barostat thermostat. - -The keyword *nreset* controls how often the reference dimensions used -to define the strain energy are reset. If this keyword is not used, -or is given a value of zero, then the reference dimensions are set to -those of the initial simulation domain and are never changed. If the -simulation domain changes significantly during the simulation, then -the final average pressure tensor will differ significantly from the -specified values of the external stress tensor. A value of *nstep* -means that every *nstep* timesteps, the reference dimensions are set -to those of the current simulation domain. - -The *scaleyz*\ , *scalexz*\ , and *scalexy* keywords control whether or -not the corresponding tilt factors are scaled with the associated box -dimensions when barostatting triclinic periodic cells. The default -values *yes* will turn on scaling, which corresponds to adjusting the -linear dimensions of the cell while preserving its shape. Choosing -*no* ensures that the tilt factors are not scaled with the box -dimensions. See below for restrictions and default values in different -situations. In older versions of LAMMPS, scaling of tilt factors was -not performed. The old behavior can be recovered by setting all three -scale keywords to *no*\ . - -The *flip* keyword allows the tilt factors for a triclinic box to -exceed half the distance of the parallel box length, as discussed -below. If the *flip* value is set to *yes*\ , the bound is enforced by -flipping the box when it is exceeded. If the *flip* value is set to -*no*\ , the tilt will continue to change without flipping. Note that if -applied stress induces large deformations (e.g. in a liquid), this -means the box shape can tilt dramatically and LAMMPS will run less -efficiently, due to the large volume of communication needed to -acquire ghost atoms around a processor's irregular-shaped sub-domain. -For extreme values of tilt, LAMMPS may also lose atoms and generate an -error. - -The *fixedpoint* keyword specifies the fixed point for barostat volume -changes. By default, it is the center of the box. Whatever point is -chosen will not move during the simulation. For example, if the lower -periodic boundaries pass through (0,0,0), and this point is provided -to *fixedpoint*\ , then the lower periodic boundaries will remain at -(0,0,0), while the upper periodic boundaries will move twice as -far. In all cases, the particle trajectories are unaffected by the -chosen value, except for a time-dependent constant translation of -positions. - -If the *update* keyword is used with the *dipole* value, then the -orientation of the dipole moment of each particle is also updated -during the time integration. This option should be used for models -where a dipole moment is assigned to finite-size particles, -e.g. spheroids via use of the :doc:`atom_style hybrid sphere dipole ` command. - -The default dipole orientation integrator can be changed to the -Dullweber-Leimkuhler-McLachlan integration scheme -:ref:`(Dullweber) ` when using *update* with the value -*dipole/dlm*\ . This integrator is symplectic and time-reversible, -giving better energy conservation and allows slightly longer timesteps -at only a small additional computational cost. - ----------- - -.. note:: - - Using a barostat coupled to tilt dimensions *xy*\ , *xz*\ , *yz* can - sometimes result in arbitrarily large values of the tilt dimensions, - i.e. a dramatically deformed simulation box. LAMMPS allows the tilt - factors to grow a small amount beyond the normal limit of half the box - length (0.6 times the box length), and then performs a box "flip" to - an equivalent periodic cell. See the discussion of the *flip* keyword - above, to allow this bound to be exceeded, if desired. - -The flip operation is described in more detail in the doc page for -:doc:`fix deform `. Both the barostat dynamics and the atom -trajectories are unaffected by this operation. However, if a tilt -factor is incremented by a large amount (1.5 times the box length) on -a single timestep, LAMMPS can not accommodate this event and will -terminate the simulation with an error. This error typically indicates -that there is something badly wrong with how the simulation was -constructed, such as specifying values of *Pstart* that are too far -from the current stress value, or specifying a timestep that is too -large. Triclinic barostatting should be used with care. This also is -true for other barostat styles, although they tend to be more -forgiving of insults. In particular, it is important to recognize that -equilibrium liquids can not support a shear stress and that -equilibrium solids can not support shear stresses that exceed the -yield stress. - -One exception to this rule is if the first dimension in the tilt factor -(x for xy) is non-periodic. In that case, the limits on the tilt -factor are not enforced, since flipping the box in that dimension does -not change the atom positions due to non-periodicity. In this mode, -if you tilt the system to extreme angles, the simulation will simply -become inefficient due to the highly skewed simulation box. +changed, all atoms are re-scaled to new positions. .. note:: Unlike the :doc:`fix temp/berendsen ` command which performs thermostatting but NO time integration, these fixes perform thermostatting/barostatting AND time integration. Thus you - should not use any other time integration fix, such as :doc:`fix nve ` on atoms to which this fix is applied. Likewise, - fix nvt and fix npt should not normally be used on atoms that also - have their temperature controlled by another fix - e.g. by :doc:`fix langevin ` or :doc:`fix temp/rescale ` - commands. + should not use any other time integration fix, such as :doc:`fix nve ` on atoms to which this fix is applied. + Likewise, these fixes should not be used on atoms that also + have their temperature controlled by another fix - e.g. by :doc:`fix langevin/drude ` command. See the :doc:`Howto thermostat ` and :doc:`Howto barostat ` doc pages for a discussion of different ways to compute temperature and perform thermostatting and @@ -430,120 +183,26 @@ barostatting. ---------- -These fixes compute a temperature and pressure each timestep. To do -this, the thermostat and barostat fixes create their own computes of -style "temp" and "pressure", as if one of these sets of commands had -been issued: - -For fix nvt: - -.. code-block:: LAMMPS - - compute fix-ID_temp group-ID temp - -For fix npt and fix nph: - -.. code-block:: LAMMPS - - compute fix-ID_temp all temp - compute fix-ID_press all pressure fix-ID_temp - -For fix nvt, the group for the new temperature compute is the same as -the fix group. For fix npt and fix nph, the group for both the new -temperature and pressure compute is "all" since pressure is computed -for the entire system. In the case of fix nph, the temperature -compute is not used for thermostatting, but just for a kinetic-energy -contribution to the pressure. See the :doc:`compute temp ` and :doc:`compute pressure ` -commands for details. Note that the IDs of the new computes are the -fix-ID + underscore + "temp" or fix_ID + underscore + "press". - -Note that these are NOT the computes used by thermodynamic output (see -the :doc:`thermo_style ` command) with ID = *thermo_temp* -and *thermo_press*. This means you can change the attributes of these -fix's temperature or pressure via the -:doc:`compute_modify ` command. Or you can print this -temperature or pressure during thermodynamic output via the -:doc:`thermo_style custom ` command using the appropriate -compute-ID. It also means that changing attributes of *thermo_temp* -or *thermo_press* will have no effect on this fix. - -Like other fixes that perform thermostatting, fix nvt and fix npt can +Like other fixes that perform thermostatting, these fixes can be used with :doc:`compute commands ` that calculate a temperature after removing a "bias" from the atom velocities. -E.g. removing the center-of-mass velocity from a group of atoms or -only calculating temperature on the x-component of velocity or only -calculating temperature for atoms in a geometric region. This is not -done by default, but only if the :doc:`fix_modify ` command +This is not done by default, but only if the :doc:`fix_modify ` command is used to assign a temperature compute to this fix that includes such a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In this case, the thermostat works in the following manner: the current temperature is calculated taking the bias into account, bias is removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. - ----------- - -These fixes can be used with either the *verlet* or *respa* -:doc:`integrators `. When using one of the barostat fixes -with *respa*\ , LAMMPS uses an integrator constructed -according to the following factorization of the Liouville propagator -(for two rRESPA levels): - -.. math:: - - \exp \left(\mathrm{i} L \Delta t \right) = & \hat{E} - \exp \left(\mathrm{i} L_{\rm T\textrm{-}baro} \frac{\Delta t}{2} \right) - \exp \left(\mathrm{i} L_{\rm T\textrm{-}part} \frac{\Delta t}{2} \right) - \exp \left(\mathrm{i} L_{\epsilon , 2} \frac{\Delta t}{2} \right) - \exp \left(\mathrm{i} L_{2}^{(2)} \frac{\Delta t}{2} \right) \\ - &\times \left[ - \exp \left(\mathrm{i} L_{2}^{(1)} \frac{\Delta t}{2n} \right) - \exp \left(\mathrm{i} L_{\epsilon , 1} \frac{\Delta t}{2n} \right) - \exp \left(\mathrm{i} L_1 \frac{\Delta t}{n} \right) - \exp \left(\mathrm{i} L_{\epsilon , 1} \frac{\Delta t}{2n} \right) - \exp \left(\mathrm{i} L_{2}^{(1)} \frac{\Delta t}{2n} \right) - \right]^n \\ - &\times - \exp \left(\mathrm{i} L_{2}^{(2)} \frac{\Delta t}{2} \right) - \exp \left(\mathrm{i} L_{\epsilon , 2} \frac{\Delta t}{2} \right) - \exp \left(\mathrm{i} L_{\rm T\textrm{-}part} \frac{\Delta t}{2} \right) - \exp \left(\mathrm{i} L_{\rm T\textrm{-}baro} \frac{\Delta t}{2} \right) \\ - &+ \mathcal{O} \left(\Delta t^3 \right) - -This factorization differs somewhat from that of Tuckerman et al, in -that the barostat is only updated at the outermost rRESPA level, -whereas Tuckerman's factorization requires splitting the pressure into -pieces corresponding to the forces computed at each rRESPA level. In -theory, the latter method will exhibit better numerical stability. In -practice, because Pdamp is normally chosen to be a large multiple of -the outermost rRESPA timestep, the barostat dynamics are not the -limiting factor for numerical stability. Both factorizations are -time-reversible and can be shown to preserve the phase space measure -of the underlying non-Hamiltonian equations of motion. +thermal DOF, and the bias is added back in. .. note:: - This implementation has been shown to conserve linear momentum - up to machine precision under NVT dynamics. Under NPT dynamics, - for a system with zero initial total linear momentum, the total - momentum fluctuates close to zero. It may occasionally undergo brief - excursions to non-negligible values, before returning close to zero. - Over long simulations, this has the effect of causing the center-of-mass - to undergo a slow random walk. This can be mitigated by resetting - the momentum at infrequent intervals using the - :doc:`fix momentum ` command. - ----------- - -The fix npt and fix nph commands can be used with rigid bodies or -mixtures of rigid bodies and non-rigid particles (e.g. solvent). But -there are also :doc:`fix rigid/npt ` and :doc:`fix rigid/nph ` commands, which are typically a more natural -choice. See the doc page for those commands for more discussion of -the various ways to do this. - ----------- - -.. include:: accel_styles.rst + However, not all temperature compute commands are valid to be used with these fixes. + Precisely, only temperature compute that does not modify the DOF of the group can be used. + E.g. :doc:`compute temp/ramp ` and :doc:`compute viscosity/cos ` + compute the kinetic energy after remove a velocity gradient without affecting the DOF of the group, + then they can be invoked in this way. + In contrast, :doc:`compute temp/partial ` may remove the DOF at one or more dimensions, + therefore it cannot be used with these fixes. ---------- @@ -586,38 +245,8 @@ These fixes compute a global scalar and a global vector of quantities, which can be accessed by various :doc:`output commands `. The scalar value calculated by these fixes is "extensive"; the vector values are "intensive". - The scalar is the cumulative energy change due to the fix. - -The vector stores internal Nose/Hoover thermostat and barostat -variables. The number and meaning of the vector values depends on -which fix is used and the settings for keywords *tchain* and *pchain*\ , -which specify the number of Nose/Hoover chains for the thermostat and -barostat. If no thermostatting is done, then *tchain* is 0. If no -barostatting is done, then *pchain* is 0. In the following list, -"ndof" is 0, 1, 3, or 6, and is the number of degrees of freedom in -the barostat. Its value is 0 if no barostat is used, else its value -is 6 if any off-diagonal stress tensor component is barostatted, else -its value is 1 if *couple xyz* is used or *couple xy* for a 2d -simulation, otherwise its value is 3. - -The order of values in the global vector and their meaning is as -follows. The notation means there are tchain values for eta, followed -by tchain for eta_dot, followed by ndof for omega, etc: - -* eta[tchain] = particle thermostat displacements (unitless) -* eta_dot[tchain] = particle thermostat velocities (1/time units) -* omega[ndof] = barostat displacements (unitless) -* omega_dot[ndof] = barostat velocities (1/time units) -* etap[pchain] = barostat thermostat displacements (unitless) -* etap_dot[pchain] = barostat thermostat velocities (1/time units) -* PE_eta[tchain] = potential energy of each particle thermostat displacement (energy units) -* KE_eta_dot[tchain] = kinetic energy of each particle thermostat velocity (energy units) -* PE_omega[ndof] = potential energy of each barostat displacement (energy units) -* KE_omega_dot[ndof] = kinetic energy of each barostat velocity (energy units) -* PE_etap[pchain] = potential energy of each barostat thermostat displacement (energy units) -* KE_etap_dot[pchain] = kinetic energy of each barostat thermostat velocity (energy units) -* PE_strain[1] = scalar strain energy (energy units) +The vector stores the three temperatures :math:`T_\mathrm{M}`, :math:`T_\mathrm{R}` and :math:`T_\mathrm{D}`. These fixes can ramp their external temperature and pressure over multiple runs, using the *start* and *stop* keywords of the @@ -631,68 +260,44 @@ These fixes are not invoked during :doc:`energy minimization `. Restrictions """""""""""" +These fixes are only available when LAMMPS was built with the USER-DRUDE package. +These fixes cannot be used with dynamic groups as defined by the :doc:`group ` command. +These fixes cannot be used in 2D simulations. + *X*\ , *y*\ , *z* cannot be barostatted if the associated dimension is not periodic. *Xy*\ , *xz*\ , and *yz* can only be barostatted if the simulation domain is triclinic and the second dimension in the keyword -(\ *y* dimension in *xy*\ ) is periodic. *Z*\ , *xz*\ , and *yz*\ , cannot be -barostatted for 2D simulations. The :doc:`create_box `, +(\ *y* dimension in *xy*\ ) is periodic. The :doc:`create_box `, :doc:`read data `, and :doc:`read_restart ` commands specify whether the simulation box is orthogonal or non-orthogonal (triclinic) and explain the meaning of the xy,xz,yz tilt factors. -For the *temp* keyword, the final Tstop cannot be 0.0 since it would +For the *temp* keyword, the final *Tstop* cannot be 0.0 since it would make the external T = 0.0 at some timestep during the simulation which is not allowed in the Nose/Hoover formulation. -The *scaleyz yes* and *scalexz yes* keyword/value pairs can not be used -for 2D simulations. *scaleyz yes*\ , *scalexz yes*\ , and *scalexy yes* options +The *scaleyz yes*\ , *scalexz yes*\ , and *scalexy yes* options can only be used if the second dimension in the keyword is periodic, and if the tilt factor is not coupled to the barostat via keywords *tri*\ , *yz*\ , *xz*\ , and *xy*\ . -These fixes can be used with dynamic groups as defined by the -:doc:`group ` command. Likewise they can be used with groups to -which atoms are added or deleted over time, e.g. a deposition -simulation. However, the conservation properties of the thermostat -and barostat are defined for systems with a static set of atoms. You -may observe odd behavior if the atoms in a group vary dramatically -over time or the atom count becomes very small. - Related commands """""""""""""""" -:doc:`fix nve `, :doc:`fix_modify `, -:doc:`run_style ` +:doc:`fix drude `, :doc:`fix nvt `, :doc:`fix_npt `, +:doc:`fix_modify ` Default """"""" The keyword defaults are tchain = 3, pchain = 3, mtk = yes, tloop = 1, -ploop = 1, nreset = 0, drag = 0.0, dilate = all, couple = none, +ploop = 1, nreset = 0, couple = none, flip = yes, scaleyz = scalexz = scalexy = yes if periodic in second dimension and not coupled to barostat, otherwise no. ---------- -.. _nh-Martyna: +.. _tgnh-Son: -**(Martyna)** Martyna, Tobias and Klein, J Chem Phys, 101, 4177 (1994). - -.. _nh-Parrinello: - -**(Parrinello)** Parrinello and Rahman, J Appl Phys, 52, 7182 (1981). - -.. _nh-Tuckerman: - -**(Tuckerman)** Tuckerman, Alejandre, Lopez-Rendon, Jochim, and -Martyna, J Phys A: Math Gen, 39, 5629 (2006). - -.. _nh-Shinoda: - -**(Shinoda)** Shinoda, Shiga, and Mikami, Phys Rev B, 69, 134103 (2004). - -.. _nh-Dullweber: - -**(Dullweber)** Dullweber, Leimkuhler and McLachlan, J Chem Phys, 107, -5840 (1997). +**(Son)** Son, McDaniel, Cui and Yethiraj, J Phys Chem Lett, 10, 7523 (2019). From c3b9a30b8afd920730ba778fc945cb2c43eda4f8 Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Mon, 16 Nov 2020 17:23:53 +0100 Subject: [PATCH 014/187] Minor fix for molecular DOF calculation. Update doc. --- doc/src/fix_drude.rst | 4 ++-- doc/src/fix_tgnh_drude.rst | 19 +++++++++---------- src/USER-DRUDE/fix_tgnh_drude.cpp | 8 +++----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/doc/src/fix_drude.rst b/doc/src/fix_drude.rst index b3b04832d2..385a847749 100644 --- a/doc/src/fix_drude.rst +++ b/doc/src/fix_drude.rst @@ -41,12 +41,12 @@ Restrictions """""""""""" This fix should be invoked before any other commands that implement -the Drude oscillator model, such as :doc:`fix langevin/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole `. +the Drude oscillator model, such as :doc:`fix langevin/drude `, :doc:`fix tgnvt/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole `. Related commands """""""""""""""" -:doc:`fix langevin/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole ` +:doc:`fix langevin/drude `, :doc:`fix tgnvt/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole ` Default """"""" diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst index 5c7a112ab7..9afb35c8f6 100644 --- a/doc/src/fix_tgnh_drude.rst +++ b/doc/src/fix_tgnh_drude.rst @@ -82,25 +82,24 @@ which are defined in terms of their associated degrees of freedom (DOF): .. math:: - T_\mathrm{M}=\frac{\Sigma_{i}^{N_\mathrm{mol}} M_i V_i^2}{3 ( N_\mathrm{mol} - \frac{N_\mathrm{real} + N_\mathrm{drude}}{N_\mathrm{system}}) k_\mathrm{B}} + T_\mathrm{M}=\frac{\Sigma_{i}^{N_\mathrm{mol}} M_i V_i^2}{3 \left ( N_\mathrm{mol} - \frac{N_\mathrm{mol}}{N_\mathrm{mol,sys}} \right ) k_\mathrm{B}} .. math:: - T_\mathrm{R}=\frac{\Sigma_{i}^{N_\mathrm{real}} m_i (v_i-v_{M,i})^2}{(N_\mathrm{DOF} - 3 N_\mathrm{mol} - 3 N_\mathrm{drude}) k_\mathrm{B}} + T_\mathrm{R}=\frac{\Sigma_{i}^{N_\mathrm{real}} m_i (v_i-v_{M,i})^2}{(N_\mathrm{DOF} - 3 N_\mathrm{mol} + 3 \frac{N_\mathrm{mol}}{N_\mathrm{mol,sys}} - 3 N_\mathrm{drude}) k_\mathrm{B}} .. math:: T_\mathrm{D}=\frac{\Sigma_{i}^{N_\mathrm{drude}} m_i^{\prime} v_i^{\prime 2}}{3 N_\mathrm{drude} k_\mathrm{B}} -Here :math:`N_\mathrm{mol}` is the number of molecules in the group, -:math:`N_\mathrm{real}` is the number of atom-Drude pairs and non-polarizable atoms in the group, -:math:`N_\mathrm{drude}` is the number of Drude particles in the group, -:math:`N_\mathrm{system}` is the number of particles (including real atoms and Drude particles) in the whole system. +Here :math:`N_\mathrm{mol}` and :math:`N_\mathrm{mol,sys}` are the numbers of molecules in the group and in the whole system, respectively. +:math:`N_\mathrm{real}` is the number of atom-Drude pairs and non-polarizable atoms in the group. +:math:`N_\mathrm{drude}` is the number of Drude particles in the group. :math:`N_\mathrm{DOF}` is the DOF of the group. -:math:`M_i` and :math:`V_i` are the mass and the COM velocity of the i-th molecule, -:math:`m_i` is the mass of the i-th atom-Drude pair or non-polarizable atom, -:math:`v_i` is the velocity of COM of i-th atom-Drude pair or non-polarizable atom, -:math:`v_{M,i}` is the COM velocity of the molecule the i-th atom-Drude pair or non-polarizable atom belongs to, +:math:`M_i` and :math:`V_i` are the mass and the COM velocity of the i-th molecule. +:math:`m_i` is the mass of the i-th atom-Drude pair or non-polarizable atom. +:math:`v_i` is the velocity of COM of i-th atom-Drude pair or non-polarizable atom. +:math:`v_{M,i}` is the COM velocity of the molecule the i-th atom-Drude pair or non-polarizable atom belongs to. :math:`m_i^\prime` and :math:`v_i^\prime` are the reduced mass and the relative velocity of the i-th atom-Drude pair. .. note:: diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index 148a23a92f..12ca55125e 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -743,11 +743,9 @@ void FixTGNHDrude::setup_mol_mass_dof() { // DOFs t_current = temperature->compute_scalar(); tdof = temperature->dof; - dof_mol = 3 * n_mol_in_group; - // remove DOFs of COM motion based on the number of atoms in the group - if (n_mol_in_group > 1) - dof_mol -= ((double) 3) * group->count(igroup) / atom->natoms; - dof_drude = 3 * n_drude; + // remove DOFs of COM translational motion based on the number of molecules in the group + dof_mol = 3.0 * n_mol_in_group - 3.0 * n_mol_in_group / n_mol; + dof_drude = 3.0 * n_drude; dof_int = tdof - dof_mol - dof_drude; if (comm->me == 0) { From bf34112672ae214972da284ef8d80502412384f7 Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Mon, 16 Nov 2020 20:36:29 +0100 Subject: [PATCH 015/187] Init nullptr --- src/USER-DRUDE/fix_tgnh_drude.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index 12ca55125e..e7cb4d18b4 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -50,7 +50,11 @@ enum{ISO,ANISO,TRICLINIC}; FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - rfix(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr) + rfix(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr), + etamol(nullptr), etamol_dot(nullptr), etamol_dotdot(nullptr), etamol_mass(nullptr), + etaint(nullptr), etaint_dot(nullptr), etaint_dotdot(nullptr), etaint_mass(nullptr), + etadrude(nullptr), etadrude_dot(nullptr), etadrude_dotdot(nullptr), etadrude_mass(nullptr), + etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), etap_mass(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix nvt/npt/nph command"); From 0f0188d7bf555d7d2350804e47d8d4cd363200ee Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Tue, 17 Nov 2020 13:45:58 +0100 Subject: [PATCH 016/187] Fix BIGBIG build --- src/USER-DRUDE/fix_tgnh_drude.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index e7cb4d18b4..6cc3fb950c 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -699,7 +699,7 @@ void FixTGNHDrude::init() void FixTGNHDrude::setup_mol_mass_dof() { double *mass = atom->mass; int *mask = atom->mask; - int *molecule = atom->molecule; + tagint *molecule = atom->molecule; int *type = atom->type; int *drudetype = fix_drude->drudetype; int n_drude, n_drude_tmp = 0; @@ -710,13 +710,13 @@ void FixTGNHDrude::setup_mol_mass_dof() { id_mol = std::max(id_mol, molecule[i]); if (mask[i] & groupbit) { if (drudetype[type[i]] == DRUDE_TYPE) - n_drude_tmp += 1; + n_drude_tmp++; } } MPI_Allreduce(&n_drude_tmp, &n_drude, 1, MPI_LMP_TAGINT, MPI_SUM, world); MPI_Allreduce(&id_mol, &n_mol, 1, MPI_LMP_TAGINT, MPI_MAX, world); - // use flag_mol to determin the number of molecules in the fix group + // use flag_mol to determine the number of molecules in the fix group int *flag_mol = new int[n_mol + 1]; int *flag_mol_tmp = new int[n_mol + 1]; memset(flag_mol_tmp, 0, sizeof(int) * (n_mol + 1)); @@ -730,6 +730,8 @@ void FixTGNHDrude::setup_mol_mass_dof() { if (flag_mol[i]) n_mol_in_group++; } + delete[] flag_mol; + delete[] flag_mol_tmp; // length of v_mol set to n_mol+1, so that the subscript start from 1, we can call v_mol[n_mol] memory->create(v_mol, n_mol + 1, 3, "fix_tgnh_drude::v_mol"); @@ -743,6 +745,7 @@ void FixTGNHDrude::setup_mol_mass_dof() { mass_tmp[id_mol] += mass[type[i]]; } MPI_Allreduce(mass_tmp, mass_mol, n_mol + 1, MPI_DOUBLE, MPI_SUM, world); + delete[] mass_tmp; // DOFs t_current = temperature->compute_scalar(); @@ -1601,11 +1604,11 @@ void FixTGNHDrude::reset_dt() void FixTGNHDrude::compute_temp_mol_int_drude(bool end_of_step) { double **v = atom->v; double *mass = atom->mass; - int *molecule = atom->molecule; + tagint *molecule = atom->molecule; int *type = atom->type; int *mask = atom->mask; int *drudetype = fix_drude->drudetype; - int *drudeid = fix_drude->drudeid; + tagint *drudeid = fix_drude->drudeid; int imol, ci, di; double mass_com, mass_reduced, mass_core, mass_drude; double vint, vcom, vrel; @@ -1988,9 +1991,9 @@ void FixTGNHDrude::nh_v_temp() double *mass = atom->mass; int *mask = atom->mask; int *type = atom->type; - int *molecule = atom->molecule; + tagint *molecule = atom->molecule; int *drudetype = fix_drude->drudetype; - int *drudeid = fix_drude->drudeid; + tagint *drudeid = fix_drude->drudeid; int imol, i, j, ci, di, itype; double mass_com, mass_core, mass_drude; From 3d28f5d610e3def1ebb6a4c55bd6703575853f1a Mon Sep 17 00:00:00 2001 From: Zheng Gong Date: Tue, 17 Nov 2020 13:51:38 +0100 Subject: [PATCH 017/187] make NH propagation a const method --- src/USER-DRUDE/fix_tgnh_drude.cpp | 2 +- src/USER-DRUDE/fix_tgnh_drude.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index 6cc3fb950c..e2122e6792 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -1728,7 +1728,7 @@ void FixTGNHDrude::nhc_temp_integrate() } double FixTGNHDrude::propagate(double *eta, double *eta_dot, double *eta_dotdot, const double *eta_mass, - double ke2, double ke2_target, double tt) { + const double &ke2, const double &ke2_target, const double &tt) const { int ich; double expfac; double ncfac = 1.0 / nc_tchain; diff --git a/src/USER-DRUDE/fix_tgnh_drude.h b/src/USER-DRUDE/fix_tgnh_drude.h index 944e5e1f4c..4d29bb90e7 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.h +++ b/src/USER-DRUDE/fix_tgnh_drude.h @@ -154,7 +154,7 @@ class FixTGNHDrude : public Fix { double ke2mol, ke2int, ke2drude; double ke2mol_target, ke2int_target, ke2drude_target; double factor_eta_mol, factor_eta_int, factor_eta_drude; - double propagate(double *, double *, double *, const double *, double , double, double); + double propagate(double *, double *, double *, const double *, const double &, const double &, const double &) const; }; } From 0623817afea8a695772b85d3e3dd8c9540c87d28 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 20 Nov 2020 11:47:31 -0700 Subject: [PATCH 018/187] Updated README --- src/MLIAPPY/README | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/MLIAPPY/README b/src/MLIAPPY/README index 12f162da5a..ba15d6eb51 100644 --- a/src/MLIAPPY/README +++ b/src/MLIAPPY/README @@ -2,8 +2,23 @@ This package provides a coupling to PyTorch energy models via the MLIAP package. Before compiling LAMMPS with either make or cmake, you have -to run cythoniz to create the coupling source files +to run cythonize to create the coupling source files in the src/MLIAPPY directory e.g. cd MLIAPPY -~/anaconda3/bin/cythonize mliap_model_python_couple.pyx +cythonize mliap_model_python_couple.pyx + +When building with make, you will have to add this +compiler option, suitably modified for your NumPy: + +-I/home/athomps/anaconda3/lib/python3.7/site-packages/numpy/core/include + +When bulding with cmake, it should just work, but if you have +cmake version older than 3.14, you will have to edit +this file accordingly: +more ../../cmake/Modules/Packages/MLIAPPY.cmake +if(CMAKE_VERSION VERSION_LESS 3.14) +: + target_include_directories(lammps PRIVATE /home/athomps/anaconda3/lib/python3.7/site-packages/numpy/core/include) +: + From 35f2c9bdf2298c33b036e2eab1011b45bf60c2da Mon Sep 17 00:00:00 2001 From: Nicholas Lubbers Date: Thu, 26 Nov 2020 12:40:28 -0700 Subject: [PATCH 019/187] Several improvements to capabilities and build. - cmake fixed, no longer needs numpy headers. - models can be loaded from an external interepreter. --- cmake/Modules/Packages/MLIAPPY.cmake | 13 +-- cmake/Modules/Packages/PYTHON.cmake | 3 +- doc/src/Packages_details.rst | 9 +- examples/mliappy/README | 26 ++++++ examples/mliappy/README.txt | 11 --- examples/mliappy/convert_mliap_Ta06A.py | 4 +- examples/mliappy/in.mliap.pytorch.Ta06A | 2 +- examples/mliappy/load_external.py | 104 ++++++++++++++++++++++ examples/mliappy/test_pylibs.py | 12 +++ python/lammps.py | 42 +++++++++ src/MLIAP/pair_mliap.cpp | 22 ++--- src/MLIAPPY/Makefile.lammps | 1 + src/MLIAPPY/README | 37 ++++++++ src/MLIAPPY/mliap_model_python.cpp | 61 +++++++++---- src/MLIAPPY/mliap_model_python.h | 7 +- src/MLIAPPY/mliap_model_python_couple.pyx | 88 ++++++++++++------ src/MLIAPPY/mliappy_pytorch.py | 10 +-- src/PYTHON/python_impl.cpp | 6 +- 18 files changed, 369 insertions(+), 89 deletions(-) create mode 100644 examples/mliappy/README delete mode 100644 examples/mliappy/README.txt create mode 100644 examples/mliappy/load_external.py create mode 100644 examples/mliappy/test_pylibs.py create mode 100644 src/MLIAPPY/Makefile.lammps create mode 100644 src/MLIAPPY/README diff --git a/cmake/Modules/Packages/MLIAPPY.cmake b/cmake/Modules/Packages/MLIAPPY.cmake index 842c43bd96..73ce83361c 100644 --- a/cmake/Modules/Packages/MLIAPPY.cmake +++ b/cmake/Modules/Packages/MLIAPPY.cmake @@ -1,12 +1,3 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - #This block was not tested, mimmicks PYTHON.cmake. - find_package(PythonLibs REQUIRED) # Deprecated since version 3.12 - target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIR}) - target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARY}) - target_include_directories(lammps PRIVATE ${Python_NumPy_INCLUDE_DIRS}) -else() - find_package(Python REQUIRED COMPONENTS NumPy) - target_include_directories(lammps PRIVATE ${Python_NumPy_INCLUDE_DIRS}) -endif() -target_compile_definitions(lammps PRIVATE -DLMP_MLIAPPY) +execute_process(COMMAND cythonize mliap_model_python_couple.pyx WORKING_DIRECTORY ../src/MLIAPPY) +target_compile_definitions(lammps PRIVATE -DLMP_MLIAPPY) diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index 7be25a6b05..e3158dc509 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -3,7 +3,8 @@ if(CMAKE_VERSION VERSION_LESS 3.12) target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) else() - find_package(Python REQUIRED COMPONENTS Development) + find_package(Python REQUIRED COMPONENTS Development Interpreter) + target_include_directories(lammps PRIVATE ${Python_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE Python::Python) endif() target_compile_definitions(lammps PRIVATE -DLMP_PYTHON) diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index edce17b9ab..7c9e8b8eb8 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -692,12 +692,10 @@ Extension to the MLIAP package for coupling with python models. To use this package, also the :ref:`MLIAP package ` needs to be installed. To use this package, also the :ref:`PYTHON package ` needs to be installed. -The version of python must be >3.5, and has been tested only with 3.8. -Compiling this package has only been tested using CMake, not with pure makefiles.s -The python interpreter linked to LAMMPS will need cython and numpy installed. +The version of python must be >3.5. -Before compiling, run cythonize on /src/MLIAPPY/mliap_model_python_couple.pyx. -This will produce /src/MLIAPPY/mliap_model_python_couple.cpp and /src/MLIAPPY/mliap_model_python_couple.h files. +The python interpreter linked to LAMMPS will need cython and numpy installed. +The examples build models with pytorch, which would thus need to be installed. This package includes more options for the mliap compute and pair style. @@ -706,6 +704,7 @@ This package includes more options for the mliap compute and pair style. **Supporting info:** * src/MLIAPPY: filenames -> commands +* src/MLIAPPY/README * :doc:`pair_style mliap ` * examples/mliappy (see README) ---------- diff --git a/examples/mliappy/README b/examples/mliappy/README new file mode 100644 index 0000000000..d61972afcf --- /dev/null +++ b/examples/mliappy/README @@ -0,0 +1,26 @@ +README for MLIAPPY Example + +These examples run the Ta06 example from the MLIAP package, but using the python coupling. + +1: Running models using LAMMPS executable: in.mliap.snap.Ta06A. + +To run this, first run convert_mliap_Ta06A.py, which will convert the Ta06 potential into a pytorch model. +It will be saved as "Ta06A.mliap.pytorch.model.pkl". + +It will also copy the "mliappy_pytorch.py" file into the current working directory. mliappy_pytorch.py contains +class definitions suitable for wrapping an arbitrary energy model MLIAPPY. It must be available to python when +creating or unpicking a pytorch model for MLIAPPY. + +From that point you can run the example lmp -in in.mliap.snap.Ta06A -echo both + +2: Running models from python with LAMMPS in library mode: load_external.py + +Before testing this, ensure that the first example (using LAMMPS executable) works. + +Not all python installations support this mode of operation. +Too test if your interpreter supports this, run: +`python test_pylibs.py` + and examine the output. + +If this succeeds, you should be able to run: +`python load_external.py` diff --git a/examples/mliappy/README.txt b/examples/mliappy/README.txt deleted file mode 100644 index f624acd657..0000000000 --- a/examples/mliappy/README.txt +++ /dev/null @@ -1,11 +0,0 @@ -README for MLIAPPY Example - -This example runs the Ta06 example from the MLIAP example, but using the python coupling. - -To run this, first run convert_mliap_Ta06A.py, which will convert the Ta06 potential into a pytorch model. -It will be saved as "Ta06A.mliap.pytorch.model.pkl". - -It will also copy the "torchlink.py" file into the current working directory. torchlink.py contains -class definitions suitable for wrapping an arbitrary energy model MLIAPPY. - -From that point you can run the example lmp -in in.mliap.snap.Ta06A -echo both \ No newline at end of file diff --git a/examples/mliappy/convert_mliap_Ta06A.py b/examples/mliappy/convert_mliap_Ta06A.py index bdc3887282..371139481d 100644 --- a/examples/mliappy/convert_mliap_Ta06A.py +++ b/examples/mliappy/convert_mliap_Ta06A.py @@ -22,7 +22,7 @@ with torch.autograd.no_grad(): lin.bias.set_(torch.as_tensor(bias,dtype=torch.float64).unsqueeze(0)) # Wrap the pytorch model for usage with MLIAPPY -model = mliappy_pytorch.IgnoreTypes(lin) +model = mliappy_pytorch.IgnoreElems(lin) n_descriptors = lin.weight.shape[1] n_params = mliappy_pytorch.calc_n_params(model) n_types = 1 @@ -30,4 +30,4 @@ linked_model = mliappy_pytorch.TorchWrapper64(model,n_descriptors=n_descriptors, # Save the result. with open("Ta06A.mliap.pytorch.model.pkl",'wb') as pfile: - pickle.dump(linked_model,pfile) \ No newline at end of file + pickle.dump(linked_model,pfile) diff --git a/examples/mliappy/in.mliap.pytorch.Ta06A b/examples/mliappy/in.mliap.pytorch.Ta06A index 526c24ab23..e44b4352e7 100644 --- a/examples/mliappy/in.mliap.pytorch.Ta06A +++ b/examples/mliappy/in.mliap.pytorch.Ta06A @@ -1,4 +1,4 @@ -# Demonstrate MLIAP interface to kinear SNAP potential +# Demonstrate MLIAP interface to linear SNAP potential # Initialize simulation diff --git a/examples/mliappy/load_external.py b/examples/mliappy/load_external.py new file mode 100644 index 0000000000..606ee8f940 --- /dev/null +++ b/examples/mliappy/load_external.py @@ -0,0 +1,104 @@ + +# Demonstrate how to load a model from the python side. +# This is essentially the same as in.mliap.pytorch.Ta06A-- +# except that python is the driving program, and lammps +# is in library mode. + +before_loading =\ +""" + # Demonstrate MLIAP interface to linear SNAP potential + + # Initialize simulation + + variable nsteps index 100 + variable nrep equal 4 + variable a equal 3.316 + units metal + + # generate the box and atom positions using a BCC lattice + + variable nx equal ${nrep} + variable ny equal ${nrep} + variable nz equal ${nrep} + + boundary p p p + + lattice bcc $a + region box block 0 ${nx} 0 ${ny} 0 ${nz} + create_box 1 box + create_atoms 1 box + + mass 1 180.88 + + # choose potential + # DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + + # Definition of SNAP potential Ta_Cand06A + # Assumes 1 LAMMPS atom type + + variable zblcutinner equal 4 + variable zblcutouter equal 4.8 + variable zblz equal 73 + + # Specify hybrid with SNAP, ZBL + + pair_style hybrid/overlay & + zbl ${zblcutinner} ${zblcutouter} & + mliap model mliappy LATER & + descriptor sna Ta06A.mliap.descriptor + pair_coeff 1 1 zbl ${zblz} ${zblz} + pair_coeff * * mliap Ta +""" +after_loading =\ +""" + + # Setup output + + compute eatom all pe/atom + compute energy all reduce sum c_eatom + + compute satom all stress/atom NULL + compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] + variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + + thermo_style custom step temp epair c_energy etotal press v_press + thermo 10 + thermo_modify norm yes + + # Set up NVE run + + timestep 0.5e-3 + neighbor 1.0 bin + neigh_modify once no every 1 delay 0 check yes + + # Run MD + + velocity all create 300.0 4928459 loop geom + fix 1 all nve + run ${nsteps} +""" + + +import lammps + +lmp = lammps.lammps(cmdargs=['-echo','both']) +# This commmand must be run before the MLIAP object is declared in lammps. +lmp.mliappy.activate() + +lmp.commands_string(before_loading) + +# Now the model is declared, but empty -- because the model filename +# was given as "LATER". + +# Load the python module, construct on the fly, do whatever, here: +import pickle +with open('Ta06A.mliap.pytorch.model.pkl','rb') as pfile: + model = pickle.load(pfile) + +# Now that you have a model, connect it to the pairstyle +lmp.mliappy.load_model(model) + +# Proceed with whatever calculations you like. +lmp.commands_string(after_loading) + + diff --git a/examples/mliappy/test_pylibs.py b/examples/mliappy/test_pylibs.py new file mode 100644 index 0000000000..c5dcab75cf --- /dev/null +++ b/examples/mliappy/test_pylibs.py @@ -0,0 +1,12 @@ +import sysconfig, os,ctypes + +library = sysconfig.get_config_vars('INSTSONAME')[0] + +pylib = ctypes.CDLL(library) + +connected = pylib.Py_IsInitialized() + +if not connected: + print("FAILURE: This interpreter is not compatible with python-driven mliappy.") +else: + print("SUCCESS: This interpreter is compatible with python-driven MLIAPPY") diff --git a/python/lammps.py b/python/lammps.py index 4be2f48b0d..df37e50ee1 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -505,6 +505,8 @@ class lammps(object): self.FIX_EXTERNAL_CALLBACK_FUNC = CFUNCTYPE(None, py_object, self.c_bigint, c_int, POINTER(self.c_tagint), POINTER(POINTER(c_double)), POINTER(POINTER(c_double))) self.lib.lammps_set_fix_external_callback.argtypes = [c_void_p, c_char_p, self.FIX_EXTERNAL_CALLBACK_FUNC, py_object] self.lib.lammps_set_fix_external_callback.restype = None + + self.mliappy = MLIAPPY(self) # ------------------------------------------------------------------------- # shut-down LAMMPS instance @@ -2924,3 +2926,43 @@ class IPyLammps(PyLammps): """ from IPython.display import HTML return HTML("") + +class MLIAPPY(): + def __init__(self,lammps): + self._module = None + self.lammps = lammps + + @property + def module(self): + if self._module: + return self._module + + try: + # Begin Importlib magic to find the embedded python module + # This is needed because the filename for liblammps does not + # match the spec for normal python modules, wherein + # file names match with PyInit function names. + # Also, python normally doesn't look for extensions besides '.so' + # We fix both of these problems by providing an explict + # path to the extension module 'mliap_model_python_couple' in + import sys + import importlib.util + import importlib.machinery + + path = self.lammps.lib._name + loader = importlib.machinery.ExtensionFileLoader('mliap_model_python_couple',path) + spec = importlib.util.spec_from_loader('mliap_model_python_couple',loader) + module = importlib.util.module_from_spec(spec) + sys.modules['mliap_model_python_couple']=module + spec.loader.exec_module(module) + self._module = module + # End Importlib magic to find the embedded python module + except: + raise ImportError("Could not load MLIAPPY coupling module") + + def activate(self): + self.module + + def load_model(self,model): + self.module.load_from_python(model) + diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index 9fd7b483af..5dd891e21f 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -69,6 +69,17 @@ PairMLIAP::~PairMLIAP() void PairMLIAP::compute(int eflag, int vflag) { + + // consistency checks + + if (data->ndescriptors != model->ndescriptors) { + error->all(FLERR,"Incompatible model and descriptor descriptor count"); + }; + + if (data->nelements != model->nelements) { + error->all(FLERR,"Incompatible model and descriptor element count"); + }; + ev_init(eflag,vflag); data->generate_neighdata(list, eflag, vflag); @@ -137,9 +148,8 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelQuadratic(lmp,arg[iarg+2]); iarg += 3; - } #ifdef LMP_MLIAPPY - else if (strcmp(arg[iarg+1],"mliappy") == 0) { + } else if (strcmp(arg[iarg+1],"mliappy") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelPython(lmp,arg[iarg+2]); iarg += 3; @@ -225,15 +235,7 @@ void PairMLIAP::coeff(int narg, char **arg) data = new MLIAPData(lmp, gradgradflag, map, model, descriptor, this); data->init(); - // consistency checks - if (data->ndescriptors != model->ndescriptors) { - error->all(FLERR,"Incompatible model and descriptor definitions (different number of descriptors)"); - }; - - if (data->nelements != model->nelements) { - error->all(FLERR,"Incompatible model and descriptor definitions (different number of elements)"); - }; } /* ---------------------------------------------------------------------- diff --git a/src/MLIAPPY/Makefile.lammps b/src/MLIAPPY/Makefile.lammps new file mode 100644 index 0000000000..f9bf1abc13 --- /dev/null +++ b/src/MLIAPPY/Makefile.lammps @@ -0,0 +1 @@ +#TODO diff --git a/src/MLIAPPY/README b/src/MLIAPPY/README new file mode 100644 index 0000000000..44b454bba1 --- /dev/null +++ b/src/MLIAPPY/README @@ -0,0 +1,37 @@ +README for MLIAPPY source files. + +MLIAPPY requires python 3 with cython, numpy, and optionally pytorch installed. +One could build compatible python models without pytorch, with a bit of work by hand. +You can get these via standard procedures (pip, conda, or similar) + +MLIAPPY also requires the LAMMPS packages MLIAP and PYTHON be enabled. + +MLIAPPY can be built with cmake -- a pure make version is forthcoming. + +If you are building LAMMPS manually (no cmake/make), the process works roughly as possible: + +First run cythonize on mliap_model_python_couple.pyx. This will generate: + +(1) mliap_model_python_couple.h +(2) mliap_model_python_couple.cpp + +File (1) is a roughly human readable header file, (2) is a large source file, +and navigating it is not for the faint of heart. These files are used in mliap_model_python.cpp. + +Then use compiler options to define the macro LMP_MLIAPPY during compilation. + +Other information: + +The "mliap_model_python.cpp" files and "mliap_model_python.h" files cover the +definitions of the LAMMPS object MLIAPModelPython. + +How does this all work? + +Roughly: A python extension module called "mliap_model_python_couple" is built in to LAMMPS. This holds a dictionary of currently defined MLIAPModelPython objects and +the equivalent python models. It also converts the data needed by the model from +C arrays to numpy arrays before passing them to the python model. + +The last file is mliappy_pytorch.py. This contains some simple utility classes +for taking an energy model in pytorch, and wrapping it for compatibily with MLIAP. + +For more information on MLIAPPY, see the examples in examples/mliappy. \ No newline at end of file diff --git a/src/MLIAPPY/mliap_model_python.cpp b/src/MLIAPPY/mliap_model_python.cpp index 13e5a85e83..1ac61f08b0 100644 --- a/src/MLIAPPY/mliap_model_python.cpp +++ b/src/MLIAPPY/mliap_model_python.cpp @@ -29,28 +29,25 @@ using namespace LAMMPS_NS; MLIAPModelPython::MLIAPModelPython(LAMMPS* lmp, char* coefffilename) : MLIAPModel(lmp, coefffilename) { - int err; - + model_loaded = 0; python->init(); - PyGILState_STATE gstate = PyGILState_Ensure(); PyObject * pyMain = PyImport_AddModule("__main__"); - PyImport_ImportModule("mliap_model_python_couple"); if (!pyMain) { PyGILState_Release(gstate); error->all(FLERR,"Could not initialize embedded Python"); } - + PyObject* coupling_module = PyImport_ImportModule("mliap_model_python_couple"); + if (!coupling_module) { PyErr_Print(); PyErr_Clear(); PyGILState_Release(gstate); error->all(FLERR,"Loading MLIAPPY coupling module failure."); } - // Recipe from lammps/src/pair_python.cpp : // add current directory to PYTHONPATH PyObject * py_path = PySys_GetObject((char *)"path"); @@ -61,7 +58,6 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS* lmp, char* coefffilename) : if (potentials_path != NULL) { PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path)); } - PyGILState_Release(gstate); if (coefffilename) read_coeffs(coefffilename); @@ -82,29 +78,51 @@ MLIAPModelPython::~MLIAPModelPython(){ int MLIAPModelPython::get_nparams() { - if (nparams == 0) { - if (ndescriptors == 0) error->all(FLERR,"ndescriptors not defined"); - else nparams = ndescriptors + 1; - } return nparams; } - void MLIAPModelPython::read_coeffs(char * fname) { PyGILState_STATE gstate = PyGILState_Ensure(); - int err = MLIAPPY_load_model(this, fname); - if (err) { + + int loaded = MLIAPPY_load_model(this, fname); + if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); PyGILState_Release(gstate); error->all(FLERR,"Loading python model failure."); } + PyGILState_Release(gstate); + + if (loaded) { + this->connect_param_counts(); + } + else { + utils::logmesg(lmp,"Loading python model deferred.\n"); + } +} + +// Finalize loading of the model. +void MLIAPModelPython::connect_param_counts() +{ + PyGILState_STATE gstate = PyGILState_Ensure(); nelements = MLIAPPY_nelements(this); nparams = MLIAPPY_nparams(this); ndescriptors = MLIAPPY_ndescriptors(this); + + if (PyErr_Occurred()) { + PyErr_Print(); + PyErr_Clear(); + PyGILState_Release(gstate); + error->all(FLERR,"Loading python model failure."); + } + PyGILState_Release(gstate); + model_loaded = 1; + utils::logmesg(lmp,"Loading python model complete.\n"); + } + /* ---------------------------------------------------------------------- Calculate model gradients w.r.t descriptors for each atom beta_i = dE(B_i)/dB_i @@ -112,7 +130,20 @@ void MLIAPModelPython::read_coeffs(char * fname) void MLIAPModelPython::compute_gradients(MLIAPData* data) { - MLIAPPY_model_callback(this, data); + if (not model_loaded) { + error->all(FLERR,"Model not loaded."); + } + + PyGILState_STATE gstate = PyGILState_Ensure(); + MLIAPPY_compute_gradients(this, data); + if (PyErr_Occurred()) { + PyErr_Print(); + PyErr_Clear(); + PyGILState_Release(gstate); + error->all(FLERR,"Running python model failure."); + } + PyGILState_Release(gstate); + } /* ---------------------------------------------------------------------- diff --git a/src/MLIAPPY/mliap_model_python.h b/src/MLIAPPY/mliap_model_python.h index 3b162509f7..0ef87f86fd 100644 --- a/src/MLIAPPY/mliap_model_python.h +++ b/src/MLIAPPY/mliap_model_python.h @@ -29,9 +29,14 @@ public: virtual void compute_gradgrads(class MLIAPData*); virtual void compute_force_gradients(class MLIAPData*); virtual double memory_usage(); + void connect_param_counts(); // If possible convert this to protected/private and + // and figure out how to declare cython fn + // load_from_python as a friend. + int model_loaded; + protected: virtual void read_coeffs(char *); - + private: }; diff --git a/src/MLIAPPY/mliap_model_python_couple.pyx b/src/MLIAPPY/mliap_model_python_couple.pyx index 3e03247fa7..ad95ea2c48 100644 --- a/src/MLIAPPY/mliap_model_python_couple.pyx +++ b/src/MLIAPPY/mliap_model_python_couple.pyx @@ -1,5 +1,12 @@ # cython: language_level=3 # distutils: language = c++ +# distutils: define_macros="LMP_MLIAPPY" +# distutils: extra_compile_args= -stdlib=libc++ -std=c++11 +# distutils: include_dirs = ../STUBS .. ../MLIAP +# distutils: extra_link_args= -stdlib=libc++ +# Note: only the language_level and language commands are needed, the rest pertain +# to building mliap_model_python_couple as a standalone python extension, which +# is experimental. cimport cython @@ -7,7 +14,6 @@ import pickle # For converting C arrays to numpy arrays import numpy as np -cimport numpy as cnp # For converting void * to integer for tracking object identity from libc.stdint cimport uintptr_t @@ -32,40 +38,72 @@ cdef extern from "mliap_data.h" namespace "LAMMPS_NS": cdef extern from "mliap_model_python.h" namespace "LAMMPS_NS": cdef cppclass MLIAPModelPython: - ctypedef void (*CBPtr)(void * , MLIAPData); - void set_model(CBPtr, void *); - + void connect_param_counts() + + +class MLIAPPYModelNotLinked(Exception): pass + LOADED_MODELS = {} -cdef public int MLIAPPY_load_model(MLIAPModelPython * c_model, char* fname) except 1 with gil: - str_fname = fname.decode('utf-8') # Python 3 only; not Python 2 not supported. - - with open(str_fname,'rb') as pfile: - model = pickle.load(pfile) - LOADED_MODELS[int( c_model)] = model - return 0 +cdef object c_id(MLIAPModelPython * c_model): + """ + Use python-style id of object to keep track of identity. + Note, this is probably not a perfect general strategy but it should work fine with LAMMPS pair styles. + """ + return int( c_model) + +cdef object retrieve(MLIAPModelPython * c_model): + try: + model = LOADED_MODELS[c_id(c_model)] + except KeyError as ke: + raise KeyError("Model has not been loaded.") from ke + if model is None: + raise MLIAPPYModelNotLinked("Model not linked, connect the model from the python side.") + return model + +cdef public int MLIAPPY_load_model(MLIAPModelPython * c_model, char* fname) with gil: + str_fname = fname.decode('utf-8') # Python 3 only; not Python 2 not supported. + if str_fname == "LATER": + model = None + returnval = 0 + else: + with open(str_fname,'rb') as pfile: + model = pickle.load(pfile) + returnval = 1 + LOADED_MODELS[c_id(c_model)] = model + return returnval + +def load_from_python(model): + unloaded_models = [k for k, v in LOADED_MODELS.items() if v is None] + num_models = len(unloaded_models) + cdef MLIAPModelPython * lmp_model + + if num_models == 0: + raise ValueError("No model in the waiting area.") + elif num_models > 1: + raise ValueError("Model is amibguous, more than one model in waiting area.") + else: + c_id = unloaded_models[0] + LOADED_MODELS[c_id]=model + lmp_model = c_id + lmp_model.connect_param_counts() + cdef public void MLIAPPY_unload_model(MLIAPModelPython * c_model) with gil: - del LOADED_MODELS[int( c_model)] + del LOADED_MODELS[c_id(c_model)] cdef public int MLIAPPY_nparams(MLIAPModelPython * c_model) with gil: - model = LOADED_MODELS[int( c_model)] - n_params = int(model.n_params) - return n_params + return int(retrieve(c_model).n_params) cdef public int MLIAPPY_nelements(MLIAPModelPython * c_model) with gil: - model = LOADED_MODELS[int( c_model)] - n_elements = int(model.n_elements) - return n_elements + return int(retrieve(c_model).n_elements) cdef public int MLIAPPY_ndescriptors(MLIAPModelPython * c_model) with gil: - model = LOADED_MODELS[int( c_model)] - n_descriptors = int(model.n_descriptors) - return n_descriptors + return int(retrieve(c_model).n_descriptors) -cdef public MLIAPPY_model_callback(MLIAPModelPython * c_model, MLIAPData * data) with gil: - model = LOADED_MODELS[int( c_model)] +cdef public void MLIAPPY_compute_gradients(MLIAPModelPython * c_model, MLIAPData * data) with gil: + model = retrieve(c_model) n_d = data.ndescriptors n_a = data.natoms @@ -73,11 +111,11 @@ cdef public MLIAPPY_model_callback(MLIAPModelPython * c_model, MLIAPData * data) # Make numpy arrays from pointers beta_np = np.asarray( &data.betas[0][0]) desc_np = np.asarray( &data.descriptors[0][0]) - type_np = np.asarray( &data.ielems[0]) + elem_np = np.asarray( &data.ielems[0]) en_np = np.asarray( &data.eatoms[0]) # Invoke python model on numpy arrays. - model(type_np,desc_np,beta_np,en_np) + model(elem_np,desc_np,beta_np,en_np) # Get the total energy from the atom energy. energy = np.sum(en_np) diff --git a/src/MLIAPPY/mliappy_pytorch.py b/src/MLIAPPY/mliappy_pytorch.py index b9f7ac3dcc..5294344c10 100644 --- a/src/MLIAPPY/mliappy_pytorch.py +++ b/src/MLIAPPY/mliappy_pytorch.py @@ -15,14 +15,14 @@ class TorchWrapper(torch.nn.Module): self.n_descriptors = n_descriptors self.n_elements = n_elements - def __call__(self, types, bispectrum, beta, energy): + def __call__(self, elems, bispectrum, beta, energy): bispectrum = torch.from_numpy(bispectrum).to(self.dtype).requires_grad_(True) - types = torch.from_numpy(types).to(torch.long) - 1 + elems = torch.from_numpy(elems).to(torch.long) - 1 with torch.autograd.enable_grad(): - energy_nn = self.model(bispectrum, types) + energy_nn = self.model(bispectrum, elems) if energy_nn.ndim > 1: energy_nn = energy_nn.flatten() @@ -37,10 +37,10 @@ class TorchWrapper32(TorchWrapper): class TorchWrapper64(TorchWrapper): dtype = torch.float64 -class IgnoreTypes(torch.nn.Module): +class IgnoreElems(torch.nn.Module): def __init__(self,subnet): super().__init__() self.subnet = subnet - def forward(self,bispectrum,types): + def forward(self,bispectrum,elems): return self.subnet(bispectrum) diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 9f54822c47..62f19d0f12 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -28,6 +28,9 @@ #ifdef LMP_MLIAPPY #include "mliap_model_python.h" +// The above should somehow really be included in the next file. +// We could get around this with cython --capi-reexport-cincludes +// However, that exposes -too many- headers. #include "mliap_model_python_couple.h" #endif @@ -52,7 +55,6 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) nfunc = 0; pfuncs = nullptr; - // one-time initialization of Python interpreter // pyMain stores pointer to main module external_interpreter = Py_IsInitialized(); @@ -61,7 +63,7 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // Inform python intialization scheme of the mliappy module. // This -must- happen before python is initialized. int err = PyImport_AppendInittab("mliap_model_python_couple", PyInit_mliap_model_python_couple); - // todo: catch if error and report problem. + if (err) error->all(FLERR,"Could not register MLIAPPY embedded python module."); #endif Py_Initialize(); From 97b77e0f138413162b3d51a6e784ad28517f91eb Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 30 Nov 2020 19:29:28 -0700 Subject: [PATCH 020/187] Added preprocessor flag --- src/MLIAPPY/Install.sh | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 src/MLIAPPY/Install.sh diff --git a/src/MLIAPPY/Install.sh b/src/MLIAPPY/Install.sh new file mode 100755 index 0000000000..8fccbc2a9c --- /dev/null +++ b/src/MLIAPPY/Install.sh @@ -0,0 +1,53 @@ +# Install/unInstall package files in LAMMPS +# mode = 0/1/2 for uninstall/install/update + +mode=$1 + +# arg1 = file, arg2 = file it depends on + +# enforce using portable C locale +LC_ALL=C +export LC_ALL + +action () { + if (test $mode = 0) then + rm -f ../$1 + elif (! cmp -s $1 ../$1) then + if (test -z "$2" || test -e ../$2) then + cp $1 .. + if (test $mode = 2) then + echo " updating src/$1" + fi + fi + elif (test -n "$2") then + if (test ! -e ../$2) then + rm -f ../$1 + fi + fi +} + +# force rebuild of files using python header + +touch ../lmppython.h + +# all package files with no dependencies + +for file in *.cpp *.h; do + test -f ${file} && action $file +done + +# edit 2 Makefile.package files to include/exclude package info + +if (test $1 = 1) then + + if (test -e ../Makefile.package) then + sed -i -e 's|^PKG_INC =[ \t]*|&-DLMP_MLIAPPY |' ../Makefile.package + fi + +elif (test $1 = 0) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*MLIAPPY[^ \t]* //g' ../Makefile.package + fi + +fi From 5a00d3c157186ff4e1163429dbfc541ec1d58f15 Mon Sep 17 00:00:00 2001 From: Julien Devemy Date: Tue, 1 Dec 2020 09:21:12 +0100 Subject: [PATCH 021/187] Fix invalid result when dihedral quadratic angle is > pi or < -pi --- src/USER-MISC/dihedral_quadratic.cpp | 2 ++ src/USER-OMP/dihedral_quadratic_omp.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/USER-MISC/dihedral_quadratic.cpp b/src/USER-MISC/dihedral_quadratic.cpp index bfe13d13d1..ef5711215c 100644 --- a/src/USER-MISC/dihedral_quadratic.cpp +++ b/src/USER-MISC/dihedral_quadratic.cpp @@ -195,6 +195,8 @@ void DihedralQuadratic::compute(int eflag, int vflag) siinv = 1.0/si; double dphi = phi-phi0[type]; + if (dphi > MY_PI) dphi -= 2*MY_PI; + else if (dphi < -MY_PI) dphi += 2*MY_PI; p = k[type]*dphi; pd = - 2.0 * p * siinv; p = p * dphi; diff --git a/src/USER-OMP/dihedral_quadratic_omp.cpp b/src/USER-OMP/dihedral_quadratic_omp.cpp index 2e25258b13..d183500182 100644 --- a/src/USER-OMP/dihedral_quadratic_omp.cpp +++ b/src/USER-OMP/dihedral_quadratic_omp.cpp @@ -23,11 +23,13 @@ #include "neighbor.h" #include "force.h" #include "update.h" +#include "math_const.h" #include "error.h" #include "suffix.h" using namespace LAMMPS_NS; +using namespace MathConst; #define TOLERANCE 0.05 #define SMALL 0.001 @@ -218,6 +220,8 @@ void DihedralQuadraticOMP::eval(int nfrom, int nto, ThrData * const thr) siinv = 1.0/si; double dphi = phi-phi0[type]; + if (dphi > MY_PI) dphi -= 2*MY_PI; + else if (dphi < -MY_PI) dphi += 2*MY_PI; p = k[type]*dphi; pd = - 2.0 * p * siinv; p = p * dphi; From 6ac481409a54d7d12853cda5eb0a471ec6b57488 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 1 Dec 2020 19:04:43 -0500 Subject: [PATCH 022/187] remove temporary flag for using the new pip resolver which is now the default --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index 59700f03aa..041c7a372a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -229,7 +229,7 @@ $(VENV): $(VIRTUALENV) -p $(PYTHON) $(VENV); \ . $(VENV)/bin/activate; \ pip install --upgrade pip; \ - pip install --use-feature=2020-resolver -r $(BUILDDIR)/utils/requirements.txt; \ + pip install -r $(BUILDDIR)/utils/requirements.txt; \ deactivate;\ ) From 63d8182ff375ecfee448a7f68d5580445a669bbc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 1 Dec 2020 19:06:09 -0500 Subject: [PATCH 023/187] fix spelling --- doc/src/balance.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/balance.rst b/doc/src/balance.rst index 7af8a86e9a..07ea82eeba 100644 --- a/doc/src/balance.rst +++ b/doc/src/balance.rst @@ -288,7 +288,7 @@ adjacent planes are closer together than the neighbor skin distance (as specified by the :doc`neigh_modify ` command), then the plane positions are shifted to separate them by at least this amount. This is to prevent particles being lost when dynamics are run -with processor subdomains that are too narrow in one or more +with processor sub-domains that are too narrow in one or more dimensions. Once the re-balancing is complete and final processor sub-domains From 71827f009950296ee56f9c0024de70eef6ddde31 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 1 Dec 2020 19:06:54 -0500 Subject: [PATCH 024/187] update pair meam/spline docs to reflect limitations of the implementation this closes #2500 --- doc/src/pair_meam_spline.rst | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/doc/src/pair_meam_spline.rst b/doc/src/pair_meam_spline.rst index b5c94385fa..6bedb9b4fb 100644 --- a/doc/src/pair_meam_spline.rst +++ b/doc/src/pair_meam_spline.rst @@ -20,7 +20,7 @@ Examples pair_style meam/spline pair_coeff * * Ti.meam.spline Ti - pair_coeff * * Ti.meam.spline Ti Ti Ti + pair_coeff * * Ti.meam.spline Ti O Description """"""""""" @@ -84,23 +84,22 @@ where N is the number of LAMMPS atom types: See the :doc:`pair_coeff ` doc page for alternate ways to specify the path for the potential file. -As an example, imagine the Ti.meam.spline file has values for Ti (old style). If -your LAMMPS simulation has 3 atoms types and they are all to be -treated with this potentials, you would use the following pair_coeff -command: +As an example, imagine the Ti.meam.spline file has values for Ti (old style). +In that case your LAMMPS simulation may only have one atom type which has +to be mapped to the Ti element as follows: .. code-block:: LAMMPS - pair_coeff * * Ti.meam.spline Ti Ti Ti + pair_coeff * * Ti.meam.spline Ti -The first 2 arguments must be \* \* so as to span all LAMMPS atom types. -The three Ti arguments map LAMMPS atom types 1,2,3 to the Ti element -in the potential file. If a mapping value is specified as NULL, the -mapping is not performed. This can be used when a *meam/spline* -potential is used as part of the *hybrid* pair style. The NULL values -are placeholders for atom types that will be used with other -potentials. The old-style potential maps any non-NULL species named -on the command line to that single type. +The first 2 arguments must be \* \* and there may be only one element +following or NULL. Systems where there would be multiple atom types +assigned to the same element are **not** supported by this pair style +due to limitations in its implementation. If a mapping value is +specified as NULL, the mapping is not performed. This can be used when +a *meam/spline* potential is used as part of the *hybrid* pair style. +The NULL values are placeholders for atom types that will be used with +other potentials. An example with a two component spline (new style) is TiO.meam.spline, where the command @@ -143,6 +142,8 @@ Restrictions This pair style requires the :doc:`newton ` setting to be "on" for pair interactions. +This pair style does not support mapping multiple atom types to the same element. + This pair style is only enabled if LAMMPS was built with the USER-MISC package. See the :doc:`Build package ` doc page for more info. From 206bc93026476a0ea42d892db40c22fc7c52a953 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 15:46:07 -0500 Subject: [PATCH 025/187] bond/react:refactor constraint framework constraints are now an array of Contraint structs --- src/USER-REACTION/fix_bond_react.cpp | 124 +++++++++++++-------------- src/USER-REACTION/fix_bond_react.h | 17 +++- 2 files changed, 76 insertions(+), 65 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 29a99db75f..6f7b52c95e 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -79,8 +79,8 @@ static const char cite_fix_bond_react[] = // RESTORE: restore mode, load most recent restore point enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE}; -// types of available reaction constraints -enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD}; +// constraint constants: constraints types, boolean operations, and ID type +enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD,AND,OR,ATOM,FRAG}; // keyword values that accept variables as input enum{NEVERY,RMIN,RMAX,PROB}; @@ -206,7 +206,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : memory->create(stabilize_steps_flag,nreacts,"bond/react:stabilize_steps_flag"); memory->create(custom_charges_fragid,nreacts,"bond/react:custom_charges_fragid"); memory->create(molecule_keyword,nreacts,"bond/react:molecule_keyword"); - memory->create(constraints,1,MAXCONARGS,"bond/react:constraints"); + memory->create(constraints,0,"bond/react:constraints"); memory->create(var_flag,NUMVARVALS,nreacts,"bond/react:var_flag"); memory->create(var_id,NUMVARVALS,nreacts,"bond/react:var_id"); memory->create(iatomtype,nreacts,"bond/react:iatomtype"); @@ -441,8 +441,8 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : rrhandom = new class RanMars*[narrhenius]; int tmp = 0; for (int i = 0; i < nconstraints; i++) { - if (constraints[i][1] == ARRHENIUS) { - rrhandom[tmp++] = new RanMars(lmp,(int) constraints[i][6] + me); + if (constraints[i].type == ARRHENIUS) { + rrhandom[tmp++] = new RanMars(lmp,(int) constraints[i].par[6] + me); } } @@ -1794,20 +1794,20 @@ int FixBondReact::check_constraints() double **x = atom->x; for (int i = 0; i < nconstraints; i++) { - if (constraints[i][0] == rxnID) { - if (constraints[i][1] == DISTANCE) { - get_IDcoords((int) constraints[i][2], (int) constraints[i][3], x1); - get_IDcoords((int) constraints[i][4], (int) constraints[i][5], x2); + if (constraints[i].rxnID == rxnID) { + if (constraints[i].type == DISTANCE) { + get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); + get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); delx = x1[0] - x2[0]; dely = x1[1] - x2[1]; delz = x1[2] - x2[2]; domain->minimum_image(delx,dely,delz); // ghost location fix rsq = delx*delx + dely*dely + delz*delz; - if (rsq < constraints[i][6] || rsq > constraints[i][7]) return 0; - } else if (constraints[i][1] == ANGLE) { - get_IDcoords((int) constraints[i][2], (int) constraints[i][3], x1); - get_IDcoords((int) constraints[i][4], (int) constraints[i][5], x2); - get_IDcoords((int) constraints[i][6], (int) constraints[i][7], x3); + if (rsq < constraints[i].par[6] || rsq > constraints[i].par[7]) return 0; + } else if (constraints[i].type == ANGLE) { + get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); + get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); + get_IDcoords((int) constraints[i].par[6], (int) constraints[i].par[7], x3); // 1st bond delx1 = x1[0] - x2[0]; @@ -1830,13 +1830,13 @@ int FixBondReact::check_constraints() c /= r1*r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - if (acos(c) < constraints[i][8] || acos(c) > constraints[i][9]) return 0; - } else if (constraints[i][1] == DIHEDRAL) { + if (acos(c) < constraints[i].par[8] || acos(c) > constraints[i].par[9]) return 0; + } else if (constraints[i].type == DIHEDRAL) { // phi calculation from dihedral style harmonic - get_IDcoords((int) constraints[i][2], (int) constraints[i][3], x1); - get_IDcoords((int) constraints[i][4], (int) constraints[i][5], x2); - get_IDcoords((int) constraints[i][6], (int) constraints[i][7], x3); - get_IDcoords((int) constraints[i][8], (int) constraints[i][9], x4); + get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); + get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); + get_IDcoords((int) constraints[i].par[6], (int) constraints[i].par[7], x3); + get_IDcoords((int) constraints[i].par[8], (int) constraints[i].par[9], x4); vb1x = x1[0] - x2[0]; vb1y = x1[1] - x2[1]; @@ -1883,30 +1883,30 @@ int FixBondReact::check_constraints() phi = atan2(s,c); ANDgate = 0; - if (constraints[i][10] < constraints[i][11]) { - if (phi > constraints[i][10] && phi < constraints[i][11]) ANDgate = 1; + if (constraints[i].par[10] < constraints[i].par[11]) { + if (phi > constraints[i].par[10] && phi < constraints[i].par[11]) ANDgate = 1; } else { - if (phi > constraints[i][10] || phi < constraints[i][11]) ANDgate = 1; + if (phi > constraints[i].par[10] || phi < constraints[i].par[11]) ANDgate = 1; } - if (constraints[i][12] < constraints[i][13]) { - if (phi > constraints[i][12] && phi < constraints[i][13]) ANDgate = 1; + if (constraints[i].par[12] < constraints[i].par[13]) { + if (phi > constraints[i].par[12] && phi < constraints[i].par[13]) ANDgate = 1; } else { - if (phi > constraints[i][12] || phi < constraints[i][13]) ANDgate = 1; + if (phi > constraints[i].par[12] || phi < constraints[i].par[13]) ANDgate = 1; } if (ANDgate != 1) return 0; - } else if (constraints[i][1] == ARRHENIUS) { + } else if (constraints[i].type == ARRHENIUS) { t = get_temperature(); - prrhob = constraints[i][3]*pow(t,constraints[i][4])* - exp(-constraints[i][5]/(force->boltz*t)); - if (prrhob < rrhandom[(int) constraints[i][2]]->uniform()) return 0; - } else if (constraints[i][1] == RMSD) { + prrhob = constraints[i].par[3]*pow(t,constraints[i].par[4])* + exp(-constraints[i].par[5]/(force->boltz*t)); + if (prrhob < rrhandom[(int) constraints[i].par[2]]->uniform()) return 0; + } else if (constraints[i].type == RMSD) { // call superpose int iatom; int iref = -1; // choose first atom as reference int n2superpose = 0; double **xfrozen; // coordinates for the "frozen" target molecule double **xmobile; // coordinates for the "mobile" molecule - int ifragment = constraints[i][3]; + int ifragment = constraints[i].par[3]; if (ifragment >= 0) { for (int j = 0; j < onemol->natoms; j++) if (onemol->fragmentmask[ifragment][j]) n2superpose++; @@ -1943,7 +1943,7 @@ int FixBondReact::check_constraints() } Superpose3D superposer(n2superpose); double rmsd = superposer.Superpose(xfrozen, xmobile); - if (rmsd > constraints[i][2]) return 0; + if (rmsd > constraints[i].par[2]) return 0; memory->destroy(xfrozen); memory->destroy(xmobile); } @@ -3215,7 +3215,7 @@ void FixBondReact::read(int myrxn) else if (strstr(line,"chiralIDs")) sscanf(line,"%d",&nchiral); else if (strstr(line,"constraints")) { sscanf(line,"%d",&nconstr); - memory->grow(constraints,nconstraints+nconstr,MAXCONARGS,"bond/react:constraints"); + memory->grow(constraints,nconstraints+nconstr,"bond/react:constraints"); } else break; } @@ -3250,7 +3250,7 @@ void FixBondReact::read(int myrxn) } else if (strcmp(keyword,"ChiralIDs") == 0) { ChiralCenters(line, myrxn); } else if (strcmp(keyword,"Constraints") == 0) { - Constraints(line, myrxn); + ReadConstraints(line, myrxn); } else error->one(FLERR,"Bond/react: Unknown section in map file"); parse_keyword(1,line,keyword); @@ -3348,7 +3348,7 @@ void FixBondReact::ChiralCenters(char *line, int myrxn) } } -void FixBondReact::Constraints(char *line, int myrxn) +void FixBondReact::ReadConstraints(char *line, int myrxn) { double tmp[MAXCONARGS]; char **strargs; @@ -3357,25 +3357,25 @@ void FixBondReact::Constraints(char *line, int myrxn) for (int i = 0; i < nconstr; i++) { readline(line); sscanf(line,"%s",constraint_type); - constraints[nconstraints][0] = myrxn; + constraints[nconstraints].rxnID = myrxn; if (strcmp(constraint_type,"distance") == 0) { - constraints[nconstraints][1] = DISTANCE; + constraints[nconstraints].type = DISTANCE; sscanf(line,"%*s %s %s %lg %lg",strargs[0],strargs[1],&tmp[0],&tmp[1]); readID(strargs[0], nconstraints, 2, 3); readID(strargs[1], nconstraints, 4, 5); // cutoffs - constraints[nconstraints][6] = tmp[0]*tmp[0]; // using square of distance - constraints[nconstraints][7] = tmp[1]*tmp[1]; + constraints[nconstraints].par[6] = tmp[0]*tmp[0]; // using square of distance + constraints[nconstraints].par[7] = tmp[1]*tmp[1]; } else if (strcmp(constraint_type,"angle") == 0) { - constraints[nconstraints][1] = ANGLE; + constraints[nconstraints].type = ANGLE; sscanf(line,"%*s %s %s %s %lg %lg",strargs[0],strargs[1],strargs[2],&tmp[0],&tmp[1]); readID(strargs[0], nconstraints, 2, 3); readID(strargs[1], nconstraints, 4, 5); readID(strargs[2], nconstraints, 6, 7); - constraints[nconstraints][8] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints][9] = tmp[1]/180.0 * MY_PI; + constraints[nconstraints].par[8] = tmp[0]/180.0 * MY_PI; + constraints[nconstraints].par[9] = tmp[1]/180.0 * MY_PI; } else if (strcmp(constraint_type,"dihedral") == 0) { - constraints[nconstraints][1] = DIHEDRAL; + constraints[nconstraints].type = DIHEDRAL; tmp[2] = 181.0; // impossible range tmp[3] = 182.0; sscanf(line,"%*s %s %s %s %s %lg %lg %lg %lg",strargs[0],strargs[1], @@ -3384,28 +3384,28 @@ void FixBondReact::Constraints(char *line, int myrxn) readID(strargs[1], nconstraints, 4, 5); readID(strargs[2], nconstraints, 6, 7); readID(strargs[3], nconstraints, 8, 9); - constraints[nconstraints][10] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints][11] = tmp[1]/180.0 * MY_PI; - constraints[nconstraints][12] = tmp[2]/180.0 * MY_PI; - constraints[nconstraints][13] = tmp[3]/180.0 * MY_PI; + constraints[nconstraints].par[10] = tmp[0]/180.0 * MY_PI; + constraints[nconstraints].par[11] = tmp[1]/180.0 * MY_PI; + constraints[nconstraints].par[12] = tmp[2]/180.0 * MY_PI; + constraints[nconstraints].par[13] = tmp[3]/180.0 * MY_PI; } else if (strcmp(constraint_type,"arrhenius") == 0) { - constraints[nconstraints][1] = ARRHENIUS; - constraints[nconstraints][2] = narrhenius++; + constraints[nconstraints].type = ARRHENIUS; + constraints[nconstraints].par[2] = narrhenius++; sscanf(line,"%*s %lg %lg %lg %lg",&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - constraints[nconstraints][3] = tmp[0]; - constraints[nconstraints][4] = tmp[1]; - constraints[nconstraints][5] = tmp[2]; - constraints[nconstraints][6] = tmp[3]; + constraints[nconstraints].par[3] = tmp[0]; + constraints[nconstraints].par[4] = tmp[1]; + constraints[nconstraints].par[5] = tmp[2]; + constraints[nconstraints].par[6] = tmp[3]; } else if (strcmp(constraint_type,"rmsd") == 0) { - constraints[nconstraints][1] = RMSD; + constraints[nconstraints].type = RMSD; strcpy(strargs[0],"0"); sscanf(line,"%*s %lg %s",&tmp[0],strargs[0]); - constraints[nconstraints][2] = tmp[0]; // RMSDmax - constraints[nconstraints][3] = -1; // optional molecule fragment + constraints[nconstraints].par[2] = tmp[0]; // RMSDmax + constraints[nconstraints].par[3] = -1; // optional molecule fragment if (isalpha(strargs[0][0])) { int ifragment = onemol->findfragment(strargs[0]); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - else constraints[nconstraints][3] = ifragment; + else constraints[nconstraints].par[3] = ifragment; } } else error->one(FLERR,"Bond/react: Illegal constraint type in 'Constraints' section of map file"); @@ -3423,15 +3423,15 @@ otherwise, it is a pre-reaction atom ID void FixBondReact::readID(char *strarg, int iconstr, int mode, int myID) { if (isalpha(strarg[0])) { - constraints[iconstr][mode] = 0; // fragment vs. atom ID flag + constraints[iconstr].par[mode] = 0; // fragment vs. atom ID flag int ifragment = onemol->findfragment(strarg); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - constraints[iconstr][myID] = ifragment; + constraints[iconstr].par[myID] = ifragment; } else { - constraints[iconstr][mode] = 1; // fragment vs. atom ID flag + constraints[iconstr].par[mode] = 1; // fragment vs. atom ID flag int iatom = atoi(strarg); if (iatom > onemol->natoms) error->one(FLERR,"Bond/react: Invalid template atom ID in map file"); - constraints[iconstr][myID] = iatom; + constraints[iconstr].par[myID] = iatom; } } diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index 6105859136..69abd47556 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -31,7 +31,9 @@ namespace LAMMPS_NS { class FixBondReact : public Fix { public: - enum {MAXLINE=256}; + enum {MAXLINE=256}; // max length of line read from files + enum {MAXCONIDS=4}; // max # of IDs used by any constraint + enum {MAXCONPAR=4}; // max # of constraint parameters FixBondReact(class LAMMPS *, int, char **); ~FixBondReact(); @@ -68,7 +70,6 @@ class FixBondReact : public Fix { int *molecule_keyword; int nconstraints; int narrhenius; - double **constraints; int **var_flag,**var_id; // for keyword values with variable inputs int status; int *groupbits; @@ -155,7 +156,7 @@ class FixBondReact : public Fix { void DeleteAtoms(char *, int); void CustomCharges(int, int); void ChiralCenters(char *, int); - void Constraints(char *, int); + void ReadConstraints(char *, int); void readID(char *, int, int, int); void make_a_guess (); @@ -195,6 +196,16 @@ class FixBondReact : public Fix { }; Set *set; + struct Constraint { + int type; + int rxnID; + int op; + int id[MAXCONIDS]; + int idtype[MAXCONIDS]; + double par[MAXCONPAR]; + }; + Constraint *constraints; + // DEBUG void print_bb(); From 29667da947fe435ffad9b72802f23b5a99751643 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 15:54:22 -0500 Subject: [PATCH 026/187] refactor RMSD constraint --- src/USER-REACTION/fix_bond_react.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 6f7b52c95e..520fc72885 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1906,7 +1906,7 @@ int FixBondReact::check_constraints() int n2superpose = 0; double **xfrozen; // coordinates for the "frozen" target molecule double **xmobile; // coordinates for the "mobile" molecule - int ifragment = constraints[i].par[3]; + int ifragment = constraints[i].id[0]; if (ifragment >= 0) { for (int j = 0; j < onemol->natoms; j++) if (onemol->fragmentmask[ifragment][j]) n2superpose++; @@ -1943,7 +1943,7 @@ int FixBondReact::check_constraints() } Superpose3D superposer(n2superpose); double rmsd = superposer.Superpose(xfrozen, xmobile); - if (rmsd > constraints[i].par[2]) return 0; + if (rmsd > constraints[i].par[0]) return 0; memory->destroy(xfrozen); memory->destroy(xmobile); } @@ -3400,12 +3400,12 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) constraints[nconstraints].type = RMSD; strcpy(strargs[0],"0"); sscanf(line,"%*s %lg %s",&tmp[0],strargs[0]); - constraints[nconstraints].par[2] = tmp[0]; // RMSDmax - constraints[nconstraints].par[3] = -1; // optional molecule fragment + constraints[nconstraints].par[0] = tmp[0]; // RMSDmax + constraints[nconstraints].id[0] = -1; // optional molecule fragment if (isalpha(strargs[0][0])) { int ifragment = onemol->findfragment(strargs[0]); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - else constraints[nconstraints].par[3] = ifragment; + else constraints[nconstraints].id[0] = ifragment; } } else error->one(FLERR,"Bond/react: Illegal constraint type in 'Constraints' section of map file"); From 0de8f829f3e620a4a22ee27417500ac802981316 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 16:02:54 -0500 Subject: [PATCH 027/187] refactor Arrhenius constraint --- src/USER-REACTION/fix_bond_react.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 520fc72885..e162a0e42c 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -442,7 +442,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : int tmp = 0; for (int i = 0; i < nconstraints; i++) { if (constraints[i].type == ARRHENIUS) { - rrhandom[tmp++] = new RanMars(lmp,(int) constraints[i].par[6] + me); + rrhandom[tmp++] = new RanMars(lmp,(int) constraints[i].par[4] + me); } } @@ -1896,9 +1896,9 @@ int FixBondReact::check_constraints() if (ANDgate != 1) return 0; } else if (constraints[i].type == ARRHENIUS) { t = get_temperature(); - prrhob = constraints[i].par[3]*pow(t,constraints[i].par[4])* - exp(-constraints[i].par[5]/(force->boltz*t)); - if (prrhob < rrhandom[(int) constraints[i].par[2]]->uniform()) return 0; + prrhob = constraints[i].par[1]*pow(t,constraints[i].par[2])* + exp(-constraints[i].par[3]/(force->boltz*t)); + if (prrhob < rrhandom[(int) constraints[i].par[0]]->uniform()) return 0; } else if (constraints[i].type == RMSD) { // call superpose int iatom; @@ -3390,12 +3390,12 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) constraints[nconstraints].par[13] = tmp[3]/180.0 * MY_PI; } else if (strcmp(constraint_type,"arrhenius") == 0) { constraints[nconstraints].type = ARRHENIUS; - constraints[nconstraints].par[2] = narrhenius++; + constraints[nconstraints].par[0] = narrhenius++; sscanf(line,"%*s %lg %lg %lg %lg",&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - constraints[nconstraints].par[3] = tmp[0]; - constraints[nconstraints].par[4] = tmp[1]; - constraints[nconstraints].par[5] = tmp[2]; - constraints[nconstraints].par[6] = tmp[3]; + constraints[nconstraints].par[1] = tmp[0]; + constraints[nconstraints].par[2] = tmp[1]; + constraints[nconstraints].par[3] = tmp[2]; + constraints[nconstraints].par[4] = tmp[3]; } else if (strcmp(constraint_type,"rmsd") == 0) { constraints[nconstraints].type = RMSD; strcpy(strargs[0],"0"); From 04e586c83d6273631ae055f58701a8bf483ea4e4 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 16:25:27 -0500 Subject: [PATCH 028/187] refactor distanace constraint NOTE: messes up angle and dihedral constraints! --- src/USER-REACTION/fix_bond_react.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index e162a0e42c..b5bcf5eae2 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1796,14 +1796,14 @@ int FixBondReact::check_constraints() for (int i = 0; i < nconstraints; i++) { if (constraints[i].rxnID == rxnID) { if (constraints[i].type == DISTANCE) { - get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); - get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); + get_IDcoords(constraints[i].idtype[0], constraints[i].id[0], x1); + get_IDcoords(constraints[i].idtype[1], constraints[i].id[1], x2); delx = x1[0] - x2[0]; dely = x1[1] - x2[1]; delz = x1[2] - x2[2]; domain->minimum_image(delx,dely,delz); // ghost location fix rsq = delx*delx + dely*dely + delz*delz; - if (rsq < constraints[i].par[6] || rsq > constraints[i].par[7]) return 0; + if (rsq < constraints[i].par[0] || rsq > constraints[i].par[1]) return 0; } else if (constraints[i].type == ANGLE) { get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); @@ -1985,7 +1985,7 @@ fragment: given pre-reacted molID (onemol) and fragID, void FixBondReact::get_IDcoords(int mode, int myID, double *center) { double **x = atom->x; - if (mode == 1) { + if (mode == ATOM) { int iatom = atom->map(glove[myID-1][1]); for (int i = 0; i < 3; i++) center[i] = x[iatom][i]; @@ -3361,11 +3361,11 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) if (strcmp(constraint_type,"distance") == 0) { constraints[nconstraints].type = DISTANCE; sscanf(line,"%*s %s %s %lg %lg",strargs[0],strargs[1],&tmp[0],&tmp[1]); - readID(strargs[0], nconstraints, 2, 3); - readID(strargs[1], nconstraints, 4, 5); + readID(strargs[0], nconstraints, 0); + readID(strargs[1], nconstraints, 1); // cutoffs - constraints[nconstraints].par[6] = tmp[0]*tmp[0]; // using square of distance - constraints[nconstraints].par[7] = tmp[1]*tmp[1]; + constraints[nconstraints].par[0] = tmp[0]*tmp[0]; // using square of distance + constraints[nconstraints].par[1] = tmp[1]*tmp[1]; } else if (strcmp(constraint_type,"angle") == 0) { constraints[nconstraints].type = ANGLE; sscanf(line,"%*s %s %s %s %lg %lg",strargs[0],strargs[1],strargs[2],&tmp[0],&tmp[1]); @@ -3420,18 +3420,18 @@ if ID starts with character, assume it is a pre-reaction molecule fragment ID otherwise, it is a pre-reaction atom ID ---------------------------------------------------------------------- */ -void FixBondReact::readID(char *strarg, int iconstr, int mode, int myID) +void FixBondReact::readID(char *strarg, int iconstr, int i, int dummy) { if (isalpha(strarg[0])) { - constraints[iconstr].par[mode] = 0; // fragment vs. atom ID flag + constraints[iconstr].idtype[i] = FRAG; // fragment vs. atom ID flag int ifragment = onemol->findfragment(strarg); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - constraints[iconstr].par[myID] = ifragment; + constraints[iconstr].id[i] = ifragment; } else { - constraints[iconstr].par[mode] = 1; // fragment vs. atom ID flag + constraints[iconstr].idtype[i] = ATOM; // fragment vs. atom ID flag int iatom = atoi(strarg); if (iatom > onemol->natoms) error->one(FLERR,"Bond/react: Invalid template atom ID in map file"); - constraints[iconstr].par[myID] = iatom; + constraints[iconstr].id[i] = iatom; } } From 2af32741fd4547e794b2a5b7c11338f5eb0b5a57 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 16:33:17 -0500 Subject: [PATCH 029/187] refactor angle constraint --- src/USER-REACTION/fix_bond_react.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index b5bcf5eae2..ece4dc9bce 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1805,9 +1805,9 @@ int FixBondReact::check_constraints() rsq = delx*delx + dely*dely + delz*delz; if (rsq < constraints[i].par[0] || rsq > constraints[i].par[1]) return 0; } else if (constraints[i].type == ANGLE) { - get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); - get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); - get_IDcoords((int) constraints[i].par[6], (int) constraints[i].par[7], x3); + get_IDcoords(constraints[i].idtype[0], constraints[i].id[0], x1); + get_IDcoords(constraints[i].idtype[1], constraints[i].id[1], x2); + get_IDcoords(constraints[i].idtype[2], constraints[i].id[2], x3); // 1st bond delx1 = x1[0] - x2[0]; @@ -1830,7 +1830,7 @@ int FixBondReact::check_constraints() c /= r1*r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - if (acos(c) < constraints[i].par[8] || acos(c) > constraints[i].par[9]) return 0; + if (acos(c) < constraints[i].par[0] || acos(c) > constraints[i].par[1]) return 0; } else if (constraints[i].type == DIHEDRAL) { // phi calculation from dihedral style harmonic get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); @@ -3369,11 +3369,11 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) } else if (strcmp(constraint_type,"angle") == 0) { constraints[nconstraints].type = ANGLE; sscanf(line,"%*s %s %s %s %lg %lg",strargs[0],strargs[1],strargs[2],&tmp[0],&tmp[1]); - readID(strargs[0], nconstraints, 2, 3); - readID(strargs[1], nconstraints, 4, 5); - readID(strargs[2], nconstraints, 6, 7); - constraints[nconstraints].par[8] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints].par[9] = tmp[1]/180.0 * MY_PI; + readID(strargs[0], nconstraints, 0); + readID(strargs[1], nconstraints, 1); + readID(strargs[2], nconstraints, 2); + constraints[nconstraints].par[0] = tmp[0]/180.0 * MY_PI; + constraints[nconstraints].par[1] = tmp[1]/180.0 * MY_PI; } else if (strcmp(constraint_type,"dihedral") == 0) { constraints[nconstraints].type = DIHEDRAL; tmp[2] = 181.0; // impossible range From 3a07eef523c854b871b909a8c9a7fe1f19a5be18 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 16:41:41 -0500 Subject: [PATCH 030/187] refactor dihedral constraint --- src/USER-REACTION/fix_bond_react.cpp | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index ece4dc9bce..21f334f5b0 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1833,10 +1833,10 @@ int FixBondReact::check_constraints() if (acos(c) < constraints[i].par[0] || acos(c) > constraints[i].par[1]) return 0; } else if (constraints[i].type == DIHEDRAL) { // phi calculation from dihedral style harmonic - get_IDcoords((int) constraints[i].par[2], (int) constraints[i].par[3], x1); - get_IDcoords((int) constraints[i].par[4], (int) constraints[i].par[5], x2); - get_IDcoords((int) constraints[i].par[6], (int) constraints[i].par[7], x3); - get_IDcoords((int) constraints[i].par[8], (int) constraints[i].par[9], x4); + get_IDcoords(constraints[i].idtype[0], constraints[i].id[0], x1); + get_IDcoords(constraints[i].idtype[1], constraints[i].id[1], x2); + get_IDcoords(constraints[i].idtype[2], constraints[i].id[2], x3); + get_IDcoords(constraints[i].idtype[3], constraints[i].id[3], x4); vb1x = x1[0] - x2[0]; vb1y = x1[1] - x2[1]; @@ -1883,15 +1883,15 @@ int FixBondReact::check_constraints() phi = atan2(s,c); ANDgate = 0; - if (constraints[i].par[10] < constraints[i].par[11]) { - if (phi > constraints[i].par[10] && phi < constraints[i].par[11]) ANDgate = 1; + if (constraints[i].par[0] < constraints[i].par[1]) { + if (phi > constraints[i].par[0] && phi < constraints[i].par[1]) ANDgate = 1; } else { - if (phi > constraints[i].par[10] || phi < constraints[i].par[11]) ANDgate = 1; + if (phi > constraints[i].par[0] || phi < constraints[i].par[1]) ANDgate = 1; } - if (constraints[i].par[12] < constraints[i].par[13]) { - if (phi > constraints[i].par[12] && phi < constraints[i].par[13]) ANDgate = 1; + if (constraints[i].par[2] < constraints[i].par[3]) { + if (phi > constraints[i].par[2] && phi < constraints[i].par[3]) ANDgate = 1; } else { - if (phi > constraints[i].par[12] || phi < constraints[i].par[13]) ANDgate = 1; + if (phi > constraints[i].par[2] || phi < constraints[i].par[3]) ANDgate = 1; } if (ANDgate != 1) return 0; } else if (constraints[i].type == ARRHENIUS) { @@ -3380,14 +3380,14 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) tmp[3] = 182.0; sscanf(line,"%*s %s %s %s %s %lg %lg %lg %lg",strargs[0],strargs[1], strargs[2],strargs[3],&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - readID(strargs[0], nconstraints, 2, 3); - readID(strargs[1], nconstraints, 4, 5); - readID(strargs[2], nconstraints, 6, 7); - readID(strargs[3], nconstraints, 8, 9); - constraints[nconstraints].par[10] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints].par[11] = tmp[1]/180.0 * MY_PI; - constraints[nconstraints].par[12] = tmp[2]/180.0 * MY_PI; - constraints[nconstraints].par[13] = tmp[3]/180.0 * MY_PI; + readID(strargs[0], nconstraints, 0); + readID(strargs[1], nconstraints, 1); + readID(strargs[2], nconstraints, 2); + readID(strargs[3], nconstraints, 3); + constraints[nconstraints].par[0] = tmp[0]/180.0 * MY_PI; + constraints[nconstraints].par[1] = tmp[1]/180.0 * MY_PI; + constraints[nconstraints].par[2] = tmp[2]/180.0 * MY_PI; + constraints[nconstraints].par[3] = tmp[3]/180.0 * MY_PI; } else if (strcmp(constraint_type,"arrhenius") == 0) { constraints[nconstraints].type = ARRHENIUS; constraints[nconstraints].par[0] = narrhenius++; From 8df26f551e52b5d40882e10f53a7016ee135575c Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 16:43:49 -0500 Subject: [PATCH 031/187] clean constraints refactor --- src/USER-REACTION/fix_bond_react.cpp | 2 +- src/USER-REACTION/fix_bond_react.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 21f334f5b0..69effa2797 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -3420,7 +3420,7 @@ if ID starts with character, assume it is a pre-reaction molecule fragment ID otherwise, it is a pre-reaction atom ID ---------------------------------------------------------------------- */ -void FixBondReact::readID(char *strarg, int iconstr, int i, int dummy) +void FixBondReact::readID(char *strarg, int iconstr, int i) { if (isalpha(strarg[0])) { constraints[iconstr].idtype[i] = FRAG; // fragment vs. atom ID flag diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index 69abd47556..011cca7368 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -157,7 +157,7 @@ class FixBondReact : public Fix { void CustomCharges(int, int); void ChiralCenters(char *, int); void ReadConstraints(char *, int); - void readID(char *, int, int, int); + void readID(char *, int, int); void make_a_guess (); void neighbor_loop(); From 63e8c8359984c2395350c5f9424306664511633a Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Thu, 19 Nov 2020 20:39:57 -0500 Subject: [PATCH 032/187] refactor constraints array into per-rxn --- src/USER-REACTION/fix_bond_react.cpp | 360 +++++++++++++-------------- src/USER-REACTION/fix_bond_react.h | 8 +- 2 files changed, 184 insertions(+), 184 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 69effa2797..8ec7350690 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -79,7 +79,7 @@ static const char cite_fix_bond_react[] = // RESTORE: restore mode, load most recent restore point enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE}; -// constraint constants: constraints types, boolean operations, and ID type +// constraint constants: constraint types, boolean operation, and ID type enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD,AND,OR,ATOM,FRAG}; // keyword values that accept variables as input @@ -115,7 +115,6 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : global_freq = 1; extvector = 0; rxnID = 0; - nconstraints = 0; narrhenius = 0; status = PROCEED; @@ -206,7 +205,8 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : memory->create(stabilize_steps_flag,nreacts,"bond/react:stabilize_steps_flag"); memory->create(custom_charges_fragid,nreacts,"bond/react:custom_charges_fragid"); memory->create(molecule_keyword,nreacts,"bond/react:molecule_keyword"); - memory->create(constraints,0,"bond/react:constraints"); + memory->create(nconstraints,nreacts,"bond/react:nconstraints"); + memory->create(constraints,0,nreacts,"bond/react:constraints"); memory->create(var_flag,NUMVARVALS,nreacts,"bond/react:var_flag"); memory->create(var_id,NUMVARVALS,nreacts,"bond/react:var_id"); memory->create(iatomtype,nreacts,"bond/react:iatomtype"); @@ -440,9 +440,11 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : rrhandom = new class RanMars*[narrhenius]; int tmp = 0; - for (int i = 0; i < nconstraints; i++) { - if (constraints[i].type == ARRHENIUS) { - rrhandom[tmp++] = new RanMars(lmp,(int) constraints[i].par[4] + me); + for (int i = 0; i < nreacts; i++) { + for (int j = 0; j < nconstraints[i]; j++) { + if (constraints[j][i].type == ARRHENIUS) { + rrhandom[tmp++] = new RanMars(lmp,(int) constraints[j][i].par[4] + me); + } } } @@ -562,6 +564,8 @@ FixBondReact::~FixBondReact() memory->destroy(stabilize_steps_flag); memory->destroy(custom_charges_fragid); memory->destroy(molecule_keyword); + memory->destroy(constraints); + memory->destroy(nconstraints); memory->destroy(iatomtype); memory->destroy(jatomtype); @@ -1793,160 +1797,158 @@ int FixBondReact::check_constraints() tagint atom1,atom2; double **x = atom->x; - for (int i = 0; i < nconstraints; i++) { - if (constraints[i].rxnID == rxnID) { - if (constraints[i].type == DISTANCE) { - get_IDcoords(constraints[i].idtype[0], constraints[i].id[0], x1); - get_IDcoords(constraints[i].idtype[1], constraints[i].id[1], x2); - delx = x1[0] - x2[0]; - dely = x1[1] - x2[1]; - delz = x1[2] - x2[2]; - domain->minimum_image(delx,dely,delz); // ghost location fix - rsq = delx*delx + dely*dely + delz*delz; - if (rsq < constraints[i].par[0] || rsq > constraints[i].par[1]) return 0; - } else if (constraints[i].type == ANGLE) { - get_IDcoords(constraints[i].idtype[0], constraints[i].id[0], x1); - get_IDcoords(constraints[i].idtype[1], constraints[i].id[1], x2); - get_IDcoords(constraints[i].idtype[2], constraints[i].id[2], x3); + for (int i = 0; i < nconstraints[rxnID]; i++) { + if (constraints[i][rxnID].type == DISTANCE) { + get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); + get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); + delx = x1[0] - x2[0]; + dely = x1[1] - x2[1]; + delz = x1[2] - x2[2]; + domain->minimum_image(delx,dely,delz); // ghost location fix + rsq = delx*delx + dely*dely + delz*delz; + if (rsq < constraints[i][rxnID].par[0] || rsq > constraints[i][rxnID].par[1]) return 0; + } else if (constraints[i][rxnID].type == ANGLE) { + get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); + get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); + get_IDcoords(constraints[i][rxnID].idtype[2], constraints[i][rxnID].id[2], x3); - // 1st bond - delx1 = x1[0] - x2[0]; - dely1 = x1[1] - x2[1]; - delz1 = x1[2] - x2[2]; - domain->minimum_image(delx1,dely1,delz1); // ghost location fix - rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - r1 = sqrt(rsq1); + // 1st bond + delx1 = x1[0] - x2[0]; + dely1 = x1[1] - x2[1]; + delz1 = x1[2] - x2[2]; + domain->minimum_image(delx1,dely1,delz1); // ghost location fix + rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; + r1 = sqrt(rsq1); - // 2nd bond - delx2 = x3[0] - x2[0]; - dely2 = x3[1] - x2[1]; - delz2 = x3[2] - x2[2]; - domain->minimum_image(delx2,dely2,delz2); // ghost location fix - rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - r2 = sqrt(rsq2); + // 2nd bond + delx2 = x3[0] - x2[0]; + dely2 = x3[1] - x2[1]; + delz2 = x3[2] - x2[2]; + domain->minimum_image(delx2,dely2,delz2); // ghost location fix + rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; + r2 = sqrt(rsq2); - // angle (cos and sin) - c = delx1*delx2 + dely1*dely2 + delz1*delz2; - c /= r1*r2; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; - if (acos(c) < constraints[i].par[0] || acos(c) > constraints[i].par[1]) return 0; - } else if (constraints[i].type == DIHEDRAL) { - // phi calculation from dihedral style harmonic - get_IDcoords(constraints[i].idtype[0], constraints[i].id[0], x1); - get_IDcoords(constraints[i].idtype[1], constraints[i].id[1], x2); - get_IDcoords(constraints[i].idtype[2], constraints[i].id[2], x3); - get_IDcoords(constraints[i].idtype[3], constraints[i].id[3], x4); + // angle (cos and sin) + c = delx1*delx2 + dely1*dely2 + delz1*delz2; + c /= r1*r2; + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + if (acos(c) < constraints[i][rxnID].par[0] || acos(c) > constraints[i][rxnID].par[1]) return 0; + } else if (constraints[i][rxnID].type == DIHEDRAL) { + // phi calculation from dihedral style harmonic + get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); + get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); + get_IDcoords(constraints[i][rxnID].idtype[2], constraints[i][rxnID].id[2], x3); + get_IDcoords(constraints[i][rxnID].idtype[3], constraints[i][rxnID].id[3], x4); - vb1x = x1[0] - x2[0]; - vb1y = x1[1] - x2[1]; - vb1z = x1[2] - x2[2]; - domain->minimum_image(vb1x,vb1y,vb1z); + vb1x = x1[0] - x2[0]; + vb1y = x1[1] - x2[1]; + vb1z = x1[2] - x2[2]; + domain->minimum_image(vb1x,vb1y,vb1z); - vb2x = x3[0] - x2[0]; - vb2y = x3[1] - x2[1]; - vb2z = x3[2] - x2[2]; - domain->minimum_image(vb2x,vb2y,vb2z); + vb2x = x3[0] - x2[0]; + vb2y = x3[1] - x2[1]; + vb2z = x3[2] - x2[2]; + domain->minimum_image(vb2x,vb2y,vb2z); - vb2xm = -vb2x; - vb2ym = -vb2y; - vb2zm = -vb2z; - domain->minimum_image(vb2xm,vb2ym,vb2zm); + vb2xm = -vb2x; + vb2ym = -vb2y; + vb2zm = -vb2z; + domain->minimum_image(vb2xm,vb2ym,vb2zm); - vb3x = x4[0] - x3[0]; - vb3y = x4[1] - x3[1]; - vb3z = x4[2] - x3[2]; - domain->minimum_image(vb3x,vb3y,vb3z); + vb3x = x4[0] - x3[0]; + vb3y = x4[1] - x3[1]; + vb3z = x4[2] - x3[2]; + 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; - rg = sqrt(rgsq); + 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); + ra2inv = rb2inv = 0.0; + 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); + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + phi = atan2(s,c); - ANDgate = 0; - if (constraints[i].par[0] < constraints[i].par[1]) { - if (phi > constraints[i].par[0] && phi < constraints[i].par[1]) ANDgate = 1; - } else { - if (phi > constraints[i].par[0] || phi < constraints[i].par[1]) ANDgate = 1; - } - if (constraints[i].par[2] < constraints[i].par[3]) { - if (phi > constraints[i].par[2] && phi < constraints[i].par[3]) ANDgate = 1; - } else { - if (phi > constraints[i].par[2] || phi < constraints[i].par[3]) ANDgate = 1; - } - if (ANDgate != 1) return 0; - } else if (constraints[i].type == ARRHENIUS) { - t = get_temperature(); - prrhob = constraints[i].par[1]*pow(t,constraints[i].par[2])* - exp(-constraints[i].par[3]/(force->boltz*t)); - if (prrhob < rrhandom[(int) constraints[i].par[0]]->uniform()) return 0; - } else if (constraints[i].type == RMSD) { - // call superpose - int iatom; - int iref = -1; // choose first atom as reference - int n2superpose = 0; - double **xfrozen; // coordinates for the "frozen" target molecule - double **xmobile; // coordinates for the "mobile" molecule - int ifragment = constraints[i].id[0]; - if (ifragment >= 0) { - for (int j = 0; j < onemol->natoms; j++) - if (onemol->fragmentmask[ifragment][j]) n2superpose++; - memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); - memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); - int myincr = 0; - for (int j = 0; j < onemol->natoms; j++) { - if (onemol->fragmentmask[ifragment][j]) { - iatom = atom->map(glove[j][1]); - if (iref == -1) iref = iatom; - iatom = domain->closest_image(iref,iatom); - for (int k = 0; k < 3; k++) { - xfrozen[myincr][k] = x[iatom][k]; - xmobile[myincr][k] = onemol->x[j][k]; - } - myincr++; - } - } - } else { - int iatom; - int iref = -1; // choose first atom as reference - n2superpose = onemol->natoms; - memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); - memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); - for (int j = 0; j < n2superpose; j++) { + ANDgate = 0; + if (constraints[i][rxnID].par[0] < constraints[i][rxnID].par[1]) { + if (phi > constraints[i][rxnID].par[0] && phi < constraints[i][rxnID].par[1]) ANDgate = 1; + } else { + if (phi > constraints[i][rxnID].par[0] || phi < constraints[i][rxnID].par[1]) ANDgate = 1; + } + if (constraints[i][rxnID].par[2] < constraints[i][rxnID].par[3]) { + if (phi > constraints[i][rxnID].par[2] && phi < constraints[i][rxnID].par[3]) ANDgate = 1; + } else { + if (phi > constraints[i][rxnID].par[2] || phi < constraints[i][rxnID].par[3]) ANDgate = 1; + } + if (ANDgate != 1) return 0; + } else if (constraints[i][rxnID].type == ARRHENIUS) { + t = get_temperature(); + prrhob = constraints[i][rxnID].par[1]*pow(t,constraints[i][rxnID].par[2])* + exp(-constraints[i][rxnID].par[3]/(force->boltz*t)); + if (prrhob < rrhandom[(int) constraints[i][rxnID].par[0]]->uniform()) return 0; + } else if (constraints[i][rxnID].type == RMSD) { + // call superpose + int iatom; + int iref = -1; // choose first atom as reference + int n2superpose = 0; + double **xfrozen; // coordinates for the "frozen" target molecule + double **xmobile; // coordinates for the "mobile" molecule + int ifragment = constraints[i][rxnID].id[0]; + if (ifragment >= 0) { + for (int j = 0; j < onemol->natoms; j++) + if (onemol->fragmentmask[ifragment][j]) n2superpose++; + memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); + memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); + int myincr = 0; + for (int j = 0; j < onemol->natoms; j++) { + if (onemol->fragmentmask[ifragment][j]) { iatom = atom->map(glove[j][1]); if (iref == -1) iref = iatom; iatom = domain->closest_image(iref,iatom); for (int k = 0; k < 3; k++) { - xfrozen[j][k] = x[iatom][k]; - xmobile[j][k] = onemol->x[j][k]; + xfrozen[myincr][k] = x[iatom][k]; + xmobile[myincr][k] = onemol->x[j][k]; } + myincr++; + } + } + } else { + int iatom; + int iref = -1; // choose first atom as reference + n2superpose = onemol->natoms; + memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); + memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); + for (int j = 0; j < n2superpose; j++) { + iatom = atom->map(glove[j][1]); + if (iref == -1) iref = iatom; + iatom = domain->closest_image(iref,iatom); + for (int k = 0; k < 3; k++) { + xfrozen[j][k] = x[iatom][k]; + xmobile[j][k] = onemol->x[j][k]; } } - Superpose3D superposer(n2superpose); - double rmsd = superposer.Superpose(xfrozen, xmobile); - if (rmsd > constraints[i].par[0]) return 0; - memory->destroy(xfrozen); - memory->destroy(xmobile); } + Superpose3D superposer(n2superpose); + double rmsd = superposer.Superpose(xfrozen, xmobile); + if (rmsd > constraints[i][rxnID].par[0]) return 0; + memory->destroy(xfrozen); + memory->destroy(xmobile); } } @@ -3214,8 +3216,8 @@ void FixBondReact::read(int myrxn) else if (strstr(line,"deleteIDs")) sscanf(line,"%d",&ndelete); else if (strstr(line,"chiralIDs")) sscanf(line,"%d",&nchiral); else if (strstr(line,"constraints")) { - sscanf(line,"%d",&nconstr); - memory->grow(constraints,nconstraints+nconstr,"bond/react:constraints"); + sscanf(line,"%d",&nconstraints[myrxn]); + memory->grow(constraints,nconstraints[myrxn],nreacts,"bond/react:constraints"); } else break; } @@ -3351,65 +3353,63 @@ void FixBondReact::ChiralCenters(char *line, int myrxn) void FixBondReact::ReadConstraints(char *line, int myrxn) { double tmp[MAXCONARGS]; - char **strargs; + char **strargs,*ptr; memory->create(strargs,MAXCONARGS,MAXLINE,"bond/react:strargs"); char *constraint_type = new char[MAXLINE]; - for (int i = 0; i < nconstr; i++) { + for (int i = 0; i < nconstraints[myrxn]; i++) { readline(line); sscanf(line,"%s",constraint_type); - constraints[nconstraints].rxnID = myrxn; if (strcmp(constraint_type,"distance") == 0) { - constraints[nconstraints].type = DISTANCE; + constraints[i][myrxn].type = DISTANCE; sscanf(line,"%*s %s %s %lg %lg",strargs[0],strargs[1],&tmp[0],&tmp[1]); - readID(strargs[0], nconstraints, 0); - readID(strargs[1], nconstraints, 1); + readID(strargs[0], i, myrxn, 0); + readID(strargs[1], i, myrxn, 1); // cutoffs - constraints[nconstraints].par[0] = tmp[0]*tmp[0]; // using square of distance - constraints[nconstraints].par[1] = tmp[1]*tmp[1]; + constraints[i][myrxn].par[0] = tmp[0]*tmp[0]; // using square of distance + constraints[i][myrxn].par[1] = tmp[1]*tmp[1]; } else if (strcmp(constraint_type,"angle") == 0) { - constraints[nconstraints].type = ANGLE; + constraints[i][myrxn].type = ANGLE; sscanf(line,"%*s %s %s %s %lg %lg",strargs[0],strargs[1],strargs[2],&tmp[0],&tmp[1]); - readID(strargs[0], nconstraints, 0); - readID(strargs[1], nconstraints, 1); - readID(strargs[2], nconstraints, 2); - constraints[nconstraints].par[0] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints].par[1] = tmp[1]/180.0 * MY_PI; + readID(strargs[0], i, myrxn, 0); + readID(strargs[1], i, myrxn, 1); + readID(strargs[2], i, myrxn, 2); + constraints[i][myrxn].par[0] = tmp[0]/180.0 * MY_PI; + constraints[i][myrxn].par[1] = tmp[1]/180.0 * MY_PI; } else if (strcmp(constraint_type,"dihedral") == 0) { - constraints[nconstraints].type = DIHEDRAL; + constraints[i][myrxn].type = DIHEDRAL; tmp[2] = 181.0; // impossible range tmp[3] = 182.0; sscanf(line,"%*s %s %s %s %s %lg %lg %lg %lg",strargs[0],strargs[1], strargs[2],strargs[3],&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - readID(strargs[0], nconstraints, 0); - readID(strargs[1], nconstraints, 1); - readID(strargs[2], nconstraints, 2); - readID(strargs[3], nconstraints, 3); - constraints[nconstraints].par[0] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints].par[1] = tmp[1]/180.0 * MY_PI; - constraints[nconstraints].par[2] = tmp[2]/180.0 * MY_PI; - constraints[nconstraints].par[3] = tmp[3]/180.0 * MY_PI; + readID(strargs[0], i, myrxn, 0); + readID(strargs[1], i, myrxn, 1); + readID(strargs[2], i, myrxn, 2); + readID(strargs[3], i, myrxn, 3); + constraints[i][myrxn].par[0] = tmp[0]/180.0 * MY_PI; + constraints[i][myrxn].par[1] = tmp[1]/180.0 * MY_PI; + constraints[i][myrxn].par[2] = tmp[2]/180.0 * MY_PI; + constraints[i][myrxn].par[3] = tmp[3]/180.0 * MY_PI; } else if (strcmp(constraint_type,"arrhenius") == 0) { - constraints[nconstraints].type = ARRHENIUS; - constraints[nconstraints].par[0] = narrhenius++; + constraints[i][myrxn].type = ARRHENIUS; + constraints[i][myrxn].par[0] = narrhenius++; sscanf(line,"%*s %lg %lg %lg %lg",&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - constraints[nconstraints].par[1] = tmp[0]; - constraints[nconstraints].par[2] = tmp[1]; - constraints[nconstraints].par[3] = tmp[2]; - constraints[nconstraints].par[4] = tmp[3]; + constraints[i][myrxn].par[1] = tmp[0]; + constraints[i][myrxn].par[2] = tmp[1]; + constraints[i][myrxn].par[3] = tmp[2]; + constraints[i][myrxn].par[4] = tmp[3]; } else if (strcmp(constraint_type,"rmsd") == 0) { - constraints[nconstraints].type = RMSD; + constraints[i][myrxn].type = RMSD; strcpy(strargs[0],"0"); sscanf(line,"%*s %lg %s",&tmp[0],strargs[0]); - constraints[nconstraints].par[0] = tmp[0]; // RMSDmax - constraints[nconstraints].id[0] = -1; // optional molecule fragment + constraints[i][myrxn].par[0] = tmp[0]; // RMSDmax + constraints[i][myrxn].id[0] = -1; // optional molecule fragment if (isalpha(strargs[0][0])) { int ifragment = onemol->findfragment(strargs[0]); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - else constraints[nconstraints].id[0] = ifragment; + else constraints[i][myrxn].id[0] = ifragment; } } else error->one(FLERR,"Bond/react: Illegal constraint type in 'Constraints' section of map file"); - nconstraints++; } delete [] constraint_type; memory->destroy(strargs); @@ -3420,18 +3420,18 @@ if ID starts with character, assume it is a pre-reaction molecule fragment ID otherwise, it is a pre-reaction atom ID ---------------------------------------------------------------------- */ -void FixBondReact::readID(char *strarg, int iconstr, int i) +void FixBondReact::readID(char *strarg, int iconstr, int myrxn, int i) { if (isalpha(strarg[0])) { - constraints[iconstr].idtype[i] = FRAG; // fragment vs. atom ID flag + constraints[iconstr][myrxn].idtype[i] = FRAG; // fragment vs. atom ID flag int ifragment = onemol->findfragment(strarg); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - constraints[iconstr].id[i] = ifragment; + constraints[iconstr][myrxn].id[i] = ifragment; } else { - constraints[iconstr].idtype[i] = ATOM; // fragment vs. atom ID flag + constraints[iconstr][myrxn].idtype[i] = ATOM; // fragment vs. atom ID flag int iatom = atoi(strarg); if (iatom > onemol->natoms) error->one(FLERR,"Bond/react: Invalid template atom ID in map file"); - constraints[iconstr].id[i] = iatom; + constraints[iconstr][myrxn].id[i] = iatom; } } diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index 011cca7368..ba768c131f 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -68,7 +68,7 @@ class FixBondReact : public Fix { int *stabilize_steps_flag; int *custom_charges_fragid; int *molecule_keyword; - int nconstraints; + int *nconstraints; int narrhenius; int **var_flag,**var_id; // for keyword values with variable inputs int status; @@ -115,7 +115,7 @@ class FixBondReact : public Fix { int *ibonding,*jbonding; int *closeneigh; // indicates if bonding atoms of a rxn are 1-2, 1-3, or 1-4 neighbors - int nedge,nequivalent,ndelete,nchiral,nconstr; // # edge, equivalent atoms in mapping file + int nedge,nequivalent,ndelete,nchiral; // # edge, equivalent atoms in mapping file int attempted_rxn; // there was an attempt! int *local_rxn_count; int *ghostly_rxn_count; @@ -157,7 +157,7 @@ class FixBondReact : public Fix { void CustomCharges(int, int); void ChiralCenters(char *, int); void ReadConstraints(char *, int); - void readID(char *, int, int); + void readID(char *, int, int, int); void make_a_guess (); void neighbor_loop(); @@ -204,7 +204,7 @@ class FixBondReact : public Fix { int idtype[MAXCONIDS]; double par[MAXCONPAR]; }; - Constraint *constraints; + Constraint **constraints; // DEBUG From 855cf2146f924f613ef19299a0689eb94f57289d Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 20 Nov 2020 13:49:13 -0500 Subject: [PATCH 033/187] set for boolean constraint logic --- src/USER-REACTION/fix_bond_react.cpp | 54 ++++++++++++++++++++++++---- src/USER-REACTION/fix_bond_react.h | 3 +- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 8ec7350690..1135d6b861 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -79,8 +79,11 @@ static const char cite_fix_bond_react[] = // RESTORE: restore mode, load most recent restore point enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE}; -// constraint constants: constraint types, boolean operation, and ID type -enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD,AND,OR,ATOM,FRAG}; +// types of available reaction constraints +enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD}; + +// ID type used by constraint +enum{ATOM,FRAG}; // keyword values that accept variables as input enum{NEVERY,RMIN,RMAX,PROB}; @@ -206,6 +209,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : memory->create(custom_charges_fragid,nreacts,"bond/react:custom_charges_fragid"); memory->create(molecule_keyword,nreacts,"bond/react:molecule_keyword"); memory->create(nconstraints,nreacts,"bond/react:nconstraints"); + memory->create(constraintstr,nreacts,MAXLINE,"bond/react:constraintstr"); memory->create(constraints,0,nreacts,"bond/react:constraints"); memory->create(var_flag,NUMVARVALS,nreacts,"bond/react:var_flag"); memory->create(var_id,NUMVARVALS,nreacts,"bond/react:var_id"); @@ -566,6 +570,7 @@ FixBondReact::~FixBondReact() memory->destroy(molecule_keyword); memory->destroy(constraints); memory->destroy(nconstraints); + // need to delete rxn_name and constraintstr memory->destroy(iatomtype); memory->destroy(jatomtype); @@ -1797,6 +1802,11 @@ int FixBondReact::check_constraints() tagint atom1,atom2; double **x = atom->x; + int *satisfied; + memory->create(satisfied,nconstraints[rxnID],"bond/react:satisfied"); + for (int i = 0; i < nconstraints[rxnID]; i++) + satisfied[i] = 1; + for (int i = 0; i < nconstraints[rxnID]; i++) { if (constraints[i][rxnID].type == DISTANCE) { get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); @@ -1806,7 +1816,7 @@ int FixBondReact::check_constraints() delz = x1[2] - x2[2]; domain->minimum_image(delx,dely,delz); // ghost location fix rsq = delx*delx + dely*dely + delz*delz; - if (rsq < constraints[i][rxnID].par[0] || rsq > constraints[i][rxnID].par[1]) return 0; + if (rsq < constraints[i][rxnID].par[0] || rsq > constraints[i][rxnID].par[1]) satisfied[i] = 0; } else if (constraints[i][rxnID].type == ANGLE) { get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); @@ -1833,7 +1843,7 @@ int FixBondReact::check_constraints() c /= r1*r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - if (acos(c) < constraints[i][rxnID].par[0] || acos(c) > constraints[i][rxnID].par[1]) return 0; + if (acos(c) < constraints[i][rxnID].par[0] || acos(c) > constraints[i][rxnID].par[1]) satisfied[i] = 0; } else if (constraints[i][rxnID].type == DIHEDRAL) { // phi calculation from dihedral style harmonic get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); @@ -1896,12 +1906,12 @@ int FixBondReact::check_constraints() } else { if (phi > constraints[i][rxnID].par[2] || phi < constraints[i][rxnID].par[3]) ANDgate = 1; } - if (ANDgate != 1) return 0; + if (ANDgate != 1) satisfied[i] = 0; } else if (constraints[i][rxnID].type == ARRHENIUS) { t = get_temperature(); prrhob = constraints[i][rxnID].par[1]*pow(t,constraints[i][rxnID].par[2])* exp(-constraints[i][rxnID].par[3]/(force->boltz*t)); - if (prrhob < rrhandom[(int) constraints[i][rxnID].par[0]]->uniform()) return 0; + if (prrhob < rrhandom[(int) constraints[i][rxnID].par[0]]->uniform()) satisfied[i] = 0; } else if (constraints[i][rxnID].type == RMSD) { // call superpose int iatom; @@ -1946,9 +1956,16 @@ int FixBondReact::check_constraints() } Superpose3D superposer(n2superpose); double rmsd = superposer.Superpose(xfrozen, xmobile); - if (rmsd > constraints[i][rxnID].par[0]) return 0; memory->destroy(xfrozen); memory->destroy(xmobile); + if (rmsd > constraints[i][rxnID].par[0]) satisfied[i] = 0; + } + } + + for (int i = 0; i < nconstraints[rxnID]; i++) { + if (satisfied[i] == 0) { + memory->destroy(satisfied); + return 0; } } @@ -1975,6 +1992,7 @@ int FixBondReact::check_constraints() } } + memory->destroy(satisfied); return 1; } @@ -3356,8 +3374,29 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) char **strargs,*ptr; memory->create(strargs,MAXCONARGS,MAXLINE,"bond/react:strargs"); char *constraint_type = new char[MAXLINE]; + strcpy(constraintstr[myrxn],"("); // string for boolean constraint logic for (int i = 0; i < nconstraints[myrxn]; i++) { readline(line); + if (ptr = strrchr(line,'(')) { // reverse char search + strncat(constraintstr[myrxn],line,ptr-line+1); + line = ptr + 1; + } + // 'C' indicates where to sub in next constraint + strcat(constraintstr[myrxn],"C"); + if (ptr = strchr(line,')')) { + strncat(constraintstr[myrxn],ptr,strrchr(line,')')-ptr+1); + } + if (ptr = strstr(line,"&&")) { + strcat(constraintstr[myrxn],"&&"); + *ptr = '\0'; + } else if (ptr = strstr(line,"||")) { + strcat(constraintstr[myrxn],"||"); + *ptr = '\0'; + } else if (i+1 < nconstraints[myrxn]){ + strcat(constraintstr[myrxn],"&&"); + } + if (ptr = strchr(line,')')) + *ptr = '\0'; sscanf(line,"%s",constraint_type); if (strcmp(constraint_type,"distance") == 0) { constraints[i][myrxn].type = DISTANCE; @@ -3411,6 +3450,7 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) } else error->one(FLERR,"Bond/react: Illegal constraint type in 'Constraints' section of map file"); } + strcat(constraintstr[myrxn],")"); // close boolean constraint logic string delete [] constraint_type; memory->destroy(strargs); } diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index ba768c131f..a66f57c2bc 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -69,6 +69,7 @@ class FixBondReact : public Fix { int *custom_charges_fragid; int *molecule_keyword; int *nconstraints; + char **constraintstr; int narrhenius; int **var_flag,**var_id; // for keyword values with variable inputs int status; @@ -198,8 +199,6 @@ class FixBondReact : public Fix { struct Constraint { int type; - int rxnID; - int op; int id[MAXCONIDS]; int idtype[MAXCONIDS]; double par[MAXCONPAR]; From 1e5611f776bb16325672007ab01683758272f4a6 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 20 Nov 2020 15:11:53 -0500 Subject: [PATCH 034/187] finally, add the logic eval --- src/USER-REACTION/fix_bond_react.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 1135d6b861..e4109dd253 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1962,11 +1962,16 @@ int FixBondReact::check_constraints() } } - for (int i = 0; i < nconstraints[rxnID]; i++) { - if (satisfied[i] == 0) { - memory->destroy(satisfied); - return 0; + if (nconstraints[rxnID] > 0) { + char evalstr[MAXLINE],*ptr,valstr; + strcpy(evalstr,constraintstr[rxnID]); + for (int i = 0; i < nconstraints[rxnID]; i++) { + sprintf(&valstr,"%d", satisfied[i]); + ptr = strchr(evalstr,'C'); + *ptr = valstr; } + double verdict = input->variable->evaluate_boolean(evalstr); + if (verdict == 0.0) return 0; } // let's also check chirality within 'check_constraint' From 64f7ea6c3827e9d254c54261ee4a1074814a5923 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 20 Nov 2020 15:46:26 -0500 Subject: [PATCH 035/187] docs for boolean constraint logic --- doc/src/fix_bond_react.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/src/fix_bond_react.rst b/doc/src/fix_bond_react.rst index 16bd4ecb71..33a443723b 100644 --- a/doc/src/fix_bond_react.rst +++ b/doc/src/fix_bond_react.rst @@ -457,6 +457,21 @@ example, the molecule fragment could consist of only the backbone atoms of a polymer chain. This constraint can be used to enforce a specific relative position and orientation between reacting molecules. +By default, all constraints must be satisfied for the reaction to +occur. In other words, constraints are evaluated as a series of +logical values using the logical AND operator "&&". More complex logic +can be achieved by explicitly adding "&&" or "||" after a given +constraint command. Logical operators must be placed after all +constraint parameters, on the same line as the constraint (one per +line). Similarly, parentheses can be used to group constraints. The +expression that results from concatenating all constraints should be a +valid logical expression that can be read by the :doc:`variable ` +command after converting each constraint to a logical value. Because +exactly one constraint is allowed per line, having a valid logical +expression implies that left parentheses "(" should only appear +before a constraint, and right parentheses ")" should only appear +after a constraint and before any logical operator. + Once a reaction site has been successfully identified, data structures within LAMMPS that store bond topology are updated to reflect the post-reacted molecule template. All force fields with fixed bonds, From bffd87a84fe5f32fba5360a7e5eb394c182e556d Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Mon, 23 Nov 2020 13:25:17 -0500 Subject: [PATCH 036/187] clarify docs --- doc/src/fix_bond_react.rst | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/doc/src/fix_bond_react.rst b/doc/src/fix_bond_react.rst index 33a443723b..15c0550ead 100644 --- a/doc/src/fix_bond_react.rst +++ b/doc/src/fix_bond_react.rst @@ -460,17 +460,19 @@ specific relative position and orientation between reacting molecules. By default, all constraints must be satisfied for the reaction to occur. In other words, constraints are evaluated as a series of logical values using the logical AND operator "&&". More complex logic -can be achieved by explicitly adding "&&" or "||" after a given -constraint command. Logical operators must be placed after all -constraint parameters, on the same line as the constraint (one per -line). Similarly, parentheses can be used to group constraints. The -expression that results from concatenating all constraints should be a -valid logical expression that can be read by the :doc:`variable ` -command after converting each constraint to a logical value. Because -exactly one constraint is allowed per line, having a valid logical -expression implies that left parentheses "(" should only appear -before a constraint, and right parentheses ")" should only appear -after a constraint and before any logical operator. +can be achieved by explicitly adding the logical AND operator "&&" or +the logical OR operator "||" after a given constraint command. If a +logical operator is specified after a constraint, it must be placed +after all constraint parameters, on the same line as the constraint +(one per line). Similarly, parentheses can be used to group +constraints. The expression that results from concatenating all +constraints should be a valid logical expression that can be read by +the :doc:`variable ` command after converting each +constraint to a logical value. Because exactly one constraint is +allowed per line, having a valid logical expression implies that left +parentheses "(" should only appear before a constraint, and right +parentheses ")" should only appear after a constraint and before any +logical operator. Once a reaction site has been successfully identified, data structures within LAMMPS that store bond topology are updated to reflect the From c332b5ff09a40e49d884a88b5337a316bac44fa9 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Tue, 24 Nov 2020 14:34:52 -0500 Subject: [PATCH 037/187] bugfix when no constraints --- src/USER-REACTION/fix_bond_react.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index e4109dd253..a1344fedf4 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -231,6 +231,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : stabilize_steps_flag[i] = 0; custom_charges_fragid[i] = -1; molecule_keyword[i] = OFF; + nconstraints[i] = 0; // set default limit duration to 60 timesteps limit_duration[i] = 60; reaction_count[i] = 0; From 90f00c01a4083254f1390568b2f3736eeb29adca Mon Sep 17 00:00:00 2001 From: Oliver Henrich Date: Thu, 3 Dec 2020 12:57:55 +0000 Subject: [PATCH 038/187] Introduced ellipsoid pointer in quaternion data access --- src/USER-CGDNA/bond_oxdna_fene.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna2_coaxstk.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna2_dh.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna_coaxstk.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna_excv.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna_hbond.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna_stk.cpp | 5 +++-- src/USER-CGDNA/pair_oxdna_xstk.cpp | 5 +++-- src/USER-CGDNA/pair_oxrna2_stk.cpp | 5 +++-- src/USER-CGDNA/pair_oxrna2_xstk.cpp | 5 +++-- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/USER-CGDNA/bond_oxdna_fene.cpp b/src/USER-CGDNA/bond_oxdna_fene.cpp index 522ea2a745..abff3804b8 100644 --- a/src/USER-CGDNA/bond_oxdna_fene.cpp +++ b/src/USER-CGDNA/bond_oxdna_fene.cpp @@ -173,6 +173,7 @@ void BondOxdnaFene::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int **bondlist = neighbor->bondlist; int nbondlist = neighbor->nbondlist; @@ -190,9 +191,9 @@ void BondOxdnaFene::compute(int eflag, int vflag) b = bondlist[in][0]; type = bondlist[in][2]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM-backbone site a and b diff --git a/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp b/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp index 273060612d..f0b3386478 100644 --- a/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp +++ b/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp @@ -133,6 +133,7 @@ void PairOxdna2Coaxstk::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -154,7 +155,7 @@ void PairOxdna2Coaxstk::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); // vector COM a - stacking site a @@ -178,7 +179,7 @@ void PairOxdna2Coaxstk::compute(int eflag, int vflag) btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM b - stacking site b diff --git a/src/USER-CGDNA/pair_oxdna2_dh.cpp b/src/USER-CGDNA/pair_oxdna2_dh.cpp index f210fe3b65..d877e0bf9a 100644 --- a/src/USER-CGDNA/pair_oxdna2_dh.cpp +++ b/src/USER-CGDNA/pair_oxdna2_dh.cpp @@ -102,6 +102,7 @@ void PairOxdna2Dh::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -120,7 +121,7 @@ void PairOxdna2Dh::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); // vector COM-backbone site a @@ -140,7 +141,7 @@ void PairOxdna2Dh::compute(int eflag, int vflag) b &= NEIGHMASK; btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM-backbone site b diff --git a/src/USER-CGDNA/pair_oxdna_coaxstk.cpp b/src/USER-CGDNA/pair_oxdna_coaxstk.cpp index 0a4a4f8ed8..c062bbfa99 100644 --- a/src/USER-CGDNA/pair_oxdna_coaxstk.cpp +++ b/src/USER-CGDNA/pair_oxdna_coaxstk.cpp @@ -145,6 +145,7 @@ void PairOxdnaCoaxstk::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -166,7 +167,7 @@ void PairOxdnaCoaxstk::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); // vector COM a - stacking site a @@ -190,7 +191,7 @@ void PairOxdnaCoaxstk::compute(int eflag, int vflag) btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM b - stacking site b diff --git a/src/USER-CGDNA/pair_oxdna_excv.cpp b/src/USER-CGDNA/pair_oxdna_excv.cpp index 0f5dc54354..e5f2a5cad5 100644 --- a/src/USER-CGDNA/pair_oxdna_excv.cpp +++ b/src/USER-CGDNA/pair_oxdna_excv.cpp @@ -134,6 +134,7 @@ void PairOxdnaExcv::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -152,7 +153,7 @@ void PairOxdnaExcv::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); // vector COM - backbone and base site a @@ -177,7 +178,7 @@ void PairOxdnaExcv::compute(int eflag, int vflag) btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM - backbone and base site b diff --git a/src/USER-CGDNA/pair_oxdna_hbond.cpp b/src/USER-CGDNA/pair_oxdna_hbond.cpp index 455c26f188..3e1d51ddf1 100644 --- a/src/USER-CGDNA/pair_oxdna_hbond.cpp +++ b/src/USER-CGDNA/pair_oxdna_hbond.cpp @@ -164,6 +164,7 @@ void PairOxdnaHbond::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -185,7 +186,7 @@ void PairOxdnaHbond::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); ra_chb[0] = d_chb*ax[0]; @@ -203,7 +204,7 @@ void PairOxdnaHbond::compute(int eflag, int vflag) btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); rb_chb[0] = d_chb*bx[0]; diff --git a/src/USER-CGDNA/pair_oxdna_stk.cpp b/src/USER-CGDNA/pair_oxdna_stk.cpp index 1a84003493..6aed2d854c 100644 --- a/src/USER-CGDNA/pair_oxdna_stk.cpp +++ b/src/USER-CGDNA/pair_oxdna_stk.cpp @@ -245,6 +245,7 @@ void PairOxdnaStk::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,in,atype,btype; @@ -262,9 +263,9 @@ void PairOxdnaStk::compute(int eflag, int vflag) a = bondlist[in][1]; b = bondlist[in][0]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM a - stacking site a diff --git a/src/USER-CGDNA/pair_oxdna_xstk.cpp b/src/USER-CGDNA/pair_oxdna_xstk.cpp index 76b67d0baa..c1b63ea2fa 100644 --- a/src/USER-CGDNA/pair_oxdna_xstk.cpp +++ b/src/USER-CGDNA/pair_oxdna_xstk.cpp @@ -142,6 +142,7 @@ void PairOxdnaXstk::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -163,7 +164,7 @@ void PairOxdnaXstk::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); ra_chb[0] = d_chb*ax[0]; @@ -181,7 +182,7 @@ void PairOxdnaXstk::compute(int eflag, int vflag) btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); rb_chb[0] = d_chb*bx[0]; diff --git a/src/USER-CGDNA/pair_oxrna2_stk.cpp b/src/USER-CGDNA/pair_oxrna2_stk.cpp index fdd1f863f4..33480aa380 100644 --- a/src/USER-CGDNA/pair_oxrna2_stk.cpp +++ b/src/USER-CGDNA/pair_oxrna2_stk.cpp @@ -262,6 +262,7 @@ void PairOxrna2Stk::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,in,atype,btype; @@ -279,9 +280,9 @@ void PairOxrna2Stk::compute(int eflag, int vflag) a = bondlist[in][1]; b = bondlist[in][0]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); // vector COM a - 3'-stacking site a diff --git a/src/USER-CGDNA/pair_oxrna2_xstk.cpp b/src/USER-CGDNA/pair_oxrna2_xstk.cpp index 81b8c92780..c3b97bfa9c 100644 --- a/src/USER-CGDNA/pair_oxrna2_xstk.cpp +++ b/src/USER-CGDNA/pair_oxrna2_xstk.cpp @@ -135,6 +135,7 @@ void PairOxrna2Xstk::compute(int eflag, int vflag) AtomVecEllipsoid *avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); AtomVecEllipsoid::Bonus *bonus = avec->bonus; + int *ellipsoid = atom->ellipsoid; int a,b,ia,ib,anum,bnum,atype,btype; @@ -156,7 +157,7 @@ void PairOxrna2Xstk::compute(int eflag, int vflag) a = alist[ia]; atype = type[a]; - qa=bonus[a].quat; + qa=bonus[ellipsoid[a]].quat; MathExtra::q_to_exyz(qa,ax,ay,az); ra_chb[0] = d_chb*ax[0]; @@ -174,7 +175,7 @@ void PairOxrna2Xstk::compute(int eflag, int vflag) btype = type[b]; - qb=bonus[b].quat; + qb=bonus[ellipsoid[b]].quat; MathExtra::q_to_exyz(qb,bx,by,bz); rb_chb[0] = d_chb*bx[0]; From 973382295b1439897e5869ff37cf5ff9915a9c54 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 16:47:27 -0700 Subject: [PATCH 039/187] Clean up file --- examples/mliappy/in.mliap.pytorch.Ta06A | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/examples/mliappy/in.mliap.pytorch.Ta06A b/examples/mliappy/in.mliap.pytorch.Ta06A index e44b4352e7..1d93d6a424 100644 --- a/examples/mliappy/in.mliap.pytorch.Ta06A +++ b/examples/mliappy/in.mliap.pytorch.Ta06A @@ -22,20 +22,6 @@ create_atoms 1 box mass 1 180.88 -python simple here """ -from __future__ import print_function - -def simple(): - foo = 0 - print("Inside simple function") - try: - foo += 1 - except Exception as e: - print("FOO error:", e) -""" - -python simple invoke - # choose potential include Ta06A.mliap.pytorch From 16f11f3421b4d14fb00e6faab7c3b5f7f4b10224 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 18:40:01 -0700 Subject: [PATCH 040/187] Moved all mliappy files in to src/MLIAP and examples/mliap --- .../{mliappy/README => mliap/README.pytorch} | 10 ++++----- .../{mliappy => mliap}/Ta06A.mliap.pytorch | 0 .../{mliappy => mliap}/convert_mliap_Ta06A.py | 6 +++--- .../{mliappy => mliap}/in.mliap.pytorch.Ta06A | 0 examples/{mliappy => mliap}/load_external.py | 0 examples/mliappy/Ta06A.mliap.descriptor | 21 ------------------- examples/mliappy/test_pylibs.py | 12 ----------- src/{MLIAPPY => MLIAP}/Install.sh | 0 src/MLIAP/README | 15 +++++++++++++ src/{MLIAPPY => MLIAP}/mliap_model_python.cpp | 0 src/{MLIAPPY => MLIAP}/mliap_model_python.h | 0 .../mliap_model_python_couple.pyx | 0 src/{MLIAPPY => MLIAP}/mliappy_pytorch.py | 0 src/MLIAPPY/Makefile.lammps | 1 - 14 files changed, 23 insertions(+), 42 deletions(-) rename examples/{mliappy/README => mliap/README.pytorch} (68%) rename examples/{mliappy => mliap}/Ta06A.mliap.pytorch (100%) rename examples/{mliappy => mliap}/convert_mliap_Ta06A.py (80%) rename examples/{mliappy => mliap}/in.mliap.pytorch.Ta06A (100%) rename examples/{mliappy => mliap}/load_external.py (100%) delete mode 100644 examples/mliappy/Ta06A.mliap.descriptor delete mode 100644 examples/mliappy/test_pylibs.py rename src/{MLIAPPY => MLIAP}/Install.sh (100%) rename src/{MLIAPPY => MLIAP}/mliap_model_python.cpp (100%) rename src/{MLIAPPY => MLIAP}/mliap_model_python.h (100%) rename src/{MLIAPPY => MLIAP}/mliap_model_python_couple.pyx (100%) rename src/{MLIAPPY => MLIAP}/mliappy_pytorch.py (100%) delete mode 100644 src/MLIAPPY/Makefile.lammps diff --git a/examples/mliappy/README b/examples/mliap/README.pytorch similarity index 68% rename from examples/mliappy/README rename to examples/mliap/README.pytorch index d61972afcf..642b39b842 100644 --- a/examples/mliappy/README +++ b/examples/mliap/README.pytorch @@ -1,17 +1,17 @@ -README for MLIAPPY Example +README for the PyTorch energy model example These examples run the Ta06 example from the MLIAP package, but using the python coupling. -1: Running models using LAMMPS executable: in.mliap.snap.Ta06A. +1: Running models using LAMMPS executable: in.mliap.pytorch.Ta06A To run this, first run convert_mliap_Ta06A.py, which will convert the Ta06 potential into a pytorch model. It will be saved as "Ta06A.mliap.pytorch.model.pkl". It will also copy the "mliappy_pytorch.py" file into the current working directory. mliappy_pytorch.py contains -class definitions suitable for wrapping an arbitrary energy model MLIAPPY. It must be available to python when -creating or unpicking a pytorch model for MLIAPPY. +class definitions suitable for wrapping an arbitrary PyTorch energy model. It must be available to python when +creating or unpicking a PyTorch energy model. -From that point you can run the example lmp -in in.mliap.snap.Ta06A -echo both +From that point you can run the example lmp -in in.mliap.pytorch.Ta06A -echo both 2: Running models from python with LAMMPS in library mode: load_external.py diff --git a/examples/mliappy/Ta06A.mliap.pytorch b/examples/mliap/Ta06A.mliap.pytorch similarity index 100% rename from examples/mliappy/Ta06A.mliap.pytorch rename to examples/mliap/Ta06A.mliap.pytorch diff --git a/examples/mliappy/convert_mliap_Ta06A.py b/examples/mliap/convert_mliap_Ta06A.py similarity index 80% rename from examples/mliappy/convert_mliap_Ta06A.py rename to examples/mliap/convert_mliap_Ta06A.py index 371139481d..6f10f8303c 100644 --- a/examples/mliappy/convert_mliap_Ta06A.py +++ b/examples/mliap/convert_mliap_Ta06A.py @@ -5,14 +5,14 @@ import pickle import os import shutil -shutil.copyfile('../../src/MLIAPPY/mliappy_pytorch.py','./mliappy_pytorch.py') +shutil.copyfile('../../src/MLIAP/mliappy_pytorch.py','./mliappy_pytorch.py') import mliappy_pytorch # Read coefficients -coeffs = np.genfromtxt("../mliap/Ta06A.mliap.model",skip_header=6) +coeffs = np.genfromtxt("Ta06A.mliap.model",skip_header=6) -# Write coefficiets to a pytorch linear model +# Write coefficients to a pytorch linear model bias = coeffs[0] weights = coeffs[1:] lin = torch.nn.Linear(weights.shape[0],1) diff --git a/examples/mliappy/in.mliap.pytorch.Ta06A b/examples/mliap/in.mliap.pytorch.Ta06A similarity index 100% rename from examples/mliappy/in.mliap.pytorch.Ta06A rename to examples/mliap/in.mliap.pytorch.Ta06A diff --git a/examples/mliappy/load_external.py b/examples/mliap/load_external.py similarity index 100% rename from examples/mliappy/load_external.py rename to examples/mliap/load_external.py diff --git a/examples/mliappy/Ta06A.mliap.descriptor b/examples/mliappy/Ta06A.mliap.descriptor deleted file mode 100644 index 481ebf7e44..0000000000 --- a/examples/mliappy/Ta06A.mliap.descriptor +++ /dev/null @@ -1,21 +0,0 @@ -# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - -# LAMMPS SNAP parameters for Ta_Cand06A - -# required -rcutfac 4.67637 -twojmax 6 - -# elements - -nelems 1 -elems Ta -radelems 0.5 -welems 1 - -# optional - -rfac0 0.99363 -rmin0 0 -bzeroflag 0 - diff --git a/examples/mliappy/test_pylibs.py b/examples/mliappy/test_pylibs.py deleted file mode 100644 index c5dcab75cf..0000000000 --- a/examples/mliappy/test_pylibs.py +++ /dev/null @@ -1,12 +0,0 @@ -import sysconfig, os,ctypes - -library = sysconfig.get_config_vars('INSTSONAME')[0] - -pylib = ctypes.CDLL(library) - -connected = pylib.Py_IsInitialized() - -if not connected: - print("FAILURE: This interpreter is not compatible with python-driven mliappy.") -else: - print("SUCCESS: This interpreter is compatible with python-driven MLIAPPY") diff --git a/src/MLIAPPY/Install.sh b/src/MLIAP/Install.sh similarity index 100% rename from src/MLIAPPY/Install.sh rename to src/MLIAP/Install.sh diff --git a/src/MLIAP/README b/src/MLIAP/README index 18ce3297e6..4cb197826e 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -28,3 +28,18 @@ reference potential. To see how this command can be used within a Python workflow to train machine-learning interatomic potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP>. + +*Additional instructions for compiling PyTorch energy models* + +The *MLIAPPY* extension written by Nick Lubers (LANL) +provides a coupling to PyTorch energy models. + +Before compiling LAMMPS with either make or cmake, you have +to run cythonize to create the coupling source files +in the src/MLIAP directory e.g. + +cd MLIAP +cythonize mliap_model_python_couple.pyx + +After that, install the MLIAP package with make or cmake +and build LAMMPS. diff --git a/src/MLIAPPY/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp similarity index 100% rename from src/MLIAPPY/mliap_model_python.cpp rename to src/MLIAP/mliap_model_python.cpp diff --git a/src/MLIAPPY/mliap_model_python.h b/src/MLIAP/mliap_model_python.h similarity index 100% rename from src/MLIAPPY/mliap_model_python.h rename to src/MLIAP/mliap_model_python.h diff --git a/src/MLIAPPY/mliap_model_python_couple.pyx b/src/MLIAP/mliap_model_python_couple.pyx similarity index 100% rename from src/MLIAPPY/mliap_model_python_couple.pyx rename to src/MLIAP/mliap_model_python_couple.pyx diff --git a/src/MLIAPPY/mliappy_pytorch.py b/src/MLIAP/mliappy_pytorch.py similarity index 100% rename from src/MLIAPPY/mliappy_pytorch.py rename to src/MLIAP/mliappy_pytorch.py diff --git a/src/MLIAPPY/Makefile.lammps b/src/MLIAPPY/Makefile.lammps deleted file mode 100644 index f9bf1abc13..0000000000 --- a/src/MLIAPPY/Makefile.lammps +++ /dev/null @@ -1 +0,0 @@ -#TODO From 3c34bdfdeddcee09134cb2be69c6377e02b7a798 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 19:04:53 -0700 Subject: [PATCH 041/187] Updated the build files --- cmake/CMakeLists.txt | 7 +++---- cmake/Modules/Packages/{MLIAPPY.cmake => MLIAP.cmake} | 2 +- src/Makefile | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) rename cmake/Modules/Packages/{MLIAPPY.cmake => MLIAP.cmake} (78%) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index fab10bfdef..a034cf6d17 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -105,7 +105,7 @@ install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR}) option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE - GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MLIAPPY MOLECULE PERI POEMS + GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE PERI POEMS QEQ REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB @@ -194,8 +194,7 @@ endif() # "hard" dependencies between packages resulting # in an error instead of skipping over files pkg_depends(MLIAP SNAP) -pkg_depends(MLIAPPY MLIAP) -pkg_depends(MLIAPPY PYTHON) +pkg_depends(MLIAP PYTHON) pkg_depends(MPIIO MPI) pkg_depends(USER-ATC MANYBODY) pkg_depends(USER-LB MPI) @@ -374,7 +373,7 @@ else() set(CUDA_REQUEST_PIC) endif() -foreach(PKG_WITH_INCL KSPACE PYTHON MLIAPPY VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM +foreach(PKG_WITH_INCL KSPACE PYTHON MLIAP VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS) if(PKG_${PKG_WITH_INCL}) include(Packages/${PKG_WITH_INCL}) diff --git a/cmake/Modules/Packages/MLIAPPY.cmake b/cmake/Modules/Packages/MLIAP.cmake similarity index 78% rename from cmake/Modules/Packages/MLIAPPY.cmake rename to cmake/Modules/Packages/MLIAP.cmake index 73ce83361c..e877d072b6 100644 --- a/cmake/Modules/Packages/MLIAPPY.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -1,3 +1,3 @@ -execute_process(COMMAND cythonize mliap_model_python_couple.pyx WORKING_DIRECTORY ../src/MLIAPPY) +execute_process(COMMAND cythonize mliap_model_python_couple.pyx WORKING_DIRECTORY ../src/MLIAP) target_compile_definitions(lammps PRIVATE -DLMP_MLIAPPY) diff --git a/src/Makefile b/src/Makefile index 8667f3f725..149dedd35b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -48,7 +48,7 @@ endif PACKAGE = asphere body class2 colloid compress coreshell dipole gpu \ granular kim kokkos kspace latte manybody mc message misc \ - mliap mliappy molecule mpiio mscg opt peri poems \ + mliap molecule mpiio mscg opt peri poems \ python qeq replica rigid shock snap spin srd voronoi PACKUSER = user-adios user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-colvars \ From 36a5e9d20edb35dc2e4bfa2a363ea6f4dcef8e38 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 19:36:52 -0700 Subject: [PATCH 042/187] Added some author credits --- src/MLIAP/compute_mliap.cpp | 4 ++++ src/MLIAP/mliap_data.cpp | 4 ++++ src/MLIAP/mliap_descriptor.cpp | 4 ++++ src/MLIAP/mliap_descriptor_snap.cpp | 4 ++++ src/MLIAP/mliap_model.cpp | 4 ++++ src/MLIAP/mliap_model_linear.cpp | 4 ++++ src/MLIAP/mliap_model_python.cpp | 4 ++++ src/MLIAP/mliap_model_quadratic.cpp | 4 ++++ src/MLIAP/mliappy_pytorch.py | 17 +++++++++++++++++ src/MLIAP/pair_mliap.cpp | 4 ++++ 10 files changed, 53 insertions(+) diff --git a/src/MLIAP/compute_mliap.cpp b/src/MLIAP/compute_mliap.cpp index 64753fe64f..72fb63ecda 100644 --- a/src/MLIAP/compute_mliap.cpp +++ b/src/MLIAP/compute_mliap.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include #include "mliap_data.h" diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 3ada98e8c0..2559f5330d 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "mliap_data.h" #include "atom.h" diff --git a/src/MLIAP/mliap_descriptor.cpp b/src/MLIAP/mliap_descriptor.cpp index b3e0cebd2e..ac168dc94b 100644 --- a/src/MLIAP/mliap_descriptor.cpp +++ b/src/MLIAP/mliap_descriptor.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "mliap_descriptor.h" using namespace LAMMPS_NS; diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp index cfbc51cb5c..2cb88de6b4 100644 --- a/src/MLIAP/mliap_descriptor_snap.cpp +++ b/src/MLIAP/mliap_descriptor_snap.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "mliap_descriptor_snap.h" #include "atom.h" diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index a4f5cdc86c..aa198e6085 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "mliap_model.h" #include "comm.h" diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp index 428d163166..3c8f9aa39a 100644 --- a/src/MLIAP/mliap_model_linear.cpp +++ b/src/MLIAP/mliap_model_linear.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "mliap_model_linear.h" #include "pair_mliap.h" #include "mliap_data.h" diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp index 1ac61f08b0..2aa588ff32 100644 --- a/src/MLIAP/mliap_model_python.cpp +++ b/src/MLIAP/mliap_model_python.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Nicholas Lubbers (LANL) +------------------------------------------------------------------------- */ + #include #include "mliap_model_python.h" #include "mliap_model_python_couple.h" diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp index 222f6ad0ae..915ec30435 100644 --- a/src/MLIAP/mliap_model_quadratic.cpp +++ b/src/MLIAP/mliap_model_quadratic.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "mliap_model_quadratic.h" #include "pair_mliap.h" #include "mliap_data.h" diff --git a/src/MLIAP/mliappy_pytorch.py b/src/MLIAP/mliappy_pytorch.py index 5294344c10..ff80720ffa 100644 --- a/src/MLIAP/mliappy_pytorch.py +++ b/src/MLIAP/mliappy_pytorch.py @@ -1,3 +1,20 @@ +# ---------------------------------------------------------------------- +# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator +# http://lammps.sandia.gov, Sandia National Laboratories +# Steve Plimpton, sjplimp@sandia.gov +# +# Copyright (2003) Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains +# certain rights in this software. This software is distributed under +# the GNU General Public License. +# +# See the README file in the top-level LAMMPS directory. +# ------------------------------------------------------------------------- + +# ---------------------------------------------------------------------- +# Contributing author: Nicholas Lubbers (LANL) +# ------------------------------------------------------------------------- + import numpy as np import torch diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index 7a2d5b14b5..5c0474d2ca 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #include "pair_mliap.h" #include "mliap_data.h" From 05bd2c5375b93ca59c5f1e0f4fe774e13c44d27f Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 19:37:07 -0700 Subject: [PATCH 043/187] Added some author credits --- doc/src/Packages_details.rst | 48 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index f8e18dafbc..ebbd6dd0b4 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -45,7 +45,6 @@ page gives those details. * :ref:`MESSAGE ` * :ref:`MISC ` * :ref:`MLIAP ` - * :ref:`MLIAPPY ` * :ref:`MOLECULE ` * :ref:`MPIIO ` * :ref:`MSCG ` @@ -663,50 +662,29 @@ MLIAP package **Contents:** -A general interface for machine-learning interatomic potentials. +A general interface for machine-learning interatomic potentials, including PyTorch. **Install:** -To use this package, also the :ref:`SNAP package ` needs to be installed. +To use this package, also the :ref:`SNAP package ` and +:ref:`PYTHON package ` packages need to be installed. +The version of python must be >3.5. -**Author:** Aidan Thompson (Sandia). +**Author:** Aidan Thompson (Sandia), Nicholas Lubbers (LANL). **Supporting info:** * src/MLIAP: filenames -> commands -* :doc:`pair_style mliap ` -* examples/mliap - ----------- - -.. _PKG-MLIAPPY: - -MLIAPPY package -------------- - -**Contents:** - -Extension to the MLIAP package for coupling with python models. - -**Install:** - -To use this package, also the :ref:`MLIAP package ` needs to be installed. -To use this package, also the :ref:`PYTHON package ` needs to be installed. -The version of python must be >3.5. - -The python interpreter linked to LAMMPS will need cython and numpy installed. -The examples build models with pytorch, which would thus need to be installed. - -This package includes more options for the mliap compute and pair style. - -**Author:** Nicholas Lubbers (LANL). - -**Supporting info:** - -* src/MLIAPPY: filenames -> commands * src/MLIAPPY/README * :doc:`pair_style mliap ` -* examples/mliappy (see README) +* examples/mliap (see README) + +When compiled with the LMP_MLIAPPY option, this package +includes an extension for coupling with python models, incuding PyTorch + +The python interpreter linked to LAMMPS will need cython and numpy installed. +The examples build models with PyTorch, which would thus need to be installed. + ---------- .. _PKG-MOLECULE: From d1422aa1097ed2ea6f4a20d34912e18a3b958b33 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 3 Dec 2020 19:46:19 -0700 Subject: [PATCH 044/187] Removed MLIAPPY package from docs --- doc/src/Packages_details.rst | 4 ++-- doc/src/Packages_standard.rst | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index ebbd6dd0b4..e04013915f 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -675,11 +675,11 @@ The version of python must be >3.5. **Supporting info:** * src/MLIAP: filenames -> commands -* src/MLIAPPY/README +* src/MLIAP/README * :doc:`pair_style mliap ` * examples/mliap (see README) -When compiled with the LMP_MLIAPPY option, this package +When compiled with the -DLMP_MLIAPPY flag, this package includes an extension for coupling with python models, incuding PyTorch The python interpreter linked to LAMMPS will need cython and numpy installed. diff --git a/doc/src/Packages_standard.rst b/doc/src/Packages_standard.rst index 800fd3c501..ab9be69ab3 100644 --- a/doc/src/Packages_standard.rst +++ b/doc/src/Packages_standard.rst @@ -61,8 +61,6 @@ package: +----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ | :ref:`MLIAP ` | multiple machine learning potentials | :doc:`pair_style mliap ` | mliap | no | +----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ -| :ref:`MLIAPPY ` | enable python ML models for mliap | :doc:`pair_style mliap ` | mliap | no | -+----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ | :ref:`MOLECULE ` | molecular system force fields | :doc:`Howto bioFF ` | peptide | no | +----------------------------------+--------------------------------------+----------------------------------------------------+------------------------------------------------------+---------+ | :ref:`MPIIO ` | MPI parallel I/O dump and restart | :doc:`dump ` | n/a | no | From 851f0775f1f9678fc97e2e7c912544ae563df4d0 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 4 Dec 2020 11:59:01 -0700 Subject: [PATCH 045/187] Fixed spelling errors --- doc/src/Packages_details.rst | 15 ++++++------ doc/src/compute_mliap.rst | 18 +++++++------- doc/src/pair_mliap.rst | 26 ++++++++++----------- doc/utils/sphinx-config/false_positives.txt | 1 + 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index e04013915f..3ed5cabe37 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -666,9 +666,10 @@ A general interface for machine-learning interatomic potentials, including PyTor **Install:** -To use this package, also the :ref:`SNAP package ` and -:ref:`PYTHON package ` packages need to be installed. -The version of python must be >3.5. +To use this package, also the :ref:`SNAP package ` +package needs to be installed. If building the *mliappy* model, +use -DLMP_MLIAPPY and the :ref:`PYTHON package ` +package needs to be installed. The version of python must be >3.5. **Author:** Aidan Thompson (Sandia), Nicholas Lubbers (LANL). @@ -677,12 +678,12 @@ The version of python must be >3.5. * src/MLIAP: filenames -> commands * src/MLIAP/README * :doc:`pair_style mliap ` +* :doc:`compute_style mliap ` * examples/mliap (see README) -When compiled with the -DLMP_MLIAPPY flag, this package -includes an extension for coupling with python models, incuding PyTorch - -The python interpreter linked to LAMMPS will need cython and numpy installed. +When built with the *mliappy* model using -DLMP_MLIAPPY, this package +includes an extension for coupling with python models, including PyTorch. +In this case, the python interpreter linked to LAMMPS will need cython and numpy installed. The examples build models with PyTorch, which would thus need to be installed. ---------- diff --git a/doc/src/compute_mliap.rst b/doc/src/compute_mliap.rst index e4e6603cdc..66bf868e0d 100644 --- a/doc/src/compute_mliap.rst +++ b/doc/src/compute_mliap.rst @@ -56,14 +56,15 @@ and it is also straightforward to add new descriptor styles. The compute *mliap* command must be followed by two keywords *model* and *descriptor* in either order. -The *model* keyword is followed by a model style, currently limited to -either *linear* or *quadratic*. The *mliappy* model is only available +The *model* keyword is followed by the model style (*linear*, *quadratic* or *mliappy*). +The *mliappy* model is only available if lammps is built with MLIAPPY package. The *descriptor* keyword is followed by a descriptor style, and additional arguments. -Currently the only descriptor style is *sna*, indicating the bispectrum component -descriptors used by the Spectral Neighbor Analysis Potential (SNAP) potentials of -:doc:`pair_style snap `. +The compute currently supports just one descriptor style, but it is +is straightforward to add new descriptor styles. +The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, +including the linear, quadratic, and chem variants. A single additional argument specifies the descriptor filename containing the parameters and setting used by the SNAP descriptor. The descriptor filename usually ends in the *.mliap.descriptor* extension. @@ -163,13 +164,12 @@ potentials, see the examples in `FitSNAP `_. Restrictions """""""""""" -This compute is part of the MLIAP package. It is only enabled if -LAMMPS was built with that package. In addition, building LAMMPS with the MLIAP package +This compute is part of the MLIAP package. It is only enabled if LAMMPS +was built with that package. In addition, building LAMMPS with the MLIAP package requires building LAMMPS with the SNAP package. +The *mliappy* model requires building LAMMPS with the PYTHON package. See the :doc:`Build package ` doc page for more info. -Python models such as neural networks can be used if the MLIAPPY package is built. - Related commands """""""""""""""" diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index aeba2d9fd2..4c1845d514 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -40,13 +40,15 @@ definitions of the interatomic potential functional form (*model*) and the geometric quantities that characterize the atomic positions (*descriptor*). By defining *model* and *descriptor* separately, it is possible to use many different models with a given descriptor, -or many different descriptors with a given model. Currently, the pair_style -supports just two models, *linear* and *quadratic*, -and one descriptor, *sna*, the SNAP descriptor used by :doc:`pair_style snap `, including the linear, quadratic, -and chem variants. With the MLIAPPY package installed, the *mliappy* model -is available which can be used to couple python models such as neural network -energy models. -It is also straightforward to add new descriptor styles. +or many different descriptors with a given model. The +pair style currently supports just one descriptor style, but it is +is straightforward to add new descriptor styles. +The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, +including the linear, quadratic, and chem variants. +The available models are *linear*, *quadratic*, and *mliappy*. +The *mliappy* style can be used to couple python models, +e.g. PyTorch neural network energy models, and requires building +LAMMPS with the PYTHON package (see below). In order to train a model, it is useful to know the gradient or derivative of energy, force, and stress w.r.t. model parameters. This information can be accessed using the related :doc:`compute mliap ` command. @@ -60,9 +62,8 @@ that specify the mapping of MLIAP element names to LAMMPS atom types, where N is the number of LAMMPS atom types. -The *model* keyword is followed by a model style, currently limited to -either *linear* or *quadratic*. In both cases, -this is followed by a single argument specifying the model filename containing the +The *model* keyword is followed by the model style. This is followed +by a single argument specifying the model filename containing the parameters for a set of elements. The model filename usually ends in the *.mliap.model* extension. It may contain parameters for many elements. The only requirement is that it @@ -139,13 +140,12 @@ This pair style can only be used via the *pair* keyword of the Restrictions """""""""""" -This style is part of the MLIAP package. It is only enabled if LAMMPS +This pair style is part of the MLIAP package. It is only enabled if LAMMPS was built with that package. In addition, building LAMMPS with the MLIAP package requires building LAMMPS with the SNAP package. +The *mliappy* model requires building LAMMPS with the PYTHON package. See the :doc:`Build package ` doc page for more info. -Python models such as neural networks can be used if the MLIAPPY package is built. - Related commands """""""""""""""" diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 3fd204ceb8..ca1e0adb34 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -557,6 +557,7 @@ Cygwin cylindrically Cyrot cyrstals +cython Daivis Dammak dampflag From 2654aca6588c2ba4bf958551637d9615f720b1d5 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 4 Dec 2020 14:04:35 -0700 Subject: [PATCH 046/187] Added blessed examples --- examples/mliap/in.mliap.pytorch.Ta06A | 2 +- .../log.04Dec20.mliap.pytorch.Ta06A.g++.1 | 157 ++++++++++++++++++ .../log.04Dec20.mliap.pytorch.Ta06A.g++.4 | 157 ++++++++++++++++++ ...oad_external.py => mliap.pytorch.Ta06A.py} | 26 +-- 4 files changed, 329 insertions(+), 13 deletions(-) create mode 100644 examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 create mode 100644 examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 rename examples/mliap/{load_external.py => mliap.pytorch.Ta06A.py} (81%) diff --git a/examples/mliap/in.mliap.pytorch.Ta06A b/examples/mliap/in.mliap.pytorch.Ta06A index 1d93d6a424..59cdcc8c81 100644 --- a/examples/mliap/in.mliap.pytorch.Ta06A +++ b/examples/mliap/in.mliap.pytorch.Ta06A @@ -1,4 +1,4 @@ -# Demonstrate MLIAP interface to linear SNAP potential +# Demonstrate MLIAP/PyTorch interface to linear SNAP potential # Initialize simulation diff --git a/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 new file mode 100644 index 0000000000..f56a79650e --- /dev/null +++ b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 @@ -0,0 +1,157 @@ +LAMMPS (30 Nov 2020) + using 48 OpenMP thread(s) per MPI task +# Demonstrate MLIAP/PyTorch interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.316 +Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.002 seconds + +mass 1 180.88 + +# choose potential + +include Ta06A.mliap.pytorch +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +Loading python model complete. +Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 +SNAP keyword rcutfac 4.67637 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Ta +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff 1 1 zbl 73 ${zblz} +pair_coeff 1 1 zbl 73 73 +pair_coeff * * mliap Ta + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8 + ghost atom cutoff = 5.8 + binsize = 2.9, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 159.8 | 159.8 | 159.8 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 + 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 + 20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527 + 30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131 + 40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684 + 50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899 + 60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757 + 70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351 + 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 + 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 + 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 +Loop time of 2.00236 on 48 procs for 100 steps with 128 atoms + +Performance: 2.157 ns/day, 11.124 hours/ns, 49.941 timesteps/s +288.8% CPU use with 1 MPI tasks x 48 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.9998 | 1.9998 | 1.9998 | 0.0 | 99.87 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0011814 | 0.0011814 | 0.0011814 | 0.0 | 0.06 +Output | 0.00059724 | 0.00059724 | 0.00059724 | 0.0 | 0.03 +Modify | 0.00047352 | 0.00047352 | 0.00047352 | 0.0 | 0.02 +Other | | 0.0003468 | | | 0.02 + +Nlocal: 128.000 ave 128 max 128 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 727.000 ave 727 max 727 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 3712.00 ave 3712 max 3712 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 7424.00 ave 7424 max 7424 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:03 diff --git a/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 new file mode 100644 index 0000000000..7f1bc818d1 --- /dev/null +++ b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 @@ -0,0 +1,157 @@ +LAMMPS (30 Nov 2020) + using 48 OpenMP thread(s) per MPI task +# Demonstrate MLIAP/PyTorch interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.316 +Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.002 seconds + +mass 1 180.88 + +# choose potential + +include Ta06A.mliap.pytorch +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +Loading python model complete. +Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 +SNAP keyword rcutfac 4.67637 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Ta +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff 1 1 zbl 73 ${zblz} +pair_coeff 1 1 zbl 73 73 +pair_coeff * * mliap Ta + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8 + ghost atom cutoff = 5.8 + binsize = 2.9, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 159.7 | 159.7 | 159.7 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 + 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 + 20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527 + 30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131 + 40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684 + 50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899 + 60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757 + 70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351 + 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 + 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 + 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 +Loop time of 0.562802 on 192 procs for 100 steps with 128 atoms + +Performance: 7.676 ns/day, 3.127 hours/ns, 177.682 timesteps/s +99.7% CPU use with 4 MPI tasks x 48 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.53583 | 0.54622 | 0.55401 | 0.9 | 97.05 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0071442 | 0.01491 | 0.025289 | 5.4 | 2.65 +Output | 0.00092525 | 0.00095771 | 0.0010166 | 0.0 | 0.17 +Modify | 0.00014479 | 0.00015043 | 0.00015893 | 0.0 | 0.03 +Other | | 0.0005624 | | | 0.10 + +Nlocal: 32.0000 ave 32 max 32 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 431.000 ave 431 max 431 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 928.000 ave 928 max 928 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 1856.00 ave 1856 max 1856 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:02 diff --git a/examples/mliap/load_external.py b/examples/mliap/mliap.pytorch.Ta06A.py similarity index 81% rename from examples/mliap/load_external.py rename to examples/mliap/mliap.pytorch.Ta06A.py index 606ee8f940..5f3ecaadc8 100644 --- a/examples/mliap/load_external.py +++ b/examples/mliap/mliap.pytorch.Ta06A.py @@ -1,12 +1,11 @@ - # Demonstrate how to load a model from the python side. -# This is essentially the same as in.mliap.pytorch.Ta06A-- +# This is essentially the same as in.mliap.pytorch.Ta06A # except that python is the driving program, and lammps # is in library mode. before_loading =\ """ - # Demonstrate MLIAP interface to linear SNAP potential + # Demonstrate MLIAP/PyTorch interface to linear SNAP potential # Initialize simulation @@ -78,27 +77,30 @@ after_loading =\ run ${nsteps} """ - import lammps lmp = lammps.lammps(cmdargs=['-echo','both']) -# This commmand must be run before the MLIAP object is declared in lammps. + +# this commmand must be run before the MLIAP object is declared in lammps. + lmp.mliappy.activate() +# setup the simulation and declare an empty model +# by specifying model filename as "LATER" + lmp.commands_string(before_loading) -# Now the model is declared, but empty -- because the model filename -# was given as "LATER". +# define the PyTorch model by loading a pkl file. +# this could also be done in other ways. -# Load the python module, construct on the fly, do whatever, here: import pickle with open('Ta06A.mliap.pytorch.model.pkl','rb') as pfile: model = pickle.load(pfile) -# Now that you have a model, connect it to the pairstyle +# connect the PyTorch model to the mliap pair style + lmp.mliappy.load_model(model) -# Proceed with whatever calculations you like. +# run the simulation with the mliap pair style + lmp.commands_string(after_loading) - - From ed7775f083f19b406c174875c7ca0f517a4702d5 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 4 Dec 2020 14:48:02 -0700 Subject: [PATCH 047/187] Added blessed log files --- examples/mliap/README.pytorch | 25 ++++-- examples/mliap/mliap.pytorch.Ta06A.py | 106 -------------------------- examples/mliap/mliap_pytorch_Ta06A.py | 106 ++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 114 deletions(-) delete mode 100644 examples/mliap/mliap.pytorch.Ta06A.py create mode 100644 examples/mliap/mliap_pytorch_Ta06A.py diff --git a/examples/mliap/README.pytorch b/examples/mliap/README.pytorch index 642b39b842..7f511168a7 100644 --- a/examples/mliap/README.pytorch +++ b/examples/mliap/README.pytorch @@ -1,6 +1,7 @@ README for the PyTorch energy model example -These examples run the Ta06 example from the MLIAP package, but using the python coupling. +These two examples run the Ta06 example from the MLIAP package, but using the python coupling. +The differ only in how the coupling is constructed. 1: Running models using LAMMPS executable: in.mliap.pytorch.Ta06A @@ -13,14 +14,22 @@ creating or unpicking a PyTorch energy model. From that point you can run the example lmp -in in.mliap.pytorch.Ta06A -echo both -2: Running models from python with LAMMPS in library mode: load_external.py +2: Running models from python with LAMMPS in library mode: mliap_pytorch_Ta06A.py Before testing this, ensure that the first example (using LAMMPS executable) works. +Also, not all python installations support this mode of operation. +It requires that the Python interpreter be initialized. +To check this for your Python library, +run the Py_IsInitialized() method. +If the return value is True, you should be able to run the example, +as follows: -Not all python installations support this mode of operation. -Too test if your interpreter supports this, run: -`python test_pylibs.py` - and examine the output. +`python mliap_pytorch_Ta06A.py` + +or + +`mpirun -np 4 python mliap_pytorch_Ta06A.py` + +The resultant log.lammps output should be identical to that generated +by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A -If this succeeds, you should be able to run: -`python load_external.py` diff --git a/examples/mliap/mliap.pytorch.Ta06A.py b/examples/mliap/mliap.pytorch.Ta06A.py deleted file mode 100644 index 5f3ecaadc8..0000000000 --- a/examples/mliap/mliap.pytorch.Ta06A.py +++ /dev/null @@ -1,106 +0,0 @@ -# Demonstrate how to load a model from the python side. -# This is essentially the same as in.mliap.pytorch.Ta06A -# except that python is the driving program, and lammps -# is in library mode. - -before_loading =\ -""" - # Demonstrate MLIAP/PyTorch interface to linear SNAP potential - - # Initialize simulation - - variable nsteps index 100 - variable nrep equal 4 - variable a equal 3.316 - units metal - - # generate the box and atom positions using a BCC lattice - - variable nx equal ${nrep} - variable ny equal ${nrep} - variable nz equal ${nrep} - - boundary p p p - - lattice bcc $a - region box block 0 ${nx} 0 ${ny} 0 ${nz} - create_box 1 box - create_atoms 1 box - - mass 1 180.88 - - # choose potential - # DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - - # Definition of SNAP potential Ta_Cand06A - # Assumes 1 LAMMPS atom type - - variable zblcutinner equal 4 - variable zblcutouter equal 4.8 - variable zblz equal 73 - - # Specify hybrid with SNAP, ZBL - - pair_style hybrid/overlay & - zbl ${zblcutinner} ${zblcutouter} & - mliap model mliappy LATER & - descriptor sna Ta06A.mliap.descriptor - pair_coeff 1 1 zbl ${zblz} ${zblz} - pair_coeff * * mliap Ta -""" -after_loading =\ -""" - - # Setup output - - compute eatom all pe/atom - compute energy all reduce sum c_eatom - - compute satom all stress/atom NULL - compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] - variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) - - thermo_style custom step temp epair c_energy etotal press v_press - thermo 10 - thermo_modify norm yes - - # Set up NVE run - - timestep 0.5e-3 - neighbor 1.0 bin - neigh_modify once no every 1 delay 0 check yes - - # Run MD - - velocity all create 300.0 4928459 loop geom - fix 1 all nve - run ${nsteps} -""" - -import lammps - -lmp = lammps.lammps(cmdargs=['-echo','both']) - -# this commmand must be run before the MLIAP object is declared in lammps. - -lmp.mliappy.activate() - -# setup the simulation and declare an empty model -# by specifying model filename as "LATER" - -lmp.commands_string(before_loading) - -# define the PyTorch model by loading a pkl file. -# this could also be done in other ways. - -import pickle -with open('Ta06A.mliap.pytorch.model.pkl','rb') as pfile: - model = pickle.load(pfile) - -# connect the PyTorch model to the mliap pair style - -lmp.mliappy.load_model(model) - -# run the simulation with the mliap pair style - -lmp.commands_string(after_loading) diff --git a/examples/mliap/mliap_pytorch_Ta06A.py b/examples/mliap/mliap_pytorch_Ta06A.py new file mode 100644 index 0000000000..71c89f112e --- /dev/null +++ b/examples/mliap/mliap_pytorch_Ta06A.py @@ -0,0 +1,106 @@ +# Demonstrate how to load a model from the python side. +# This is essentially the same as in.mliap.pytorch.Ta06A +# except that python is the driving program, and lammps +# is in library mode. + +before_loading =\ +"""# Demonstrate MLIAP/PyTorch interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable ny equal ${nrep} +variable nz equal ${nrep} + +boundary p p p + +lattice bcc $a +region box block 0 ${nx} 0 ${ny} 0 ${nz} +create_box 1 box +create_atoms 1 box + +mass 1 180.88 + +# choose potential + +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay & +zbl ${zblcutinner} ${zblcutouter} & +mliap model mliappy LATER & +descriptor sna Ta06A.mliap.descriptor +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff * * mliap Ta +""" +after_loading =\ +""" + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +""" + +import lammps + +lmp = lammps.lammps(cmdargs=['-echo','both']) + +# this commmand must be run before the MLIAP object is declared in lammps. + +lmp.mliappy.activate() + +# setup the simulation and declare an empty model +# by specifying model filename as "LATER" + +lmp.commands_string(before_loading) + +# define the PyTorch model by loading a pkl file. +# this could also be done in other ways. + +import pickle +with open('Ta06A.mliap.pytorch.model.pkl','rb') as pfile: + model = pickle.load(pfile) + +# connect the PyTorch model to the mliap pair style + +lmp.mliappy.load_model(model) + +# run the simulation with the mliap pair style + +lmp.commands_string(after_loading) From 3ed41295cdf81b67828c46485e6ca12bf080101b Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 4 Dec 2020 15:01:39 -0700 Subject: [PATCH 048/187] Tweaked build instructions --- src/MLIAP/Install.sh | 6 +----- src/MLIAP/README | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/MLIAP/Install.sh b/src/MLIAP/Install.sh index 8fccbc2a9c..bd7f7d23a8 100755 --- a/src/MLIAP/Install.sh +++ b/src/MLIAP/Install.sh @@ -26,10 +26,6 @@ action () { fi } -# force rebuild of files using python header - -touch ../lmppython.h - # all package files with no dependencies for file in *.cpp *.h; do @@ -47,7 +43,7 @@ if (test $1 = 1) then elif (test $1 = 0) then if (test -e ../Makefile.package) then - sed -i -e 's/[^ \t]*MLIAPPY[^ \t]* //g' ../Makefile.package + sed -i -e 's/[^ \t]*-DLMP_MLIAPPY[^ \t]* //g' ../Makefile.package fi fi diff --git a/src/MLIAP/README b/src/MLIAP/README index 4cb197826e..d94a1bac16 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -31,14 +31,14 @@ potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP>. *Additional instructions for compiling PyTorch energy models* -The *MLIAPPY* extension written by Nick Lubers (LANL) +The *MLIAPPY* extension written by Nick Lubbers (LANL) provides a coupling to PyTorch energy models. Before compiling LAMMPS with either make or cmake, you have to run cythonize to create the coupling source files in the src/MLIAP directory e.g. -cd MLIAP +cd src/MLIAP cythonize mliap_model_python_couple.pyx After that, install the MLIAP package with make or cmake From 36c2947de725d3e4fce6c961582010506959d445 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 00:31:50 -0500 Subject: [PATCH 049/187] silence compiler warnings --- src/COMPRESS/zstd_file_writer.cpp | 2 +- src/USER-MISC/angle_gaussian.cpp | 3 +-- src/USER-MISC/fix_electron_stopping_fit.cpp | 10 ++++----- src/USER-PLUMED/fix_plumed.cpp | 2 +- src/USER-REACTION/fix_bond_react.cpp | 24 +++++++++++---------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index e99dbf0181..2631faa4ad 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -79,7 +79,7 @@ size_t ZstdFileWriter::write(const void * buffer, size_t length) do { ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; - size_t const remaining = ZSTD_compressStream2(cctx, &output, &input, mode); + ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while(input.pos < input.size); diff --git a/src/USER-MISC/angle_gaussian.cpp b/src/USER-MISC/angle_gaussian.cpp index 640be38433..554b19cfb5 100644 --- a/src/USER-MISC/angle_gaussian.cpp +++ b/src/USER-MISC/angle_gaussian.cpp @@ -62,7 +62,7 @@ void AngleGaussian::compute(int eflag, int vflag) int i1,i2,i3,n,type; double delx1,dely1,delz1,delx2,dely2,delz2; double eangle,f1[3],f3[3]; - double dtheta,tk; + double dtheta; double rsq1,rsq2,r1,r2,c,s,a,a11,a12,a22; double prefactor, exponent, g_i, sum_g_i, sum_numerator; @@ -331,7 +331,6 @@ double AngleGaussian::single(int type, int i1, int i2, int i3) double theta = acos(c) ; double sum_g_i = 0.0; - double sum_numerator = 0.0; for (int i = 0; i < nterms[type]; i++) { double dtheta = theta - theta0[type][i]; double prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); diff --git a/src/USER-MISC/fix_electron_stopping_fit.cpp b/src/USER-MISC/fix_electron_stopping_fit.cpp index e6fa0f2b9b..2d9034aaef 100644 --- a/src/USER-MISC/fix_electron_stopping_fit.cpp +++ b/src/USER-MISC/fix_electron_stopping_fit.cpp @@ -62,9 +62,9 @@ static const char cite_fix_electron_stopping_fit_c[] = // --------------------------------------------------------------------- FixElectronStoppingFit::FixElectronStoppingFit(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp,narg,arg), energy_coh_in(nullptr), drag_fac_in_1(nullptr), - drag_fac_in_2(nullptr), drag_fac_1(nullptr), drag_fac_2(nullptr), - v_min_sq(nullptr), v_max_sq(nullptr) + Fix(lmp,narg,arg), energy_coh_in(nullptr), v_min_sq(nullptr), v_max_sq(nullptr), + drag_fac_in_1(nullptr), drag_fac_in_2(nullptr), + drag_fac_1(nullptr), drag_fac_2(nullptr) { if (lmp->citeme) lmp->citeme->add(cite_fix_electron_stopping_fit_c); @@ -151,7 +151,7 @@ void FixElectronStoppingFit::setup(int vflag) // --------------------------------------------------------------------- -void FixElectronStoppingFit::post_force(int vflag) +void FixElectronStoppingFit::post_force(int /*vflag*/) { double **v = atom->v; double **f = atom->f; @@ -192,7 +192,7 @@ void FixElectronStoppingFit::post_force(int vflag) // --------------------------------------------------------------------- -void FixElectronStoppingFit::post_force_respa(int vflag, int ilevel, int iloop) +void FixElectronStoppingFit::post_force_respa(int vflag, int ilevel, int /*iloop*/) { if (ilevel == nlevels_respa-1) post_force(vflag); }; diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index b1397b8eeb..ed7f05f2ae 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -76,7 +76,7 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : // Check API version - int api_version; + int api_version=0; p->cmd("getApiVersion",&api_version); if ((api_version < 5) || (api_version > 7)) error->all(FLERR,"Incompatible API version for PLUMED in fix plumed. " diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 29a99db75f..efadec1b91 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -761,15 +761,15 @@ void FixBondReact::post_constructor() void FixBondReact::init() { - if (strstr(update->integrate_style,"respa")) + if (utils::strmatch(update->integrate_style,"^respa")) nlevels_respa = ((Respa *) update->integrate)->nlevels; - // check cutoff for iatomtype,jatomtype - for (int i = 0; i < nreacts; i++) { - if (closeneigh[i] == -1) // indicates will search for non-bonded bonding atoms - if (force->pair == nullptr || cutsq[i][1] > force->pair->cutsq[iatomtype[i]][jatomtype[i]]) - error->all(FLERR,"Bond/react: Fix bond/react cutoff is longer than pairwise cutoff"); - } + // check cutoff for iatomtype,jatomtype + for (int i = 0; i < nreacts; i++) { + if (closeneigh[i] == -1) // indicates will search for non-bonded bonding atoms + if (force->pair == nullptr || cutsq[i][1] > force->pair->cutsq[iatomtype[i]][jatomtype[i]]) + error->all(FLERR,"Bond/react: Fix bond/react cutoff is longer than pairwise cutoff"); + } // need a half neighbor list, built every Nevery steps int irequest = neighbor->request(this,instance_me); @@ -1068,10 +1068,11 @@ void FixBondReact::far_partner() continue; } - if (molecule_keyword[rxnID] == INTER) + if (molecule_keyword[rxnID] == INTER) { if (atom->molecule[i] == atom->molecule[j]) continue; - else if (molecule_keyword[rxnID] == INTRA) + } else if (molecule_keyword[rxnID] == INTRA) { if (atom->molecule[i] != atom->molecule[j]) continue; + } jtype = type[j]; possible = 0; @@ -1152,10 +1153,11 @@ void FixBondReact::close_partner() if (i_limit_tags[i2] != 0) continue; if (itype != iatomtype[rxnID] || jtype != jatomtype[rxnID]) continue; - if (molecule_keyword[rxnID] == INTER) + if (molecule_keyword[rxnID] == INTER) { if (atom->molecule[i1] == atom->molecule[i2]) continue; - else if (molecule_keyword[rxnID] == INTRA) + } else if (molecule_keyword[rxnID] == INTRA) { if (atom->molecule[i1] != atom->molecule[i2]) continue; + } delx = x[i1][0] - x[i2][0]; dely = x[i1][1] - x[i2][1]; From 1695bf3d67fe949ea0f2da900e242254f261a89e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 01:09:24 -0500 Subject: [PATCH 050/187] silence compiler warnings and correct issues with energy/virial accumulators - must not zero global accumulators from Pair class (already done by parent) - must add not set accumulated values --- src/USER-MESONT/pair_mesont_tpm.cpp | 37 ++++++++++++----------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/USER-MESONT/pair_mesont_tpm.cpp b/src/USER-MESONT/pair_mesont_tpm.cpp index 1271ebddb6..2a18bd64c9 100644 --- a/src/USER-MESONT/pair_mesont_tpm.cpp +++ b/src/USER-MESONT/pair_mesont_tpm.cpp @@ -510,33 +510,28 @@ void PairMESONTTPM::compute(int eflag, int vflag) { buckling[idx] = b_sort[i]; } if (eflag_global) { - eng_vdwl = 0.0; energy_s = 0.0; - energy_b = 0.0; energy_t = 0.0; + energy_s = energy_b = energy_t = 0.0; for (int i = 0; i < nall; i++) { - int idx = ntlist.get_idx(i); energy_s += u_ts_sort[i]; energy_b += u_tb_sort[i]; energy_t += u_tt_sort[i]; } - eng_vdwl = energy_s + energy_b + energy_t; + eng_vdwl += energy_s + energy_b + energy_t; } if (eflag_atom) { - for (int i = 0; i < ntot; i++) { - eatom[i] = 0.0; eatom_s[i] = 0.0; - eatom_b[i] = 0.0; eatom_t[i] = 0.0; - } + for (int i = 0; i < ntot; i++) + eatom_s[i] = eatom_b[i] = eatom_t[i] = 0.0; + for (int i = 0; i < nall; i++) { int idx = ntlist.get_idx(i); - eatom_s[idx] = u_ts_sort[i]; - eatom_b[idx] = u_tb_sort[i]; - eatom_t[idx] = u_tt_sort[i]; - eatom[idx] = u_ts_sort[i] + u_tb_sort[i] + u_tt_sort[i]; + eatom_s[idx] += u_ts_sort[i]; + eatom_b[idx] += u_tb_sort[i]; + eatom_t[idx] += u_tt_sort[i]; + eatom[idx] += u_ts_sort[i] + u_tb_sort[i] + u_tt_sort[i]; } } if (vflag_global) { - for (int i = 0; i < 6; i++) virial[i] = 0.0; for (int i = 0; i < nall; i++) { - int idx = ntlist.get_idx(i); virial[0] += s_sort[9*i+0]; //xx virial[1] += s_sort[9*i+4]; //yy virial[2] += s_sort[9*i+8]; //zz @@ -546,16 +541,14 @@ void PairMESONTTPM::compute(int eflag, int vflag) { } } if (vflag_atom) { - for (int i = 0; i < ntot; i++) - for (int j = 0; j < 6; j++) vatom[i][j] = 0.0; for (int i = 0; i < nall; i++) { int idx = ntlist.get_idx(i); - vatom[idx][0] = s_sort[9*i+0]; //xx - vatom[idx][1] = s_sort[9*i+4]; //yy - vatom[idx][2] = s_sort[9*i+8]; //zz - vatom[idx][3] = s_sort[9*i+1]; //xy - vatom[idx][4] = s_sort[9*i+2]; //xz - vatom[idx][5] = s_sort[9*i+5]; //yz + vatom[idx][0] += s_sort[9*i+0]; //xx + vatom[idx][1] += s_sort[9*i+4]; //yy + vatom[idx][2] += s_sort[9*i+8]; //zz + vatom[idx][3] += s_sort[9*i+1]; //xy + vatom[idx][4] += s_sort[9*i+2]; //xz + vatom[idx][5] += s_sort[9*i+5]; //yz } } From fd37abd6495952e3d71c3d9e2d046538db278fd8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 01:45:27 -0500 Subject: [PATCH 051/187] fix typo flagged by compiler warning --- src/USER-MESONT/pair_mesocnt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-MESONT/pair_mesocnt.cpp b/src/USER-MESONT/pair_mesocnt.cpp index 39a97321a7..f460e3aebb 100644 --- a/src/USER-MESONT/pair_mesocnt.cpp +++ b/src/USER-MESONT/pair_mesocnt.cpp @@ -546,7 +546,7 @@ void PairMesoCNT::bond_neigh() if (i2 > nlocal-1 && false) numneigh2 = 0; else numneigh2 = numneigh[i2]; - int numneigh_max_local = numneigh1 + numneigh1; + int numneigh_max_local = numneigh1 + numneigh2; if (numneigh_max_local > numneigh_max) numneigh_max = numneigh_max_local; } if (numneigh_max > reduced_neigh_size) { From d350f46a2c58cc008c7f887caa6793a910e11423 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 7 Dec 2020 09:22:34 -0700 Subject: [PATCH 052/187] Fixed error in Wurtzite script and added more explanation --- doc/src/lattice.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/src/lattice.rst b/doc/src/lattice.rst index da4e0b7e5e..e937541864 100644 --- a/doc/src/lattice.rst +++ b/doc/src/lattice.rst @@ -251,12 +251,16 @@ in commands that use the spacings should be decipherable. ---------- -Example commands for generating a Wurtzite crystal (courtesy -of Aidan Thompson), with its 8 atom unit cell. +Example commands for generating a Wurtzite crystal. +The lattice constants approximate those of CdSe. +The :math:`\sqrt{3}\times 1` orthorhombic supercell is used +with the x, y, and z directions oriented +along :math:`[\bar{1}\bar{2}30]`, +:math:`[10\bar{1}0]`, and :math:`[0001]`, respectively. .. code-block:: LAMMPS - variable a equal 4.340330 + variable a equal 4.34 variable b equal $a*sqrt(3.0) variable c equal $a*sqrt(8.0/3.0) @@ -264,8 +268,8 @@ of Aidan Thompson), with its 8 atom unit cell. variable five6 equal 5.0/6.0 lattice custom 1.0 & - a1 $a 0.0 0.0 & - a2 0.0 $b 0.0 & + a1 $b 0.0 0.0 & + a2 0.0 $a 0.0 & a3 0.0 0.0 $c & basis 0.0 0.0 0.0 & basis 0.5 0.5 0.0 & From 3f5a896aab4bc4fe2a89c8af1dcd883e16c1f262 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 17:35:10 -0500 Subject: [PATCH 053/187] update build system to make it auto-adapt to include python support or not into MLIAP --- cmake/CMakeLists.txt | 1 - cmake/Modules/FindCythonize.cmake | 30 ++++++++++++++++++++++++++++++ cmake/Modules/LAMMPSUtils.cmake | 1 + cmake/Modules/Packages/MLIAP.cmake | 30 ++++++++++++++++++++++++++++-- doc/src/Packages_details.rst | 12 ++++++------ lib/python/Makefile.lammps | 2 +- lib/python/Makefile.mliap_python | 3 +++ src/Depend.sh | 5 +++++ src/MLIAP/Install.sh | 30 ++++++++++++++++++++++++------ src/MLIAP/compute_mliap.cpp | 6 +++--- src/MLIAP/pair_mliap.cpp | 8 ++++---- src/PYTHON/python_impl.cpp | 10 +++++----- src/Purge.list | 2 ++ 13 files changed, 112 insertions(+), 28 deletions(-) create mode 100644 cmake/Modules/FindCythonize.cmake create mode 100644 lib/python/Makefile.mliap_python diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a034cf6d17..e9f9136398 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -194,7 +194,6 @@ endif() # "hard" dependencies between packages resulting # in an error instead of skipping over files pkg_depends(MLIAP SNAP) -pkg_depends(MLIAP PYTHON) pkg_depends(MPIIO MPI) pkg_depends(USER-ATC MANYBODY) pkg_depends(USER-LB MPI) diff --git a/cmake/Modules/FindCythonize.cmake b/cmake/Modules/FindCythonize.cmake new file mode 100644 index 0000000000..9a37904ea7 --- /dev/null +++ b/cmake/Modules/FindCythonize.cmake @@ -0,0 +1,30 @@ +# Find the Cythonize tool. +# +# This code sets the following variables: +# +# Cythonize_EXECUTABLE +# +# adapted from https://github.com/cmarshall108/cython-cmake-example/blob/master/cmake/FindCython.cmake +#============================================================================= + +if(CMAKE_VERSION VERSION_LESS 3.12) + find_package(PythonInterp 3.6 QUIET) # Deprecated since version 3.12 + if(PYTHONINTERP_FOUND) + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + endif() +else() + find_package(Python3 3.6 COMPONENTS Interpreter QUIET) +endif() + +# Use the Cython executable that lives next to the Python executable +# if it is a local installation. +if(Python3_EXECUTABLE) + get_filename_component(_python_path ${Python3_EXECUTABLE} PATH) + find_program(Cythonize_EXECUTABLE + NAMES cythonize3 cythonize cythonize.bat + HINTS ${_python_path}) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cythonize REQUIRED_VARS Cythonize_EXECUTABLE) +mark_as_advanced(Cythonize_EXECUTABLE) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 339ba867bd..fb1203ec73 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -50,6 +50,7 @@ function(check_for_autogen_files source_dir) file(GLOB SRC_AUTOGEN_FILES ${source_dir}/style_*.h) file(GLOB SRC_AUTOGEN_PACKAGES ${source_dir}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) + list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/MLIAP/mliap_model_python_couple ${source_dir}/MLIAP/mliap_model_python_couple.cpp) foreach(_SRC ${SRC_AUTOGEN_FILES}) get_filename_component(FILENAME "${_SRC}" NAME) if(EXISTS ${source_dir}/${FILENAME}) diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/MLIAP.cmake index e877d072b6..153900e2b8 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -1,3 +1,29 @@ -execute_process(COMMAND cythonize mliap_model_python_couple.pyx WORKING_DIRECTORY ../src/MLIAP) +# if PYTHON package is included we may also include Python support in MLIAP +set(ENABLE_MLIAP_PYTHON_DEFAULT OFF) +if(PKG_PYTHON) + find_package(Cythonize) + if(Cythonize_FOUND) + set(ENABLE_MLIAP_PYTHON_DEFAULT ON) + endif() +endif() -target_compile_definitions(lammps PRIVATE -DLMP_MLIAPPY) +option(ENABLE_MLIAP_PYTHON "Build MLIAP package with Python support" ${ENABLE_MLIAP_PYTHON_DEFAULT}) + +if(ENABLE_MLIAP_PYTHON) + find_package(Cythonize REQUIRED) + if(NOT_PKG_PYTHON) + message(FATAL_ERROR "Must install PYTHON package for MLIAP_PYTHON") + endif() + + set(MLIAP_CYTHON_DIR ${CMAKE_BINARY_DIR}/cython) + file(MAKE_DIRECTORY ${MLIAP_CYTHON_DIR}) + add_custom_command(OUTPUT ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.cpp ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.h + COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx + COMMAND ${Cythonize_EXECUTABLE} ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx -3 + WORKING_DIRECTORY ${MLIAP_CYTHON_DIR} + MAIN_DEPENDENCY ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx + COMMENT "Generating C++ sources with cythonize...") + target_compile_definitions(lammps PRIVATE -DMLIAP_PYTHON) + target_sources(lammps PRIVATE ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.cpp) + target_include_directories(lammps PRIVATE ${MLIAP_CYTHON_DIR}) +endif() diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index 3ed5cabe37..3fb906addf 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -666,10 +666,10 @@ A general interface for machine-learning interatomic potentials, including PyTor **Install:** -To use this package, also the :ref:`SNAP package ` -package needs to be installed. If building the *mliappy* model, -use -DLMP_MLIAPPY and the :ref:`PYTHON package ` -package needs to be installed. The version of python must be >3.5. +To use this package, also the :ref:`SNAP package ` package needs +to be installed. To make the *mliappy* model available, also the +:ref:`PYTHON package ` package needs to be installed and the version of +python must be 3.5 or later. **Author:** Aidan Thompson (Sandia), Nicholas Lubbers (LANL). @@ -681,8 +681,8 @@ package needs to be installed. The version of python must be >3.5. * :doc:`compute_style mliap ` * examples/mliap (see README) -When built with the *mliappy* model using -DLMP_MLIAPPY, this package -includes an extension for coupling with python models, including PyTorch. +When built with the *mliappy* model this package includes an extension for +coupling with python models, including PyTorch. In this case, the python interpreter linked to LAMMPS will need cython and numpy installed. The examples build models with PyTorch, which would thus need to be installed. diff --git a/lib/python/Makefile.lammps b/lib/python/Makefile.lammps index 4289674e99..adda24caec 100644 --- a/lib/python/Makefile.lammps +++ b/lib/python/Makefile.lammps @@ -2,6 +2,6 @@ # See the README file for more explanation python_SYSINC = $(shell which python-config > /dev/null 2>&1 && python-config --includes || :) -python_SYSLIB = $(shell which python-config > /dev/null 2>&1 && python-config --ldflags || :) +python_SYSLIB = -lpython3 $(shell which python-config > /dev/null 2>&1 && python-config --ldflags || :) python_SYSPATH = PYTHON=python diff --git a/lib/python/Makefile.mliap_python b/lib/python/Makefile.mliap_python new file mode 100644 index 0000000000..00483a4a6a --- /dev/null +++ b/lib/python/Makefile.mliap_python @@ -0,0 +1,3 @@ + +../mliap_model_python_couple.cpp: ../mliap_model_python_couple.pyx + cythonize -3 ../mliap_model_python_couple.cpp diff --git a/src/Depend.sh b/src/Depend.sh index e629ca9197..f77d435fc5 100755 --- a/src/Depend.sh +++ b/src/Depend.sh @@ -106,6 +106,10 @@ if (test $1 = "PERI") then depend USER-OMP fi +if (test $1 = "PYTHON") then + depend MLIAP +fi + if (test $1 = "RIGID") then depend KOKKOS depend USER-OMP @@ -114,6 +118,7 @@ fi if (test $1 = "SNAP") then depend KOKKOS + depend MLIAP fi if (test $1 = "USER-CGSDK") then diff --git a/src/MLIAP/Install.sh b/src/MLIAP/Install.sh index bd7f7d23a8..e6ba4042a9 100755 --- a/src/MLIAP/Install.sh +++ b/src/MLIAP/Install.sh @@ -26,24 +26,42 @@ action () { fi } +# enforce package dependency +if (test $1 = 1 || test $1 = 2) then + if (test ! -e ../sna.h) then + echo "Must install SNAP package to use MLIAP package" + exit 1 + fi +fi + # all package files with no dependencies -for file in *.cpp *.h; do +for file in *.cpp *.h *.pyx; do test -f ${file} && action $file done # edit 2 Makefile.package files to include/exclude package info if (test $1 = 1) then - - if (test -e ../Makefile.package) then - sed -i -e 's|^PKG_INC =[ \t]*|&-DLMP_MLIAPPY |' ../Makefile.package + if (test "$(type cythonize 2> /dev/null)" != "" && test -e ../python_impl.cpp) then + if (test -e ../Makefile.package) then + sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package + fi + if (test -e ../Makefile.package.settings) then + sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings + # multiline form needed for BSD sed on Macs + sed -i -e '4 i \ +include ..\/..\/lib\/python\/Makefile.mliap_python +' ../Makefile.package.settings + fi + cythonize -3 ../mliap_model_python_couple.pyx fi elif (test $1 = 0) then if (test -e ../Makefile.package) then - sed -i -e 's/[^ \t]*-DLMP_MLIAPPY[^ \t]* //g' ../Makefile.package + sed -i -e 's/[^ \t]*-DMLIAP_PYTHON[^ \t]* //g' ../Makefile.package fi - + rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h + sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings fi diff --git a/src/MLIAP/compute_mliap.cpp b/src/MLIAP/compute_mliap.cpp index 72fb63ecda..0842e421c0 100644 --- a/src/MLIAP/compute_mliap.cpp +++ b/src/MLIAP/compute_mliap.cpp @@ -21,7 +21,7 @@ #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" #include "mliap_descriptor_snap.h" -#ifdef LMP_MLIAPPY +#ifdef MLIAP_PYTHON #include "mliap_model_python.h" #endif @@ -74,12 +74,12 @@ ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) : model = new MLIAPModelQuadratic(lmp); iarg += 2; } - #ifdef LMP_MLIAPPY +#ifdef MLIAP_PYTHON else if (strcmp(arg[iarg+1],"mliappy") == 0) { model = new MLIAPModelPython(lmp); iarg += 2; } - #endif +#endif else error->all(FLERR,"Illegal compute mliap command"); modelflag = 1; } else if (strcmp(arg[iarg],"descriptor") == 0) { diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index 5c0474d2ca..6f75ef542e 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -21,7 +21,7 @@ #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" #include "mliap_descriptor_snap.h" -#ifdef LMP_MLIAPPY +#ifdef MLIAP_PYTHON #include "mliap_model_python.h" #endif @@ -128,7 +128,7 @@ void PairMLIAP::allocate() void PairMLIAP::settings(int narg, char ** arg) { - + if (narg < 4) error->all(FLERR,"Illegal pair_style command"); @@ -152,12 +152,12 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelQuadratic(lmp,arg[iarg+2]); iarg += 3; - #ifdef LMP_MLIAPPY +#ifdef MLIAP_PYTHON } else if (strcmp(arg[iarg+1],"mliappy") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelPython(lmp,arg[iarg+2]); iarg += 3; - #endif +#endif } else error->all(FLERR,"Illegal pair_style mliap command"); modelflag = 1; } else if (strcmp(arg[iarg],"descriptor") == 0) { diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 62f19d0f12..533394f7b1 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -26,7 +26,7 @@ #include #include // IWYU pragma: export -#ifdef LMP_MLIAPPY +#ifdef MLIAP_PYTHON #include "mliap_model_python.h" // The above should somehow really be included in the next file. // We could get around this with cython --capi-reexport-cincludes @@ -58,14 +58,14 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // one-time initialization of Python interpreter // pyMain stores pointer to main module external_interpreter = Py_IsInitialized(); - - #ifdef LMP_MLIAPPY + +#ifdef MLIAP_PYTHON // Inform python intialization scheme of the mliappy module. // This -must- happen before python is initialized. int err = PyImport_AppendInittab("mliap_model_python_couple", PyInit_mliap_model_python_couple); if (err) error->all(FLERR,"Could not register MLIAPPY embedded python module."); - #endif - +#endif + Py_Initialize(); PyEval_InitThreads(); diff --git a/src/Purge.list b/src/Purge.list index 0251f923be..2853ce2a7c 100644 --- a/src/Purge.list +++ b/src/Purge.list @@ -49,6 +49,8 @@ packages_ntopo.h # other auto-generated files lmpinstalledpkgs.h lmpgitversion.h +mliap_model_python_couple.cpp +mliap_model_python_couple.h # removed on 9 Sep 2020 mergesort.h # renamed on 8 May 2020 From 280c19cf3258e754937fced81e798965cf29894c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 17:46:54 -0500 Subject: [PATCH 054/187] rename CMake configuation variable to MLIAP_ENABLE_PYTHON to be more consistent with other packages --- cmake/Modules/Packages/MLIAP.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/MLIAP.cmake index 153900e2b8..0f19c54461 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -1,15 +1,15 @@ # if PYTHON package is included we may also include Python support in MLIAP -set(ENABLE_MLIAP_PYTHON_DEFAULT OFF) +set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) if(PKG_PYTHON) find_package(Cythonize) if(Cythonize_FOUND) - set(ENABLE_MLIAP_PYTHON_DEFAULT ON) + set(MLIAP_ENABLE_PYTHON_DEFAULT ON) endif() endif() -option(ENABLE_MLIAP_PYTHON "Build MLIAP package with Python support" ${ENABLE_MLIAP_PYTHON_DEFAULT}) +option(MLIAP_ENABLE_PYTHON "Build MLIAP package with Python support" ${MLIAP_ENABLE_PYTHON_DEFAULT}) -if(ENABLE_MLIAP_PYTHON) +if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) if(NOT_PKG_PYTHON) message(FATAL_ERROR "Must install PYTHON package for MLIAP_PYTHON") From 3eb22e240673743c7ce29c0b3abb0662f712ed81 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 17:47:21 -0500 Subject: [PATCH 055/187] cleanup and compilation for python off --- python/lammps.py | 12 ++++++------ src/MLIAP/mliap_data.cpp | 2 +- src/MLIAP/mliap_model_python.cpp | 14 +++++++++----- src/MLIAP/mliap_model_python.h | 2 +- src/MLIAP/mliap_model_python_couple.pyx | 15 ++++----------- src/MLIAP/pair_mliap.cpp | 8 ++++---- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/python/lammps.py b/python/lammps.py index 85fbd1217b..6f88ee86a7 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -505,7 +505,7 @@ class lammps(object): self.FIX_EXTERNAL_CALLBACK_FUNC = CFUNCTYPE(None, py_object, self.c_bigint, c_int, POINTER(self.c_tagint), POINTER(POINTER(c_double)), POINTER(POINTER(c_double))) self.lib.lammps_set_fix_external_callback.argtypes = [c_void_p, c_char_p, self.FIX_EXTERNAL_CALLBACK_FUNC, py_object] self.lib.lammps_set_fix_external_callback.restype = None - + self.mliappy = MLIAPPY(self) # ------------------------------------------------------------------------- @@ -2931,12 +2931,12 @@ class MLIAPPY(): def __init__(self,lammps): self._module = None self.lammps = lammps - + @property def module(self): if self._module: return self._module - + try: # Begin Importlib magic to find the embedded python module # This is needed because the filename for liblammps does not @@ -2959,10 +2959,10 @@ class MLIAPPY(): # End Importlib magic to find the embedded python module except: raise ImportError("Could not load MLIAPPY coupling module") - + def activate(self): self.module - + def load_model(self,model): self.module.load_from_python(model) - + diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 2559f5330d..c310f0efc7 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -29,7 +29,7 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, class MLIAPModel* model_in, class MLIAPDescriptor* descriptor_in, class PairMLIAP* pairmliap_in) : - Pointers(lmp), gradforce(nullptr), betas(nullptr), + Pointers(lmp), gradforce(nullptr), betas(nullptr), descriptors(nullptr), eatoms(nullptr), gamma(nullptr), gamma_row_index(nullptr), gamma_col_index(nullptr), egradient(nullptr), numneighs(nullptr), iatoms(nullptr), ielems(nullptr), jatoms(nullptr), jelems(nullptr), diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp index 2aa588ff32..e47356390f 100644 --- a/src/MLIAP/mliap_model_python.cpp +++ b/src/MLIAP/mliap_model_python.cpp @@ -15,6 +15,8 @@ Contributing author: Nicholas Lubbers (LANL) ------------------------------------------------------------------------- */ +#ifdef MLIAP_PYTHON + #include #include "mliap_model_python.h" #include "mliap_model_python_couple.h" @@ -43,9 +45,9 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS* lmp, char* coefffilename) : PyGILState_Release(gstate); error->all(FLERR,"Could not initialize embedded Python"); } - + PyObject* coupling_module = PyImport_ImportModule("mliap_model_python_couple"); - + if (!coupling_module) { PyErr_Print(); PyErr_Clear(); @@ -97,7 +99,7 @@ void MLIAPModelPython::read_coeffs(char * fname) error->all(FLERR,"Loading python model failure."); } PyGILState_Release(gstate); - + if (loaded) { this->connect_param_counts(); } @@ -113,7 +115,7 @@ void MLIAPModelPython::connect_param_counts() nelements = MLIAPPY_nelements(this); nparams = MLIAPPY_nparams(this); ndescriptors = MLIAPPY_ndescriptors(this); - + if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); @@ -137,7 +139,7 @@ void MLIAPModelPython::compute_gradients(MLIAPData* data) if (not model_loaded) { error->all(FLERR,"Model not loaded."); } - + PyGILState_STATE gstate = PyGILState_Ensure(); MLIAPPY_compute_gradients(this, data); if (PyErr_Occurred()) { @@ -196,3 +198,5 @@ double MLIAPModelPython::memory_usage() // todo: get approximate memory usage in coupling code. return 0; } + +#endif diff --git a/src/MLIAP/mliap_model_python.h b/src/MLIAP/mliap_model_python.h index 0ef87f86fd..57110f36e2 100644 --- a/src/MLIAP/mliap_model_python.h +++ b/src/MLIAP/mliap_model_python.h @@ -38,7 +38,7 @@ protected: virtual void read_coeffs(char *); private: - + }; } diff --git a/src/MLIAP/mliap_model_python_couple.pyx b/src/MLIAP/mliap_model_python_couple.pyx index ad95ea2c48..49bdd47412 100644 --- a/src/MLIAP/mliap_model_python_couple.pyx +++ b/src/MLIAP/mliap_model_python_couple.pyx @@ -1,12 +1,5 @@ # cython: language_level=3 # distutils: language = c++ -# distutils: define_macros="LMP_MLIAPPY" -# distutils: extra_compile_args= -stdlib=libc++ -std=c++11 -# distutils: include_dirs = ../STUBS .. ../MLIAP -# distutils: extra_link_args= -stdlib=libc++ -# Note: only the language_level and language commands are needed, the rest pertain -# to building mliap_model_python_couple as a standalone python extension, which -# is experimental. cimport cython @@ -88,11 +81,11 @@ def load_from_python(model): LOADED_MODELS[c_id]=model lmp_model = c_id lmp_model.connect_param_counts() - + cdef public void MLIAPPY_unload_model(MLIAPModelPython * c_model) with gil: del LOADED_MODELS[c_id(c_model)] - + cdef public int MLIAPPY_nparams(MLIAPModelPython * c_model) with gil: return int(retrieve(c_model).n_params) @@ -107,7 +100,7 @@ cdef public void MLIAPPY_compute_gradients(MLIAPModelPython * c_model, MLIAPData n_d = data.ndescriptors n_a = data.natoms - + # Make numpy arrays from pointers beta_np = np.asarray( &data.betas[0][0]) desc_np = np.asarray( &data.descriptors[0][0]) @@ -116,7 +109,7 @@ cdef public void MLIAPPY_compute_gradients(MLIAPModelPython * c_model, MLIAPData # Invoke python model on numpy arrays. model(elem_np,desc_np,beta_np,en_np) - + # Get the total energy from the atom energy. energy = np.sum(en_np) data.energy = energy diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index 6f75ef542e..0c6f3903f6 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -73,17 +73,17 @@ PairMLIAP::~PairMLIAP() void PairMLIAP::compute(int eflag, int vflag) { - + // consistency checks if (data->ndescriptors != model->ndescriptors) { error->all(FLERR,"Incompatible model and descriptor descriptor count"); }; - + if (data->nelements != model->nelements) { error->all(FLERR,"Incompatible model and descriptor element count"); }; - + ev_init(eflag,vflag); data->generate_neighdata(list, eflag, vflag); @@ -249,7 +249,7 @@ void PairMLIAP::coeff(int narg, char **arg) void PairMLIAP::e_tally(MLIAPData* data) { if (eflag_global) eng_vdwl += data->energy; - if (eflag_atom) + if (eflag_atom) for (int ii = 0; ii < data->natoms; ii++) { const int i = data->iatoms[ii]; eatom[i] += data->eatoms[ii]; From 2ccb39b54c3c82bc70cdbee2ccaa976adac33455 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 17:49:07 -0500 Subject: [PATCH 056/187] doc updates --- doc/src/Build_extras.rst | 35 +++++++++++++++++++++++++++++++++++ doc/src/compute_mliap.rst | 6 +++--- doc/src/pair_mliap.rst | 6 +++--- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 5ef29fbca1..8b11ede347 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -37,6 +37,7 @@ This is the list of packages that may require additional steps. * :ref:`KOKKOS ` * :ref:`LATTE ` * :ref:`MESSAGE ` + * :ref:`MLIAP ` * :ref:`MSCG ` * :ref:`OPT ` * :ref:`POEMS ` @@ -732,6 +733,40 @@ be installed on your system. ---------- +.. _mliap: + +MLIAP package +--------------------------- + +Building the MLIAP package requires also enabling the SNAP package. +There will be an error message if this requirement is not satisfied. +Using the *mliappy* model also requires enabling the PYTHON package +**and** requires you have the `cython `_ software +installed and a working ``cythonize`` command. This requires Python +version 3.6 or later. + +.. tabs:: + + .. tab:: CMake build + + .. code-block:: bash + + -D MLIAP_ENABLE_PYTHON=value # enable mliappy model (default is autodetect) + + Without this setting, CMake will check whether it can find a + suitable Python version and the ``cythonize`` command and choose + the default accordingly. + + .. tab:: Traditional make + + The build uses the ``lib/python/Makefile.mliap_python`` file in the + compile/link process to add a rule to update the files generated by + the ``cythonize`` command in case the corresponding .pyx file was + modified. You may need to need to modify ``lib/python/Makefile.lammps`` + if the LAMMPS build fails. + +---------- + .. _mscg: MSCG package diff --git a/doc/src/compute_mliap.rst b/doc/src/compute_mliap.rst index 66bf868e0d..579086ad4a 100644 --- a/doc/src/compute_mliap.rst +++ b/doc/src/compute_mliap.rst @@ -56,14 +56,14 @@ and it is also straightforward to add new descriptor styles. The compute *mliap* command must be followed by two keywords *model* and *descriptor* in either order. -The *model* keyword is followed by the model style (*linear*, *quadratic* or *mliappy*). +The *model* keyword is followed by the model style (*linear*, *quadratic* or *mliappy*). The *mliappy* model is only available if lammps is built with MLIAPPY package. The *descriptor* keyword is followed by a descriptor style, and additional arguments. -The compute currently supports just one descriptor style, but it is +The compute currently supports just one descriptor style, but it is is straightforward to add new descriptor styles. -The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, +The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, including the linear, quadratic, and chem variants. A single additional argument specifies the descriptor filename containing the parameters and setting used by the SNAP descriptor. diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index 4c1845d514..9dd8c5c6b1 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -41,9 +41,9 @@ and the geometric quantities that characterize the atomic positions (*descriptor*). By defining *model* and *descriptor* separately, it is possible to use many different models with a given descriptor, or many different descriptors with a given model. The -pair style currently supports just one descriptor style, but it is +pair style currently supports just one descriptor style, but it is is straightforward to add new descriptor styles. -The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, +The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, including the linear, quadratic, and chem variants. The available models are *linear*, *quadratic*, and *mliappy*. The *mliappy* style can be used to couple python models, @@ -62,7 +62,7 @@ that specify the mapping of MLIAP element names to LAMMPS atom types, where N is the number of LAMMPS atom types. -The *model* keyword is followed by the model style. This is followed +The *model* keyword is followed by the model style. This is followed by a single argument specifying the model filename containing the parameters for a set of elements. The model filename usually ends in the *.mliap.model* extension. From 161fdbd7ec356bb2022f1ef56f1bab396aa9e98e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 18:28:13 -0500 Subject: [PATCH 057/187] whitespace --- doc/src/lattice.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/lattice.rst b/doc/src/lattice.rst index e937541864..b87ddaaf70 100644 --- a/doc/src/lattice.rst +++ b/doc/src/lattice.rst @@ -254,9 +254,9 @@ in commands that use the spacings should be decipherable. Example commands for generating a Wurtzite crystal. The lattice constants approximate those of CdSe. The :math:`\sqrt{3}\times 1` orthorhombic supercell is used -with the x, y, and z directions oriented -along :math:`[\bar{1}\bar{2}30]`, -:math:`[10\bar{1}0]`, and :math:`[0001]`, respectively. +with the x, y, and z directions oriented +along :math:`[\bar{1}\bar{2}30]`, +:math:`[10\bar{1}0]`, and :math:`[0001]`, respectively. .. code-block:: LAMMPS From 77168b510512393aec275c026195c60b125395a2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Dec 2020 18:32:11 -0500 Subject: [PATCH 058/187] delete hack --- lib/python/Makefile.lammps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/python/Makefile.lammps b/lib/python/Makefile.lammps index adda24caec..4289674e99 100644 --- a/lib/python/Makefile.lammps +++ b/lib/python/Makefile.lammps @@ -2,6 +2,6 @@ # See the README file for more explanation python_SYSINC = $(shell which python-config > /dev/null 2>&1 && python-config --includes || :) -python_SYSLIB = -lpython3 $(shell which python-config > /dev/null 2>&1 && python-config --ldflags || :) +python_SYSLIB = $(shell which python-config > /dev/null 2>&1 && python-config --ldflags || :) python_SYSPATH = PYTHON=python From 5b6b327a5d4a36bcd7bdca557f104cc347d0a46d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 8 Dec 2020 00:04:54 -0500 Subject: [PATCH 059/187] fix CMake errors --- cmake/Modules/LAMMPSUtils.cmake | 2 +- cmake/Modules/Packages/MLIAP.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index fb1203ec73..37275843fa 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -50,7 +50,7 @@ function(check_for_autogen_files source_dir) file(GLOB SRC_AUTOGEN_FILES ${source_dir}/style_*.h) file(GLOB SRC_AUTOGEN_PACKAGES ${source_dir}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) - list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/MLIAP/mliap_model_python_couple ${source_dir}/MLIAP/mliap_model_python_couple.cpp) + list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/mliap_model_python_couple.h ${source_dir}/mliap_model_python_couple.cpp) foreach(_SRC ${SRC_AUTOGEN_FILES}) get_filename_component(FILENAME "${_SRC}" NAME) if(EXISTS ${source_dir}/${FILENAME}) diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/MLIAP.cmake index 0f19c54461..0fba0fd63d 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -11,8 +11,8 @@ option(MLIAP_ENABLE_PYTHON "Build MLIAP package with Python support" ${MLIAP_ENA if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) - if(NOT_PKG_PYTHON) - message(FATAL_ERROR "Must install PYTHON package for MLIAP_PYTHON") + if(NOT PKG_PYTHON) + message(FATAL_ERROR "Must install PYTHON package for MLIAP with Python support") endif() set(MLIAP_CYTHON_DIR ${CMAKE_BINARY_DIR}/cython) From c4ee2f2e4243c5c79832eb03916b39b40ae9d3d7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 8 Dec 2020 00:28:16 -0500 Subject: [PATCH 060/187] don't need Python interpreter for compiling the PYTHON package --- cmake/Modules/Packages/PYTHON.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index e3158dc509..ef8b056a85 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -3,7 +3,7 @@ if(CMAKE_VERSION VERSION_LESS 3.12) target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) else() - find_package(Python REQUIRED COMPONENTS Development Interpreter) + find_package(Python REQUIRED COMPONENTS Development) target_include_directories(lammps PRIVATE ${Python_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE Python::Python) endif() From ddcd5a3c2e856d174960f635062628f36c2cac0d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 9 Dec 2020 10:28:12 -0500 Subject: [PATCH 061/187] small CMake tweaks and cleanups --- cmake/Modules/Packages/MLIAP.cmake | 4 ++-- cmake/Modules/Packages/PYTHON.cmake | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/MLIAP.cmake index 0fba0fd63d..ffb10acec9 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -12,14 +12,14 @@ option(MLIAP_ENABLE_PYTHON "Build MLIAP package with Python support" ${MLIAP_ENA if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) if(NOT PKG_PYTHON) - message(FATAL_ERROR "Must install PYTHON package for MLIAP with Python support") + message(FATAL_ERROR "Must enable PYTHON package for including Python support in MLIAP") endif() set(MLIAP_CYTHON_DIR ${CMAKE_BINARY_DIR}/cython) file(MAKE_DIRECTORY ${MLIAP_CYTHON_DIR}) add_custom_command(OUTPUT ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.cpp ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.h COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx - COMMAND ${Cythonize_EXECUTABLE} ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx -3 + COMMAND ${Cythonize_EXECUTABLE} -3 ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx WORKING_DIRECTORY ${MLIAP_CYTHON_DIR} MAIN_DEPENDENCY ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx COMMENT "Generating C++ sources with cythonize...") diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index ef8b056a85..7be25a6b05 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -4,7 +4,6 @@ if(CMAKE_VERSION VERSION_LESS 3.12) target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) else() find_package(Python REQUIRED COMPONENTS Development) - target_include_directories(lammps PRIVATE ${Python_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE Python::Python) endif() target_compile_definitions(lammps PRIVATE -DLMP_PYTHON) From 50a9ac92a7ecc73dc3c53500f2e75da891f9382f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 9 Dec 2020 10:28:27 -0500 Subject: [PATCH 062/187] update docs for MLIAP some more --- doc/src/Build_extras.rst | 26 +++++++++++++++++++------- doc/src/Packages_details.rst | 12 +++++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 8b11ede347..34a75b66dc 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -738,12 +738,12 @@ be installed on your system. MLIAP package --------------------------- -Building the MLIAP package requires also enabling the SNAP package. -There will be an error message if this requirement is not satisfied. -Using the *mliappy* model also requires enabling the PYTHON package -**and** requires you have the `cython `_ software -installed and a working ``cythonize`` command. This requires Python -version 3.6 or later. +Building the MLIAP package requires including the :ref:`SNAP ` +package. There will be an error message if this requirement is not satisfied. +Using the *mliappy* model also requires enabling the :ref:`PYTHON ` +package **and** requires you have the `cython `_ software +installed and with it a working ``cythonize`` command. This feature requires +compiling LAMMPS with Python version 3.6 or later. .. tabs:: @@ -755,7 +755,11 @@ version 3.6 or later. Without this setting, CMake will check whether it can find a suitable Python version and the ``cythonize`` command and choose - the default accordingly. + the default accordingly. During the build procedure the provided + .pyx file(s) will be automatically translated to C++ code and compiled. + Please do **not** run ``cythonize`` manually in the ``src/MLIAP`` folder, + as that can lead to compilation errors if PYTHON support is not included. + If you did by accident, please remove the generated .cpp and .h files. .. tab:: Traditional make @@ -764,6 +768,14 @@ version 3.6 or later. the ``cythonize`` command in case the corresponding .pyx file was modified. You may need to need to modify ``lib/python/Makefile.lammps`` if the LAMMPS build fails. + To manually enforce building MLIAP with Python support, you can add + ``-DMLIAP_PYTHON`` to the ``LMP_INC`` variable in your machine makefile. + You may have to manually run the cythonize command on .pyx file(s) + in the ``src`` folder, if this is not automatically done during + installing the MLIAP package. Please do **not** run ``cythonize`` + in the ``src/MLIAP`` folder, as that can lead to compilation errors + if PYTHON support is not included. + If you did by accident, please remove the generated .cpp and .h files. ---------- diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index 3fb906addf..e044adfcb3 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -668,8 +668,9 @@ A general interface for machine-learning interatomic potentials, including PyTor To use this package, also the :ref:`SNAP package ` package needs to be installed. To make the *mliappy* model available, also the -:ref:`PYTHON package ` package needs to be installed and the version of -python must be 3.5 or later. +:ref:`PYTHON package ` package needs to be installed, the version of +Python must be 3.6 or later, and the `cython `_ software +must be installed. **Author:** Aidan Thompson (Sandia), Nicholas Lubbers (LANL). @@ -682,9 +683,10 @@ python must be 3.5 or later. * examples/mliap (see README) When built with the *mliappy* model this package includes an extension for -coupling with python models, including PyTorch. -In this case, the python interpreter linked to LAMMPS will need cython and numpy installed. -The examples build models with PyTorch, which would thus need to be installed. +coupling with Python models, including PyTorch. In this case, the Python +interpreter linked to LAMMPS will need the ``cython`` and ``numpy`` modules +installed. The provided examples build models with PyTorch, which would +therefore also needs to be installed to run those examples. ---------- From f7e0fbf064b610781c643066e0eea54692479456 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 9 Dec 2020 10:28:40 -0500 Subject: [PATCH 063/187] update MLIAP readme files --- examples/mliap/README.pytorch | 4 ++-- src/MLIAP/README | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/mliap/README.pytorch b/examples/mliap/README.pytorch index 7f511168a7..49868208fe 100644 --- a/examples/mliap/README.pytorch +++ b/examples/mliap/README.pytorch @@ -17,8 +17,8 @@ From that point you can run the example lmp -in in.mliap.pytorch.Ta06A -echo bot 2: Running models from python with LAMMPS in library mode: mliap_pytorch_Ta06A.py Before testing this, ensure that the first example (using LAMMPS executable) works. -Also, not all python installations support this mode of operation. -It requires that the Python interpreter be initialized. +Also, not all python installations support this mode of operation. +It requires that the Python interpreter be initialized. To check this for your Python library, run the Py_IsInitialized() method. If the return value is True, you should be able to run the example, diff --git a/src/MLIAP/README b/src/MLIAP/README index d94a1bac16..7841b7c158 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -32,14 +32,17 @@ potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP>. *Additional instructions for compiling PyTorch energy models* The *MLIAPPY* extension written by Nick Lubbers (LANL) -provides a coupling to PyTorch energy models. +provides a coupling to PyTorch energy models. This should be automatically +enabled by default if the prerequisite software is installed. It can be +enforced during CMake configuration by setting the variable +MLIAP_ENABLE_PYTHON=yes or for conventional build by adding -DMLIAP_PYTHON +to the LMP_INC variable in your makefile and running the cythonize script +on the .pyx file(s) copied to the src folder. -Before compiling LAMMPS with either make or cmake, you have -to run cythonize to create the coupling source files -in the src/MLIAP directory e.g. +This requires to also install the PYTHON package and have the cython +(https://cython.org) software installed. During configuration/compilation +the cythonize script will be used to convert the provided .pyx file(s) +to C++ code. Please do not run the cythonize script in the src/MLIAP folder. +If you have done so by accident, you need to delete the generated .cpp and .h +file(s) in the src/MLIAP folder or there may be problems during compilation. -cd src/MLIAP -cythonize mliap_model_python_couple.pyx - -After that, install the MLIAP package with make or cmake -and build LAMMPS. From cc222791a58e5aee2484613e568e17bc425836f5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 9 Dec 2020 10:47:06 -0500 Subject: [PATCH 064/187] use variables to infer filenames from original .pyx source --- cmake/Modules/Packages/MLIAP.cmake | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/MLIAP.cmake index ffb10acec9..d3f601a1e1 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -15,15 +15,17 @@ if(MLIAP_ENABLE_PYTHON) message(FATAL_ERROR "Must enable PYTHON package for including Python support in MLIAP") endif() - set(MLIAP_CYTHON_DIR ${CMAKE_BINARY_DIR}/cython) - file(MAKE_DIRECTORY ${MLIAP_CYTHON_DIR}) - add_custom_command(OUTPUT ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.cpp ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.h - COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx - COMMAND ${Cythonize_EXECUTABLE} -3 ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.pyx - WORKING_DIRECTORY ${MLIAP_CYTHON_DIR} - MAIN_DEPENDENCY ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx - COMMENT "Generating C++ sources with cythonize...") + set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) + set(MLIAP_CYTHON_SRC ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx) + get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_SRC} NAME_WE) + file(MAKE_DIRECTORY ${MLIAP_BINARY_DIR}) + add_custom_command(OUTPUT ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MLIAP_CYTHON_SRC} ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.pyx + COMMAND ${Cythonize_EXECUTABLE} -3 ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.pyx + WORKING_DIRECTORY ${MLIAP_BINARY_DIR} + MAIN_DEPENDENCY ${MLIAP_CYTHON_SRC} + COMMENT "Generating C++ sources with cythonize...") target_compile_definitions(lammps PRIVATE -DMLIAP_PYTHON) - target_sources(lammps PRIVATE ${MLIAP_CYTHON_DIR}/mliap_model_python_couple.cpp) - target_include_directories(lammps PRIVATE ${MLIAP_CYTHON_DIR}) + target_sources(lammps PRIVATE ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp) + target_include_directories(lammps PRIVATE ${MLIAP_BINARY_DIR}) endif() From 56feb03b38bea4d141c330b7071425831cec5513 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 9 Dec 2020 16:51:36 -0700 Subject: [PATCH 065/187] Edits to README --- examples/mliap/README | 74 +++++++++++++++++++++++++++ examples/mliap/README.pytorch | 35 ------------- examples/mliap/convert_mliap_Ta06A.py | 2 +- examples/mliap/in.mliap.snap.Ta06A | 2 +- 4 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 examples/mliap/README delete mode 100644 examples/mliap/README.pytorch diff --git a/examples/mliap/README b/examples/mliap/README new file mode 100644 index 0000000000..68b6f2e200 --- /dev/null +++ b/examples/mliap/README @@ -0,0 +1,74 @@ +This directory contains multipler examples of +machine-learning potentials defined using the +MLIAP package in LAMMPS. The input files +are descirbed below. + +in.mliap.snap.Ta06A +------------------- +Run linear SNAP, equivalent to examples/snap/in.snap.Ta06A + +in.mliap.snap.WBe.PRB2019 +------------------------- +Run linear SNAP, equivalent to examples/snap/in.snap.WBe.PRB2019 + +in.mliap.snap.quadratic +----------------------- +Run quadratic SNAP + +in.mliap.snap.chem +------------------ +Run EME-SNAP, equivalent to examples/snap/in.snap.InP.JCPA2020 + +in.mliap.snap.compute +--------------------- +Generate gradients w.r.t. coefficients for linear SNAP, +equivalent to in.snap.compute + +in.mliap.quadratic.compute +-------------------------- +Generate gradients w.r.t. coefficients for quadratic SNAP, +equivalent to in.snap.compute.quadratic + +in.mliap.pytorch.Ta06A +----------------------- +This reproduces the output of in.mliap.snap.Ta06A above, +but using the Python coupling to PyTorch. +It can be run in two different ways: + +1: Running a LAMMPS executable: in.mliap.pytorch.Ta06A + +First run convert_mliap_Ta06A.py, which will convert the Ta06A potential +into a pytorch model. It will be saved as "Ta06A.mliap.pytorch.model.pkl". + +It will also copy "../../src/MLIAP/mliappy_pytorch.py" +file into the current working directory. mliappy_pytorch.py contains +class definitions suitable for wrapping an arbitrary PyTorch +energy model. It must be available to python when +creating or unpickling a PyTorch energy model. + +From that point you can run the example as follows + +`lmp -in in.mliap.pytorch.Ta06A -echo both` + +The resultant log.lammps output should be identical to that generated +by in.mliap.snap.Ta06A. + +2: Running a Python script: mliap_pytorch_Ta06A.py + +Before testing this, ensure that the first example +(using LAMMPS executable) works. +Also, not all python installations support this mode of operation. +It requires that the Python interpreter be initialized. +To check this for your Python library, +try running the Py_IsInitialized() method. +If the return value is True, you should be able to run the example, +as follows: + +`python mliap_pytorch_Ta06A.py` + +or + +`mpirun -np 4 python mliap_pytorch_Ta06A.py` + +The resultant log.lammps output should be identical to that generated +by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A. diff --git a/examples/mliap/README.pytorch b/examples/mliap/README.pytorch deleted file mode 100644 index 49868208fe..0000000000 --- a/examples/mliap/README.pytorch +++ /dev/null @@ -1,35 +0,0 @@ -README for the PyTorch energy model example - -These two examples run the Ta06 example from the MLIAP package, but using the python coupling. -The differ only in how the coupling is constructed. - -1: Running models using LAMMPS executable: in.mliap.pytorch.Ta06A - -To run this, first run convert_mliap_Ta06A.py, which will convert the Ta06 potential into a pytorch model. -It will be saved as "Ta06A.mliap.pytorch.model.pkl". - -It will also copy the "mliappy_pytorch.py" file into the current working directory. mliappy_pytorch.py contains -class definitions suitable for wrapping an arbitrary PyTorch energy model. It must be available to python when -creating or unpicking a PyTorch energy model. - -From that point you can run the example lmp -in in.mliap.pytorch.Ta06A -echo both - -2: Running models from python with LAMMPS in library mode: mliap_pytorch_Ta06A.py - -Before testing this, ensure that the first example (using LAMMPS executable) works. -Also, not all python installations support this mode of operation. -It requires that the Python interpreter be initialized. -To check this for your Python library, -run the Py_IsInitialized() method. -If the return value is True, you should be able to run the example, -as follows: - -`python mliap_pytorch_Ta06A.py` - -or - -`mpirun -np 4 python mliap_pytorch_Ta06A.py` - -The resultant log.lammps output should be identical to that generated -by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A - diff --git a/examples/mliap/convert_mliap_Ta06A.py b/examples/mliap/convert_mliap_Ta06A.py index 6f10f8303c..ba95678c9e 100644 --- a/examples/mliap/convert_mliap_Ta06A.py +++ b/examples/mliap/convert_mliap_Ta06A.py @@ -21,7 +21,7 @@ with torch.autograd.no_grad(): lin.weight.set_(torch.from_numpy(weights).unsqueeze(0)) lin.bias.set_(torch.as_tensor(bias,dtype=torch.float64).unsqueeze(0)) -# Wrap the pytorch model for usage with MLIAPPY +# Wrap the pytorch model for usage with mliappy energy model model = mliappy_pytorch.IgnoreElems(lin) n_descriptors = lin.weight.shape[1] n_params = mliappy_pytorch.calc_n_params(model) diff --git a/examples/mliap/in.mliap.snap.Ta06A b/examples/mliap/in.mliap.snap.Ta06A index 3d94d5c9fc..7b9b5b47d1 100644 --- a/examples/mliap/in.mliap.snap.Ta06A +++ b/examples/mliap/in.mliap.snap.Ta06A @@ -1,4 +1,4 @@ -# Demonstrate MLIAP interface to kinear SNAP potential +# Demonstrate MLIAP interface to linear SNAP potential # Initialize simulation From 4964a569749528df10c58cce85eea237de291531 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 9 Dec 2020 17:12:35 -0700 Subject: [PATCH 066/187] Tweaked build instructions --- doc/src/Build_extras.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 34a75b66dc..adbfa02952 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -741,7 +741,7 @@ MLIAP package Building the MLIAP package requires including the :ref:`SNAP ` package. There will be an error message if this requirement is not satisfied. Using the *mliappy* model also requires enabling the :ref:`PYTHON ` -package **and** requires you have the `cython `_ software +package **and** requires you have the `cython `_ software installed and with it a working ``cythonize`` command. This feature requires compiling LAMMPS with Python version 3.6 or later. @@ -765,16 +765,17 @@ compiling LAMMPS with Python version 3.6 or later. The build uses the ``lib/python/Makefile.mliap_python`` file in the compile/link process to add a rule to update the files generated by - the ``cythonize`` command in case the corresponding .pyx file was - modified. You may need to need to modify ``lib/python/Makefile.lammps`` + the ``cythonize`` command in case the corresponding .pyx file(s) were + modified. You may need to modify ``lib/python/Makefile.lammps`` if the LAMMPS build fails. - To manually enforce building MLIAP with Python support, you can add + To manually enforce building MLIAP with Python support enabled, + you can add ``-DMLIAP_PYTHON`` to the ``LMP_INC`` variable in your machine makefile. You may have to manually run the cythonize command on .pyx file(s) in the ``src`` folder, if this is not automatically done during installing the MLIAP package. Please do **not** run ``cythonize`` in the ``src/MLIAP`` folder, as that can lead to compilation errors - if PYTHON support is not included. + if Python support is not enabled. If you did by accident, please remove the generated .cpp and .h files. ---------- From b8a7edfaa1434a6fd96535fd99d0949f3f0015d1 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 9 Dec 2020 17:27:20 -0700 Subject: [PATCH 067/187] Tried to distinguish MLIAP package with Python support from PYTHON package --- doc/src/Build_extras.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index adbfa02952..5fa68778b6 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -740,7 +740,8 @@ MLIAP package Building the MLIAP package requires including the :ref:`SNAP ` package. There will be an error message if this requirement is not satisfied. -Using the *mliappy* model also requires enabling the :ref:`PYTHON ` +Using the *mliappy* model also requires enabling Python support, which +in turn requires the :ref:`PYTHON ` package **and** requires you have the `cython `_ software installed and with it a working ``cythonize`` command. This feature requires compiling LAMMPS with Python version 3.6 or later. @@ -758,7 +759,7 @@ compiling LAMMPS with Python version 3.6 or later. the default accordingly. During the build procedure the provided .pyx file(s) will be automatically translated to C++ code and compiled. Please do **not** run ``cythonize`` manually in the ``src/MLIAP`` folder, - as that can lead to compilation errors if PYTHON support is not included. + as that can lead to compilation errors if Python support is not enabled. If you did by accident, please remove the generated .cpp and .h files. .. tab:: Traditional make @@ -771,7 +772,7 @@ compiling LAMMPS with Python version 3.6 or later. To manually enforce building MLIAP with Python support enabled, you can add ``-DMLIAP_PYTHON`` to the ``LMP_INC`` variable in your machine makefile. - You may have to manually run the cythonize command on .pyx file(s) + You may have to manually run the ``cythonize`` command on .pyx file(s) in the ``src`` folder, if this is not automatically done during installing the MLIAP package. Please do **not** run ``cythonize`` in the ``src/MLIAP`` folder, as that can lead to compilation errors From 8f10691ae63f5747d4aed3271b74730bd141d8b7 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 9 Dec 2020 17:33:29 -0700 Subject: [PATCH 068/187] Added link to on-line build info --- src/MLIAP/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MLIAP/README b/src/MLIAP/README index 7841b7c158..21c34ade5c 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -46,3 +46,7 @@ to C++ code. Please do not run the cythonize script in the src/MLIAP folder. If you have done so by accident, you need to delete the generated .cpp and .h file(s) in the src/MLIAP folder or there may be problems during compilation. +More information on building LAMMPS with this package is here: + +https://lammps.sandia.gov/doc/html/Build_extras.html#mliap + From bf0acf9581a64aeb3147c57f971560ab5ebd007a Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 9 Dec 2020 17:38:31 -0700 Subject: [PATCH 069/187] Tried to distinguish MLIAP package with Python support from PYTHON package --- src/MLIAP/README | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/MLIAP/README b/src/MLIAP/README index 21c34ade5c..9179d9d02f 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -29,10 +29,13 @@ To see how this command can be used within a Python workflow to train machine-learning interatomic potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP>. -*Additional instructions for compiling PyTorch energy models* +*Additional instructions for building MLIAP with Python support enabled* -The *MLIAPPY* extension written by Nick Lubbers (LANL) -provides a coupling to PyTorch energy models. This should be automatically +The *mliappy* energy model requires that the MLIAP package +be compiled with Python support enabled. +This extension written by Nick Lubbers (LANL) +provides a coupling to PyTorch and other Python modules. +This should be automatically enabled by default if the prerequisite software is installed. It can be enforced during CMake configuration by setting the variable MLIAP_ENABLE_PYTHON=yes or for conventional build by adding -DMLIAP_PYTHON From dbdb1085129323f97729c57a94ac4327e1dcd892 Mon Sep 17 00:00:00 2001 From: Pablo Piaggi Date: Thu, 10 Dec 2020 15:18:48 -0500 Subject: [PATCH 070/187] update temp/csvr manual --- doc/src/fix_temp_csvr.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index 8faa6035cf..c5ca2ed5eb 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -124,6 +124,19 @@ temperature is calculated taking the bias into account, bias is removed from each atom, thermostatting is performed on the remaining thermal degrees of freedom, and the bias is added back in. +An important feature of these thermostats is that they have an +associated effective energy that is a contant of the motion. +The effective energy is the total energy (kinetic + potential) plus +the accumulated kinetic energy changes due to the thermostat. The +latter quantity is the global scalar computed by these fixes. This +feature is useful to check the integration of the equations of motion +against discretization errors. In other words, the conservation of +the effective energy can be used to choose an appropriate integration +:doc:`timestep `. This is similar to the usual paradigm of +checking the conservation of the total energy in the microcanonical +ensemble. + + ---------- Restart, fix_modify, output, run start/stop, minimize info @@ -153,7 +166,7 @@ These fixes are not invoked during :doc:`energy minimization `. These fixes compute a global scalar which can be accessed by various :doc:`output commands `. The scalar is the cumulative -energy change due to the fix. The scalar value calculated by this fix +kinetic energy change due to the fix. The scalar value calculated by this fix is "extensive". Restrictions From d913b5fadfac24d6b43f6298ed74b417483e4d25 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 11 Dec 2020 08:46:26 -0700 Subject: [PATCH 071/187] Fix Kokkos performance regression for small systems --- src/KOKKOS/atom_vec_kokkos.cpp | 16 ++++++++++++++++ src/KOKKOS/atom_vec_kokkos.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index e6caa59859..86f15b0b40 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -16,8 +16,11 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "comm_kokkos.h" +#include "error.h" #include "domain.h" +#define DELTA 10 + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -32,6 +35,19 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) no_border_vel_flag = 1; } +/* ---------------------------------------------------------------------- + roundup N so it is a multiple of DELTA + error if N exceeds 32-bit int, since will be used as arg to grow() +------------------------------------------------------------------------- */ + +bigint AtomVecKokkos::roundup(bigint n) +{ + if (n % DELTA) n = n/DELTA * DELTA + DELTA; + if (n > MAXSMALLINT) + error->one(FLERR,"Too many atoms created on one or more procs"); + return n; +} + /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 09f02f61e2..9fbf172535 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -36,6 +36,7 @@ class AtomVecKokkos : public AtomVec { public: AtomVecKokkos(class LAMMPS *); virtual ~AtomVecKokkos() {} + bigint roundup(bigint); virtual int pack_comm(int, int *, double *, int, int *); virtual int pack_comm_vel(int, int *, double *, int, int *); virtual void unpack_comm(int, int, double *); From b53f37a9ac9a7fbdb6b707d43b6c7b490549d507 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 12 Dec 2020 23:43:11 -0500 Subject: [PATCH 072/187] fix typo --- src/universe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universe.cpp b/src/universe.cpp index 3f58c4a074..a7fa8fc2e2 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -185,7 +185,7 @@ void Universe::add_world(char *str) nper = atoi(part.c_str()); } else { n = atoi(part.substr(0,found).c_str()); - nper = atoi(part.substr(found-1).c_str());\ + nper = atoi(part.substr(found+1).c_str()); } } From acce3c265ae02c8ae4755d1617686f5c8053ec69 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 13 Dec 2020 00:00:15 -0500 Subject: [PATCH 073/187] use C++ string operations --- src/KIM/kim_interactions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 5eb01d7ced..afb1391606 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -291,10 +291,10 @@ void KimInteractions::KIM_SET_TYPE_PARAMETERS(const std::string &input_line) con MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - if (ptr = strchr(line,'#')) *ptr = '\0'; - if (strspn(line," \t\n\r") == strlen(line)) continue; + auto trimmed = utils::trim_comment(line); + if (trimmed.find_first_not_of(" \t\n\r") == std::string::npos) continue; - words = utils::split_words(line); + words = utils::split_words(trimmed); if (key == "pair") { for (int ia = 0; ia < atom->ntypes; ++ia) { for (int ib = ia; ib < atom->ntypes; ++ib) From 524302e6e688c23caad353cb380b964dba6026c5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 13 Dec 2020 00:07:48 -0500 Subject: [PATCH 074/187] whitespace --- doc/src/lattice.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/lattice.rst b/doc/src/lattice.rst index e937541864..b87ddaaf70 100644 --- a/doc/src/lattice.rst +++ b/doc/src/lattice.rst @@ -254,9 +254,9 @@ in commands that use the spacings should be decipherable. Example commands for generating a Wurtzite crystal. The lattice constants approximate those of CdSe. The :math:`\sqrt{3}\times 1` orthorhombic supercell is used -with the x, y, and z directions oriented -along :math:`[\bar{1}\bar{2}30]`, -:math:`[10\bar{1}0]`, and :math:`[0001]`, respectively. +with the x, y, and z directions oriented +along :math:`[\bar{1}\bar{2}30]`, +:math:`[10\bar{1}0]`, and :math:`[0001]`, respectively. .. code-block:: LAMMPS From 7f29c56c8f20033385ddd92f0bd7d98dd0ecc1e5 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Mon, 14 Dec 2020 00:03:59 -0600 Subject: [PATCH 075/187] update for kim-api-2.2.1 --- cmake/Modules/Packages/KIM.cmake | 4 ++-- lib/kim/Install.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 42b7bb884d..91a48eb3a7 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -34,8 +34,8 @@ if(DOWNLOAD_KIM) enable_language(C) enable_language(Fortran) ExternalProject_Add(kim_build - URL https://s3.openkim.org/kim-api/kim-api-2.2.0.txz - URL_MD5 e7f944e1593cffd7444679a660607f6c + URL https://s3.openkim.org/kim-api/kim-api-2.2.1.txz + URL_MD5 ae1ddda2ef7017ea07934e519d023dca BINARY_DIR build CMAKE_ARGS ${CMAKE_REQUEST_PIC} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} diff --git a/lib/kim/Install.py b/lib/kim/Install.py index 3ebcb8e237..ae4b356ba9 100644 --- a/lib/kim/Install.py +++ b/lib/kim/Install.py @@ -18,13 +18,14 @@ parser = ArgumentParser(prog='Install.py', # settings thisdir = fullpath('.') -version = "2.2.0" +version = "2.2.1" # known checksums for different KIM-API versions. used to validate the download. checksums = { \ '2.1.2' : '6ac52e14ef52967fc7858220b208cba5', \ '2.1.3' : '6ee829a1bbba5f8b9874c88c4c4ebff8', \ '2.2.0' : 'e7f944e1593cffd7444679a660607f6c', \ + '2.2.1' : 'ae1ddda2ef7017ea07934e519d023dca', \ } From 65d1594474fabfcbdf4fee7c297b9a9242e6a7a1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Dec 2020 08:39:27 -0500 Subject: [PATCH 076/187] Fix typo and adjust grammar --- doc/src/fix_temp_csvr.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index c5ca2ed5eb..ea023c4e24 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -125,7 +125,7 @@ removed from each atom, thermostatting is performed on the remaining thermal degrees of freedom, and the bias is added back in. An important feature of these thermostats is that they have an -associated effective energy that is a contant of the motion. +associated effective energy that is a constant of motion. The effective energy is the total energy (kinetic + potential) plus the accumulated kinetic energy changes due to the thermostat. The latter quantity is the global scalar computed by these fixes. This From 17f8aed268e24f5947c2164e050a6941c491cc72 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Dec 2020 13:03:16 -0500 Subject: [PATCH 077/187] must not use MPI_COMM_WORLD inside of LAMMPS. value of "me" is already computed. --- src/USER-REAXC/reaxc_ffield.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/USER-REAXC/reaxc_ffield.cpp b/src/USER-REAXC/reaxc_ffield.cpp index e4826e78c3..5181415a9f 100644 --- a/src/USER-REAXC/reaxc_ffield.cpp +++ b/src/USER-REAXC/reaxc_ffield.cpp @@ -44,10 +44,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, int lgflag = control->lgflag; int errorflag = 1; double val; - MPI_Comm comm; - int me; - comm = MPI_COMM_WORLD; - MPI_Comm_rank(comm, &me); + int me = control->me; s = (char*) malloc(sizeof(char)*MAX_LINE); tmp = (char**) malloc(sizeof(char*)*MAX_TOKENS); From ac36fb8290fb5b12f7764527c694e69fcecf3e0c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Dec 2020 15:53:21 -0500 Subject: [PATCH 078/187] must not use MPI_COMM_WORLD to be compatible with multi-partition runs --- src/USER-NETCDF/dump_netcdf_mpiio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/USER-NETCDF/dump_netcdf_mpiio.cpp b/src/USER-NETCDF/dump_netcdf_mpiio.cpp index 5b83ab58ee..2067e14c22 100644 --- a/src/USER-NETCDF/dump_netcdf_mpiio.cpp +++ b/src/USER-NETCDF/dump_netcdf_mpiio.cpp @@ -292,7 +292,7 @@ void DumpNetCDFMPIIO::openfile() if (singlefile_opened) return; singlefile_opened = 1; - NCERRX( ncmpi_open(MPI_COMM_WORLD, filecurrent, NC_WRITE, MPI_INFO_NULL, + NCERRX( ncmpi_open(world, filecurrent, NC_WRITE, MPI_INFO_NULL, &ncid), filecurrent ); // dimensions @@ -372,7 +372,7 @@ void DumpNetCDFMPIIO::openfile() if (singlefile_opened) return; singlefile_opened = 1; - NCERRX( ncmpi_create(MPI_COMM_WORLD, filecurrent, NC_64BIT_DATA, + NCERRX( ncmpi_create(world, filecurrent, NC_64BIT_DATA, MPI_INFO_NULL, &ncid), filecurrent ); // dimensions @@ -748,7 +748,7 @@ void DumpNetCDFMPIIO::write() nme = count(); int *block_sizes = new int[comm->nprocs]; - MPI_Allgather(&nme, 1, MPI_INT, block_sizes, 1, MPI_INT, MPI_COMM_WORLD); + MPI_Allgather(&nme, 1, MPI_INT, block_sizes, 1, MPI_INT, world); blocki = 0; for (int i = 0; i < comm->me; i++) blocki += block_sizes[i]; delete [] block_sizes; From 231b40995fc5e637a525d7011c41ad021cf82f5d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Dec 2020 17:49:12 -0500 Subject: [PATCH 079/187] work around dump output issues with TAD --- src/REPLICA/tad.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index b2a4851d27..0fc611b307 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -554,7 +554,10 @@ void TAD::log_event(int ievent) timer->barrier_start(); modify->addstep_compute_all(update->ntimestep); update->integrate->setup_minimal(1); + // must reset whichflag so that computes won't fail. + update->whichflag = 1; output->write_dump(update->ntimestep); + update->whichflag = 0; timer->barrier_stop(); time_output += timer->get_wall(Timer::TOTAL); } From 4b69693b89a80f4849d565e12efbc07914ab078d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 14 Dec 2020 18:24:50 -0500 Subject: [PATCH 080/187] correct/improve warning messages related to per-atom properties --- src/atom_vec_hybrid.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 885299982b..8679b7383d 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -154,9 +154,9 @@ void AtomVecHybrid::process_args(int narg, char **arg) } if (mass_pertype && mass_peratom && comm->me == 0) - error->warning(FLERR, - "Atom_style hybrid defines both pertype and peratom masses " - "- both must be set, only peratom masses will be used"); + error->warning(FLERR, "Atom style hybrid defines both, per-type " + "and per-atom masses; both must be set, but only " + "per-atom masses will be used"); // free allstyles created by build_styles() @@ -216,8 +216,8 @@ void AtomVecHybrid::process_args(int narg, char **arg) char *dup = (char *) dupfield[idup]; ptr = strstr(concat_grow,dup); if ((ptr && strstr(ptr+1,dup)) && (comm->me == 0)) - error->warning(FLERR,fmt::format("Peratom {} is in multiple sub-styles " - "- must be used consistently",dup)); + error->warning(FLERR,fmt::format("Per-atom {} is used in multiple sub-" + "styles; must be used consistently",dup)); } delete [] concat_grow; From 40d260dcc6bbdbea23c9268065e3e5920d6d097e Mon Sep 17 00:00:00 2001 From: PabloPiaggi Date: Mon, 14 Dec 2020 18:45:46 -0500 Subject: [PATCH 081/187] Remove word kinetic --- doc/src/fix_temp_csvr.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index ea023c4e24..5e6074bc66 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -166,7 +166,7 @@ These fixes are not invoked during :doc:`energy minimization `. These fixes compute a global scalar which can be accessed by various :doc:`output commands `. The scalar is the cumulative -kinetic energy change due to the fix. The scalar value calculated by this fix +energy change due to the fix. The scalar value calculated by this fix is "extensive". Restrictions From a7fa4739f5a2de99c2ef55d0c3bfc7623b50c92b Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Tue, 15 Dec 2020 11:39:14 -0500 Subject: [PATCH 082/187] update reference --- doc/src/fix_bond_react.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/fix_bond_react.rst b/doc/src/fix_bond_react.rst index 15c0550ead..38f061e05f 100644 --- a/doc/src/fix_bond_react.rst +++ b/doc/src/fix_bond_react.rst @@ -616,8 +616,8 @@ reset_mol_ids = yes, custom_charges = no, molecule = off .. _Gissinger: -**(Gissinger)** Gissinger, Jensen and Wise, Polymer, 128, 211 (2017). +**(Gissinger)** Gissinger, Jensen and Wise, Polymer, 128, 211-217 (2017). .. _Gissinger2020: -**(Gissinger)** Gissinger, Jensen and Wise, Macromolecules (2020, in press). +**(Gissinger)** Gissinger, Jensen and Wise, Macromolecules, 53, 22, 9953–9961 (2020). From 3dea3188aa7b71e71e2070f58d10c133bf43121c Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Tue, 15 Dec 2020 12:14:03 -0700 Subject: [PATCH 083/187] Added a simple neural network potential --- examples/mliap/README | 8 +++ examples/mliap/in.mliap.pytorch.relu1hidden | 53 ++++++++++++++++++ examples/mliap/relu1hidden.mliap.pytorch | 18 ++++++ .../mliap/relu1hidden.mliap.pytorch.model.pkl | Bin 0 -> 4059 bytes 4 files changed, 79 insertions(+) create mode 100644 examples/mliap/in.mliap.pytorch.relu1hidden create mode 100644 examples/mliap/relu1hidden.mliap.pytorch create mode 100644 examples/mliap/relu1hidden.mliap.pytorch.model.pkl diff --git a/examples/mliap/README b/examples/mliap/README index 68b6f2e200..2641bdc975 100644 --- a/examples/mliap/README +++ b/examples/mliap/README @@ -72,3 +72,11 @@ or The resultant log.lammps output should be identical to that generated by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A. + +in.mliap.pytorch.relu1hidden +---------------------------- +This example demonstrates a simple neural network potential +using PyTorch and SNAP descriptors. It uses a ReLU activation +function with just 1 hidden layer. + +`lmp -in in.mliap.pytorch.relu1hidden -echo both` diff --git a/examples/mliap/in.mliap.pytorch.relu1hidden b/examples/mliap/in.mliap.pytorch.relu1hidden new file mode 100644 index 0000000000..f19ffb608d --- /dev/null +++ b/examples/mliap/in.mliap.pytorch.relu1hidden @@ -0,0 +1,53 @@ +# Demonstrate MLIAP interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable ny equal ${nrep} +variable nz equal ${nrep} + +boundary p p p + +lattice bcc $a +region box block 0 ${nx} 0 ${ny} 0 ${nz} +create_box 1 box +create_atoms 1 box + +mass 1 180.88 + +# choose potential + +include relu1hidden.mliap.pytorch + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} + diff --git a/examples/mliap/relu1hidden.mliap.pytorch b/examples/mliap/relu1hidden.mliap.pytorch new file mode 100644 index 0000000000..a2271cee39 --- /dev/null +++ b/examples/mliap/relu1hidden.mliap.pytorch @@ -0,0 +1,18 @@ +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay & +zbl ${zblcutinner} ${zblcutouter} & +mliap model mliappy relu1hidden.mliap.pytorch.model.pkl & +descriptor sna Ta06A.mliap.descriptor +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff * * mliap Ta + diff --git a/examples/mliap/relu1hidden.mliap.pytorch.model.pkl b/examples/mliap/relu1hidden.mliap.pytorch.model.pkl new file mode 100644 index 0000000000000000000000000000000000000000..49e70ca1a4f00345b5ce4ab4afb4d1e7549bba38 GIT binary patch literal 4059 zcmds4`+pSG6`v%Vg{(kCl&8gMDHyE8JbB0?Lj)9;=kQvJbf1&Vz-D&O%q$_0z((98 zAo36ev{p9(tQJ069#PQ94unTPBFaM%KDM$*v85mM^J(cv>4ScH&zYfwTK)i=ANHH` zxaWTFx#!+FH=Y%&3M>9-w8k5)F(O(}cFn}!IU3VR+RzdgaD(e1qYg6jJe@g?Gc>=V zDrzNUHF@q}vN!72{8f@6X*xK9!ALkP1q~&l>aM9;NYbRxI3;MfAbYR~P72@+#40M# zyOWH{&Ypf4MUALlHlMEOhNK!de7w43Ku$0aQ^JPALNd_>uK93B0=kIM)su@u1ODK` zYQGlp%8|%I9lBB2Tu(Q&RYbH7raQ^h-E&t*Q&f}ek#~`~ho?K5b;EB+-Vh^iTkj_8 zJ)XX34M+T;jxINY^dz@l)>5k?p;%bbp*Jb}c(U18rjx?Z_d98ySgA%dX?$3!(p}Jx z<^0|{_(7hW)g(J;bbr}O*nM)2%u>K7;D;joNVb+cK(^NQW7%57K-r=@NVfRgFIyDy zJWfVIj|Ehg*ug>C@O)Lxw~6KlBdWpnSJGTFB#5z{Q2b#RJiyreqz)eJz-EZeCf{Q7 zPyz}>D74uW*=&k!HYGNjQk%_Co6WF1PX?n?0K>n_B+OX&HP<8yU<9M^a2<^7Kw*@% zm}*I>lnoedhw#P>C9J!=nuJvox>=qs7;_sJR&jbn^DZiKL0O*dqqEfbD=HThdEMdhk!je}~LyBL8%qEYEDUF(_z>!ClqRSD@fNXcBCyTi# zssT>7!{fjh5q1DOxgD_>n={YTiK%SDz*!4$jf=zrVQGfF49KAKFrs*PQE5SONzsU* zLx&ZC6*w4;L6&>Z6ayU7S-APY{V(4PfBqgejs3@;zrMGO{hzG8wu$hA%b%xEUi^uP zGI#C3MMNRo`abD@{)-P$Hu;(Dh{;vl$EY_$*(XW<%h@A{!nr2$OXnYIM%kB|+lt7K z3nUQJy~n;qe#`#wG2z%XG>+%yyqRM5c&^-znC{>H9-=w&;xR;_^}ePu!Yi#PbG6qF zqnsXcoZ^|~?v1E7&tKb)dULS$F3QP?Ija$U<2^eO)6I*2P5Skh4mNY7bH>*xP`nt1vy4mpB;eDS3Nh`x#skCOaE=~hH@ z){fnX@tiq3%NTM?`?VqRGioTF@AG^2qn+zLoA~(t(MJBqEOa5{X+W8{Y%FA2x_o19#nQ86gk?Q>@C!3oulK+-oXUIPJ?_VGa#;25b z-+K?ACizqo?Wg(m3EFpltZ)JKz9qaBPZ@avW%H>G#9LUlIf*jAt8G<^VfsQ#BVzpU z@=sBpoR>>+&Cx~Hx@+nwU*_V3wNGuQ51~IV?tT&d&Ct5n5!2lqucBVa?%INK{IjcD z37_ftCZgcDpX!&tzK`~c^VV)d|M==%R=ss^I*+p1u;Cc`b8zeujXVF<2Gk3!4OFM` z_7$|=q`vJ8=^YyJqTMB@uPQ08d^UWP!Z`eIccEQ)XxZC{>Ao*pd5wNE8}0Eg6IMQR#~&oQWHr@^ z5FBOQ2kom5<2a6Y?k03pQC{LDP79aUTI2R`R6ks4fbzr*D}Dvz2?I9lLNvFi6py>- zPZpnzJyWQUU*%|B!l1ue^Khdl&^#C4Z$^8X%iM>^^)ynb_xfh4Kg4m-+kskt--3QSe_M zIp^&@a<(t~$YFnE|M8_cbjY~@e!6_jG274KrX^e6`2f+pbn+CU@42mqQ!qIJQ$(1G zNl(BucSZuHTL~8pm?6SUE8(*mVYUc!Vs`uFvD&A(3HYf9^X&HN3A=roZ?{iBv)d=H z-9Gv3_Q_8TxT1P1B)<{USnm*U_xE&Rj3P1PrZVVu#sbu66+*~vZ#uMme%7up@?*>H z5~WGATp+PltD+7nJG5G|O;@q#E=a&a5yCdzDx0oq(~a14qc&Zz>1x!cC~7q94@#h~ zv`H0#A!BzJtAj-yrmW7BNB{rSVsS}fY3Z#E*KKRj_PwP2`` z{?EC0eBaOgu!6$U!h(`pn%j)qockNTEZ6uDx$$@5N?RGMNWfDfBrt~wXuzLFD}PM} ztQ29DmA|JOVYLX)+&Ir`tOK$(0qaCqZy%6n?E|vGJ|NH82jqGCfNZo6$R;`9cFI9_ zMl2AE1=u4^r&lC<7~>OLht2K-^ny^mAxRHvN|ZJCI=sNnJU$^*uf*Pt?8&CXix?vR E-*|c0EdT%j literal 0 HcmV?d00001 From f7dc7e3f3f383b7897682bec02a4fba2dfee9166 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 14:31:40 -0500 Subject: [PATCH 084/187] add preset for use with PGI compilers (tested with version 20.11) --- cmake/presets/pgi.cmake | 16 ++++++++++++++++ doc/src/Build_basics.rst | 5 ++++- doc/src/Build_package.rst | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 cmake/presets/pgi.cmake diff --git a/cmake/presets/pgi.cmake b/cmake/presets/pgi.cmake new file mode 100644 index 0000000000..b34cb05331 --- /dev/null +++ b/cmake/presets/pgi.cmake @@ -0,0 +1,16 @@ +# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes) + +set(CMAKE_CXX_COMPILER "pgc++" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "pgcc" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER "pgfortran" CACHE STRING "" FORCE) +set(MPI_CXX "pgc++" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) +unset(HAVE_OMP_H_INCLUDE CACHE) + +set(OpenMP_C "pgcc" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-mp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_CXX "pgc++" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-mp" CACHE STRING "" FORCE) +set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE) diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 8f40d3e5ba..cb6bd9f6aa 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -236,12 +236,15 @@ LAMMPS. cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort # Building with LLVM/Clang Compilers: cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_Fortran_COMPILER=flang + # Building with PGI/Nvidia Compilers: + cmake ../cmake -DCMAKE_C_COMPILER=pgcc -DCMAKE_CXX_COMPILER=pgc++ -DCMAKE_Fortran_COMPILER=pgfortran For compiling with the Clang/LLVM compilers a CMake preset is provided that can be loaded with `-C ../cmake/presets/clang.cmake`. Similarly, `-C ../cmake/presets/intel.cmake` should switch the compiler - toolchain to the Intel compilers. + toolchain to the Intel compilers and `-C ../cmake/presets/pgi.cmake` + should switch the compiler to the PGI compilers. In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add compiler flags to tune for optimal performance on given hosts. By diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index 18d9ab5f19..63312d7aa8 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -1,4 +1,5 @@ Include packages in build + ========================= In LAMMPS, a package is a group of files that enable a specific set of @@ -160,6 +161,7 @@ one of them as a starting point and customize it to your needs. cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake # change settings to use the Clang compilers by default cmake -C ../cmake/presets/gcc.cmake [OPTIONS] ../cmake # change settings to use the GNU compilers by default cmake -C ../cmake/presets/intel.cmake [OPTIONS] ../cmake # change settings to use the Intel compilers by default + cmake -C ../cmake/presets/pgi.cmake [OPTIONS] ../cmake # change settings to use the PGI compilers by default cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages mingw64-cmake -C ../cmake/presets/mingw-cross.cmake [OPTIONS] ../cmake # compile with MinGW cross compilers From 65dc5c0351139ee381376feef7547e5cabb63829 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 14:32:18 -0500 Subject: [PATCH 085/187] work around PGI compiler issues --- cmake/CMakeLists.txt | 1 + src/fmt/os.h | 4 ++++ src/lmptype.h | 2 ++ unittest/fortran/test_fortran_commands.f90 | 6 +++--- unittest/fortran/test_fortran_create.f90 | 8 +++----- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 42e6d12ffb..60b1bcfc0a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -220,6 +220,7 @@ if(BUILD_OMP) endif() if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0))) # GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts. diff --git a/src/fmt/os.h b/src/fmt/os.h index d44ea0c904..823173c8e3 100644 --- a/src/fmt/os.h +++ b/src/fmt/os.h @@ -375,7 +375,11 @@ struct ostream_params { }; } // namespace detail +#if defined(__PGI) +static detail::buffer_size buffer_size; +#else static constexpr detail::buffer_size buffer_size; +#endif // A fast output stream which is not thread-safe. class ostream final : private detail::buffer { diff --git a/src/lmptype.h b/src/lmptype.h index e5dba94be0..264b93a329 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -268,6 +268,8 @@ The typecasts prevent compiler warnings about possible truncation issues. # define _noopt __attribute__((optnone)) #elif defined(__INTEL_COMPILER) # define _noopt +#elif defined(__PGI) +# define _noopt #elif defined(__GNUC__) # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) # if defined(_FORTIFY_SOURCE) && (_FORTIFY_SOURCE > 0) diff --git a/unittest/fortran/test_fortran_commands.f90 b/unittest/fortran/test_fortran_commands.f90 index 748bc5774a..b5cffe698f 100644 --- a/unittest/fortran/test_fortran_commands.f90 +++ b/unittest/fortran/test_fortran_commands.f90 @@ -1,12 +1,12 @@ MODULE keepcmds USE liblammps TYPE(LAMMPS) :: lmp - CHARACTER(len=*), DIMENSION(*), PARAMETER :: demo_input = & + CHARACTER(len=40), DIMENSION(3), PARAMETER :: demo_input = & [ CHARACTER(len=40) :: & 'region box block 0 $x 0 2 0 2', & 'create_box 1 box', & 'create_atoms 1 single 1.0 1.0 ${zpos}' ] - CHARACTER(len=*), DIMENSION(*), PARAMETER :: cont_input = & + CHARACTER(len=40), DIMENSION(2), PARAMETER :: cont_input = & [ CHARACTER(len=40) :: & 'create_atoms 1 single &', & ' 0.2 0.1 0.1' ] @@ -19,7 +19,7 @@ FUNCTION f_lammps_with_args() BIND(C, name="f_lammps_with_args") IMPLICIT NONE TYPE(c_ptr) :: f_lammps_with_args - CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = & + CHARACTER(len=12), DIMENSION(12), PARAMETER :: args = & [ CHARACTER(len=12) :: 'liblammps', '-log', 'none', & '-echo','screen','-nocite','-var','zpos','1.5','-var','x','2'] diff --git a/unittest/fortran/test_fortran_create.f90 b/unittest/fortran/test_fortran_create.f90 index 694646e9bd..e1df7502cb 100644 --- a/unittest/fortran/test_fortran_create.f90 +++ b/unittest/fortran/test_fortran_create.f90 @@ -22,7 +22,7 @@ FUNCTION f_lammps_no_mpi_with_args() BIND(C, name="f_lammps_no_mpi_with_args") IMPLICIT NONE TYPE(c_ptr) :: f_lammps_no_mpi_with_args - CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = & + CHARACTER(len=12), DIMENSION(4), PARAMETER :: args = & [ CHARACTER(len=12) :: 'liblammps', '-log', 'none', '-nocite' ] lmp = lammps(args) @@ -54,7 +54,7 @@ FUNCTION f_lammps_open_with_args() BIND(C, name="f_lammps_open_with_args") TYPE(c_ptr) :: f_lammps_open_with_args INTEGER :: color, key, ierr - CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = & + CHARACTER(len=12), DIMENSION(4), PARAMETER :: args = & [ CHARACTER(len=12) :: 'liblammps', '-log', 'none', '-nocite' ] color = 2 @@ -73,7 +73,7 @@ SUBROUTINE f_lammps_close() BIND(C, name="f_lammps_close") CALL lmp%close() lmp%handle = c_null_ptr END SUBROUTINE f_lammps_close - + FUNCTION f_lammps_get_comm() BIND(C, name="f_lammps_get_comm") USE liblammps USE keepcreate, ONLY: mycomm @@ -82,5 +82,3 @@ FUNCTION f_lammps_get_comm() BIND(C, name="f_lammps_get_comm") f_lammps_get_comm = mycomm END FUNCTION f_lammps_get_comm - - From 2a763d17132d40d227aacb07a1c44d3756865f0b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 15:00:31 -0500 Subject: [PATCH 086/187] PythonCommands test fails without exceptions enabled --- unittest/python/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index 47fdbbfb2d..575b64252b 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -57,10 +57,13 @@ if (Python_EXECUTABLE) WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(PythonOpen PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}") - add_test(NAME PythonCommands - COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-commands.py -v - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_tests_properties(PythonCommands PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}") + # some of the tests in this file will fail without exceptions enabled + if(LAMMPS_EXCEPTIONS) + add_test(NAME PythonCommands + COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-commands.py -v + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + set_tests_properties(PythonCommands PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}") + endif() add_test(NAME PythonNumpy COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-numpy.py -v From aca2eefce595a6366a4fdab7a2b0c26987adb39b Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 15:11:21 -0500 Subject: [PATCH 087/187] Transform LAMMPS Python module into package - Moves lammps.py into its own package - Imports entire module in __init__.py - Changes both how legacy and CMake build systems install - Added traditional setup.py for Python-only installation Note: the CMake install target runs setup.py build and install in a way that produces files in CMAKE_BINARY_DIR/python instead of python/build. This is to maintain out-of-source compilation support. --- cmake/CMakeLists.txt | 9 ++---- python/install.py | 54 +++++++++++++++++++---------------- python/lammps/__init__.py | 1 + python/{ => lammps}/lammps.py | 0 python/setup.py | 26 +++++++++++++++++ src/Makefile | 2 +- 6 files changed, 60 insertions(+), 32 deletions(-) create mode 100644 python/lammps/__init__.py rename python/{ => lammps}/lammps.py (100%) create mode 100644 python/setup.py diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 42e6d12ffb..854937dec8 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -661,7 +661,7 @@ if(BUILD_SHARED_LIBS) add_custom_target( install-python ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h - -m ${LAMMPS_PYTHON_DIR}/lammps.py + -p ${LAMMPS_PYTHON_DIR}/lammps -l ${CMAKE_BINARY_DIR}/liblammps${CMAKE_SHARED_LIBRARY_SUFFIX} WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR} COMMENT "Installing LAMMPS Python module") @@ -691,11 +691,8 @@ if(BUILD_SHARED_LIBS OR PKG_PYTHON) find_package(Python COMPONENTS Interpreter) endif() if (Python_EXECUTABLE) - execute_process(COMMAND ${Python_EXECUTABLE} - -c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE) - set(PYTHON_INSTDIR ${PYTHON_DEFAULT_INSTDIR} CACHE PATH "Installation folder for LAMMPS Python module") - install(FILES ${LAMMPS_PYTHON_DIR}/lammps.py DESTINATION ${PYTHON_INSTDIR}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python) + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})") endif() endif() diff --git a/python/install.py b/python/install.py index 7f7062103a..a6b69c1ee6 100644 --- a/python/install.py +++ b/python/install.py @@ -1,42 +1,42 @@ #!/usr/bin/env python """ -Installer script to install the LAMMPS python module and the corresponding +Installer script to install the LAMMPS python package and the corresponding shared library into either the system-wide site-packages tree, or - failing that - into the corresponding user tree. Called from the 'install-python' build target in the conventional and CMake based build systems """ -# copy LAMMPS shared library and lammps.py to system dirs +# copy LAMMPS shared library and lammps package to system dirs from __future__ import print_function import sys,os,shutil from argparse import ArgumentParser parser = ArgumentParser(prog='install.py', - description='LAMMPS python module installer script') + description='LAMMPS python package installer script') -parser.add_argument("-m", "--module", required=True, - help="path to the source of the LAMMPS Python module") +parser.add_argument("-p", "--package", required=True, + help="path to the LAMMPS Python package") parser.add_argument("-l", "--lib", required=True, help="path to the compiled LAMMPS shared library") parser.add_argument("-v", "--version", required=True, help="path to the LAMMPS version.h header file") parser.add_argument("-d","--dir", - help="Legacy custom installation folder selection for module and library") + help="Legacy custom installation folder selection for package and library") args = parser.parse_args() # validate arguments and make paths absolute -if args.module: - if not os.path.exists(args.module): - print( "ERROR: LAMMPS module file %s does not exist" % args.module) +if args.package: + if not os.path.exists(args.package): + print( "ERROR: LAMMPS package %s does not exist" % args.package) parser.print_help() sys.exit(1) else: - args.module = os.path.abspath(args.module) + args.package = os.path.abspath(args.package) if args.lib: if not os.path.exists(args.lib): @@ -66,9 +66,9 @@ if args.dir: # without any special processing or additional steps to that folder if args.dir: - print("Copying LAMMPS Python module to custom folder %s" % args.dir) + print("Copying LAMMPS Python package to custom folder %s" % args.dir) try: - shutil.copyfile(args.module, os.path.join(args.dir,'lammps.py')) + shutil.copytree(args.package, os.path.join(args.dir,'lammps')) except shutil.Error: pass # fail silently @@ -81,15 +81,19 @@ if args.dir: sys.exit() # extract version string from header -fp = open(args.version,'r') -txt=fp.read().split('"')[1].split() -verstr=txt[0]+txt[1]+txt[2] -fp.close() +def get_lammps_version(header): + with open(header, 'r') as f: + line = f.readline() + start_pos = line.find('"')+1 + end_pos = line.find('"', start_pos) + return "".join(line[start_pos:end_pos].split()) -print("Installing LAMMPS Python module version %s into site-packages folder" % verstr) +verstr = get_lammps_version(args.version) -# we need to switch to the folder of the python module -os.chdir(os.path.dirname(args.module)) +print("Installing LAMMPS Python package version %s into site-packages folder" % verstr) + +# we need to switch to the folder of the python package +os.chdir(os.path.dirname(args.package)) from distutils.core import setup from distutils.sysconfig import get_python_lib @@ -103,10 +107,10 @@ try: author = "Steve Plimpton", author_email = "sjplimp@sandia.gov", url = "https://lammps.sandia.gov", - description = "LAMMPS Molecular Dynamics Python module", + description = "LAMMPS Molecular Dynamics Python package", license = "GPL", - py_modules = ["lammps"], - data_files = [(get_python_lib(), [args.lib])]) + packages=['lammps'], + data_files = [(os.path.join(get_python_lib(), 'lammps'), [args.lib])]) except: tryuser=True print ("Installation into global site-packages folder failed.\nTrying user folder %s now." % site.USER_SITE) @@ -119,9 +123,9 @@ if tryuser: author = "Steve Plimpton", author_email = "sjplimp@sandia.gov", url = "https://lammps.sandia.gov", - description = "LAMMPS Molecular Dynamics Python module", + description = "LAMMPS Molecular Dynamics Python package", license = "GPL", - py_modules = ["lammps"], - data_files = [(site.USER_SITE, [args.lib])]) + packages=['lammps'], + data_files = [(os.path.join(site.USER_SITE, 'lammps'), [args.lib])]) except: print("Installation into user site package folder failed.") diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py new file mode 100644 index 0000000000..2f29663b75 --- /dev/null +++ b/python/lammps/__init__.py @@ -0,0 +1 @@ +from .lammps import * diff --git a/python/lammps.py b/python/lammps/lammps.py similarity index 100% rename from python/lammps.py rename to python/lammps/lammps.py diff --git a/python/setup.py b/python/setup.py new file mode 100644 index 0000000000..9be04138d5 --- /dev/null +++ b/python/setup.py @@ -0,0 +1,26 @@ +# this only installs the LAMMPS python package +# it assumes the LAMMPS shared library is already installed +from distutils.core import setup +import os + +LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__)) +LAMMPS_DIR = os.path.dirname(LAMMPS_PYTHON_DIR) +LAMMPS_SOURCE_DIR = os.path.join(LAMMPS_DIR, 'src') + +def get_lammps_version(): + with open(os.path.join(LAMMPS_SOURCE_DIR, 'version.h'), 'r') as f: + line = f.readline() + start_pos = line.find('"')+1 + end_pos = line.find('"', start_pos) + return "".join(line[start_pos:end_pos].split()) + +setup( + name = "lammps", + version = get_lammps_version(), + author = "Steve Plimpton", + author_email = "sjplimp@sandia.gov", + url = "https://lammps.sandia.gov", + description = "LAMMPS Molecular Dynamics Python package", + license = "GPL", + packages=["lammps"] +) diff --git a/src/Makefile b/src/Makefile index 149dedd35b..7a5e1aa728 100644 --- a/src/Makefile +++ b/src/Makefile @@ -278,7 +278,7 @@ mpi-stubs: sinclude ../lib/python/Makefile.lammps install-python: @$(PYTHON) ../python/install.py -v ../src/version.h \ - -m ../python/lammps.py -l ../src/liblammps.so + -p ../python/lammps -l ../src/liblammps.so # Create a tarball of src dir and packages From 588198c5dda256ce6b0cd72d7b1953e86b7fca92 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 16:07:49 -0500 Subject: [PATCH 088/187] Add --embed to python-config for legacy build Newer versions of Python (v3.9) do not include the python library in their python-config --ldflags unless you also pass --embed. --- lib/python/Makefile.lammps | 2 +- lib/python/Makefile.lammps.python3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/python/Makefile.lammps b/lib/python/Makefile.lammps index 4289674e99..e4afa70456 100644 --- a/lib/python/Makefile.lammps +++ b/lib/python/Makefile.lammps @@ -2,6 +2,6 @@ # See the README file for more explanation python_SYSINC = $(shell which python-config > /dev/null 2>&1 && python-config --includes || :) -python_SYSLIB = $(shell which python-config > /dev/null 2>&1 && python-config --ldflags || :) +python_SYSLIB = $(shell which python-config > /dev/null 2>&1 && python-config --ldflags --embed > /dev/null 2>&1 && python-config --ldflags --embed || (which python-config > /dev/null 2>&1 && python-config --ldflags || :) ) python_SYSPATH = PYTHON=python diff --git a/lib/python/Makefile.lammps.python3 b/lib/python/Makefile.lammps.python3 index 5c43b45ff6..d37e822327 100644 --- a/lib/python/Makefile.lammps.python3 +++ b/lib/python/Makefile.lammps.python3 @@ -2,6 +2,6 @@ # See the README file for more explanation python_SYSINC = $(shell which python3-config > /dev/null 2>&1 && python3-config --includes || (which python-config > /dev/null 2>&1 && python-config --includes || :)) -python_SYSLIB = $(shell which python3-config > /dev/null 2>&1 && python3-config --ldflags || (which python-config > /dev/null 2>&1 && python-config --ldflags || :)) +python_SYSLIB = $(shell which python3-config > /dev/null 2>&1 && python3-config --ldflags --embed > /dev/null 2>&1 && python3-config --ldflags --embed || (which python3-config > /dev/null 2>&1 && python3-config --ldflags || (which python-config > /dev/null 2>&1 && python-config --ldflags || :) ) ) python_SYSPATH = PYTHON=$(shell which python3 > /dev/null 2>&1 && echo python3 || echo python) From b390c1e3d34c599d77abe3fb418cb5a201c55491 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 16:15:16 -0500 Subject: [PATCH 089/187] Split lammps.py into core.py and pylammps.py --- python/lammps/__init__.py | 3 +- python/lammps/{lammps.py => core.py} | 858 +------------------------- python/lammps/pylammps.py | 870 +++++++++++++++++++++++++++ 3 files changed, 877 insertions(+), 854 deletions(-) rename python/lammps/{lammps.py => core.py} (73%) create mode 100644 python/lammps/pylammps.py diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index 2f29663b75..37773d84a5 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -1 +1,2 @@ -from .lammps import * +from .core import * +from .pylammps import * diff --git a/python/lammps/lammps.py b/python/lammps/core.py similarity index 73% rename from python/lammps/lammps.py rename to python/lammps/core.py index b74e111dc6..14b727e59a 100644 --- a/python/lammps/lammps.py +++ b/python/lammps/core.py @@ -10,28 +10,21 @@ # # See the README file in the top-level LAMMPS directory. # ------------------------------------------------------------------------- -# Python wrappers for the LAMMPS library via ctypes +# Python wrapper for the LAMMPS library via ctypes # for python2/3 compatibility from __future__ import print_function -# imports for simple LAMMPS python wrapper module "lammps" - -import sys,traceback,types +import os +import sys +import traceback +import types import warnings from ctypes import * from os.path import dirname,abspath,join from inspect import getsourcefile -# imports for advanced LAMMPS python wrapper modules "PyLammps" and "IPyLammps" - -from collections import namedtuple -import os -import select -import re -import sys - # various symbolic constants to be used # in certain calls to select data formats LAMMPS_AUTODETECT = None @@ -2083,844 +2076,3 @@ class numpy_wrapper: a = np.frombuffer(ptr.contents) a.shape = (nelem, dim) return a - - -# ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- - -################################################################################ -# Alternative Python Wrapper -# Written by Richard Berger -################################################################################ - -class OutputCapture(object): - """ Utility class to capture LAMMPS library output """ - - def __init__(self): - self.stdout_pipe_read, self.stdout_pipe_write = os.pipe() - self.stdout_fd = 1 - - def __enter__(self): - self.stdout = os.dup(self.stdout_fd) - os.dup2(self.stdout_pipe_write, self.stdout_fd) - return self - - def __exit__(self, type, value, tracebac): - os.dup2(self.stdout, self.stdout_fd) - os.close(self.stdout) - os.close(self.stdout_pipe_read) - os.close(self.stdout_pipe_write) - - # check if we have more to read from the pipe - def more_data(self, pipe): - r, _, _ = select.select([pipe], [], [], 0) - return bool(r) - - # read the whole pipe - def read_pipe(self, pipe): - out = "" - while self.more_data(pipe): - out += os.read(pipe, 1024).decode() - return out - - @property - def output(self): - return self.read_pipe(self.stdout_pipe_read) - -# ------------------------------------------------------------------------- - -class Variable(object): - def __init__(self, pylammps_instance, name, style, definition): - self._pylmp = pylammps_instance - self.name = name - self.style = style - self.definition = definition.split() - - @property - def value(self): - if self.style == 'atom': - return list(self._pylmp.lmp.extract_variable(self.name, "all", 1)) - else: - value = self._pylmp.lmp_print('"${%s}"' % self.name).strip() - try: - return float(value) - except ValueError: - return value - -# ------------------------------------------------------------------------- - -class AtomList(object): - """ - A dynamic list of atoms that returns either an :py:class:`Atom` or - :py:class:`Atom2D` instance for each atom. Instances are only allocated - when accessed. - - :ivar natoms: total number of atoms - :ivar dimensions: number of dimensions in system - """ - def __init__(self, pylammps_instance): - self._pylmp = pylammps_instance - self.natoms = self._pylmp.system.natoms - self.dimensions = self._pylmp.system.dimensions - self._loaded = {} - - def __getitem__(self, index): - """ - Return Atom with given local index - - :param index: Local index of atom - :type index: int - :rtype: Atom or Atom2D - """ - if index not in self._loaded: - if self.dimensions == 2: - atom = Atom2D(self._pylmp, index + 1) - else: - atom = Atom(self._pylmp, index + 1) - self._loaded[index] = atom - return self._loaded[index] - - def __len__(self): - return self.natoms - - -# ------------------------------------------------------------------------- - -class Atom(object): - """ - A wrapper class then represents a single atom inside of LAMMPS - - It provides access to properties of the atom and allows you to change some of them. - """ - def __init__(self, pylammps_instance, index): - self._pylmp = pylammps_instance - self.index = index - - @property - def id(self): - """ - Return the atom ID - - :type: int - """ - return int(self._pylmp.eval("id[%d]" % self.index)) - - @property - def type(self): - """ - Return the atom type - - :type: int - """ - return int(self._pylmp.eval("type[%d]" % self.index)) - - @property - def mol(self): - """ - Return the atom molecule index - - :type: int - """ - return self._pylmp.eval("mol[%d]" % self.index) - - @property - def mass(self): - """ - Return the atom mass - - :type: float - """ - return self._pylmp.eval("mass[%d]" % self.index) - - @property - def position(self): - """ - :getter: Return position of atom - :setter: Set position of atom - :type: tuple (float, float, float) - """ - return (self._pylmp.eval("x[%d]" % self.index), - self._pylmp.eval("y[%d]" % self.index), - self._pylmp.eval("z[%d]" % self.index)) - - @position.setter - def position(self, value): - """ - :getter: Return velocity of atom - :setter: Set velocity of atom - :type: tuple (float, float, float) - """ - self._pylmp.set("atom", self.index, "x", value[0]) - self._pylmp.set("atom", self.index, "y", value[1]) - self._pylmp.set("atom", self.index, "z", value[2]) - - @property - def velocity(self): - return (self._pylmp.eval("vx[%d]" % self.index), - self._pylmp.eval("vy[%d]" % self.index), - self._pylmp.eval("vz[%d]" % self.index)) - - @velocity.setter - def velocity(self, value): - self._pylmp.set("atom", self.index, "vx", value[0]) - self._pylmp.set("atom", self.index, "vy", value[1]) - self._pylmp.set("atom", self.index, "vz", value[2]) - - @property - def force(self): - """ - Return the total force acting on the atom - - :type: tuple (float, float, float) - """ - return (self._pylmp.eval("fx[%d]" % self.index), - self._pylmp.eval("fy[%d]" % self.index), - self._pylmp.eval("fz[%d]" % self.index)) - - @property - def charge(self): - """ - Return the atom charge - - :type: float - """ - return self._pylmp.eval("q[%d]" % self.index) - -# ------------------------------------------------------------------------- - -class Atom2D(Atom): - """ - A wrapper class then represents a single 2D atom inside of LAMMPS - - Inherits all properties from the :py:class:`Atom` class, but returns 2D versions - of position, velocity, and force. - - It provides access to properties of the atom and allows you to change some of them. - """ - def __init__(self, pylammps_instance, index): - super(Atom2D, self).__init__(pylammps_instance, index) - - @property - def position(self): - """ - :getter: Return position of atom - :setter: Set position of atom - :type: tuple (float, float) - """ - return (self._pylmp.eval("x[%d]" % self.index), - self._pylmp.eval("y[%d]" % self.index)) - - @position.setter - def position(self, value): - self._pylmp.set("atom", self.index, "x", value[0]) - self._pylmp.set("atom", self.index, "y", value[1]) - - @property - def velocity(self): - """ - :getter: Return velocity of atom - :setter: Set velocity of atom - :type: tuple (float, float) - """ - return (self._pylmp.eval("vx[%d]" % self.index), - self._pylmp.eval("vy[%d]" % self.index)) - - @velocity.setter - def velocity(self, value): - self._pylmp.set("atom", self.index, "vx", value[0]) - self._pylmp.set("atom", self.index, "vy", value[1]) - - @property - def force(self): - """ - Return the total force acting on the atom - - :type: tuple (float, float) - """ - return (self._pylmp.eval("fx[%d]" % self.index), - self._pylmp.eval("fy[%d]" % self.index)) - -# ------------------------------------------------------------------------- - -class variable_set: - def __init__(self, name, variable_dict): - self._name = name - array_pattern = re.compile(r"(?P.+)\[(?P[0-9]+)\]") - - for key, value in variable_dict.items(): - m = array_pattern.match(key) - if m: - g = m.groupdict() - varname = g['arr'] - idx = int(g['index']) - if varname not in self.__dict__: - self.__dict__[varname] = {} - self.__dict__[varname][idx] = value - else: - self.__dict__[key] = value - - def __str__(self): - return "{}({})".format(self._name, ','.join(["{}={}".format(k, self.__dict__[k]) for k in self.__dict__.keys() if not k.startswith('_')])) - - def __repr__(self): - return self.__str__() - -# ------------------------------------------------------------------------- - -def get_thermo_data(output): - """ traverse output of runs and extract thermo data columns """ - if isinstance(output, str): - lines = output.splitlines() - else: - lines = output - - runs = [] - columns = [] - in_run = False - current_run = {} - - for line in lines: - if line.startswith("Per MPI rank memory allocation"): - in_run = True - elif in_run and len(columns) == 0: - # first line after memory usage are column names - columns = line.split() - - current_run = {} - - for col in columns: - current_run[col] = [] - - elif line.startswith("Loop time of "): - in_run = False - columns = None - thermo_data = variable_set('ThermoData', current_run) - r = {'thermo' : thermo_data } - runs.append(namedtuple('Run', list(r.keys()))(*list(r.values()))) - elif in_run and len(columns) > 0: - items = line.split() - # Convert thermo output and store it. - # It must have the same number of columns and - # all of them must be convertible to floats. - # Otherwise we ignore the line - if len(items) == len(columns): - try: - values = [float(x) for x in items] - for i, col in enumerate(columns): - current_run[col].append(values[i]) - except ValueError: - pass - - return runs - -# ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- - -class PyLammps(object): - """ - This is a Python wrapper class around the lower-level - :py:class:`lammps` class, exposing a more Python-like, - object-oriented interface for prototyping system inside of IPython and - Jupyter notebooks. - - It either creates its own instance of :py:class:`lammps` or can be - initialized with an existing instance. The arguments are the same of the - lower-level interface. The original interface can still be accessed via - :py:attr:`PyLammps.lmp`. - - :param name: "machine" name of the shared LAMMPS library ("mpi" loads ``liblammps_mpi.so``, "" loads ``liblammps.so``) - :type name: string - :param cmdargs: list of command line arguments to be passed to the :cpp:func:`lammps_open` function. The executable name is automatically added. - :type cmdargs: list - :param ptr: pointer to a LAMMPS C++ class instance when called from an embedded Python interpreter. None means load symbols from shared library. - :type ptr: pointer - :param comm: MPI communicator (as provided by `mpi4py `_). ``None`` means use ``MPI_COMM_WORLD`` implicitly. - :type comm: MPI_Comm - - :ivar lmp: instance of original LAMMPS Python interface - :vartype lmp: :py:class:`lammps` - - :ivar runs: list of completed runs, each storing the thermo output - :vartype run: list - """ - - def __init__(self, name="", cmdargs=None, ptr=None, comm=None): - self.has_echo = False - - if cmdargs: - if '-echo' in cmdargs: - idx = cmdargs.index('-echo') - # ensures that echo line is ignored during output capture - self.has_echo = idx+1 < len(cmdargs) and cmdargs[idx+1] in ('screen', 'both') - - if ptr: - if isinstance(ptr,PyLammps): - self.lmp = ptr.lmp - elif isinstance(ptr,lammps): - self.lmp = ptr - else: - self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=ptr,comm=comm) - else: - self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=None,comm=comm) - print("LAMMPS output is captured by PyLammps wrapper") - self._cmd_history = [] - self.runs = [] - - def __del__(self): - if self.lmp: self.lmp.close() - self.lmp = None - - def close(self): - """Explicitly delete a LAMMPS instance - - This is a wrapper around the :py:meth:`lammps.close` of the Python interface. - """ - if self.lmp: self.lmp.close() - self.lmp = None - - def version(self): - """Return a numerical representation of the LAMMPS version in use. - - This is a wrapper around the :py:meth:`lammps.version` function of the Python interface. - - :return: version number - :rtype: int - """ - return self.lmp.version() - - def file(self, file): - """Read LAMMPS commands from a file. - - This is a wrapper around the :py:meth:`lammps.file` function of the Python interface. - - :param path: Name of the file/path with LAMMPS commands - :type path: string - """ - self.lmp.file(file) - - def write_script(self, filepath): - """ - Write LAMMPS script file containing all commands executed up until now - - :param filepath: path to script file that should be written - :type filepath: string - """ - with open(filepath, "w") as f: - for cmd in self._cmd_history: - print(cmd, file=f) - - def command(self, cmd): - """ - Execute LAMMPS command - - All commands executed will be stored in a command history which can be - written to a file using :py:meth:`PyLammps.write_script()` - - :param cmd: command string that should be executed - :type: cmd: string - """ - self.lmp.command(cmd) - self._cmd_history.append(cmd) - - def run(self, *args, **kwargs): - """ - Execute LAMMPS run command with given arguments - - All thermo output during the run is captured and saved as new entry in - :py:attr:`PyLammps.runs`. The latest run can be retrieved by - :py:attr:`PyLammps.last_run`. - """ - output = self.__getattr__('run')(*args, **kwargs) - - comm = self.lmp.get_mpi_comm() - if comm: - output = self.lmp.comm.bcast(output, root=0) - - self.runs += get_thermo_data(output) - return output - - @property - def last_run(self): - """ - Return data produced of last completed run command - - :getter: Returns an object containing information about the last run command - :type: dict - """ - if len(self.runs) > 0: - return self.runs[-1] - return None - - @property - def atoms(self): - """ - All atoms of this LAMMPS instance - - :getter: Returns a list of atoms currently in the system - :type: AtomList - """ - return AtomList(self) - - @property - def system(self): - """ - The system state of this LAMMPS instance - - :getter: Returns an object with properties storing the current system state - :type: namedtuple - """ - output = self.info("system") - d = self._parse_info_system(output) - return namedtuple('System', d.keys())(*d.values()) - - @property - def communication(self): - """ - The communication state of this LAMMPS instance - - :getter: Returns an object with properties storing the current communication state - :type: namedtuple - """ - output = self.info("communication") - d = self._parse_info_communication(output) - return namedtuple('Communication', d.keys())(*d.values()) - - @property - def computes(self): - """ - The list of active computes of this LAMMPS instance - - :getter: Returns a list of computes that are currently active in this LAMMPS instance - :type: list - """ - output = self.info("computes") - return self._parse_element_list(output) - - @property - def dumps(self): - """ - The list of active dumps of this LAMMPS instance - - :getter: Returns a list of dumps that are currently active in this LAMMPS instance - :type: list - """ - output = self.info("dumps") - return self._parse_element_list(output) - - @property - def fixes(self): - """ - The list of active fixes of this LAMMPS instance - - :getter: Returns a list of fixes that are currently active in this LAMMPS instance - :type: list - """ - output = self.info("fixes") - return self._parse_element_list(output) - - @property - def groups(self): - """ - The list of active atom groups of this LAMMPS instance - - :getter: Returns a list of atom groups that are currently active in this LAMMPS instance - :type: list - """ - output = self.info("groups") - return self._parse_groups(output) - - @property - def variables(self): - """ - Returns a dictionary of all variables defined in the current LAMMPS instance - - :getter: Returns a dictionary of all variables that are defined in this LAMMPS instance - :type: dict - """ - output = self.info("variables") - vars = {} - for v in self._parse_element_list(output): - vars[v['name']] = Variable(self, v['name'], v['style'], v['def']) - return vars - - def eval(self, expr): - """ - Evaluate expression - - :param expr: the expression string that should be evaluated inside of LAMMPS - :type expr: string - - :return: the value of the evaluated expression - :rtype: float if numeric, string otherwise - """ - value = self.lmp_print('"$(%s)"' % expr).strip() - try: - return float(value) - except ValueError: - return value - - def _split_values(self, line): - return [x.strip() for x in line.split(',')] - - def _get_pair(self, value): - return [x.strip() for x in value.split('=')] - - def _parse_info_system(self, output): - lines = output[6:-2] - system = {} - - for line in lines: - if line.startswith("Units"): - system['units'] = self._get_pair(line)[1] - elif line.startswith("Atom style"): - system['atom_style'] = self._get_pair(line)[1] - elif line.startswith("Atom map"): - system['atom_map'] = self._get_pair(line)[1] - elif line.startswith("Atoms"): - parts = self._split_values(line) - system['natoms'] = int(self._get_pair(parts[0])[1]) - system['ntypes'] = int(self._get_pair(parts[1])[1]) - system['style'] = self._get_pair(parts[2])[1] - elif line.startswith("Kspace style"): - system['kspace_style'] = self._get_pair(line)[1] - elif line.startswith("Dimensions"): - system['dimensions'] = int(self._get_pair(line)[1]) - elif line.startswith("Orthogonal box"): - system['orthogonal_box'] = [float(x) for x in self._get_pair(line)[1].split('x')] - elif line.startswith("Boundaries"): - system['boundaries'] = self._get_pair(line)[1] - elif line.startswith("xlo"): - keys, values = [self._split_values(x) for x in self._get_pair(line)] - for key, value in zip(keys, values): - system[key] = float(value) - elif line.startswith("ylo"): - keys, values = [self._split_values(x) for x in self._get_pair(line)] - for key, value in zip(keys, values): - system[key] = float(value) - elif line.startswith("zlo"): - keys, values = [self._split_values(x) for x in self._get_pair(line)] - for key, value in zip(keys, values): - system[key] = float(value) - elif line.startswith("Molecule type"): - system['molecule_type'] = self._get_pair(line)[1] - elif line.startswith("Bonds"): - parts = self._split_values(line) - system['nbonds'] = int(self._get_pair(parts[0])[1]) - system['nbondtypes'] = int(self._get_pair(parts[1])[1]) - system['bond_style'] = self._get_pair(parts[2])[1] - elif line.startswith("Angles"): - parts = self._split_values(line) - system['nangles'] = int(self._get_pair(parts[0])[1]) - system['nangletypes'] = int(self._get_pair(parts[1])[1]) - system['angle_style'] = self._get_pair(parts[2])[1] - elif line.startswith("Dihedrals"): - parts = self._split_values(line) - system['ndihedrals'] = int(self._get_pair(parts[0])[1]) - system['ndihedraltypes'] = int(self._get_pair(parts[1])[1]) - system['dihedral_style'] = self._get_pair(parts[2])[1] - elif line.startswith("Impropers"): - parts = self._split_values(line) - system['nimpropers'] = int(self._get_pair(parts[0])[1]) - system['nimpropertypes'] = int(self._get_pair(parts[1])[1]) - system['improper_style'] = self._get_pair(parts[2])[1] - - return system - - def _parse_info_communication(self, output): - lines = output[6:-3] - comm = {} - - for line in lines: - if line.startswith("MPI library"): - comm['mpi_version'] = line.split(':')[1].strip() - elif line.startswith("Comm style"): - parts = self._split_values(line) - comm['comm_style'] = self._get_pair(parts[0])[1] - comm['comm_layout'] = self._get_pair(parts[1])[1] - elif line.startswith("Processor grid"): - comm['proc_grid'] = [int(x) for x in self._get_pair(line)[1].split('x')] - elif line.startswith("Communicate velocities for ghost atoms"): - comm['ghost_velocity'] = (self._get_pair(line)[1] == "yes") - elif line.startswith("Nprocs"): - parts = self._split_values(line) - comm['nprocs'] = int(self._get_pair(parts[0])[1]) - comm['nthreads'] = int(self._get_pair(parts[1])[1]) - return comm - - def _parse_element_list(self, output): - lines = output[6:-3] - elements = [] - - for line in lines: - element_info = self._split_values(line.split(':')[1].strip()) - element = {'name': element_info[0]} - for key, value in [self._get_pair(x) for x in element_info[1:]]: - element[key] = value - elements.append(element) - return elements - - def _parse_groups(self, output): - lines = output[6:-3] - groups = [] - group_pattern = re.compile(r"(?P.+) \((?P.+)\)") - - for line in lines: - m = group_pattern.match(line.split(':')[1].strip()) - group = {'name': m.group('name'), 'type': m.group('type')} - groups.append(group) - return groups - - def lmp_print(self, s): - """ needed for Python2 compatibility, since print is a reserved keyword """ - return self.__getattr__("print")(s) - - def __dir__(self): - return ['angle_coeff', 'angle_style', 'atom_modify', 'atom_style', 'atom_style', - 'bond_coeff', 'bond_style', 'boundary', 'change_box', 'communicate', 'compute', - 'create_atoms', 'create_box', 'delete_atoms', 'delete_bonds', 'dielectric', - 'dihedral_coeff', 'dihedral_style', 'dimension', 'dump', 'fix', 'fix_modify', - 'group', 'improper_coeff', 'improper_style', 'include', 'kspace_modify', - 'kspace_style', 'lattice', 'mass', 'minimize', 'min_style', 'neighbor', - 'neigh_modify', 'newton', 'nthreads', 'pair_coeff', 'pair_modify', - 'pair_style', 'processors', 'read', 'read_data', 'read_restart', 'region', - 'replicate', 'reset_timestep', 'restart', 'run', 'run_style', 'thermo', - 'thermo_modify', 'thermo_style', 'timestep', 'undump', 'unfix', 'units', - 'variable', 'velocity', 'write_restart'] - - def __getattr__(self, name): - """ - This method is where the Python 'magic' happens. If a method is not - defined by the class PyLammps, it assumes it is a LAMMPS command. It takes - all the arguments, concatinates them to a single string, and executes it using - :py:meth:`lammps.PyLammps.command()`. - - :param verbose: Print output of command - :type verbose: bool - :return: line or list of lines of output, None if no output - :rtype: list or string - """ - def handler(*args, **kwargs): - cmd_args = [name] + [str(x) for x in args] - - with OutputCapture() as capture: - cmd = ' '.join(cmd_args) - self.command(cmd) - output = capture.output - - if 'verbose' in kwargs and kwargs['verbose']: - print(output) - - lines = output.splitlines() - - if self.has_echo: - lines = lines[1:] - - if len(lines) > 1: - return lines - elif len(lines) == 1: - return lines[0] - return None - - return handler - - -class IPyLammps(PyLammps): - """ - IPython wrapper for LAMMPS which adds embedded graphics capabilities to PyLammmps interface - - It either creates its own instance of :py:class:`lammps` or can be - initialized with an existing instance. The arguments are the same of the - lower-level interface. The original interface can still be accessed via - :py:attr:`PyLammps.lmp`. - - :param name: "machine" name of the shared LAMMPS library ("mpi" loads ``liblammps_mpi.so``, "" loads ``liblammps.so``) - :type name: string - :param cmdargs: list of command line arguments to be passed to the :cpp:func:`lammps_open` function. The executable name is automatically added. - :type cmdargs: list - :param ptr: pointer to a LAMMPS C++ class instance when called from an embedded Python interpreter. None means load symbols from shared library. - :type ptr: pointer - :param comm: MPI communicator (as provided by `mpi4py `_). ``None`` means use ``MPI_COMM_WORLD`` implicitly. - :type comm: MPI_Comm - """ - - def __init__(self,name="",cmdargs=None,ptr=None,comm=None): - super(IPyLammps, self).__init__(name=name,cmdargs=cmdargs,ptr=ptr,comm=comm) - - def image(self, filename="snapshot.png", group="all", color="type", diameter="type", - size=None, view=None, center=None, up=None, zoom=1.0, background_color="white"): - """ Generate image using write_dump command and display it - - See :doc:`dump image ` for more information. - - :param filename: Name of the image file that should be generated. The extension determines whether it is PNG or JPEG - :type filename: string - :param group: the group of atoms write_image should use - :type group: string - :param color: name of property used to determine color - :type color: string - :param diameter: name of property used to determine atom diameter - :type diameter: string - :param size: dimensions of image - :type size: tuple (width, height) - :param view: view parameters - :type view: tuple (theta, phi) - :param center: center parameters - :type center: tuple (flag, center_x, center_y, center_z) - :param up: vector pointing to up direction - :type up: tuple (up_x, up_y, up_z) - :param zoom: zoom factor - :type zoom: float - :param background_color: background color of scene - :type background_color: string - - :return: Image instance used to display image in notebook - :rtype: :py:class:`IPython.core.display.Image` - """ - cmd_args = [group, "image", filename, color, diameter] - - if size: - width = size[0] - height = size[1] - cmd_args += ["size", width, height] - - if view: - theta = view[0] - phi = view[1] - cmd_args += ["view", theta, phi] - - if center: - flag = center[0] - Cx = center[1] - Cy = center[2] - Cz = center[3] - cmd_args += ["center", flag, Cx, Cy, Cz] - - if up: - Ux = up[0] - Uy = up[1] - Uz = up[2] - cmd_args += ["up", Ux, Uy, Uz] - - if zoom: - cmd_args += ["zoom", zoom] - - cmd_args.append("modify backcolor " + background_color) - - self.write_dump(*cmd_args) - from IPython.core.display import Image - return Image(filename) - - def video(self, filename): - """ - Load video from file - - Can be used to visualize videos from :doc:`dump movie `. - - :param filename: Path to video file - :type filename: string - :return: HTML Video Tag used by notebook to embed a video - :rtype: :py:class:`IPython.display.HTML` - """ - from IPython.display import HTML - return HTML("") diff --git a/python/lammps/pylammps.py b/python/lammps/pylammps.py new file mode 100644 index 0000000000..007c771308 --- /dev/null +++ b/python/lammps/pylammps.py @@ -0,0 +1,870 @@ +# ---------------------------------------------------------------------- +# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator +# http://lammps.sandia.gov, Sandia National Laboratories +# Steve Plimpton, sjplimp@sandia.gov +# +# Copyright (2003) Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains +# certain rights in this software. This software is distributed under +# the GNU General Public License. +# +# See the README file in the top-level LAMMPS directory. +# ------------------------------------------------------------------------- + +################################################################################ +# Alternative Python Wrapper +# Written by Richard Berger +################################################################################ + +# for python2/3 compatibility + +from __future__ import print_function + +# imports for simple LAMMPS python wrapper module "lammps" + +import sys,traceback,types +import warnings +from ctypes import * +from os.path import dirname,abspath,join +from inspect import getsourcefile + +# imports for advanced LAMMPS python wrapper modules "PyLammps" and "IPyLammps" + +from collections import namedtuple +import os +import select +import re +import sys + +from .core import lammps + +class OutputCapture(object): + """ Utility class to capture LAMMPS library output """ + + def __init__(self): + self.stdout_pipe_read, self.stdout_pipe_write = os.pipe() + self.stdout_fd = 1 + + def __enter__(self): + self.stdout = os.dup(self.stdout_fd) + os.dup2(self.stdout_pipe_write, self.stdout_fd) + return self + + def __exit__(self, type, value, tracebac): + os.dup2(self.stdout, self.stdout_fd) + os.close(self.stdout) + os.close(self.stdout_pipe_read) + os.close(self.stdout_pipe_write) + + # check if we have more to read from the pipe + def more_data(self, pipe): + r, _, _ = select.select([pipe], [], [], 0) + return bool(r) + + # read the whole pipe + def read_pipe(self, pipe): + out = "" + while self.more_data(pipe): + out += os.read(pipe, 1024).decode() + return out + + @property + def output(self): + return self.read_pipe(self.stdout_pipe_read) + +# ------------------------------------------------------------------------- + +class Variable(object): + def __init__(self, pylammps_instance, name, style, definition): + self._pylmp = pylammps_instance + self.name = name + self.style = style + self.definition = definition.split() + + @property + def value(self): + if self.style == 'atom': + return list(self._pylmp.lmp.extract_variable(self.name, "all", 1)) + else: + value = self._pylmp.lmp_print('"${%s}"' % self.name).strip() + try: + return float(value) + except ValueError: + return value + +# ------------------------------------------------------------------------- + +class AtomList(object): + """ + A dynamic list of atoms that returns either an :py:class:`Atom` or + :py:class:`Atom2D` instance for each atom. Instances are only allocated + when accessed. + + :ivar natoms: total number of atoms + :ivar dimensions: number of dimensions in system + """ + def __init__(self, pylammps_instance): + self._pylmp = pylammps_instance + self.natoms = self._pylmp.system.natoms + self.dimensions = self._pylmp.system.dimensions + self._loaded = {} + + def __getitem__(self, index): + """ + Return Atom with given local index + + :param index: Local index of atom + :type index: int + :rtype: Atom or Atom2D + """ + if index not in self._loaded: + if self.dimensions == 2: + atom = Atom2D(self._pylmp, index + 1) + else: + atom = Atom(self._pylmp, index + 1) + self._loaded[index] = atom + return self._loaded[index] + + def __len__(self): + return self.natoms + + +# ------------------------------------------------------------------------- + +class Atom(object): + """ + A wrapper class then represents a single atom inside of LAMMPS + + It provides access to properties of the atom and allows you to change some of them. + """ + def __init__(self, pylammps_instance, index): + self._pylmp = pylammps_instance + self.index = index + + @property + def id(self): + """ + Return the atom ID + + :type: int + """ + return int(self._pylmp.eval("id[%d]" % self.index)) + + @property + def type(self): + """ + Return the atom type + + :type: int + """ + return int(self._pylmp.eval("type[%d]" % self.index)) + + @property + def mol(self): + """ + Return the atom molecule index + + :type: int + """ + return self._pylmp.eval("mol[%d]" % self.index) + + @property + def mass(self): + """ + Return the atom mass + + :type: float + """ + return self._pylmp.eval("mass[%d]" % self.index) + + @property + def position(self): + """ + :getter: Return position of atom + :setter: Set position of atom + :type: tuple (float, float, float) + """ + return (self._pylmp.eval("x[%d]" % self.index), + self._pylmp.eval("y[%d]" % self.index), + self._pylmp.eval("z[%d]" % self.index)) + + @position.setter + def position(self, value): + """ + :getter: Return velocity of atom + :setter: Set velocity of atom + :type: tuple (float, float, float) + """ + self._pylmp.set("atom", self.index, "x", value[0]) + self._pylmp.set("atom", self.index, "y", value[1]) + self._pylmp.set("atom", self.index, "z", value[2]) + + @property + def velocity(self): + return (self._pylmp.eval("vx[%d]" % self.index), + self._pylmp.eval("vy[%d]" % self.index), + self._pylmp.eval("vz[%d]" % self.index)) + + @velocity.setter + def velocity(self, value): + self._pylmp.set("atom", self.index, "vx", value[0]) + self._pylmp.set("atom", self.index, "vy", value[1]) + self._pylmp.set("atom", self.index, "vz", value[2]) + + @property + def force(self): + """ + Return the total force acting on the atom + + :type: tuple (float, float, float) + """ + return (self._pylmp.eval("fx[%d]" % self.index), + self._pylmp.eval("fy[%d]" % self.index), + self._pylmp.eval("fz[%d]" % self.index)) + + @property + def charge(self): + """ + Return the atom charge + + :type: float + """ + return self._pylmp.eval("q[%d]" % self.index) + +# ------------------------------------------------------------------------- + +class Atom2D(Atom): + """ + A wrapper class then represents a single 2D atom inside of LAMMPS + + Inherits all properties from the :py:class:`Atom` class, but returns 2D versions + of position, velocity, and force. + + It provides access to properties of the atom and allows you to change some of them. + """ + def __init__(self, pylammps_instance, index): + super(Atom2D, self).__init__(pylammps_instance, index) + + @property + def position(self): + """ + :getter: Return position of atom + :setter: Set position of atom + :type: tuple (float, float) + """ + return (self._pylmp.eval("x[%d]" % self.index), + self._pylmp.eval("y[%d]" % self.index)) + + @position.setter + def position(self, value): + self._pylmp.set("atom", self.index, "x", value[0]) + self._pylmp.set("atom", self.index, "y", value[1]) + + @property + def velocity(self): + """ + :getter: Return velocity of atom + :setter: Set velocity of atom + :type: tuple (float, float) + """ + return (self._pylmp.eval("vx[%d]" % self.index), + self._pylmp.eval("vy[%d]" % self.index)) + + @velocity.setter + def velocity(self, value): + self._pylmp.set("atom", self.index, "vx", value[0]) + self._pylmp.set("atom", self.index, "vy", value[1]) + + @property + def force(self): + """ + Return the total force acting on the atom + + :type: tuple (float, float) + """ + return (self._pylmp.eval("fx[%d]" % self.index), + self._pylmp.eval("fy[%d]" % self.index)) + +# ------------------------------------------------------------------------- + +class variable_set: + def __init__(self, name, variable_dict): + self._name = name + array_pattern = re.compile(r"(?P.+)\[(?P[0-9]+)\]") + + for key, value in variable_dict.items(): + m = array_pattern.match(key) + if m: + g = m.groupdict() + varname = g['arr'] + idx = int(g['index']) + if varname not in self.__dict__: + self.__dict__[varname] = {} + self.__dict__[varname][idx] = value + else: + self.__dict__[key] = value + + def __str__(self): + return "{}({})".format(self._name, ','.join(["{}={}".format(k, self.__dict__[k]) for k in self.__dict__.keys() if not k.startswith('_')])) + + def __repr__(self): + return self.__str__() + +# ------------------------------------------------------------------------- + +def get_thermo_data(output): + """ traverse output of runs and extract thermo data columns """ + if isinstance(output, str): + lines = output.splitlines() + else: + lines = output + + runs = [] + columns = [] + in_run = False + current_run = {} + + for line in lines: + if line.startswith("Per MPI rank memory allocation"): + in_run = True + elif in_run and len(columns) == 0: + # first line after memory usage are column names + columns = line.split() + + current_run = {} + + for col in columns: + current_run[col] = [] + + elif line.startswith("Loop time of "): + in_run = False + columns = None + thermo_data = variable_set('ThermoData', current_run) + r = {'thermo' : thermo_data } + runs.append(namedtuple('Run', list(r.keys()))(*list(r.values()))) + elif in_run and len(columns) > 0: + items = line.split() + # Convert thermo output and store it. + # It must have the same number of columns and + # all of them must be convertible to floats. + # Otherwise we ignore the line + if len(items) == len(columns): + try: + values = [float(x) for x in items] + for i, col in enumerate(columns): + current_run[col].append(values[i]) + except ValueError: + pass + + return runs + +# ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- + +class PyLammps(object): + """ + This is a Python wrapper class around the lower-level + :py:class:`lammps` class, exposing a more Python-like, + object-oriented interface for prototyping system inside of IPython and + Jupyter notebooks. + + It either creates its own instance of :py:class:`lammps` or can be + initialized with an existing instance. The arguments are the same of the + lower-level interface. The original interface can still be accessed via + :py:attr:`PyLammps.lmp`. + + :param name: "machine" name of the shared LAMMPS library ("mpi" loads ``liblammps_mpi.so``, "" loads ``liblammps.so``) + :type name: string + :param cmdargs: list of command line arguments to be passed to the :cpp:func:`lammps_open` function. The executable name is automatically added. + :type cmdargs: list + :param ptr: pointer to a LAMMPS C++ class instance when called from an embedded Python interpreter. None means load symbols from shared library. + :type ptr: pointer + :param comm: MPI communicator (as provided by `mpi4py `_). ``None`` means use ``MPI_COMM_WORLD`` implicitly. + :type comm: MPI_Comm + + :ivar lmp: instance of original LAMMPS Python interface + :vartype lmp: :py:class:`lammps` + + :ivar runs: list of completed runs, each storing the thermo output + :vartype run: list + """ + + def __init__(self, name="", cmdargs=None, ptr=None, comm=None): + self.has_echo = False + + if cmdargs: + if '-echo' in cmdargs: + idx = cmdargs.index('-echo') + # ensures that echo line is ignored during output capture + self.has_echo = idx+1 < len(cmdargs) and cmdargs[idx+1] in ('screen', 'both') + + if ptr: + if isinstance(ptr,PyLammps): + self.lmp = ptr.lmp + elif isinstance(ptr,lammps): + self.lmp = ptr + else: + self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=ptr,comm=comm) + else: + self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=None,comm=comm) + print("LAMMPS output is captured by PyLammps wrapper") + self._cmd_history = [] + self.runs = [] + + def __del__(self): + if self.lmp: self.lmp.close() + self.lmp = None + + def close(self): + """Explicitly delete a LAMMPS instance + + This is a wrapper around the :py:meth:`lammps.close` of the Python interface. + """ + if self.lmp: self.lmp.close() + self.lmp = None + + def version(self): + """Return a numerical representation of the LAMMPS version in use. + + This is a wrapper around the :py:meth:`lammps.version` function of the Python interface. + + :return: version number + :rtype: int + """ + return self.lmp.version() + + def file(self, file): + """Read LAMMPS commands from a file. + + This is a wrapper around the :py:meth:`lammps.file` function of the Python interface. + + :param path: Name of the file/path with LAMMPS commands + :type path: string + """ + self.lmp.file(file) + + def write_script(self, filepath): + """ + Write LAMMPS script file containing all commands executed up until now + + :param filepath: path to script file that should be written + :type filepath: string + """ + with open(filepath, "w") as f: + for cmd in self._cmd_history: + print(cmd, file=f) + + def command(self, cmd): + """ + Execute LAMMPS command + + All commands executed will be stored in a command history which can be + written to a file using :py:meth:`PyLammps.write_script()` + + :param cmd: command string that should be executed + :type: cmd: string + """ + self.lmp.command(cmd) + self._cmd_history.append(cmd) + + def run(self, *args, **kwargs): + """ + Execute LAMMPS run command with given arguments + + All thermo output during the run is captured and saved as new entry in + :py:attr:`PyLammps.runs`. The latest run can be retrieved by + :py:attr:`PyLammps.last_run`. + """ + output = self.__getattr__('run')(*args, **kwargs) + + comm = self.lmp.get_mpi_comm() + if comm: + output = self.lmp.comm.bcast(output, root=0) + + self.runs += get_thermo_data(output) + return output + + @property + def last_run(self): + """ + Return data produced of last completed run command + + :getter: Returns an object containing information about the last run command + :type: dict + """ + if len(self.runs) > 0: + return self.runs[-1] + return None + + @property + def atoms(self): + """ + All atoms of this LAMMPS instance + + :getter: Returns a list of atoms currently in the system + :type: AtomList + """ + return AtomList(self) + + @property + def system(self): + """ + The system state of this LAMMPS instance + + :getter: Returns an object with properties storing the current system state + :type: namedtuple + """ + output = self.info("system") + d = self._parse_info_system(output) + return namedtuple('System', d.keys())(*d.values()) + + @property + def communication(self): + """ + The communication state of this LAMMPS instance + + :getter: Returns an object with properties storing the current communication state + :type: namedtuple + """ + output = self.info("communication") + d = self._parse_info_communication(output) + return namedtuple('Communication', d.keys())(*d.values()) + + @property + def computes(self): + """ + The list of active computes of this LAMMPS instance + + :getter: Returns a list of computes that are currently active in this LAMMPS instance + :type: list + """ + output = self.info("computes") + return self._parse_element_list(output) + + @property + def dumps(self): + """ + The list of active dumps of this LAMMPS instance + + :getter: Returns a list of dumps that are currently active in this LAMMPS instance + :type: list + """ + output = self.info("dumps") + return self._parse_element_list(output) + + @property + def fixes(self): + """ + The list of active fixes of this LAMMPS instance + + :getter: Returns a list of fixes that are currently active in this LAMMPS instance + :type: list + """ + output = self.info("fixes") + return self._parse_element_list(output) + + @property + def groups(self): + """ + The list of active atom groups of this LAMMPS instance + + :getter: Returns a list of atom groups that are currently active in this LAMMPS instance + :type: list + """ + output = self.info("groups") + return self._parse_groups(output) + + @property + def variables(self): + """ + Returns a dictionary of all variables defined in the current LAMMPS instance + + :getter: Returns a dictionary of all variables that are defined in this LAMMPS instance + :type: dict + """ + output = self.info("variables") + vars = {} + for v in self._parse_element_list(output): + vars[v['name']] = Variable(self, v['name'], v['style'], v['def']) + return vars + + def eval(self, expr): + """ + Evaluate expression + + :param expr: the expression string that should be evaluated inside of LAMMPS + :type expr: string + + :return: the value of the evaluated expression + :rtype: float if numeric, string otherwise + """ + value = self.lmp_print('"$(%s)"' % expr).strip() + try: + return float(value) + except ValueError: + return value + + def _split_values(self, line): + return [x.strip() for x in line.split(',')] + + def _get_pair(self, value): + return [x.strip() for x in value.split('=')] + + def _parse_info_system(self, output): + lines = output[6:-2] + system = {} + + for line in lines: + if line.startswith("Units"): + system['units'] = self._get_pair(line)[1] + elif line.startswith("Atom style"): + system['atom_style'] = self._get_pair(line)[1] + elif line.startswith("Atom map"): + system['atom_map'] = self._get_pair(line)[1] + elif line.startswith("Atoms"): + parts = self._split_values(line) + system['natoms'] = int(self._get_pair(parts[0])[1]) + system['ntypes'] = int(self._get_pair(parts[1])[1]) + system['style'] = self._get_pair(parts[2])[1] + elif line.startswith("Kspace style"): + system['kspace_style'] = self._get_pair(line)[1] + elif line.startswith("Dimensions"): + system['dimensions'] = int(self._get_pair(line)[1]) + elif line.startswith("Orthogonal box"): + system['orthogonal_box'] = [float(x) for x in self._get_pair(line)[1].split('x')] + elif line.startswith("Boundaries"): + system['boundaries'] = self._get_pair(line)[1] + elif line.startswith("xlo"): + keys, values = [self._split_values(x) for x in self._get_pair(line)] + for key, value in zip(keys, values): + system[key] = float(value) + elif line.startswith("ylo"): + keys, values = [self._split_values(x) for x in self._get_pair(line)] + for key, value in zip(keys, values): + system[key] = float(value) + elif line.startswith("zlo"): + keys, values = [self._split_values(x) for x in self._get_pair(line)] + for key, value in zip(keys, values): + system[key] = float(value) + elif line.startswith("Molecule type"): + system['molecule_type'] = self._get_pair(line)[1] + elif line.startswith("Bonds"): + parts = self._split_values(line) + system['nbonds'] = int(self._get_pair(parts[0])[1]) + system['nbondtypes'] = int(self._get_pair(parts[1])[1]) + system['bond_style'] = self._get_pair(parts[2])[1] + elif line.startswith("Angles"): + parts = self._split_values(line) + system['nangles'] = int(self._get_pair(parts[0])[1]) + system['nangletypes'] = int(self._get_pair(parts[1])[1]) + system['angle_style'] = self._get_pair(parts[2])[1] + elif line.startswith("Dihedrals"): + parts = self._split_values(line) + system['ndihedrals'] = int(self._get_pair(parts[0])[1]) + system['ndihedraltypes'] = int(self._get_pair(parts[1])[1]) + system['dihedral_style'] = self._get_pair(parts[2])[1] + elif line.startswith("Impropers"): + parts = self._split_values(line) + system['nimpropers'] = int(self._get_pair(parts[0])[1]) + system['nimpropertypes'] = int(self._get_pair(parts[1])[1]) + system['improper_style'] = self._get_pair(parts[2])[1] + + return system + + def _parse_info_communication(self, output): + lines = output[6:-3] + comm = {} + + for line in lines: + if line.startswith("MPI library"): + comm['mpi_version'] = line.split(':')[1].strip() + elif line.startswith("Comm style"): + parts = self._split_values(line) + comm['comm_style'] = self._get_pair(parts[0])[1] + comm['comm_layout'] = self._get_pair(parts[1])[1] + elif line.startswith("Processor grid"): + comm['proc_grid'] = [int(x) for x in self._get_pair(line)[1].split('x')] + elif line.startswith("Communicate velocities for ghost atoms"): + comm['ghost_velocity'] = (self._get_pair(line)[1] == "yes") + elif line.startswith("Nprocs"): + parts = self._split_values(line) + comm['nprocs'] = int(self._get_pair(parts[0])[1]) + comm['nthreads'] = int(self._get_pair(parts[1])[1]) + return comm + + def _parse_element_list(self, output): + lines = output[6:-3] + elements = [] + + for line in lines: + element_info = self._split_values(line.split(':')[1].strip()) + element = {'name': element_info[0]} + for key, value in [self._get_pair(x) for x in element_info[1:]]: + element[key] = value + elements.append(element) + return elements + + def _parse_groups(self, output): + lines = output[6:-3] + groups = [] + group_pattern = re.compile(r"(?P.+) \((?P.+)\)") + + for line in lines: + m = group_pattern.match(line.split(':')[1].strip()) + group = {'name': m.group('name'), 'type': m.group('type')} + groups.append(group) + return groups + + def lmp_print(self, s): + """ needed for Python2 compatibility, since print is a reserved keyword """ + return self.__getattr__("print")(s) + + def __dir__(self): + return ['angle_coeff', 'angle_style', 'atom_modify', 'atom_style', 'atom_style', + 'bond_coeff', 'bond_style', 'boundary', 'change_box', 'communicate', 'compute', + 'create_atoms', 'create_box', 'delete_atoms', 'delete_bonds', 'dielectric', + 'dihedral_coeff', 'dihedral_style', 'dimension', 'dump', 'fix', 'fix_modify', + 'group', 'improper_coeff', 'improper_style', 'include', 'kspace_modify', + 'kspace_style', 'lattice', 'mass', 'minimize', 'min_style', 'neighbor', + 'neigh_modify', 'newton', 'nthreads', 'pair_coeff', 'pair_modify', + 'pair_style', 'processors', 'read', 'read_data', 'read_restart', 'region', + 'replicate', 'reset_timestep', 'restart', 'run', 'run_style', 'thermo', + 'thermo_modify', 'thermo_style', 'timestep', 'undump', 'unfix', 'units', + 'variable', 'velocity', 'write_restart'] + + def __getattr__(self, name): + """ + This method is where the Python 'magic' happens. If a method is not + defined by the class PyLammps, it assumes it is a LAMMPS command. It takes + all the arguments, concatinates them to a single string, and executes it using + :py:meth:`lammps.PyLammps.command()`. + + :param verbose: Print output of command + :type verbose: bool + :return: line or list of lines of output, None if no output + :rtype: list or string + """ + def handler(*args, **kwargs): + cmd_args = [name] + [str(x) for x in args] + + with OutputCapture() as capture: + cmd = ' '.join(cmd_args) + self.command(cmd) + output = capture.output + + if 'verbose' in kwargs and kwargs['verbose']: + print(output) + + lines = output.splitlines() + + if self.has_echo: + lines = lines[1:] + + if len(lines) > 1: + return lines + elif len(lines) == 1: + return lines[0] + return None + + return handler + + +class IPyLammps(PyLammps): + """ + IPython wrapper for LAMMPS which adds embedded graphics capabilities to PyLammmps interface + + It either creates its own instance of :py:class:`lammps` or can be + initialized with an existing instance. The arguments are the same of the + lower-level interface. The original interface can still be accessed via + :py:attr:`PyLammps.lmp`. + + :param name: "machine" name of the shared LAMMPS library ("mpi" loads ``liblammps_mpi.so``, "" loads ``liblammps.so``) + :type name: string + :param cmdargs: list of command line arguments to be passed to the :cpp:func:`lammps_open` function. The executable name is automatically added. + :type cmdargs: list + :param ptr: pointer to a LAMMPS C++ class instance when called from an embedded Python interpreter. None means load symbols from shared library. + :type ptr: pointer + :param comm: MPI communicator (as provided by `mpi4py `_). ``None`` means use ``MPI_COMM_WORLD`` implicitly. + :type comm: MPI_Comm + """ + + def __init__(self,name="",cmdargs=None,ptr=None,comm=None): + super(IPyLammps, self).__init__(name=name,cmdargs=cmdargs,ptr=ptr,comm=comm) + + def image(self, filename="snapshot.png", group="all", color="type", diameter="type", + size=None, view=None, center=None, up=None, zoom=1.0, background_color="white"): + """ Generate image using write_dump command and display it + + See :doc:`dump image ` for more information. + + :param filename: Name of the image file that should be generated. The extension determines whether it is PNG or JPEG + :type filename: string + :param group: the group of atoms write_image should use + :type group: string + :param color: name of property used to determine color + :type color: string + :param diameter: name of property used to determine atom diameter + :type diameter: string + :param size: dimensions of image + :type size: tuple (width, height) + :param view: view parameters + :type view: tuple (theta, phi) + :param center: center parameters + :type center: tuple (flag, center_x, center_y, center_z) + :param up: vector pointing to up direction + :type up: tuple (up_x, up_y, up_z) + :param zoom: zoom factor + :type zoom: float + :param background_color: background color of scene + :type background_color: string + + :return: Image instance used to display image in notebook + :rtype: :py:class:`IPython.core.display.Image` + """ + cmd_args = [group, "image", filename, color, diameter] + + if size: + width = size[0] + height = size[1] + cmd_args += ["size", width, height] + + if view: + theta = view[0] + phi = view[1] + cmd_args += ["view", theta, phi] + + if center: + flag = center[0] + Cx = center[1] + Cy = center[2] + Cz = center[3] + cmd_args += ["center", flag, Cx, Cy, Cz] + + if up: + Ux = up[0] + Uy = up[1] + Uz = up[2] + cmd_args += ["up", Ux, Uy, Uz] + + if zoom: + cmd_args += ["zoom", zoom] + + cmd_args.append("modify backcolor " + background_color) + + self.write_dump(*cmd_args) + from IPython.core.display import Image + return Image(filename) + + def video(self, filename): + """ + Load video from file + + Can be used to visualize videos from :doc:`dump movie `. + + :param filename: Path to video file + :type filename: string + :return: HTML Video Tag used by notebook to embed a video + :rtype: :py:class:`IPython.display.HTML` + """ + from IPython.display import HTML + return HTML("") From 9e188a381867e915ddda5c78131d53064716656a Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 16:19:23 -0500 Subject: [PATCH 090/187] Clean up imports --- python/lammps/pylammps.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/python/lammps/pylammps.py b/python/lammps/pylammps.py index 007c771308..1ec45d43b5 100644 --- a/python/lammps/pylammps.py +++ b/python/lammps/pylammps.py @@ -20,24 +20,15 @@ from __future__ import print_function -# imports for simple LAMMPS python wrapper module "lammps" - -import sys,traceback,types -import warnings -from ctypes import * -from os.path import dirname,abspath,join -from inspect import getsourcefile - -# imports for advanced LAMMPS python wrapper modules "PyLammps" and "IPyLammps" - -from collections import namedtuple import os -import select import re +import select import sys +from collections import namedtuple from .core import lammps + class OutputCapture(object): """ Utility class to capture LAMMPS library output """ From df58a1fc5fccf5edb052d7a03029d581fb11259c Mon Sep 17 00:00:00 2001 From: Yaser Afshar Date: Tue, 15 Dec 2020 15:22:24 -0600 Subject: [PATCH 091/187] Update the eflag_global & eflag_atom Update the eflag_global & eflag_atom use based on the flag use in LAMMPS. --- src/KIM/pair_kim.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 7ff067dcac..ad671de5b3 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -890,7 +890,7 @@ void PairKIM::set_argument_pointers() KIM_SUPPORT_STATUS_notSupported)) { if (KIM_SupportStatus_Equal(kim_model_support_for_energy, KIM_SUPPORT_STATUS_required) - || (eflag_global == 1)) { + || (eflag_global != 0)) { kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( pargs,KIM_COMPUTE_ARGUMENT_NAME_partialEnergy,&(eng_vdwl)); @@ -905,7 +905,7 @@ void PairKIM::set_argument_pointers() // Set KIM pointer appropriately for particalEnergy if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy, KIM_SUPPORT_STATUS_required) - && (eflag_atom != 1)) { + && (eflag_atom == 0)) { // reallocate per-atom energy array if necessary if (atom->nmax > maxeatom) { maxeatom = atom->nmax; @@ -916,13 +916,13 @@ void PairKIM::set_argument_pointers() if (KIM_SupportStatus_Equal(kim_model_support_for_particleEnergy, KIM_SUPPORT_STATUS_optional) - && (eflag_atom != 1)) { + && (eflag_atom == 0)) { kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, static_cast(nullptr)); } else if (KIM_SupportStatus_NotEqual(kim_model_support_for_particleEnergy, - KIM_SUPPORT_STATUS_notSupported)) { + KIM_SUPPORT_STATUS_notSupported)) { kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy, eatom); } @@ -940,9 +940,9 @@ void PairKIM::set_argument_pointers() } // Set KIM pointer appropriately for particleVirial - if ((vflag_atom == 0) && - KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_required)) { + if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_required) + && (vflag_atom == 0)) { // reallocate per-atom virial array if necessary if (atom->nmax > maxvatom) { maxvatom = atom->nmax; @@ -951,9 +951,9 @@ void PairKIM::set_argument_pointers() } } - if ((vflag_atom == 0) && - KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_optional)) { + if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, + KIM_SUPPORT_STATUS_optional) + && (vflag_atom == 0)) { kimerror = kimerror || KIM_ComputeArguments_SetArgumentPointerDouble( pargs, KIM_COMPUTE_ARGUMENT_NAME_partialParticleVirial, From 33f9a296399a45ac7c6d6ea74a7b18e58e3fdebc Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 16:33:21 -0500 Subject: [PATCH 092/187] Split core.py into more files --- python/lammps/__init__.py | 2 + python/lammps/constants.py | 49 +++++ python/lammps/core.py | 412 +------------------------------------ python/lammps/data.py | 73 +++++++ python/lammps/numpy.py | 335 ++++++++++++++++++++++++++++++ 5 files changed, 462 insertions(+), 409 deletions(-) create mode 100644 python/lammps/constants.py create mode 100644 python/lammps/data.py create mode 100644 python/lammps/numpy.py diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index 37773d84a5..b1c8306617 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -1,2 +1,4 @@ +from .constants import * from .core import * +from .data import * from .pylammps import * diff --git a/python/lammps/constants.py b/python/lammps/constants.py new file mode 100644 index 0000000000..e5504691fe --- /dev/null +++ b/python/lammps/constants.py @@ -0,0 +1,49 @@ +# ---------------------------------------------------------------------- +# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator +# http://lammps.sandia.gov, Sandia National Laboratories +# Steve Plimpton, sjplimp@sandia.gov +# +# Copyright (2003) Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains +# certain rights in this software. This software is distributed under +# the GNU General Public License. +# +# See the README file in the top-level LAMMPS directory. +# ------------------------------------------------------------------------- + +from ctypes import c_int, c_int32, c_int64 + +# various symbolic constants to be used +# in certain calls to select data formats +LAMMPS_AUTODETECT = None +LAMMPS_INT = 0 +LAMMPS_INT_2D = 1 +LAMMPS_DOUBLE = 2 +LAMMPS_DOUBLE_2D = 3 +LAMMPS_INT64 = 4 +LAMMPS_INT64_2D = 5 +LAMMPS_STRING = 6 + +# these must be kept in sync with the enums in library.h +LMP_STYLE_GLOBAL = 0 +LMP_STYLE_ATOM = 1 +LMP_STYLE_LOCAL = 2 + +LMP_TYPE_SCALAR = 0 +LMP_TYPE_VECTOR = 1 +LMP_TYPE_ARRAY = 2 +LMP_SIZE_VECTOR = 3 +LMP_SIZE_ROWS = 4 +LMP_SIZE_COLS = 5 + +LMP_VAR_EQUAL = 0 +LMP_VAR_ATOM = 1 + +# ------------------------------------------------------------------------- + +def get_ctypes_int(size): + if size == 4: + return c_int32 + elif size == 8: + return c_int64 + return c_int diff --git a/python/lammps/core.py b/python/lammps/core.py index 14b727e59a..009409f48d 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -25,40 +25,8 @@ from ctypes import * from os.path import dirname,abspath,join from inspect import getsourcefile -# various symbolic constants to be used -# in certain calls to select data formats -LAMMPS_AUTODETECT = None -LAMMPS_INT = 0 -LAMMPS_INT_2D = 1 -LAMMPS_DOUBLE = 2 -LAMMPS_DOUBLE_2D = 3 -LAMMPS_INT64 = 4 -LAMMPS_INT64_2D = 5 -LAMMPS_STRING = 6 - -# these must be kept in sync with the enums in library.h -LMP_STYLE_GLOBAL = 0 -LMP_STYLE_ATOM = 1 -LMP_STYLE_LOCAL = 2 - -LMP_TYPE_SCALAR = 0 -LMP_TYPE_VECTOR = 1 -LMP_TYPE_ARRAY = 2 -LMP_SIZE_VECTOR = 3 -LMP_SIZE_ROWS = 4 -LMP_SIZE_COLS = 5 - -LMP_VAR_EQUAL = 0 -LMP_VAR_ATOM = 1 - -# ------------------------------------------------------------------------- - -def get_ctypes_int(size): - if size == 4: - return c_int32 - elif size == 8: - return c_int64 - return c_int +from .constants import * +from .data import * # ------------------------------------------------------------------------- @@ -71,94 +39,6 @@ class MPIAbortException(Exception): # ------------------------------------------------------------------------- -class NeighList: - """This is a wrapper class that exposes the contents of a neighbor list. - - It can be used like a regular Python list. Each element is a tuple of: - - * the atom local index - * its number of neighbors - * and a pointer to an c_int array containing local atom indices of its - neighbors - - Internally it uses the lower-level LAMMPS C-library interface. - - :param lmp: reference to instance of :py:class:`lammps` - :type lmp: lammps - :param idx: neighbor list index - :type idx: int - """ - def __init__(self, lmp, idx): - self.lmp = lmp - self.idx = idx - - def __str__(self): - return "Neighbor List ({} atoms)".format(self.size) - - def __repr__(self): - return self.__str__() - - @property - def size(self): - """ - :return: number of elements in neighbor list - """ - return self.lmp.get_neighlist_size(self.idx) - - def get(self, element): - """ - :return: tuple with atom local index, numpy array of neighbor local atom indices - :rtype: (int, int, ctypes.POINTER(c_int)) - """ - iatom, numneigh, neighbors = self.lmp.get_neighlist_element_neighbors(self.idx, element) - return iatom, numneigh, neighbors - - # the methods below implement the iterator interface, so NeighList can be used like a regular Python list - - def __getitem__(self, element): - return self.get(element) - - def __len__(self): - return self.size - - def __iter__(self): - inum = self.size - - for ii in range(inum): - yield self.get(ii) - -# ------------------------------------------------------------------------- - -class NumPyNeighList(NeighList): - """This is a wrapper class that exposes the contents of a neighbor list. - - It can be used like a regular Python list. Each element is a tuple of: - - * the atom local index - * a NumPy array containing the local atom indices of its neighbors - - Internally it uses the lower-level LAMMPS C-library interface. - - :param lmp: reference to instance of :py:class:`lammps` - :type lmp: lammps - :param idx: neighbor list index - :type idx: int - """ - def __init__(self, lmp, idx): - super(NumPyNeighList, self).__init__(lmp, idx) - - def get(self, element): - """ - :return: tuple with atom local index, numpy array of neighbor local atom indices - :rtype: (int, numpy.array) - """ - iatom, neighbors = self.lmp.numpy.get_neighlist_element_neighbors(self.idx, element) - return iatom, neighbors - - -# ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- - class lammps(object): """Create an instance of the LAMMPS Python class. @@ -521,6 +401,7 @@ class lammps(object): :rtype: numpy_wrapper """ if not self._numpy: + from .numpy import numpy_wrapper self._numpy = numpy_wrapper(self) return self._numpy @@ -1789,290 +1670,3 @@ class lammps(object): computeid = computeid.encode() idx = self.lib.lammps_find_compute_neighlist(self.lmp, computeid, request) return idx - -# ------------------------------------------------------------------------- - -class numpy_wrapper: - """lammps API NumPy Wrapper - - This is a wrapper class that provides additional methods on top of an - existing :py:class:`lammps` instance. The methods transform raw ctypes - pointers into NumPy arrays, which give direct access to the - original data while protecting against out-of-bounds accesses. - - There is no need to explicitly instantiate this class. Each instance - of :py:class:`lammps` has a :py:attr:`numpy ` property - that returns an instance. - - :param lmp: instance of the :py:class:`lammps` class - :type lmp: lammps - """ - def __init__(self, lmp): - self.lmp = lmp - - # ------------------------------------------------------------------------- - - def _ctype_to_numpy_int(self, ctype_int): - import numpy as np - if ctype_int == c_int32: - return np.int32 - elif ctype_int == c_int64: - return np.int64 - return np.intc - - # ------------------------------------------------------------------------- - - def extract_atom(self, name, dtype=LAMMPS_AUTODETECT, nelem=LAMMPS_AUTODETECT, dim=LAMMPS_AUTODETECT): - """Retrieve per-atom properties from LAMMPS as NumPy arrays - - This is a wrapper around the :py:meth:`lammps.extract_atom()` method. - It behaves the same as the original method, but returns NumPy arrays - instead of ``ctypes`` pointers. - - .. note:: - - While the returned arrays of per-atom data are dimensioned - for the range [0:nmax] - as is the underlying storage - - the data is usually only valid for the range of [0:nlocal], - unless the property of interest is also updated for ghost - atoms. In some cases, this depends on a LAMMPS setting, see - for example :doc:`comm_modify vel yes `. - - :param name: name of the property - :type name: string - :param dtype: type of the returned data (see :ref:`py_datatype_constants`) - :type dtype: int, optional - :param nelem: number of elements in array - :type nelem: int, optional - :param dim: dimension of each element - :type dim: int, optional - :return: requested data as NumPy array with direct access to C data or None - :rtype: numpy.array or NoneType - """ - if dtype == LAMMPS_AUTODETECT: - dtype = self.lmp.extract_atom_datatype(name) - - if nelem == LAMMPS_AUTODETECT: - if name == "mass": - nelem = self.lmp.extract_global("ntypes") + 1 - else: - nelem = self.lmp.extract_global("nlocal") - if dim == LAMMPS_AUTODETECT: - if dtype in (LAMMPS_INT_2D, LAMMPS_DOUBLE_2D, LAMMPS_INT64_2D): - # TODO add other fields - if name in ("x", "v", "f", "angmom", "torque", "csforce", "vforce"): - dim = 3 - else: - dim = 2 - else: - dim = 1 - - raw_ptr = self.lmp.extract_atom(name, dtype) - - if dtype in (LAMMPS_DOUBLE, LAMMPS_DOUBLE_2D): - return self.darray(raw_ptr, nelem, dim) - elif dtype in (LAMMPS_INT, LAMMPS_INT_2D): - return self.iarray(c_int32, raw_ptr, nelem, dim) - elif dtype in (LAMMPS_INT64, LAMMPS_INT64_2D): - return self.iarray(c_int64, raw_ptr, nelem, dim) - return raw_ptr - - # ------------------------------------------------------------------------- - - def extract_atom_iarray(self, name, nelem, dim=1): - warnings.warn("deprecated, use extract_atom instead", DeprecationWarning) - - if name in ['id', 'molecule']: - c_int_type = self.lmp.c_tagint - elif name in ['image']: - c_int_type = self.lmp.c_imageint - else: - c_int_type = c_int - - if dim == 1: - raw_ptr = self.lmp.extract_atom(name, LAMMPS_INT) - else: - raw_ptr = self.lmp.extract_atom(name, LAMMPS_INT_2D) - - return self.iarray(c_int_type, raw_ptr, nelem, dim) - - # ------------------------------------------------------------------------- - - def extract_atom_darray(self, name, nelem, dim=1): - warnings.warn("deprecated, use extract_atom instead", DeprecationWarning) - - if dim == 1: - raw_ptr = self.lmp.extract_atom(name, LAMMPS_DOUBLE) - else: - raw_ptr = self.lmp.extract_atom(name, LAMMPS_DOUBLE_2D) - - return self.darray(raw_ptr, nelem, dim) - - # ------------------------------------------------------------------------- - - def extract_compute(self, cid, style, type): - """Retrieve data from a LAMMPS compute - - This is a wrapper around the - :py:meth:`lammps.extract_compute() ` method. - It behaves the same as the original method, but returns NumPy arrays - instead of ``ctypes`` pointers. - - :param id: compute ID - :type id: string - :param style: style of the data retrieve (global, atom, or local), see :ref:`py_style_constants` - :type style: int - :param type: type of the returned data (scalar, vector, or array), see :ref:`py_type_constants` - :type type: int - :return: requested data either as float, as NumPy array with direct access to C data, or None - :rtype: float, numpy.array, or NoneType - """ - value = self.lmp.extract_compute(cid, style, type) - - if style in (LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL): - if type == LMP_TYPE_VECTOR: - nrows = self.lmp.extract_compute(cid, style, LMP_SIZE_VECTOR) - return self.darray(value, nrows) - elif type == LMP_TYPE_ARRAY: - nrows = self.lmp.extract_compute(cid, style, LMP_SIZE_ROWS) - ncols = self.lmp.extract_compute(cid, style, LMP_SIZE_COLS) - return self.darray(value, nrows, ncols) - elif style == LMP_STYLE_ATOM: - if type == LMP_TYPE_VECTOR: - nlocal = self.lmp.extract_global("nlocal") - return self.darray(value, nlocal) - elif type == LMP_TYPE_ARRAY: - nlocal = self.lmp.extract_global("nlocal") - ncols = self.lmp.extract_compute(cid, style, LMP_SIZE_COLS) - return self.darray(value, nlocal, ncols) - return value - - # ------------------------------------------------------------------------- - - def extract_fix(self, fid, style, type, nrow=0, ncol=0): - """Retrieve data from a LAMMPS fix - - This is a wrapper around the :py:meth:`lammps.extract_fix() ` method. - It behaves the same as the original method, but returns NumPy arrays - instead of ``ctypes`` pointers. - - :param id: fix ID - :type id: string - :param style: style of the data retrieve (global, atom, or local), see :ref:`py_style_constants` - :type style: int - :param type: type or size of the returned data (scalar, vector, or array), see :ref:`py_type_constants` - :type type: int - :param nrow: index of global vector element or row index of global array element - :type nrow: int - :param ncol: column index of global array element - :type ncol: int - :return: requested data - :rtype: integer or double value, pointer to 1d or 2d double array or None - - """ - value = self.lmp.extract_fix(fid, style, type, nrow, ncol) - if style == LMP_STYLE_ATOM: - if type == LMP_TYPE_VECTOR: - nlocal = self.lmp.extract_global("nlocal") - return self.darray(value, nlocal) - elif type == LMP_TYPE_ARRAY: - nlocal = self.lmp.extract_global("nlocal") - ncols = self.lmp.extract_fix(fid, style, LMP_SIZE_COLS, 0, 0) - return self.darray(value, nlocal, ncols) - elif style == LMP_STYLE_LOCAL: - if type == LMP_TYPE_VECTOR: - nrows = self.lmp.extract_fix(fid, style, LMP_SIZE_ROWS, 0, 0) - return self.darray(value, nrows) - elif type == LMP_TYPE_ARRAY: - nrows = self.lmp.extract_fix(fid, style, LMP_SIZE_ROWS, 0, 0) - ncols = self.lmp.extract_fix(fid, style, LMP_SIZE_COLS, 0, 0) - return self.darray(value, nrows, ncols) - return value - - # ------------------------------------------------------------------------- - - def extract_variable(self, name, group=None, vartype=LMP_VAR_EQUAL): - """ Evaluate a LAMMPS variable and return its data - - This function is a wrapper around the function - :py:meth:`lammps.extract_variable() ` - method. It behaves the same as the original method, but returns NumPy arrays - instead of ``ctypes`` pointers. - - :param name: name of the variable to execute - :type name: string - :param group: name of group for atom-style variable (ignored for equal-style variables) - :type group: string - :param vartype: type of variable, see :ref:`py_vartype_constants` - :type vartype: int - :return: the requested data or None - :rtype: c_double, numpy.array, or NoneType - """ - import numpy as np - value = self.lmp.extract_variable(name, group, vartype) - if vartype == LMP_VAR_ATOM: - return np.ctypeslib.as_array(value) - return value - - # ------------------------------------------------------------------------- - - def get_neighlist(self, idx): - """Returns an instance of :class:`NumPyNeighList` which wraps access to the neighbor list with the given index - - :param idx: index of neighbor list - :type idx: int - :return: an instance of :class:`NumPyNeighList` wrapping access to neighbor list data - :rtype: NumPyNeighList - """ - if idx < 0: - return None - return NumPyNeighList(self.lmp, idx) - - # ------------------------------------------------------------------------- - - def get_neighlist_element_neighbors(self, idx, element): - """Return data of neighbor list entry - - This function is a wrapper around the function - :py:meth:`lammps.get_neighlist_element_neighbors() ` - method. It behaves the same as the original method, but returns a NumPy array containing the neighbors - instead of a ``ctypes`` pointer. - - :param element: neighbor list index - :type element: int - :param element: neighbor list element index - :type element: int - :return: tuple with atom local index and numpy array of neighbor local atom indices - :rtype: (int, numpy.array) - """ - iatom, numneigh, c_neighbors = self.lmp.get_neighlist_element_neighbors(idx, element) - neighbors = self.iarray(c_int, c_neighbors, numneigh, 1) - return iatom, neighbors - - # ------------------------------------------------------------------------- - - def iarray(self, c_int_type, raw_ptr, nelem, dim=1): - import numpy as np - np_int_type = self._ctype_to_numpy_int(c_int_type) - - if dim == 1: - ptr = cast(raw_ptr, POINTER(c_int_type * nelem)) - else: - ptr = cast(raw_ptr[0], POINTER(c_int_type * nelem * dim)) - - a = np.frombuffer(ptr.contents, dtype=np_int_type) - a.shape = (nelem, dim) - return a - - # ------------------------------------------------------------------------- - - def darray(self, raw_ptr, nelem, dim=1): - import numpy as np - if dim == 1: - ptr = cast(raw_ptr, POINTER(c_double * nelem)) - else: - ptr = cast(raw_ptr[0], POINTER(c_double * nelem * dim)) - - a = np.frombuffer(ptr.contents) - a.shape = (nelem, dim) - return a diff --git a/python/lammps/data.py b/python/lammps/data.py new file mode 100644 index 0000000000..2cf100ed82 --- /dev/null +++ b/python/lammps/data.py @@ -0,0 +1,73 @@ +# ---------------------------------------------------------------------- +# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator +# http://lammps.sandia.gov, Sandia National Laboratories +# Steve Plimpton, sjplimp@sandia.gov +# +# Copyright (2003) Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains +# certain rights in this software. This software is distributed under +# the GNU General Public License. +# +# See the README file in the top-level LAMMPS directory. +# ------------------------------------------------------------------------- + +################################################################################ +# LAMMPS data structures +# Written by Richard Berger +################################################################################ + +class NeighList: + """This is a wrapper class that exposes the contents of a neighbor list. + + It can be used like a regular Python list. Each element is a tuple of: + + * the atom local index + * its number of neighbors + * and a pointer to an c_int array containing local atom indices of its + neighbors + + Internally it uses the lower-level LAMMPS C-library interface. + + :param lmp: reference to instance of :py:class:`lammps` + :type lmp: lammps + :param idx: neighbor list index + :type idx: int + """ + def __init__(self, lmp, idx): + self.lmp = lmp + self.idx = idx + + def __str__(self): + return "Neighbor List ({} atoms)".format(self.size) + + def __repr__(self): + return self.__str__() + + @property + def size(self): + """ + :return: number of elements in neighbor list + """ + return self.lmp.get_neighlist_size(self.idx) + + def get(self, element): + """ + :return: tuple with atom local index, numpy array of neighbor local atom indices + :rtype: (int, int, ctypes.POINTER(c_int)) + """ + iatom, numneigh, neighbors = self.lmp.get_neighlist_element_neighbors(self.idx, element) + return iatom, numneigh, neighbors + + # the methods below implement the iterator interface, so NeighList can be used like a regular Python list + + def __getitem__(self, element): + return self.get(element) + + def __len__(self): + return self.size + + def __iter__(self): + inum = self.size + + for ii in range(inum): + yield self.get(ii) diff --git a/python/lammps/numpy.py b/python/lammps/numpy.py new file mode 100644 index 0000000000..e7b4ef9fcd --- /dev/null +++ b/python/lammps/numpy.py @@ -0,0 +1,335 @@ +# ---------------------------------------------------------------------- +# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator +# http://lammps.sandia.gov, Sandia National Laboratories +# Steve Plimpton, sjplimp@sandia.gov +# +# Copyright (2003) Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains +# certain rights in this software. This software is distributed under +# the GNU General Public License. +# +# See the README file in the top-level LAMMPS directory. +# ------------------------------------------------------------------------- + +################################################################################ +# NumPy additions +# Written by Richard Berger +################################################################################ + +import warnings +from ctypes import POINTER, c_double, c_int, c_int32, c_int64, cast + +import numpy as np + +from .constants import * +from .data import NeighList + + +class numpy_wrapper: + """lammps API NumPy Wrapper + + This is a wrapper class that provides additional methods on top of an + existing :py:class:`lammps` instance. The methods transform raw ctypes + pointers into NumPy arrays, which give direct access to the + original data while protecting against out-of-bounds accesses. + + There is no need to explicitly instantiate this class. Each instance + of :py:class:`lammps` has a :py:attr:`numpy ` property + that returns an instance. + + :param lmp: instance of the :py:class:`lammps` class + :type lmp: lammps + """ + def __init__(self, lmp): + self.lmp = lmp + + # ------------------------------------------------------------------------- + + def _ctype_to_numpy_int(self, ctype_int): + if ctype_int == c_int32: + return np.int32 + elif ctype_int == c_int64: + return np.int64 + return np.intc + + # ------------------------------------------------------------------------- + + def extract_atom(self, name, dtype=LAMMPS_AUTODETECT, nelem=LAMMPS_AUTODETECT, dim=LAMMPS_AUTODETECT): + """Retrieve per-atom properties from LAMMPS as NumPy arrays + + This is a wrapper around the :py:meth:`lammps.extract_atom()` method. + It behaves the same as the original method, but returns NumPy arrays + instead of ``ctypes`` pointers. + + .. note:: + + While the returned arrays of per-atom data are dimensioned + for the range [0:nmax] - as is the underlying storage - + the data is usually only valid for the range of [0:nlocal], + unless the property of interest is also updated for ghost + atoms. In some cases, this depends on a LAMMPS setting, see + for example :doc:`comm_modify vel yes `. + + :param name: name of the property + :type name: string + :param dtype: type of the returned data (see :ref:`py_datatype_constants`) + :type dtype: int, optional + :param nelem: number of elements in array + :type nelem: int, optional + :param dim: dimension of each element + :type dim: int, optional + :return: requested data as NumPy array with direct access to C data or None + :rtype: numpy.array or NoneType + """ + if dtype == LAMMPS_AUTODETECT: + dtype = self.lmp.extract_atom_datatype(name) + + if nelem == LAMMPS_AUTODETECT: + if name == "mass": + nelem = self.lmp.extract_global("ntypes") + 1 + else: + nelem = self.lmp.extract_global("nlocal") + if dim == LAMMPS_AUTODETECT: + if dtype in (LAMMPS_INT_2D, LAMMPS_DOUBLE_2D, LAMMPS_INT64_2D): + # TODO add other fields + if name in ("x", "v", "f", "angmom", "torque", "csforce", "vforce"): + dim = 3 + else: + dim = 2 + else: + dim = 1 + + raw_ptr = self.lmp.extract_atom(name, dtype) + + if dtype in (LAMMPS_DOUBLE, LAMMPS_DOUBLE_2D): + return self.darray(raw_ptr, nelem, dim) + elif dtype in (LAMMPS_INT, LAMMPS_INT_2D): + return self.iarray(c_int32, raw_ptr, nelem, dim) + elif dtype in (LAMMPS_INT64, LAMMPS_INT64_2D): + return self.iarray(c_int64, raw_ptr, nelem, dim) + return raw_ptr + + # ------------------------------------------------------------------------- + + def extract_atom_iarray(self, name, nelem, dim=1): + warnings.warn("deprecated, use extract_atom instead", DeprecationWarning) + + if name in ['id', 'molecule']: + c_int_type = self.lmp.c_tagint + elif name in ['image']: + c_int_type = self.lmp.c_imageint + else: + c_int_type = c_int + + if dim == 1: + raw_ptr = self.lmp.extract_atom(name, LAMMPS_INT) + else: + raw_ptr = self.lmp.extract_atom(name, LAMMPS_INT_2D) + + return self.iarray(c_int_type, raw_ptr, nelem, dim) + + # ------------------------------------------------------------------------- + + def extract_atom_darray(self, name, nelem, dim=1): + warnings.warn("deprecated, use extract_atom instead", DeprecationWarning) + + if dim == 1: + raw_ptr = self.lmp.extract_atom(name, LAMMPS_DOUBLE) + else: + raw_ptr = self.lmp.extract_atom(name, LAMMPS_DOUBLE_2D) + + return self.darray(raw_ptr, nelem, dim) + + # ------------------------------------------------------------------------- + + def extract_compute(self, cid, style, type): + """Retrieve data from a LAMMPS compute + + This is a wrapper around the + :py:meth:`lammps.extract_compute() ` method. + It behaves the same as the original method, but returns NumPy arrays + instead of ``ctypes`` pointers. + + :param id: compute ID + :type id: string + :param style: style of the data retrieve (global, atom, or local), see :ref:`py_style_constants` + :type style: int + :param type: type of the returned data (scalar, vector, or array), see :ref:`py_type_constants` + :type type: int + :return: requested data either as float, as NumPy array with direct access to C data, or None + :rtype: float, numpy.array, or NoneType + """ + value = self.lmp.extract_compute(cid, style, type) + + if style in (LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL): + if type == LMP_TYPE_VECTOR: + nrows = self.lmp.extract_compute(cid, style, LMP_SIZE_VECTOR) + return self.darray(value, nrows) + elif type == LMP_TYPE_ARRAY: + nrows = self.lmp.extract_compute(cid, style, LMP_SIZE_ROWS) + ncols = self.lmp.extract_compute(cid, style, LMP_SIZE_COLS) + return self.darray(value, nrows, ncols) + elif style == LMP_STYLE_ATOM: + if type == LMP_TYPE_VECTOR: + nlocal = self.lmp.extract_global("nlocal") + return self.darray(value, nlocal) + elif type == LMP_TYPE_ARRAY: + nlocal = self.lmp.extract_global("nlocal") + ncols = self.lmp.extract_compute(cid, style, LMP_SIZE_COLS) + return self.darray(value, nlocal, ncols) + return value + + # ------------------------------------------------------------------------- + + def extract_fix(self, fid, style, type, nrow=0, ncol=0): + """Retrieve data from a LAMMPS fix + + This is a wrapper around the :py:meth:`lammps.extract_fix() ` method. + It behaves the same as the original method, but returns NumPy arrays + instead of ``ctypes`` pointers. + + :param id: fix ID + :type id: string + :param style: style of the data retrieve (global, atom, or local), see :ref:`py_style_constants` + :type style: int + :param type: type or size of the returned data (scalar, vector, or array), see :ref:`py_type_constants` + :type type: int + :param nrow: index of global vector element or row index of global array element + :type nrow: int + :param ncol: column index of global array element + :type ncol: int + :return: requested data + :rtype: integer or double value, pointer to 1d or 2d double array or None + + """ + value = self.lmp.extract_fix(fid, style, type, nrow, ncol) + if style == LMP_STYLE_ATOM: + if type == LMP_TYPE_VECTOR: + nlocal = self.lmp.extract_global("nlocal") + return self.darray(value, nlocal) + elif type == LMP_TYPE_ARRAY: + nlocal = self.lmp.extract_global("nlocal") + ncols = self.lmp.extract_fix(fid, style, LMP_SIZE_COLS, 0, 0) + return self.darray(value, nlocal, ncols) + elif style == LMP_STYLE_LOCAL: + if type == LMP_TYPE_VECTOR: + nrows = self.lmp.extract_fix(fid, style, LMP_SIZE_ROWS, 0, 0) + return self.darray(value, nrows) + elif type == LMP_TYPE_ARRAY: + nrows = self.lmp.extract_fix(fid, style, LMP_SIZE_ROWS, 0, 0) + ncols = self.lmp.extract_fix(fid, style, LMP_SIZE_COLS, 0, 0) + return self.darray(value, nrows, ncols) + return value + + # ------------------------------------------------------------------------- + + def extract_variable(self, name, group=None, vartype=LMP_VAR_EQUAL): + """ Evaluate a LAMMPS variable and return its data + + This function is a wrapper around the function + :py:meth:`lammps.extract_variable() ` + method. It behaves the same as the original method, but returns NumPy arrays + instead of ``ctypes`` pointers. + + :param name: name of the variable to execute + :type name: string + :param group: name of group for atom-style variable (ignored for equal-style variables) + :type group: string + :param vartype: type of variable, see :ref:`py_vartype_constants` + :type vartype: int + :return: the requested data or None + :rtype: c_double, numpy.array, or NoneType + """ + value = self.lmp.extract_variable(name, group, vartype) + if vartype == LMP_VAR_ATOM: + return np.ctypeslib.as_array(value) + return value + + # ------------------------------------------------------------------------- + + def get_neighlist(self, idx): + """Returns an instance of :class:`NumPyNeighList` which wraps access to the neighbor list with the given index + + :param idx: index of neighbor list + :type idx: int + :return: an instance of :class:`NumPyNeighList` wrapping access to neighbor list data + :rtype: NumPyNeighList + """ + if idx < 0: + return None + return NumPyNeighList(self.lmp, idx) + + # ------------------------------------------------------------------------- + + def get_neighlist_element_neighbors(self, idx, element): + """Return data of neighbor list entry + + This function is a wrapper around the function + :py:meth:`lammps.get_neighlist_element_neighbors() ` + method. It behaves the same as the original method, but returns a NumPy array containing the neighbors + instead of a ``ctypes`` pointer. + + :param element: neighbor list index + :type element: int + :param element: neighbor list element index + :type element: int + :return: tuple with atom local index and numpy array of neighbor local atom indices + :rtype: (int, numpy.array) + """ + iatom, numneigh, c_neighbors = self.lmp.get_neighlist_element_neighbors(idx, element) + neighbors = self.iarray(c_int, c_neighbors, numneigh, 1) + return iatom, neighbors + + # ------------------------------------------------------------------------- + + def iarray(self, c_int_type, raw_ptr, nelem, dim=1): + np_int_type = self._ctype_to_numpy_int(c_int_type) + + if dim == 1: + ptr = cast(raw_ptr, POINTER(c_int_type * nelem)) + else: + ptr = cast(raw_ptr[0], POINTER(c_int_type * nelem * dim)) + + a = np.frombuffer(ptr.contents, dtype=np_int_type) + a.shape = (nelem, dim) + return a + + # ------------------------------------------------------------------------- + + def darray(self, raw_ptr, nelem, dim=1): + if dim == 1: + ptr = cast(raw_ptr, POINTER(c_double * nelem)) + else: + ptr = cast(raw_ptr[0], POINTER(c_double * nelem * dim)) + + a = np.frombuffer(ptr.contents) + a.shape = (nelem, dim) + return a + +# ------------------------------------------------------------------------- + +class NumPyNeighList(NeighList): + """This is a wrapper class that exposes the contents of a neighbor list. + + It can be used like a regular Python list. Each element is a tuple of: + + * the atom local index + * a NumPy array containing the local atom indices of its neighbors + + Internally it uses the lower-level LAMMPS C-library interface. + + :param lmp: reference to instance of :py:class:`lammps` + :type lmp: lammps + :param idx: neighbor list index + :type idx: int + """ + def __init__(self, lmp, idx): + super(NumPyNeighList, self).__init__(lmp, idx) + + def get(self, element): + """ + :return: tuple with atom local index, numpy array of neighbor local atom indices + :rtype: (int, numpy.array) + """ + iatom, neighbors = self.lmp.numpy.get_neighlist_element_neighbors(self.idx, element) + return iatom, neighbors From 47d18c9f903d8155c4bd8c9b066a34b72bcc1df7 Mon Sep 17 00:00:00 2001 From: Yaser Afshar Date: Tue, 15 Dec 2020 15:48:49 -0600 Subject: [PATCH 093/187] Add KIM_EXTRA_UNITTESTS option Add KIM_EXTRA_UNITTESTS option which defaults to OFF and can be enabled on request to add a corresponding pre-processor define to do extra tests. --- cmake/Modules/Packages/KIM.cmake | 2 ++ unittest/commands/CMakeLists.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 91a48eb3a7..83a96d02b8 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -19,6 +19,8 @@ if(CURL_FOUND) target_compile_definitions(lammps PRIVATE -DLMP_NO_SSL_CHECK) endif() endif() +set(KIM_EXTRA_UNITTESTS OFF CACHE STRING "Set extra unit tests verbose mode on/off. If on, extra tests are included.") +mark_as_advanced(KIM_EXTRA_UNITTESTS) find_package(PkgConfig QUIET) set(DOWNLOAD_KIM_DEFAULT ON) if(PKG_CONFIG_FOUND) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index e9cdf78ab7..218189721a 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -8,6 +8,13 @@ target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock GTest::GTe add_test(NAME LatticeRegion COMMAND test_lattice_region WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) add_executable(test_kim_commands test_kim_commands.cpp) +if(KIM_EXTRA_UNITTESTS) + if(CURL_FOUND) + target_compile_definitions(test_kim_commands PRIVATE -DKIM_EXTRA_UNITTESTS) + else() + message(STATUS "CURL not found. Enabling KIM extra unit tests requires to have libcurl installed.") + endif() +endif() target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME KimCommands COMMAND test_kim_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) From 94cbee7710091ccdca999c8adbb6c5180a0cbd4a Mon Sep 17 00:00:00 2001 From: Yaser Afshar Date: Tue, 15 Dec 2020 15:50:15 -0600 Subject: [PATCH 094/187] Document the cmake KIM_EXTRA_UNITTESTS option Document KIM_EXTRA_UNITTESTS option and it's pre-requisites. --- doc/src/Build_extras.rst | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 5ef29fbca1..6847b8c030 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -282,6 +282,7 @@ minutes to hours) to build. Of course you only need to do that once.) -D DOWNLOAD_KIM=value # download OpenKIM API v2 for build, value = no (default) or yes -D LMP_DEBUG_CURL=value # set libcurl verbose mode on/off, value = off (default) or on -D LMP_NO_SSL_CHECK=value # tell libcurl to not verify the peer, value = no (default) or yes + -D KIM_EXTRA_UNITTESTS=value # enables extra unit tests, value = no (default) or yes If ``DOWNLOAD_KIM`` is set to *yes* (or *on*), the KIM API library will be downloaded and built inside the CMake build directory. If @@ -290,6 +291,11 @@ minutes to hours) to build. Of course you only need to do that once.) ``PKG_CONFIG_PATH`` environment variable so that libkim-api can be found, or run the command ``source kim-api-activate``. + Extra unit tests can only be available if they are explicitly requested + (``KIM_EXTRA_UNITTESTS`` is set to *yes* (or *on*)) and the prerequisites + are met. See :ref:`KIM Extra unit tests ` for + more details on this. + .. tab:: Traditional make You can download and build the KIM library manually if you prefer; @@ -338,6 +344,38 @@ specify your own CA cert path by setting the environment variable ``CURL_CA_BUNDLE`` to the path of your choice. A call to the KIM web query would get this value from the environment variable. +.. _kim_extra_unittests: + +KIM Extra unit tests (CMake only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +During development, testing, or debugging, if +:doc:`unit testing ` is enabled in LAMMPS, one can also +enable extra tests on :doc:`KIM commands ` by setting the +``KIM_EXTRA_UNITTESTS`` to *yes* (or *on*). + +Enabling the extra unit tests have some requirements, + +* It requires to have internet access. +* It requires to have libcurl installed with the matching development headers + and the curl-config tool. +* It requires to build LAMMPS with the PYTHON package installed and linked to + Python 3.6 or later. See the :ref:`PYTHON package build info ` for + more details on this. +* It requires to have ``kim-property`` Python package installed, which can be + easily done using *pip* as ``pip install kim-property``, or from the + *conda-forge* channel as ``conda install kim-property`` if LAMMPS is built in + Conda. More detailed information is available at: + `kim-property installation `_. +* It is also necessary to install + ``EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000``, and + ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005`` KIM models. + See `Obtaining KIM Models `_ + to learn how to install a pre-build binary of the OpenKIM Repository of + Models or see + `Installing KIM Models `_ + to learn how to install the specific KIM models. + ---------- .. _kokkos: From 9f8b42acca448b042684c3ccda0fe074f1222832 Mon Sep 17 00:00:00 2001 From: Yaser Afshar Date: Tue, 15 Dec 2020 16:31:23 -0600 Subject: [PATCH 095/187] Add extra unit tests and uncomment the kim_query tests --- unittest/commands/test_kim_commands.cpp | 94 ++++++++++++++++--------- 1 file changed, 60 insertions(+), 34 deletions(-) diff --git a/unittest/commands/test_kim_commands.cpp b/unittest/commands/test_kim_commands.cpp index 42e8a441bd..4e16e28783 100644 --- a/unittest/commands/test_kim_commands.cpp +++ b/unittest/commands/test_kim_commands.cpp @@ -326,7 +326,8 @@ TEST_F(KimCommandsTest, kim_property) "3 >= 3.6 support.*", lmp->input->one("kim_property");); } else { - TEST_FAILURE(".*ERROR: Invalid kim_property command.*", lmp->input->one("kim_property");); + TEST_FAILURE(".*ERROR: Invalid kim_property command.*", + lmp->input->one("kim_property");); TEST_FAILURE(".*ERROR: Invalid kim_property command.*", lmp->input->one("kim_property create");); TEST_FAILURE(".*ERROR: Incorrect arguments in kim_property command.\n" @@ -334,6 +335,29 @@ TEST_F(KimCommandsTest, kim_property) "is mandatory.*", lmp->input->one("kim_property unknown 1 atomic-mass");); } +#if defined(KIM_EXTRA_UNITTESTS) + TEST_FAILURE(".*ERROR: Invalid 'kim_property create' command.*", + lmp->input->one("kim_property create 1");); + TEST_FAILURE(".*ERROR: Invalid 'kim_property destroy' command.*", + lmp->input->one("kim_property destroy 1 cohesive-potential-energy-cubic-crystal");); + TEST_FAILURE(".*ERROR: Invalid 'kim_property modify' command.*", + lmp->input->one("kim_property modify 1 key short-name");); + TEST_FAILURE(".*ERROR: There is no property instance to modify the content.*", + lmp->input->one("kim_property modify 1 key short-name source-value 1 fcc");); + TEST_FAILURE(".*ERROR: Invalid 'kim_property remove' command.*", + lmp->input->one("kim_property remove 1 key");); + TEST_FAILURE(".*ERROR: There is no property instance to remove the content.*", + lmp->input->one("kim_property remove 1 key short-name");); + TEST_FAILURE(".*ERROR: There is no property instance to dump the content.*", + lmp->input->one("kim_property dump results.edn");); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("clear"); + lmp->input->one("kim_init LennardJones612_UniversalShifted__MO_959249795837_003 real"); + lmp->input->one("kim_property create 1 cohesive-potential-energy-cubic-crystal"); + lmp->input->one("kim_property modify 1 key short-name source-value 1 fcc"); + lmp->input->one("kim_property destroy 1"); + if (!verbose) ::testing::internal::GetCapturedStdout(); +#endif } TEST_F(KimCommandsTest, kim_query) @@ -420,48 +444,50 @@ TEST_F(KimCommandsTest, kim_query) "units=[\"angstrom\"]"; TEST_FAILURE(".*ERROR: OpenKIM query failed:.*", lmp->input->one(squery);); - // if (!verbose) ::testing::internal::CaptureStdout(); - // lmp->input->one("clear"); - // lmp->input->one("kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal"); +#if defined(KIM_EXTRA_UNITTESTS) + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("clear"); + lmp->input->one("kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal"); - // squery = "kim_query latconst split get_lattice_constant_hexagonal "; - // squery += "crystal=[\"hcp\"] species=[\"Zr\"] units=[\"angstrom\"]"; - // lmp->input->one(squery); - // if (!verbose) ::testing::internal::GetCapturedStdout(); + squery = "kim_query latconst split get_lattice_constant_hexagonal "; + squery += "crystal=[\"hcp\"] species=[\"Zr\"] units=[\"angstrom\"]"; + lmp->input->one(squery); + if (!verbose) ::testing::internal::GetCapturedStdout(); - // ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) == - // std::string("3.234055244384789"))); - // ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_2")) == - // std::string("5.167650199630013"))); + ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) == + std::string("3.234055244384789"))); + ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_2")) == + std::string("5.167650199630013"))); - // if (!verbose) ::testing::internal::CaptureStdout(); - // lmp->input->one("clear"); - // lmp->input->one("kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal"); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("clear"); + lmp->input->one("kim_init EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000 metal"); - // squery = "kim_query latconst list get_lattice_constant_hexagonal "; - // squery += "crystal=[hcp] species=[Zr] units=[angstrom]"; - // lmp->input->one(squery); - // if (!verbose) ::testing::internal::GetCapturedStdout(); + squery = "kim_query latconst list get_lattice_constant_hexagonal "; + squery += "crystal=[hcp] species=[Zr] units=[angstrom]"; + lmp->input->one(squery); + if (!verbose) ::testing::internal::GetCapturedStdout(); - // ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst")) == - // std::string("3.234055244384789 5.167650199630013"))); + ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst")) == + std::string("3.234055244384789 5.167650199630013"))); - // squery = "kim_query latconst list get_lattice_constant_hexagonal "; - // squery += "crystal=[bcc] species=[Zr] units=[angstrom]"; - // TEST_FAILURE(".*ERROR: OpenKIM query failed:.*", lmp->input->one(squery);); + squery = "kim_query latconst list get_lattice_constant_hexagonal "; + squery += "crystal=[bcc] species=[Zr] units=[angstrom]"; + TEST_FAILURE(".*ERROR: OpenKIM query failed:.*", lmp->input->one(squery);); - // if (!verbose) ::testing::internal::CaptureStdout(); - // lmp->input->one("clear"); - // lmp->input->one("kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal"); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("clear"); + lmp->input->one("kim_init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal"); - // squery = "kim_query alpha get_linear_thermal_expansion_coefficient_cubic "; - // squery += "crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] "; - // squery += "temperature_units=[K]"; - // lmp->input->one(squery); - // if (!verbose) ::testing::internal::GetCapturedStdout(); + squery = "kim_query alpha get_linear_thermal_expansion_coefficient_cubic "; + squery += "crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] "; + squery += "temperature_units=[K]"; + lmp->input->one(squery); + if (!verbose) ::testing::internal::GetCapturedStdout(); - // ASSERT_TRUE((std::string(lmp->input->variable->retrieve("alpha")) == - // std::string("1.654960564704273e-05"))); + ASSERT_TRUE((std::string(lmp->input->variable->retrieve("alpha")) == + std::string("1.654960564704273e-05"))); +#endif } } // namespace LAMMPS_NS From 162d34d16852cdc25f151bff39ee9756ae216a5c Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 17:58:41 -0500 Subject: [PATCH 096/187] Update Python coverage tests --- unittest/python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index 47fdbbfb2d..c344a51ce7 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -44,7 +44,7 @@ if (Python_EXECUTABLE) find_package_handle_standard_args(COVERAGE DEFAULT_MSG COVERAGE_BINARY) if(COVERAGE_FOUND) - set(PYTHON_TEST_RUNNER ${Python_EXECUTABLE} -u ${COVERAGE_BINARY} run --parallel-mode --include=${LAMMPS_PYTHON_DIR}/lammps.py --omit=${LAMMPS_PYTHON_DIR}/install.py) + set(PYTHON_TEST_RUNNER ${Python_EXECUTABLE} -u ${COVERAGE_BINARY} run --parallel-mode --include=${LAMMPS_PYTHON_DIR}/lammps/*.py --omit=${LAMMPS_PYTHON_DIR}/install.py) else() set(PYTHON_TEST_RUNNER ${Python_EXECUTABLE} -u) endif() From ccb304fa1360a198cc0246b2fcf203595793ccc5 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 18:23:40 -0500 Subject: [PATCH 097/187] Remove deprecated PyEval_InitThreads() not needed by Python > 3.6 --- src/PYTHON/python_impl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 22bf8e77fb..1b3fabfa62 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -53,7 +53,15 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) external_interpreter = Py_IsInitialized(); Py_Initialize(); - PyEval_InitThreads(); + + // only needed for Python 2.x and Python 3 < 3.7 + // With Python 3.7 this function is now called by Py_Initialize() + // Deprecated since version 3.9, will be removed in version 3.11 +#if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 7 + if(!PyEval_ThreadsInitialized()) { + PyEval_InitThreads(); + } +#endif PyGILState_STATE gstate = PyGILState_Ensure(); From ac203b36839675f5c7c9c972a8328f3df3aea300 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 18:50:38 -0500 Subject: [PATCH 098/187] Keep numpy imports inside of functions --- python/lammps/numpy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/lammps/numpy.py b/python/lammps/numpy.py index e7b4ef9fcd..ce64d68c90 100644 --- a/python/lammps/numpy.py +++ b/python/lammps/numpy.py @@ -19,7 +19,6 @@ import warnings from ctypes import POINTER, c_double, c_int, c_int32, c_int64, cast -import numpy as np from .constants import * from .data import NeighList @@ -46,6 +45,7 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def _ctype_to_numpy_int(self, ctype_int): + import numpy as np if ctype_int == c_int32: return np.int32 elif ctype_int == c_int64: @@ -240,6 +240,7 @@ class numpy_wrapper: :return: the requested data or None :rtype: c_double, numpy.array, or NoneType """ + import numpy as np value = self.lmp.extract_variable(name, group, vartype) if vartype == LMP_VAR_ATOM: return np.ctypeslib.as_array(value) @@ -283,6 +284,7 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def iarray(self, c_int_type, raw_ptr, nelem, dim=1): + import numpy as np np_int_type = self._ctype_to_numpy_int(c_int_type) if dim == 1: @@ -297,6 +299,7 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def darray(self, raw_ptr, nelem, dim=1): + import numpy as np if dim == 1: ptr = cast(raw_ptr, POINTER(c_double * nelem)) else: From 3103fe85f6c39672dae0d092c2ca5e9771810d6c Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 19:16:29 -0500 Subject: [PATCH 099/187] Update Python_module.rst --- doc/src/Python_module.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/src/Python_module.rst b/doc/src/Python_module.rst index 04bc3f2c5b..8b4fbe1c2e 100644 --- a/doc/src/Python_module.rst +++ b/doc/src/Python_module.rst @@ -3,12 +3,12 @@ The ``lammps`` Python module .. py:module:: lammps -The LAMMPS Python interface is implemented as a module called -:py:mod:`lammps` in the ``lammps.py`` file in the ``python`` folder of -the LAMMPS source code distribution. After compilation of LAMMPS, the -module can be installed into a Python system folder or a user folder -with ``make install-python``. Components of the module can then loaded -into a Python session with the ``import`` command. +The LAMMPS Python interface is implemented as a module called :py:mod:`lammps` +which is defined in the ``lammps`` package in the ``python`` folder of the +LAMMPS source code distribution. After compilation of LAMMPS, the module can +be installed into a Python system folder or a user folder with ``make +install-python``. Components of the module can then loaded into a Python +session with the ``import`` command. There are multiple Python interface classes in the :py:mod:`lammps` module: @@ -44,7 +44,7 @@ functions. Below is a detailed documentation of the API. .. autoclass:: lammps.lammps :members: -.. autoclass:: lammps.numpy_wrapper +.. autoclass:: lammps.numpy::numpy_wrapper :members: ---------- @@ -117,8 +117,8 @@ Style Constants to request from computes or fixes. See :cpp:enum:`_LMP_STYLE_CONST` for the equivalent constants in the C library interface. Used in :py:func:`lammps.extract_compute`, :py:func:`lammps.extract_fix`, and their NumPy variants - :py:func:`lammps.numpy.extract_compute() ` and - :py:func:`lammps.numpy.extract_fix() `. + :py:func:`lammps.numpy.extract_compute() ` and + :py:func:`lammps.numpy.extract_fix() `. .. _py_type_constants: @@ -132,8 +132,8 @@ Type Constants to request from computes or fixes. See :cpp:enum:`_LMP_TYPE_CONST` for the equivalent constants in the C library interface. Used in :py:func:`lammps.extract_compute`, :py:func:`lammps.extract_fix`, and their NumPy variants - :py:func:`lammps.numpy.extract_compute() ` and - :py:func:`lammps.numpy.extract_fix() `. + :py:func:`lammps.numpy.extract_compute() ` and + :py:func:`lammps.numpy.extract_fix() `. .. _py_vartype_constants: @@ -153,6 +153,6 @@ Classes representing internal objects :members: :no-undoc-members: -.. autoclass:: lammps.NumPyNeighList +.. autoclass:: lammps.numpy::NumPyNeighList :members: :no-undoc-members: From 7a9d6611d9c574b122fdfa475c9b3b89e7300f9d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 20:36:27 -0500 Subject: [PATCH 100/187] add false positive --- doc/utils/sphinx-config/false_positives.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 3fd204ceb8..0563ac1499 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -3001,6 +3001,7 @@ Sukumaran Sulc sumsq Sunderland +supercell superset supersphere Supinski From 6671e7ba3c164df03735b8f21a5d2d1bc1bc7cf5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 20:37:14 -0500 Subject: [PATCH 101/187] relax some more unittest thresholds to reduce failures with crappy compilers --- unittest/force-styles/tests/angle-harmonic.yaml | 2 +- unittest/force-styles/tests/angle-table_linear.yaml | 2 +- unittest/force-styles/tests/angle-table_spline.yaml | 2 +- unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml | 2 +- unittest/force-styles/tests/fix-timestep-addforce_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-addforce_variable.yaml | 2 +- unittest/force-styles/tests/fix-timestep-aveforce_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-aveforce_variable.yaml | 2 +- unittest/force-styles/tests/fix-timestep-drag.yaml | 2 +- unittest/force-styles/tests/fix-timestep-heat.yaml | 2 +- unittest/force-styles/tests/fix-timestep-momentum.yaml | 2 +- unittest/force-styles/tests/fix-timestep-npt_aniso.yaml | 2 +- unittest/force-styles/tests/fix-timestep-npt_iso.yaml | 2 +- unittest/force-styles/tests/fix-timestep-nve.yaml | 2 +- unittest/force-styles/tests/fix-timestep-nve_limit.yaml | 2 +- unittest/force-styles/tests/fix-timestep-nve_noforce.yaml | 2 +- unittest/force-styles/tests/fix-timestep-nvt.yaml | 2 +- .../force-styles/tests/fix-timestep-press_berendsen_iso.yaml | 2 +- unittest/force-styles/tests/fix-timestep-rattle_bond.yaml | 2 +- unittest/force-styles/tests/fix-timestep-rigid_nph_small.yaml | 2 +- unittest/force-styles/tests/fix-timestep-setforce_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-setforce_variable.yaml | 2 +- unittest/force-styles/tests/fix-timestep-shake_angle.yaml | 2 +- unittest/force-styles/tests/fix-timestep-shake_bond.yaml | 2 +- unittest/force-styles/tests/fix-timestep-spring_chunk.yaml | 2 +- unittest/force-styles/tests/fix-timestep-spring_self.yaml | 2 +- unittest/force-styles/tests/fix-timestep-temp_berendsen.yaml | 2 +- unittest/force-styles/tests/fix-timestep-temp_csld.yaml | 2 +- unittest/force-styles/tests/fix-timestep-temp_csvr.yaml | 2 +- .../force-styles/tests/fix-timestep-wall_harmonic_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-wall_lj1043_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-wall_lj126_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-wall_lj93_const.yaml | 2 +- unittest/force-styles/tests/fix-timestep-wall_morse_const.yaml | 2 +- unittest/force-styles/tests/kspace-pppm_tip4p_ad.yaml | 2 +- unittest/force-styles/tests/kspace-pppm_tip4p_slab.yaml | 2 +- unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml | 2 +- unittest/force-styles/tests/mol-pair-buck.yaml | 2 +- unittest/force-styles/tests/mol-pair-buck_coul_long.yaml | 2 +- unittest/force-styles/tests/mol-pair-buck_coul_msm.yaml | 2 +- unittest/force-styles/tests/mol-pair-buck_coul_msm_table.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_cut_coul_cut.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_cut_coul_dsf.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_cut_coul_msm.yaml | 2 +- unittest/force-styles/tests/mol-pair-lj_expand.yaml | 2 +- unittest/force-styles/tests/mol-pair-tip4p_cut.yaml | 2 +- unittest/force-styles/tests/mol-pair-tip4p_long.yaml | 2 +- 48 files changed, 48 insertions(+), 48 deletions(-) diff --git a/unittest/force-styles/tests/angle-harmonic.yaml b/unittest/force-styles/tests/angle-harmonic.yaml index a419c131f1..6d9cf67210 100644 --- a/unittest/force-styles/tests/angle-harmonic.yaml +++ b/unittest/force-styles/tests/angle-harmonic.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:34 202 -epsilon: 2.5e-13 +epsilon: 5e-13 prerequisites: ! | atom full angle harmonic diff --git a/unittest/force-styles/tests/angle-table_linear.yaml b/unittest/force-styles/tests/angle-table_linear.yaml index 2c5410f646..7dc66d9edf 100644 --- a/unittest/force-styles/tests/angle-table_linear.yaml +++ b/unittest/force-styles/tests/angle-table_linear.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:35 202 -epsilon: 2.5e-13 +epsilon: 5e-13 prerequisites: ! | atom full angle table diff --git a/unittest/force-styles/tests/angle-table_spline.yaml b/unittest/force-styles/tests/angle-table_spline.yaml index 42d8f58900..10edec26fd 100644 --- a/unittest/force-styles/tests/angle-table_spline.yaml +++ b/unittest/force-styles/tests/angle-table_spline.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:35 202 -epsilon: 2.5e-13 +epsilon: 5e-13 prerequisites: ! | atom full angle table diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml index 6647cc39a5..b3569a7e74 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:23 202 -epsilon: 5e-12 +epsilon: 1e-11 prerequisites: ! | pair eam/fs pre_commands: ! "" diff --git a/unittest/force-styles/tests/fix-timestep-addforce_const.yaml b/unittest/force-styles/tests/fix-timestep-addforce_const.yaml index 13f4644815..39bbfcf280 100644 --- a/unittest/force-styles/tests/fix-timestep-addforce_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-addforce_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:39 202 -epsilon: 5e-12 +epsilon: 9e-12 prerequisites: ! | atom full fix addforce diff --git a/unittest/force-styles/tests/fix-timestep-addforce_variable.yaml b/unittest/force-styles/tests/fix-timestep-addforce_variable.yaml index 112b6d89c1..421051601a 100644 --- a/unittest/force-styles/tests/fix-timestep-addforce_variable.yaml +++ b/unittest/force-styles/tests/fix-timestep-addforce_variable.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:39 202 -epsilon: 5e-12 +epsilon: 2e-11 prerequisites: ! | atom full fix addforce diff --git a/unittest/force-styles/tests/fix-timestep-aveforce_const.yaml b/unittest/force-styles/tests/fix-timestep-aveforce_const.yaml index bb8ec69e3e..18dd4cf4b2 100644 --- a/unittest/force-styles/tests/fix-timestep-aveforce_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-aveforce_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 5e-12 +epsilon: 2e-11 prerequisites: ! | atom full fix aveforce diff --git a/unittest/force-styles/tests/fix-timestep-aveforce_variable.yaml b/unittest/force-styles/tests/fix-timestep-aveforce_variable.yaml index 3f7832acfe..41299b2ec8 100644 --- a/unittest/force-styles/tests/fix-timestep-aveforce_variable.yaml +++ b/unittest/force-styles/tests/fix-timestep-aveforce_variable.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 2e-11 +epsilon: 2.5e-11 prerequisites: ! | atom full fix aveforce diff --git a/unittest/force-styles/tests/fix-timestep-drag.yaml b/unittest/force-styles/tests/fix-timestep-drag.yaml index 9b5791f55b..bb4908f55e 100644 --- a/unittest/force-styles/tests/fix-timestep-drag.yaml +++ b/unittest/force-styles/tests/fix-timestep-drag.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 1e-14 +epsilon: 5e-14 prerequisites: ! | atom full fix drag diff --git a/unittest/force-styles/tests/fix-timestep-heat.yaml b/unittest/force-styles/tests/fix-timestep-heat.yaml index bfd51fb2a9..a7197528f5 100644 --- a/unittest/force-styles/tests/fix-timestep-heat.yaml +++ b/unittest/force-styles/tests/fix-timestep-heat.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix heat diff --git a/unittest/force-styles/tests/fix-timestep-momentum.yaml b/unittest/force-styles/tests/fix-timestep-momentum.yaml index eb5f4e0235..884c71785d 100644 --- a/unittest/force-styles/tests/fix-timestep-momentum.yaml +++ b/unittest/force-styles/tests/fix-timestep-momentum.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 2e-14 +epsilon: 4e-14 prerequisites: ! | atom full fix momentum diff --git a/unittest/force-styles/tests/fix-timestep-npt_aniso.yaml b/unittest/force-styles/tests/fix-timestep-npt_aniso.yaml index 3f71f8d87b..b086a1b95e 100644 --- a/unittest/force-styles/tests/fix-timestep-npt_aniso.yaml +++ b/unittest/force-styles/tests/fix-timestep-npt_aniso.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 2e-12 +epsilon: 4e-11 prerequisites: ! | atom full fix npt diff --git a/unittest/force-styles/tests/fix-timestep-npt_iso.yaml b/unittest/force-styles/tests/fix-timestep-npt_iso.yaml index 365b01c29e..8dec2a1bec 100644 --- a/unittest/force-styles/tests/fix-timestep-npt_iso.yaml +++ b/unittest/force-styles/tests/fix-timestep-npt_iso.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 5e-13 +epsilon: 2e-12 prerequisites: ! | atom full fix npt diff --git a/unittest/force-styles/tests/fix-timestep-nve.yaml b/unittest/force-styles/tests/fix-timestep-nve.yaml index 8626163bd3..5d2efa1373 100644 --- a/unittest/force-styles/tests/fix-timestep-nve.yaml +++ b/unittest/force-styles/tests/fix-timestep-nve.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix nve diff --git a/unittest/force-styles/tests/fix-timestep-nve_limit.yaml b/unittest/force-styles/tests/fix-timestep-nve_limit.yaml index 56f9873ddd..bc6a16704f 100644 --- a/unittest/force-styles/tests/fix-timestep-nve_limit.yaml +++ b/unittest/force-styles/tests/fix-timestep-nve_limit.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix nve/limit diff --git a/unittest/force-styles/tests/fix-timestep-nve_noforce.yaml b/unittest/force-styles/tests/fix-timestep-nve_noforce.yaml index 7bb02e7873..17e9923d45 100644 --- a/unittest/force-styles/tests/fix-timestep-nve_noforce.yaml +++ b/unittest/force-styles/tests/fix-timestep-nve_noforce.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix nve/noforce diff --git a/unittest/force-styles/tests/fix-timestep-nvt.yaml b/unittest/force-styles/tests/fix-timestep-nvt.yaml index 58eeee64d0..6a4ead99c1 100644 --- a/unittest/force-styles/tests/fix-timestep-nvt.yaml +++ b/unittest/force-styles/tests/fix-timestep-nvt.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 5e-14 +epsilon: 2e-13 prerequisites: ! | atom full fix nvt diff --git a/unittest/force-styles/tests/fix-timestep-press_berendsen_iso.yaml b/unittest/force-styles/tests/fix-timestep-press_berendsen_iso.yaml index 975d31692e..5bbf178dc3 100644 --- a/unittest/force-styles/tests/fix-timestep-press_berendsen_iso.yaml +++ b/unittest/force-styles/tests/fix-timestep-press_berendsen_iso.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 2e-13 +epsilon: 2e-12 prerequisites: ! | atom full fix press/berendsen diff --git a/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml b/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml index 8f771d84b3..cad83187c6 100644 --- a/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml +++ b/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 9e-12 +epsilon: 1e-10 prerequisites: ! | atom full fix rattle diff --git a/unittest/force-styles/tests/fix-timestep-rigid_nph_small.yaml b/unittest/force-styles/tests/fix-timestep-rigid_nph_small.yaml index 5019d8fbe5..11d6870a42 100644 --- a/unittest/force-styles/tests/fix-timestep-rigid_nph_small.yaml +++ b/unittest/force-styles/tests/fix-timestep-rigid_nph_small.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 22:36:55 202 -epsilon: 5e-13 +epsilon: 6.5e-13 prerequisites: ! | atom full fix rigid/nph/small diff --git a/unittest/force-styles/tests/fix-timestep-setforce_const.yaml b/unittest/force-styles/tests/fix-timestep-setforce_const.yaml index b932718f71..4ff222aff6 100644 --- a/unittest/force-styles/tests/fix-timestep-setforce_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-setforce_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:42 202 -epsilon: 5e-12 +epsilon: 2e-11 prerequisites: ! | atom full fix setforce diff --git a/unittest/force-styles/tests/fix-timestep-setforce_variable.yaml b/unittest/force-styles/tests/fix-timestep-setforce_variable.yaml index 5c01ca714f..960368a081 100644 --- a/unittest/force-styles/tests/fix-timestep-setforce_variable.yaml +++ b/unittest/force-styles/tests/fix-timestep-setforce_variable.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:42 202 -epsilon: 5e-12 +epsilon: 1e-11 prerequisites: ! | atom full fix setforce diff --git a/unittest/force-styles/tests/fix-timestep-shake_angle.yaml b/unittest/force-styles/tests/fix-timestep-shake_angle.yaml index e2cc5cb36f..1cc3dfe429 100644 --- a/unittest/force-styles/tests/fix-timestep-shake_angle.yaml +++ b/unittest/force-styles/tests/fix-timestep-shake_angle.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:42 202 -epsilon: 2e-12 +epsilon: 3e-10 prerequisites: ! | atom full fix shake diff --git a/unittest/force-styles/tests/fix-timestep-shake_bond.yaml b/unittest/force-styles/tests/fix-timestep-shake_bond.yaml index 70e70215cc..afbba6c6d7 100644 --- a/unittest/force-styles/tests/fix-timestep-shake_bond.yaml +++ b/unittest/force-styles/tests/fix-timestep-shake_bond.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:42 202 -epsilon: 2e-12 +epsilon: 3.5e-11 prerequisites: ! | atom full fix shake diff --git a/unittest/force-styles/tests/fix-timestep-spring_chunk.yaml b/unittest/force-styles/tests/fix-timestep-spring_chunk.yaml index c151352548..66a9ff9449 100644 --- a/unittest/force-styles/tests/fix-timestep-spring_chunk.yaml +++ b/unittest/force-styles/tests/fix-timestep-spring_chunk.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:42 202 -epsilon: 2e-14 +epsilon: 1e-11 prerequisites: ! | atom full fix spring/chunk diff --git a/unittest/force-styles/tests/fix-timestep-spring_self.yaml b/unittest/force-styles/tests/fix-timestep-spring_self.yaml index 0e8e85516b..96755572bf 100644 --- a/unittest/force-styles/tests/fix-timestep-spring_self.yaml +++ b/unittest/force-styles/tests/fix-timestep-spring_self.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 2e-14 +epsilon: 5e-14 prerequisites: ! | atom full fix spring/self diff --git a/unittest/force-styles/tests/fix-timestep-temp_berendsen.yaml b/unittest/force-styles/tests/fix-timestep-temp_berendsen.yaml index 8b05abe90f..7975b61a13 100644 --- a/unittest/force-styles/tests/fix-timestep-temp_berendsen.yaml +++ b/unittest/force-styles/tests/fix-timestep-temp_berendsen.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix temp/berendsen diff --git a/unittest/force-styles/tests/fix-timestep-temp_csld.yaml b/unittest/force-styles/tests/fix-timestep-temp_csld.yaml index 63940d626c..ef6535888d 100644 --- a/unittest/force-styles/tests/fix-timestep-temp_csld.yaml +++ b/unittest/force-styles/tests/fix-timestep-temp_csld.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix temp/csld diff --git a/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml b/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml index 02592f100c..d4f77f596c 100644 --- a/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml +++ b/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix temp/csvr diff --git a/unittest/force-styles/tests/fix-timestep-wall_harmonic_const.yaml b/unittest/force-styles/tests/fix-timestep-wall_harmonic_const.yaml index 2cb8904632..e1de14d018 100644 --- a/unittest/force-styles/tests/fix-timestep-wall_harmonic_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-wall_harmonic_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 2e-14 +epsilon: 3e-14 prerequisites: ! | atom full fix wall/harmonic diff --git a/unittest/force-styles/tests/fix-timestep-wall_lj1043_const.yaml b/unittest/force-styles/tests/fix-timestep-wall_lj1043_const.yaml index db63a76786..e8be8b41a2 100644 --- a/unittest/force-styles/tests/fix-timestep-wall_lj1043_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-wall_lj1043_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 5e-14 prerequisites: ! | atom full fix wall/lj1043 diff --git a/unittest/force-styles/tests/fix-timestep-wall_lj126_const.yaml b/unittest/force-styles/tests/fix-timestep-wall_lj126_const.yaml index 71b1498ac5..e65b582c09 100644 --- a/unittest/force-styles/tests/fix-timestep-wall_lj126_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-wall_lj126_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix wall/lj126 diff --git a/unittest/force-styles/tests/fix-timestep-wall_lj93_const.yaml b/unittest/force-styles/tests/fix-timestep-wall_lj93_const.yaml index 7fa620fae3..d1c27927a2 100644 --- a/unittest/force-styles/tests/fix-timestep-wall_lj93_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-wall_lj93_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 2e-14 prerequisites: ! | atom full fix wall/lj93 diff --git a/unittest/force-styles/tests/fix-timestep-wall_morse_const.yaml b/unittest/force-styles/tests/fix-timestep-wall_morse_const.yaml index 65f82f8a80..2b935dbf14 100644 --- a/unittest/force-styles/tests/fix-timestep-wall_morse_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-wall_morse_const.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 1e-14 +epsilon: 4e-14 prerequisites: ! | atom full fix wall/morse diff --git a/unittest/force-styles/tests/kspace-pppm_tip4p_ad.yaml b/unittest/force-styles/tests/kspace-pppm_tip4p_ad.yaml index 7aebfdd2fb..e2a644a7b2 100644 --- a/unittest/force-styles/tests/kspace-pppm_tip4p_ad.yaml +++ b/unittest/force-styles/tests/kspace-pppm_tip4p_ad.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:39 202 -epsilon: 2e-13 +epsilon: 3e-13 prerequisites: ! | atom full pair tip4p/long diff --git a/unittest/force-styles/tests/kspace-pppm_tip4p_slab.yaml b/unittest/force-styles/tests/kspace-pppm_tip4p_slab.yaml index 69dcdfaf32..b64d7db0f6 100644 --- a/unittest/force-styles/tests/kspace-pppm_tip4p_slab.yaml +++ b/unittest/force-styles/tests/kspace-pppm_tip4p_slab.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:39 202 -epsilon: 2e-13 +epsilon: 5e-13 prerequisites: ! | atom full pair tip4p/long diff --git a/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml b/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml index 02200151c9..18a2e85c7c 100644 --- a/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml +++ b/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:31 202 -epsilon: 1e-12 +epsilon: 4e-12 prerequisites: ! | pair polymorphic pre_commands: ! | diff --git a/unittest/force-styles/tests/mol-pair-buck.yaml b/unittest/force-styles/tests/mol-pair-buck.yaml index 16866bba3e..6600c63b4f 100644 --- a/unittest/force-styles/tests/mol-pair-buck.yaml +++ b/unittest/force-styles/tests/mol-pair-buck.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:11 202 -epsilon: 5e-14 +epsilon: 6e-14 prerequisites: ! | atom full pair buck diff --git a/unittest/force-styles/tests/mol-pair-buck_coul_long.yaml b/unittest/force-styles/tests/mol-pair-buck_coul_long.yaml index 75b2c40fbd..07606715b8 100644 --- a/unittest/force-styles/tests/mol-pair-buck_coul_long.yaml +++ b/unittest/force-styles/tests/mol-pair-buck_coul_long.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:11 202 -epsilon: 5e-14 +epsilon: 4e-13 prerequisites: ! | atom full pair buck/coul/long diff --git a/unittest/force-styles/tests/mol-pair-buck_coul_msm.yaml b/unittest/force-styles/tests/mol-pair-buck_coul_msm.yaml index 70a34e3726..ca38b6369d 100644 --- a/unittest/force-styles/tests/mol-pair-buck_coul_msm.yaml +++ b/unittest/force-styles/tests/mol-pair-buck_coul_msm.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:11 202 -epsilon: 5e-14 +epsilon: 2e-13 prerequisites: ! | atom full pair buck/coul/msm diff --git a/unittest/force-styles/tests/mol-pair-buck_coul_msm_table.yaml b/unittest/force-styles/tests/mol-pair-buck_coul_msm_table.yaml index b78affb564..24a23bb444 100644 --- a/unittest/force-styles/tests/mol-pair-buck_coul_msm_table.yaml +++ b/unittest/force-styles/tests/mol-pair-buck_coul_msm_table.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:11 202 -epsilon: 5e-14 +epsilon: 2e-13 prerequisites: ! | atom full pair buck/coul/msm diff --git a/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml b/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml index 6c91f1a9a1..d20b8e2e87 100644 --- a/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:14 202 -epsilon: 5e-14 +epsilon: 7e-14 prerequisites: ! | atom full pair lj/charmm/coul/charmm diff --git a/unittest/force-styles/tests/mol-pair-lj_cut_coul_cut.yaml b/unittest/force-styles/tests/mol-pair-lj_cut_coul_cut.yaml index 9140d352d6..d34748446f 100644 --- a/unittest/force-styles/tests/mol-pair-lj_cut_coul_cut.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_cut_coul_cut.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:15 202 -epsilon: 5e-14 +epsilon: 1e-13 prerequisites: ! | atom full pair lj/cut/coul/cut diff --git a/unittest/force-styles/tests/mol-pair-lj_cut_coul_dsf.yaml b/unittest/force-styles/tests/mol-pair-lj_cut_coul_dsf.yaml index 7560b3a2d0..e830d17236 100644 --- a/unittest/force-styles/tests/mol-pair-lj_cut_coul_dsf.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_cut_coul_dsf.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:15 202 -epsilon: 5e-14 +epsilon: 8e-14 prerequisites: ! | atom full pair lj/cut/coul/dsf diff --git a/unittest/force-styles/tests/mol-pair-lj_cut_coul_msm.yaml b/unittest/force-styles/tests/mol-pair-lj_cut_coul_msm.yaml index d150f9ee7c..a861ce9a34 100644 --- a/unittest/force-styles/tests/mol-pair-lj_cut_coul_msm.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_cut_coul_msm.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:16 202 -epsilon: 5e-14 +epsilon: 7e-14 prerequisites: ! | atom full pair lj/cut/coul/msm diff --git a/unittest/force-styles/tests/mol-pair-lj_expand.yaml b/unittest/force-styles/tests/mol-pair-lj_expand.yaml index 4732d26d9c..cc94bc7213 100644 --- a/unittest/force-styles/tests/mol-pair-lj_expand.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_expand.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:16 202 -epsilon: 5e-14 +epsilon: 1e-13 prerequisites: ! | atom full pair lj/expand diff --git a/unittest/force-styles/tests/mol-pair-tip4p_cut.yaml b/unittest/force-styles/tests/mol-pair-tip4p_cut.yaml index f5e302e7ce..aeaa129089 100644 --- a/unittest/force-styles/tests/mol-pair-tip4p_cut.yaml +++ b/unittest/force-styles/tests/mol-pair-tip4p_cut.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:20 202 -epsilon: 1e-14 +epsilon: 5e-14 prerequisites: ! | atom full pair tip4p/cut diff --git a/unittest/force-styles/tests/mol-pair-tip4p_long.yaml b/unittest/force-styles/tests/mol-pair-tip4p_long.yaml index f80d4587b3..16e07643fb 100644 --- a/unittest/force-styles/tests/mol-pair-tip4p_long.yaml +++ b/unittest/force-styles/tests/mol-pair-tip4p_long.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:20 202 -epsilon: 1e-13 +epsilon: 2.5e-13 prerequisites: ! | atom full pair tip4p/long From 8fc2c13f8d557ce1ad7985df56ce54bf94c8573d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 20:47:20 -0500 Subject: [PATCH 102/187] add PGI compiler version detection --- src/info.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/info.cpp b/src/info.cpp index 63ea4dccce..085e4e65ea 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -1179,6 +1179,8 @@ std::string Info::get_compiler_info() std::string buf; #if __clang__ buf = fmt::format("Clang C++ {}", __VERSION__); +#elif __PGI + buf = fmt::format("PGI C++ {}.{}",__PGIC__,__PGIC_MINOR__); #elif __INTEL_COMPILER double version = static_cast(__INTEL_COMPILER)*0.01; buf = fmt::format("Intel C++ {:.2f}.{} / {}", version, From 21c3a5155738e2e96b31b6ed2048111a407c79d0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 15 Dec 2020 20:47:40 -0500 Subject: [PATCH 103/187] skip unsupported GCC pragma --- unittest/formats/test_atom_styles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index cb3f7d79a4..b9957c6732 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -32,7 +32,7 @@ #include #if !defined(_FORTIFY_SOURCE) || (_FORTIFY_SOURCE == 0) -#if defined(__INTEL_COMPILER) +#if defined(__INTEL_COMPILER) || (__PGI) #define _do_nothing #elif defined(__clang__) #pragma clang optimize off From f614aa401e13ba4ce427a9d94683c7907c6b3ab1 Mon Sep 17 00:00:00 2001 From: Shern Tee Date: Wed, 16 Dec 2020 15:42:10 +1000 Subject: [PATCH 104/187] build_one() update parent skiplist if an occasional skip list has an occasional parent list, the parent list must be built when the skip list is built. This patch ensures that behavior. (Otherwise, build_one(foo) returns an empty skip list with no warnings or errors.) --- src/neighbor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 949e0387ea..7761aae721 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2162,12 +2162,15 @@ void Neighbor::build_one(class NeighList *mylist, int preflag) // if this is copy list and parent is occasional list, // or this is halffull and parent is occasional list, + // or this is skip list and parent is occasional list, // insure parent is current if (mylist->listcopy && mylist->listcopy->occasional) build_one(mylist->listcopy,preflag); if (mylist->listfull && mylist->listfull->occasional) build_one(mylist->listfull,preflag); + if (mylist->listskip && mylist->listskip->occasional) + build_one(mylist->listskip,preflag); // create stencil if hasn't been created since last setup_bins() call From 0e6e1b6de176a9b6994f2fcc2d05909334a98334 Mon Sep 17 00:00:00 2001 From: Yaser Afshar Date: Wed, 16 Dec 2020 07:53:37 -0600 Subject: [PATCH 105/187] Update the mode to FATAL_ERROR when CURL not found --- unittest/commands/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index 218189721a..7a804820cb 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -12,7 +12,7 @@ if(KIM_EXTRA_UNITTESTS) if(CURL_FOUND) target_compile_definitions(test_kim_commands PRIVATE -DKIM_EXTRA_UNITTESTS) else() - message(STATUS "CURL not found. Enabling KIM extra unit tests requires to have libcurl installed.") + message(FATAL_ERROR "CURL not found. Enabling KIM extra unit tests requires to have libcurl installed.") endif() endif() target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock GTest::GTest) From ba64e7c75c142ab77674f9d3b363f3d386541f6c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 07:20:53 -0500 Subject: [PATCH 106/187] simplify/improve multi-partition test --- unittest/c-library/test_library_mpi.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/unittest/c-library/test_library_mpi.cpp b/unittest/c-library/test_library_mpi.cpp index cf33ed13b5..7502da767a 100644 --- a/unittest/c-library/test_library_mpi.cpp +++ b/unittest/c-library/test_library_mpi.cpp @@ -173,7 +173,7 @@ TEST(MPI, multi_partition) MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &me); - const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "2x2", + const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "4x1", "-echo", "screen", "-nocite", "-in", "none"}; char **argv = (char **)args; int argc = sizeof(args) / sizeof(char *); @@ -183,19 +183,15 @@ TEST(MPI, multi_partition) lammps_command(lmp, "atom_style atomic"); lammps_command(lmp, "region box block 0 2 0 2 0 2"); lammps_command(lmp, "create_box 1 box"); - lammps_command(lmp, "variable partition universe 1 2"); + lammps_command(lmp, "variable partition universe 1 2 3 4"); EXPECT_EQ(lammps_extract_setting(lmp, "universe_size"), nprocs); EXPECT_EQ(lammps_extract_setting(lmp, "universe_rank"), me); - EXPECT_EQ(lammps_extract_setting(lmp, "world_size"), nprocs / 2); - EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), me % 2); + EXPECT_EQ(lammps_extract_setting(lmp, "world_size"), 1); + EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), 0); char *part_id = (char *)lammps_extract_variable(lmp, "partition", nullptr); - if (me < 2) { - ASSERT_THAT(part_id, StrEq("1")); - } else { - ASSERT_THAT(part_id, StrEq("2")); - } + ASSERT_THAT(part_id, StrEq(std::to_string(me+1))); lammps_close(lmp); }; From 181b18beeb675a20237767bca3547cd3e1bbc53f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 07:21:17 -0500 Subject: [PATCH 107/187] tweak epsilon for better compiler compatibility --- unittest/force-styles/tests/fix-timestep-oneway.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/force-styles/tests/fix-timestep-oneway.yaml b/unittest/force-styles/tests/fix-timestep-oneway.yaml index 4fcef41f5b..01131a3803 100644 --- a/unittest/force-styles/tests/fix-timestep-oneway.yaml +++ b/unittest/force-styles/tests/fix-timestep-oneway.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 2e-14 +epsilon: 4e-14 prerequisites: ! | atom full fix oneway From e3c3106795a3f8fc4906fcfb5f56e0992caa9cce Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 09:20:38 -0500 Subject: [PATCH 108/187] fix incorrect use of MPI_Gather() --- src/fix_temp_csld.cpp | 2 +- src/fix_temp_csvr.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fix_temp_csld.cpp b/src/fix_temp_csld.cpp index f01de7c2fa..48c18c4e4f 100644 --- a/src/fix_temp_csld.cpp +++ b/src/fix_temp_csld.cpp @@ -314,7 +314,7 @@ void FixTempCSLD::write_restart(FILE *fp) } double state[103]; random->get_state(state); - MPI_Gather(state,103,MPI_DOUBLE,list+2,103*comm->nprocs,MPI_DOUBLE,0,world); + MPI_Gather(state,103,MPI_DOUBLE,list+2,103,MPI_DOUBLE,0,world); if (comm->me == 0) { int size = nsize * sizeof(double); diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index 0130631172..e3fdb7fc80 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -347,7 +347,7 @@ void FixTempCSVR::write_restart(FILE *fp) } double state[103]; random->get_state(state); - MPI_Gather(state,103,MPI_DOUBLE,list+2,103*comm->nprocs,MPI_DOUBLE,0,world); + MPI_Gather(state,103,MPI_DOUBLE,list+2,103,MPI_DOUBLE,0,world); if (comm->me == 0) { int size = nsize * sizeof(double); From 5ddeb45c0a27ae7e263b8323a5357a1dbc5ca24d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 09:25:54 -0500 Subject: [PATCH 109/187] whitespace --- doc/src/Build_extras.rst | 8 ++++---- doc/src/fix_temp_csvr.rst | 18 +++++++++--------- src/KIM/pair_kim.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 6847b8c030..4dd17d71f8 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -352,7 +352,7 @@ KIM Extra unit tests (CMake only) During development, testing, or debugging, if :doc:`unit testing ` is enabled in LAMMPS, one can also enable extra tests on :doc:`KIM commands ` by setting the -``KIM_EXTRA_UNITTESTS`` to *yes* (or *on*). +``KIM_EXTRA_UNITTESTS`` to *yes* (or *on*). Enabling the extra unit tests have some requirements, @@ -367,9 +367,9 @@ Enabling the extra unit tests have some requirements, *conda-forge* channel as ``conda install kim-property`` if LAMMPS is built in Conda. More detailed information is available at: `kim-property installation `_. -* It is also necessary to install - ``EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000``, and - ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005`` KIM models. +* It is also necessary to install + ``EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000``, and + ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005`` KIM models. See `Obtaining KIM Models `_ to learn how to install a pre-build binary of the OpenKIM Repository of Models or see diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index 5e6074bc66..440a264ed5 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -124,16 +124,16 @@ temperature is calculated taking the bias into account, bias is removed from each atom, thermostatting is performed on the remaining thermal degrees of freedom, and the bias is added back in. -An important feature of these thermostats is that they have an +An important feature of these thermostats is that they have an associated effective energy that is a constant of motion. -The effective energy is the total energy (kinetic + potential) plus -the accumulated kinetic energy changes due to the thermostat. The -latter quantity is the global scalar computed by these fixes. This -feature is useful to check the integration of the equations of motion -against discretization errors. In other words, the conservation of -the effective energy can be used to choose an appropriate integration -:doc:`timestep `. This is similar to the usual paradigm of -checking the conservation of the total energy in the microcanonical +The effective energy is the total energy (kinetic + potential) plus +the accumulated kinetic energy changes due to the thermostat. The +latter quantity is the global scalar computed by these fixes. This +feature is useful to check the integration of the equations of motion +against discretization errors. In other words, the conservation of +the effective energy can be used to choose an appropriate integration +:doc:`timestep `. This is similar to the usual paradigm of +checking the conservation of the total energy in the microcanonical ensemble. diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index ad671de5b3..ee6f5f98a5 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -941,7 +941,7 @@ void PairKIM::set_argument_pointers() // Set KIM pointer appropriately for particleVirial if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_required) + KIM_SUPPORT_STATUS_required) && (vflag_atom == 0)) { // reallocate per-atom virial array if necessary if (atom->nmax > maxvatom) { From 527ffa79dc11f41cbe3a8a8cd9d369b9103e520a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 09:34:56 -0500 Subject: [PATCH 110/187] refactor for clarity --- src/fix_temp_csld.cpp | 7 ++++--- src/fix_temp_csvr.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fix_temp_csld.cpp b/src/fix_temp_csld.cpp index 48c18c4e4f..3b522c185f 100644 --- a/src/fix_temp_csld.cpp +++ b/src/fix_temp_csld.cpp @@ -305,16 +305,17 @@ double FixTempCSLD::compute_scalar() void FixTempCSLD::write_restart(FILE *fp) { - int nsize = (98+2+3)*comm->nprocs+2; // pRNG state per proc + nprocs + energy + const int PRNGSIZE = 98+2+3; + int nsize = PRNGSIZE*comm->nprocs+2; // pRNG state per proc + nprocs + energy double *list = nullptr; if (comm->me == 0) { list = new double[nsize]; list[0] = energy; list[1] = comm->nprocs; } - double state[103]; + double state[PRNGSIZE]; random->get_state(state); - MPI_Gather(state,103,MPI_DOUBLE,list+2,103,MPI_DOUBLE,0,world); + MPI_Gather(state,PRNGSIZE,MPI_DOUBLE,list+2,PRNGSIZE,MPI_DOUBLE,0,world); if (comm->me == 0) { int size = nsize * sizeof(double); diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index e3fdb7fc80..674c436e9d 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -338,16 +338,17 @@ double FixTempCSVR::compute_scalar() void FixTempCSVR::write_restart(FILE *fp) { - int nsize = (98+2+3)*comm->nprocs+2; // pRNG state per proc + nprocs + energy + const int PRNGSIZE = 98+2+3; + int nsize = PRNGSIZE*comm->nprocs+2; // pRNG state per proc + nprocs + energy double *list = nullptr; if (comm->me == 0) { list = new double[nsize]; list[0] = energy; list[1] = comm->nprocs; } - double state[103]; + double state[PRNGSIZE]; random->get_state(state); - MPI_Gather(state,103,MPI_DOUBLE,list+2,103,MPI_DOUBLE,0,world); + MPI_Gather(state,PRNGSIZE,MPI_DOUBLE,list+2,PRNGSIZE,MPI_DOUBLE,0,world); if (comm->me == 0) { int size = nsize * sizeof(double); From f9f9c37bd2b67d99fe281b060fc09c4acf99ea2c Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Thu, 17 Dec 2020 11:54:30 -0500 Subject: [PATCH 111/187] Update docs --- doc/src/Howto_pylammps.rst | 4 +- doc/src/Python_ext.rst | 2 +- doc/src/Python_install.rst | 176 ++++++++++++++++++------------------ doc/src/Python_overview.rst | 10 +- doc/src/Python_trouble.rst | 2 +- doc/src/python.rst | 26 +++--- 6 files changed, 111 insertions(+), 109 deletions(-) diff --git a/doc/src/Howto_pylammps.rst b/doc/src/Howto_pylammps.rst index 89119e89af..e6d3d7b91d 100644 --- a/doc/src/Howto_pylammps.rst +++ b/doc/src/Howto_pylammps.rst @@ -9,8 +9,8 @@ Overview ``PyLammps`` is a Python wrapper class for LAMMPS which can be created on its own or use an existing lammps Python object. It creates a simpler, more "pythonic" interface to common LAMMPS functionality, in contrast to -the ``lammps.py`` wrapper for the C-style LAMMPS library interface which -is written using `Python ctypes `_. The ``lammps.py`` wrapper +the ``lammps`` wrapper for the C-style LAMMPS library interface which +is written using `Python ctypes `_. The ``lammps`` wrapper is discussed on the :doc:`Python_head` doc page. Unlike the flat ``ctypes`` interface, PyLammps exposes a discoverable diff --git a/doc/src/Python_ext.rst b/doc/src/Python_ext.rst index 6b6d1ab715..8966ffcb2a 100644 --- a/doc/src/Python_ext.rst +++ b/doc/src/Python_ext.rst @@ -9,7 +9,7 @@ This means you can extend the Python wrapper by following these steps: * Add a new interface function to ``src/library.cpp`` and ``src/library.h``. * Rebuild LAMMPS as a shared library. -* Add a wrapper method to ``python/lammps.py`` for this interface +* Add a wrapper method to ``python/lammps/core.py`` for this interface function. * Define the corresponding ``argtypes`` list and ``restype`` in the ``lammps.__init__()`` function. diff --git a/doc/src/Python_install.rst b/doc/src/Python_install.rst index 88d32895a3..0ebc1c49c3 100644 --- a/doc/src/Python_install.rst +++ b/doc/src/Python_install.rst @@ -8,9 +8,9 @@ module. Because of the dynamic loading, it is required that LAMMPS is compiled in :ref:`"shared" mode `. It is also recommended to compile LAMMPS with :ref:`C++ exceptions ` enabled. -Two files are necessary for Python to be able to invoke LAMMPS code: +Two components are necessary for Python to be able to invoke LAMMPS code: -* The LAMMPS Python Module (``lammps.py``) from the ``python`` folder +* The LAMMPS Python Package (``lammps``) from the ``python`` folder * The LAMMPS Shared Library (``liblammps.so``, ``liblammps.dylib`` or ``liblammps.dll``) from the folder where you compiled LAMMPS. @@ -25,10 +25,10 @@ Installing the LAMMPS Python Module and Shared Library ====================================================== Making LAMMPS usable within Python and vice versa requires putting the -LAMMPS Python module file (``lammps.py``) into a location where the +LAMMPS Python package (``lammps``) into a location where the Python interpreter can find it and installing the LAMMPS shared library -into a folder that the dynamic loader searches or into the same folder -where the ``lammps.py`` file is. There are multiple ways to achieve +into a folder that the dynamic loader searches or inside of the installed +``lammps`` package folder. There are multiple ways to achieve this. #. Do a full LAMMPS installation of libraries, executables, selected @@ -36,13 +36,13 @@ this. available via CMake), which can also be either system-wide or into user specific folders. -#. Install both files into a Python ``site-packages`` folder, either +#. Install both components into a Python ``site-packages`` folder, either system-wide or in the corresponding user-specific folder. This way no additional environment variables need to be set, but the shared library is otherwise not accessible. -#. Do an installation into a virtual environment. This can either be - an installation of the python module only or a full installation. +#. Do an installation into a virtual environment. This can either be an + installation of the Python package only or a full installation of LAMMPS. #. Leave the files where they are in the source/development tree and adjust some environment variables. @@ -81,19 +81,19 @@ this. This leads to an installation to the following locations: - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | File | Location | Notes | - +========================+===========================================================+=============================================================+ - | LAMMPS Python Module | * ``$HOME/.local/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``$HOME/.local/lib/`` (32bit) | | - | | * ``$HOME/.local/lib64/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS executable | * ``$HOME/.local/bin/`` | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS potential files | * ``$HOME/.local/share/lammps/potentials/`` | Set ``LAMMPS_POTENTIALS`` environment variable to this path | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | File | Location | Notes | + +========================+=================================================================+=============================================================+ + | LAMMPS Python package | * ``$HOME/.local/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS shared library | * ``$HOME/.local/lib/`` (32bit) | | + | | * ``$HOME/.local/lib64/`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS executable | * ``$HOME/.local/bin/`` | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS potential files | * ``$HOME/.local/share/lammps/potentials/`` | Set ``LAMMPS_POTENTIALS`` environment variable to this path | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ For a system-wide installation you need to set ``CMAKE_INSTALL_PREFIX`` to a system folder like ``/usr`` (or @@ -102,19 +102,19 @@ this. privilege, e.g. by using ``sudo cmake --install .``. The installation folders will then by changed to: - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ - | File | Location | Notes | - +========================+===================================================+=============================================================+ - | LAMMPS Python Module | * ``/usr/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``/usr/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``/usr/lib/`` (32bit) | | - | | * ``/usr/lib64/`` (64bit) | | - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS executable | * ``/usr/bin/`` | | - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS potential files | * ``/usr/share/lammps/potentials/`` | | - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ + | File | Location | Notes | + +========================+=========================================================+=============================================================+ + | LAMMPS Python package | * ``/usr/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``/usr/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS shared library | * ``/usr/lib/`` (32bit) | | + | | * ``/usr/lib64/`` (64bit) | | + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS executable | * ``/usr/bin/`` | | + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS potential files | * ``/usr/share/lammps/potentials/`` | | + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ To be able to use the "user" installation you have to ensure that the folder containing the LAMMPS shared library is either included @@ -146,7 +146,7 @@ this. necessary due to files installed in system folders that are loaded automatically when a login shell is started. - .. tab:: Python module only + .. tab:: Python package only Compile LAMMPS with either :doc:`CMake ` or the :doc:`traditional make ` procedure in :ref:`shared @@ -157,37 +157,37 @@ this. make install-python - This will try to install (only) the shared library and the python - module into a system folder and if that fails (due to missing + This will try to install (only) the shared library and the Python + package into a system folder and if that fails (due to missing write permissions) will instead do the installation to a user folder under ``$HOME/.local``. For a system-wide installation you would have to gain superuser privilege, e.g. though ``sudo`` - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | File | Location | Notes | - +========================+===========================================================+=============================================================+ - | LAMMPS Python Module | * ``$HOME/.local/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``$HOME/.local/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | File | Location | Notes | + +========================+=================================================================+=============================================================+ + | LAMMPS Python package | * ``$HOME/.local/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS shared library | * ``$HOME/.local/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ For a system-wide installation those folders would then become. - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ - | File | Location | Notes | - +========================+===================================================+=============================================================+ - | LAMMPS Python Module | * ``/usr/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``/usr/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``/usr/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``/usr/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+---------------------------------------------------+-------------------------------------------------------------+ + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ + | File | Location | Notes | + +========================+=========================================================+=============================================================+ + | LAMMPS Python package | * ``/usr/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``/usr/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS shared library | * ``/usr/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``/usr/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ No environment variables need to be set for those, as those folders are searched by default by Python or the LAMMPS Python - module. + package. For the traditional make process you can override the python version to version x.y when calling ``make`` with @@ -199,9 +199,9 @@ this. .. code-block:: bash - $ python install.py -m -l -v [-d ] + $ python install.py -p -l -v [-d ] - * The ``-m`` flag points to the ``lammps.py`` python module file to be installed, + * The ``-p`` flag points to the ``lammps`` Python package folder to be installed, * the ``-l`` flag points to the LAMMPS shared library file to be installed, * the ``-v`` flag points to the ``version.h`` file in the LAMMPS source * and the optional ``-d`` flag to a custom (legacy) installation folder @@ -249,38 +249,38 @@ this. When using CMake to build LAMMPS, you need to set ``CMAKE_INSTALL_PREFIX`` to the value of the ``$VIRTUAL_ENV`` environment variable during the configuration step. For the - traditional make procedure, not additional steps are needed. - After compiling LAMMPS you can do a "Python module only" + traditional make procedure, no additional steps are needed. + After compiling LAMMPS you can do a "Python package only" installation with ``make install-python`` and the LAMMPS Python - module and the shared library file are installed into the + package and the shared library file are installed into the following locations: - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | File | Location | Notes | - +========================+===========================================================+=============================================================+ - | LAMMPS Python Module | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | File | Location | Notes | + +========================+=================================================================+=============================================================+ + | LAMMPS Python Module | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS shared library | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ If you do a full installation (CMake only) with "install", this leads to the following installation locations: - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | File | Location | Notes | - +========================+===========================================================+=============================================================+ - | LAMMPS Python Module | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/`` (32bit) | ``X.Y`` depends on the installed Python version | - | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``$VIRTUAL_ENV/lib/`` (32bit) | | - | | * ``$VIRTUAL_ENV/lib64/`` (64bit) | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS executable | * ``$VIRTUAL_ENV/bin/`` | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS potential files | * ``$VIRTUAL_ENV/share/lammps/potentials/`` | | - +------------------------+-----------------------------------------------------------+-------------------------------------------------------------+ + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | File | Location | Notes | + +========================+=================================================================+=============================================================+ + | LAMMPS Python Module | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | + | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS shared library | * ``$VIRTUAL_ENV/lib/`` (32bit) | | + | | * ``$VIRTUAL_ENV/lib64/`` (64bit) | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS executable | * ``$VIRTUAL_ENV/bin/`` | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ + | LAMMPS potential files | * ``$VIRTUAL_ENV/share/lammps/potentials/`` | | + +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ In that case you need to modify the ``$HOME/myenv/bin/activate`` script in a similar fashion you need to update your @@ -302,9 +302,9 @@ this. You can also :doc:`compile LAMMPS ` as usual in :ref:`"shared" mode ` leave the shared library and Python - module files inside the source/compilation folders. Instead of + package inside the source/compilation folders. Instead of copying the files where they can be found, you need to set the environment - variables ``PYTHONPATH`` (for the Python module) and + variables ``PYTHONPATH`` (for the Python package) and ``LD_LIBRARY_PATH`` (or ``DYLD_LIBRARY_PATH`` on MacOS For Bourne shells (bash, ksh and similar) the commands are: @@ -325,6 +325,10 @@ this. You can make those changes permanent by editing your ``$HOME/.bashrc`` or ``$HOME/.login`` files, respectively. + .. note:: + + The ``PYTHONPATH`` needs to point to the parent folder that contains the ``lammps`` package! + To verify if LAMMPS can be successfully started from Python, start the Python interpreter, load the ``lammps`` Python module and create a @@ -346,7 +350,7 @@ output similar to the following: .. note:: Unless you opted for "In place use", you will have to rerun the installation - any time you recompile LAMMPS to ensure the latest Python module and shared + any time you recompile LAMMPS to ensure the latest Python package and shared library are installed and used. .. note:: diff --git a/doc/src/Python_overview.rst b/doc/src/Python_overview.rst index a90ea171d5..2dfc193f8d 100644 --- a/doc/src/Python_overview.rst +++ b/doc/src/Python_overview.rst @@ -2,9 +2,9 @@ Overview ======== The LAMMPS distribution includes a ``python`` directory with the Python -code needed to run LAMMPS from Python. The ``python/lammps.py`` -contains :doc:`the "lammps" Python ` that wraps the -LAMMPS C-library interface. This file makes it is possible to do the +code needed to run LAMMPS from Python. The ``python/lammps`` package +contains :doc:`the "lammps" Python module ` that wraps the +LAMMPS C-library interface. This module makes it is possible to do the following either from a Python script, or interactively from a Python prompt: @@ -20,8 +20,8 @@ have a version of Python that extends Python to enable multiple instances of Python to read what you type. To do all of this, you must build LAMMPS in :ref:`"shared" mode ` -and make certain that your Python interpreter can find the ``lammps.py`` -file and the LAMMPS shared library file. +and make certain that your Python interpreter can find the ``lammps`` +Python package and the LAMMPS shared library file. .. _ctypes: https://docs.python.org/3/library/ctypes.html diff --git a/doc/src/Python_trouble.rst b/doc/src/Python_trouble.rst index 3ef7dacf34..b94a043a6a 100644 --- a/doc/src/Python_trouble.rst +++ b/doc/src/Python_trouble.rst @@ -33,7 +33,7 @@ the constructor call as follows (see :ref:`python_create_lammps` for more detail >>> lmp = lammps(name='mpi') You can also test the load directly in Python as follows, without -first importing from the lammps.py file: +first importing from the ``lammps`` module: .. code-block:: python diff --git a/doc/src/python.rst b/doc/src/python.rst index f38e756232..a4c3d7097c 100644 --- a/doc/src/python.rst +++ b/doc/src/python.rst @@ -323,8 +323,8 @@ Python function is as follows: The function definition must include a variable (lmpptr in this case) which corresponds to SELF in the python command. The first line of the -function imports the Python module lammps.py in the python directory of -the distribution. The second line creates a Python object "lmp" which +function imports the :doc:`"lammps" Python module `. +The second line creates a Python object ``lmp`` which wraps the instance of LAMMPS that called the function. The "ptr=lmpptr" argument is what makes that happen. The third line invokes the command() function in the LAMMPS library interface. It takes a single @@ -502,18 +502,16 @@ Python library on your system. Settings to enable this are in the lib/python/Makefile.lammps file. See the lib/python/README file for information on those settings. -If you use Python code which calls back to LAMMPS, via the SELF input -argument explained above, there is an extra step required when -building LAMMPS. LAMMPS must also be built as a shared library and -your Python function must be able to load the Python module in -python/lammps.py that wraps the LAMMPS library interface. These are -the same steps required to use Python by itself to wrap LAMMPS. -Details on these steps are explained on the :doc:`Python ` -doc page. Note that it is important that the stand-alone LAMMPS -executable and the LAMMPS shared library be consistent (built from the -same source code files) in order for this to work. If the two have -been built at different times using different source files, problems -may occur. +If you use Python code which calls back to LAMMPS, via the SELF input argument +explained above, there is an extra step required when building LAMMPS. LAMMPS +must also be built as a shared library and your Python function must be able to +load the :doc:`"lammps" Python module ` that wraps the LAMMPS +library interface. These are the same steps required to use Python by itself +to wrap LAMMPS. Details on these steps are explained on the :doc:`Python +` doc page. Note that it is important that the stand-alone LAMMPS +executable and the LAMMPS shared library be consistent (built from the same +source code files) in order for this to work. If the two have been built at +different times using different source files, problems may occur. Related commands """""""""""""""" From 47cdafe651a70fe228a2159fd41af226dd0d5b91 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 12:06:44 -0500 Subject: [PATCH 112/187] reduce size of executable/library by replacing static const int with enum --- src/fix.h | 51 +++++++++++++++-------------- src/neighbor.h | 88 +++++++++++++++++++++++++++----------------------- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/src/fix.h b/src/fix.h index 75c644e87f..ec951e3bb2 100644 --- a/src/fix.h +++ b/src/fix.h @@ -251,31 +251,32 @@ class Fix : protected Pointers { }; namespace FixConst { - static const int INITIAL_INTEGRATE = 1<<0; - static const int POST_INTEGRATE = 1<<1; - static const int PRE_EXCHANGE = 1<<2; - static const int PRE_NEIGHBOR = 1<<3; - static const int POST_NEIGHBOR = 1<<4; - static const int PRE_FORCE = 1<<5; - static const int PRE_REVERSE = 1<<6; - static const int POST_FORCE = 1<<7; - static const int FINAL_INTEGRATE = 1<<8; - static const int END_OF_STEP = 1<<9; - static const int POST_RUN = 1<<10; - static const int THERMO_ENERGY = 1<<11; - static const int INITIAL_INTEGRATE_RESPA = 1<<12; - static const int POST_INTEGRATE_RESPA = 1<<13; - static const int PRE_FORCE_RESPA = 1<<14; - static const int POST_FORCE_RESPA = 1<<15; - static const int FINAL_INTEGRATE_RESPA = 1<<16; - static const int MIN_PRE_EXCHANGE = 1<<17; - static const int MIN_PRE_NEIGHBOR = 1<<18; - static const int MIN_POST_NEIGHBOR = 1<<19; - static const int MIN_PRE_FORCE = 1<<20; - static const int MIN_PRE_REVERSE = 1<<21; - static const int MIN_POST_FORCE = 1<<22; - static const int MIN_ENERGY = 1<<23; - static const int FIX_CONST_LAST = 1<<24; + enum { + INITIAL_INTEGRATE = 1<<0, + POST_INTEGRATE = 1<<1, + PRE_EXCHANGE = 1<<2, + PRE_NEIGHBOR = 1<<3, + POST_NEIGHBOR = 1<<4, + PRE_FORCE = 1<<5, + PRE_REVERSE = 1<<6, + POST_FORCE = 1<<7, + FINAL_INTEGRATE = 1<<8, + END_OF_STEP = 1<<9, + POST_RUN = 1<<10, + THERMO_ENERGY = 1<<11, + INITIAL_INTEGRATE_RESPA = 1<<12, + POST_INTEGRATE_RESPA = 1<<13, + PRE_FORCE_RESPA = 1<<14, + POST_FORCE_RESPA = 1<<15, + FINAL_INTEGRATE_RESPA = 1<<16, + MIN_PRE_EXCHANGE = 1<<17, + MIN_PRE_NEIGHBOR = 1<<18, + MIN_POST_NEIGHBOR = 1<<19, + MIN_PRE_FORCE = 1<<20, + MIN_PRE_REVERSE = 1<<21, + MIN_POST_FORCE = 1<<22, + MIN_ENERGY = 1<<23 + }; } } diff --git a/src/neighbor.h b/src/neighbor.h index 9ee2af9c75..b9b40bcf1a 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -235,49 +235,55 @@ class Neighbor : protected Pointers { }; namespace NeighConst { - static const int NB_INTEL = 1<<0; - static const int NB_KOKKOS_DEVICE = 1<<1; - static const int NB_KOKKOS_HOST = 1<<2; - static const int NB_SSA = 1<<3; + enum { + NB_INTEL = 1<<0, + NB_KOKKOS_DEVICE = 1<<1, + NB_KOKKOS_HOST = 1<<2, + NB_SSA = 1<<3 + }; - static const int NS_BIN = 1<<0; - static const int NS_MULTI = 1<<1; - static const int NS_HALF = 1<<2; - static const int NS_FULL = 1<<3; - static const int NS_2D = 1<<4; - static const int NS_3D = 1<<5; - static const int NS_NEWTON = 1<<6; - static const int NS_NEWTOFF = 1<<7; - static const int NS_ORTHO = 1<<8; - static const int NS_TRI = 1<<9; - static const int NS_GHOST = 1<<10; - static const int NS_SSA = 1<<11; + enum { + NS_BIN = 1<<0, + NS_MULTI = 1<<1, + NS_HALF = 1<<2, + NS_FULL = 1<<3, + NS_2D = 1<<4, + NS_3D = 1<<5, + NS_NEWTON = 1<<6, + NS_NEWTOFF = 1<<7, + NS_ORTHO = 1<<8, + NS_TRI = 1<<9, + NS_GHOST = 1<<10, + NS_SSA = 1<<11 + }; - static const int NP_NSQ = 1<<0; - static const int NP_BIN = 1<<1; - static const int NP_MULTI = 1<<2; - static const int NP_HALF = 1<<3; - static const int NP_FULL = 1<<4; - static const int NP_ORTHO = 1<<5; - static const int NP_TRI = 1<<6; - static const int NP_ATOMONLY = 1<<7; - static const int NP_MOLONLY = 1<<8; - static const int NP_NEWTON = 1<<9; - static const int NP_NEWTOFF = 1<<10; - static const int NP_GHOST = 1<<11; - static const int NP_SIZE = 1<<12; - static const int NP_ONESIDE = 1<<13; - static const int NP_RESPA = 1<<14; - static const int NP_BOND = 1<<15; - static const int NP_OMP = 1<<16; - static const int NP_INTEL = 1<<17; - static const int NP_KOKKOS_DEVICE = 1<<18; - static const int NP_KOKKOS_HOST = 1<<19; - static const int NP_SSA = 1<<20; - static const int NP_COPY = 1<<21; - static const int NP_SKIP = 1<<22; - static const int NP_HALF_FULL = 1<<23; - static const int NP_OFF2ON = 1<<24; + enum { + NP_NSQ = 1<<0, + NP_BIN = 1<<1, + NP_MULTI = 1<<2, + NP_HALF = 1<<3, + NP_FULL = 1<<4, + NP_ORTHO = 1<<5, + NP_TRI = 1<<6, + NP_ATOMONLY = 1<<7, + NP_MOLONLY = 1<<8, + NP_NEWTON = 1<<9, + NP_NEWTOFF = 1<<10, + NP_GHOST = 1<<11, + NP_SIZE = 1<<12, + NP_ONESIDE = 1<<13, + NP_RESPA = 1<<14, + NP_BOND = 1<<15, + NP_OMP = 1<<16, + NP_INTEL = 1<<17, + NP_KOKKOS_DEVICE = 1<<18, + NP_KOKKOS_HOST = 1<<19, + NP_SSA = 1<<20, + NP_COPY = 1<<21, + NP_SKIP = 1<<22, + NP_HALF_FULL = 1<<23, + NP_OFF2ON = 1<<24 + }; } } From bcb89a1d90f0eafd27bb149d189e150180c7edb3 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 16 Dec 2020 10:55:29 -0500 Subject: [PATCH 113/187] Honor DESTDIR for packaging --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 854937dec8..e0d0cafb2a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -692,7 +692,7 @@ if(BUILD_SHARED_LIBS OR PKG_PYTHON) endif() if (Python_EXECUTABLE) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python) - install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})") + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})") endif() endif() From 511a1a539540cc7346161565316728d313a127b7 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Thu, 17 Dec 2020 12:12:04 -0500 Subject: [PATCH 114/187] Update comments mentioning lammps.py --- examples/COUPLE/python/example.py | 2 +- python/lammps/core.py | 6 +++--- src/library.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/COUPLE/python/example.py b/examples/COUPLE/python/example.py index ea268fe1ca..5ddb9fb587 100644 --- a/examples/COUPLE/python/example.py +++ b/examples/COUPLE/python/example.py @@ -1,4 +1,4 @@ -# this example requires the LAMMPS Python package (lammps.py) to be installed +# this example requires the LAMMPS Python package (python/lammps) to be installed # and LAMMPS to be loadable as shared library in LD_LIBRARY_PATH import lammps diff --git a/python/lammps/core.py b/python/lammps/core.py index 009409f48d..161583b78c 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -95,7 +95,7 @@ class lammps(object): # load liblammps.so unless name is given # if name = "g++", load liblammps_g++.so # try loading the LAMMPS shared object from the location - # of lammps.py with an absolute path, + # of the lammps package with an absolute path, # so that LD_LIBRARY_PATH does not need to be set for regular install # fall back to loading with a relative path, # typically requires LD_LIBRARY_PATH to be set appropriately @@ -319,7 +319,7 @@ class lammps(object): narg = 0 cargs = None if cmdargs: - cmdargs.insert(0,"lammps.py") + cmdargs.insert(0,"lammps") narg = len(cmdargs) for i in range(narg): if type(cmdargs[i]) is str: @@ -341,7 +341,7 @@ class lammps(object): self.comm = self.MPI.COMM_WORLD self.opened = 1 if cmdargs: - cmdargs.insert(0,"lammps.py") + cmdargs.insert(0,"lammps") narg = len(cmdargs) for i in range(narg): if type(cmdargs[i]) is str: diff --git a/src/library.h b/src/library.h index 7806903e49..14be4064ea 100644 --- a/src/library.h +++ b/src/library.h @@ -42,7 +42,7 @@ /** Data type constants for extracting data from atoms, computes and fixes * - * Must be kept in sync with the equivalent constants in lammps.py */ + * Must be kept in sync with the equivalent constants in lammps/constants.py */ enum _LMP_DATATYPE_CONST { LAMMPS_INT = 0, /*!< 32-bit integer (array) */ @@ -56,7 +56,7 @@ enum _LMP_DATATYPE_CONST { /** Style constants for extracting data from computes and fixes. * - * Must be kept in sync with the equivalent constants in lammps.py */ + * Must be kept in sync with the equivalent constants in lammps/constants.py */ enum _LMP_STYLE_CONST { LMP_STYLE_GLOBAL=0, /*!< return global data */ @@ -66,7 +66,7 @@ enum _LMP_STYLE_CONST { /** Type and size constants for extracting data from computes and fixes. * - * Must be kept in sync with the equivalent constants in lammps.py */ + * Must be kept in sync with the equivalent constants in lammps/constants.py */ enum _LMP_TYPE_CONST { LMP_TYPE_SCALAR=0, /*!< return scalar */ From 72f68f3d56d01cf888e268703057491276d8359a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 12:47:04 -0500 Subject: [PATCH 115/187] consolidate multiple factorial() function definitions into MathSpecial::factorial() --- .../compute_orientorder_atom_kokkos.cpp | 2 + src/SNAP/sna.cpp | 192 +---------------- src/SNAP/sna.h | 4 - src/USER-SMTBQ/pair_smtbq.cpp | 11 - src/compute_orientorder_atom.cpp | 191 +---------------- src/compute_orientorder_atom.h | 3 - src/math_special.cpp | 194 ++++++++++++++++++ src/math_special.h | 4 + 8 files changed, 205 insertions(+), 396 deletions(-) diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 1323e589d3..3703769e90 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_masks.h" #include "kokkos.h" #include "math_const.h" +#include "math_special.h" #include "memory_kokkos.h" #include "neigh_list.h" #include "neigh_request.h" @@ -32,6 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; +using namespace MathSpecial; using namespace std; #ifdef DBL_EPSILON diff --git a/src/SNAP/sna.cpp b/src/SNAP/sna.cpp index 6d4197b59b..3c7a40c0dc 100644 --- a/src/SNAP/sna.cpp +++ b/src/SNAP/sna.cpp @@ -18,6 +18,7 @@ #include "sna.h" #include #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "error.h" #include "comm.h" @@ -25,6 +26,7 @@ using namespace std; using namespace LAMMPS_NS; using namespace MathConst; +using namespace MathSpecial; /* ---------------------------------------------------------------------- @@ -1363,196 +1365,6 @@ void SNA::destroy_twojmax_arrays() } -/* ---------------------------------------------------------------------- - factorial n, wrapper for precomputed table -------------------------------------------------------------------------- */ - -double SNA::factorial(int n) -{ - if (n < 0 || n > nmaxfactorial) { - char str[128]; - sprintf(str, "Invalid argument to factorial %d", n); - error->all(FLERR, str); - } - - return nfac_table[n]; -} - -/* ---------------------------------------------------------------------- - factorial n table, size SNA::nmaxfactorial+1 -------------------------------------------------------------------------- */ - -const double SNA::nfac_table[] = { - 1, - 1, - 2, - 6, - 24, - 120, - 720, - 5040, - 40320, - 362880, - 3628800, - 39916800, - 479001600, - 6227020800, - 87178291200, - 1307674368000, - 20922789888000, - 355687428096000, - 6.402373705728e+15, - 1.21645100408832e+17, - 2.43290200817664e+18, - 5.10909421717094e+19, - 1.12400072777761e+21, - 2.5852016738885e+22, - 6.20448401733239e+23, - 1.5511210043331e+25, - 4.03291461126606e+26, - 1.08888694504184e+28, - 3.04888344611714e+29, - 8.8417619937397e+30, - 2.65252859812191e+32, - 8.22283865417792e+33, - 2.63130836933694e+35, - 8.68331761881189e+36, - 2.95232799039604e+38, - 1.03331479663861e+40, - 3.71993326789901e+41, - 1.37637530912263e+43, - 5.23022617466601e+44, - 2.03978820811974e+46, - 8.15915283247898e+47, - 3.34525266131638e+49, - 1.40500611775288e+51, - 6.04152630633738e+52, - 2.65827157478845e+54, - 1.1962222086548e+56, - 5.50262215981209e+57, - 2.58623241511168e+59, - 1.24139155925361e+61, - 6.08281864034268e+62, - 3.04140932017134e+64, - 1.55111875328738e+66, - 8.06581751709439e+67, - 4.27488328406003e+69, - 2.30843697339241e+71, - 1.26964033536583e+73, - 7.10998587804863e+74, - 4.05269195048772e+76, - 2.35056133128288e+78, - 1.3868311854569e+80, - 8.32098711274139e+81, - 5.07580213877225e+83, - 3.14699732603879e+85, - 1.98260831540444e+87, - 1.26886932185884e+89, - 8.24765059208247e+90, - 5.44344939077443e+92, - 3.64711109181887e+94, - 2.48003554243683e+96, - 1.71122452428141e+98, - 1.19785716699699e+100, - 8.50478588567862e+101, - 6.12344583768861e+103, - 4.47011546151268e+105, - 3.30788544151939e+107, - 2.48091408113954e+109, - 1.88549470166605e+111, - 1.45183092028286e+113, - 1.13242811782063e+115, - 8.94618213078297e+116, - 7.15694570462638e+118, - 5.79712602074737e+120, - 4.75364333701284e+122, - 3.94552396972066e+124, - 3.31424013456535e+126, - 2.81710411438055e+128, - 2.42270953836727e+130, - 2.10775729837953e+132, - 1.85482642257398e+134, - 1.65079551609085e+136, - 1.48571596448176e+138, - 1.3520015276784e+140, - 1.24384140546413e+142, - 1.15677250708164e+144, - 1.08736615665674e+146, - 1.03299784882391e+148, - 9.91677934870949e+149, - 9.61927596824821e+151, - 9.42689044888324e+153, - 9.33262154439441e+155, - 9.33262154439441e+157, - 9.42594775983835e+159, - 9.61446671503512e+161, - 9.90290071648618e+163, - 1.02990167451456e+166, - 1.08139675824029e+168, - 1.14628056373471e+170, - 1.22652020319614e+172, - 1.32464181945183e+174, - 1.44385958320249e+176, - 1.58824554152274e+178, - 1.76295255109024e+180, - 1.97450685722107e+182, - 2.23119274865981e+184, - 2.54355973347219e+186, - 2.92509369349301e+188, - 3.3931086844519e+190, - 3.96993716080872e+192, - 4.68452584975429e+194, - 5.5745857612076e+196, - 6.68950291344912e+198, - 8.09429852527344e+200, - 9.8750442008336e+202, - 1.21463043670253e+205, - 1.50614174151114e+207, - 1.88267717688893e+209, - 2.37217324288005e+211, - 3.01266001845766e+213, - 3.8562048236258e+215, - 4.97450422247729e+217, - 6.46685548922047e+219, - 8.47158069087882e+221, - 1.118248651196e+224, - 1.48727070609069e+226, - 1.99294274616152e+228, - 2.69047270731805e+230, - 3.65904288195255e+232, - 5.01288874827499e+234, - 6.91778647261949e+236, - 9.61572319694109e+238, - 1.34620124757175e+241, - 1.89814375907617e+243, - 2.69536413788816e+245, - 3.85437071718007e+247, - 5.5502938327393e+249, - 8.04792605747199e+251, - 1.17499720439091e+254, - 1.72724589045464e+256, - 2.55632391787286e+258, - 3.80892263763057e+260, - 5.71338395644585e+262, - 8.62720977423323e+264, - 1.31133588568345e+267, - 2.00634390509568e+269, - 3.08976961384735e+271, - 4.78914290146339e+273, - 7.47106292628289e+275, - 1.17295687942641e+278, - 1.85327186949373e+280, - 2.94670227249504e+282, - 4.71472363599206e+284, - 7.59070505394721e+286, - 1.22969421873945e+289, - 2.0044015765453e+291, - 3.28721858553429e+293, - 5.42391066613159e+295, - 9.00369170577843e+297, - 1.503616514865e+300, // nmaxfactorial = 167 -}; - /* ---------------------------------------------------------------------- the function delta given by VMK Eq. 8.2(1) ------------------------------------------------------------------------- */ diff --git a/src/SNAP/sna.h b/src/SNAP/sna.h index 30c4aa6bbc..746b55fb70 100644 --- a/src/SNAP/sna.h +++ b/src/SNAP/sna.h @@ -100,10 +100,6 @@ private: double** dulist_r, ** dulist_i; int elem_duarray; // element of j in derivative - static const int nmaxfactorial = 167; - static const double nfac_table[]; - double factorial(int); - void create_twojmax_arrays(); void destroy_twojmax_arrays(); void init_clebsch_gordan(); diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index 94647cb552..aedf90da07 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -72,17 +72,6 @@ using namespace MathSpecial; #define PGDELTA 1 #define MAXNEIGH 24 -/* ------------------------------------------------------------------------------------ - - Calculates the factorial of an integer n via recursion. - - ------------------------------------------------------------------------------------ */ -static double factorial(int n) -{ - if (n <= 1) return 1.0; - else return static_cast(n)*factorial(n-1); -} - /* ---------------------------------------------------------------------- */ PairSMTBQ::PairSMTBQ(LAMMPS *lmp) : Pair(lmp) diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index db8a2f404b..b334654e82 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -23,6 +23,7 @@ #include "error.h" #include "force.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" @@ -36,6 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using namespace MathSpecial; + #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) @@ -708,191 +711,3 @@ void ComputeOrientOrderAtom::init_clebsch_gordan() } } } - -/* ---------------------------------------------------------------------- - factorial n, wrapper for precomputed table -------------------------------------------------------------------------- */ - -double ComputeOrientOrderAtom::factorial(int n) -{ - if (n < 0 || n > nmaxfactorial) - error->all(FLERR,fmt::format("Invalid argument to factorial {}", n)); - - return nfac_table[n]; -} - -/* ---------------------------------------------------------------------- - factorial n table, size SNA::nmaxfactorial+1 -------------------------------------------------------------------------- */ - -const double ComputeOrientOrderAtom::nfac_table[] = { - 1, - 1, - 2, - 6, - 24, - 120, - 720, - 5040, - 40320, - 362880, - 3628800, - 39916800, - 479001600, - 6227020800, - 87178291200, - 1307674368000, - 20922789888000, - 355687428096000, - 6.402373705728e+15, - 1.21645100408832e+17, - 2.43290200817664e+18, - 5.10909421717094e+19, - 1.12400072777761e+21, - 2.5852016738885e+22, - 6.20448401733239e+23, - 1.5511210043331e+25, - 4.03291461126606e+26, - 1.08888694504184e+28, - 3.04888344611714e+29, - 8.8417619937397e+30, - 2.65252859812191e+32, - 8.22283865417792e+33, - 2.63130836933694e+35, - 8.68331761881189e+36, - 2.95232799039604e+38, - 1.03331479663861e+40, - 3.71993326789901e+41, - 1.37637530912263e+43, - 5.23022617466601e+44, - 2.03978820811974e+46, - 8.15915283247898e+47, - 3.34525266131638e+49, - 1.40500611775288e+51, - 6.04152630633738e+52, - 2.65827157478845e+54, - 1.1962222086548e+56, - 5.50262215981209e+57, - 2.58623241511168e+59, - 1.24139155925361e+61, - 6.08281864034268e+62, - 3.04140932017134e+64, - 1.55111875328738e+66, - 8.06581751709439e+67, - 4.27488328406003e+69, - 2.30843697339241e+71, - 1.26964033536583e+73, - 7.10998587804863e+74, - 4.05269195048772e+76, - 2.35056133128288e+78, - 1.3868311854569e+80, - 8.32098711274139e+81, - 5.07580213877225e+83, - 3.14699732603879e+85, - 1.98260831540444e+87, - 1.26886932185884e+89, - 8.24765059208247e+90, - 5.44344939077443e+92, - 3.64711109181887e+94, - 2.48003554243683e+96, - 1.71122452428141e+98, - 1.19785716699699e+100, - 8.50478588567862e+101, - 6.12344583768861e+103, - 4.47011546151268e+105, - 3.30788544151939e+107, - 2.48091408113954e+109, - 1.88549470166605e+111, - 1.45183092028286e+113, - 1.13242811782063e+115, - 8.94618213078297e+116, - 7.15694570462638e+118, - 5.79712602074737e+120, - 4.75364333701284e+122, - 3.94552396972066e+124, - 3.31424013456535e+126, - 2.81710411438055e+128, - 2.42270953836727e+130, - 2.10775729837953e+132, - 1.85482642257398e+134, - 1.65079551609085e+136, - 1.48571596448176e+138, - 1.3520015276784e+140, - 1.24384140546413e+142, - 1.15677250708164e+144, - 1.08736615665674e+146, - 1.03299784882391e+148, - 9.91677934870949e+149, - 9.61927596824821e+151, - 9.42689044888324e+153, - 9.33262154439441e+155, - 9.33262154439441e+157, - 9.42594775983835e+159, - 9.61446671503512e+161, - 9.90290071648618e+163, - 1.02990167451456e+166, - 1.08139675824029e+168, - 1.14628056373471e+170, - 1.22652020319614e+172, - 1.32464181945183e+174, - 1.44385958320249e+176, - 1.58824554152274e+178, - 1.76295255109024e+180, - 1.97450685722107e+182, - 2.23119274865981e+184, - 2.54355973347219e+186, - 2.92509369349301e+188, - 3.3931086844519e+190, - 3.96993716080872e+192, - 4.68452584975429e+194, - 5.5745857612076e+196, - 6.68950291344912e+198, - 8.09429852527344e+200, - 9.8750442008336e+202, - 1.21463043670253e+205, - 1.50614174151114e+207, - 1.88267717688893e+209, - 2.37217324288005e+211, - 3.01266001845766e+213, - 3.8562048236258e+215, - 4.97450422247729e+217, - 6.46685548922047e+219, - 8.47158069087882e+221, - 1.118248651196e+224, - 1.48727070609069e+226, - 1.99294274616152e+228, - 2.69047270731805e+230, - 3.65904288195255e+232, - 5.01288874827499e+234, - 6.91778647261949e+236, - 9.61572319694109e+238, - 1.34620124757175e+241, - 1.89814375907617e+243, - 2.69536413788816e+245, - 3.85437071718007e+247, - 5.5502938327393e+249, - 8.04792605747199e+251, - 1.17499720439091e+254, - 1.72724589045464e+256, - 2.55632391787286e+258, - 3.80892263763057e+260, - 5.71338395644585e+262, - 8.62720977423323e+264, - 1.31133588568345e+267, - 2.00634390509568e+269, - 3.08976961384735e+271, - 4.78914290146339e+273, - 7.47106292628289e+275, - 1.17295687942641e+278, - 1.85327186949373e+280, - 2.94670227249504e+282, - 4.71472363599206e+284, - 7.59070505394721e+286, - 1.22969421873945e+289, - 2.0044015765453e+291, - 3.28721858553429e+293, - 5.42391066613159e+295, - 9.00369170577843e+297, - 1.503616514865e+300, // nmaxfactorial = 167 -}; - diff --git a/src/compute_orientorder_atom.h b/src/compute_orientorder_atom.h index 4e5084bfcd..4fc122c5c8 100644 --- a/src/compute_orientorder_atom.h +++ b/src/compute_orientorder_atom.h @@ -56,9 +56,6 @@ class ComputeOrientOrderAtom : public Compute { double polar_prefactor(int, int, double); double associated_legendre(int, int, double); - static const int nmaxfactorial = 167; - static const double nfac_table[]; - double factorial(int); virtual void init_clebsch_gordan(); double *cglist; // Clebsch-Gordan coeffs int idxcg_max; diff --git a/src/math_special.cpp b/src/math_special.cpp index 5ec0fc3f61..4ed91ba51f 100644 --- a/src/math_special.cpp +++ b/src/math_special.cpp @@ -1,9 +1,203 @@ #include "math_special.h" + #include #include // IWYU pragma: keep +#include + +#include "error.h" using namespace LAMMPS_NS; +static constexpr int nmaxfactorial = 167; + +/* ---------------------------------------------------------------------- + factorial n table, size nmaxfactorial+1 +------------------------------------------------------------------------- */ + +static const double nfac_table[] = { + 1, + 1, + 2, + 6, + 24, + 120, + 720, + 5040, + 40320, + 362880, + 3628800, + 39916800, + 479001600, + 6227020800, + 87178291200, + 1307674368000, + 20922789888000, + 355687428096000, + 6.402373705728e+15, + 1.21645100408832e+17, + 2.43290200817664e+18, + 5.10909421717094e+19, + 1.12400072777761e+21, + 2.5852016738885e+22, + 6.20448401733239e+23, + 1.5511210043331e+25, + 4.03291461126606e+26, + 1.08888694504184e+28, + 3.04888344611714e+29, + 8.8417619937397e+30, + 2.65252859812191e+32, + 8.22283865417792e+33, + 2.63130836933694e+35, + 8.68331761881189e+36, + 2.95232799039604e+38, + 1.03331479663861e+40, + 3.71993326789901e+41, + 1.37637530912263e+43, + 5.23022617466601e+44, + 2.03978820811974e+46, + 8.15915283247898e+47, + 3.34525266131638e+49, + 1.40500611775288e+51, + 6.04152630633738e+52, + 2.65827157478845e+54, + 1.1962222086548e+56, + 5.50262215981209e+57, + 2.58623241511168e+59, + 1.24139155925361e+61, + 6.08281864034268e+62, + 3.04140932017134e+64, + 1.55111875328738e+66, + 8.06581751709439e+67, + 4.27488328406003e+69, + 2.30843697339241e+71, + 1.26964033536583e+73, + 7.10998587804863e+74, + 4.05269195048772e+76, + 2.35056133128288e+78, + 1.3868311854569e+80, + 8.32098711274139e+81, + 5.07580213877225e+83, + 3.14699732603879e+85, + 1.98260831540444e+87, + 1.26886932185884e+89, + 8.24765059208247e+90, + 5.44344939077443e+92, + 3.64711109181887e+94, + 2.48003554243683e+96, + 1.71122452428141e+98, + 1.19785716699699e+100, + 8.50478588567862e+101, + 6.12344583768861e+103, + 4.47011546151268e+105, + 3.30788544151939e+107, + 2.48091408113954e+109, + 1.88549470166605e+111, + 1.45183092028286e+113, + 1.13242811782063e+115, + 8.94618213078297e+116, + 7.15694570462638e+118, + 5.79712602074737e+120, + 4.75364333701284e+122, + 3.94552396972066e+124, + 3.31424013456535e+126, + 2.81710411438055e+128, + 2.42270953836727e+130, + 2.10775729837953e+132, + 1.85482642257398e+134, + 1.65079551609085e+136, + 1.48571596448176e+138, + 1.3520015276784e+140, + 1.24384140546413e+142, + 1.15677250708164e+144, + 1.08736615665674e+146, + 1.03299784882391e+148, + 9.91677934870949e+149, + 9.61927596824821e+151, + 9.42689044888324e+153, + 9.33262154439441e+155, + 9.33262154439441e+157, + 9.42594775983835e+159, + 9.61446671503512e+161, + 9.90290071648618e+163, + 1.02990167451456e+166, + 1.08139675824029e+168, + 1.14628056373471e+170, + 1.22652020319614e+172, + 1.32464181945183e+174, + 1.44385958320249e+176, + 1.58824554152274e+178, + 1.76295255109024e+180, + 1.97450685722107e+182, + 2.23119274865981e+184, + 2.54355973347219e+186, + 2.92509369349301e+188, + 3.3931086844519e+190, + 3.96993716080872e+192, + 4.68452584975429e+194, + 5.5745857612076e+196, + 6.68950291344912e+198, + 8.09429852527344e+200, + 9.8750442008336e+202, + 1.21463043670253e+205, + 1.50614174151114e+207, + 1.88267717688893e+209, + 2.37217324288005e+211, + 3.01266001845766e+213, + 3.8562048236258e+215, + 4.97450422247729e+217, + 6.46685548922047e+219, + 8.47158069087882e+221, + 1.118248651196e+224, + 1.48727070609069e+226, + 1.99294274616152e+228, + 2.69047270731805e+230, + 3.65904288195255e+232, + 5.01288874827499e+234, + 6.91778647261949e+236, + 9.61572319694109e+238, + 1.34620124757175e+241, + 1.89814375907617e+243, + 2.69536413788816e+245, + 3.85437071718007e+247, + 5.5502938327393e+249, + 8.04792605747199e+251, + 1.17499720439091e+254, + 1.72724589045464e+256, + 2.55632391787286e+258, + 3.80892263763057e+260, + 5.71338395644585e+262, + 8.62720977423323e+264, + 1.31133588568345e+267, + 2.00634390509568e+269, + 3.08976961384735e+271, + 4.78914290146339e+273, + 7.47106292628289e+275, + 1.17295687942641e+278, + 1.85327186949373e+280, + 2.94670227249504e+282, + 4.71472363599206e+284, + 7.59070505394721e+286, + 1.22969421873945e+289, + 2.0044015765453e+291, + 3.28721858553429e+293, + 5.42391066613159e+295, + 9.00369170577843e+297, + 1.503616514865e+300, // nmaxfactorial = 167 +}; + +/* ---------------------------------------------------------------------- + factorial n vial lookup from precomputed table +------------------------------------------------------------------------- */ + +double MathSpecial::factorial(const int n) +{ + if (n < 0 || n > nmaxfactorial) + return std::numeric_limits::quiet_NaN(); + + return nfac_table[n]; +} + + /* Library libcerf: * Compute complex error functions, based on a new implementation of * Faddeeva's w_of_z. Also provide Dawson and Voigt functions. diff --git a/src/math_special.h b/src/math_special.h index 1e7b10d9fd..59517a2f76 100644 --- a/src/math_special.h +++ b/src/math_special.h @@ -20,6 +20,10 @@ namespace LAMMPS_NS { namespace MathSpecial { + // tabulated factorial function + + extern double factorial(const int); + // support function for scaled error function complement extern double erfcx_y100(const double y100); From a403e209d38db8b06a74401e8ed0109cea310771 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 13:00:51 -0500 Subject: [PATCH 116/187] use C++11 constexpr instead of C++98 const. --- src/math_const.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/math_const.h b/src/math_const.h index fefb442f68..53a485bf99 100644 --- a/src/math_const.h +++ b/src/math_const.h @@ -17,18 +17,18 @@ namespace LAMMPS_NS { namespace MathConst { - static const double THIRD = 1.0/3.0; - static const double TWOTHIRDS = 2.0/3.0; - static const double MY_PI = 3.14159265358979323846; // pi - static const double MY_2PI = 6.28318530717958647692; // 2pi - static const double MY_3PI = 9.42477796076937971538; // 3pi - static const double MY_4PI = 12.56637061435917295384; // 4pi - static const double MY_PI2 = 1.57079632679489661923; // pi/2 - static const double MY_PI4 = 0.78539816339744830962; // pi/4 - static const double MY_PIS = 1.77245385090551602729; // sqrt(pi) - static const double MY_ISPI4 = 1.12837916709551257389; // 1/sqrt(pi/4) - static const double MY_SQRT2 = 1.41421356237309504880; // sqrt(2) - static const double MY_CBRT2 = 1.25992104989487316476; // 2*(1/3) + static constexpr double THIRD = 1.0/3.0; + static constexpr double TWOTHIRDS = 2.0/3.0; + static constexpr double MY_PI = 3.14159265358979323846; // pi + static constexpr double MY_2PI = 6.28318530717958647692; // 2pi + static constexpr double MY_3PI = 9.42477796076937971538; // 3pi + static constexpr double MY_4PI = 12.56637061435917295384; // 4pi + static constexpr double MY_PI2 = 1.57079632679489661923; // pi/2 + static constexpr double MY_PI4 = 0.78539816339744830962; // pi/4 + static constexpr double MY_PIS = 1.77245385090551602729; // sqrt(pi) + static constexpr double MY_ISPI4 = 1.12837916709551257389; // 1/sqrt(pi/4) + static constexpr double MY_SQRT2 = 1.41421356237309504880; // sqrt(2) + static constexpr double MY_CBRT2 = 1.25992104989487316476; // 2*(1/3) } } From 2426e6245db130237a645230aaec564fa1871a91 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 14:02:56 -0500 Subject: [PATCH 117/187] move static constants in pair style out of the globally included header --- src/KOKKOS/pair_zbl_kokkos.cpp | 2 ++ src/USER-OMP/pair_zbl_omp.cpp | 1 - src/pair_zbl.cpp | 7 +++++-- src/pair_zbl.h | 17 ----------------- src/pair_zbl_const.h | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 src/pair_zbl_const.h diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index 2cbe65dcf7..4e7e67a074 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -30,6 +30,8 @@ #include "atom_masks.h" #include "kokkos.h" +#include "pair_zbl_const.h" + // From J.F. Zeigler, J. P. Biersack and U. Littmark, // "The Stopping and Range of Ions in Matter" volume 1, Pergamon, 1985. diff --git a/src/USER-OMP/pair_zbl_omp.cpp b/src/USER-OMP/pair_zbl_omp.cpp index 993e75f499..6794789f25 100644 --- a/src/USER-OMP/pair_zbl_omp.cpp +++ b/src/USER-OMP/pair_zbl_omp.cpp @@ -24,7 +24,6 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -using namespace PairZBLConstants; /* ---------------------------------------------------------------------- */ diff --git a/src/pair_zbl.cpp b/src/pair_zbl.cpp index 6dff702d2c..80b623ff35 100644 --- a/src/pair_zbl.cpp +++ b/src/pair_zbl.cpp @@ -16,15 +16,18 @@ ------------------------------------------------------------------------- */ #include "pair_zbl.h" + #include + #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" +#include "memory.h" #include "neighbor.h" #include "neigh_list.h" -#include "memory.h" -#include "error.h" +#include "pair_zbl_const.h" // From J.F. Zeigler, J. P. Biersack and U. Littmark, // "The Stopping and Range of Ions in Matter" volume 1, Pergamon, 1985. diff --git a/src/pair_zbl.h b/src/pair_zbl.h index 55a5dc5fa4..6a16bc7419 100644 --- a/src/pair_zbl.h +++ b/src/pair_zbl.h @@ -54,23 +54,6 @@ class PairZBL : public Pair { double d2zbldr2(double, int, int); void set_coeff(int, int, double, double); }; - -namespace PairZBLConstants { - - // ZBL constants - - static const double pzbl = 0.23; - static const double a0 = 0.46850; - static const double c1 = 0.02817; - static const double c2 = 0.28022; - static const double c3 = 0.50986; - static const double c4 = 0.18175; - static const double d1 = 0.20162; - static const double d2 = 0.40290; - static const double d3 = 0.94229; - static const double d4 = 3.19980; -} - } #endif diff --git a/src/pair_zbl_const.h b/src/pair_zbl_const.h new file mode 100644 index 0000000000..385657693f --- /dev/null +++ b/src/pair_zbl_const.h @@ -0,0 +1,34 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_PAIR_ZBL_CONST_H +#define LMP_PAIR_ZBL_CONST_H + +namespace LAMMPS_NS { +namespace PairZBLConstants { + + // ZBL constants + + static constexpr double pzbl = 0.23; + static constexpr double a0 = 0.46850; + static constexpr double c1 = 0.02817; + static constexpr double c2 = 0.28022; + static constexpr double c3 = 0.50986; + static constexpr double c4 = 0.18175; + static constexpr double d1 = 0.20162; + static constexpr double d2 = 0.40290; + static constexpr double d3 = 0.94229; + static constexpr double d4 = 3.19980; +} +} +#endif From 3e2b004d216e9b6dfceab78afa889657a4f3f754 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 16:01:26 -0500 Subject: [PATCH 118/187] more use of constexpr --- src/MANYBODY/pair_comb.h | 2 +- src/MANYBODY/pair_comb3.h | 2 +- src/MANYBODY/pair_gw.h | 2 +- src/MANYBODY/pair_gw_zbl.h | 2 +- src/MANYBODY/pair_nb3b_harmonic.h | 2 +- src/MANYBODY/pair_sw.h | 2 +- src/MANYBODY/pair_tersoff.h | 2 +- src/MANYBODY/pair_tersoff_mod.h | 2 +- src/MANYBODY/pair_tersoff_mod_c.h | 2 +- src/MANYBODY/pair_tersoff_zbl.h | 2 +- src/MANYBODY/pair_vashishta.h | 2 +- src/RIGID/rigid_const.h | 20 ++++++++++---------- src/USER-MISC/pair_tersoff_table.h | 2 +- src/pair_coul_streitz.h | 2 +- src/text_file_reader.h | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/MANYBODY/pair_comb.h b/src/MANYBODY/pair_comb.h index 7a3d279033..f809dfaf0e 100644 --- a/src/MANYBODY/pair_comb.h +++ b/src/MANYBODY/pair_comb.h @@ -38,7 +38,7 @@ class PairComb : public Pair { virtual double yasu_char(double *, int &); double enegtot; - static const int NPARAMS_PER_LINE = 49; + static constexpr int NPARAMS_PER_LINE = 49; protected: struct Param { diff --git a/src/MANYBODY/pair_comb3.h b/src/MANYBODY/pair_comb3.h index 567859127b..b1c216fee6 100644 --- a/src/MANYBODY/pair_comb3.h +++ b/src/MANYBODY/pair_comb3.h @@ -37,7 +37,7 @@ class PairComb3 : public Pair { virtual double combqeq(double *, int &); double enegtot; - static const int NPARAMS_PER_LINE = 74; + static constexpr int NPARAMS_PER_LINE = 74; protected: // general potential parameters diff --git a/src/MANYBODY/pair_gw.h b/src/MANYBODY/pair_gw.h index 77ff5c0399..2dbf3dcf84 100644 --- a/src/MANYBODY/pair_gw.h +++ b/src/MANYBODY/pair_gw.h @@ -34,7 +34,7 @@ class PairGW : public Pair { void init_style(); double init_one(int, int); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; protected: struct Param { diff --git a/src/MANYBODY/pair_gw_zbl.h b/src/MANYBODY/pair_gw_zbl.h index 95129c4eb8..de344e94f7 100644 --- a/src/MANYBODY/pair_gw_zbl.h +++ b/src/MANYBODY/pair_gw_zbl.h @@ -29,7 +29,7 @@ class PairGWZBL : public PairGW { PairGWZBL(class LAMMPS *); ~PairGWZBL() {} - static const int NPARAMS_PER_LINE = 21; + static constexpr int NPARAMS_PER_LINE = 21; private: double global_a_0; // Bohr radius for Coulomb repulsion diff --git a/src/MANYBODY/pair_nb3b_harmonic.h b/src/MANYBODY/pair_nb3b_harmonic.h index 0267b6d0e2..b68974e15f 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.h +++ b/src/MANYBODY/pair_nb3b_harmonic.h @@ -34,7 +34,7 @@ class PairNb3bHarmonic : public Pair { double init_one(int, int); void init_style(); - static const int NPARAMS_PER_LINE = 6; + static constexpr int NPARAMS_PER_LINE = 6; protected: struct Param { diff --git a/src/MANYBODY/pair_sw.h b/src/MANYBODY/pair_sw.h index 441b1c0303..4fdc538430 100644 --- a/src/MANYBODY/pair_sw.h +++ b/src/MANYBODY/pair_sw.h @@ -34,7 +34,7 @@ class PairSW : public Pair { virtual double init_one(int, int); virtual void init_style(); - static const int NPARAMS_PER_LINE = 14; + static constexpr int NPARAMS_PER_LINE = 14; struct Param { double epsilon,sigma; diff --git a/src/MANYBODY/pair_tersoff.h b/src/MANYBODY/pair_tersoff.h index 8ebbc83544..eb29cc227d 100644 --- a/src/MANYBODY/pair_tersoff.h +++ b/src/MANYBODY/pair_tersoff.h @@ -34,7 +34,7 @@ class PairTersoff : public Pair { virtual void init_style(); double init_one(int, int); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; protected: diff --git a/src/MANYBODY/pair_tersoff_mod.h b/src/MANYBODY/pair_tersoff_mod.h index 2cdbae9518..4f1d7a12a6 100644 --- a/src/MANYBODY/pair_tersoff_mod.h +++ b/src/MANYBODY/pair_tersoff_mod.h @@ -30,7 +30,7 @@ class PairTersoffMOD : public PairTersoff { PairTersoffMOD(class LAMMPS *); ~PairTersoffMOD() {} - static const int NPARAMS_PER_LINE = 20; + static constexpr int NPARAMS_PER_LINE = 20; protected: virtual void read_file(char *); diff --git a/src/MANYBODY/pair_tersoff_mod_c.h b/src/MANYBODY/pair_tersoff_mod_c.h index bad5f988be..4949cb76db 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.h +++ b/src/MANYBODY/pair_tersoff_mod_c.h @@ -29,7 +29,7 @@ class PairTersoffMODC : public PairTersoffMOD { PairTersoffMODC(class LAMMPS *lmp) : PairTersoffMOD(lmp) {}; ~PairTersoffMODC() {} - static const int NPARAMS_PER_LINE = 21; + static constexpr int NPARAMS_PER_LINE = 21; protected: void read_file(char *); diff --git a/src/MANYBODY/pair_tersoff_zbl.h b/src/MANYBODY/pair_tersoff_zbl.h index be3f496b62..42483b7d89 100644 --- a/src/MANYBODY/pair_tersoff_zbl.h +++ b/src/MANYBODY/pair_tersoff_zbl.h @@ -29,7 +29,7 @@ class PairTersoffZBL : public PairTersoff { PairTersoffZBL(class LAMMPS *); ~PairTersoffZBL() {} - static const int NPARAMS_PER_LINE = 21; + static constexpr int NPARAMS_PER_LINE = 21; protected: double global_a_0; // Bohr radius for Coulomb repulsion diff --git a/src/MANYBODY/pair_vashishta.h b/src/MANYBODY/pair_vashishta.h index bd250d328a..19a8e01cd9 100644 --- a/src/MANYBODY/pair_vashishta.h +++ b/src/MANYBODY/pair_vashishta.h @@ -34,7 +34,7 @@ class PairVashishta : public Pair { double init_one(int, int); void init_style(); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; struct Param { double bigb,gamma,r0,bigc,costheta; diff --git a/src/RIGID/rigid_const.h b/src/RIGID/rigid_const.h index 3aae988197..b345a6b9dc 100644 --- a/src/RIGID/rigid_const.h +++ b/src/RIGID/rigid_const.h @@ -33,21 +33,21 @@ namespace LAMMPS_NS { TORQUE = 1<<8 }; - static const double TOLERANCE = 1.0e-6; - static const double EPSILON = 1.0e-7; - static const double BIG = 1.0e20; + static constexpr double TOLERANCE = 1.0e-6; + static constexpr double EPSILON = 1.0e-7; + static constexpr double BIG = 1.0e20; // moment of inertia prefactor for sphere - static const double SINERTIA = 0.4; + static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for ellipsoid - static const double EINERTIA = 0.2; + static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for line segment - static const double LINERTIA = 1.0/12.0; + static constexpr double LINERTIA = 1.0/12.0; - static const int MAXLINE = 1024; - static const int CHUNK = 1024; - static const int DELTA_BODY = 10000; - static const int ATTRIBUTE_PERBODY = 20; + static constexpr int MAXLINE = 1024; + static constexpr int CHUNK = 1024; + static constexpr int DELTA_BODY = 10000; + static constexpr int ATTRIBUTE_PERBODY = 20; } } diff --git a/src/USER-MISC/pair_tersoff_table.h b/src/USER-MISC/pair_tersoff_table.h index faa704191c..d63a5be5a6 100644 --- a/src/USER-MISC/pair_tersoff_table.h +++ b/src/USER-MISC/pair_tersoff_table.h @@ -43,7 +43,7 @@ class PairTersoffTable : public Pair { void init_style(); double init_one(int, int); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; protected: struct Param { diff --git a/src/pair_coul_streitz.h b/src/pair_coul_streitz.h index d5a4a2de5c..2f62846212 100644 --- a/src/pair_coul_streitz.h +++ b/src/pair_coul_streitz.h @@ -36,7 +36,7 @@ class PairCoulStreitz : public Pair { double memory_usage(); virtual void *extract(const char *, int &); - static const int NPARAMS_PER_LINE = 6; + static constexpr int NPARAMS_PER_LINE = 6; protected: struct Param { diff --git a/src/text_file_reader.h b/src/text_file_reader.h index 0b90304911..0da21e4581 100644 --- a/src/text_file_reader.h +++ b/src/text_file_reader.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS class TextFileReader { std::string filename; std::string filetype; - static const int MAXLINE = 1024; + static constexpr int MAXLINE = 1024; char line[MAXLINE]; FILE *fp; From 09023edc984405cf991d2e7bbf158ccab033553c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 16:41:18 -0500 Subject: [PATCH 119/187] small python installation docs update --- doc/src/Python_install.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/Python_install.rst b/doc/src/Python_install.rst index 0ebc1c49c3..c12644bf4a 100644 --- a/doc/src/Python_install.rst +++ b/doc/src/Python_install.rst @@ -87,8 +87,8 @@ this. | LAMMPS Python package | * ``$HOME/.local/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | | | * ``$HOME/.local/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``$HOME/.local/lib/`` (32bit) | | - | | * ``$HOME/.local/lib64/`` (64bit) | | + | LAMMPS shared library | * ``$HOME/.local/lib/`` (32bit) | Set shared loader environment variable to this path | + | | * ``$HOME/.local/lib64/`` (64bit) | (see below for more info on this) | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ | LAMMPS executable | * ``$HOME/.local/bin/`` | | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ @@ -274,12 +274,12 @@ this. | LAMMPS Python Module | * ``$VIRTUAL_ENV/lib/pythonX.Y/site-packages/lammps`` (32bit) | ``X.Y`` depends on the installed Python version | | | * ``$VIRTUAL_ENV/lib64/pythonX.Y/site-packages/lammps`` (64bit) | | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS shared library | * ``$VIRTUAL_ENV/lib/`` (32bit) | | - | | * ``$VIRTUAL_ENV/lib64/`` (64bit) | | + | LAMMPS shared library | * ``$VIRTUAL_ENV/lib/`` (32bit) | Set shared loader environment variable to this path | + | | * ``$VIRTUAL_ENV/lib64/`` (64bit) | (see below for more info on this) | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ | LAMMPS executable | * ``$VIRTUAL_ENV/bin/`` | | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ - | LAMMPS potential files | * ``$VIRTUAL_ENV/share/lammps/potentials/`` | | + | LAMMPS potential files | * ``$VIRTUAL_ENV/share/lammps/potentials/`` | Set ``LAMMPS_POTENTIALS`` environment variable to this path | +------------------------+-----------------------------------------------------------------+-------------------------------------------------------------+ In that case you need to modify the ``$HOME/myenv/bin/activate`` @@ -296,7 +296,7 @@ this. echo 'export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$LD_LIBRARY_PATH' >> $HOME/myenv/bin/activate # MacOS - echo 'export DYLD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$LD_LIBRARY_PATH' >> $HOME/myenv/bin/activate + echo 'export DYLD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$DYLD_LIBRARY_PATH' >> $HOME/myenv/bin/activate .. tab:: In place usage From f6fa564ef2b587a48aee0d0f2395b527be009236 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 17:43:04 -0500 Subject: [PATCH 120/187] whitespace --- src/math_special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math_special.cpp b/src/math_special.cpp index 4ed91ba51f..243d5a05f3 100644 --- a/src/math_special.cpp +++ b/src/math_special.cpp @@ -183,7 +183,7 @@ static const double nfac_table[] = { 5.42391066613159e+295, 9.00369170577843e+297, 1.503616514865e+300, // nmaxfactorial = 167 -}; +}; /* ---------------------------------------------------------------------- factorial n vial lookup from precomputed table From de94e28c8bcf07510f1f6426914a48c4231b6dd6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 21:48:04 -0500 Subject: [PATCH 121/187] correct path to find liblammps.dll with Windows installer package --- python/lammps/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index 161583b78c..c0cbaac533 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -77,7 +77,7 @@ class lammps(object): modpath = dirname(abspath(getsourcefile(lambda:0))) # for windows installers the shared library is in a different folder - winpath = abspath(os.path.join(modpath,'..','bin')) + winpath = abspath(os.path.join(modpath,'..','..','bin')) self.lib = None self.lmp = None From 96fa85f61c96b041cd81126db1a61cb4ae4236d8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 22:39:36 -0500 Subject: [PATCH 122/187] alternate implementation of pair/only option (for KOKKOS and GPU) --- src/GPU/fix_gpu.cpp | 12 ++++++++++++ src/KOKKOS/kokkos.cpp | 16 ++++++++++++++++ src/force.cpp | 16 +++++++++++++--- src/input.cpp | 5 ++++- src/lammps.cpp | 3 ++- src/lammps.h | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 5774d1ea50..1f5ad59e09 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -120,6 +120,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : double binsize = 0.0; char *opencl_flags = nullptr; int block_pair = -1; + int pair_only_flag = 0; int iarg = 4; while (iarg < narg) { @@ -169,6 +170,12 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); block_pair = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; + } else if (strcmp(arg[iarg],"pair/only") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); + if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0; + else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1; + else error->all(FLERR,"Illegal package gpu command"); + iarg += 2; } else error->all(FLERR,"Illegal package gpu command"); } @@ -186,6 +193,11 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (force->newton_pair || force->newton_bond) force->newton = 1; else force->newton = 0; + if (pair_only_flag) { + lmp->suffixp = lmp->suffix; + lmp->suffix = nullptr; + } + // pass params to GPU library // change binsize default (0.0) to -1.0 used by GPU lib diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 64455fef4f..d702fbc1be 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -301,6 +301,7 @@ KokkosLMP::~KokkosLMP() void KokkosLMP::accelerator(int narg, char **arg) { + int pair_only_flag = 0; int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"neigh") == 0) { @@ -390,6 +391,12 @@ void KokkosLMP::accelerator(int narg, char **arg) else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; else error->all(FLERR,"Illegal package kokkos command"); iarg += 2; + } else if (strcmp(arg[iarg],"pair/only") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0; + else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1; + else error->all(FLERR,"Illegal package kokkos command"); + iarg += 2; } else if (strcmp(arg[iarg],"neigh/thread") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"off") == 0) neigh_thread = 0; @@ -452,6 +459,15 @@ void KokkosLMP::accelerator(int narg, char **arg) neighbor->binsize_user = binsize; if (binsize <= 0.0) neighbor->binsizeflag = 0; else neighbor->binsizeflag = 1; + + if (pair_only_flag) { + lmp->suffixp = lmp->suffix; + lmp->suffix = new char[7]; + strcpy(lmp->suffix,"kk/host"); + + exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + } } /* ---------------------------------------------------------------------- diff --git a/src/force.cpp b/src/force.cpp index d271d1207e..1f03206f31 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -245,13 +245,22 @@ void Force::create_pair(const std::string &style, int trysuffix) /* ---------------------------------------------------------------------- generate a pair class if trysuffix = 1, try first with suffix1/2 appended - return sflag = 0 for no suffix added, 1 or 2 for suffix1/2 added + return sflag = 0 for no suffix added, 1 or 2 or 3 for suffix1/2/p added + special case: if suffixp exists only try suffixp, not suffix ------------------------------------------------------------------------- */ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag) { if (trysuffix && lmp->suffix_enable) { - if (lmp->suffix) { + if (lmp->suffixp) { + sflag = 3; + std::string estyle = style + "/" + lmp->suffixp; + if (pair_map->find(estyle) != pair_map->end()) { + PairCreator &pair_creator = (*pair_map)[estyle]; + return pair_creator(lmp); + } + } + if (lmp->suffix && !lmp->suffixp) { sflag = 1; std::string estyle = style + "/" + lmp->suffix; if (pair_map->find(estyle) != pair_map->end()) { @@ -727,7 +736,7 @@ KSpace *Force::kspace_match(const std::string &word, int exact) /* ---------------------------------------------------------------------- store style name in str allocated here if sflag = 0, no suffix - if sflag = 1/2, append suffix or suffix2 to style + if sflag = 1/2/3, append suffix or suffix2 or suffixp to style ------------------------------------------------------------------------- */ void Force::store_style(char *&str, const std::string &style, int sflag) @@ -736,6 +745,7 @@ void Force::store_style(char *&str, const std::string &style, int sflag) if (sflag == 1) estyle += std::string("/") + lmp->suffix; else if (sflag == 2) estyle += std::string("/") + lmp->suffix2; + else if (sflag == 3) estyle += std::string("/") + lmp->suffixp; str = new char[estyle.size()+1]; strcpy(str,estyle.c_str()); diff --git a/src/input.cpp b/src/input.cpp index abdc3775ce..457cf74b1a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1715,7 +1715,10 @@ void Input::pair_style() int match = 0; if (style == force->pair_style) match = 1; if (!match && lmp->suffix_enable) { - if (lmp->suffix) + if (lmp->suffixp) + if (style + "/" + lmp->suffixp == force->pair_style) match = 1; + + if (lmp->suffix && !lmp->suffixp) if (style + "/" + lmp->suffix == force->pair_style) match = 1; if (lmp->suffix2) diff --git a/src/lammps.cpp b/src/lammps.cpp index 102d2f18cf..69baec5557 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -173,7 +173,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : int citeflag = 1; int helpflag = 0; - suffix = suffix2 = nullptr; + suffix = suffix2 = suffixp = nullptr; suffix_enable = 0; if (arg) exename = arg[0]; else exename = nullptr; @@ -714,6 +714,7 @@ LAMMPS::~LAMMPS() delete kokkos; delete [] suffix; delete [] suffix2; + delete [] suffixp; // free the MPI comm created by -mpi command-line arg processed in constructor // it was passed to universe as if original universe world diff --git a/src/lammps.h b/src/lammps.h index 0d9442ffb9..49d55d4e37 100644 --- a/src/lammps.h +++ b/src/lammps.h @@ -51,7 +51,7 @@ class LAMMPS { double initclock; // wall clock at instantiation - char *suffix,*suffix2; // suffixes to add to input script style names + char *suffix,*suffix2,*suffixp;// suffixes to add to input script style names int suffix_enable; // 1 if suffixes are enabled, 0 if disabled char *exename; // pointer to argv[0] char ***packargs; // arguments for cmdline package commands From 959f67962dcd1e3961afc0ece4236b3bc4292649 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Dec 2020 22:59:12 -0500 Subject: [PATCH 123/187] allow to revert the pair/only setting --- src/GPU/fix_gpu.cpp | 5 +++++ src/KOKKOS/kokkos.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 1f5ad59e09..8f88dfd61d 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -196,6 +196,11 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (pair_only_flag) { lmp->suffixp = lmp->suffix; lmp->suffix = nullptr; + } else { + if (lmp->suffixp) { + lmp->suffix = lmp->suffixp; + lmp->suffixp = nullptr; + } } // pass params to GPU library diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index d702fbc1be..85a1b9f4e8 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -467,6 +467,14 @@ void KokkosLMP::accelerator(int narg, char **arg) exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + } else { + // restore settings to regular suffix use, if previously, pair/only was used. + if (lmp->suffixp) { + delete[] lmp->suffix; + lmp->suffix = lmp->suffixp; + lmp->suffixp = nullptr; + // TODO: restore communication settings + } } } From 71e340a792607f0ede5874088c895583ed9acf2a Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Fri, 18 Dec 2020 17:56:51 -0700 Subject: [PATCH 124/187] Adding multi+granular note in neighbor documentation --- doc/src/neighbor.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/src/neighbor.rst b/doc/src/neighbor.rst index 1bb591587c..6671e7e1ac 100644 --- a/doc/src/neighbor.rst +++ b/doc/src/neighbor.rst @@ -49,7 +49,9 @@ sometimes be faster. Either style should give the same answers. The *multi* style is a modified binning algorithm that is useful for systems with a wide range of cutoff distances, e.g. due to different -size particles. For the *bin* style, the bin size is set to 1/2 of +size particles. For granular pairstyles, cutoffs are set to the +sum of the maximum atomic radii for each atom type. +For the *bin* style, the bin size is set to 1/2 of the largest cutoff distance between any pair of atom types and a single set of bins is defined to search over for all atom types. This can be inefficient if one pair of types has a very long cutoff, but From 384376bc51cc37f64edc2d612bd47205e7eca9c7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 18 Dec 2020 22:33:56 -0500 Subject: [PATCH 125/187] increase precision of lj/cubic constants and document how to compute them --- src/GPU/pair_lj_cubic_gpu.cpp | 5 +- src/USER-OMP/pair_lj_cubic_omp.cpp | 2 + src/pair_lj_cubic.cpp | 1 + src/pair_lj_cubic.h | 14 -- src/pair_lj_cubic_const.h | 48 +++++++ .../force-styles/tests/mol-pair-lj_cubic.yaml | 128 +++++++++--------- 6 files changed, 119 insertions(+), 79 deletions(-) create mode 100644 src/pair_lj_cubic_const.h diff --git a/src/GPU/pair_lj_cubic_gpu.cpp b/src/GPU/pair_lj_cubic_gpu.cpp index a669d52a19..35062a5d71 100644 --- a/src/GPU/pair_lj_cubic_gpu.cpp +++ b/src/GPU/pair_lj_cubic_gpu.cpp @@ -16,10 +16,11 @@ ------------------------------------------------------------------------- */ #include "pair_lj_cubic_gpu.h" + #include #include - #include + #include "atom.h" #include "atom_vec.h" #include "comm.h" @@ -36,6 +37,8 @@ #include "gpu_extra.h" #include "suffix.h" +#include "pair_lj_cubic_const.h" + using namespace LAMMPS_NS; using namespace PairLJCubicConstants; diff --git a/src/USER-OMP/pair_lj_cubic_omp.cpp b/src/USER-OMP/pair_lj_cubic_omp.cpp index 872574a3b2..e96b3d0a79 100644 --- a/src/USER-OMP/pair_lj_cubic_omp.cpp +++ b/src/USER-OMP/pair_lj_cubic_omp.cpp @@ -23,6 +23,8 @@ #include #include "omp_compat.h" +#include "pair_lj_cubic_const.h" + using namespace LAMMPS_NS; using namespace PairLJCubicConstants; diff --git a/src/pair_lj_cubic.cpp b/src/pair_lj_cubic.cpp index 7fe4757358..c5f1f5b257 100644 --- a/src/pair_lj_cubic.cpp +++ b/src/pair_lj_cubic.cpp @@ -26,6 +26,7 @@ #include "memory.h" #include "error.h" +#include "pair_lj_cubic_const.h" using namespace LAMMPS_NS; using namespace PairLJCubicConstants; diff --git a/src/pair_lj_cubic.h b/src/pair_lj_cubic.h index d0af06c0a0..4b5edf7e97 100644 --- a/src/pair_lj_cubic.h +++ b/src/pair_lj_cubic.h @@ -46,20 +46,6 @@ class PairLJCubic : public Pair { void allocate(); }; - -namespace PairLJCubicConstants { - - // LJ quantities scaled by epsilon and rmin = sigma*2^1/6 - - static const double RT6TWO = 1.1224621; // 2^1/6 - static const double SS = 1.1086834; // inflection point (13/7)^1/6 - static const double PHIS = -0.7869823; // energy at s - static const double DPHIDS = 2.6899009; // gradient at s - static const double A3 = 27.93357; // cubic coefficient - static const double SM = 1.5475375; // cubic cutoff = s*67/48 - -} - } #endif diff --git a/src/pair_lj_cubic_const.h b/src/pair_lj_cubic_const.h new file mode 100644 index 0000000000..5fc773ac3c --- /dev/null +++ b/src/pair_lj_cubic_const.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_PAIR_LJ_CUBIC_CONST_H +#define LMP_PAIR_LJ_CUBIC_CONST_H + +namespace LAMMPS_NS { +namespace PairLJCubicConstants { + + // LJ quantities scaled by epsilon and rmin = sigma*2^1/6 + + static constexpr double RT6TWO = 1.1224620483093730; // 2^1/6 + static constexpr double SS = 1.1086834179687215; // inflection point (13/7)^1/6 + static constexpr double PHIS = -0.7869822485207097; // energy at s + static constexpr double DPHIDS = 2.6899008972047196; // gradient at s + static constexpr double A3 = 27.9335700460986445; // cubic coefficient + static constexpr double SM = 1.5475372709146737; // cubic cutoff = s*67/48} +} +} +#endif + +// python script to compute the constants +// +// sixth = 1.0/6.0 +// rmin = pow(2.0,sixth) +// rs = pow(26.0/7.0,sixth) +// ss = rs/rmin +// pow6 = pow(1.0/rs,6.0) +// phis = 4.0*pow6*(pow6-1.0) +// dpds = -24.0*pow6*(2.0*pow6-1.0)/rs*rmin +// a3 = 8.0*pow(dpds,3)/(9.0*phis*phis) +// sm = 67.0/48.0*ss +// print("static constexpr double RT6TWO = %19.16f; // 2^1/6" % rmin) +// print("static constexpr double SS = %19.16f; // inflection point (13/7)^1/6" % ss) +// print("static constexpr double PHIS = %19.16f; // energy at s" % phis) +// print("static constexpr double DPHIDS = %19.16f; // gradient at s" % dpds) +// print("static constexpr double A3 = %19.16f; // cubic coefficient" % a3) +// print("static constexpr double SM = %19.16f; // cubic cutoff = s*67/48" % sm) diff --git a/unittest/force-styles/tests/mol-pair-lj_cubic.yaml b/unittest/force-styles/tests/mol-pair-lj_cubic.yaml index ad7f0666ca..6d23998ad5 100644 --- a/unittest/force-styles/tests/mol-pair-lj_cubic.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_cubic.yaml @@ -1,7 +1,7 @@ --- -lammps_version: 24 Aug 2020 -date_generated: Tue Sep 15 09:44:15 202 -epsilon: 2e-13 +lammps_version: 30 Nov 2020 +date_generated: Fri Dec 18 22:30:42 202 +epsilon: 1e-13 prerequisites: ! | atom full pair lj/cubic @@ -19,72 +19,72 @@ pair_coeff: ! | 5 5 0.015 3.1 extract: ! "" natoms: 29 -init_vdwl: 166.005266308562 +init_vdwl: 166.005266338502 init_coul: 0 init_stress: ! |2- - 4.5860676757908186e+02 4.8091912919212928e+02 1.0767204080701006e+03 -2.1005546139122362e+02 -2.9491286717936713e+00 1.6145675857120941e+02 + 4.5860676760613336e+02 4.8091912923656065e+02 1.0767204080957010e+03 -2.1005546139899724e+02 -2.9491286649299440e+00 1.6145675855773089e+02 init_forces: ! |2 - 1 9.1849370411551270e+00 7.6268937957720553e+01 6.1726872441625311e+01 - 2 2.2858712118514426e+01 1.8809274242266209e+01 -2.6905829837199740e+01 - 3 -3.2016987482543328e+01 -9.4135849525427091e+01 -3.4799279593035926e+01 - 4 -5.5341015869901478e-01 1.5206999898436971e-01 -3.9418368928369890e-01 - 5 -1.8042057425348118e-01 -3.0459951056385326e-01 8.7068483241007189e-01 - 6 -2.0038994438822397e+02 2.3344446299945159e+02 2.8487343926572851e+02 - 7 8.0909912172413883e+00 -7.8410849891085633e+01 -4.3214084684451740e+02 - 8 4.7943581255133857e+01 -2.1287511456246008e+01 1.4094503445180061e+02 - 9 1.1447552368270737e+01 1.2328709806786962e+01 5.0656476982000299e+01 - 10 1.3071496571967870e+02 -1.4589264560693914e+02 -4.4748155922123622e+01 - 11 -1.6551880116149281e-01 -4.1534332040572380e-01 -6.8284765241715795e-01 - 12 1.7721533626133388e+00 6.3456329073685158e-01 -8.2372301448028962e-01 - 13 5.6789360334118277e-01 -2.2634410312439054e-01 -9.7536738055328392e-03 - 14 -2.4337021468262635e-01 4.6659433642728905e-02 -6.1110664501270184e-01 - 15 -2.1936997101927893e-02 5.9238263972968364e-01 2.1493099548264527e-01 - 16 1.1121534968449923e+02 -7.8056927924992834e+01 -2.9249212971206231e+02 - 17 -1.1020604609843586e+02 7.6481296254913858e+01 2.9430701446263464e+02 - 18 -1.6570656719723909e-02 -2.7996966177077785e-02 2.6456326954440619e-02 - 19 7.4243353115058947e-04 6.3524893127716046e-04 1.8675586277048476e-04 - 20 -7.4243353115058947e-04 -6.3524893127716046e-04 -1.8675586277048476e-04 + 1 9.1849370400954342e+00 7.6268937960282486e+01 6.1726872440953251e+01 + 2 2.2858712118557477e+01 1.8809274242339992e+01 -2.6905829837209875e+01 + 3 -3.2016987482586380e+01 -9.4135849525500873e+01 -3.4799279593025787e+01 + 4 -5.5341015917141478e-01 1.5206999930354809e-01 -3.9418368927471259e-01 + 5 -1.8042057490785210e-01 -3.0459951013385317e-01 8.7068483295449139e-01 + 6 -2.0038994438983289e+02 2.3344446299845976e+02 2.8487343926562755e+02 + 7 8.0909912152126484e+00 -7.8410849888970290e+01 -4.3214084684693944e+02 + 8 4.7943581253518161e+01 -2.1287511458762772e+01 1.4094503445043824e+02 + 9 1.1447552368334570e+01 1.2328709806695397e+01 5.0656476981938759e+01 + 10 1.3071496571895125e+02 -1.4589264560750766e+02 -4.4748155921681018e+01 + 11 -1.6551880130741767e-01 -4.1534332035668403e-01 -6.8284765271893910e-01 + 12 1.7721533633976141e+00 6.3456328808910523e-01 -8.2372301296999062e-01 + 13 5.6789360517170440e-01 -2.2634410322310763e-01 -9.7536744156455080e-03 + 14 -2.4337021462140446e-01 4.6659433737428486e-02 -6.1110664517858926e-01 + 15 -2.1936996885396808e-02 5.9238264018028652e-01 2.1493099542010694e-01 + 16 1.1121534968641315e+02 -7.8056927926703892e+01 -2.9249212971001145e+02 + 17 -1.1020604609471918e+02 7.6481296251709367e+01 2.9430701446464468e+02 + 18 -1.6570656172995385e-02 -2.7996961634495443e-02 2.6456324093123054e-02 + 19 7.4243314752471426e-04 6.3524860303507949e-04 1.8675576627109685e-04 + 20 -7.4243314752471426e-04 -6.3524860303507949e-04 -1.8675576627109685e-04 21 -1.1415041486189516e+01 -1.3016363071591645e+01 3.6007276733401099e+01 - 22 -1.7227422089792942e+01 -4.1746638094950628e+00 -2.7029162034499002e+01 - 23 2.8642463575982458e+01 1.7191026881086707e+01 -8.9781146989020968e+00 - 24 5.8150644491939154e+00 -3.3774314134628064e+01 1.7867788752379695e+01 - 25 -2.3666545027773044e+01 3.8106021846559952e+00 -1.9896269873584632e+01 - 26 1.7843812244577855e+01 2.9960339884741117e+01 2.0167430316952100e+00 - 27 8.2825859209946024e+00 -3.6194570066818969e+01 1.4492694351988913e+01 - 28 -2.8773892796642542e+01 1.2366374307374247e+01 -1.9468877181285176e+01 - 29 2.0497044211022661e+01 2.3831279505404666e+01 4.9748677441078746e+00 -run_vdwl: 164.176727313193 + 22 -1.7227422090167991e+01 -4.1746638096674396e+00 -2.7029162034658786e+01 + 23 2.8642463576357507e+01 1.7191026881259084e+01 -8.9781146987423170e+00 + 24 5.8150644495067958e+00 -3.3774314132751599e+01 1.7867788754173183e+01 + 25 -2.3666545028156815e+01 3.8106021844353424e+00 -1.9896269873795571e+01 + 26 1.7843812244961626e+01 2.9960339884961773e+01 2.0167430319061479e+00 + 27 8.2825859198612442e+00 -3.6194570067428131e+01 1.4492694352248694e+01 + 28 -2.8773892797077618e+01 1.2366374307246014e+01 -1.9468877181493664e+01 + 29 2.0497044211457737e+01 2.3831279505532898e+01 4.9748677443163629e+00 +run_vdwl: 164.176727343123 run_coul: 0 run_stress: ! |2- - 4.5696669905868288e+02 4.7904134871830234e+02 1.0582153129928076e+03 -2.0794233475912671e+02 -2.0206236780739086e+00 1.5948889983617320e+02 + 4.5696669908578690e+02 4.7904134876274537e+02 1.0582153130184231e+03 -2.0794233476691440e+02 -2.0206236712071677e+00 1.5948889982266843e+02 run_forces: ! |2 - 1 9.2483453892728740e+00 7.5945844239974676e+01 6.1367289784738311e+01 - 2 2.2732852134554197e+01 1.8737493288759875e+01 -2.6669600068587577e+01 - 3 -3.1964986246503269e+01 -9.3734416340601200e+01 -3.4671255449722295e+01 - 4 -5.5001585694065913e-01 1.5070776418957152e-01 -3.9275226164990551e-01 - 5 -1.7969915375876547e-01 -3.0362292678324765e-01 8.6793365916706400e-01 - 6 -1.9796806590003533e+02 2.2990162655369829e+02 2.7501790745035373e+02 - 7 7.9109888171861886e+00 -7.6524641847864288e+01 -4.2032627555539375e+02 - 8 4.5992175211879918e+01 -1.9873148355500923e+01 1.3922798515578887e+02 - 9 1.1403303962503362e+01 1.2231165268449960e+01 5.0409090529604853e+01 - 10 1.3047784096912977e+02 -1.4556513307073578e+02 -4.4756481385998420e+01 - 11 -1.6346238349194633e-01 -4.0922088697872150e-01 -6.7303941060221573e-01 - 12 1.7689668574627495e+00 6.3166692380469824e-01 -8.3233385524693426e-01 - 13 5.6480104331071312e-01 -2.2395151872256039e-01 -9.5790993973179691e-03 - 14 -2.4030540495346994e-01 4.5179188229734012e-02 -6.0304369153488313e-01 - 15 -2.3220111317111478e-02 5.9408611078423390e-01 2.1676726911830960e-01 - 16 1.0963039832302356e+02 -7.7096357855469549e+01 -2.8842624961188653e+02 - 17 -1.0862142117090467e+02 7.5521002117836630e+01 2.9024023117219969e+02 - 18 -1.6565212275867415e-02 -2.7990268691876326e-02 2.6458602067006932e-02 - 19 7.1473709241289744e-04 6.1248437925700357e-04 1.7889258733572757e-04 - 20 -7.1473709241289744e-04 -6.1248437925700357e-04 -1.7889258733572757e-04 - 21 -1.1536904971247665e+01 -1.3021625993962397e+01 3.6108894191673429e+01 - 22 -1.7333879764643559e+01 -4.2314763344327275e+00 -2.7103019136756011e+01 - 23 2.8870784735891224e+01 1.7253102328395126e+01 -9.0058750549174214e+00 - 24 6.1437425316795213e+00 -3.4297207023632204e+01 1.8296742414004438e+01 - 25 -2.4276461284621075e+01 3.8560435260643189e+00 -2.0415720860228767e+01 - 26 1.8125049871956215e+01 3.0437790982988908e+01 2.1072387594169975e+00 - 27 8.4078124309265192e+00 -3.6323119973255714e+01 1.4505938075037919e+01 - 28 -2.8937319168272772e+01 1.2421253477627801e+01 -1.9540501416079319e+01 - 29 2.0535244350189391e+01 2.3904950625827414e+01 5.0332497948309163e+00 + 1 9.2483453882111135e+00 7.5945844242532630e+01 6.1367289784064468e+01 + 2 2.2732852134599622e+01 1.8737493288836678e+01 -2.6669600068598680e+01 + 3 -3.1964986246546172e+01 -9.3734416340673434e+01 -3.4671255449709932e+01 + 4 -5.5001585741105219e-01 1.5070776450703974e-01 -3.9275226164162935e-01 + 5 -1.7969915441332354e-01 -3.0362292635308630e-01 8.6793365971015668e-01 + 6 -1.9796806590165264e+02 2.2990162655270728e+02 2.7501790745023669e+02 + 7 7.9109888151537930e+00 -7.6524641845739424e+01 -4.2032627555780203e+02 + 8 4.5992175210254615e+01 -1.9873148358014198e+01 1.3922798515443196e+02 + 9 1.1403303962567387e+01 1.2231165268357689e+01 5.0409090529541324e+01 + 10 1.3047784096840681e+02 -1.4556513307130629e+02 -4.4756481385556341e+01 + 11 -1.6346238363922402e-01 -4.0922088693014880e-01 -6.7303941090576869e-01 + 12 1.7689668582530251e+00 6.3166692115802814e-01 -8.3233385373913271e-01 + 13 5.6480104514758445e-01 -2.2395151881989347e-01 -9.5791000096411370e-03 + 14 -2.4030540489083232e-01 4.5179188324553629e-02 -6.0304369170302041e-01 + 15 -2.3220111102749796e-02 5.9408611123108124e-01 2.1676726905655996e-01 + 16 1.0963039832494319e+02 -7.7096357857185083e+01 -2.8842624960984045e+02 + 17 -1.0862142116718823e+02 7.5521002114629724e+01 2.9024023117422536e+02 + 18 -1.6565211729771653e-02 -2.7990264151000276e-02 2.6458599205916818e-02 + 19 7.1473670261989000e-04 6.1248404522910675e-04 1.7889248977386897e-04 + 20 -7.1473670261989000e-04 -6.1248404522910675e-04 -1.7889248977386897e-04 + 21 -1.1536904971247079e+01 -1.3021625993961788e+01 3.6108894191671638e+01 + 22 -1.7333879765020438e+01 -4.2314763346057394e+00 -2.7103019136915339e+01 + 23 2.8870784736267517e+01 1.7253102328567529e+01 -9.0058750547563005e+00 + 24 6.1437425319896413e+00 -3.4297207021755547e+01 1.8296742415795482e+01 + 25 -2.4276461285000558e+01 3.8560435258438814e+00 -2.0415720860437396e+01 + 26 1.8125049872338021e+01 3.0437790983209180e+01 2.1072387596271578e+00 + 27 8.4078124297937791e+00 -3.6323119973862774e+01 1.4505938075297303e+01 + 28 -2.8937319168706676e+01 1.2421253477499173e+01 -1.9540501416287395e+01 + 29 2.0535244350622666e+01 2.3904950625953887e+01 5.0332497950390769e+00 ... From 2022dc0aa9b0fee7c0150b6887bf6940c43fecf6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 18 Dec 2020 22:43:12 -0500 Subject: [PATCH 126/187] whitespace fixes --- doc/src/comm_modify.rst | 6 +- doc/src/neighbor.rst | 2 +- src/balance.cpp | 92 ++++++++++++------------ src/npair_half_size_multi_newton.cpp | 6 +- src/npair_half_size_multi_newton_tri.cpp | 2 +- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/doc/src/comm_modify.rst b/doc/src/comm_modify.rst index 1ccf77e995..56d3c08a57 100644 --- a/doc/src/comm_modify.rst +++ b/doc/src/comm_modify.rst @@ -84,15 +84,15 @@ information is available, then also a heuristic based on that bond length is computed. It is used as communication cutoff, if there is no pair style present and no *comm_modify cutoff* command used. Otherwise a warning is printed, if this bond based estimate is larger than the -communication cutoff used. +communication cutoff used. The *cutoff/multi* option is equivalent to *cutoff*\ , but applies to communication mode *multi* instead. Since in this case the communication cutoffs are determined per atom type, a type specifier is needed and cutoff for one or multiple types can be extended. Also ranges of types -using the usual asterisk notation can be given. For granular pairstyles, +using the usual asterisk notation can be given. For granular pairstyles, the default cutoff is set to the sum of the current maximum atomic radii -for each type. +for each type. These are simulation scenarios in which it may be useful or even necessary to set a ghost cutoff > neighbor cutoff: diff --git a/doc/src/neighbor.rst b/doc/src/neighbor.rst index 6671e7e1ac..878fa53f8c 100644 --- a/doc/src/neighbor.rst +++ b/doc/src/neighbor.rst @@ -49,7 +49,7 @@ sometimes be faster. Either style should give the same answers. The *multi* style is a modified binning algorithm that is useful for systems with a wide range of cutoff distances, e.g. due to different -size particles. For granular pairstyles, cutoffs are set to the +size particles. For granular pairstyles, cutoffs are set to the sum of the maximum atomic radii for each atom type. For the *bin* style, the bin size is set to 1/2 of the largest cutoff distance between any pair of atom types and a diff --git a/src/balance.cpp b/src/balance.cpp index c47412cc9e..6294e023b3 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -924,66 +924,66 @@ int Balance::shift() i = 0; while (i < np) { if (split[i+1] - split[i] < close) { - j = i+1; + j = i+1; - // I,J = set of consecutive splits that are collectively too close - // if can expand set and not become too close to splits I-1 or J+1, do it - // else add split I-1 or J+1 to set and try again - // delta = size of expanded split set that will satisy criterion + // I,J = set of consecutive splits that are collectively too close + // if can expand set and not become too close to splits I-1 or J+1, do it + // else add split I-1 or J+1 to set and try again + // delta = size of expanded split set that will satisy criterion - while (1) { - delta = (j-i) * close; - midpt = 0.5 * (split[i]+split[j]); - start = midpt - 0.5*delta; - stop = midpt + 0.5*delta; + while (1) { + delta = (j-i) * close; + midpt = 0.5 * (split[i]+split[j]); + start = midpt - 0.5*delta; + stop = midpt + 0.5*delta; - if (i > 0) lbound = split[i-1] + close; - else lbound = 0.0; - if (j < np) ubound = split[j+1] - close; - else ubound = 1.0; + if (i > 0) lbound = split[i-1] + close; + else lbound = 0.0; + if (j < np) ubound = split[j+1] - close; + else ubound = 1.0; - // start/stop are within bounds, reset the splits + // start/stop are within bounds, reset the splits - if (start >= lbound && stop <= ubound) break; + if (start >= lbound && stop <= ubound) break; - // try a shift to either bound, reset the splits if delta fits - // these tests change start/stop + // try a shift to either bound, reset the splits if delta fits + // these tests change start/stop - if (start < lbound) { - start = lbound; - stop = start + delta; - if (stop <= ubound) break; - } else if (stop > ubound) { - stop = ubound; - start = stop - delta; - if (start >= lbound) break; - } + if (start < lbound) { + start = lbound; + stop = start + delta; + if (stop <= ubound) break; + } else if (stop > ubound) { + stop = ubound; + start = stop - delta; + if (start >= lbound) break; + } - // delta does not fit between lbound and ubound - // exit if can't expand set, else expand set - // if can expand in either direction, - // pick new split closest to current midpt of set + // delta does not fit between lbound and ubound + // exit if can't expand set, else expand set + // if can expand in either direction, + // pick new split closest to current midpt of set - if (i == 0 && j == np) { - start = 0.0; stop = 1.0; - break; - } - if (i == 0) j++; - else if (j == np) i--; - else if (midpt-lbound < ubound-midpt) i--; - else j++; - } + if (i == 0 && j == np) { + start = 0.0; stop = 1.0; + break; + } + if (i == 0) j++; + else if (j == np) i--; + else if (midpt-lbound < ubound-midpt) i--; + else j++; + } - // reset all splits between I,J inclusive to be equi-spaced + // reset all splits between I,J inclusive to be equi-spaced - spacing = (stop-start) / (j-i); - for (m = i; m <= j; m++) - split[m] = start + (m-i)*spacing; + spacing = (stop-start) / (j-i); + for (m = i; m <= j; m++) + split[m] = start + (m-i)*spacing; if (j == np) split[np] = 1.0; - // continue testing beyond the J split + // continue testing beyond the J split - i = j+1; + i = j+1; } else i++; } diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp index 0d12924629..943965ab63 100644 --- a/src/npair_half_size_multi_newton.cpp +++ b/src/npair_half_size_multi_newton.cpp @@ -93,9 +93,9 @@ void NPairHalfSizeMultiNewton::build(NeighList *list) cutdistsq = (radsum+skin) * (radsum+skin); if (rsq <= cutdistsq) { - if (history && rsq < radsum*radsum) + if (history && rsq < radsum*radsum) neighptr[n++] = j ^ mask_history; - else + else neighptr[n++] = j; } } @@ -123,7 +123,7 @@ void NPairHalfSizeMultiNewton::build(NeighList *list) cutdistsq = (radsum+skin) * (radsum+skin); if (rsq <= cutdistsq) { - if (history && rsq < radsum*radsum) + if (history && rsq < radsum*radsum) neighptr[n++] = j ^ mask_history; else neighptr[n++] = j; diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index adc4c080ec..e59a3f088a 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -105,7 +105,7 @@ void NPairHalfSizeMultiNewtonTri::build(NeighList *list) cutdistsq = (radsum+skin) * (radsum+skin); if (rsq <= cutdistsq) { - if (history && rsq < radsum*radsum) + if (history && rsq < radsum*radsum) neighptr[n++] = j ^ mask_history; else neighptr[n++] = j; From 151110f07f59ebba7b4b75470797e09a9680b22c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 18 Dec 2020 22:55:15 -0500 Subject: [PATCH 127/187] refactor constant vs define in edip pair styles --- src/USER-MISC/pair_edip.cpp | 2 +- src/USER-MISC/pair_edip_multi.cpp | 5 ++--- src/USER-MISC/pair_edip_multi.h | 26 +++++++++++--------------- src/USER-OMP/pair_edip_omp.cpp | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index b29f499de8..12390ba69d 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -46,7 +46,7 @@ using namespace LAMMPS_NS; // max number of interaction per atom for f(Z) environment potential -#define leadDimInteractionList 64 +static constexpr int leadDimInteractionList = 64; /* ---------------------------------------------------------------------- */ diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 811f80abfc..9d36db7041 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -32,13 +32,11 @@ #include "error.h" #include "citeme.h" - using namespace LAMMPS_NS; #define MAXLINE 1024 #define DELTA 4 - static const char cite_pair_edip[] = "@article{cjiang2012\n" " author = {Jian, Chao and Morgan, Dane, and Szlufarska, Izabella},\n" @@ -56,7 +54,9 @@ static const char cite_pair_edip[] = " year = {2010},\n" "}\n\n"; +// max number of interaction per atom for f(Z) environment potential +static constexpr int leadDimInteractionList = 64; /* ---------------------------------------------------------------------- */ @@ -94,7 +94,6 @@ PairEDIPMulti::~PairEDIPMulti() memory->destroy(cutsq); delete [] map; -//XXX deallocateGrids(); deallocatePreLoops(); } } diff --git a/src/USER-MISC/pair_edip_multi.h b/src/USER-MISC/pair_edip_multi.h index 26433a66fa..5120ece5d2 100644 --- a/src/USER-MISC/pair_edip_multi.h +++ b/src/USER-MISC/pair_edip_multi.h @@ -36,17 +36,17 @@ class PairEDIPMulti : public Pair { protected: struct Param { - double A, B;//coefficients for pair interaction I-J - double cutoffA;//cut-off distance for pair interaction I-J - double cutoffC;//lower cut-off distance for calculating Z_I - double alpha;//coefficient for calculating Z_I - double beta;//attractive term for pair I-J - double sigma;//cut-off coefficient for pair I-J - double rho;//pair I-J - double gamma;//coefficient for three-body interaction I-J-K - double eta, lambda;//coefficients for function h(l,Z) - double mu, Q0;//coefficients for function Q(Z) - double u1, u2, u3, u4;//coefficients for function tau(Z) + double A, B; // coefficients for pair interaction I-J + double cutoffA; // cut-off distance for pair interaction I-J + double cutoffC; // lower cut-off distance for calculating Z_I + double alpha; // coefficient for calculating Z_I + double beta; // attractive term for pair I-J + double sigma; // cut-off coefficient for pair I-J + double rho; // pair I-J + double gamma; // coefficient for three-body interaction I-J-K + double eta, lambda; // coefficients for function h(l,Z) + double mu, Q0; // coefficients for function Q(Z) + double u1, u2, u3, u4; // coefficients for function tau(Z) double cutsq; int ielement,jelement,kelement; }; @@ -62,10 +62,6 @@ class PairEDIPMulti : public Pair { int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction - // max number of interaction per atom for f(Z) environment potential - - static const int leadDimInteractionList = 64; - void allocate(); void allocatePreLoops(void); void deallocatePreLoops(void); diff --git a/src/USER-OMP/pair_edip_omp.cpp b/src/USER-OMP/pair_edip_omp.cpp index 2eb8384113..106d038743 100644 --- a/src/USER-OMP/pair_edip_omp.cpp +++ b/src/USER-OMP/pair_edip_omp.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; // max number of interaction per atom for f(Z) environment potential -#define leadDimInteractionList 64 +static constexpr int leadDimInteractionList = 64; /* ---------------------------------------------------------------------- */ From a13f70790a279a629bb2082aa8874b6854ee8152 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 18 Dec 2020 23:02:28 -0500 Subject: [PATCH 128/187] spelling --- doc/src/comm_modify.rst | 2 +- doc/src/neighbor.rst | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/src/comm_modify.rst b/doc/src/comm_modify.rst index 56d3c08a57..864c544fed 100644 --- a/doc/src/comm_modify.rst +++ b/doc/src/comm_modify.rst @@ -90,7 +90,7 @@ The *cutoff/multi* option is equivalent to *cutoff*\ , but applies to communication mode *multi* instead. Since in this case the communication cutoffs are determined per atom type, a type specifier is needed and cutoff for one or multiple types can be extended. Also ranges of types -using the usual asterisk notation can be given. For granular pairstyles, +using the usual asterisk notation can be given. For granular pair styles, the default cutoff is set to the sum of the current maximum atomic radii for each type. diff --git a/doc/src/neighbor.rst b/doc/src/neighbor.rst index 878fa53f8c..98ee0d0b6a 100644 --- a/doc/src/neighbor.rst +++ b/doc/src/neighbor.rst @@ -49,7 +49,7 @@ sometimes be faster. Either style should give the same answers. The *multi* style is a modified binning algorithm that is useful for systems with a wide range of cutoff distances, e.g. due to different -size particles. For granular pairstyles, cutoffs are set to the +size particles. For granular pair styles, cutoffs are set to the sum of the maximum atomic radii for each atom type. For the *bin* style, the bin size is set to 1/2 of the largest cutoff distance between any pair of atom types and a @@ -59,8 +59,10 @@ other type pairs have a much shorter cutoff. For style *multi* the bin size is set to 1/2 of the shortest cutoff distance and multiple sets of bins are defined to search over for different atom types. This imposes some extra setup overhead, but the searches themselves -may be much faster for the short-cutoff cases. See the :doc:`comm_modify mode multi ` command for a communication option -that may also be beneficial for simulations of this kind. +may be much faster for the short-cutoff cases. +See the :doc:`comm_modify mode multi ` command for a +communication option that may also be beneficial for simulations of +this kind. The :doc:`neigh_modify ` command has additional options that control how often neighbor lists are built and which pairs are From 24e2166357ed8bbcb445840d434aac9b804374b7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 20 Dec 2020 15:02:01 -0500 Subject: [PATCH 129/187] add missing references --- doc/src/Commands_fix.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index d1bc20c9ca..26dcc1101c 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -221,6 +221,8 @@ OPT. * :doc:`temp/rescale ` * :doc:`temp/rescale/eff ` * :doc:`tfmc ` + * :doc:`tgnpt/drude ` + * :doc:`tgnvt/drude ` * :doc:`thermal/conductivity ` * :doc:`ti/spring ` * :doc:`tmd ` From 800ff0f1c214917580a490efcc8f90cf7869db75 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 20 Dec 2020 15:02:59 -0500 Subject: [PATCH 130/187] update spelling/grammar and false positives --- doc/src/fix_tgnh_drude.rst | 15 +++++++++------ doc/utils/sphinx-config/false_positives.txt | 7 ++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst index 9afb35c8f6..92781cd9e8 100644 --- a/doc/src/fix_tgnh_drude.rst +++ b/doc/src/fix_tgnh_drude.rst @@ -65,10 +65,13 @@ Examples Description """"""""""" -These commands are variants of the Nose-Hoover fix styles :doc:`fix nvt ` and :doc:`fix npt ` for thermalized Drude polarizable models. -They apply temperature-grouped Nose-Hoover thermostat (TGNH) proposed by :ref:`(Son) `. -When there are fast vibrational modes with frequencies close to Drude oscillators (e.g. double bonds or out-of-plane torsions), -this thermostat can provide better kinetic energy equipartition. +These commands are variants of the Nose-Hoover fix styles :doc:`fix nvt +` and :doc:`fix npt ` for thermalized Drude polarizable +models. They apply temperature-grouped Nose-Hoover thermostat (TGNH) +proposed by :ref:`(Son) `. When there are fast vibrational +modes with frequencies close to Drude oscillators (e.g. double bonds or +out-of-plane torsions), this thermostat can provide better kinetic +energy equipartitioning. The difference between TGNH and the original Nose-Hoover thermostat is that, TGNH separates the kinetic energy of the group into three contributions: @@ -108,8 +111,8 @@ Here :math:`N_\mathrm{mol}` and :math:`N_\mathrm{mol,sys}` are the numbers of mo not. You must therefore use the :doc:`fix drude ` command to specify the Drude status of each atom type. - Because that TGNH thermostat thermalizes the molecular COM motion, - all atoms belong to the same molecule must be in the same group. + Because the TGNH thermostat thermostats the molecular COM motion, + all atoms belonging to the same molecule must be in the same group. That is, these fixes can not be applied to a subset of a molecule. For this fix to act correctly, ghost atoms need to know their velocity. diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 0563ac1499..de2065c1e3 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -533,6 +533,7 @@ cuda Cuda CUDA CuH +Cui cuFFT Cummins Curk @@ -869,6 +870,7 @@ equilibrating equilibration Equilibria equilization +equipartitioning Ercolessi Erdmann eradius @@ -3071,9 +3073,11 @@ tex tfac tfmc tfMC -th +tgnpt +tgnvt Thakkar Thaokar +th thb thei Theodorou @@ -3479,6 +3483,7 @@ Yc ycm Yeh yellowgreen +Yethiraj yflag yhi yi From 7c7f13faf54d0d742774b92a8afb4344aa0b0de0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 21 Dec 2020 10:21:53 -0500 Subject: [PATCH 131/187] step version strings for the next LAMMPS release --- doc/lammps.1 | 2 +- src/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lammps.1 b/doc/lammps.1 index 5fc4795ba7..f52bebab8e 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "30 November 2020" "2020-10-29" +.TH LAMMPS "22 December 2020" "2020-12-22" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/src/version.h b/src/version.h index 379d627653..33aa08f8df 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "30 Nov 2020" +#define LAMMPS_VERSION "22 Dec 2020" From e7fa0a6bac75824361c9b13d9aecc8667a41fc43 Mon Sep 17 00:00:00 2001 From: Nicholas Lubbers Date: Mon, 21 Dec 2020 11:51:10 -0700 Subject: [PATCH 132/187] Changes to MLIAP python - update lammps python package to use setuptools - refactor MLIAP classes into lammps python package lammps.mliap package - change TorchWrapper to use dtype and device as arguments - turn activation of mliappy into functions (was a class) - add a check to see if python interpreter is compatible with python lib calls internal to lammps mliap_model_python_couple.pyx: - load models ending in '.pt' or '.pth' with pytorch rather than pickle --- doc/src/pair_mliap.rst | 10 ++++ examples/mliap/Ta06A.mliap.pytorch | 2 +- examples/mliap/convert_mliap_Ta06A.py | 21 +++----- examples/mliap/mliap_pytorch_Ta06A.py | 28 +++++----- python/install.py | 37 ++++++------- python/lammps/core.py | 39 -------------- python/lammps/mliap/__init__.py | 13 +++++ python/lammps/mliap/loader.py | 52 +++++++++++++++++++ .../lammps/mliap/pytorch.py | 24 +++++---- python/setup.py | 4 +- src/MLIAP/mliap_model_python_couple.pyx | 10 ++-- 11 files changed, 135 insertions(+), 105 deletions(-) create mode 100644 python/lammps/mliap/__init__.py create mode 100644 python/lammps/mliap/loader.py rename src/MLIAP/mliappy_pytorch.py => python/lammps/mliap/pytorch.py (80%) diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index 9dd8c5c6b1..af0cc9e855 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -84,6 +84,16 @@ for the :doc:`pair_style snap ` coefficient file. Specifically, the line containing the element weight and radius is omitted, since these are handled by the *descriptor*. +Notes on mliappy models: +When the *model* keyword is *mliappy*, the filename should end in '.pt', +'.pth' for pytorch models, or be a pickle file. To load a model from +memory (i.e. an existing python object), specify the filename as +"LATER", and then call `lammps.mliap.load_model(model)` from python +before using the pair style. When using lammps via the library mode, you will need to call +`lammps.mliappy.activate_mliappy(lmp)` on the active lammps object +before the pair style is defined. This call locates and loads the mliap-specific +python module that is built into lammps. + The *descriptor* keyword is followed by a descriptor style, and additional arguments. Currently the only descriptor style is *sna*, indicating the bispectrum component descriptors used by the Spectral Neighbor Analysis Potential (SNAP) potentials of diff --git a/examples/mliap/Ta06A.mliap.pytorch b/examples/mliap/Ta06A.mliap.pytorch index c6c6bc653d..5489688a82 100644 --- a/examples/mliap/Ta06A.mliap.pytorch +++ b/examples/mliap/Ta06A.mliap.pytorch @@ -11,7 +11,7 @@ variable zblz equal 73 pair_style hybrid/overlay & zbl ${zblcutinner} ${zblcutouter} & -mliap model mliappy Ta06A.mliap.pytorch.model.pkl & +mliap model mliappy Ta06A.mliap.pytorch.model.pt & descriptor sna Ta06A.mliap.descriptor pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff * * mliap Ta diff --git a/examples/mliap/convert_mliap_Ta06A.py b/examples/mliap/convert_mliap_Ta06A.py index ba95678c9e..8a7466743f 100644 --- a/examples/mliap/convert_mliap_Ta06A.py +++ b/examples/mliap/convert_mliap_Ta06A.py @@ -1,13 +1,9 @@ import sys import numpy as np import torch -import pickle -import os -import shutil -shutil.copyfile('../../src/MLIAP/mliappy_pytorch.py','./mliappy_pytorch.py') - -import mliappy_pytorch +# torch.nn.modules useful for defining a MLIAPPY model. +from lammps.mliap.pytorch import TorchWrapper, IgnoreElems # Read coefficients coeffs = np.genfromtxt("Ta06A.mliap.model",skip_header=6) @@ -21,13 +17,10 @@ with torch.autograd.no_grad(): lin.weight.set_(torch.from_numpy(weights).unsqueeze(0)) lin.bias.set_(torch.as_tensor(bias,dtype=torch.float64).unsqueeze(0)) -# Wrap the pytorch model for usage with mliappy energy model -model = mliappy_pytorch.IgnoreElems(lin) +# Wrap the pytorch model for usage with mliappy coupling. +model = IgnoreElems(lin) # The linear module does not use the types. n_descriptors = lin.weight.shape[1] -n_params = mliappy_pytorch.calc_n_params(model) -n_types = 1 -linked_model = mliappy_pytorch.TorchWrapper64(model,n_descriptors=n_descriptors,n_elements=n_types) +n_elements = 1 +linked_model = TorchWrapper(model,n_descriptors=n_descriptors,n_elements=n_elements) -# Save the result. -with open("Ta06A.mliap.pytorch.model.pkl",'wb') as pfile: - pickle.dump(linked_model,pfile) +torch.save(linked_model,"Ta06A.mliap.pytorch.model.pt") diff --git a/examples/mliap/mliap_pytorch_Ta06A.py b/examples/mliap/mliap_pytorch_Ta06A.py index 71c89f112e..c4387e21a3 100644 --- a/examples/mliap/mliap_pytorch_Ta06A.py +++ b/examples/mliap/mliap_pytorch_Ta06A.py @@ -81,26 +81,24 @@ import lammps lmp = lammps.lammps(cmdargs=['-echo','both']) -# this commmand must be run before the MLIAP object is declared in lammps. +# Before defining the pair style, one must do the following: +import lammps.mliap +lammps.mliap.activate_mliappy(lmp) +# Otherwise, when running lammps in library mode, +# you will get an error: +# "ERROR: Loading MLIAPPY coupling module failure." -lmp.mliappy.activate() - -# setup the simulation and declare an empty model +# Setup the simulation and declare an empty model # by specifying model filename as "LATER" - lmp.commands_string(before_loading) -# define the PyTorch model by loading a pkl file. -# this could also be done in other ways. +# Define the model however you like. In this example +# we load it from disk: +import torch +model = torch.load('Ta06A.mliap.pytorch.model.pt') -import pickle -with open('Ta06A.mliap.pytorch.model.pkl','rb') as pfile: - model = pickle.load(pfile) +# Connect the PyTorch model to the mliap pair style. +lammps.mliap.load_model(model) -# connect the PyTorch model to the mliap pair style - -lmp.mliappy.load_model(model) - # run the simulation with the mliap pair style - lmp.commands_string(after_loading) diff --git a/python/install.py b/python/install.py index a6b69c1ee6..8c632c096e 100644 --- a/python/install.py +++ b/python/install.py @@ -95,22 +95,26 @@ print("Installing LAMMPS Python package version %s into site-packages folder" % # we need to switch to the folder of the python package os.chdir(os.path.dirname(args.package)) -from distutils.core import setup +from setuptools import setup, find_packages from distutils.sysconfig import get_python_lib import site -tryuser=False +#Arguments common to global or user install -- everything but data_files +setup_kwargs= dict(name="lammps", + version=verstr, + author="Steve Plimpton", + author_email="sjplimp@sandia.gov", + url="https://lammps.sandia.gov", + description="LAMMPS Molecular Dynamics Python package", + license="GPL", + packages=find_packages(), + ) + +tryuser=False try: sys.argv = ["setup.py","install"] # as if had run "python setup.py install" - setup(name = "lammps", - version = verstr, - author = "Steve Plimpton", - author_email = "sjplimp@sandia.gov", - url = "https://lammps.sandia.gov", - description = "LAMMPS Molecular Dynamics Python package", - license = "GPL", - packages=['lammps'], - data_files = [(os.path.join(get_python_lib(), 'lammps'), [args.lib])]) + setup_kwargs['data_files']=[(os.path.join(get_python_lib(), 'lammps'), [args.lib])] + setup(**setup_kwargs) except: tryuser=True print ("Installation into global site-packages folder failed.\nTrying user folder %s now." % site.USER_SITE) @@ -118,14 +122,7 @@ except: if tryuser: try: sys.argv = ["setup.py","install","--user"] # as if had run "python setup.py install --user" - setup(name = "lammps", - version = verstr, - author = "Steve Plimpton", - author_email = "sjplimp@sandia.gov", - url = "https://lammps.sandia.gov", - description = "LAMMPS Molecular Dynamics Python package", - license = "GPL", - packages=['lammps'], - data_files = [(os.path.join(site.USER_SITE, 'lammps'), [args.lib])]) + setup_kwargs['data_files']=[(os.path.join(site.USER_SITE, 'lammps'), [args.lib])] + setup(**setup_kwargs) except: print("Installation into user site package folder failed.") diff --git a/python/lammps/core.py b/python/lammps/core.py index e30f036e1b..a75a02e358 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -379,8 +379,6 @@ class lammps(object): self.lib.lammps_set_fix_external_callback.argtypes = [c_void_p, c_char_p, self.FIX_EXTERNAL_CALLBACK_FUNC, py_object] self.lib.lammps_set_fix_external_callback.restype = None - self.mliappy = MLIAPPY(self) - # ------------------------------------------------------------------------- # shut-down LAMMPS instance @@ -1673,41 +1671,4 @@ class lammps(object): idx = self.lib.lammps_find_compute_neighlist(self.lmp, computeid, request) return idx -class MLIAPPY(): - def __init__(self,lammps): - self._module = None - self.lammps = lammps - @property - def module(self): - if self._module: - return self._module - - try: - # Begin Importlib magic to find the embedded python module - # This is needed because the filename for liblammps does not - # match the spec for normal python modules, wherein - # file names match with PyInit function names. - # Also, python normally doesn't look for extensions besides '.so' - # We fix both of these problems by providing an explict - # path to the extension module 'mliap_model_python_couple' in - import sys - import importlib.util - import importlib.machinery - - path = self.lammps.lib._name - loader = importlib.machinery.ExtensionFileLoader('mliap_model_python_couple',path) - spec = importlib.util.spec_from_loader('mliap_model_python_couple',loader) - module = importlib.util.module_from_spec(spec) - sys.modules['mliap_model_python_couple']=module - spec.loader.exec_module(module) - self._module = module - # End Importlib magic to find the embedded python module - except: - raise ImportError("Could not load MLIAPPY coupling module") - - def activate(self): - self.module - - def load_model(self,model): - self.module.load_from_python(model) diff --git a/python/lammps/mliap/__init__.py b/python/lammps/mliap/__init__.py new file mode 100644 index 0000000000..06c127055e --- /dev/null +++ b/python/lammps/mliap/__init__.py @@ -0,0 +1,13 @@ + +# Check compatiblity of this build with the python shared library. +# If this fails, lammps will segfault because its library will +# try to improperly start up a new interpreter. +import sysconfig +import ctypes +library = sysconfig.get_config_vars('INSTSONAME')[0] +pylib = ctypes.CDLL(library) +if not pylib.Py_IsInitialized(): + raise RuntimeError("This interpreter is not compatible with python-based mliap for LAMMPS.") +del sysconfig, ctypes, library, pylib + +from .loader import load_model, activate_mliappy \ No newline at end of file diff --git a/python/lammps/mliap/loader.py b/python/lammps/mliap/loader.py new file mode 100644 index 0000000000..b875d8d834 --- /dev/null +++ b/python/lammps/mliap/loader.py @@ -0,0 +1,52 @@ +# ---------------------------------------------------------------------- +# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator +# http://lammps.sandia.gov, Sandia National Laboratories +# Steve Plimpton, sjplimp@sandia.gov +# +# Copyright (2003) Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains +# certain rights in this software. This software is distributed under +# the GNU General Public License. +# +# See the README file in the top-level LAMMPS directory. +# ------------------------------------------------------------------------- + +# ---------------------------------------------------------------------- +# Contributing author: Nicholas Lubbers (LANL) +# ------------------------------------------------------------------------- + + +import sys +import importlib.util +import importlib.machinery + +def activate_mliappy(lmp): + try: + # Begin Importlib magic to find the embedded python module + # This is needed because the filename for liblammps does not + # match the spec for normal python modules, wherein + # file names match with PyInit function names. + # Also, python normally doesn't look for extensions besides '.so' + # We fix both of these problems by providing an explict + # path to the extension module 'mliap_model_python_couple' in + + path = lmp.lib._name + loader = importlib.machinery.ExtensionFileLoader('mliap_model_python_couple', path) + spec = importlib.util.spec_from_loader('mliap_model_python_couple', loader) + module = importlib.util.module_from_spec(spec) + sys.modules['mliap_model_python_couple'] = module + spec.loader.exec_module(module) + # End Importlib magic to find the embedded python module + + except Exception as ee: + raise ImportError("Could not load MLIAP python coupling module.") from ee + +def load_model(model): + try: + import mliap_model_python_couple + except ImportError as ie: + raise ImportError("MLIAP python module must be activated before loading\n" + "the pair style. Call lammps.mliap.activate_mliappy(lmp)." + ) from ie + mliap_model_python_couple.load_from_python(model) + diff --git a/src/MLIAP/mliappy_pytorch.py b/python/lammps/mliap/pytorch.py similarity index 80% rename from src/MLIAP/mliappy_pytorch.py rename to python/lammps/mliap/pytorch.py index ff80720ffa..aa2cf1c97c 100644 --- a/src/MLIAP/mliappy_pytorch.py +++ b/python/lammps/mliap/pytorch.py @@ -22,20 +22,28 @@ def calc_n_params(model): return sum(p.nelement() for p in model.parameters()) class TorchWrapper(torch.nn.Module): - def __init__(self, model,n_descriptors,n_elements,n_params=None): + def __init__(self, model,n_descriptors,n_elements,n_params=None,device=None,dtype=torch.float64): super().__init__() + self.model = model - self.model.to(self.dtype) + self.device = device + self.dtype = dtype + + # Put model on device and convert to dtype + self.to(self.dtype) + self.to(self.device) + if n_params is None: n_params = calc_n_params(model) + self.n_params = n_params self.n_descriptors = n_descriptors self.n_elements = n_elements - def __call__(self, elems, bispectrum, beta, energy): + def forward(self, elems, bispectrum, beta, energy): - bispectrum = torch.from_numpy(bispectrum).to(self.dtype).requires_grad_(True) - elems = torch.from_numpy(elems).to(torch.long) - 1 + bispectrum = torch.from_numpy(bispectrum).to(dtype=self.dtype, device=self.device).requires_grad_(True) + elems = torch.from_numpy(elems).to(dtype=torch.long, device=self.device) - 1 with torch.autograd.enable_grad(): @@ -48,12 +56,6 @@ class TorchWrapper(torch.nn.Module): beta[:] = beta_nn.detach().cpu().numpy().astype(np.float64) energy[:] = energy_nn.detach().cpu().numpy().astype(np.float64) -class TorchWrapper32(TorchWrapper): - dtype = torch.float32 - -class TorchWrapper64(TorchWrapper): - dtype = torch.float64 - class IgnoreElems(torch.nn.Module): def __init__(self,subnet): super().__init__() diff --git a/python/setup.py b/python/setup.py index 9be04138d5..50e215cb09 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,6 +1,6 @@ # this only installs the LAMMPS python package # it assumes the LAMMPS shared library is already installed -from distutils.core import setup +from setuptools import setup, find_packages import os LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -22,5 +22,5 @@ setup( url = "https://lammps.sandia.gov", description = "LAMMPS Molecular Dynamics Python package", license = "GPL", - packages=["lammps"] + packages=find_packages(), ) diff --git a/src/MLIAP/mliap_model_python_couple.pyx b/src/MLIAP/mliap_model_python_couple.pyx index 49bdd47412..1f04964ef6 100644 --- a/src/MLIAP/mliap_model_python_couple.pyx +++ b/src/MLIAP/mliap_model_python_couple.pyx @@ -46,7 +46,7 @@ cdef object c_id(MLIAPModelPython * c_model): """ return int( c_model) -cdef object retrieve(MLIAPModelPython * c_model): +cdef object retrieve(MLIAPModelPython * c_model) with gil: try: model = LOADED_MODELS[c_id(c_model)] except KeyError as ke: @@ -61,8 +61,12 @@ cdef public int MLIAPPY_load_model(MLIAPModelPython * c_model, char* fname) with model = None returnval = 0 else: - with open(str_fname,'rb') as pfile: - model = pickle.load(pfile) + if str_fname.endswith(".pt") or str_fname.endswith('.pth'): + import torch + model = torch.load(str_fname) + else: + with open(str_fname,'rb') as pfile: + model = pickle.load(pfile) returnval = 1 LOADED_MODELS[c_id(c_model)] = model return returnval From a1c5ed93ab9d0659edad5d34ab61b0e4cb2f9668 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 21 Dec 2020 17:13:32 -0700 Subject: [PATCH 133/187] new Developer_notes doc page --- doc/src/Developer.rst | 1 + doc/src/Developer_notes.rst | 101 ++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 doc/src/Developer_notes.rst diff --git a/doc/src/Developer.rst b/doc/src/Developer.rst index a895369a28..9eea57537f 100644 --- a/doc/src/Developer.rst +++ b/doc/src/Developer.rst @@ -16,3 +16,4 @@ of time and requests from the LAMMPS user community. Developer_unittest Classes Developer_utils + Developer_notes diff --git a/doc/src/Developer_notes.rst b/doc/src/Developer_notes.rst new file mode 100644 index 0000000000..c1a808f98b --- /dev/null +++ b/doc/src/Developer_notes.rst @@ -0,0 +1,101 @@ +Notes for Developers and Code Maintainers +----------------------------------------- + +This section documents how a few large sections of code with LAMMPS +work at a conceptual level. Comments on code in source files +typically document what a variable stores, what a small section of +code does, or what a function does or its input/outputs. The topics +on this page are intended to document code at a higher level. + +KSpace PPPM FFT grids +^^^^^^^^^^^^^^^^^^^^^ + +The various :doc:`KSpace PPPM ` styles in LAMMPS use +FFTs to solve Poisson's equation. This subsection describes: + +* how FFT grids are defined +* how they are decomposed across processors +* how they are indexed by each processor +* how particle charge and electric field values are mapped to/from + the grid + +An FFT grid cell is a 3d volume; grid points are corners of a grid +cell and the code stores values assigned to grid points in vectors or +3d arrays. A global 3d FFT grid has points indexed 0 to N-1 inclusive +in each dimension. + +Each processor owns two subsets of the grid, each subset is +brick-shaped. Depending on how it is used, these subsets are +allocated as a 1d vector or 3d array. Either way, the ordering of +values within contiguous memory x fastest, then y, z slowest. + +For the ``3d decomposition`` of the grid, the global grid is +partitioned into bricks that correspond to the subdomains of the +simulation box that each processor owns. Often, this is a regular 3d +array (Px by Py by Pz) of bricks, where P = number of processors = +Px * Py * Pz. More generally it can be a tiled decomposition, where +each processor owns a brick and the union of all the bricks is the +global grid. Tiled decompositions are produced by load balancing with +the RCB algorithm; see the :doc:`balance rcb ` command. + +For the ``FFT decompostion`` of the grid, each processor owns a brick +that spans the entire x dimension of the grid while the y and z +dimensions are partitioned as a regular 2d array (P1 by P2), where P = +P1 * P2. + +The following indices store the inclusive bounds of the brick a +processor owns, within the global grid: + +* nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in = 3d decomposition brick +* nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft = FFT decomposition brick +* nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out = 3d + decomposition brick + ghost cells + +The ``in`` and ``fft`` indices are from 0 to N-1 inclusive in each +dimension, where N is the grid size. + +The ``out`` indices index an array which stores the ``in`` subset of +the grid plus ghost cells that surround it. These indices can thus be +< 0 or >= N. + +The number of ghost cells a processor owns in each of the 6 directions +is a function of: + +* neighbor skin distance (since atoms can move outside a proc subdomain) +* qdist = offset or charge from atom due to TIP4P fictitious charge +* order = mapping stencil size +* shift = factor used when order is an even number (see below) + +Here is an explanation of how the PPPM variables order, nlower/nupper, +shift, and OFFSET work. + +These are the relevant variables that determine how atom charge is +mapped to grid points and how field values are mapped from grid points +to atoms: + +* order = # of nearby grid points in each dim that atom charge/field are mapped to/from +* nlower,nupper = extent of stencil around the grid point an atom is assigned to +* OFFSET = large integer added/subtracted when mapping to avoid + int(-0.75) = 0 when -1 is the desired result + +The particle_map() method assigns each atom to a grid point. + +If order is even, say 4: + +* atom is assigned to grid point to its left (in each dim) +* shift = OFFSET +* nlower = -1, nupper = 2, which are offsets from assigned grid point +* window of mapping grid pts is thus 2 grid points to left of atom, 2 to right + +If order is odd, say 5: + +* atom is assigned to left/right grid pt it is closest to (in each dim) +* shift = OFFSET + 0.5 +* nlower = 2, nupper = 2 +* if point is in left half of cell, then + window of affected grid pts is 3 grid points to left of atom, 2 to right +* if point is in right half of cell, then + window of affected grid pts is 2 grid points to left of atom, 3 to right + +These settings apply to each dimension, so that if order = 5, an +atom's charge is mapped to 125 grid points that surround the atom. From 75eadabaf08746e958518fc0b395caf0b7d56bd0 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 22 Dec 2020 08:02:28 -0700 Subject: [PATCH 134/187] change ordering of sub sections --- doc/src/Developer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Developer.rst b/doc/src/Developer.rst index 9eea57537f..3a0c03b7ea 100644 --- a/doc/src/Developer.rst +++ b/doc/src/Developer.rst @@ -13,7 +13,7 @@ of time and requests from the LAMMPS user community. Developer_org Developer_flow Developer_write + Developer_notes Developer_unittest Classes Developer_utils - Developer_notes From ce24d70cccb936ffdc2a39b25bf133e23bd6d740 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 22 Dec 2020 08:15:51 -0700 Subject: [PATCH 135/187] Add comments about smaller DELTA in atom_vec_kokkos.cpp --- src/KOKKOS/atom_vec_kokkos.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 86f15b0b40..2cb70a8c87 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -19,7 +19,7 @@ #include "error.h" #include "domain.h" -#define DELTA 10 +#define DELTA 10 // much smaller than atom_vec.cpp using namespace LAMMPS_NS; @@ -38,6 +38,7 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- roundup N so it is a multiple of DELTA error if N exceeds 32-bit int, since will be used as arg to grow() + overload needed because Kokkos uses a smaller DELTA than in atom_vec.cpp ------------------------------------------------------------------------- */ bigint AtomVecKokkos::roundup(bigint n) From d07cf22ac5d0899469b6eeb4121065e7f415006a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 22 Dec 2020 10:13:53 -0500 Subject: [PATCH 136/187] use parsed-literal sections to reduce spellchecking variable names --- doc/src/Developer_notes.rst | 66 ++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/doc/src/Developer_notes.rst b/doc/src/Developer_notes.rst index c1a808f98b..87ef97ea7b 100644 --- a/doc/src/Developer_notes.rst +++ b/doc/src/Developer_notes.rst @@ -30,7 +30,7 @@ allocated as a 1d vector or 3d array. Either way, the ordering of values within contiguous memory x fastest, then y, z slowest. For the ``3d decomposition`` of the grid, the global grid is -partitioned into bricks that correspond to the subdomains of the +partitioned into bricks that correspond to the sub-domains of the simulation box that each processor owns. Often, this is a regular 3d array (Px by Py by Pz) of bricks, where P = number of processors = Px * Py * Pz. More generally it can be a tiled decomposition, where @@ -46,10 +46,11 @@ P1 * P2. The following indices store the inclusive bounds of the brick a processor owns, within the global grid: -* nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in = 3d decomposition brick -* nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft = FFT decomposition brick -* nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out = 3d - decomposition brick + ghost cells +.. parsed-literal:: + + nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in = 3d decomposition brick + nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft = FFT decomposition brick + nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out = 3d decomposition brick + ghost cells The ``in`` and ``fft`` indices are from 0 to N-1 inclusive in each dimension, where N is the grid size. @@ -61,41 +62,44 @@ the grid plus ghost cells that surround it. These indices can thus be The number of ghost cells a processor owns in each of the 6 directions is a function of: -* neighbor skin distance (since atoms can move outside a proc subdomain) -* qdist = offset or charge from atom due to TIP4P fictitious charge -* order = mapping stencil size -* shift = factor used when order is an even number (see below) +.. parsed-literal:: -Here is an explanation of how the PPPM variables order, nlower/nupper, -shift, and OFFSET work. + neighbor skin distance (since atoms can move outside a proc subdomain) + qdist = offset or charge from atom due to TIP4P fictitious charge + order = mapping stencil size + shift = factor used when order is an even number (see below) -These are the relevant variables that determine how atom charge is -mapped to grid points and how field values are mapped from grid points -to atoms: +Here is an explanation of how the PPPM variables ``order``, +``nlower`` / ``nupper``, ``shift``, and ``OFFSET`` work. They are the +relevant variables that determine how atom charge is mapped to grid +points and how field values are mapped from grid points to atoms: + +.. parsed-literal:: + + order = # of nearby grid points in each dim that atom charge/field are mapped to/from + nlower,nupper = extent of stencil around the grid point an atom is assigned to + OFFSET = large integer added/subtracted when mapping to avoid int(-0.75) = 0 when -1 is the desired result -* order = # of nearby grid points in each dim that atom charge/field are mapped to/from -* nlower,nupper = extent of stencil around the grid point an atom is assigned to -* OFFSET = large integer added/subtracted when mapping to avoid - int(-0.75) = 0 when -1 is the desired result - The particle_map() method assigns each atom to a grid point. If order is even, say 4: -* atom is assigned to grid point to its left (in each dim) -* shift = OFFSET -* nlower = -1, nupper = 2, which are offsets from assigned grid point -* window of mapping grid pts is thus 2 grid points to left of atom, 2 to right - +.. parsed-literal:: + + atom is assigned to grid point to its left (in each dim) + shift = OFFSET + nlower = -1, nupper = 2, which are offsets from assigned grid point + window of mapping grid pts is thus 2 grid points to left of atom, 2 to right + If order is odd, say 5: -* atom is assigned to left/right grid pt it is closest to (in each dim) -* shift = OFFSET + 0.5 -* nlower = 2, nupper = 2 -* if point is in left half of cell, then - window of affected grid pts is 3 grid points to left of atom, 2 to right -* if point is in right half of cell, then - window of affected grid pts is 2 grid points to left of atom, 3 to right +.. parsed-literal:: + + atom is assigned to left/right grid pt it is closest to (in each dim) + shift = OFFSET + 0.5 + nlower = 2, nupper = 2 + if point is in left half of cell, then window of affected grid pts is 3 grid points to left of atom, 2 to right + if point is in right half of cell, then window of affected grid pts is 2 grid points to left of atom, 3 to right These settings apply to each dimension, so that if order = 5, an atom's charge is mapped to 125 grid points that surround the atom. From 7a934eac373cfe024676eb98340cb506ddd16c03 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 22 Dec 2020 10:40:28 -0500 Subject: [PATCH 137/187] use constexpr instead of define for better typechecking --- src/KOKKOS/atom_vec_kokkos.cpp | 5 +++-- src/atom_vec.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 2cb70a8c87..779e977b09 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -19,8 +19,6 @@ #include "error.h" #include "domain.h" -#define DELTA 10 // much smaller than atom_vec.cpp - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -35,10 +33,13 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) no_border_vel_flag = 1; } +static constexpr bigint DELTA=10; // much smaller than DELTA in atom_vec.cpp + /* ---------------------------------------------------------------------- roundup N so it is a multiple of DELTA error if N exceeds 32-bit int, since will be used as arg to grow() overload needed because Kokkos uses a smaller DELTA than in atom_vec.cpp + and an exponential instead of a linear growth ------------------------------------------------------------------------- */ bigint AtomVecKokkos::roundup(bigint n) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index e464d31b77..4406ac5f23 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -29,9 +29,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 16384 -#define DELTA_BONUS 8192 - /* ---------------------------------------------------------------------- */ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) @@ -188,6 +185,8 @@ void AtomVec::init() error->all(FLERR,"KOKKOS package requires a kokkos enabled atom_style"); } +static constexpr bigint DELTA=16384; + /* ---------------------------------------------------------------------- roundup N so it is a multiple of DELTA error if N exceeds 32-bit int, since will be used as arg to grow() @@ -211,6 +210,8 @@ void AtomVec::grow_nmax() nmax += DELTA; } +static constexpr bigint DELTA_BONUS=8192; + /* ---------------------------------------------------------------------- grow nmax_bonus so it is a multiple of DELTA_BONUS ------------------------------------------------------------------------- */ From 8efd1c93ec8a2f65c31331a0111bda038b3816ce Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 09:19:01 -0700 Subject: [PATCH 138/187] Add more granular control of Kokkos pair and fix comm --- src/KOKKOS/comm_kokkos.cpp | 22 ++++- src/KOKKOS/comm_kokkos.h | 4 + src/KOKKOS/fix_qeq_reax_kokkos.cpp | 80 +++++++++++-------- src/KOKKOS/kokkos.cpp | 59 ++++++++++++++ src/KOKKOS/kokkos.h | 6 ++ src/KOKKOS/pair_buck_coul_cut_kokkos.cpp | 1 + src/KOKKOS/pair_buck_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_buck_kokkos.cpp | 1 + src/KOKKOS/pair_coul_cut_kokkos.cpp | 1 + src/KOKKOS/pair_coul_debye_kokkos.cpp | 1 + src/KOKKOS/pair_coul_dsf_kokkos.cpp | 1 + src/KOKKOS/pair_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_coul_wolf_kokkos.cpp | 1 + src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp | 1 + src/KOKKOS/pair_eam_alloy_kokkos.cpp | 19 ++++- src/KOKKOS/pair_eam_fs_kokkos.cpp | 17 +++- src/KOKKOS/pair_eam_kokkos.cpp | 19 ++++- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 1 + src/KOKKOS/pair_gran_hooke_history_kokkos.cpp | 1 + src/KOKKOS/pair_hybrid_kokkos.cpp | 1 + ..._lj_charmm_coul_charmm_implicit_kokkos.cpp | 1 + .../pair_lj_charmm_coul_charmm_kokkos.cpp | 1 + .../pair_lj_charmm_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp | 1 + .../pair_lj_class2_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_lj_class2_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | 1 + src/KOKKOS/pair_lj_cut_kokkos.cpp | 1 + src/KOKKOS/pair_lj_expand_kokkos.cpp | 1 + .../pair_lj_gromacs_coul_gromacs_kokkos.cpp | 1 + src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 1 + src/KOKKOS/pair_lj_sdk_kokkos.cpp | 1 + src/KOKKOS/pair_morse_kokkos.cpp | 1 + src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 1 + src/KOKKOS/pair_reaxc_kokkos.cpp | 1 + src/KOKKOS/pair_snap_kokkos_impl.h | 1 + src/KOKKOS/pair_sw_kokkos.cpp | 1 + src/KOKKOS/pair_table_kokkos.cpp | 1 + src/KOKKOS/pair_table_rx_kokkos.cpp | 1 + src/KOKKOS/pair_tersoff_kokkos.cpp | 1 + src/KOKKOS/pair_tersoff_mod_kokkos.cpp | 1 + src/KOKKOS/pair_tersoff_zbl_kokkos.cpp | 1 + src/KOKKOS/pair_vashishta_kokkos.cpp | 1 + src/KOKKOS/pair_yukawa_kokkos.cpp | 1 + src/KOKKOS/pair_zbl_kokkos.cpp | 1 + src/pair.cpp | 1 + src/pair.h | 1 + 50 files changed, 224 insertions(+), 44 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 2ef4b14d4f..c57a2c1431 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -107,9 +107,13 @@ void CommKokkos::init() atomKK = (AtomKokkos *) atom; exchange_comm_classic = lmp->kokkos->exchange_comm_classic; forward_comm_classic = lmp->kokkos->forward_comm_classic; + forward_pair_comm_classic = lmp->kokkos->forward_pair_comm_classic; + forward_fix_comm_classic = lmp->kokkos->forward_fix_comm_classic; reverse_comm_classic = lmp->kokkos->reverse_comm_classic; exchange_comm_on_host = lmp->kokkos->exchange_comm_on_host; forward_comm_on_host = lmp->kokkos->forward_comm_on_host; + forward_pair_comm_on_host = lmp->kokkos->forward_pair_comm_on_host; + forward_fix_comm_on_host = lmp->kokkos->forward_fix_comm_on_host; reverse_comm_on_host = lmp->kokkos->reverse_comm_on_host; CommBrick::init(); @@ -361,6 +365,17 @@ void CommKokkos::reverse_comm_device() void CommKokkos::forward_comm_fix(Fix *fix, int size) { + if (!fix->kokkosable || !fix->forward_comm_device || forward_fix_comm_classic) { + k_sendlist.sync(); + CommBrick::forward_comm_fix(fix); + } else if (forward_fix_comm_on_host) { + k_sendlist.sync(); + forward_comm_fix_device(fix); + } else { + k_sendlist.sync(); + forward_comm_fix_device(fix); + } + if (fix->execution_space == Device && fix->forward_comm_device) { k_sendlist.sync(); forward_comm_fix_device(fix,size); @@ -456,10 +471,13 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (pair->execution_space == Host) { + if (!pair->kokkosable || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); - } else if (pair->execution_space == Device) { + } else if (forward_pair_comm_on_host) { + k_sendlist.sync(); + forward_comm_pair_device(pair); + } else { k_sendlist.sync(); forward_comm_pair_device(pair); } diff --git a/src/KOKKOS/comm_kokkos.h b/src/KOKKOS/comm_kokkos.h index 6b4a201ab7..d1cb388954 100644 --- a/src/KOKKOS/comm_kokkos.h +++ b/src/KOKKOS/comm_kokkos.h @@ -25,9 +25,13 @@ class CommKokkos : public CommBrick { bool exchange_comm_classic; bool forward_comm_classic; + bool forward_pair_comm_classic; + bool forward_fix_comm_classic; bool reverse_comm_classic; bool exchange_comm_on_host; bool forward_comm_on_host; + bool forward_pair_comm_on_host; + bool forward_fix_comm_on_host; bool reverse_comm_on_host; CommKokkos(class LAMMPS *); diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index c96f5ded68..88b5414fc6 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -263,15 +263,15 @@ void FixQEqReaxKokkos::pre_force(int /*vflag*/) // comm->forward_comm_fix(this); //Dist_vector( s ); pack_flag = 2; - k_s.template sync(); - comm->forward_comm_fix(this); k_s.template modify(); + comm->forward_comm_fix(this); + k_s.template sync(); // comm->forward_comm_fix(this); //Dist_vector( t ); pack_flag = 3; - k_t.template sync(); - comm->forward_comm_fix(this); k_t.template modify(); + comm->forward_comm_fix(this); + k_t.template sync(); need_dup = lmp->kokkos->need_dup(); @@ -752,9 +752,7 @@ void FixQEqReaxKokkos::cg_solve1() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -781,9 +779,9 @@ void FixQEqReaxKokkos::cg_solve1() // comm->forward_comm_fix(this); //Dist_vector( d ); pack_flag = 1; - k_d.template sync(); - comm->forward_comm_fix(this); k_d.template modify(); + comm->forward_comm_fix(this); + k_d.template sync(); // sparse_matvec( &H, d, q ); FixQEqReaxKokkosSparse22Functor sparse22_functor(this); @@ -807,9 +805,7 @@ void FixQEqReaxKokkos::cg_solve1() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -888,9 +884,7 @@ void FixQEqReaxKokkos::cg_solve2() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -917,9 +911,9 @@ void FixQEqReaxKokkos::cg_solve2() // comm->forward_comm_fix(this); //Dist_vector( d ); pack_flag = 1; - k_d.template sync(); - comm->forward_comm_fix(this); k_d.template modify(); + comm->forward_comm_fix(this); + k_d.template sync(); // sparse_matvec( &H, d, q ); FixQEqReaxKokkosSparse22Functor sparse22_functor(this); @@ -943,9 +937,7 @@ void FixQEqReaxKokkos::cg_solve2() if (neighflag != FULL) { k_o.template modify(); - k_o.template sync(); comm->reverse_comm_fix(this); //Coll_vector( q ); - k_o.template modify(); k_o.template sync(); } @@ -1020,9 +1012,9 @@ void FixQEqReaxKokkos::calculate_q() pack_flag = 4; //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); - atomKK->k_q.sync(); - comm->forward_comm_fix(this); atomKK->k_q.modify(); + comm->forward_comm_fix(this); + atomKK->k_q.sync(); } @@ -1411,14 +1403,19 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu { int m; - if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = h_d[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = h_s[list[m]]; - else if( pack_flag == 3 ) - for(m = 0; m < n; m++) buf[m] = h_t[list[m]]; - else if( pack_flag == 4 ) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + if (pack_flag == 1) { + k_d.sync_host(); + for (m = 0; m < n; m++) buf[m] = h_d[list[m]]; + } else if (pack_flag == 2) { + k_s.sync_host(); + for (m = 0; m < n; m++) buf[m] = h_s[list[m]]; + } else if (pack_flag == 3) { + k_t.sync_host(); + for (m = 0; m < n; m++) buf[m] = h_t[list[m]]; + } else if (pack_flag == 4) { + atomKK->sync(Host,Q_MASK); + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + } return n; } @@ -1430,14 +1427,23 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double { int i, m; - if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; - else if( pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; - else if( pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + if (pack_flag == 1) { + k_d.sync_host(); + for (m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; + k_d.modify_host(); + } else if (pack_flag == 2) { + k_s.sync_host(); + for (m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; + k_d.modify_host(); + } else if (pack_flag == 3) { + k_t.sync_host(); + for (m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; + k_d.modify_host(); + } else if (pack_flag == 4) { + atomKK->sync(Host,Q_MASK); + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + atomKK->modified(Host,Q_MASK); + } } /* ---------------------------------------------------------------------- */ @@ -1445,6 +1451,8 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double template int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_o.sync_host(); + int i, m; for(m = 0, i = first; m < n; m++, i++) { buf[m] = h_o[i]; @@ -1457,9 +1465,13 @@ int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *bu template void FixQEqReaxKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_o.sync_host(); + for(int m = 0; m < n; m++) { h_o[list[m]] += buf[m]; } + + k_o.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 64455fef4f..3be19e6190 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -77,6 +77,8 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) exchange_comm_changed = 0; forward_comm_changed = 0; + forward_pair_comm_changed = 0; + forward_fix_comm_changed = 0; reverse_comm_changed = 0; delete memory; @@ -203,8 +205,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) neighflag = FULL; neighflag_qeq = FULL; newtonflag = 0; + exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 0; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else { if (nthreads > 1) { neighflag = HALFTHREAD; @@ -214,8 +220,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) neighflag_qeq = HALF; } newtonflag = 1; + exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; + forward_pair_comm_classic = forward_fix_comm_classic = 1; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } #ifdef LMP_KOKKOS_GPU @@ -339,13 +349,22 @@ void KokkosLMP::accelerator(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; + forward_pair_comm_classic = forward_fix_comm_classic = 1; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else if (strcmp(arg[iarg+1],"host") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 0; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 1; + forward_pair_comm_on_host = forward_fix_comm_on_host = 1; } else if (strcmp(arg[iarg+1],"device") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 0; + exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; + forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else error->all(FLERR,"Illegal package kokkos command"); iarg += 2; } else if (strcmp(arg[iarg],"comm/exchange") == 0) { @@ -372,6 +391,30 @@ void KokkosLMP::accelerator(int narg, char **arg) } else error->all(FLERR,"Illegal package kokkos command"); forward_comm_changed = 0; iarg += 2; + } else if (strcmp(arg[iarg],"comm/pair/forward") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + if (strcmp(arg[iarg+1],"no") == 0) forward_pair_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) { + forward_pair_comm_classic = 0; + forward_pair_comm_on_host = 1; + } else if (strcmp(arg[iarg+1],"device") == 0) { + forward_pair_comm_classic = 0; + forward_pair_comm_on_host = 0; + } else error->all(FLERR,"Illegal package kokkos command"); + forward_pair_comm_changed = 0; + iarg += 2; + } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) { + forward_fix_comm_classic = 0; + forward_fix_comm_on_host = 1; + } else if (strcmp(arg[iarg+1],"device") == 0) { + forward_fix_comm_classic = 0; + forward_fix_comm_on_host = 0; + } else error->all(FLERR,"Illegal package kokkos command"); + forward_fix_comm_changed = 0; + iarg += 2; } else if (strcmp(arg[iarg],"comm/reverse") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) reverse_comm_classic = 1; @@ -416,6 +459,14 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_comm_on_host = 1; forward_comm_changed = 1; } + if (forward_pair_comm_classic == 0 && forward_pair_comm_on_host == 0) { + forward_pair_comm_on_host = 1; + forward_pair_comm_changed = 1; + } + if (forward_fix_comm_classic == 0 && forward_fix_comm_on_host == 0) { + forward_fix_comm_on_host = 1; + forward_fix_comm_changed = 1; + } if (reverse_comm_classic == 0 && reverse_comm_on_host == 0) { reverse_comm_on_host = 1; reverse_comm_changed = 1; @@ -433,6 +484,14 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_comm_on_host = 0; forward_comm_changed = 0; } + if (forward_pair_comm_changed) { + forward_pair_comm_on_host = 0; + forward_pair_comm_changed = 0; + } + if (forward_fix_comm_changed) { + forward_fix_comm_on_host = 0; + forward_fix_comm_changed = 0; + } if (reverse_comm_changed) { reverse_comm_on_host = 0; reverse_comm_changed = 0; diff --git a/src/KOKKOS/kokkos.h b/src/KOKKOS/kokkos.h index eb0eb2e71f..f4d9b99dba 100644 --- a/src/KOKKOS/kokkos.h +++ b/src/KOKKOS/kokkos.h @@ -28,12 +28,18 @@ class KokkosLMP : protected Pointers { int neighflag_qeq_set; int exchange_comm_classic; int forward_comm_classic; + int forward_pair_comm_classic; + int forward_fix_comm_classic; int reverse_comm_classic; int exchange_comm_on_host; int forward_comm_on_host; + int forward_pair_comm_on_host; + int forward_fix_comm_on_host; int reverse_comm_on_host; int exchange_comm_changed; int forward_comm_changed; + int forward_pair_comm_changed; + int forward_fix_comm_changed; int reverse_comm_changed; int nthreads,ngpus; int numa; diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index d3b00329d8..47b4f55662 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -44,6 +44,7 @@ PairBuckCoulCutKokkos::PairBuckCoulCutKokkos(LAMMPS *lmp):PairBuckCo { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp index e503dd7ba5..41bb7a5fdb 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp @@ -51,6 +51,7 @@ PairBuckCoulLongKokkos::PairBuckCoulLongKokkos(LAMMPS *lmp):PairBuck { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_buck_kokkos.cpp b/src/KOKKOS/pair_buck_kokkos.cpp index b361824adc..7535f757f2 100644 --- a/src/KOKKOS/pair_buck_kokkos.cpp +++ b/src/KOKKOS/pair_buck_kokkos.cpp @@ -42,6 +42,7 @@ PairBuckKokkos::PairBuckKokkos(LAMMPS *lmp) : PairBuck(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_cut_kokkos.cpp b/src/KOKKOS/pair_coul_cut_kokkos.cpp index 8ac8f89db8..7dcc8549f9 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_coul_cut_kokkos.cpp @@ -33,6 +33,7 @@ using namespace LAMMPS_NS; template PairCoulCutKokkos::PairCoulCutKokkos(LAMMPS *lmp) : PairCoulCut(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index 1abd6bad05..da678eccf2 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -42,6 +42,7 @@ PairCoulDebyeKokkos::PairCoulDebyeKokkos(LAMMPS *lmp):PairCoulDebye( { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_coul_dsf_kokkos.cpp index 17f87767d9..4981d3240f 100644 --- a/src/KOKKOS/pair_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_dsf_kokkos.cpp @@ -46,6 +46,7 @@ PairCoulDSFKokkos::PairCoulDSFKokkos(LAMMPS *lmp) : PairCoulDSF(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_long_kokkos.cpp b/src/KOKKOS/pair_coul_long_kokkos.cpp index e2407e6e53..91f80ba146 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_coul_long_kokkos.cpp @@ -51,6 +51,7 @@ PairCoulLongKokkos::PairCoulLongKokkos(LAMMPS *lmp):PairCoulLong(lmp { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_coul_wolf_kokkos.cpp index 843b3106c9..44d9222baf 100644 --- a/src/KOKKOS/pair_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_wolf_kokkos.cpp @@ -41,6 +41,7 @@ PairCoulWolfKokkos::PairCoulWolfKokkos(LAMMPS *lmp) : PairCoulWolf(l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp index 629c5b0bec..649459f178 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp @@ -44,6 +44,7 @@ PairDPDfdtEnergyKokkos::PairDPDfdtEnergyKokkos(LAMMPS *lmp) : rand_pool() #endif { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index c2fbe7b87a..48b5efaf54 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -46,6 +46,7 @@ PairEAMAlloyKokkos::PairEAMAlloyKokkos(LAMMPS *lmp) : PairEAM(lmp) one_coeff = 1; manybody_flag = 1; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; @@ -170,9 +171,7 @@ void PairEAMAlloyKokkos::compute(int eflag_in, int vflag_in) if (newton_pair) { k_rho.template modify(); - k_rho.template sync(); comm->reverse_comm_pair(this); - k_rho.template modify(); k_rho.template sync(); } @@ -198,9 +197,11 @@ void PairEAMAlloyKokkos::compute(int eflag_in, int vflag_in) ev.evdwl = 0.0; } - // communicate derivative of embedding function (on the device) + // communicate derivative of embedding function + k_fp.template modify(); comm->forward_comm_pair(this); + k_fp.template sync(); // compute kernel C @@ -467,6 +468,8 @@ template int PairEAMAlloyKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + k_fp.sync_host(); + int i,j; for (i = 0; i < n; i++) { @@ -481,9 +484,13 @@ int PairEAMAlloyKokkos::pack_forward_comm(int n, int *list, double * template void PairEAMAlloyKokkos::unpack_forward_comm(int n, int first, double *buf) { + k_fp.sync_host(); + for (int i = 0; i < n; i++) { h_fp[i + first] = buf[i]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ @@ -491,6 +498,8 @@ void PairEAMAlloyKokkos::unpack_forward_comm(int n, int first, doubl template int PairEAMAlloyKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_rho.sync_host(); + int i,m,last; m = 0; @@ -504,6 +513,8 @@ int PairEAMAlloyKokkos::pack_reverse_comm(int n, int first, double * template void PairEAMAlloyKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_rho.sync_host(); + int i,j,m; m = 0; @@ -511,6 +522,8 @@ void PairEAMAlloyKokkos::unpack_reverse_comm(int n, int *list, doubl j = list[i]; h_rho[j] += buf[m++]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 54397cea51..2f9f67ba6f 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -46,6 +46,7 @@ PairEAMFSKokkos::PairEAMFSKokkos(LAMMPS *lmp) : PairEAM(lmp) manybody_flag = 1; respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; @@ -170,9 +171,7 @@ void PairEAMFSKokkos::compute(int eflag_in, int vflag_in) if (newton_pair) { k_rho.template modify(); - k_rho.template sync(); comm->reverse_comm_pair(this); - k_rho.template modify(); k_rho.template sync(); } @@ -200,7 +199,9 @@ void PairEAMFSKokkos::compute(int eflag_in, int vflag_in) // communicate derivative of embedding function (on the device) + k_fp.template sync(); comm->forward_comm_pair(this); + k_fp.template modify(); // compute kernel C @@ -467,6 +468,8 @@ template int PairEAMFSKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + k_fp.sync_host(); + int i,j; for (i = 0; i < n; i++) { @@ -481,9 +484,13 @@ int PairEAMFSKokkos::pack_forward_comm(int n, int *list, double *buf template void PairEAMFSKokkos::unpack_forward_comm(int n, int first, double *buf) { + k_fp.sync_host(); + for (int i = 0; i < n; i++) { h_fp[i + first] = buf[i]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ @@ -491,6 +498,8 @@ void PairEAMFSKokkos::unpack_forward_comm(int n, int first, double * template int PairEAMFSKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_rho.sync_host(); + int i,m,last; m = 0; @@ -504,6 +513,8 @@ int PairEAMFSKokkos::pack_reverse_comm(int n, int first, double *buf template void PairEAMFSKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_rho.sync_host(); + int i,j,m; m = 0; @@ -511,6 +522,8 @@ void PairEAMFSKokkos::unpack_reverse_comm(int n, int *list, double * j = list[i]; h_rho[j] += buf[m++]; } + + k_rho.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index bcbddea28d..98dbcba633 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -39,6 +39,7 @@ PairEAMKokkos::PairEAMKokkos(LAMMPS *lmp) : PairEAM(lmp) respa_enable = 0; single_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; @@ -163,9 +164,7 @@ void PairEAMKokkos::compute(int eflag_in, int vflag_in) if (newton_pair) { k_rho.template modify(); - k_rho.template sync(); comm->reverse_comm_pair(this); - k_rho.template modify(); k_rho.template sync(); } @@ -191,9 +190,11 @@ void PairEAMKokkos::compute(int eflag_in, int vflag_in) ev.evdwl = 0.0; } - // communicate derivative of embedding function (on the device) + // communicate derivative of embedding function + k_fp.template modify(); comm->forward_comm_pair(this); + k_fp.template sync(); // compute kernel C @@ -465,6 +466,8 @@ template int PairEAMKokkos::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + k_fp.sync_host(); + int i,j; for (i = 0; i < n; i++) { @@ -479,9 +482,13 @@ int PairEAMKokkos::pack_forward_comm(int n, int *list, double *buf, template void PairEAMKokkos::unpack_forward_comm(int n, int first, double *buf) { + k_fp.sync_host(); + for (int i = 0; i < n; i++) { h_fp[i + first] = buf[i]; } + + k_fp.modify_host(); } /* ---------------------------------------------------------------------- */ @@ -489,6 +496,8 @@ void PairEAMKokkos::unpack_forward_comm(int n, int first, double *bu template int PairEAMKokkos::pack_reverse_comm(int n, int first, double *buf) { + k_rho.sync_host(); + int i,m,last; m = 0; @@ -502,6 +511,8 @@ int PairEAMKokkos::pack_reverse_comm(int n, int first, double *buf) template void PairEAMKokkos::unpack_reverse_comm(int n, int *list, double *buf) { + k_rho.sync_host(); + int i,j,m; m = 0; @@ -509,6 +520,8 @@ void PairEAMKokkos::unpack_reverse_comm(int n, int *list, double *bu j = list[i]; h_rho[j] += buf[m++]; } + + k_rho.modify_host(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index bc60bab85c..81cd69fd4d 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -77,6 +77,7 @@ double getElapsedTime( const TimerType &t0, const TimerType &t1) template PairExp6rxKokkos::PairExp6rxKokkos(LAMMPS *lmp) : PairExp6rx(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp index f82351fc9c..81c82ab826 100644 --- a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp +++ b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp @@ -32,6 +32,7 @@ using namespace LAMMPS_NS; template PairGranHookeHistoryKokkos::PairGranHookeHistoryKokkos(LAMMPS *lmp) : PairGranHookeHistory(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | OMEGA_MASK | F_MASK | TORQUE_MASK | TYPE_MASK | MASK_MASK | ENERGY_MASK | VIRIAL_MASK | RMASS_MASK | RADIUS_MASK; diff --git a/src/KOKKOS/pair_hybrid_kokkos.cpp b/src/KOKKOS/pair_hybrid_kokkos.cpp index 0d28e4a15d..540a6a368a 100644 --- a/src/KOKKOS/pair_hybrid_kokkos.cpp +++ b/src/KOKKOS/pair_hybrid_kokkos.cpp @@ -30,6 +30,7 @@ using namespace LAMMPS_NS; PairHybridKokkos::PairHybridKokkos(LAMMPS *lmp) : PairHybrid(lmp) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; // prevent overlapping host/device computation, which isn't diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index 208fb8165b..04632c9eec 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -50,6 +50,7 @@ PairLJCharmmCoulCharmmImplicitKokkos::PairLJCharmmCoulCharmmImplicit { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp index 4d7341a40a..8fe3e405af 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp @@ -51,6 +51,7 @@ PairLJCharmmCoulCharmmKokkos::PairLJCharmmCoulCharmmKokkos(LAMMPS *l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp index 0c04b8a9f6..e70bfdb811 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp @@ -51,6 +51,7 @@ PairLJCharmmCoulLongKokkos::PairLJCharmmCoulLongKokkos(LAMMPS *lmp): { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp index c2a221d928..7fc802e0eb 100644 --- a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp @@ -39,6 +39,7 @@ PairLJClass2CoulCutKokkos::PairLJClass2CoulCutKokkos(LAMMPS *lmp):Pa { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp index a3efbec8dd..dc7858d8d1 100644 --- a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp @@ -47,6 +47,7 @@ PairLJClass2CoulLongKokkos::PairLJClass2CoulLongKokkos(LAMMPS *lmp): { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_class2_kokkos.cpp b/src/KOKKOS/pair_lj_class2_kokkos.cpp index baac21f014..dbeb78d89a 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_kokkos.cpp @@ -42,6 +42,7 @@ PairLJClass2Kokkos::PairLJClass2Kokkos(LAMMPS *lmp) : PairLJClass2(l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp index 9cfae7a05b..ccdfd127bd 100644 --- a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp @@ -38,6 +38,7 @@ PairLJCutCoulCutKokkos::PairLJCutCoulCutKokkos(LAMMPS *lmp):PairLJCu { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp index 2b523321e3..9a641b514f 100644 --- a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp @@ -42,6 +42,7 @@ PairLJCutCoulDebyeKokkos::PairLJCutCoulDebyeKokkos(LAMMPS *lmp):Pair { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index 12ecb1b576..b1af8df018 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -52,6 +52,7 @@ PairLJCutCoulDSFKokkos::PairLJCutCoulDSFKokkos(LAMMPS *lmp):PairLJCu { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp index 2e2a756a70..68d6fe3a11 100644 --- a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp @@ -49,6 +49,7 @@ PairLJCutCoulLongKokkos::PairLJCutCoulLongKokkos(LAMMPS *lmp):PairLJ { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_kokkos.cpp index 518fb4d866..89bd82f682 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_kokkos.cpp @@ -37,6 +37,7 @@ PairLJCutKokkos::PairLJCutKokkos(LAMMPS *lmp) : PairLJCut(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_expand_kokkos.cpp b/src/KOKKOS/pair_lj_expand_kokkos.cpp index 07e37b75e7..1f80d501c5 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_kokkos.cpp @@ -42,6 +42,7 @@ PairLJExpandKokkos::PairLJExpandKokkos(LAMMPS *lmp) : PairLJExpand(l { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp index a0d86e3bdb..9bc294ae71 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp @@ -42,6 +42,7 @@ PairLJGromacsCoulGromacsKokkos::PairLJGromacsCoulGromacsKokkos(LAMMP { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp index c907dc9c25..ad9d8ddbc5 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp @@ -42,6 +42,7 @@ PairLJGromacsKokkos::PairLJGromacsKokkos(LAMMPS *lmp):PairLJGromacs( { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.cpp b/src/KOKKOS/pair_lj_sdk_kokkos.cpp index 27003089de..2c66aad25a 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.cpp +++ b/src/KOKKOS/pair_lj_sdk_kokkos.cpp @@ -42,6 +42,7 @@ PairLJSDKKokkos::PairLJSDKKokkos(LAMMPS *lmp) : PairLJSDK(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_morse_kokkos.cpp b/src/KOKKOS/pair_morse_kokkos.cpp index 47bd636aa8..f6a67f81d5 100644 --- a/src/KOKKOS/pair_morse_kokkos.cpp +++ b/src/KOKKOS/pair_morse_kokkos.cpp @@ -44,6 +44,7 @@ PairMorseKokkos::PairMorseKokkos(LAMMPS *lmp) : PairMorse(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 644115ccd6..05421186c0 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -57,6 +57,7 @@ PairMultiLucyRXKokkos::PairMultiLucyRXKokkos(LAMMPS *lmp) : PairMult { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index eea397dc69..cfb273cd97 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -49,6 +49,7 @@ PairReaxCKokkos::PairReaxCKokkos(LAMMPS *lmp) : PairReaxC(lmp) cut_nbsq = cut_hbsq = cut_bosq = 0.0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | Q_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index bacb5f75d6..1037985670 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -53,6 +53,7 @@ PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 3ff990ed4e..5d629dc42a 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -45,6 +45,7 @@ PairSWKokkos::PairSWKokkos(LAMMPS *lmp) : PairSW(lmp) respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_table_kokkos.cpp b/src/KOKKOS/pair_table_kokkos.cpp index dbea12a1f0..f57956f1ea 100644 --- a/src/KOKKOS/pair_table_kokkos.cpp +++ b/src/KOKKOS/pair_table_kokkos.cpp @@ -35,6 +35,7 @@ template PairTableKokkos::PairTableKokkos(LAMMPS *lmp) : PairTable(lmp) { update_table = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index 82807f944d..d6728098b5 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -141,6 +141,7 @@ template PairTableRXKokkos::PairTableRXKokkos(LAMMPS *lmp) : PairTable(lmp) { update_table = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK | diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index f90a803a49..74d3521940 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -42,6 +42,7 @@ PairTersoffKokkos::PairTersoffKokkos(LAMMPS *lmp) : PairTersoff(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index 24f466d750..13222c2214 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -42,6 +42,7 @@ PairTersoffMODKokkos::PairTersoffMODKokkos(LAMMPS *lmp) : PairTersof { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index 01612905b5..5e201dbc1c 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -44,6 +44,7 @@ PairTersoffZBLKokkos::PairTersoffZBLKokkos(LAMMPS *lmp) : PairTersof { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 23a0d10757..4b7b50afe9 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -45,6 +45,7 @@ PairVashishtaKokkos::PairVashishtaKokkos(LAMMPS *lmp) : PairVashisht { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_yukawa_kokkos.cpp b/src/KOKKOS/pair_yukawa_kokkos.cpp index d927526320..6a6c8bffba 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.cpp +++ b/src/KOKKOS/pair_yukawa_kokkos.cpp @@ -41,6 +41,7 @@ PairYukawaKokkos::PairYukawaKokkos(LAMMPS *lmp) : PairYukawa(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index 2cbe65dcf7..a3cdbf3b6e 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -43,6 +43,7 @@ PairZBLKokkos::PairZBLKokkos(LAMMPS *lmp) : PairZBL(lmp) { respa_enable = 0; + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; diff --git a/src/pair.cpp b/src/pair.cpp index 5c8422c91a..afc5eb2785 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -115,6 +115,7 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp) datamask_read = ALL_MASK; datamask_modify = ALL_MASK; + kokkosable = 0; copymode = 0; } diff --git a/src/pair.h b/src/pair.h index ff0ce82cc8..5801941458 100644 --- a/src/pair.h +++ b/src/pair.h @@ -115,6 +115,7 @@ class Pair : protected Pointers { ExecutionSpace execution_space; unsigned int datamask_read,datamask_modify; + int kokkosable; // 1 if Kokkos pair Pair(class LAMMPS *); virtual ~Pair(); From 60dc9f61872943fb13aded606b050a663edc7605 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 17 Dec 2020 15:57:51 -0700 Subject: [PATCH 139/187] Update docs --- doc/src/package.rst | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/src/package.rst b/doc/src/package.rst index 725536310a..9ace307bd5 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -65,7 +65,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/reverse* or *cuda/aware* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* *pair/comm/forward* *fix/comm/forward* or *comm/reverse* or *cuda/aware* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -81,9 +81,11 @@ Syntax *binsize* value = size size = bin size for neighbor list construction (distance units) *comm* value = *no* or *host* or *device* - use value for comm/exchange and comm/forward and comm/reverse + use value for comm/exchange and comm/forward and pair/comm/forward and fix/comm/forward and comm/reverse *comm/exchange* value = *no* or *host* or *device* *comm/forward* value = *no* or *host* or *device* + *pair/comm/forward* value = *no* or *host* or *device* + *fix/comm/forward* value = *no* or *host* or *device* *comm/reverse* value = *no* or *host* or *device* no = perform communication pack/unpack in non-KOKKOS mode host = perform pack/unpack on host (e.g. with OpenMP threading) @@ -484,7 +486,8 @@ because the GPU is faster at performing pairwise interactions, then this rule of thumb may give too large a binsize and the default should be overridden with a smaller value. -The *comm* and *comm/exchange* and *comm/forward* and *comm/reverse* +The *comm* and *comm/exchange* and *comm/forward* and *pair/comm/forward* +and *fix/comm/forward* and comm/reverse* keywords determine whether the host or device performs the packing and unpacking of data when communicating per-atom data between processors. "Exchange" communication happens only on timesteps that neighbor lists @@ -492,10 +495,12 @@ are rebuilt. The data is only for atoms that migrate to new processors. "Forward" communication happens every timestep. "Reverse" communication happens every timestep if the *newton* option is on. The data is for atom coordinates and any other atom properties that needs to be updated -for ghost atoms owned by each processor. +for ghost atoms owned by each processor. "Pair/comm" controls additional +communication in pair styles, such as pair_style EAM. "Fix/comm" controls +additional communication in fixes, such as fix SHAKE. -The *comm* keyword is simply a short-cut to set the same value for both -the *comm/exchange* and *comm/forward* and *comm/reverse* keywords. +The *comm* keyword is simply a short-cut to set the same value for all +the comm keywords. The value options for all 3 keywords are *no* or *host* or *device*\ . A value of *no* means to use the standard non-KOKKOS method of From cf3ae8cdd26270e56dce49c25aba76dde067217c Mon Sep 17 00:00:00 2001 From: Nicholas Lubbers Date: Tue, 22 Dec 2020 09:59:50 -0700 Subject: [PATCH 140/187] switch setuptools back to distutils --- python/install.py | 4 ++-- python/setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/install.py b/python/install.py index 8c632c096e..6765c33925 100644 --- a/python/install.py +++ b/python/install.py @@ -95,7 +95,7 @@ print("Installing LAMMPS Python package version %s into site-packages folder" % # we need to switch to the folder of the python package os.chdir(os.path.dirname(args.package)) -from setuptools import setup, find_packages +from distutils.core import setup from distutils.sysconfig import get_python_lib import site @@ -107,7 +107,7 @@ setup_kwargs= dict(name="lammps", url="https://lammps.sandia.gov", description="LAMMPS Molecular Dynamics Python package", license="GPL", - packages=find_packages(), + packages=["lammps","lammps.mliap"], ) tryuser=False diff --git a/python/setup.py b/python/setup.py index 50e215cb09..aff0b14671 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,6 +1,6 @@ # this only installs the LAMMPS python package # it assumes the LAMMPS shared library is already installed -from setuptools import setup, find_packages +from distutils.core import setup import os LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -22,5 +22,5 @@ setup( url = "https://lammps.sandia.gov", description = "LAMMPS Molecular Dynamics Python package", license = "GPL", - packages=find_packages(), + packages=["lammps","lammps.mliap"], ) From 271cbad787ee078170cb2176fc7bf6327f8f0501 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 11:58:32 -0700 Subject: [PATCH 141/187] Remove redundant code --- src/KOKKOS/comm_kokkos.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index c57a2c1431..c25fd1d111 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -375,14 +375,6 @@ void CommKokkos::forward_comm_fix(Fix *fix, int size) k_sendlist.sync(); forward_comm_fix_device(fix); } - - if (fix->execution_space == Device && fix->forward_comm_device) { - k_sendlist.sync(); - forward_comm_fix_device(fix,size); - } else { - k_sendlist.sync(); - CommBrick::forward_comm_fix(fix,size); - } } template From 6f852e7b2cf41d6d0bac8ae8cf15da6c6364f5a0 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 12:55:44 -0700 Subject: [PATCH 142/187] Remove 'host' option for Kokkos pair and fix comm --- src/KOKKOS/comm_kokkos.cpp | 10 +--- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 16 ++--- src/KOKKOS/kokkos.cpp | 75 ++++++++++-------------- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 15 +++-- 4 files changed, 52 insertions(+), 64 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index c25fd1d111..23923419e8 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -365,12 +365,9 @@ void CommKokkos::reverse_comm_device() void CommKokkos::forward_comm_fix(Fix *fix, int size) { - if (!fix->kokkosable || !fix->forward_comm_device || forward_fix_comm_classic) { + if (!(fix->execution_space == Device) || !fix->forward_comm_device || forward_fix_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_fix(fix); - } else if (forward_fix_comm_on_host) { - k_sendlist.sync(); - forward_comm_fix_device(fix); } else { k_sendlist.sync(); forward_comm_fix_device(fix); @@ -463,12 +460,9 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (!pair->kokkosable || forward_pair_comm_classic) { + if (!(fix->execution_space == Device) || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); - } else if (forward_pair_comm_on_host) { - k_sendlist.sync(); - forward_comm_pair_device(pair); } else { k_sendlist.sync(); forward_comm_pair_device(pair); diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index 88b5414fc6..f380ab40f5 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -21,7 +21,7 @@ #include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm.h" +#include "comm_kokkos.h" #include "error.h" #include "force.h" #include "kokkos.h" @@ -49,6 +49,7 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : kokkosable = 1; forward_comm_device = 1; atomKK = (AtomKokkos *) atom; + commKK = (CommKokkos *) comm; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | Q_MASK | TYPE_MASK | TAG_MASK; @@ -81,8 +82,8 @@ FixQEqReaxKokkos::~FixQEqReaxKokkos() template void FixQEqReaxKokkos::init() { - atomKK->k_q.modify(); - atomKK->k_q.sync(); + atomKK->modified(Host,Q_MASK); + atomKK->sync(execution_space,Q_MASK); FixQEqReax::init(); @@ -1012,9 +1013,9 @@ void FixQEqReaxKokkos::calculate_q() pack_flag = 4; //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); - atomKK->k_q.modify(); + atomKK->modified(execution_space,Q_MASK); comm->forward_comm_fix(this); - atomKK->k_q.sync(); + atomKK->sync(execution_space,Q_MASK); } @@ -1349,6 +1350,7 @@ int FixQEqReaxKokkos::pack_forward_comm_fix_kokkos(int n, DAT::tdual int iswap_in, DAT::tdual_xfloat_1d &k_buf, int /*pbc_flag*/, int * /*pbc*/) { + k_sendlist.sync(); d_sendlist = k_sendlist.view(); iswap = iswap_in; d_buf = k_buf.view(); @@ -1434,11 +1436,11 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double } else if (pack_flag == 2) { k_s.sync_host(); for (m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; - k_d.modify_host(); + k_s.modify_host(); } else if (pack_flag == 3) { k_t.sync_host(); for (m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; - k_d.modify_host(); + k_t.modify_host(); } else if (pack_flag == 4) { atomKK->sync(Host,Q_MASK); for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 3be19e6190..11116b0c93 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -39,7 +39,7 @@ GPU_AWARE_UNKNOWN #elif defined(KOKKOS_ENABLE_CUDA) -// OpenMPI supports detecting CUDA-aware MPI as of version 2.0.0 +// OpenMPI supports detecting GPU-aware MPI as of version 2.0.0 #if (OPEN_MPI) #if (OMPI_MAJOR_VERSION >= 2) @@ -149,7 +149,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (ngpus > 1 && !set_flag) error->all(FLERR,"Could not determine local MPI rank for multiple " - "GPUs with Kokkos CUDA because MPI library not recognized"); + "GPUs with Kokkos CUDA or HIP because MPI library not recognized"); } else if (strcmp(arg[iarg],"t") == 0 || strcmp(arg[iarg],"threads") == 0) { @@ -210,7 +210,6 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) forward_pair_comm_classic = forward_fix_comm_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else { if (nthreads > 1) { neighflag = HALFTHREAD; @@ -225,13 +224,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) forward_pair_comm_classic = forward_fix_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } #ifdef LMP_KOKKOS_GPU - // check and warn about CUDA-aware MPI availability when using multiple MPI tasks - // change default only if we can safely detect that CUDA-aware MPI is not available + // check and warn about GPU-aware MPI availability when using multiple MPI tasks + // change default only if we can safely detect that GPU-aware MPI is not available int nmpi = 0; MPI_Comm_size(world,&nmpi); @@ -254,14 +252,14 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (!gpu_aware_flag) if (me == 0) - error->warning(FLERR,"The Spectrum MPI '-gpu' flag is not set. Disabling CUDA-aware MPI"); + error->warning(FLERR,"The Spectrum MPI '-gpu' flag is not set. Disabling GPU-aware MPI"); } #endif if (gpu_aware_flag == 1 && have_gpu_aware == 0) { if (me == 0) - error->warning(FLERR,"Turning off CUDA-aware MPI since it is not detected, " - "use '-pk kokkos cuda/aware on' to override"); + error->warning(FLERR,"Turning off GPU-aware MPI since it is not detected, " + "use '-pk kokkos gpu/aware on' to override"); gpu_aware_flag = 0; } else if (have_gpu_aware == -1) { // maybe we are dealing with MPICH, MVAPICH2 or some derivative? // MVAPICH2 @@ -274,17 +272,17 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) if (!gpu_aware_flag) if (me == 0) - error->warning(FLERR,"MVAPICH2 'MV2_USE_CUDA' environment variable is not set. Disabling CUDA-aware MPI"); + error->warning(FLERR,"MVAPICH2 'MV2_USE_CUDA' environment variable is not set. Disabling GPU-aware MPI"); // pure MPICH or some unsupported MPICH derivative #elif defined(MPICH) && !defined(MVAPICH2_VERSION) if (me == 0) - error->warning(FLERR,"Detected MPICH. Disabling CUDA-aware MPI"); + error->warning(FLERR,"Detected MPICH. Disabling GPU-aware MPI"); gpu_aware_flag = 0; #else if (me == 0) - error->warning(FLERR,"Kokkos with CUDA assumes CUDA-aware MPI is available," + error->warning(FLERR,"Kokkos with CUDA or HIP assumes GPU-aware MPI is available," " but cannot determine if this is the case\n try" - " '-pk kokkos cuda/aware off' if getting segmentation faults"); + " '-pk kokkos gpu/aware off' if getting segmentation faults"); #endif } // if (-1 == have_gpu_aware) @@ -352,19 +350,16 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_pair_comm_classic = forward_fix_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else if (strcmp(arg[iarg+1],"host") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; forward_pair_comm_classic = forward_fix_comm_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 1; - forward_pair_comm_on_host = forward_fix_comm_on_host = 1; } else if (strcmp(arg[iarg+1],"device") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; forward_pair_comm_classic = forward_fix_comm_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - forward_pair_comm_on_host = forward_fix_comm_on_host = 0; } else error->all(FLERR,"Illegal package kokkos command"); iarg += 2; } else if (strcmp(arg[iarg],"comm/exchange") == 0) { @@ -394,25 +389,15 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/pair/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_pair_comm_classic = 1; - else if (strcmp(arg[iarg+1],"host") == 0) { - forward_pair_comm_classic = 0; - forward_pair_comm_on_host = 1; - } else if (strcmp(arg[iarg+1],"device") == 0) { - forward_pair_comm_classic = 0; - forward_pair_comm_on_host = 0; - } else error->all(FLERR,"Illegal package kokkos command"); + else if (strcmp(arg[iarg+1],"device") == 0) forward_pair_comm_classic = 0; + else error->all(FLERR,"Illegal package kokkos command"); forward_pair_comm_changed = 0; iarg += 2; } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; - else if (strcmp(arg[iarg+1],"host") == 0) { - forward_fix_comm_classic = 0; - forward_fix_comm_on_host = 1; - } else if (strcmp(arg[iarg+1],"device") == 0) { - forward_fix_comm_classic = 0; - forward_fix_comm_on_host = 0; - } else error->all(FLERR,"Illegal package kokkos command"); + else if (strcmp(arg[iarg+1],"device") == 0) forward_fix_comm_classic = 0; + else error->all(FLERR,"Illegal package kokkos command"); forward_fix_comm_changed = 0; iarg += 2; } else if (strcmp(arg[iarg],"comm/reverse") == 0) { @@ -427,7 +412,7 @@ void KokkosLMP::accelerator(int narg, char **arg) } else error->all(FLERR,"Illegal package kokkos command"); reverse_comm_changed = 0; iarg += 2; - } else if (strcmp(arg[iarg],"cuda/aware") == 0) { + } else if (strcmp(arg[iarg],"gpu/aware") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"off") == 0) gpu_aware_flag = 0; else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; @@ -448,52 +433,52 @@ void KokkosLMP::accelerator(int narg, char **arg) int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "cuda/aware off" and "comm device", change to "comm host" + // if "gpu/aware off" and "comm device", change to "comm classic" if (!gpu_aware_flag && nmpi > 1) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { - exchange_comm_on_host = 1; + exchange_comm_classic = 1; exchange_comm_changed = 1; } if (forward_comm_classic == 0 && forward_comm_on_host == 0) { - forward_comm_on_host = 1; + forward_comm_classic = 1; forward_comm_changed = 1; } - if (forward_pair_comm_classic == 0 && forward_pair_comm_on_host == 0) { - forward_pair_comm_on_host = 1; + if (forward_pair_comm_classic == 0) { + forward_pair_comm_classic = 1; forward_pair_comm_changed = 1; } - if (forward_fix_comm_classic == 0 && forward_fix_comm_on_host == 0) { - forward_fix_comm_on_host = 1; + if (forward_fix_comm_classic == 0) { + forward_fix_comm_classic = 1; forward_fix_comm_changed = 1; } if (reverse_comm_classic == 0 && reverse_comm_on_host == 0) { - reverse_comm_on_host = 1; + reverse_comm_classic = 1; reverse_comm_changed = 1; } } - // if "cuda/aware on" and comm flags were changed previously, change them back + // if "gpu/aware on" and comm flags were changed previously, change them back if (gpu_aware_flag) { if (exchange_comm_changed) { - exchange_comm_on_host = 0; + exchange_comm_classic = 0; exchange_comm_changed = 0; } if (forward_comm_changed) { - forward_comm_on_host = 0; + forward_comm_classic = 0; forward_comm_changed = 0; } if (forward_pair_comm_changed) { - forward_pair_comm_on_host = 0; + forward_pair_classic = 0; forward_pair_comm_changed = 0; } if (forward_fix_comm_changed) { - forward_fix_comm_on_host = 0; + forward_fix_comm_classic = 0; forward_fix_comm_changed = 0; } if (reverse_comm_changed) { - reverse_comm_on_host = 0; + reverse_comm_classic = 0; reverse_comm_changed = 0; } } diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 05421186c0..d0c8432af0 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -512,12 +512,17 @@ void PairMultiLucyRXKokkos::computeLocalDensity() atomKK->modified(execution_space,DPDRHO_MASK); - // communicate and sum densities (on the host) + // communicate and sum densities - if (newton_pair) + atomKK->modified(execution_space,DPDRHO_MASK); + + if (newton_pair) { comm->reverse_comm_pair(this); + atomKK->sync(execution_space,DPDRHO_MASK); + } comm->forward_comm_pair(this); + atomKK->sync(execution_space,DPDRHO_MASK); } template @@ -686,8 +691,6 @@ void PairMultiLucyRXKokkos::unpack_forward_comm_kokkos(int n, int fi first = first_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); - - atomKK->modified(execution_space,DPDRHO_MASK); } template @@ -721,6 +724,8 @@ void PairMultiLucyRXKokkos::unpack_forward_comm(int n, int first, do { int i,m,last; + atomKK->sync(Host,DPDRHO_MASK); + m = 0; last = first + n; for (i = first; i < last; i++) h_rho[i] = buf[m++]; @@ -750,6 +755,8 @@ void PairMultiLucyRXKokkos::unpack_reverse_comm(int n, int *list, do { int i,j,m; + atomKK->sync(Host,DPDRHO_MASK); + m = 0; for (i = 0; i < n; i++) { j = list[i]; From 8ba288e1676d2d06c92cc664773521238f6ad190 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 13:16:58 -0700 Subject: [PATCH 143/187] Remove unneeded UVM code --- src/KOKKOS/fix_neigh_history_kokkos.cpp | 4 ---- src/KOKKOS/fix_shardlow_kokkos.cpp | 5 ----- src/KOKKOS/kokkos.cpp | 12 +----------- src/KOKKOS/memory_kokkos.h | 16 ---------------- src/KOKKOS/nbin_kokkos.cpp | 4 ---- src/KOKKOS/nbin_ssa_kokkos.cpp | 10 ---------- src/KOKKOS/npair_ssa_kokkos.h | 8 -------- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 8 files changed, 2 insertions(+), 59 deletions(-) diff --git a/src/KOKKOS/fix_neigh_history_kokkos.cpp b/src/KOKKOS/fix_neigh_history_kokkos.cpp index bb12194af6..e7b16e64f8 100644 --- a/src/KOKKOS/fix_neigh_history_kokkos.cpp +++ b/src/KOKKOS/fix_neigh_history_kokkos.cpp @@ -43,11 +43,7 @@ FixNeighHistoryKokkos::FixNeighHistoryKokkos(LAMMPS *lmp, int narg, grow_arrays(atom->nmax); d_resize = typename ArrayTypes::t_int_scalar("FixNeighHistoryKokkos::resize"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(d_resize); -#else - h_resize = d_resize; -#endif h_resize() = 1; } diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 564c405894..2fd16059bf 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -94,13 +94,8 @@ FixShardlowKokkos::FixShardlowKokkos(LAMMPS *lmp, int narg, char **a #ifdef DEBUG_SSA_PAIR_CT d_counters = typename AT::t_int_2d("FixShardlowKokkos::d_counters", 2, 3); d_hist = typename AT::t_int_1d("FixShardlowKokkos::d_hist", 32); -#ifndef KOKKOS_USE_CUDA_UVM h_counters = Kokkos::create_mirror_view(d_counters); h_hist = Kokkos::create_mirror_view(d_hist); -#else - h_counters = d_counters; - h_hist = d_hist; -#endif #endif } diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 11116b0c93..139fd8f318 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -352,7 +352,7 @@ void KokkosLMP::accelerator(int narg, char **arg) exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; } else if (strcmp(arg[iarg+1],"host") == 0) { exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; - forward_pair_comm_classic = forward_fix_comm_classic = 0; + forward_pair_comm_classic = forward_fix_comm_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 1; } else if (strcmp(arg[iarg+1],"device") == 0) { @@ -514,25 +514,15 @@ int KokkosLMP::neigh_count(int m) if (nk->lists[m]->execution_space == Host) { NeighListKokkos* nlistKK = (NeighListKokkos*) nk->lists[m]; inum = nlistKK->inum; -#ifndef KOKKOS_USE_CUDA_UVM h_ilist = Kokkos::create_mirror_view(nlistKK->d_ilist); h_numneigh = Kokkos::create_mirror_view(nlistKK->d_numneigh); -#else - h_ilist = nlistKK->d_ilist; - h_numneigh = nlistKK->d_numneigh; -#endif Kokkos::deep_copy(h_ilist,nlistKK->d_ilist); Kokkos::deep_copy(h_numneigh,nlistKK->d_numneigh); } else if (nk->lists[m]->execution_space == Device) { NeighListKokkos* nlistKK = (NeighListKokkos*) nk->lists[m]; inum = nlistKK->inum; -#ifndef KOKKOS_USE_CUDA_UVM h_ilist = Kokkos::create_mirror_view(nlistKK->d_ilist); h_numneigh = Kokkos::create_mirror_view(nlistKK->d_numneigh); -#else - h_ilist = nlistKK->d_ilist; - h_numneigh = nlistKK->d_numneigh; -#endif Kokkos::deep_copy(h_ilist,nlistKK->d_ilist); Kokkos::deep_copy(h_numneigh,nlistKK->d_numneigh); } diff --git a/src/KOKKOS/memory_kokkos.h b/src/KOKKOS/memory_kokkos.h index df85f72c65..2f9e0cc375 100644 --- a/src/KOKKOS/memory_kokkos.h +++ b/src/KOKKOS/memory_kokkos.h @@ -46,11 +46,7 @@ template const char *name) { data = TYPE(std::string(name),n1); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif array = h_data.data(); return data; } @@ -61,11 +57,7 @@ template int n1, const char *name) { data = TYPE(std::string(name),n1); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif return data; } @@ -167,11 +159,7 @@ template const char *name) { data = TYPE(std::string(name),n1,n2); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif return data; } @@ -200,11 +188,7 @@ template const char *name) { data = TYPE(std::string(name),n1,n2); -#ifndef KOKKOS_USE_CUDA_UVM h_data = Kokkos::create_mirror_view(data); -#else - h_data = data; -#endif bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; array = (typename TYPE::value_type **) smalloc(nbytes,name); diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 712ea345cf..36a5b09966 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -30,11 +30,7 @@ NBinKokkos::NBinKokkos(LAMMPS *lmp) : NBinStandard(lmp) { atoms_per_bin = 16; d_resize = typename AT::t_int_scalar("NeighborKokkosFunctor::resize"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(d_resize); -#else - h_resize = d_resize; -#endif h_resize() = 1; kokkos = 1; diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 8c9ccb5f59..d04312d620 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -41,7 +41,6 @@ NBinSSAKokkos::NBinSSAKokkos(LAMMPS *lmp) : NBinStandard(lmp) d_lbinxhi = typename AT::t_int_scalar("NBinSSAKokkos::d_lbinxhi"); d_lbinyhi = typename AT::t_int_scalar("NBinSSAKokkos::d_lbinyhi"); d_lbinzhi = typename AT::t_int_scalar("NBinSSAKokkos::d_lbinzhi"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(d_resize); h_lbinxlo = Kokkos::create_mirror_view(d_lbinxlo); h_lbinylo = Kokkos::create_mirror_view(d_lbinylo); @@ -49,15 +48,6 @@ NBinSSAKokkos::NBinSSAKokkos(LAMMPS *lmp) : NBinStandard(lmp) h_lbinxhi = Kokkos::create_mirror_view(d_lbinxhi); h_lbinyhi = Kokkos::create_mirror_view(d_lbinyhi); h_lbinzhi = Kokkos::create_mirror_view(d_lbinzhi); -#else - h_resize = d_resize; - h_lbinxlo = d_lbinxlo; - h_lbinylo = d_lbinylo; - h_lbinzlo = d_lbinzlo; - h_lbinxhi = d_lbinxhi; - h_lbinyhi = d_lbinyhi; - h_lbinzhi = d_lbinzhi; -#endif h_resize() = 1; k_gbincount = DAT::tdual_int_1d("NBinSSAKokkos::gbincount",8); diff --git a/src/KOKKOS/npair_ssa_kokkos.h b/src/KOKKOS/npair_ssa_kokkos.h index b4f541cf2a..5bd0a67001 100644 --- a/src/KOKKOS/npair_ssa_kokkos.h +++ b/src/KOKKOS/npair_ssa_kokkos.h @@ -281,19 +281,11 @@ class NPairSSAKokkosExecute bboxhi[0] = _bboxhi[0]; bboxhi[1] = _bboxhi[1]; bboxhi[2] = _bboxhi[2]; resize = typename AT::t_int_scalar("NPairSSAKokkosExecute::resize"); -#ifndef KOKKOS_USE_CUDA_UVM h_resize = Kokkos::create_mirror_view(resize); -#else - h_resize = resize; -#endif h_resize() = 1; new_maxneighs = typename AT:: t_int_scalar("NPairSSAKokkosExecute::new_maxneighs"); -#ifndef KOKKOS_USE_CUDA_UVM h_new_maxneighs = Kokkos::create_mirror_view(new_maxneighs); -#else - h_new_maxneighs = new_maxneighs; -#endif h_new_maxneighs() = neigh_list.maxneighs; }; diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 95ee7e39a8..19af61a209 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent # FFT library # see discussion in Section 3.5.2 of manual From 679f1e83a48eaf0830b1c1e92eb3ef84b9cae5f9 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 13:49:21 -0700 Subject: [PATCH 144/187] More cleanup --- src/KOKKOS/comm_kokkos.cpp | 4 ++-- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 4 +--- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 23923419e8..d4dab67a39 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -365,7 +365,7 @@ void CommKokkos::reverse_comm_device() void CommKokkos::forward_comm_fix(Fix *fix, int size) { - if (!(fix->execution_space == Device) || !fix->forward_comm_device || forward_fix_comm_classic) { + if (fix->execution_space == Host || !fix->forward_comm_device || forward_fix_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_fix(fix); } else { @@ -460,7 +460,7 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (!(fix->execution_space == Device) || forward_pair_comm_classic) { + if (fix->execution_space == Host || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); } else { diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index f380ab40f5..5383fc47e2 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -21,7 +21,7 @@ #include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" +#include "comm.h" #include "error.h" #include "force.h" #include "kokkos.h" @@ -49,7 +49,6 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : kokkosable = 1; forward_comm_device = 1; atomKK = (AtomKokkos *) atom; - commKK = (CommKokkos *) comm; execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | Q_MASK | TYPE_MASK | TAG_MASK; @@ -1350,7 +1349,6 @@ int FixQEqReaxKokkos::pack_forward_comm_fix_kokkos(int n, DAT::tdual int iswap_in, DAT::tdual_xfloat_1d &k_buf, int /*pbc_flag*/, int * /*pbc*/) { - k_sendlist.sync(); d_sendlist = k_sendlist.view(); iswap = iswap_in; d_buf = k_buf.view(); diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 19af61a209..95ee7e39a8 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm # FFT library # see discussion in Section 3.5.2 of manual From 4520ef16e3caeaaec7dce09eae13167a1f1cb579 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:22:41 -0700 Subject: [PATCH 145/187] Cleanup --- src/KOKKOS/comm_kokkos.cpp | 4 +--- src/KOKKOS/kokkos.cpp | 4 +++- src/KOKKOS/kokkos.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index d4dab67a39..e5016efef1 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -112,8 +112,6 @@ void CommKokkos::init() reverse_comm_classic = lmp->kokkos->reverse_comm_classic; exchange_comm_on_host = lmp->kokkos->exchange_comm_on_host; forward_comm_on_host = lmp->kokkos->forward_comm_on_host; - forward_pair_comm_on_host = lmp->kokkos->forward_pair_comm_on_host; - forward_fix_comm_on_host = lmp->kokkos->forward_fix_comm_on_host; reverse_comm_on_host = lmp->kokkos->reverse_comm_on_host; CommBrick::init(); @@ -460,7 +458,7 @@ void CommKokkos::reverse_comm_compute(Compute *compute) void CommKokkos::forward_comm_pair(Pair *pair) { - if (fix->execution_space == Host || forward_pair_comm_classic) { + if (pair->execution_space == Host || forward_pair_comm_classic) { k_sendlist.sync(); CommBrick::forward_comm_pair(pair); } else { diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 139fd8f318..2f7f69afdc 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -389,6 +389,7 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/pair/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_pair_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) forward_pair_comm_classic = 1; else if (strcmp(arg[iarg+1],"device") == 0) forward_pair_comm_classic = 0; else error->all(FLERR,"Illegal package kokkos command"); forward_pair_comm_changed = 0; @@ -396,6 +397,7 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; + if (strcmp(arg[iarg+1],"host") == 0) forward_fix_comm_classic = 1; else if (strcmp(arg[iarg+1],"device") == 0) forward_fix_comm_classic = 0; else error->all(FLERR,"Illegal package kokkos command"); forward_fix_comm_changed = 0; @@ -470,7 +472,7 @@ void KokkosLMP::accelerator(int narg, char **arg) forward_comm_changed = 0; } if (forward_pair_comm_changed) { - forward_pair_classic = 0; + forward_pair_comm_classic = 0; forward_pair_comm_changed = 0; } if (forward_fix_comm_changed) { diff --git a/src/KOKKOS/kokkos.h b/src/KOKKOS/kokkos.h index f4d9b99dba..b247d583a6 100644 --- a/src/KOKKOS/kokkos.h +++ b/src/KOKKOS/kokkos.h @@ -33,8 +33,6 @@ class KokkosLMP : protected Pointers { int reverse_comm_classic; int exchange_comm_on_host; int forward_comm_on_host; - int forward_pair_comm_on_host; - int forward_fix_comm_on_host; int reverse_comm_on_host; int exchange_comm_changed; int forward_comm_changed; From 31626185126860bb91931464ae0e3e8ce6522f55 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:24:24 -0700 Subject: [PATCH 146/187] Update docs --- doc/src/Speed_kokkos.rst | 12 ++++---- doc/src/package.rst | 36 +++++++++++++----------- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/doc/src/Speed_kokkos.rst b/doc/src/Speed_kokkos.rst index 7827c13811..da483567b3 100644 --- a/doc/src/Speed_kokkos.rst +++ b/doc/src/Speed_kokkos.rst @@ -38,14 +38,14 @@ produce an executable compatible with a specific hardware. :class: note Kokkos with CUDA currently implicitly assumes that the MPI library is - CUDA-aware. This is not always the case, especially when using + GPU-aware. This is not always the case, especially when using pre-compiled MPI libraries provided by a Linux distribution. This is not a problem when using only a single GPU with a single MPI rank. When running with multiple MPI ranks, you may see segmentation - faults without CUDA-aware MPI support. These can be avoided by adding - the flags :doc:`-pk kokkos cuda/aware off ` to the + faults without GPU-aware MPI support. These can be avoided by adding + the flags :doc:`-pk kokkos gpu/aware off ` to the LAMMPS command line or by using the command :doc:`package kokkos - cuda/aware off ` in the input file. + gpu/aware off ` in the input file. .. admonition:: AMD GPU support :class: note @@ -242,8 +242,8 @@ case, also packing/unpacking communication buffers on the host may give speedup (see the KOKKOS :doc:`package ` command). Using CUDA MPS is recommended in this scenario. -Using a CUDA-aware MPI library is highly recommended. CUDA-aware MPI use can be -avoided by using :doc:`-pk kokkos cuda/aware no `. As above for +Using a GPU-aware MPI library is highly recommended. GPU-aware MPI use can be +avoided by using :doc:`-pk kokkos gpu/aware no `. As above for multi-core CPUs (and no GPU), if N is the number of physical cores/node, then the number of MPI tasks/node should not exceed N. diff --git a/doc/src/package.rst b/doc/src/package.rst index 9ace307bd5..1adfc584e1 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -65,7 +65,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* *pair/comm/forward* *fix/comm/forward* or *comm/reverse* or *cuda/aware* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* *pair/comm/forward* *fix/comm/forward* or *comm/reverse* or *gpu/aware* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -84,15 +84,15 @@ Syntax use value for comm/exchange and comm/forward and pair/comm/forward and fix/comm/forward and comm/reverse *comm/exchange* value = *no* or *host* or *device* *comm/forward* value = *no* or *host* or *device* - *pair/comm/forward* value = *no* or *host* or *device* - *fix/comm/forward* value = *no* or *host* or *device* + *pair/comm/forward* value = *no* or *device* + *fix/comm/forward* value = *no* or *device* *comm/reverse* value = *no* or *host* or *device* no = perform communication pack/unpack in non-KOKKOS mode host = perform pack/unpack on host (e.g. with OpenMP threading) device = perform pack/unpack on device (e.g. on GPU) - *cuda/aware* = *off* or *on* - off = do not use CUDA-aware MPI - on = use CUDA-aware MPI (default) + *gpu/aware* = *off* or *on* + off = do not use GPU-aware MPI + on = use GPU-aware MPI (default) *omp* args = Nthreads keyword value ... Nthread = # of OpenMP threads to associate with each MPI process zero or more keyword/value pairs may be appended @@ -502,13 +502,15 @@ additional communication in fixes, such as fix SHAKE. The *comm* keyword is simply a short-cut to set the same value for all the comm keywords. -The value options for all 3 keywords are *no* or *host* or *device*\ . A +The value options for the keywords are *no* or *host* or *device*\ . A value of *no* means to use the standard non-KOKKOS method of packing/unpacking data for the communication. A value of *host* means to use the host, typically a multi-core CPU, and perform the packing/unpacking in parallel with threads. A value of *device* means to use the device, typically a GPU, to perform the packing/unpacking -operation. +operation. If a value of *host* is used for the *pair/comm/forward* or +*fix/comm/forward* keyword, it will be automatically be changed to *no* +since these keywords don't support *host* mode. The optimal choice for these keywords depends on the input script and the hardware used. The *no* value is useful for verifying that the @@ -529,18 +531,18 @@ pack/unpack communicated data. When running small systems on a GPU, performing the exchange pack/unpack on the host CPU can give speedup since it reduces the number of CUDA kernel launches. -The *cuda/aware* keyword chooses whether CUDA-aware MPI will be used. When +The *gpu/aware* keyword chooses whether GPU-aware MPI will be used. When this keyword is set to *on*\ , buffers in GPU memory are passed directly through MPI send/receive calls. This reduces overhead of first copying -the data to the host CPU. However CUDA-aware MPI is not supported on all +the data to the host CPU. However GPU-aware MPI is not supported on all systems, which can lead to segmentation faults and would require using a -value of *off*\ . If LAMMPS can safely detect that CUDA-aware MPI is not +value of *off*\ . If LAMMPS can safely detect that GPU-aware MPI is not available (currently only possible with OpenMPI v2.0.0 or later), then -the *cuda/aware* keyword is automatically set to *off* by default. When -the *cuda/aware* keyword is set to *off* while any of the *comm* +the *gpu/aware* keyword is automatically set to *off* by default. When +the *gpu/aware* keyword is set to *off* while any of the *comm* keywords are set to *device*\ , the value for these *comm* keywords will -be automatically changed to *host*\ . This setting has no effect if not -running on GPUs or if using only one MPI rank. CUDA-aware MPI is available +be automatically changed to *no*\ . This setting has no effect if not +running on GPUs or if using only one MPI rank. GPU-aware MPI is available for OpenMPI 1.8 (or later versions), Mvapich2 1.9 (or later) when the "MV2_USE_CUDA" environment variable is set to "1", CrayMPI, and IBM Spectrum MPI when the "-gpu" flag is used. @@ -654,8 +656,8 @@ script or via the "-pk intel" :doc:`command-line switch `. For the KOKKOS package, the option defaults for GPUs are neigh = full, neigh/qeq = full, newton = off, binsize for GPUs = 2x LAMMPS default -value, comm = device, cuda/aware = on. When LAMMPS can safely detect -that CUDA-aware MPI is not available, the default value of cuda/aware +value, comm = device, gpu/aware = on. When LAMMPS can safely detect +that GPU-aware MPI is not available, the default value of gpu/aware becomes "off". For CPUs or Xeon Phis, the option defaults are neigh = half, neigh/qeq = half, newton = on, binsize = 0.0, and comm = no. The option neigh/thread = on when there are 16K atoms or less on an MPI diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 95ee7e39a8..19af61a209 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent # FFT library # see discussion in Section 3.5.2 of manual From bfb85d3cb43aa20092e54dfb93b3a1da41a15303 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:37:34 -0700 Subject: [PATCH 147/187] Fix typo in docs --- doc/src/Speed_kokkos.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Speed_kokkos.rst b/doc/src/Speed_kokkos.rst index da483567b3..e7724eb229 100644 --- a/doc/src/Speed_kokkos.rst +++ b/doc/src/Speed_kokkos.rst @@ -243,7 +243,7 @@ speedup (see the KOKKOS :doc:`package ` command). Using CUDA MPS is recommended in this scenario. Using a GPU-aware MPI library is highly recommended. GPU-aware MPI use can be -avoided by using :doc:`-pk kokkos gpu/aware no `. As above for +avoided by using :doc:`-pk kokkos gpu/aware off `. As above for multi-core CPUs (and no GPU), if N is the number of physical cores/node, then the number of MPI tasks/node should not exceed N. From d192a77763e3261fbe02bcfa9a8547e10b6072b4 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:47:41 -0700 Subject: [PATCH 148/187] Small tweaks --- src/KOKKOS/comm_kokkos.h | 2 -- src/KOKKOS/kokkos.cpp | 2 +- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 4 ---- src/MAKE/MACHINES/Makefile.summit_kokkos | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.h b/src/KOKKOS/comm_kokkos.h index d1cb388954..c5772bafe7 100644 --- a/src/KOKKOS/comm_kokkos.h +++ b/src/KOKKOS/comm_kokkos.h @@ -30,8 +30,6 @@ class CommKokkos : public CommBrick { bool reverse_comm_classic; bool exchange_comm_on_host; bool forward_comm_on_host; - bool forward_pair_comm_on_host; - bool forward_fix_comm_on_host; bool reverse_comm_on_host; CommKokkos(class LAMMPS *); diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 2f7f69afdc..ca5762f088 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -435,7 +435,7 @@ void KokkosLMP::accelerator(int narg, char **arg) int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "gpu/aware off" and "comm device", change to "comm classic" + // if "gpu/aware off" and "comm device", change to "comm no" if (!gpu_aware_flag && nmpi > 1) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index d0c8432af0..97a6fe5699 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -514,8 +514,6 @@ void PairMultiLucyRXKokkos::computeLocalDensity() // communicate and sum densities - atomKK->modified(execution_space,DPDRHO_MASK); - if (newton_pair) { comm->reverse_comm_pair(this); atomKK->sync(execution_space,DPDRHO_MASK); @@ -667,8 +665,6 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi template int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { - atomKK->sync(execution_space,DPDRHO_MASK); - d_sendlist = k_sendlist.view(); iswap = iswap_in; v_buf = buf.view(); diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 19af61a209..95ee7e39a8 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -48,7 +48,7 @@ MY_MPI_PATH = $(dir ${MY_MPI_EXE}) MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MY_MPI_PATH}../include MPI_PATH = -MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm -lopen-pal -lopen-rte -lhwloc_ompi -levent_core -levent_pthreads -levent +MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm # FFT library # see discussion in Section 3.5.2 of manual From 06596683c746a27ce830cf91890d9feda1e0f206 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 14:51:27 -0700 Subject: [PATCH 149/187] Add back in param --- src/KOKKOS/comm_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index e5016efef1..cb1c3c60a1 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -365,7 +365,7 @@ void CommKokkos::forward_comm_fix(Fix *fix, int size) { if (fix->execution_space == Host || !fix->forward_comm_device || forward_fix_comm_classic) { k_sendlist.sync(); - CommBrick::forward_comm_fix(fix); + CommBrick::forward_comm_fix(fix,size); } else { k_sendlist.sync(); forward_comm_fix_device(fix); From 4befc0fa565894f1bbfa8260e84b81b23f92e8be Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 15:25:40 -0700 Subject: [PATCH 150/187] Fix logic error --- src/KOKKOS/kokkos.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index ca5762f088..f42f0177df 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -397,14 +397,14 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if (strcmp(arg[iarg],"comm/fix/forward") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"no") == 0) forward_fix_comm_classic = 1; - if (strcmp(arg[iarg+1],"host") == 0) forward_fix_comm_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) forward_fix_comm_classic = 1; else if (strcmp(arg[iarg+1],"device") == 0) forward_fix_comm_classic = 0; else error->all(FLERR,"Illegal package kokkos command"); forward_fix_comm_changed = 0; iarg += 2; } else if (strcmp(arg[iarg],"comm/reverse") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); - if (strcmp(arg[iarg+1],"no") == 0) reverse_comm_classic = 1; + else if (strcmp(arg[iarg+1],"no") == 0) reverse_comm_classic = 1; else if (strcmp(arg[iarg+1],"host") == 0) { reverse_comm_classic = 0; reverse_comm_on_host = 1; From a02471967b5ce291a9f188c048469a0929dbb469 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 16:08:21 -0700 Subject: [PATCH 151/187] Tweak DELTA constant --- src/KOKKOS/atom_vec_angle_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_atomic_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_bond_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_charge_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_full_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 3 +-- src/KOKKOS/atom_vec_sphere_kokkos.cpp | 3 +-- src/KOKKOS/kokkos_type.h | 3 ++- 10 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 827929f1a4..b15fc2965b 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecAngleKokkos::AtomVecAngleKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -59,6 +57,7 @@ AtomVecAngleKokkos::AtomVecAngleKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecAngleKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index b25cefae34..013b55c959 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecAtomicKokkos::AtomVecAtomicKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -55,6 +53,7 @@ AtomVecAtomicKokkos::AtomVecAtomicKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecAtomicKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index 8908ad9b29..91d7dbef63 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecBondKokkos::AtomVecBondKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecBondKokkos::AtomVecBondKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecBondKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 6dd3880c20..698703371f 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecChargeKokkos::AtomVecChargeKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecChargeKokkos::AtomVecChargeKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecChargeKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index cd4bb76d05..8a733f66e4 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecDPDKokkos::AtomVecDPDKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -60,6 +58,7 @@ AtomVecDPDKokkos::AtomVecDPDKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecDPDKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 032b36ff4a..2c85e4129b 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecFullKokkos::AtomVecFullKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecFullKokkos::AtomVecFullKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecFullKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 779e977b09..35ed9160d2 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -33,8 +33,6 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) no_border_vel_flag = 1; } -static constexpr bigint DELTA=10; // much smaller than DELTA in atom_vec.cpp - /* ---------------------------------------------------------------------- roundup N so it is a multiple of DELTA error if N exceeds 32-bit int, since will be used as arg to grow() @@ -44,6 +42,7 @@ static constexpr bigint DELTA=10; // much smaller than DELTA in atom_vec.cpp bigint AtomVecKokkos::roundup(bigint n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; if (n % DELTA) n = n/DELTA * DELTA + DELTA; if (n > MAXSMALLINT) error->one(FLERR,"Too many atoms created on one or more procs"); diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index f54005e87a..20a748191c 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecMolecularKokkos::AtomVecMolecularKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecMolecularKokkos::AtomVecMolecularKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecMolecularKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index f5973c9ab9..22d10e4632 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -30,8 +30,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecSphereKokkos::AtomVecSphereKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -91,6 +89,7 @@ void AtomVecSphereKokkos::init() void AtomVecSphereKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 580b22d35f..72513d2b17 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -15,6 +15,7 @@ #define LMP_LMPTYPE_KOKKOS_H #include "pointers.h" +#include "lmptype.h" #include #include @@ -40,7 +41,7 @@ enum{FULL=1u,HALFTHREAD=2u,HALF=4u}; #endif #define MAX_TYPES_STACKPARAMS 12 -#define NeighClusterSize 8 +static constexpr LAMMPS_NS::bigint LMP_KOKKOS_AV_DELTA = 10; namespace Kokkos { using NoInit = ViewAllocateWithoutInitializing; From 2962fa561d409ccc395661c0505afd8c31fd842c Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Tue, 22 Dec 2020 21:08:07 -0700 Subject: [PATCH 152/187] Revert comm flags if pair/only is turned off --- src/KOKKOS/kokkos.cpp | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 85a1b9f4e8..00a17456b4 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -409,12 +409,25 @@ void KokkosLMP::accelerator(int narg, char **arg) #ifdef LMP_KOKKOS_GPU + if (pair_only_flag) { + lmp->suffixp = lmp->suffix; + lmp->suffix = new char[7]; + strcpy(lmp->suffix,"kk/host"); + } else { + // restore settings to regular suffix use, if previously, pair/only was used + if (lmp->suffixp) { + delete[] lmp->suffix; + lmp->suffix = lmp->suffixp; + lmp->suffixp = nullptr; + } + } + int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "cuda/aware off" and "comm device", change to "comm host" + // if "cuda/aware off" or "pair/only on", and "comm device", change to "comm host" - if (!gpu_aware_flag && nmpi > 1) { + if (!gpu_aware_flag && nmpi > 1 || pair_only_flag) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { exchange_comm_on_host = 1; exchange_comm_changed = 1; @@ -429,9 +442,9 @@ void KokkosLMP::accelerator(int narg, char **arg) } } - // if "cuda/aware on" and comm flags were changed previously, change them back + // if "cuda/aware on" or "pair/only off" and comm flags were changed previously, change them back - if (gpu_aware_flag) { + if (gpu_aware_flag && !pair_only_flag) { if (exchange_comm_changed) { exchange_comm_on_host = 0; exchange_comm_changed = 0; @@ -459,23 +472,6 @@ void KokkosLMP::accelerator(int narg, char **arg) neighbor->binsize_user = binsize; if (binsize <= 0.0) neighbor->binsizeflag = 0; else neighbor->binsizeflag = 1; - - if (pair_only_flag) { - lmp->suffixp = lmp->suffix; - lmp->suffix = new char[7]; - strcpy(lmp->suffix,"kk/host"); - - exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; - exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; - } else { - // restore settings to regular suffix use, if previously, pair/only was used. - if (lmp->suffixp) { - delete[] lmp->suffix; - lmp->suffix = lmp->suffixp; - lmp->suffixp = nullptr; - // TODO: restore communication settings - } - } } /* ---------------------------------------------------------------------- From 6fd7d584c2eebaa86ea7fbe94bcfc882697bd2db Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 23 Dec 2020 01:05:52 -0500 Subject: [PATCH 153/187] move release date --- doc/lammps.1 | 2 +- src/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lammps.1 b/doc/lammps.1 index f52bebab8e..cb4d0d9942 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "22 December 2020" "2020-12-22" +.TH LAMMPS "23 December 2020" "2020-12-23" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/src/version.h b/src/version.h index 33aa08f8df..afd6789991 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "22 Dec 2020" +#define LAMMPS_VERSION "23 Dec 2020" From ddfa5c3e87a767c128fa6d13b7ca4a5ff4f70be7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 23 Dec 2020 10:09:54 -0500 Subject: [PATCH 154/187] document pair/only keyword to package command --- doc/src/package.rst | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/src/package.rst b/doc/src/package.rst index 725536310a..b9bf56e46b 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -18,13 +18,16 @@ Syntax *gpu* args = Ngpu keyword value ... Ngpu = # of GPUs per node zero or more keyword/value pairs may be appended - keywords = *neigh* or *newton* or *binsize* or *split* or *gpuID* or *tpa* or *device* or *blocksize* + keywords = *neigh* or *newton* or *pair/only* or *binsize* or *split* or *gpuID* or *tpa* or *device* or *blocksize* *neigh* value = *yes* or *no* yes = neighbor list build on GPU (default) no = neighbor list build on CPU *newton* = *off* or *on* off = set Newton pairwise flag off (default and required) on = set Newton pairwise flag on (currently not allowed) + *pair/only* = *off* or *on* + off = apply "gpu" suffix to all available styles in the GPU package (default) + on - apply "gpu" suffix only pair styles *binsize* value = size size = bin size for neighbor list construction (distance units) *split* = fraction @@ -65,7 +68,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/reverse* or *cuda/aware* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/reverse* or *cuda/aware* or *pair/only* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -91,6 +94,9 @@ Syntax *cuda/aware* = *off* or *on* off = do not use CUDA-aware MPI on = use CUDA-aware MPI (default) + *pair/only* = *off* or *on* + off = use device acceleration (e.g. GPU) for all available styles in the KOKKOS package (default) + on = use device acceleration only for pair styles (and host acceleration for others) *omp* args = Nthreads keyword value ... Nthread = # of OpenMP threads to associate with each MPI process zero or more keyword/value pairs may be appended @@ -194,6 +200,14 @@ for compatibility with the package command for other accelerator styles. Note that the newton setting for bonded interactions is not affected by this keyword. +The *pair/only* keyword can change how any "gpu" suffix is applied. +By default a suffix is applied to all styles for which an accelerated +variant is available. However, that is not always the most effective +way to use an accelerator. With *pair/only* set to *on* the suffix +will only by applied to supported pair styles, which tend to be the +most effective in using an accelerator and their operation can be +overlapped with all other computations on the CPU. + The *binsize* keyword sets the size of bins used to bin atoms in neighbor list builds performed on the GPU, if *neigh* = *yes* is set. If *binsize* is set to 0.0 (the default), then bins = the size of the @@ -540,6 +554,13 @@ for OpenMPI 1.8 (or later versions), Mvapich2 1.9 (or later) when the "MV2_USE_CUDA" environment variable is set to "1", CrayMPI, and IBM Spectrum MPI when the "-gpu" flag is used. +The *pair/only* keyword can change how the KOKKOS suffix "kk" is applied +when using an accelerator device. By default device acceleration is +always used for all available styles. With *pair/only* set to *on* the +suffix setting will choose device acceleration only for pair styles and +run all other force computations concurrently on the host GPU. This can +result in better performance for certain configurations and system sizes. + ---------- The *omp* style invokes settings associated with the use of the From 37063ab61f20b20b63fce6b35b36397c105d0560 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 23 Dec 2020 09:22:27 -0700 Subject: [PATCH 155/187] Small tweaks --- doc/src/package.rst | 5 +++-- src/KOKKOS/kokkos.cpp | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/src/package.rst b/doc/src/package.rst index b9bf56e46b..339a1c7ca7 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -548,7 +548,7 @@ available (currently only possible with OpenMPI v2.0.0 or later), then the *cuda/aware* keyword is automatically set to *off* by default. When the *cuda/aware* keyword is set to *off* while any of the *comm* keywords are set to *device*\ , the value for these *comm* keywords will -be automatically changed to *host*\ . This setting has no effect if not +be automatically changed to *no*\ . This setting has no effect if not running on GPUs or if using only one MPI rank. CUDA-aware MPI is available for OpenMPI 1.8 (or later versions), Mvapich2 1.9 (or later) when the "MV2_USE_CUDA" environment variable is set to "1", CrayMPI, and IBM @@ -558,7 +558,8 @@ The *pair/only* keyword can change how the KOKKOS suffix "kk" is applied when using an accelerator device. By default device acceleration is always used for all available styles. With *pair/only* set to *on* the suffix setting will choose device acceleration only for pair styles and -run all other force computations concurrently on the host GPU. This can +run all other force computations concurrently on the host CPU. +The *comm* flags will also automatically be changed to *no*\ . This can result in better performance for certain configurations and system sizes. ---------- diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 00a17456b4..ff1b736bf0 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -425,36 +425,36 @@ void KokkosLMP::accelerator(int narg, char **arg) int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "cuda/aware off" or "pair/only on", and "comm device", change to "comm host" + // if "cuda/aware off" or "pair/only on", and "comm device", change to "comm no" - if (!gpu_aware_flag && nmpi > 1 || pair_only_flag) { + if ((!gpu_aware_flag && nmpi > 1) || pair_only_flag) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { - exchange_comm_on_host = 1; + exchange_comm_classic = 1; exchange_comm_changed = 1; } if (forward_comm_classic == 0 && forward_comm_on_host == 0) { - forward_comm_on_host = 1; + forward_comm_classic = 1; forward_comm_changed = 1; } if (reverse_comm_classic == 0 && reverse_comm_on_host == 0) { - reverse_comm_on_host = 1; + reverse_comm_classic = 1; reverse_comm_changed = 1; } } - // if "cuda/aware on" or "pair/only off" and comm flags were changed previously, change them back + // if "cuda/aware on" and "pair/only off", and comm flags were changed previously, change them back if (gpu_aware_flag && !pair_only_flag) { if (exchange_comm_changed) { - exchange_comm_on_host = 0; + exchange_comm_classic = 0; exchange_comm_changed = 0; } if (forward_comm_changed) { - forward_comm_on_host = 0; + forward_comm_classic = 0; forward_comm_changed = 0; } if (reverse_comm_changed) { - reverse_comm_on_host = 0; + reverse_comm_classic = 0; reverse_comm_changed = 0; } } From 9122b18c6f16a1298b8ccb00976a070ed1799e4a Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 23 Dec 2020 10:17:55 -0700 Subject: [PATCH 156/187] Updated README files --- examples/mliap/README | 54 +++++++++++++++++++++++-------------------- src/MLIAP/README | 22 ++++++++++-------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/examples/mliap/README b/examples/mliap/README index 2641bdc975..9d7d22b0c5 100644 --- a/examples/mliap/README +++ b/examples/mliap/README @@ -1,7 +1,7 @@ -This directory contains multipler examples of +This directory contains multiple examples of machine-learning potentials defined using the MLIAP package in LAMMPS. The input files -are descirbed below. +are described below. in.mliap.snap.Ta06A ------------------- @@ -21,58 +21,62 @@ Run EME-SNAP, equivalent to examples/snap/in.snap.InP.JCPA2020 in.mliap.snap.compute --------------------- -Generate gradients w.r.t. coefficients for linear SNAP, -equivalent to in.snap.compute +Generate the A matrix, the gradients (w.r.t. coefficients) +of total potential energy, forces, and stress tensor for +linear SNAP, equivalent to in.snap.compute in.mliap.quadratic.compute -------------------------- -Generate gradients w.r.t. coefficients for quadratic SNAP, -equivalent to in.snap.compute.quadratic +Generate the A matrix, the gradients (w.r.t. coefficients) +of total potential energy, forces, and stress tensor for +for quadratic SNAP, equivalent to in.snap.compute.quadratic in.mliap.pytorch.Ta06A ----------------------- This reproduces the output of in.mliap.snap.Ta06A above, but using the Python coupling to PyTorch. -It can be run in two different ways: + +This example can be run in two different ways: 1: Running a LAMMPS executable: in.mliap.pytorch.Ta06A -First run convert_mliap_Ta06A.py, which will convert the Ta06A potential -into a pytorch model. It will be saved as "Ta06A.mliap.pytorch.model.pkl". +First run ``python convert_mliap_Ta06A.py``. It creates +a PyTorch energy model that replicates the +SNAP Ta06A potential and saves it in the file +"Ta06A.mliap.pytorch.model.pt". -It will also copy "../../src/MLIAP/mliappy_pytorch.py" -file into the current working directory. mliappy_pytorch.py contains -class definitions suitable for wrapping an arbitrary PyTorch -energy model. It must be available to python when -creating or unpickling a PyTorch energy model. - -From that point you can run the example as follows +You can then run the example as follows `lmp -in in.mliap.pytorch.Ta06A -echo both` The resultant log.lammps output should be identical to that generated by in.mliap.snap.Ta06A. +If this fails, see the instructions for building the MLIAP package +with Python support enabled. Also, confirm that the +LAMMPS Python embedded Python interpreter is +working by running ../examples/in.python. + 2: Running a Python script: mliap_pytorch_Ta06A.py -Before testing this, ensure that the first example -(using LAMMPS executable) works. -Also, not all python installations support this mode of operation. -It requires that the Python interpreter be initialized. -To check this for your Python library, -try running the Py_IsInitialized() method. -If the return value is True, you should be able to run the example, -as follows: +Before testing this, ensure that the previous method +(running a LAMMPS executable) works. + +You can run the example in serial: `python mliap_pytorch_Ta06A.py` -or +or in parallel: `mpirun -np 4 python mliap_pytorch_Ta06A.py` The resultant log.lammps output should be identical to that generated by in.mliap.snap.Ta06A and in.mliap.pytorch.Ta06A. +Not all Python installations support this mode of operation. +It requires that the Python interpreter be initialized. If not, +the script will exit with an error message. + in.mliap.pytorch.relu1hidden ---------------------------- This example demonstrates a simple neural network potential diff --git a/src/MLIAP/README b/src/MLIAP/README index 9179d9d02f..59eb5e34b3 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -8,12 +8,15 @@ definitions of the interatomic potential functional form (*model*) and the geometric quantities that characterize the atomic positions (*descriptor*). By defining *model* and *descriptor* separately, it is possible to use many different models with a given descriptor, -or many different descriptors with a given model. Currently, the pair_style -supports just two models, *linear* and *quadratic*, -and one descriptor, *sna*, the SNAP descriptor, including the -linear, quadratic, and chem variants. Work is currently underway to extend -the interface to handle neural network energy models, -and it is also straightforward to add new descriptor styles. +or many different descriptors with a given model. The pair_style +supports the following models: *linear*, *quadratic*, and +*mliappy* (general Python interface to things like PyTorch, see below +for build instructions). +It currently supports only one class of descriptors, +*sna*, the SNAP descriptors, including the +linear, quadratic, and chem variants. +It is straightforward to add new descriptor and model +styles. The mliap compute style provides gradients of the energy, force, and stress tensor w.r.t. model parameters. @@ -27,13 +30,13 @@ reference potential. To see how this command can be used within a Python workflow to train machine-learning interatomic -potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP>. +potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP. *Additional instructions for building MLIAP with Python support enabled* The *mliappy* energy model requires that the MLIAP package be compiled with Python support enabled. -This extension written by Nick Lubbers (LANL) +This extension, written by Nick Lubbers (LANL), provides a coupling to PyTorch and other Python modules. This should be automatically enabled by default if the prerequisite software is installed. It can be @@ -51,5 +54,4 @@ file(s) in the src/MLIAP folder or there may be problems during compilation. More information on building LAMMPS with this package is here: -https://lammps.sandia.gov/doc/html/Build_extras.html#mliap - +https://lammps.sandia.gov/doc/Build_extras.html#mliap From 780c31c5f7c77fa2846ad771875da041b5598cb4 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 23 Dec 2020 12:22:44 -0700 Subject: [PATCH 157/187] Updated PyTorch ReLU example to latest --- examples/mliap/README | 23 +++++++++++++++--- examples/mliap/relu1hidden.mliap.pytorch | 2 +- .../mliap/relu1hidden.mliap.pytorch.model.pkl | Bin 4059 -> 0 bytes .../mliap/relu1hidden.mliap.pytorch.model.pt | Bin 0 -> 11506 bytes 4 files changed, 21 insertions(+), 4 deletions(-) delete mode 100644 examples/mliap/relu1hidden.mliap.pytorch.model.pkl create mode 100644 examples/mliap/relu1hidden.mliap.pytorch.model.pt diff --git a/examples/mliap/README b/examples/mliap/README index 9d7d22b0c5..af848e42ba 100644 --- a/examples/mliap/README +++ b/examples/mliap/README @@ -80,7 +80,24 @@ the script will exit with an error message. in.mliap.pytorch.relu1hidden ---------------------------- This example demonstrates a simple neural network potential -using PyTorch and SNAP descriptors. It uses a ReLU activation -function with just 1 hidden layer. - +using PyTorch and SNAP descriptors. + `lmp -in in.mliap.pytorch.relu1hidden -echo both` + +It was trained on just the energy component (no forces) of +the data used in the original SNAP Ta06A potential for +tantalum (Thompson, Swiler, Trott, Foiles, Tucker, +J Comp Phys, 285, 316 (2015).). Because of the very small amount +of energy training data, it uses just 1 hidden layer with +a ReLU activation function. It is not expected to be +very accurate for forces. + +NOTE: Unlike the previous example, this example uses +a pre-built PyTorch file `Ta06A.mliap.pytorch.model.pt`. +It is read using `torch.load`, +which implicitly uses the Python `pickle` module. +This is known to be insecure. It is possible to construct malicious +pickle data that will execute arbitrary code during unpickling. Never +load data that could have come from an untrusted source, or that +could have been tampered with. Only load data you trust. + diff --git a/examples/mliap/relu1hidden.mliap.pytorch b/examples/mliap/relu1hidden.mliap.pytorch index a2271cee39..32ac4c85a3 100644 --- a/examples/mliap/relu1hidden.mliap.pytorch +++ b/examples/mliap/relu1hidden.mliap.pytorch @@ -11,7 +11,7 @@ variable zblz equal 73 pair_style hybrid/overlay & zbl ${zblcutinner} ${zblcutouter} & -mliap model mliappy relu1hidden.mliap.pytorch.model.pkl & +mliap model mliappy relu1hidden.mliap.pytorch.model.pt & descriptor sna Ta06A.mliap.descriptor pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff * * mliap Ta diff --git a/examples/mliap/relu1hidden.mliap.pytorch.model.pkl b/examples/mliap/relu1hidden.mliap.pytorch.model.pkl deleted file mode 100644 index 49e70ca1a4f00345b5ce4ab4afb4d1e7549bba38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4059 zcmds4`+pSG6`v%Vg{(kCl&8gMDHyE8JbB0?Lj)9;=kQvJbf1&Vz-D&O%q$_0z((98 zAo36ev{p9(tQJ069#PQ94unTPBFaM%KDM$*v85mM^J(cv>4ScH&zYfwTK)i=ANHH` zxaWTFx#!+FH=Y%&3M>9-w8k5)F(O(}cFn}!IU3VR+RzdgaD(e1qYg6jJe@g?Gc>=V zDrzNUHF@q}vN!72{8f@6X*xK9!ALkP1q~&l>aM9;NYbRxI3;MfAbYR~P72@+#40M# zyOWH{&Ypf4MUALlHlMEOhNK!de7w43Ku$0aQ^JPALNd_>uK93B0=kIM)su@u1ODK` zYQGlp%8|%I9lBB2Tu(Q&RYbH7raQ^h-E&t*Q&f}ek#~`~ho?K5b;EB+-Vh^iTkj_8 zJ)XX34M+T;jxINY^dz@l)>5k?p;%bbp*Jb}c(U18rjx?Z_d98ySgA%dX?$3!(p}Jx z<^0|{_(7hW)g(J;bbr}O*nM)2%u>K7;D;joNVb+cK(^NQW7%57K-r=@NVfRgFIyDy zJWfVIj|Ehg*ug>C@O)Lxw~6KlBdWpnSJGTFB#5z{Q2b#RJiyreqz)eJz-EZeCf{Q7 zPyz}>D74uW*=&k!HYGNjQk%_Co6WF1PX?n?0K>n_B+OX&HP<8yU<9M^a2<^7Kw*@% zm}*I>lnoedhw#P>C9J!=nuJvox>=qs7;_sJR&jbn^DZiKL0O*dqqEfbD=HThdEMdhk!je}~LyBL8%qEYEDUF(_z>!ClqRSD@fNXcBCyTi# zssT>7!{fjh5q1DOxgD_>n={YTiK%SDz*!4$jf=zrVQGfF49KAKFrs*PQE5SONzsU* zLx&ZC6*w4;L6&>Z6ayU7S-APY{V(4PfBqgejs3@;zrMGO{hzG8wu$hA%b%xEUi^uP zGI#C3MMNRo`abD@{)-P$Hu;(Dh{;vl$EY_$*(XW<%h@A{!nr2$OXnYIM%kB|+lt7K z3nUQJy~n;qe#`#wG2z%XG>+%yyqRM5c&^-znC{>H9-=w&;xR;_^}ePu!Yi#PbG6qF zqnsXcoZ^|~?v1E7&tKb)dULS$F3QP?Ija$U<2^eO)6I*2P5Skh4mNY7bH>*xP`nt1vy4mpB;eDS3Nh`x#skCOaE=~hH@ z){fnX@tiq3%NTM?`?VqRGioTF@AG^2qn+zLoA~(t(MJBqEOa5{X+W8{Y%FA2x_o19#nQ86gk?Q>@C!3oulK+-oXUIPJ?_VGa#;25b z-+K?ACizqo?Wg(m3EFpltZ)JKz9qaBPZ@avW%H>G#9LUlIf*jAt8G<^VfsQ#BVzpU z@=sBpoR>>+&Cx~Hx@+nwU*_V3wNGuQ51~IV?tT&d&Ct5n5!2lqucBVa?%INK{IjcD z37_ftCZgcDpX!&tzK`~c^VV)d|M==%R=ss^I*+p1u;Cc`b8zeujXVF<2Gk3!4OFM` z_7$|=q`vJ8=^YyJqTMB@uPQ08d^UWP!Z`eIccEQ)XxZC{>Ao*pd5wNE8}0Eg6IMQR#~&oQWHr@^ z5FBOQ2kom5<2a6Y?k03pQC{LDP79aUTI2R`R6ks4fbzr*D}Dvz2?I9lLNvFi6py>- zPZpnzJyWQUU*%|B!l1ue^Khdl&^#C4Z$^8X%iM>^^)ynb_xfh4Kg4m-+kskt--3QSe_M zIp^&@a<(t~$YFnE|M8_cbjY~@e!6_jG274KrX^e6`2f+pbn+CU@42mqQ!qIJQ$(1G zNl(BucSZuHTL~8pm?6SUE8(*mVYUc!Vs`uFvD&A(3HYf9^X&HN3A=roZ?{iBv)d=H z-9Gv3_Q_8TxT1P1B)<{USnm*U_xE&Rj3P1PrZVVu#sbu66+*~vZ#uMme%7up@?*>H z5~WGATp+PltD+7nJG5G|O;@q#E=a&a5yCdzDx0oq(~a14qc&Zz>1x!cC~7q94@#h~ zv`H0#A!BzJtAj-yrmW7BNB{rSVsS}fY3Z#E*KKRj_PwP2`` z{?EC0eBaOgu!6$U!h(`pn%j)qockNTEZ6uDx$$@5N?RGMNWfDfBrt~wXuzLFD}PM} ztQ29DmA|JOVYLX)+&Ir`tOK$(0qaCqZy%6n?E|vGJ|NH82jqGCfNZo6$R;`9cFI9_ zMl2AE1=u4^r&lC<7~>OLht2K-^ny^mAxRHvN|ZJCI=sNnJU$^*uf*Pt?8&CXix?vR E-*|c0EdT%j diff --git a/examples/mliap/relu1hidden.mliap.pytorch.model.pt b/examples/mliap/relu1hidden.mliap.pytorch.model.pt new file mode 100644 index 0000000000000000000000000000000000000000..ecc04341a7aa40df2258925e3eeeb34b3dbef19d GIT binary patch literal 11506 zcmb_C33MFAm1A2Lcmg>{aj2f&U{sq$EBW3WbVx z!7ZcV1xxBHbA<=+13RXWqs;8k;0-8#q5r*=GOev@HP&%jO^F>F^=S;1r z7Khw|oi@T7@c$LIRxIjvn9oXF0xM#grKJm2Mr)7h)_@apEUnnSIF>W}VzA68SncZK zm}9znb5Tog(fV~KCUD0HHv%D6puuM+9s{<3wBxWKDMdh7mb!}Ai*$w={4#o$C6lIQ zy2+&C=(%i^0sDF`Y9%weleWzwtaG5J=k&a8x%gPrY%T9}tu9!4G@}ogXCeUv*bIu8YDsx>wClhI%q*+Qg_#aR(Fpkp#LS=V zVreaxPFA56+I0XE@lc(GT~!}z8L80@K?Srm6||~4f~$6fpiuqUg1uF6UKy4}n5G^gaw=mTI>P`J`3K7l#yoHi9xGady$}=rJlaB8P-P zRa@sJ)7G72zpZ7G$_Bfn`zj#T>XD*}02RRtp3J&bSTk$&cd^xU4avP$atlaU)h(?L z90NWp!5yPEg&dNW1)R`!NP~gxf~Zi2KHsCVLK9`nt_qD0cSN`EWv-F&xooy zc)}E`s8&z6X9|Ltz~U1=ay)#F%Ny23w)43oyirLU4L&j12d)lWGe0UVwg;|D4mql8 zSXMaMue(WnN@hz|+6C8MT@&UzNg1 z+70thz=C5W;Zin>(8n4$cwAzBl^Z-JNuyBM;_&%2_sPU@I44h#oI0MSK9%@XaH?qQ za{2_C{&eDaoOWEz)sq?EK+b-KW=~9ruvfvjC5aNx)Pocq6DPWON z^3xP!hA4D#zg4jHm1wA8{#j#o;w2y`qDElqh=Ybx>a%qB(B2+R7JqbT!~#4*v~mV- z!{~r;a z@W(7GCh^BS{21pypSWvYRbxImWmPb^+ozv?dN+uu$_z$6!J$egR{%R~tC`Ee;b&SV zqh~NInl3Xf<{COH;2FWEA*R_nD?(ZUAaWAWIS?XH5&~g&4vv|nx#obL8;U}(73*OI znm8+DF&?9>LJ+i=mU9Y7)6aTMgc-WM)`^h~)x_cpAT(BO>gA;rlMd%Q(^V zMA_Mz-S13uRlfeC~isv8>69U%N#abz!G{L;kGSfQEKyZx)6%ZhWcpzA? zEjpYIaTM?@AwF28LV}-nFyW}utG47a;dCa&8YQsaPc!tKGbQOnQf6i_NJ@ubuG_fekT3!S3U(A}2Q~vbxlo6!8@vikG=r7m zT0EaLBv+y4ylq1j2B#B6juP;<3hQCK00jjSQcds;gT$q`6ch4-%bKx}W9M}tMRp#; zUhS4`&2)5jF(O!L+XY)`B4liM1RYEPDhS}u)~tTLNdg5XA-=^OQI%hwH9I3@>J zkWrdPvI&@(PYED>I>f|$-97nbxDC%kD@338XL}-_VkswbyOvl|Mk4ASmke7 zF4%}04M>%S<*|lm)pRmuzv(KG%~Q`ELi!d5C<5iJX%$PsJQWG}j#${6=sRlFhHDi@ z7+^!v6$^w@S)kD{kGi}WlTdYp$3#`*g2S;O8{sWu)2fqJN>JNsi;#92T$nfw3jzyD z9B_IL9AZc>lYOF4Ny3rh9qAv$g%uN{khh4ON;)>^5gXoO)R>g8BIHs_I9g9yk(A0d zz_x@}#9h|l!z*N{cOebRuq@mHRtaoEdxtB};mbyp=1mT_-Qg`GKtMi4z}`sZHOM4$ zTTn1rTT2hOjttjPU_gVyoY@q4;OGp(sPb1=0I=5@eo$a=R5~$Accu_)3e&@?p^GEq z3kHs8tuUq`lN&s&aO%h=pu8iH4^ft-uoEnhmo8n(@*rQRY^8&P>Wj6v_;DB^gs-XI z?t*{ISW0W#k|=AN0tg0#whduXp*6K=iZ;A5Q3Q;Nsj?#LG~5i`bExZabR*$zZ`mxC zS8D-CW$~s#gVztqB+%H{gerj25t4Q9IAa$m_I1#dCso!ka+c2KSaS3<7s ziz6UlNSbh4{)SNM#0Cx@8SVhO=_x7Uvh{vUOKktXRjH~8Ux)YxA)z7e_@I!%`xzUA zyxKWj5y(YRm+BVH#HgAqStf>DQ8uYUTyXQ$g>FYhC!=%(cn4AV8;28&v2FUxnyhBQ zE3qg;TO(pgd}mXFBwbI6xg?wfdIb54a!OG4cZo9YE5NN4;AmwrxY4TeBQVrL5|!Gm zpl+h9nQ(wzBC3Fl4xQD?Z2baNWG3QB3e)vOly|> z9<)CipaV2K;#JF@IeSJIFjC1<5Q!Wj%M2*ULjza47rXot%&L1v_@#=`GG>Uxd6l@L z6^h`i<^623S^p*u!CRT zv!G|z4t~Y;l

6eq}HJ!WeZn?&O<#`DS{zj6&dFG}aivhOy3=N@YoFOWQ)8G&b}! z0`?SPALUxltWn-4FsEIf>E*h>oZZR$d%00EL`h*99R^egSB>&5y*y`#Y9Mcj)Za2h zj$bfDHeWPEy3P%eq1#lv1T@K=o&||xKvF?na<`|k)JM5|D=*c}VPPz{-6tQlA9CL_eMC~AMxUiTo zt!9E$Ss=}p8N2YDN0MiI`E{zAS>q*rAhix8)ZU4M`vNbu_6F-`%$Uv1koF2DRh5}} zI7ppP)6mBSPRv(RlBS#(N>43X{bI>sk{8mY?@VV(TH0zsz)Gj2D}oqf-5_gxnSdWV zh&m3^=kt*Yyf!vmx9D`nVwyc@4yXmYKc@9LvDQT`?P^O$TT9@rav;4rVh+`k<-n^N z9TK6LvMZ4*rQsG*sU}*{ywWUEE*a-$&YA!Wt*z-$nGr#Bk!1zkzes^_C&EA1y&b2B zB56?MBwRwUn1vl-%))E_YQ&P*#76?Mb42k9I#-YI;Xu&YCcWv1@TS*{@@so}S$fm$(wlxsdeiHqH~q5orlZoE z?w}YW$?=`nOP|@s$BYYskA| z{vCnvyF2+^z5MQKpcxmU*)_^{_wswBXzrDwxlfAbekq#oNzptYMf0HH^fVf7&#Y2k zsnqAtZIO3}_Rts%84r!oS6AZGApY=bdjCz|nD9L^T+8nj!u;U?#KZXpz2VR@;qcZ#+AQFC{LBxZ!b+*hgp?{B_as~&$|)Z)XK!; z*iP;me2m6#eV^nKpKlVK$xq)$>&nkvGO!HceslaDgbQW%K1u!Mchf#5uNbENvwwS? z_)NXq`~t$U_V*58o67$DMe1+rxEI^XWqU{;<#|^;z6|=I;nVhG%hnGOzSM6&`wYT` zPQIM@N&WYJf)AZ_t_o+zOeNf?2qr-^)A8RbJ80$zv{n!hi%;bHOW2oW52TFwwDk-#9w-k*1i3Q+i*O-ZwJ|F`QUZ5-*M-@H)y=U zCVttSYsoIhdq1H4S3dp|(W^Y(NAs!QPm&#l<~=L){>a%RmvJTYk4Pu==Z_vne3jyL z!d{L)@End$HeU87jKkGjPolw^WMCaX~?!x)W(CnwN4V~yt;CSkPzd`Fl zU%Kg=G`{(I%s5qvy+D#@vQ>>~0f Date: Wed, 23 Dec 2020 14:23:39 -0500 Subject: [PATCH 158/187] add support for plumed version 2.7.0 and make it default --- cmake/Modules/Packages/USER-PLUMED.cmake | 4 ++-- lib/plumed/Install.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake index 74add65cdc..53abf5771a 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -55,8 +55,8 @@ if(DOWNLOAD_PLUMED) endif() include(ExternalProject) ExternalProject_Add(plumed_build - URL https://github.com/plumed/plumed2/releases/download/v2.6.1/plumed-src-2.6.1.tgz - URL_MD5 89a9a450fc6025299fe16af235957163 + URL https://github.com/plumed/plumed2/releases/download/v2.7.0/plumed-src-2.7.0.tgz + URL_MD5 95f29dd0c067577f11972ff90dfc7d12 BUILD_IN_SOURCE 1 CONFIGURE_COMMAND /configure --prefix= ${CONFIGURE_REQUEST_PIC} diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index 33bb40c9d9..c11d5bfee9 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -17,7 +17,7 @@ parser = ArgumentParser(prog='Install.py', # settings -version = "2.6.1" +version = "2.7.0" mode = "static" # help message @@ -49,6 +49,7 @@ checksums = { \ '2.5.4' : 'f31b7d16a4be2e30aa7d5c19c3d37853', \ '2.6.0' : '204d2edae58d9b10ba3ad460cad64191', \ '2.6.1' : '89a9a450fc6025299fe16af235957163', \ + '2.7.0' : '95f29dd0c067577f11972ff90dfc7d12', \ } # parse and process arguments From c6fb9c3836c127fdac0b8284020dcc48f304cfdc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 23 Dec 2020 15:13:38 -0500 Subject: [PATCH 159/187] update supported version test in fix plumed for new version --- src/USER-PLUMED/fix_plumed.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index ed7f05f2ae..1fc19a7724 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -78,9 +78,9 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : int api_version=0; p->cmd("getApiVersion",&api_version); - if ((api_version < 5) || (api_version > 7)) + if ((api_version < 5) || (api_version > 8)) error->all(FLERR,"Incompatible API version for PLUMED in fix plumed. " - "Only Plumed 2.4.x, 2.5.x, and 2.6.x are tested and supported."); + "Only Plumed 2.4.x, 2.5.x, 2.6.x, 2.7.x are tested and supported."); #if !defined(MPI_STUBS) // If the -partition option is activated then enable From 8e6b89cc81dbc4f0ae387a32826ada464f074051 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 23 Dec 2020 15:14:00 -0500 Subject: [PATCH 160/187] fix multiplication issue in shake stats --- src/RIGID/fix_shake.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 98700403b6..61ba36ea2b 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -2542,13 +2542,13 @@ void FixShake::stats() const auto bcnt = b_count_all[i]/2; if (bcnt) mesg += fmt::format("{:>6d} {:<9.6} {:<11.6} {:>8d}\n",i, - b_ave_all[i]/bcnt,b_max_all[i]-b_min_all[i],bcnt); + b_ave_all[i]/bcnt/2.0,b_max_all[i]-b_min_all[i],bcnt); } for (i = 1; i < na; i++) { const auto acnt = a_count_all[i]/3; if (acnt) mesg += fmt::format("{:>6d} {:<9.6} {:<11.6} {:>8d}\n",i, - a_ave_all[i]/acnt,a_max_all[i]-a_min_all[i],acnt); + a_ave_all[i]/acnt/3.0,a_max_all[i]-a_min_all[i],acnt); } utils::logmesg(lmp,mesg); } From ddeae8a3ba15cf81fa3094f15fb874ac6f8caa7e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 23 Dec 2020 20:15:52 -0500 Subject: [PATCH 161/187] step version string one more time --- doc/lammps.1 | 2 +- src/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lammps.1 b/doc/lammps.1 index cb4d0d9942..299f8538b0 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "23 December 2020" "2020-12-23" +.TH LAMMPS "24 December 2020" "2020-12-24" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/src/version.h b/src/version.h index afd6789991..f812b62821 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "23 Dec 2020" +#define LAMMPS_VERSION "24 Dec 2020" From 4382529158ec0a1fcdb9727b11dfdb4c345880b0 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 24 Dec 2020 10:28:52 -0700 Subject: [PATCH 162/187] Fix sync/modify issues in fix_qeq --- src/KOKKOS/atom_vec_charge_kokkos.cpp | 4 ++-- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 698703371f..6bfe227c9e 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -1131,7 +1131,7 @@ void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned perform_async_copy(atomKK->k_mask,space); if ((mask & IMAGE_MASK) && atomKK->k_image.need_sync()) perform_async_copy(atomKK->k_image,space); - if ((mask & MOLECULE_MASK) && atomKK->k_q.need_sync()) + if ((mask & Q_MASK) && atomKK->k_q.need_sync()) perform_async_copy(atomKK->k_q,space); } else { if ((mask & X_MASK) && atomKK->k_x.need_sync()) @@ -1148,7 +1148,7 @@ void AtomVecChargeKokkos::sync_overlapping_device(ExecutionSpace space, unsigned perform_async_copy(atomKK->k_mask,space); if ((mask & IMAGE_MASK) && atomKK->k_image.need_sync()) perform_async_copy(atomKK->k_image,space); - if ((mask & MOLECULE_MASK) && atomKK->k_q.need_sync()) + if ((mask & Q_MASK) && atomKK->k_q.need_sync()) perform_async_copy(atomKK->k_q,space); } } diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index 5383fc47e2..535a4cd555 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -51,8 +51,8 @@ FixQEqReaxKokkos(LAMMPS *lmp, int narg, char **arg) : atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; - datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | Q_MASK | TYPE_MASK | TAG_MASK; - datamask_modify = Q_MASK | X_MASK; + datamask_read = X_MASK | V_MASK | F_MASK | Q_MASK | MASK_MASK | TYPE_MASK | TAG_MASK; + datamask_modify = X_MASK; nmax = m_cap = 0; allocated_flag = 0; @@ -81,7 +81,6 @@ FixQEqReaxKokkos::~FixQEqReaxKokkos() template void FixQEqReaxKokkos::init() { - atomKK->modified(Host,Q_MASK); atomKK->sync(execution_space,Q_MASK); FixQEqReax::init(); @@ -1009,13 +1008,11 @@ void FixQEqReaxKokkos::calculate_q() // q[i] = s[i] - u * t[i]; FixQEqReaxKokkosCalculateQFunctor calculateQ_functor(this); Kokkos::parallel_for(inum,calculateQ_functor); + atomKK->modified(execution_space,Q_MASK); pack_flag = 4; //comm->forward_comm_fix( this ); //Dist_vector( atom->q ); - atomKK->modified(execution_space,Q_MASK); comm->forward_comm_fix(this); - atomKK->sync(execution_space,Q_MASK); - } /* ---------------------------------------------------------------------- */ @@ -1379,6 +1376,9 @@ void FixQEqReaxKokkos::unpack_forward_comm_fix_kokkos(int n, int fir first = first_in; d_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); + + if (pack_flag == 4) + atomKK->modified(execution_space,Q_MASK); // needed for auto_sync } template From a4897d38b9b785dd3756c70859797267caa3ea3f Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 24 Dec 2020 10:36:24 -0700 Subject: [PATCH 163/187] Tweak sync/modify in pair_multi_lucy_rx_kokkos --- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 97a6fe5699..6a48a0206a 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -514,10 +514,8 @@ void PairMultiLucyRXKokkos::computeLocalDensity() // communicate and sum densities - if (newton_pair) { + if (newton_pair) comm->reverse_comm_pair(this); - atomKK->sync(execution_space,DPDRHO_MASK); - } comm->forward_comm_pair(this); atomKK->sync(execution_space,DPDRHO_MASK); @@ -665,6 +663,8 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi template int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { + atomKK->sync(execution_space,DPDRHO_MASK); + d_sendlist = k_sendlist.view(); iswap = iswap_in; v_buf = buf.view(); @@ -687,6 +687,8 @@ void PairMultiLucyRXKokkos::unpack_forward_comm_kokkos(int n, int fi first = first_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); + + atomKK->modified(execution_space,DPDRHO_MASK); // needed for auto_sync } template From 5dc868ec3051a87b62049adb33b64744966363f2 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 28 Dec 2020 09:37:13 -0500 Subject: [PATCH 164/187] whitespace --- .gitignore | 1 - python/lammps/core.py | 2 -- python/lammps/mliap/__init__.py | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 92fae19766..0f1b01775d 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,3 @@ Thumbs.db /Makefile /cmake_install.cmake /lmp - diff --git a/python/lammps/core.py b/python/lammps/core.py index a75a02e358..161583b78c 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -1670,5 +1670,3 @@ class lammps(object): computeid = computeid.encode() idx = self.lib.lammps_find_compute_neighlist(self.lmp, computeid, request) return idx - - diff --git a/python/lammps/mliap/__init__.py b/python/lammps/mliap/__init__.py index 06c127055e..0d63cc810b 100644 --- a/python/lammps/mliap/__init__.py +++ b/python/lammps/mliap/__init__.py @@ -10,4 +10,4 @@ if not pylib.Py_IsInitialized(): raise RuntimeError("This interpreter is not compatible with python-based mliap for LAMMPS.") del sysconfig, ctypes, library, pylib -from .loader import load_model, activate_mliappy \ No newline at end of file +from .loader import load_model, activate_mliappy From 086ac30267ea2b0d6fe59df1afc47380dccb9b61 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 10:21:14 -0500 Subject: [PATCH 165/187] whitespace --- doc/src/Build_extras.rst | 2 +- src/MLIAP/README | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 78165f0150..f82c6c8d04 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -807,7 +807,7 @@ compiling LAMMPS with Python version 3.6 or later. the ``cythonize`` command in case the corresponding .pyx file(s) were modified. You may need to modify ``lib/python/Makefile.lammps`` if the LAMMPS build fails. - To manually enforce building MLIAP with Python support enabled, + To manually enforce building MLIAP with Python support enabled, you can add ``-DMLIAP_PYTHON`` to the ``LMP_INC`` variable in your machine makefile. You may have to manually run the ``cythonize`` command on .pyx file(s) diff --git a/src/MLIAP/README b/src/MLIAP/README index 59eb5e34b3..1ff1e250c5 100644 --- a/src/MLIAP/README +++ b/src/MLIAP/README @@ -9,13 +9,13 @@ and the geometric quantities that characterize the atomic positions (*descriptor*). By defining *model* and *descriptor* separately, it is possible to use many different models with a given descriptor, or many different descriptors with a given model. The pair_style -supports the following models: *linear*, *quadratic*, and +supports the following models: *linear*, *quadratic*, and *mliappy* (general Python interface to things like PyTorch, see below for build instructions). -It currently supports only one class of descriptors, +It currently supports only one class of descriptors, *sna*, the SNAP descriptors, including the -linear, quadratic, and chem variants. -It is straightforward to add new descriptor and model +linear, quadratic, and chem variants. +It is straightforward to add new descriptor and model styles. The mliap compute style provides gradients of the energy, force, @@ -37,7 +37,7 @@ potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP. The *mliappy* energy model requires that the MLIAP package be compiled with Python support enabled. This extension, written by Nick Lubbers (LANL), -provides a coupling to PyTorch and other Python modules. +provides a coupling to PyTorch and other Python modules. This should be automatically enabled by default if the prerequisite software is installed. It can be enforced during CMake configuration by setting the variable From 76cb49d0a0001832ceb8f3576ddb33e372369210 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 10:31:35 -0500 Subject: [PATCH 166/187] silence compiler warnings --- src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp | 2 +- src/USER-OMP/npair_half_size_multi_newton_omp.cpp | 2 +- src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp | 2 +- src/npair_half_size_multi_newtoff.cpp | 2 +- src/npair_half_size_multi_newton.cpp | 2 +- src/npair_half_size_multi_newton_tri.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp index 33722eb9d3..415bfd3323 100644 --- a/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newtoff_omp.cpp @@ -48,7 +48,7 @@ void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp index 0be87457e3..e4914fd9bd 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newton_omp.cpp @@ -47,7 +47,7 @@ void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp index ef26a5f2bd..ce54c4135f 100644 --- a/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp +++ b/src/USER-OMP/npair_half_size_multi_newton_tri_omp.cpp @@ -47,7 +47,7 @@ void NPairHalfSizeMultiNewtonTriOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index 813a642b96..d57542f562 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -35,7 +35,7 @@ NPairHalfSizeMultiNewtoff::NPairHalfSizeMultiNewtoff(LAMMPS *lmp) : NPair(lmp) { void NPairHalfSizeMultiNewtoff::build(NeighList *list) { - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp index 943965ab63..01065876af 100644 --- a/src/npair_half_size_multi_newton.cpp +++ b/src/npair_half_size_multi_newton.cpp @@ -34,7 +34,7 @@ NPairHalfSizeMultiNewton::NPairHalfSizeMultiNewton(LAMMPS *lmp) : NPair(lmp) {} void NPairHalfSizeMultiNewton::build(NeighList *list) { - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index e59a3f088a..361c0ba260 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -33,7 +33,7 @@ NPairHalfSizeMultiNewtonTri::NPairHalfSizeMultiNewtonTri(LAMMPS *lmp) : NPair(lm void NPairHalfSizeMultiNewtonTri::build(NeighList *list) { - int i,j,k,m,n,itype,jtype,ibin,ns; + int i,j,k,n,itype,jtype,ibin,ns; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutdistsq; int *neighptr,*s; From fec52f6a48e46dda23b24fdb012627f312620f2e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 10:40:39 -0500 Subject: [PATCH 167/187] make CMake script formatting more consistent --- cmake/CMakeLists.txt | 10 +++++----- cmake/Modules/CodingStandard.cmake | 2 +- cmake/Modules/MPI4WIN.cmake | 2 +- unittest/c-library/CMakeLists.txt | 2 +- unittest/formats/CMakeLists.txt | 6 +++--- unittest/python/CMakeLists.txt | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 12b713f15c..c29fba5957 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -25,7 +25,7 @@ set(LAMMPS_POTENTIALS_DIR ${LAMMPS_DIR}/potentials) find_package(Git) # by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE ) endif() @@ -33,7 +33,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) # make sure LIBRARY_PATH is set if environment variable is set -if (DEFINED ENV{LIBRARY_PATH}) +if(DEFINED ENV{LIBRARY_PATH}) list(APPEND CMAKE_LIBRARY_PATH "$ENV{LIBRARY_PATH}") message(STATUS "Appending $ENV{LIBRARY_PATH} to CMAKE_LIBRARY_PATH: ${CMAKE_LIBRARY_PATH}") endif() @@ -580,7 +580,7 @@ add_dependencies(lammps gitversion) ############################################ get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) list (FIND LANGUAGES "Fortran" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h @@ -737,14 +737,14 @@ if(OPTIONS) endif() get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) list (FIND LANGUAGES "Fortran" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER} Type: ${CMAKE_Fortran_COMPILER_ID} Version: ${CMAKE_Fortran_COMPILER_VERSION} Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") endif() list (FIND LANGUAGES "C" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) message(STATUS "C compiler: ${CMAKE_C_COMPILER} Type: ${CMAKE_C_COMPILER_ID} Version: ${CMAKE_C_COMPILER_VERSION} diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 72b064af66..646bdcdd4a 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -8,7 +8,7 @@ else() find_package(Python3 COMPONENTS Interpreter QUIET) endif() -if (Python3_EXECUTABLE) +if(Python3_EXECUTABLE) if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) add_custom_target( check-whitespace diff --git a/cmake/Modules/MPI4WIN.cmake b/cmake/Modules/MPI4WIN.cmake index 035c6a22f3..529cefeab0 100644 --- a/cmake/Modules/MPI4WIN.cmake +++ b/cmake/Modules/MPI4WIN.cmake @@ -1,7 +1,7 @@ # Download and configure custom MPICH files for Windows message(STATUS "Downloading and configuring MPICH-1.4.1 for Windows") include(ExternalProject) -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ExternalProject_Add(mpi4win_build URL https://download.lammps.org/thirdparty/mpich2-win64-devel.tar.gz URL_MD5 4939fdb59d13182fd5dd65211e469f14 diff --git a/unittest/c-library/CMakeLists.txt b/unittest/c-library/CMakeLists.txt index 09717c058e..121c42f7fd 100644 --- a/unittest/c-library/CMakeLists.txt +++ b/unittest/c-library/CMakeLists.txt @@ -56,7 +56,7 @@ target_link_libraries(test_library_config PRIVATE lammps GTest::GTest GTest::GMo target_compile_definitions(test_library_config PRIVATE ${TEST_CONFIG_DEFS}) add_test(LibraryConfig test_library_config) -if (BUILD_MPI) +if(BUILD_MPI) add_executable(test_library_mpi test_library_mpi.cpp) target_link_libraries(test_library_mpi PRIVATE lammps GTest::GTest GTest::GMock) target_compile_definitions(test_library_mpi PRIVATE ${TEST_CONFIG_DEFS}) diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 72cd81357b..3c1ed66c06 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(test_potential_file_reader PRIVATE lammps GTest::GMock GTe add_test(NAME PotentialFileReader COMMAND test_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(PotentialFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -if (PKG_MANYBODY) +if(PKG_MANYBODY) add_executable(test_eim_potential_file_reader test_eim_potential_file_reader.cpp) target_link_libraries(test_eim_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME EIMPotentialFileReader COMMAND test_eim_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -33,7 +33,7 @@ target_link_libraries(test_dump_atom PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME DumpAtom COMMAND test_dump_atom WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -if (PKG_COMPRESS) +if(PKG_COMPRESS) find_program(GZIP_BINARY NAMES gzip REQUIRED) add_executable(test_dump_atom_gz test_dump_atom_gz.cpp) @@ -113,7 +113,7 @@ target_link_libraries(test_dump_cfg PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME DumpCfg COMMAND test_dump_cfg WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(DumpCfg PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") -if (BUILD_TOOLS) +if(BUILD_TOOLS) set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$") set_tests_properties(DumpCustom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$") endif() diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index 640edf2733..d5328b1cfe 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -25,7 +25,7 @@ else() find_package(Python3 COMPONENTS Interpreter) endif() -if (Python_EXECUTABLE) +if(Python_EXECUTABLE) # prepare to augment the environment so that the LAMMPS python module and the shared library is found. set(PYTHON_TEST_ENVIRONMENT PYTHONPATH=${LAMMPS_PYTHON_DIR}:$ENV{PYTHONPATH}) if(APPLE) From 840dd61095ebb9cfb9ff8cb8a9723407c629c9fa Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Tue, 29 Dec 2020 14:23:58 -0500 Subject: [PATCH 168/187] Further optimized algorithm for computing the Wigner U matrices and derivatives thereof. Replaced explicit double within the SNAP kernels with a compile-time "real" type. Optimized GPU compressed neighbor build within SNAP. --- src/KOKKOS/kokkos_type.h | 41 +- src/KOKKOS/pair_snap_kokkos.cpp | 6 +- src/KOKKOS/pair_snap_kokkos.h | 102 ++- src/KOKKOS/pair_snap_kokkos_impl.h | 996 +++++++++++++++----------- src/KOKKOS/sna_kokkos.h | 154 ++-- src/KOKKOS/sna_kokkos_impl.h | 1075 ++++++++++++++-------------- 6 files changed, 1341 insertions(+), 1033 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 72513d2b17..aac87e9153 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1076,15 +1076,29 @@ struct params_lj_coul { // Pair SNAP +#define SNAP_KOKKOS_REAL double +#define SNAP_KOKKOS_HOST_VECLEN 1 + +#ifdef LMP_KOKKOS_GPU +#define SNAP_KOKKOS_DEVICE_VECLEN 32 +#else +#define SNAP_KOKKOS_DEVICE_VECLEN 1 +#endif + + +// intentional: SNAreal/complex gets reused beyond SNAP typedef double SNAreal; //typedef struct { SNAreal re, im; } SNAcomplex; -template -struct alignas(2*sizeof(real)) SNAComplex +template +struct alignas(2*sizeof(real_)) SNAComplex { + using real = real_; + using complex = SNAComplex; real re,im; - SNAComplex() = default; + KOKKOS_FORCEINLINE_FUNCTION SNAComplex() + : re(static_cast(0.)), im(static_cast(0.)) { ; } KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real re) : re(re), im(static_cast(0.)) { ; } @@ -1117,6 +1131,15 @@ struct alignas(2*sizeof(real)) SNAComplex return *this; } + KOKKOS_INLINE_FUNCTION + static constexpr complex zero() { return complex(static_cast(0.), static_cast(0.)); } + + KOKKOS_INLINE_FUNCTION + static constexpr complex one() { return complex(static_cast(1.), static_cast(0.)); } + + KOKKOS_INLINE_FUNCTION + const complex conj() { return complex(re, -im); } + }; template @@ -1126,18 +1149,6 @@ KOKKOS_FORCEINLINE_FUNCTION SNAComplex operator*(const real& r, const SNAC typedef SNAComplex SNAcomplex; -// Cayley-Klein pack -// Can guarantee it's aligned to 2 complex -struct alignas(32) CayleyKleinPack { - - SNAcomplex a, b; - SNAcomplex da[3], db[3]; - SNAreal sfac; - SNAreal dsfacu[3]; - -}; - - #if defined(KOKKOS_ENABLE_CXX11) #undef ISFINITE #define ISFINITE(x) std::isfinite(x) diff --git a/src/KOKKOS/pair_snap_kokkos.cpp b/src/KOKKOS/pair_snap_kokkos.cpp index 6f324a97be..4677d178e0 100644 --- a/src/KOKKOS/pair_snap_kokkos.cpp +++ b/src/KOKKOS/pair_snap_kokkos.cpp @@ -15,9 +15,11 @@ #include "pair_snap_kokkos_impl.h" namespace LAMMPS_NS { -template class PairSNAPKokkos; + +template class PairSNAPKokkosDevice; #ifdef LMP_KOKKOS_GPU -template class PairSNAPKokkos; +template class PairSNAPKokkosHost; #endif + } diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index e7a1f3173d..352e6e30b1 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -13,9 +13,15 @@ #ifdef PAIR_CLASS -PairStyle(snap/kk,PairSNAPKokkos) -PairStyle(snap/kk/device,PairSNAPKokkos) -PairStyle(snap/kk/host,PairSNAPKokkos) +#include "kokkos_type.h" + +PairStyle(snap/kk,PairSNAPKokkosDevice) +PairStyle(snap/kk/device,PairSNAPKokkosDevice) +#ifdef LMP_KOKKOS_GPU +PairStyle(snap/kk/host,PairSNAPKokkosHost) +#else +PairStyle(snap/kk/host,PairSNAPKokkosDevice) +#endif #else @@ -33,9 +39,11 @@ namespace LAMMPS_NS { // Routines for both the CPU and GPU backend template struct TagPairSNAPComputeForce{}; -struct TagPairSNAPComputeNeigh{}; + // GPU backend only +struct TagPairSNAPComputeNeigh{}; +struct TagPairSNAPComputeCayleyKlein{}; struct TagPairSNAPPreUi{}; struct TagPairSNAPComputeUi{}; struct TagPairSNAPTransformUi{}; // re-order ulisttot from SoA to AoSoA, zero ylist @@ -44,10 +52,10 @@ struct TagPairSNAPBeta{}; struct TagPairSNAPComputeBi{}; struct TagPairSNAPTransformBi{}; // re-order blist from AoSoA to AoS struct TagPairSNAPComputeYi{}; -struct TagPairSNAPTransformYi{}; // re-order ylist from AoSoA to AoS struct TagPairSNAPComputeFusedDeidrj{}; // CPU backend only +struct TagPairSNAPComputeNeighCPU{}; struct TagPairSNAPPreUiCPU{}; struct TagPairSNAPComputeUiCPU{}; struct TagPairSNAPTransformUiCPU{}; @@ -59,7 +67,7 @@ struct TagPairSNAPComputeYiCPU{}; struct TagPairSNAPComputeDuidrjCPU{}; struct TagPairSNAPComputeDeidrjCPU{}; -template +template class PairSNAPKokkos : public PairSNAP { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; @@ -68,6 +76,10 @@ public: typedef ArrayTypes AT; typedef EV_FLOAT value_type; + static constexpr int vector_length = vector_length_; + using real = real_; + using complex = SNAComplex; + PairSNAPKokkos(class LAMMPS *); ~PairSNAPKokkos(); @@ -78,10 +90,10 @@ public: double memory_usage(); template - void check_team_size_for(int, int&, int); + void check_team_size_for(int, int&); template - void check_team_size_reduce(int, int&, int); + void check_team_size_reduce(int, int&); template KOKKOS_INLINE_FUNCTION @@ -91,15 +103,18 @@ public: KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT&) const; - KOKKOS_INLINE_FUNCTION - void operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const; - KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPBetaCPU,const int& ii) const; // GPU backend only KOKKOS_INLINE_FUNCTION - void operator() (TagPairSNAPPreUi,const typename Kokkos::TeamPolicy::member_type& team) const; + void operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const; + + KOKKOS_INLINE_FUNCTION + void operator() (TagPairSNAPComputeCayleyKlein, const int iatom_mod, const int jnbor, const int iatom_div) const; + + KOKKOS_INLINE_FUNCTION + void operator() (TagPairSNAPPreUi,const int iatom_mod, const int j, const int iatom_div) const; KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const; @@ -122,13 +137,13 @@ public: KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeYi,const int iatom_mod, const int idxz, const int iatom_div) const; - KOKKOS_INLINE_FUNCTION - void operator() (TagPairSNAPTransformYi,const int iatom_mod, const int idxu, const int iatom_div) const; - KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const; // CPU backend only + KOKKOS_INLINE_FUNCTION + void operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const; + KOKKOS_INLINE_FUNCTION void operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const; @@ -173,7 +188,7 @@ protected: t_bvec bvec; typedef Kokkos::View t_dbvec; t_dbvec dbvec; - SNAKokkos snaKK; + SNAKokkos snaKK; int inum,max_neighs,chunk_size,chunk_offset; int host_flag; @@ -208,14 +223,14 @@ inline double dist2(double* x,double* y); Kokkos::View i_uarraytot_r, i_uarraytot_i; Kokkos::View i_zarray_r, i_zarray_i; - Kokkos::View d_radelem; // element radii - Kokkos::View d_wjelem; // elements weights - Kokkos::View d_coeffelem; // element bispectrum coefficients + Kokkos::View d_radelem; // element radii + Kokkos::View d_wjelem; // elements weights + Kokkos::View d_coeffelem; // element bispectrum coefficients Kokkos::View d_map; // mapping from atom types to elements Kokkos::View d_ninside; // ninside for all atoms in list - Kokkos::View d_beta; // betas for all atoms in list - Kokkos::View d_beta_pack; // betas for all atoms in list, GPU - Kokkos::View d_bispectrum; // bispectrum components for all atoms in list + Kokkos::View d_beta; // betas for all atoms in list + Kokkos::View d_beta_pack; // betas for all atoms in list, GPU + Kokkos::View d_bispectrum; // bispectrum components for all atoms in list typedef Kokkos::DualView tdual_fparams; tdual_fparams k_cutsq; @@ -237,6 +252,49 @@ inline double dist2(double* x,double* y); }; + +// These wrapper classes exist to make the pair style factory happy/avoid having +// to extend the pair style factory to support Pair classes w/an arbitrary number +// of extra template parameters + +template +class PairSNAPKokkosDevice : public PairSNAPKokkos { + +private: + using Base = PairSNAPKokkos; + +public: + + PairSNAPKokkosDevice(class LAMMPS *); + + void coeff(int, char**); + void init_style(); + double init_one(int, int); + void compute(int, int); + double memory_usage(); + +}; + +#ifdef LMP_KOKKOS_GPU +template +class PairSNAPKokkosHost : public PairSNAPKokkos { + +private: + using Base = PairSNAPKokkos; + +public: + + PairSNAPKokkosHost(class LAMMPS *); + + void coeff(int, char**); + void init_style(); + double init_one(int, int); + void compute(int, int); + double memory_usage(); + +}; +#endif + } #endif diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index bacb5f75d6..194738828c 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -48,8 +48,8 @@ namespace LAMMPS_NS { //static double t7 = 0.0; /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) +template +PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) { respa_enable = 0; @@ -67,8 +67,8 @@ PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::~PairSNAPKokkos() +template +PairSNAPKokkos::~PairSNAPKokkos() { if (copymode) return; @@ -81,8 +81,8 @@ PairSNAPKokkos::~PairSNAPKokkos() init specific to this pair style ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::init_style() +template +void PairSNAPKokkos::init_style() { if (force->newton_pair == 0) error->all(FLERR,"Pair style SNAP requires newton pair on"); @@ -128,8 +128,8 @@ struct FindMaxNumNeighs { This version is a straightforward implementation ---------------------------------------------------------------------- */ -template -void PairSNAPKokkos::compute(int eflag_in, int vflag_in) +template +void PairSNAPKokkos::compute(int eflag_in, int vflag_in) { eflag = eflag_in; vflag = vflag_in; @@ -186,16 +186,15 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) max_neighs = 0; Kokkos::parallel_reduce("PairSNAPKokkos::find_max_neighs",inum, FindMaxNumNeighs(k_list), Kokkos::Max(max_neighs)); - int vector_length_default = 1; int team_size_default = 1; if (!host_flag) team_size_default = 32;//max_neighs; if (beta_max < inum) { beta_max = inum; - d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); + d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); if (!host_flag) - d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",32,ncoeff,(inum+32-1)/32); + d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",vector_length,ncoeff,(inum + vector_length - 1) / vector_length); d_ninside = Kokkos::View("PairSNAPKokkos:ninside",inum); } @@ -213,31 +212,28 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) if (chunk_size > inum - chunk_offset) chunk_size = inum - chunk_offset; - //ComputeNeigh - { - int vector_length = vector_length_default; - int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); - typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); - Kokkos::parallel_for("ComputeNeigh",policy_neigh,*this); - } - if (host_flag) { // Host codepath + //ComputeNeigh + { + int team_size = team_size_default; + check_team_size_for(chunk_size,team_size); + typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); + Kokkos::parallel_for("ComputeNeighCPU",policy_neigh,*this); + } + //PreUi { - int vector_length = vector_length_default; int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); + check_team_size_for(chunk_size,team_size); typename Kokkos::TeamPolicy policy_preui_cpu((chunk_size+team_size-1)/team_size,team_size,vector_length); Kokkos::parallel_for("PreUiCPU",policy_preui_cpu,*this); } // ComputeUi { - int vector_length = vector_length_default; int team_size = team_size_default; // Fused calculation of ulist and accumulation into ulisttot using atomics typename Kokkos::TeamPolicy policy_ui_cpu(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); @@ -259,9 +255,8 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_for("ComputeZiCPU",policy_zi_cpu,*this); //ComputeBi - int vector_length = vector_length_default; int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); + check_team_size_for(chunk_size,team_size); typename Kokkos::TeamPolicy policy_bi_cpu(chunk_size,team_size,vector_length); Kokkos::parallel_for("ComputeBiCPU",policy_bi_cpu,*this); } @@ -281,7 +276,6 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) //ComputeDuidrj and Deidrj { int team_size = team_size_default; - int vector_length = vector_length_default; typename Kokkos::TeamPolicy policy_duidrj_cpu(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); snaKK.set_dir(-1); // technically doesn't do anything @@ -295,39 +289,65 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) } else { // GPU #ifdef LMP_KOKKOS_GPU + + //ComputeNeigh + { + constexpr int team_size = 4; + + // scratch size: max_neighs * sizeof(int) * number of threads per team + typedef Kokkos::View< int*, + Kokkos::DefaultExecutionSpace::scratch_memory_space, + Kokkos::MemoryTraits > + ScratchViewType; + int scratch_size = ScratchViewType::shmem_size( team_size * max_neighs ); + + typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); + policy_neigh = policy_neigh.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + Kokkos::parallel_for("ComputeNeigh",policy_neigh,*this); + } + + //ComputeCayleyKlein + { + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeCayleyKlein> + policy_compute_ck({0,0,0},{vector_length,max_neighs,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); + Kokkos::parallel_for("ComputeCayleyKlein",policy_compute_ck,*this); + } + //PreUi { - int vector_length = vector_length_default; - int team_size = team_size_default; - check_team_size_for(chunk_size,team_size,vector_length); - typename Kokkos::TeamPolicy policy_preui((chunk_size+team_size-1)/team_size,team_size,vector_length); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPPreUi> + policy_preui({0,0,0},{vector_length,twojmax+1,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("PreUi",policy_preui,*this); + } // ComputeUi w/vector parallelism, shared memory, direct atomicAdd into ulisttot { + // new AoSoA form + constexpr int team_size = sizeof(real) == 4 ? 8 : 4; // shared memory reqs - int vector_length = 32; - int team_size = 4; // need to cap b/c of shared memory reqs - check_team_size_for(chunk_size,team_size,vector_length); - - // scratch size: 2 * team_size * (twojmax+1)^2, to cover all `m1`,`m2` values, div 2 for symmetry - // 2 is for double buffer - - const int tile_size = (twojmax+1)*(twojmax/2+1); - typedef Kokkos::View< SNAcomplex*, + // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer + const int tile_size = vector_length * (twojmax + 1); + typedef Kokkos::View< complex*, Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( 2 * team_size * tile_size ); + int scratch_size = ScratchViewType::shmem_size( team_size * tile_size ); - typename Kokkos::TeamPolicy policy_ui(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); + // total number of teams needed + int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; + + // (natoms / 32) * (max_neighs) * ("bend" locations) + int n_teams = chunk_size_div * max_neighs * (twojmax + 1); + int n_teams_div = (n_teams + team_size - 1) / team_size; + + typename Kokkos::TeamPolicy policy_ui(n_teams_div,team_size, vector_length); policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); Kokkos::parallel_for("ComputeUi",policy_ui,*this); - //Transform data layout of ulisttot to AoSoA, zero ylist - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformUi> policy_transform_ui({0,0,0},{32,twojmax+1,(chunk_size + 32 - 1) / 32},{32,4,1}); + // un-"fold" ulisttot, zero ylist + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformUi> policy_transform_ui({0,0,0},{vector_length,snaKK.idxu_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("TransformUi",policy_transform_ui,*this); } @@ -336,19 +356,19 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) if (quadraticflag || eflag) { //ComputeZi int idxz_max = snaKK.idxz_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeZi> policy_compute_zi({0,0,0},{32,idxz_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeZi> policy_compute_zi({0,0,0},{vector_length,idxz_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("ComputeZi",policy_compute_zi,*this); //ComputeBi int idxb_max = snaKK.idxb_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeBi> policy_compute_bi({0,0,0},{32,idxb_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeBi> policy_compute_bi({0,0,0},{vector_length,idxb_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("ComputeBi",policy_compute_bi,*this); //Transform data layout of blist out of AoSoA //We need this b/c `blist` gets used in ComputeForce which doesn't //take advantage of AoSoA (which at best would only be beneficial //on the margins) - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformBi> policy_transform_bi({0,0,0},{32,idxb_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformBi> policy_transform_bi({0,0,0},{vector_length,idxb_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("TransformBi",policy_transform_bi,*this); } @@ -361,39 +381,39 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) //ComputeYi const int idxz_max = snaKK.idxz_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeYi> policy_compute_yi({0,0,0},{32,idxz_max,(chunk_size + 32 - 1) / 32},{32,4,1}); + typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPComputeYi> policy_compute_yi({0,0,0},{vector_length,idxz_max,(chunk_size + vector_length - 1) / vector_length},{vector_length,4,1}); Kokkos::parallel_for("ComputeYi",policy_compute_yi,*this); - //Transform data layout of ylist out of AoSoA - const int idxu_half_max = snaKK.idxu_half_max; - typename Kokkos::MDRangePolicy, Kokkos::Rank<3, Kokkos::Iterate::Left, Kokkos::Iterate::Left>, TagPairSNAPTransformYi> policy_transform_yi({0,0,0},{32,idxu_half_max,(chunk_size + 32 - 1) / 32},{32,4,1}); - Kokkos::parallel_for("TransformYi",policy_transform_yi,*this); - } // Fused ComputeDuidrj, ComputeDeidrj { - int vector_length = 32; - int team_size = 2; // need to cap b/c of shared memory reqs - check_team_size_for(chunk_size,team_size,vector_length); + // new AoSoA form + constexpr int team_size = sizeof(real) == 4 ? 4 : 2; // shared memory reqs - // scratch size: 2 * 2 * team_size * (twojmax+1)*(twojmax/2+1), to cover half `m1`,`m2` values due to symmetry - // 2 is for double buffer - const int tile_size = (twojmax+1)*(twojmax/2+1); - - typedef Kokkos::View< SNAcomplex*, + // scratch size: 32 atoms * (twojmax+1) cached values * 2 for u, du, no double buffer + const int tile_size = vector_length * (twojmax + 1); + typedef Kokkos::View< complex*, Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( 4 * team_size * tile_size); + int scratch_size = ScratchViewType::shmem_size( 2 * team_size * tile_size ); - typename Kokkos::TeamPolicy policy_fused_deidrj(((chunk_size+team_size-1)/team_size)*max_neighs,team_size,vector_length); + // total number of teams needed + int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; + + // (natoms / 32) * (max_neighs) * ("bend" locations) + int n_teams = chunk_size_div * max_neighs * (twojmax + 1); + int n_teams_div = (n_teams + team_size - 1) / team_size; + + typename Kokkos::TeamPolicy policy_fused_deidrj(n_teams_div,team_size,vector_length); policy_fused_deidrj = policy_fused_deidrj.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); for (int k = 0; k < 3; k++) { snaKK.set_dir(k); Kokkos::parallel_for("ComputeFusedDeidrj",policy_fused_deidrj,*this); } + } #endif // LMP_KOKKOS_GPU @@ -403,27 +423,26 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) //ComputeForce { int team_size = team_size_default; - int vector_length = vector_length_default; if (evflag) { if (neighflag == HALF) { - check_team_size_reduce >(chunk_size,team_size,vector_length); + check_team_size_reduce >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_reduce(policy_force ,*this,ev_tmp); } else if (neighflag == HALFTHREAD) { - check_team_size_reduce >(chunk_size,team_size,vector_length); + check_team_size_reduce >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_reduce(policy_force ,*this,ev_tmp); } } else { if (neighflag == HALF) { - check_team_size_for >(chunk_size,team_size,vector_length); + check_team_size_for >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_for(policy_force ,*this); } else if (neighflag == HALFTHREAD) { - check_team_size_for >(chunk_size,team_size,vector_length); + check_team_size_for >(chunk_size,team_size); typename Kokkos::TeamPolicy > policy_force(chunk_size,team_size,vector_length); Kokkos::parallel_for(policy_force ,*this); @@ -478,8 +497,8 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) allocate all arrays ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::allocate() +template +void PairSNAPKokkos::allocate() { PairSNAP::allocate(); @@ -492,8 +511,8 @@ void PairSNAPKokkos::allocate() init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::init_one(int i, int j) +template +double PairSNAPKokkos::init_one(int i, int j) { double cutone = PairSNAP::init_one(i,j); k_cutsq.h_view(i,j) = k_cutsq.h_view(j,i) = cutone*cutone; @@ -506,16 +525,16 @@ double PairSNAPKokkos::init_one(int i, int j) set coeffs for one or more type pairs ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::coeff(int narg, char **arg) +template +void PairSNAPKokkos::coeff(int narg, char **arg) { PairSNAP::coeff(narg,arg); // Set up element lists - d_radelem = Kokkos::View("pair:radelem",nelements); - d_wjelem = Kokkos::View("pair:wjelem",nelements); - d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); + d_radelem = Kokkos::View("pair:radelem",nelements); + d_wjelem = Kokkos::View("pair:wjelem",nelements); + d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); auto h_radelem = Kokkos::create_mirror_view(d_radelem); auto h_wjelem = Kokkos::create_mirror_view(d_wjelem); @@ -539,25 +558,382 @@ void PairSNAPKokkos::coeff(int narg, char **arg) Kokkos::deep_copy(d_coeffelem,h_coeffelem); Kokkos::deep_copy(d_map,h_map); - snaKK = SNAKokkos(rfac0,twojmax, + snaKK = SNAKokkos(rfac0,twojmax, rmin0,switchflag,bzeroflag,chemflag,bnormflag,wselfallflag,nelements); snaKK.grow_rij(0,0); snaKK.init(); } /* ---------------------------------------------------------------------- - Begin routines that are called on both CPU and GPU codepaths + Begin routines that are unique to the GPU codepath. These take advantage + of AoSoA data layouts and scratch memory for recursive polynomials ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- */ - -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { + + if (ii >= chunk_size) return; + + const int iatom_mod = ii % vector_length; + const int iatom_div = ii / vector_length; + + const int i = d_ilist[ii + chunk_offset]; + const int itype = type[i]; + const int ielem = d_map[itype]; + SNAKokkos my_sna = snaKK; + + auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); + + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + d_beta_pack(iatom_mod,icoeff,iatom_div) = d_coeffi[icoeff+1]; + } + + if (quadraticflag) { + const auto idxb_max = my_sna.idxb_max; + int k = ncoeff+1; + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + const auto idxb = icoeff % idxb_max; + const auto idx_chem = icoeff / idxb_max; + auto bveci = my_sna.blist(idxb, idx_chem, ii); + d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bveci; + k++; + for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { + const auto jdxb = jcoeff % idxb_max; + const auto jdx_chem = jcoeff / idxb_max; + real bvecj = my_sna.blist(jdxb, jdx_chem, ii); + d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bvecj; + d_beta_pack(iatom_mod,jcoeff,iatom_div) += d_coeffi[k]*bveci; + k++; + } + } + } +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { + + SNAKokkos my_sna = snaKK; + + // extract atom number + int ii = team.team_rank() + team.league_rank() * team.team_size(); + if (ii >= chunk_size) return; + + // get a pointer to scratch memory + // This is used to cache whether or not an atom is within the cutoff. + // If it is, type_cache is assigned to the atom type. + // If it's not, it's assigned to -1. + const int tile_size = max_neighs; // number of elements per thread + const int team_rank = team.team_rank(); + const int scratch_shift = team_rank * tile_size; // offset into pointer for entire team + int* type_cache = (int*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(int), 0) + scratch_shift; + + // Load various info about myself up front + const int i = d_ilist[ii + chunk_offset]; + const F_FLOAT xtmp = x(i,0); + const F_FLOAT ytmp = x(i,1); + const F_FLOAT ztmp = x(i,2); + const int itype = type[i]; + const int ielem = d_map[itype]; + const double radi = d_radelem[ielem]; + + const int num_neighs = d_numneigh[i]; + + // rij[][3] = displacements between atom I and those neighbors + // inside = indices of neighbors of I within cutoff + // wj = weights for neighbors of I within cutoff + // rcutij = cutoffs for neighbors of I within cutoff + // note Rij sign convention => dU/dRij = dU/dRj = -dU/dRi + + // Compute the number of neighbors, store rsq + int ninside = 0; + Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,num_neighs), + [&] (const int jj, int& count) { + T_INT j = d_neighbors(i,jj); + const F_FLOAT dx = x(j,0) - xtmp; + const F_FLOAT dy = x(j,1) - ytmp; + const F_FLOAT dz = x(j,2) - ztmp; + + int jtype = type(j); + const F_FLOAT rsq = dx*dx + dy*dy + dz*dz; + + if (rsq >= rnd_cutsq(itype,jtype)) { + jtype = -1; // use -1 to signal it's outside the radius + } + + type_cache[jj] = jtype; + + if ( jtype >= 0 ) + count++; + }, ninside); + + d_ninside(ii) = ninside; + + Kokkos::parallel_scan(Kokkos::ThreadVectorRange(team,num_neighs), + [&] (const int jj, int& offset, bool final) { + + const int jtype = type_cache[jj]; + + if ( jtype >= 0 ) { + if (final) { + T_INT j = d_neighbors(i,jj); + const F_FLOAT dx = x(j,0) - xtmp; + const F_FLOAT dy = x(j,1) - ytmp; + const F_FLOAT dz = x(j,2) - ztmp; + const int elem_j = d_map[jtype]; + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); + my_sna.inside(ii,offset) = j; + if (chemflag) + my_sna.element(ii,offset) = elem_j; + else + my_sna.element(ii,offset) = 0; + } + offset++; + } + }); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeCayleyKlein,const int iatom_mod, const int jnbor, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int ii = iatom_mod + iatom_div * vector_length; + if (ii >= chunk_size) return; + + const int ninside = d_ninside(ii); + if (jnbor >= ninside) return; + + my_sna.compute_cayley_klein(iatom_mod,jnbor,iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPPreUi, const int iatom_mod, const int j, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int ii = iatom_mod + iatom_div * vector_length; + if (ii >= chunk_size) return; + + int itype = type(ii); + int ielem = d_map[itype]; + + my_sna.pre_ui(iatom_mod, j, ielem, iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; + + constexpr int team_size = sizeof(real) == 4 ? 8 : 4; + if (team.team_size() != team_size) return; // error + + // extract flattened atom_div / neighbor number / bend location + int flattened_idx = team.team_rank() + team.league_rank() * team_size; + + // extract neighbor index, iatom_div + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); + const int jbend = jj_jbend / max_neighs; + const int jj = jj_jbend - jbend * max_neighs; + + // check base atom numbers, hopefully this doesn't lead to blocking conditions? + // yep, we can't have a return in here + Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, vector_length), + [&] (const int iatom_mod) { + const int ii = iatom_mod + vector_length * iatom_div; + if (ii >= chunk_size) return; + + const int ninside = d_ninside(ii); + if (jj >= ninside) return; + + my_sna.compute_ui(team,iatom_mod, jbend, jj, iatom_div); + }); + +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int idxu, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (idxu > my_sna.idxu_max) return; + + int elem_count = chemflag ? nelements : 1; + + for (int ielem = 0; ielem < elem_count; ielem++) { + + const FullHalfMapper mapper = my_sna.idxu_full_half[idxu]; + + auto utot_re = my_sna.ulisttot_re_pack(iatom_mod, mapper.idxu_half, ielem, iatom_div); + auto utot_im = my_sna.ulisttot_im_pack(iatom_mod, mapper.idxu_half, ielem, iatom_div); + + if (mapper.flip_sign == 1) { + utot_im = -utot_im; + } else if (mapper.flip_sign == -1 ) { + utot_re = -utot_re; + } + + my_sna.ulisttot_pack(iatom_mod, idxu, ielem, iatom_div) = { utot_re, utot_im }; + + if (mapper.flip_sign == 0) { + my_sna.ylist_pack_re(iatom_mod, mapper.idxu_half, ielem, iatom_div) = 0.; + my_sna.ylist_pack_im(iatom_mod, mapper.idxu_half, ielem, iatom_div) = 0.; + } + } +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (jjz >= my_sna.idxz_max) return; + + my_sna.compute_yi(iatom_mod,jjz,iatom_div,d_beta_pack); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (jjz >= my_sna.idxz_max) return; + + my_sna.compute_zi(iatom_mod,jjz,iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (jjb >= my_sna.idxb_max) return; + + my_sna.compute_bi(iatom_mod,jjb,iatom_div); +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; + + const int iatom = iatom_mod + iatom_div * vector_length; + if (iatom >= chunk_size) return; + + if (idxb >= my_sna.idxb_max) return; + + const int ntriples = my_sna.ntriples; + + for (int itriple = 0; itriple < ntriples; itriple++) { + + const auto blocal = my_sna.blist_pack(iatom_mod, idxb, itriple, iatom_div); + + my_sna.blist(idxb, itriple, iatom) = blocal; + } + +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; + + constexpr int team_size = sizeof(real) == 4 ? 4 : 2; + if (team.team_size() != team_size) return; // error + + // extract flattened atom_div / neighbor number / bend location + int flattened_idx = team.team_rank() + team.league_rank() * team_size; + + // extract neighbor index, iatom_div + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); + const int jbend = jj_jbend / max_neighs; + const int jj = jj_jbend - jbend * max_neighs; + + Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, vector_length), + [&] (const int iatom_mod) { + const int ii = iatom_mod + vector_length * iatom_div; + if (ii >= chunk_size) return; + + const int ninside = d_ninside(ii); + if (jj >= ninside) return; + + my_sna.compute_fused_deidrj(team, iatom_mod, jbend, jj, iatom_div); + + }); + +} + +/* ---------------------------------------------------------------------- + Begin routines that are unique to the CPU codepath. These do not take + advantage of AoSoA data layouts, but that could be a good point of + future optimization and unification with the above kernels. It's unlikely + that scratch memory optimizations will ever be useful for the CPU due to + different arithmetic intensity requirements for the CPU vs GPU. +------------------------------------------------------------------------- */ + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { + + const int i = d_ilist[ii + chunk_offset]; + const int itype = type[i]; + const int ielem = d_map[itype]; + SNAKokkos my_sna = snaKK; + + auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); + + for (int icoeff = 0; icoeff < ncoeff; icoeff++) + d_beta(icoeff,ii) = d_coeffi[icoeff+1]; + + if (quadraticflag) { + const auto idxb_max = my_sna.idxb_max; + int k = ncoeff+1; + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + const auto idxb = icoeff % idxb_max; + const auto idx_chem = icoeff / idxb_max; + auto bveci = my_sna.blist(idxb,idx_chem,ii); + d_beta(icoeff,ii) += d_coeffi[k]*bveci; + k++; + for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { + const auto jdxb = jcoeff % idxb_max; + const auto jdx_chem = jcoeff / idxb_max; + auto bvecj = my_sna.blist(jdxb,jdx_chem,ii); + d_beta(icoeff,ii) += d_coeffi[k]*bvecj; + d_beta(jcoeff,ii) += d_coeffi[k]*bveci; + k++; + } + } + } +} + +template +KOKKOS_INLINE_FUNCTION +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + int ii = team.league_rank(); const int i = d_ilist[ii + chunk_offset]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; const double xtmp = x(i,0); const double ytmp = x(i,1); const double ztmp = x(i,2); @@ -607,20 +983,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typen if ( rsq < rnd_cutsq(itype,jtype) ) { if (final) { -#ifdef LMP_KOKKOS_GPU - if (!host_flag) { - my_sna.compute_cayley_klein(ii, offset, dx, dy, dz, (radi + d_radelem[elem_j])*rcutfac, - d_wjelem[elem_j]); - } else { -#endif - my_sna.rij(ii,offset,0) = dx; - my_sna.rij(ii,offset,1) = dy; - my_sna.rij(ii,offset,2) = dz; - my_sna.wj(ii,offset) = d_wjelem[elem_j]; - my_sna.rcutij(ii,offset) = (radi + d_radelem[elem_j])*rcutfac; -#ifdef LMP_KOKKOS_GPU - } -#endif + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); my_sna.inside(ii,offset) = j; if (chemflag) my_sna.element(ii,offset) = elem_j; @@ -632,282 +999,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typen }); } -/* ---------------------------------------------------------------------- - Begin routines that are unique to the GPU codepath. These take advantage - of AoSoA data layouts and scratch memory for recursive polynomials -------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { - - if (ii >= chunk_size) return; - - const int iatom_mod = ii % 32; - const int iatom_div = ii / 32; - - const int i = d_ilist[ii + chunk_offset]; - const int itype = type[i]; - const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; - - Kokkos::View> - d_coeffi(d_coeffelem,ielem,Kokkos::ALL); - - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - d_beta_pack(iatom_mod,icoeff,iatom_div) = d_coeffi[icoeff+1]; - } - - if (quadraticflag) { - const auto idxb_max = my_sna.idxb_max; - int k = ncoeff+1; - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - const auto idxb = icoeff % idxb_max; - const auto idx_chem = icoeff / idxb_max; - double bveci = my_sna.blist(idxb, idx_chem, ii); - d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bveci; - k++; - for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { - const auto jdxb = jcoeff % idxb_max; - const auto jdx_chem = jcoeff / idxb_max; - double bvecj = my_sna.blist(jdxb, jdx_chem, ii); - d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bvecj; - d_beta_pack(iatom_mod,jcoeff,iatom_div) += d_coeffi[k]*bveci; - k++; - } - } - } -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUi,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; - - // Extract the atom number - const int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); - if (ii >= chunk_size) return; - int itype = type(ii); - int ielem = d_map[itype]; - - my_sna.pre_ui(team,ii,ielem); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; - - // Extract the atom number - int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); - if (ii >= chunk_size) return; - - // Extract the neighbor number - const int jj = team.league_rank() / ((chunk_size+team.team_size()-1)/team.team_size()); - const int ninside = d_ninside(ii); - if (jj >= ninside) return; - - my_sna.compute_ui(team,ii,jj); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int j, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (j > twojmax) return; - - int elem_count = chemflag ? nelements : 1; - - for (int ielem = 0; ielem < elem_count; ielem++) { - const int jju_half = my_sna.idxu_half_block(j); - const int jju = my_sna.idxu_block(j); - - for (int mb = 0; 2*mb <= j; mb++) { - for (int ma = 0; ma <= j; ma++) { - // Extract top half - - const int idxu_shift = mb * (j + 1) + ma; - const int idxu_half = jju_half + idxu_shift; - const int idxu = jju + idxu_shift; - - auto utot_re = my_sna.ulisttot_re(idxu_half, ielem, iatom); - auto utot_im = my_sna.ulisttot_im(idxu_half, ielem, iatom); - - // Store - my_sna.ulisttot_pack(iatom_mod, idxu, ielem, iatom_div) = { utot_re, utot_im }; - - // Also zero yi - my_sna.ylist_pack_re(iatom_mod, idxu_half, ielem, iatom_div) = 0.; - my_sna.ylist_pack_im(iatom_mod, idxu_half, ielem, iatom_div) = 0.; - - // Symmetric term - const int sign_factor = (((ma+mb)%2==0)?1:-1); - const int idxu_flip = jju + (j + 1 - mb) * (j + 1) - (ma + 1); - - if (sign_factor == 1) { - utot_im = -utot_im; - } else { - utot_re = -utot_re; - } - - my_sna.ulisttot_pack(iatom_mod, idxu_flip, ielem, iatom_div) = { utot_re, utot_im }; - - // No need to zero symmetrized ylist - } - } - } -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (jjz >= my_sna.idxz_max) return; - - my_sna.compute_yi(iatom_mod,jjz,iatom_div,d_beta_pack); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformYi,const int iatom_mod, const int idxu_half, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (idxu_half >= my_sna.idxu_half_max) return; - - int elem_count = chemflag ? nelements : 1; - for (int ielem = 0; ielem < elem_count; ielem++) { - const auto y_re = my_sna.ylist_pack_re(iatom_mod, idxu_half, ielem, iatom_div); - const auto y_im = my_sna.ylist_pack_im(iatom_mod, idxu_half, ielem, iatom_div); - - my_sna.ylist(idxu_half, ielem, iatom) = { y_re, y_im }; - } - -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (jjz >= my_sna.idxz_max) return; - - my_sna.compute_zi(iatom_mod,jjz,iatom_div); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (jjb >= my_sna.idxb_max) return; - - my_sna.compute_bi(iatom_mod,jjb,iatom_div); -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; - - const int iatom = iatom_mod + iatom_div * 32; - if (iatom >= chunk_size) return; - - if (idxb >= my_sna.idxb_max) return; - - const int ntriples = my_sna.ntriples; - - for (int itriple = 0; itriple < ntriples; itriple++) { - - const auto blocal = my_sna.blist_pack(iatom_mod, idxb, itriple, iatom_div); - - my_sna.blist(idxb, itriple, iatom) = blocal; - } - -} - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; - - // Extract the atom number - int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); - if (ii >= chunk_size) return; - - // Extract the neighbor number - const int jj = team.league_rank() / ((chunk_size+team.team_size()-1)/team.team_size()); - const int ninside = d_ninside(ii); - if (jj >= ninside) return; - - my_sna.compute_fused_deidrj(team,ii,jj); -} - -/* ---------------------------------------------------------------------- - Begin routines that are unique to the CPU codepath. These do not take - advantage of AoSoA data layouts, but that could be a good point of - future optimization and unification with the above kernels. It's unlikely - that scratch memory optimizations will ever be useful for the CPU due to - different arithmetic intensity requirements for the CPU vs GPU. -------------------------------------------------------------------------- */ - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { - - const int i = d_ilist[ii + chunk_offset]; - const int itype = type[i]; - const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; - - Kokkos::View> - d_coeffi(d_coeffelem,ielem,Kokkos::ALL); - - for (int icoeff = 0; icoeff < ncoeff; icoeff++) - d_beta(icoeff,ii) = d_coeffi[icoeff+1]; - - if (quadraticflag) { - const auto idxb_max = my_sna.idxb_max; - int k = ncoeff+1; - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - const auto idxb = icoeff % idxb_max; - const auto idx_chem = icoeff / idxb_max; - double bveci = my_sna.blist(idxb,idx_chem,ii); - d_beta(icoeff,ii) += d_coeffi[k]*bveci; - k++; - for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { - const auto jdxb = jcoeff % idxb_max; - const auto jdx_chem = jcoeff / idxb_max; - double bvecj = my_sna.blist(jdxb,jdx_chem,ii); - d_beta(icoeff,ii) += d_coeffi[k]*bvecj; - d_beta(jcoeff,ii) += d_coeffi[k]*bveci; - k++; - } - } - } -} - - -template -KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number const int ii = team.team_rank() + team.team_size() * team.league_rank(); @@ -920,10 +1016,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -937,10 +1033,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typen my_sna.compute_ui_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { + SNAKokkos my_sna = snaKK; if (iatom >= chunk_size) return; @@ -987,32 +1083,32 @@ void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const in } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_yi_cpu(ii,d_beta); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_zi_cpu(ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { int ii = team.league_rank(); - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; my_sna.compute_bi_cpu(team,ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1026,10 +1122,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const t my_sna.compute_duidrj_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1049,10 +1145,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const t likely not worth it. ------------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -1061,7 +1157,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeForce my_sna = snaKK; + SNAKokkos my_sna = snaKK; const int ninside = d_ninside(ii); Kokkos::parallel_for (Kokkos::TeamThreadRange(team,ninside), @@ -1102,14 +1198,13 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeForce> - d_coeffi(d_coeffelem,ielem,Kokkos::ALL); + auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); Kokkos::single(Kokkos::PerTeam(team), [&] () { // evdwl = energy of atom I, sum over coeffs_k * Bi_k - double evdwl = d_coeffi[0]; + auto evdwl = d_coeffi[0]; // E = beta.B + 0.5*B^t.alpha.B @@ -1130,13 +1225,13 @@ void PairSNAPKokkos::operator() (TagPairSNAPComputeForce::operator() (TagPairSNAPComputeForce +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { EV_FLOAT ev; this->template operator()(TagPairSNAPComputeForce(), team, ev); } /* ---------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, +void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { @@ -1209,24 +1304,24 @@ void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const i memory usage ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::memory_usage() +template +double PairSNAPKokkos::memory_usage() { double bytes = Pair::memory_usage(); int n = atom->ntypes+1; bytes += n*n*sizeof(int); - bytes += n*n*sizeof(double); - bytes += (2*ncoeffall)*sizeof(double); - bytes += (ncoeff*3)*sizeof(double); + bytes += n*n*sizeof(real); + bytes += (2*ncoeffall)*sizeof(real); + bytes += (ncoeff*3)*sizeof(real); bytes += snaKK.memory_usage(); return bytes; } /* ---------------------------------------------------------------------- */ -template +template template -void PairSNAPKokkos::check_team_size_for(int inum, int &team_size, int vector_length) { +void PairSNAPKokkos::check_team_size_for(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); @@ -1235,9 +1330,9 @@ void PairSNAPKokkos::check_team_size_for(int inum, int &team_size, i team_size = team_size_max/vector_length; } -template +template template -void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size, int vector_length) { +void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelReduceTag()); @@ -1246,4 +1341,79 @@ void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size team_size = team_size_max/vector_length; } + +/* ---------------------------------------------------------------------- + routines used by template reference classes +------------------------------------------------------------------------- */ + +template +PairSNAPKokkosDevice::PairSNAPKokkosDevice(class LAMMPS *lmp) + : PairSNAPKokkos(lmp) { ; } + +template +void PairSNAPKokkosDevice::coeff(int narg, char **arg) +{ + Base::coeff(narg, arg); +} + +template +void PairSNAPKokkosDevice::init_style() +{ + Base::init_style(); +} + +template +double PairSNAPKokkosDevice::init_one(int i, int j) +{ + return Base::init_one(i, j); +} + +template +void PairSNAPKokkosDevice::compute(int eflag_in, int vflag_in) +{ + Base::compute(eflag_in, vflag_in); +} + +template +double PairSNAPKokkosDevice::memory_usage() +{ + return Base::memory_usage(); +} + +#ifdef LMP_KOKKOS_GPU +template +PairSNAPKokkosHost::PairSNAPKokkosHost(class LAMMPS *lmp) + : PairSNAPKokkos(lmp) { ; } + +template +void PairSNAPKokkosHost::coeff(int narg, char **arg) +{ + Base::coeff(narg, arg); +} + +template +void PairSNAPKokkosHost::init_style() +{ + Base::init_style(); +} + +template +double PairSNAPKokkosHost::init_one(int i, int j) +{ + return Base::init_one(i, j); +} + +template +void PairSNAPKokkosHost::compute(int eflag_in, int vflag_in) +{ + Base::compute(eflag_in, vflag_in); +} + +template +double PairSNAPKokkosHost::memory_usage() +{ + return Base::memory_usage(); +} +#endif + } diff --git a/src/KOKKOS/sna_kokkos.h b/src/KOKKOS/sna_kokkos.h index 7804aaef18..d34e9a9e17 100644 --- a/src/KOKKOS/sna_kokkos.h +++ b/src/KOKKOS/sna_kokkos.h @@ -25,45 +25,78 @@ namespace LAMMPS_NS { -template +template +struct WignerWrapper { + using real = real_; + using complex = SNAComplex; + static constexpr int vector_length = vector_length_; + + const int offset; // my offset into the vector (0, ..., vector_length - 1) + real* buffer; // buffer of real numbers + + KOKKOS_INLINE_FUNCTION + WignerWrapper(complex* buffer_, const int offset_) + : offset(offset_), buffer(reinterpret_cast(buffer_)) + { ; } + + KOKKOS_INLINE_FUNCTION + complex get(const int& ma) { + return complex(buffer[offset + 2 * vector_length * ma], buffer[offset + vector_length + 2 * vector_length * ma]); + } + + KOKKOS_INLINE_FUNCTION + void set(const int& ma, const complex& store) { + buffer[offset + 2 * vector_length * ma] = store.re; + buffer[offset + vector_length + 2 * vector_length * ma] = store.im; + } +}; + +struct alignas(8) FullHalfMapper { + int idxu_half; + int flip_sign; // 0 -> isn't flipped, 1 -> conj, -1 -> -conj +}; + +template class SNAKokkos { public: + using real = real_; + using complex = SNAComplex; + static constexpr int vector_length = vector_length_; + typedef Kokkos::View t_sna_1i; - typedef Kokkos::View t_sna_1d; - typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; + typedef Kokkos::View t_sna_1d; + typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; typedef Kokkos::View t_sna_2i; - typedef Kokkos::View t_sna_2d; - typedef Kokkos::View t_sna_2d_ll; - typedef Kokkos::View t_sna_3d; - typedef Kokkos::View t_sna_3d_ll; - typedef Kokkos::View t_sna_4d; - typedef Kokkos::View t_sna_4d_ll; - typedef Kokkos::View t_sna_3d3; - typedef Kokkos::View t_sna_5d; + typedef Kokkos::View t_sna_2d; + typedef Kokkos::View t_sna_2d_ll; + typedef Kokkos::View t_sna_3d; + typedef Kokkos::View t_sna_3d_ll; + typedef Kokkos::View t_sna_4d; + typedef Kokkos::View t_sna_4d_ll; + typedef Kokkos::View t_sna_3d3; + typedef Kokkos::View t_sna_5d; - typedef Kokkos::View t_sna_1c; - typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1c_atomic; - typedef Kokkos::View t_sna_2c; - typedef Kokkos::View t_sna_2c_ll; - typedef Kokkos::View t_sna_2c_lr; - typedef Kokkos::View t_sna_3c; - typedef Kokkos::View t_sna_3c_ll; - typedef Kokkos::View t_sna_4c; - typedef Kokkos::View t_sna_4c3_ll; - typedef Kokkos::View t_sna_4c_ll; - typedef Kokkos::View t_sna_3c3; - typedef Kokkos::View t_sna_5c; - - typedef Kokkos::View t_sna_2ckp; + typedef Kokkos::View t_sna_1c; + typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1c_atomic; + typedef Kokkos::View t_sna_2c; + typedef Kokkos::View t_sna_2c_ll; + typedef Kokkos::View t_sna_2c_lr; + typedef Kokkos::View t_sna_3c; + typedef Kokkos::View t_sna_3c_ll; + typedef Kokkos::View t_sna_4c; + typedef Kokkos::View t_sna_4c3_ll; + typedef Kokkos::View t_sna_4c_ll; + typedef Kokkos::View t_sna_3c3; + typedef Kokkos::View t_sna_5c; inline SNAKokkos() {}; KOKKOS_INLINE_FUNCTION - SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); + SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); inline - SNAKokkos(double, int, double, int, int, int, int, int, int); + SNAKokkos(real, int, real, int, int, int, int, int, int); KOKKOS_INLINE_FUNCTION ~SNAKokkos(); @@ -81,17 +114,16 @@ inline // functions for bispectrum coefficients, GPU only KOKKOS_INLINE_FUNCTION - void compute_cayley_klein(const int&, const int&, const double&, const double&, - const double&, const double&, const double&); + void compute_cayley_klein(const int&, const int&, const int&); KOKKOS_INLINE_FUNCTION - void pre_ui(const typename Kokkos::TeamPolicy::member_type& team,const int&,const int&); // ForceSNAP + void pre_ui(const int&, const int&, const int&, const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION - void compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int, const int); // ForceSNAP + void compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int, const int, const int, const int); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_zi(const int&, const int&, const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi(int,int,int, - const Kokkos::View &beta_pack); // ForceSNAP + const Kokkos::View &beta_pack); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi(const int&, const int&, const int&); // ForceSNAP @@ -104,34 +136,33 @@ inline void compute_zi_cpu(const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi_cpu(int, - const Kokkos::View &beta); // ForceSNAP + const Kokkos::View &beta); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int); // ForceSNAP // functions for derivatives, GPU only KOKKOS_INLINE_FUNCTION - void compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int, const int); //ForceSNAP + void compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int, const int, const int, const int); //ForceSNAP // functions for derivatives, CPU only KOKKOS_INLINE_FUNCTION void compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int); //ForceSNAP KOKKOS_INLINE_FUNCTION void compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int); // ForceSNAP - KOKKOS_INLINE_FUNCTION - double compute_sfac(double, double); // add_uarraytot, compute_duarray - KOKKOS_INLINE_FUNCTION - double compute_dsfac(double, double); // compute_duarray - KOKKOS_INLINE_FUNCTION - void compute_s_dsfac(const double, const double, double&, double&); // compute_cayley_klein - // efficient complex FMA - // efficient caxpy (i.e., y += a x) - static KOKKOS_FORCEINLINE_FUNCTION - void caxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y); + KOKKOS_INLINE_FUNCTION + real compute_sfac(real, real); // add_uarraytot, compute_duarray + + KOKKOS_INLINE_FUNCTION + real compute_dsfac(real, real); // compute_duarray + + KOKKOS_INLINE_FUNCTION + void compute_s_dsfac(const real, const real, real&, real&); // compute_cayley_klein - // efficient complex FMA, conjugate of scalar static KOKKOS_FORCEINLINE_FUNCTION - void caconjxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y); + void sincos_wrapper(double x, double* sin_, double *cos_) { sincos(x, sin_, cos_); } + static KOKKOS_FORCEINLINE_FUNCTION + void sincos_wrapper(float x, float* sin_, float *cos_) { sincosf(x, sin_, cos_); } // Set the direction for split ComputeDuidrj KOKKOS_INLINE_FUNCTION @@ -146,10 +177,6 @@ inline //per sna class instance for OMP use - // Alternative to rij, wj, rcutij... - // just calculate everything up front - t_sna_2ckp cayleyklein; - // Per InFlight Particle t_sna_3d rij; t_sna_2i inside; @@ -175,8 +202,14 @@ inline t_sna_4c3_ll dulist; // Modified structures for GPU backend - t_sna_3d_ll ulisttot_re; // split real, - t_sna_3d_ll ulisttot_im; // imag + t_sna_3c_ll a_pack; // Cayley-Klein `a` + t_sna_3c_ll b_pack; // `b` + t_sna_4c_ll da_pack; // `da` + t_sna_4c_ll db_pack; // `db` + t_sna_4d_ll sfac_pack; // sfac, dsfac_{x,y,z} + + t_sna_4d_ll ulisttot_re_pack; // split real, + t_sna_4d_ll ulisttot_im_pack; // imag, AoSoA, flattened t_sna_4c_ll ulisttot_pack; // AoSoA layout t_sna_4c_ll zlist_pack; // AoSoA layout t_sna_4d_ll blist_pack; @@ -191,7 +224,7 @@ inline int ntriples; private: - double rmin0, rfac0; + real rmin0, rfac0; //use indexlist instead of loops, constructor generates these // Same across all SNAKokkos @@ -203,6 +236,7 @@ public: Kokkos::View idxu_block; Kokkos::View idxu_half_block; Kokkos::View idxu_cache_block; + Kokkos::View idxu_full_half; private: Kokkos::View idxz_block; @@ -231,12 +265,12 @@ inline void init_rootpqarray(); // init() KOKKOS_INLINE_FUNCTION - void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, double, double, double, int); // compute_ui + void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, const real&, const real&, const real&, int); // compute_ui KOKKOS_INLINE_FUNCTION void compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - double, double, double, - double, double); // compute_ui_cpu + const real&, const real&, const real&, + const real&, const real&); // compute_ui_cpu inline @@ -246,8 +280,8 @@ inline int compute_ncoeff(); // SNAKokkos() KOKKOS_INLINE_FUNCTION void compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - double, double, double, // compute_duidrj_cpu - double, double, double, double, double); + const real&, const real&, const real&, // compute_duidrj_cpu + const real&, const real&, const real&, const real&, const real&); // Sets the style for the switching function // 0 = none @@ -259,11 +293,11 @@ inline int bnorm_flag; // Self-weight - double wself; + real wself; int wselfall_flag; int bzero_flag; // 1 if bzero subtracted from barray - Kokkos::View bzero; // array of B values for isolated atoms + Kokkos::View bzero; // array of B values for isolated atoms // for per-direction dulist calculation, specify the direction. int dir; diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index 3060aa9527..dc5ab2bcb8 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -25,16 +25,16 @@ namespace LAMMPS_NS { static const double MY_PI = 3.14159265358979323846; // pi -template +template inline -SNAKokkos::SNAKokkos(double rfac0_in, - int twojmax_in, double rmin0_in, int switch_flag_in, int bzero_flag_in, +SNAKokkos::SNAKokkos(real rfac0_in, + int twojmax_in, real rmin0_in, int switch_flag_in, int bzero_flag_in, int chem_flag_in, int bnorm_flag_in, int wselfall_flag_in, int nelements_in) { LAMMPS_NS::ExecutionSpace execution_space = ExecutionSpaceFromDevice::space; host_flag = (execution_space == LAMMPS_NS::Host); - wself = 1.0; + wself = static_cast(1.0); rfac0 = rfac0_in; rmin0 = rmin0_in; @@ -63,7 +63,7 @@ SNAKokkos::SNAKokkos(double rfac0_in, cglist = t_sna_1d("SNAKokkos::cglist",idxcg_max); if (bzero_flag) { - bzero = Kokkos::View("sna:bzero",twojmax+1); + bzero = Kokkos::View("sna:bzero",twojmax+1); auto h_bzero = Kokkos::create_mirror_view(bzero); double www = wself*wself*wself; @@ -78,20 +78,20 @@ SNAKokkos::SNAKokkos(double rfac0_in, /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -SNAKokkos::~SNAKokkos() +SNAKokkos::~SNAKokkos() { } -template +template inline -void SNAKokkos::build_indexlist() +void SNAKokkos::build_indexlist() { // index list for cglist int jdim = twojmax + 1; - idxcg_block = Kokkos::View("SNAKokkos::idxcg_block",jdim,jdim,jdim); + idxcg_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxcg_block"),jdim,jdim,jdim); auto h_idxcg_block = Kokkos::create_mirror_view(idxcg_block); int idxcg_count = 0; @@ -109,7 +109,7 @@ void SNAKokkos::build_indexlist() // index list for uarray // need to include both halves - idxu_block = Kokkos::View("SNAKokkos::idxu_block",jdim); + idxu_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_block"),jdim); auto h_idxu_block = Kokkos::create_mirror_view(idxu_block); int idxu_count = 0; @@ -124,7 +124,7 @@ void SNAKokkos::build_indexlist() Kokkos::deep_copy(idxu_block,h_idxu_block); // index list for half uarray - idxu_half_block = Kokkos::View("SNAKokkos::idxu_half_block",jdim); + idxu_half_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_half_block"),jdim); auto h_idxu_half_block = Kokkos::create_mirror_view(idxu_half_block); int idxu_half_count = 0; @@ -137,10 +137,35 @@ void SNAKokkos::build_indexlist() idxu_half_max = idxu_half_count; Kokkos::deep_copy(idxu_half_block, h_idxu_half_block); + // mapping between full and half indexing, encoding flipping + idxu_full_half = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_full_half"),idxu_max); + auto h_idxu_full_half = Kokkos::create_mirror_view(idxu_full_half); + + idxu_count = 0; + for(int j = 0; j <= twojmax; j++) { + int jju_half = h_idxu_half_block[j]; + for(int mb = 0; mb <= j; mb++) { + for(int ma = 0; ma <= j; ma++) { + FullHalfMapper mapper; + if (2*mb <= j) { + mapper.idxu_half = jju_half + mb * (j + 1) + ma; + mapper.flip_sign = 0; + } else { + mapper.idxu_half = jju_half + (j + 1 - mb) * (j + 1) - (ma + 1); + mapper.flip_sign = (((ma+mb)%2==0)?1:-1); + } + h_idxu_full_half[idxu_count] = mapper; + idxu_count++; + } + } + } + + Kokkos::deep_copy(idxu_full_half, h_idxu_full_half); + // index list for "cache" uarray // this is the GPU scratch memory requirements // applied the CPU structures - idxu_cache_block = Kokkos::View("SNAKokkos::idxu_cache_block",jdim); + idxu_cache_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxu_cache_block"),jdim); auto h_idxu_cache_block = Kokkos::create_mirror_view(idxu_cache_block); int idxu_cache_count = 0; @@ -162,7 +187,7 @@ void SNAKokkos::build_indexlist() if (j >= j1) idxb_count++; idxb_max = idxb_count; - idxb = Kokkos::View("SNAKokkos::idxb",idxb_max); + idxb = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxb"),idxb_max); auto h_idxb = Kokkos::create_mirror_view(idxb); idxb_count = 0; @@ -179,7 +204,7 @@ void SNAKokkos::build_indexlist() // reverse index list for beta and b - idxb_block = Kokkos::View("SNAKokkos::idxb_block",jdim,jdim,jdim); + idxb_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxb_block"),jdim,jdim,jdim); auto h_idxb_block = Kokkos::create_mirror_view(idxb_block); idxb_count = 0; @@ -205,10 +230,10 @@ void SNAKokkos::build_indexlist() idxz_count++; idxz_max = idxz_count; - idxz = Kokkos::View("SNAKokkos::idxz",idxz_max); + idxz = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxz"),idxz_max); auto h_idxz = Kokkos::create_mirror_view(idxz); - idxz_block = Kokkos::View("SNAKokkos::idxz_block", jdim,jdim,jdim); + idxz_block = Kokkos::View(Kokkos::NoInit("SNAKokkos::idxz_block"), jdim,jdim,jdim); auto h_idxz_block = Kokkos::create_mirror_view(idxz_block); idxz_count = 0; @@ -249,53 +274,63 @@ void SNAKokkos::build_indexlist() /* ---------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init() +void SNAKokkos::init() { init_clebsch_gordan(); init_rootpqarray(); } -template +template inline -void SNAKokkos::grow_rij(int newnatom, int newnmax) +void SNAKokkos::grow_rij(int newnatom, int newnmax) { if(newnatom <= natom && newnmax <= nmax) return; natom = newnatom; nmax = newnmax; + int natom_div = (natom + vector_length - 1) / vector_length; + + rij = t_sna_3d(Kokkos::NoInit("sna:rij"),natom,nmax,3); + wj = t_sna_2d(Kokkos::NoInit("sna:wj"),natom,nmax); + rcutij = t_sna_2d(Kokkos::NoInit("sna:rcutij"),natom,nmax); inside = t_sna_2i(Kokkos::NoInit("sna:inside"),natom,nmax); - element = t_sna_2i(Kokkos::NoInit("sna:rcutij"),natom,nmax); + element = t_sna_2i(Kokkos::NoInit("sna:element"),natom,nmax); dedr = t_sna_3d(Kokkos::NoInit("sna:dedr"),natom,nmax,3); #ifdef LMP_KOKKOS_GPU if (!host_flag) { - - cayleyklein = t_sna_2ckp(Kokkos::NoInit("sna:cayleyklein"), natom, nmax); + a_pack = t_sna_3c_ll(Kokkos::NoInit("sna:a_pack"),vector_length,nmax,natom_div); + b_pack = t_sna_3c_ll(Kokkos::NoInit("sna:b_pack"),vector_length,nmax,natom_div); + da_pack = t_sna_4c_ll(Kokkos::NoInit("sna:da_pack"),vector_length,nmax,natom_div,3); + db_pack = t_sna_4c_ll(Kokkos::NoInit("sna:db_pack"),vector_length,nmax,natom_div,3); + sfac_pack = t_sna_4d_ll(Kokkos::NoInit("sna:sfac_pack"),vector_length,nmax,natom_div,4); ulisttot = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot"),1,1,1); // dummy allocation ulisttot_full = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot"),1,1,1); - ulisttot_re = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_re"),idxu_half_max,nelements,natom); - ulisttot_im = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_im"),idxu_half_max,nelements,natom); - ulisttot_pack = t_sna_4c_ll(Kokkos::NoInit("sna:ulisttot_pack"),32,idxu_max,nelements,(natom+32-1)/32); + ulisttot_re_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_re_pack"),vector_length,idxu_half_max,nelements,natom_div); + ulisttot_im_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_im_pack"),vector_length,idxu_half_max,nelements,natom_div); + ulisttot_pack = t_sna_4c_ll(Kokkos::NoInit("sna:ulisttot_pack"),vector_length,idxu_max,nelements,natom_div); ulist = t_sna_3c_ll(Kokkos::NoInit("sna:ulist"),1,1,1); zlist = t_sna_3c_ll(Kokkos::NoInit("sna:zlist"),1,1,1); - zlist_pack = t_sna_4c_ll(Kokkos::NoInit("sna:zlist_pack"),32,idxz_max,ndoubles,(natom+32-1)/32); + zlist_pack = t_sna_4c_ll(Kokkos::NoInit("sna:zlist_pack"),vector_length,idxz_max,ndoubles,natom_div); blist = t_sna_3d_ll(Kokkos::NoInit("sna:blist"),idxb_max,ntriples,natom); - blist_pack = t_sna_4d_ll(Kokkos::NoInit("sna:blist_pack"),32,idxb_max,ntriples,(natom+32-1)/32); - ylist = t_sna_3c_ll(Kokkos::NoInit("sna:ylist"),idxu_half_max,nelements,natom); - ylist_pack_re = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_re"),32,idxu_half_max,nelements,(natom+32-1)/32); - ylist_pack_im = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_im"),32,idxu_half_max,nelements,(natom+32-1)/32); + blist_pack = t_sna_4d_ll(Kokkos::NoInit("sna:blist_pack"),vector_length,idxb_max,ntriples,natom_div); + ylist = t_sna_3c_ll(Kokkos::NoInit("sna:ylist"),1,1,1); + ylist_pack_re = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_re"),vector_length,idxu_half_max,nelements,natom_div); + ylist_pack_im = t_sna_4d_ll(Kokkos::NoInit("sna:ylist_pack_im"),vector_length,idxu_half_max,nelements,natom_div); dulist = t_sna_4c3_ll(Kokkos::NoInit("sna:dulist"),1,1,1); } else { #endif - rij = t_sna_3d(Kokkos::NoInit("sna:rij"),natom,nmax,3); - wj = t_sna_2d(Kokkos::NoInit("sna:wj"),natom,nmax); - rcutij = t_sna_2d(Kokkos::NoInit("sna:rcutij"),natom,nmax); + a_pack = t_sna_3c_ll(Kokkos::NoInit("sna:a_pack"),1,1,1); + b_pack = t_sna_3c_ll(Kokkos::NoInit("sna:b_pack"),1,1,1); + da_pack = t_sna_4c_ll(Kokkos::NoInit("sna:da_pack"),1,1,1,1); + db_pack = t_sna_4c_ll(Kokkos::NoInit("sna:db_pack"),1,1,1,1); + sfac_pack = t_sna_4d_ll(Kokkos::NoInit("sna:sfac_pack"),1,1,1,1); ulisttot = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot"),idxu_half_max,nelements,natom); ulisttot_full = t_sna_3c_ll(Kokkos::NoInit("sna:ulisttot_full"),idxu_max,nelements,natom); - ulisttot_re = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_re"),1,1,1); - ulisttot_im = t_sna_3d_ll(Kokkos::NoInit("sna:ulisttot_im"),1,1,1); + ulisttot_re_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_re"),1,1,1,1); + ulisttot_im_pack = t_sna_4d_ll(Kokkos::NoInit("sna:ulisttot_im"),1,1,1,1); ulisttot_pack = t_sna_4c_ll(Kokkos::NoInit("sna:ulisttot_pack"),1,1,1,1); ulist = t_sna_3c_ll(Kokkos::NoInit("sna:ulist"),idxu_cache_max,natom,nmax); zlist = t_sna_3c_ll(Kokkos::NoInit("sna:zlist"),idxz_max,ndoubles,natom); @@ -323,81 +358,85 @@ void SNAKokkos::grow_rij(int newnatom, int newnmax) ComputeFusedDeidrj, which are one warp per atom-neighbor pair. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_cayley_klein(const int& iatom, const int& jnbor, const double& x, const double& y, - const double& z, const double& rcut, const double& wj_local) +void SNAKokkos::compute_cayley_klein(const int& iatom_mod, const int& jnbor, const int& iatom_div) { - //const double x = rij(iatom,jnbor,0); - //const double y = rij(iatom,jnbor,1); - //const double z = rij(iatom,jnbor,2); - const double rsq = x * x + y * y + z * z; - const double r = sqrt(rsq); - //const double rcut = rcutij(iatom, jnbor); - const double rscale0 = rfac0 * MY_PI / (rcut - rmin0); - const double theta0 = (r - rmin0) * rscale0; - double sn, cs; - sincos(theta0, &sn, &cs); - const double z0 = r * cs / sn; - const double dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; + const int iatom = iatom_mod + vector_length * iatom_div; + const auto x = rij(iatom,jnbor,0); + const auto y = rij(iatom,jnbor,1); + const auto z = rij(iatom,jnbor,2); + const auto rsq = x * x + y * y + z * z; + const auto r = sqrt(rsq); + const auto rcut = rcutij(iatom, jnbor); + const auto rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); + const auto theta0 = (r - rmin0) * rscale0; + real sn, cs; + sincos_wrapper(theta0, &sn, &cs); + const real z0 = r * cs / sn; + const real dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; - //const double wj_local = wj(iatom, jnbor); - double sfac, dsfac; + const auto wj_local = wj(iatom, jnbor); + real sfac, dsfac; compute_s_dsfac(r, rcut, sfac, dsfac); sfac *= wj_local; dsfac *= wj_local; - const double rinv = 1.0 / r; - const double ux = x * rinv; - const double uy = y * rinv; - const double uz = z * rinv; + const auto rinv = static_cast(1.0) / r; + const auto ux = x * rinv; + const auto uy = y * rinv; + const auto uz = z * rinv; - const double r0inv = 1.0 / sqrt(r * r + z0 * z0); + const auto r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); - const SNAcomplex a = { z0 * r0inv, -z * r0inv }; - const SNAcomplex b = { r0inv * y, -r0inv * x }; + const complex a = { z0 * r0inv, -z * r0inv }; + const complex b = { r0inv * y, -r0inv * x }; - const double dr0invdr = -r0inv * r0inv * r0inv * (r + z0 * dz0dr); + const auto dr0invdr = -r0inv * r0inv * r0inv * (r + z0 * dz0dr); - const double dr0invx = dr0invdr * ux; - const double dr0invy = dr0invdr * uy; - const double dr0invz = dr0invdr * uz; + const auto dr0invx = dr0invdr * ux; + const auto dr0invy = dr0invdr * uy; + const auto dr0invz = dr0invdr * uz; - const double dz0x = dz0dr * ux; - const double dz0y = dz0dr * uy; - const double dz0z = dz0dr * uz; + const auto dz0x = dz0dr * ux; + const auto dz0y = dz0dr * uy; + const auto dz0z = dz0dr * uz; - const SNAcomplex dax = { dz0x * r0inv + z0 * dr0invx, -z * dr0invx }; - const SNAcomplex day = { dz0y * r0inv + z0 * dr0invy, -z * dr0invy }; - const SNAcomplex daz = { dz0z * r0inv + z0 * dr0invz, -z * dr0invz - r0inv }; + const complex dax = { dz0x * r0inv + z0 * dr0invx, -z * dr0invx }; + const complex day = { dz0y * r0inv + z0 * dr0invy, -z * dr0invy }; + const complex daz = { dz0z * r0inv + z0 * dr0invz, -z * dr0invz - r0inv }; - const SNAcomplex dbx = { y * dr0invx, -x * dr0invx - r0inv }; - const SNAcomplex dby = { y * dr0invy + r0inv, -x * dr0invy }; - const SNAcomplex dbz = { y * dr0invz, -x * dr0invz }; + const complex dbx = { y * dr0invx, -x * dr0invx - r0inv }; + const complex dby = { y * dr0invy + r0inv, -x * dr0invy }; + const complex dbz = { y * dr0invz, -x * dr0invz }; - const double dsfacux = dsfac * ux; - const double dsfacuy = dsfac * uy; - const double dsfacuz = dsfac * uz; + const auto dsfacux = dsfac * ux; + const auto dsfacuy = dsfac * uy; + const auto dsfacuz = dsfac * uz; - CayleyKleinPack ckp{}; - ckp.a = a; - ckp.b = b; - ckp.da[0] = dax; - ckp.db[0] = dbx; - ckp.da[1] = day; - ckp.db[1] = dby; - ckp.da[2] = daz; - ckp.db[2] = dbz; - ckp.sfac = sfac; - ckp.dsfacu[0] = dsfacux; - ckp.dsfacu[1] = dsfacuy; - ckp.dsfacu[2] = dsfacuz; + a_pack(iatom_mod,jnbor,iatom_div) = a; + b_pack(iatom_mod,jnbor,iatom_div) = b; + + da_pack(iatom_mod,jnbor,iatom_div,0) = dax; + db_pack(iatom_mod,jnbor,iatom_div,0) = dbx; + + da_pack(iatom_mod,jnbor,iatom_div,1) = day; + db_pack(iatom_mod,jnbor,iatom_div,1) = dby; + + da_pack(iatom_mod,jnbor,iatom_div,2) = daz; + db_pack(iatom_mod,jnbor,iatom_div,2) = dbz; + + sfac_pack(iatom_mod,jnbor,iatom_div,0) = sfac; + sfac_pack(iatom_mod,jnbor,iatom_div,1) = dsfacux; + sfac_pack(iatom_mod,jnbor,iatom_div,2) = dsfacuy; + sfac_pack(iatom_mod,jnbor,iatom_div,3) = dsfacuz; + + // we need to explicitly zero `dedr` somewhere before hitting + // ComputeFusedDeidrj --- this is just a convenient place to do it. + dedr(iatom_mod + vector_length * iatom_div, jnbor, 0) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 1) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 2) = static_cast(0.); - // Yes, this breaks the standard mantra of using SoA - // instead of AoS, but it's net fine because of the - // one warp per atom/neighbor pair for the recursive - // polynomials. There's good L1 reuse, anyway. - cayleyklein(iatom, jnbor) = ckp; } /* ---------------------------------------------------------------------- @@ -406,30 +445,28 @@ void SNAKokkos::compute_cayley_klein(const int& iatom, const int& jn advantage of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) +void SNAKokkos::pre_ui(const int& iatom_mod, const int& j, const int& ielem, const int& iatom_div) { + for (int jelem = 0; jelem < nelements; jelem++) { - for (int j = 0; j <= twojmax; j++) { - const int jju_half = idxu_half_block(j); + int jju_half = idxu_half_block(j); - // Only diagonal elements get initialized - // Top half only: gets symmetrized by TransformUi - // for (int m = 0; m < (j+1)*(j/2+1); m++) - Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, (j+1)*(j/2+1)), - [&] (const int m) { + // Only diagonal elements get initialized + // Top half only: gets symmetrized by TransformUi - const int jjup = jju_half + m; + for (int mb = 0; 2*mb <= j; mb++) { + for (int ma = 0; ma <= j; ma++) { - // if m is on the "diagonal", initialize it with the self energy. - // Otherwise zero it out - double re_part = 0.; - if (m % (j+2) == 0 && (!chem_flag || ielem == jelem || wselfall_flag)) { re_part = wself; } + real re_part = static_cast(0.); + if (ma == mb && (!chem_flag || ielem == jelem || wselfall_flag)) { re_part = wself; } - ulisttot_re(jjup, jelem, iatom) = re_part; - ulisttot_im(jjup, jelem, iatom) = 0.; - }); + ulisttot_re_pack(iatom_mod, jju_half, jelem, iatom_div) = re_part; + ulisttot_im_pack(iatom_mod, jju_half, jelem, iatom_div) = static_cast(0.); + + jju_half++; + } } } @@ -440,9 +477,9 @@ void SNAKokkos::pre_ui(const typename Kokkos::TeamPolicy accumulating to the total. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom, const int jnbor) +void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // utot(j,ma,mb) = 0 for all j,ma,ma @@ -452,119 +489,122 @@ void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - // Each warp is accessing the same pack: take advantage of - // L1 reuse - const CayleyKleinPack& ckp = cayleyklein(iatom, jnbor); - const SNAcomplex a = ckp.a; - const SNAcomplex b = ckp.b; - const double sfac = ckp.sfac; + // load parameters + const auto a = a_pack(iatom_mod, jnbor, iatom_div); + const auto b = b_pack(iatom_mod, jnbor, iatom_div); + const auto sfac = sfac_pack(iatom_mod, jnbor, iatom_div, 0); - const int jelem = element(iatom, jnbor); + const int jelem = element(iatom_mod + vector_length * iatom_div, jnbor); - // VMK Section 4.8.2 + // we need to "choose" when to bend + // this for loop is here for context --- we expose additional + // parallelism over this loop instead + //for (int j_bend = 0; j_bend <= twojmax; j_bend++) { - // All writes go to global memory and shared memory - // so we can avoid all global memory reads - Kokkos::single(Kokkos::PerThread(team), [=]() { - buf1[0] = {1.,0.}; - Kokkos::atomic_add(&(ulisttot_re(0,jelem,iatom)), sfac); - }); + // level 0 is just 1. + ulist_wrapper.set(0, complex::one()); - for (int j = 1; j <= twojmax; j++) { + // j from before the bend, don't store, mb == 0 + // this is "creeping up the side" + for (int j = 1; j <= j_bend; j++) { - const int jju = idxu_half_block[j]; + int jjup = idxu_half_block[j-1]; - // fill in left side of matrix layer from previous layer + constexpr int mb = 0; // intentional for readability, compiler should optimize this out - // Flatten loop over ma, mb - // for (int ma = 0; ma <= j; ma++) - const int n_ma = j+1; - // for (int mb = 0; 2*mb <= j; mb++) - const int n_mb = j/2+1; + complex ulist_accum = complex::zero(); - const int total_iters = n_ma * n_mb; + int ma; + for (ma = 0; ma < j; ma++) { + const int jjup_index = idxu_half_block[j - 1] + mb * j + ma; - //for (int m = 0; m < total_iters; m++) { - Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, total_iters), - [&] (const int m) { + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); - // ma fast, mb slow - // Equivalent to `int ma = m % n_ma; int mb = m / n_ma;` IF everything's positive. - const int mb = m / n_ma; - const int ma = m - mb * n_ma; + // ulist_accum += rootpq * a.conj() * ulist_prev; + real rootpq = rootpqarray(j - ma, j - mb); + ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); + ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); - // index into global memory array - const int jju_index = jju+m; + // store ulist_accum, we atomic accumulate values after the bend, so no atomic add here + ulist_wrapper.set(ma, ulist_accum); - // index into shared memory buffer for this level - const int jju_shared_idx = m; + // next value + // ulist_accum = -rootpq * b.conj() * ulist_prev; + rootpq = rootpqarray(ma + 1, j - mb); + ulist_accum.re = -rootpq * (b.re * ulist_prev.re + b.im * ulist_prev.im); + ulist_accum.im = -rootpq * (b.re * ulist_prev.im - b.im * ulist_prev.re); - // index into shared memory buffer for next level - const int jjup_shared_idx = jju_shared_idx - mb; - - SNAcomplex u_accum = {0., 0.}; - - // VMK recursion relation: grab contribution which is multiplied by b* - const double rootpq2 = -rootpqarray(ma, j - mb); - const SNAcomplex u_up2 = rootpq2*((ma > 0)?buf1[jjup_shared_idx-1]:SNAcomplex(0.,0.)); - - // u_accum += conj(b) * u_up2 - caconjxpy(b, u_up2, u_accum); - - // VMK recursion relation: grab contribution which is multiplied by a* - const double rootpq1 = rootpqarray(j - ma, j - mb); - const SNAcomplex u_up1 = rootpq1*((ma < j)?buf1[jjup_shared_idx]:SNAcomplex(0.,0.)); - - // u_accum += conj(a) * u_up1 - caconjxpy(a, u_up1, u_accum); - - // back up into shared memory for next iter - buf2[jju_shared_idx] = u_accum; - - Kokkos::atomic_add(&(ulisttot_re(jju_index,jelem,iatom)), sfac * u_accum.re); - Kokkos::atomic_add(&(ulisttot_im(jju_index,jelem,iatom)), sfac * u_accum.im); - - // copy left side to right side with inversion symmetry VMK 4.4(2) - // u[ma-j,mb-j] = (-1)^(ma-mb)*Conj([u[ma,mb)) - // if j is even (-> physical j integer), last element maps to self, skip - - const int sign_factor = (((ma+mb)%2==0)?1:-1); - const int jju_shared_flip = (j+1-mb)*(j+1)-(ma+1); - - if (sign_factor == 1) { - u_accum.im = -u_accum.im; - } else { - u_accum.re = -u_accum.re; } - if (j%2==1 && mb+1==n_mb) { - buf2[jju_shared_flip] = u_accum; + ulist_wrapper.set(ma, ulist_accum); + } + + // now we're after the bend, start storing but only up to the "half way point" + const int j_half_way = MIN(2 * j_bend, twojmax); + + int mb = 1; + int j; //= j_bend + 1; // need this value below + for (j = j_bend + 1; j <= j_half_way; j++) { + + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + complex ulist_accum = complex::zero(); + + int ma; + for (ma = 0; ma < j; ma++) { + + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); + + // atomic add the previous level here + Kokkos::atomic_add(&(ulisttot_re_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.re * sfac); + Kokkos::atomic_add(&(ulisttot_im_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.im * sfac); + + // ulist_accum += rootpq * b * ulist_prev; + real rootpq = rootpqarray(j - ma, mb); + ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); + ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); + + // store ulist_accum + ulist_wrapper.set(ma, ulist_accum); + + // next value + // ulist_accum = rootpq * a * ulist_prev; + rootpq = rootpqarray(ma + 1, mb); + ulist_accum.re = rootpq * (a.re * ulist_prev.re - a.im * ulist_prev.im); + ulist_accum.im = rootpq * (a.re * ulist_prev.im + a.im * ulist_prev.re); } - // symmetric part of ulisttot is generated in TransformUi + ulist_wrapper.set(ma, ulist_accum); - }); - // In CUDA backend, - // ThreadVectorRange has a __syncwarp (appropriately masked for - // vector lengths < 32) implict at the end + mb++; + } - // swap double buffers - auto tmp = buf1; buf1 = buf2; buf2 = tmp; + // atomic add the last level + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + for (int ma = 0; ma < j; ma++) { + const complex ulist_prev = ulist_wrapper.get(ma); + + // atomic add the previous level here + Kokkos::atomic_add(&(ulisttot_re_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.re * sfac); + Kokkos::atomic_add(&(ulisttot_im_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.im * sfac); + } + + //} // end of "reference" loop over j_bend - } } @@ -574,9 +614,9 @@ void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) +void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) { const int j1 = idxz(jjz, 0); @@ -589,14 +629,13 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const double* cgblock = cglist.data() + idxcg_block(j1, j2, j); + const real* cgblock = cglist.data() + idxcg_block(j1, j2, j); int idouble = 0; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - double ztmp_r = 0.; - double ztmp_i = 0.; + complex ztmp = complex::zero(); int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; @@ -615,12 +654,12 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con #pragma unroll #endif for(int ia = 0; ia < na; ia++) { - const SNAcomplex utot1 = ulisttot_pack(iatom_mod, jju1+ma1, elem1, iatom_div); - const SNAcomplex utot2 = ulisttot_pack(iatom_mod, jju2+ma2, elem2, iatom_div); + const auto utot1 = ulisttot_pack(iatom_mod, jju1+ma1, elem1, iatom_div); + const auto utot2 = ulisttot_pack(iatom_mod, jju2+ma2, elem2, iatom_div); const auto cgcoeff_a = cgblock[icga]; const auto cgcoeff_b = cgblock[icgb]; - ztmp_r += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.re - utot1.im * utot2.im); - ztmp_i += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.im + utot1.im * utot2.re); + ztmp.re += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.re - utot1.im * utot2.im); + ztmp.im += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.im + utot1.im * utot2.re); ma1++; ma2--; icga += j2; @@ -632,11 +671,11 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con } // end loop over ib if (bnorm_flag) { - ztmp_r /= (j + 1); - ztmp_i /= (j + 1); + ztmp.re /= (j + 1); + ztmp.im /= (j + 1); } - zlist_pack(iatom_mod,jjz,idouble,iatom_div) = { ztmp_r, ztmp_i }; + zlist_pack(iatom_mod,jjz,idouble,iatom_div) = ztmp; idouble++; } @@ -649,9 +688,9 @@ void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, con divergence. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) +void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -712,10 +751,10 @@ void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, con const auto utot = ulisttot_pack(iatom_mod, jju_index, elem3, iatom_div); const auto zloc = zlist_pack(iatom_mod, jjz_index, idouble, iatom_div); - sumzu += 0.5 * (utot.re * zloc.re + utot.im * zloc.im); + sumzu += static_cast(0.5) * (utot.re * zloc.re + utot.im * zloc.im); } // end if jeven - sumzu *= 2.0; + sumzu *= static_cast(2.0); if (bzero_flag) { if (!wselfall_flag) { if (elem1 == elem2 && elem1 == elem3) { @@ -742,12 +781,12 @@ void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, con divergence. GPU version. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, - const Kokkos::View &beta_pack) +void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, + const Kokkos::View &beta_pack) { - double betaj; + real betaj; const int j1 = idxz(jjz, 0); const int j2 = idxz(jjz, 1); @@ -760,15 +799,15 @@ void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const double *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - double ztmp_r = 0.0; - double ztmp_i = 0.0; + real ztmp_r = 0.0; + real ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -787,8 +826,8 @@ void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, #pragma unroll #endif for (int ia = 0; ia < na; ia++) { - const SNAcomplex utot1 = ulisttot_pack(iatom_mod,jju1+ma1,elem1,iatom_div); - const SNAcomplex utot2 = ulisttot_pack(iatom_mod,jju2+ma2,elem2,iatom_div); + const auto utot1 = ulisttot_pack(iatom_mod,jju1+ma1,elem1,iatom_div); + const auto utot2 = ulisttot_pack(iatom_mod,jju2+ma2,elem2,iatom_div); const auto cgcoeff_a = cgblock[icga]; const auto cgcoeff_b = cgblock[icgb]; ztmp_r += cgcoeff_a * cgcoeff_b * (utot1.re * utot2.re - utot1.im * utot2.im); @@ -849,169 +888,173 @@ void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, and accumulation into dEidRj. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom, const int jnbor) +void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // get shared memory offset - const int max_m_tile = (twojmax+1)*(twojmax/2+1); + // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer + const int tile_size = vector_length * (twojmax + 1); + const int team_rank = team.team_rank(); - const int scratch_shift = team_rank * max_m_tile; - const int jelem = element(iatom, jnbor); + const int scratch_shift = team_rank * tile_size; - // See notes on data layouts for shared memory caching - // in `compute_ui`. + // extract, wrap shared memory buffer + WignerWrapper ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper dulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - // double buffer for ulist - SNAcomplex* ulist_buf1 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; - SNAcomplex* ulist_buf2 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; + // load parameters + const auto a = a_pack(iatom_mod, jnbor, iatom_div); + const auto b = b_pack(iatom_mod, jnbor, iatom_div); + const auto da = da_pack(iatom_mod, jnbor, iatom_div, dir); + const auto db = db_pack(iatom_mod, jnbor, iatom_div, dir); + const auto sfac = sfac_pack(iatom_mod, jnbor, iatom_div, 0); + const auto dsfacu = sfac_pack(iatom_mod, jnbor, iatom_div, dir + 1); // dsfac * u - // double buffer for dulist - SNAcomplex* dulist_buf1 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; - SNAcomplex* dulist_buf2 = (SNAcomplex*)team.team_shmem( ).get_shmem(team.team_size()*max_m_tile*sizeof(SNAcomplex), 0) + scratch_shift; + const int jelem = element(iatom_mod + vector_length * iatom_div, jnbor); - const CayleyKleinPack& ckp = cayleyklein(iatom, jnbor); + auto dedr_full_sum = static_cast(0.); - const SNAcomplex a = ckp.a; - const SNAcomplex b = ckp.b; - const SNAcomplex da = ckp.da[dir]; - const SNAcomplex db = ckp.db[dir]; - const double sfac = ckp.sfac; - const double dsfacu = ckp.dsfacu[dir]; // dsfac * u + // we need to "choose" when to bend + // this for loop is here for context --- we expose additional + // parallelism over this loop instead + //for (int j_bend = 0; j_bend <= twojmax; j_bend++) { - // Accumulate the full contribution to dedr on the fly - const SNAcomplex y_local = ylist(0, jelem, iatom); + // level 0 is just 1, 0 + ulist_wrapper.set(0, complex::one()); + dulist_wrapper.set(0, complex::zero()); - // Symmetry factor of 0.5 b/c 0 element is on diagonal for even j==0 - double dedr_full_sum = 0.5 * dsfacu * y_local.re; + // j from before the bend, don't store, mb == 0 + // this is "creeping up the side" + for (int j = 1; j <= j_bend; j++) { - // single has a warp barrier at the end - Kokkos::single(Kokkos::PerThread(team), [=]() { + int jjup = idxu_half_block[j-1]; - ulist_buf1[0] = {1., 0.}; - dulist_buf1[0] = {0., 0.}; - }); + constexpr int mb = 0; // intentional for readability, compiler should optimize this out - for (int j = 1; j <= twojmax; j++) { - int jju_half = idxu_half_block[j]; + complex ulist_accum = complex::zero(); + complex dulist_accum = complex::zero(); - // flatten the loop over ma,mb + int ma; + for (ma = 0; ma < j; ma++) { + const int jjup_index = idxu_half_block[j - 1] + mb * j + ma; - // for (int ma = 0; ma <= j; ma++) - const int n_ma = j+1; - // for (int mb = 0; 2*mb <= j; mb++) - const int n_mb = j/2+1; + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); + const complex dulist_prev = dulist_wrapper.get(ma); - const int total_iters = n_ma * n_mb; + // ulist_accum += rootpq * a.conj() * ulist_prev; + real rootpq = rootpqarray(j - ma, j - mb); + ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); + ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); - double dedr_sum = 0.; // j-local sum + // product rule of above + dulist_accum.re += rootpq * (da.re * ulist_prev.re + da.im * ulist_prev.im + a.re * dulist_prev.re + a.im * dulist_prev.im); + dulist_accum.im += rootpq * (da.re * ulist_prev.im - da.im * ulist_prev.re + a.re * dulist_prev.im - a.im * dulist_prev.re); - //for (int m = 0; m < total_iters; m++) { - Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, total_iters), - [&] (const int m, double& sum_tmp) { + // store ulist_accum, we atomic accumulate values after the bend, so no atomic add here + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); - // ma fast, mb slow - const int mb = m / n_ma; - const int ma = m - mb * n_ma; + // next value + // ulist_accum = -rootpq * b.conj() * ulist_prev; + rootpq = rootpqarray(ma + 1, j - mb); + ulist_accum.re = -rootpq * (b.re * ulist_prev.re + b.im * ulist_prev.im); + ulist_accum.im = -rootpq * (b.re * ulist_prev.im - b.im * ulist_prev.re); - const int jju_half_index = jju_half+m; + // product rule of above + dulist_accum.re = -rootpq * (db.re * ulist_prev.re + db.im * ulist_prev.im + b.re * dulist_prev.re + b.im * dulist_prev.im); + dulist_accum.im = -rootpq * (db.re * ulist_prev.im - db.im * ulist_prev.re + b.re * dulist_prev.im - b.im * dulist_prev.re); - // Load y_local, apply the symmetry scaling factor - // The "secret" of the shared memory optimization is it eliminates - // all global memory reads to duidrj in lieu of caching values in - // shared memory and otherwise always writing, making the kernel - // ultimately compute bound. We take advantage of that by adding - // some reads back in. - auto y_local = ylist(jju_half_index, jelem, iatom); - if (j % 2 == 0 && 2*mb == j) { - if (ma == mb) { y_local = 0.5*y_local; } - else if (ma > mb) { y_local = { 0., 0. }; } // can probably avoid this outright + } + + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); + } + + // now we're after the bend, start storing but only up to the "half way point" + const int j_half_way = MIN(2 * j_bend, twojmax); + + int mb = 1; + int j; //= j_bend + 1; // need this value below + for (j = j_bend + 1; j <= j_half_way; j++) { + + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + complex ulist_accum = complex::zero(); + complex dulist_accum = complex::zero(); + + int ma; + for (ma = 0; ma < j; ma++) { + + // grab y_local early + // this will never be the last element of a row, no need to rescale. + auto y_local = complex(ylist_pack_re(iatom_mod, jjup + ma, jelem, iatom_div), ylist_pack_im(iatom_mod, jjup+ma, jelem, iatom_div)); + + // grab the cached value + const complex ulist_prev = ulist_wrapper.get(ma); + const complex dulist_prev = dulist_wrapper.get(ma); + + // ulist_accum += rootpq * b * ulist_prev; + real rootpq = rootpqarray(j - ma, mb); + ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); + ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); + + // product rule of above + dulist_accum.re += rootpq * (db.re * ulist_prev.re - db.im * ulist_prev.im + b.re * dulist_prev.re - b.im * dulist_prev.im); + dulist_accum.im += rootpq * (db.re * ulist_prev.im + db.im * ulist_prev.re + b.re * dulist_prev.im + b.im * dulist_prev.re); + + // store ulist_accum + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); + + // Directly accumulate deidrj into sum_tmp + const complex du_prod = (dsfacu * ulist_prev) + (sfac * dulist_prev); + dedr_full_sum += du_prod.re * y_local.re + du_prod.im * y_local.im; + + // next value + // ulist_accum = rootpq * a * ulist_prev; + rootpq = rootpqarray(ma + 1, mb); + ulist_accum.re = rootpq * (a.re * ulist_prev.re - a.im * ulist_prev.im); + ulist_accum.im = rootpq * (a.re * ulist_prev.im + a.im * ulist_prev.re); + + // product rule of above + dulist_accum.re = rootpq * (da.re * ulist_prev.re - da.im * ulist_prev.im + a.re * dulist_prev.re - a.im * dulist_prev.im); + dulist_accum.im = rootpq * (da.re * ulist_prev.im + da.im * ulist_prev.re + a.re * dulist_prev.im + a.im * dulist_prev.re); + + } + + ulist_wrapper.set(ma, ulist_accum); + dulist_wrapper.set(ma, dulist_accum); + + mb++; + } + + // accumulate the last level + const int jjup = idxu_half_block[j-1] + (mb - 1) * j; + + for (int ma = 0; ma < j; ma++) { + // grab y_local early + auto y_local = complex(ylist_pack_re(iatom_mod, jjup + ma, jelem, iatom_div), ylist_pack_im(iatom_mod, jjup+ma, jelem, iatom_div)); + if (j % 2 == 1 && 2*(mb-1) == j-1) { // double check me... + if (ma == (mb-1)) { y_local = static_cast(0.5)*y_local; } + else if (ma > (mb-1)) { y_local.re = static_cast(0.); y_local.im = static_cast(0.); } // can probably avoid this outright // else the ma < mb gets "double counted", cancelling the 0.5. } - // index into shared memory - const int jju_shared_idx = m; - const int jjup_shared_idx = jju_shared_idx - mb; - - // Need to compute and accumulate both u and du (mayhaps, we could probably - // balance some read and compute by reading u each time). - SNAcomplex u_accum = { 0., 0. }; - SNAcomplex du_accum = { 0., 0. }; - - const double rootpq2 = -rootpqarray(ma, j - mb); - const SNAcomplex u_up2 = rootpq2*((ma > 0) ? ulist_buf1[jjup_shared_idx-1]:SNAcomplex(0.,0.)); - - // u_accum += conj(b) * u_up2 - caconjxpy(b, u_up2, u_accum); - - const double rootpq1 = rootpqarray(j - ma, j - mb); - const SNAcomplex u_up1 = rootpq1*((ma < j) ? ulist_buf1[jjup_shared_idx]:SNAcomplex(0.,0.)); - - // u_accum += conj(a) * u_up1 - caconjxpy(a, u_up1, u_accum); - - // Next, spin up du_accum - const SNAcomplex du_up1 = rootpq1*((ma < j) ? dulist_buf1[jjup_shared_idx] : SNAcomplex(0.,0.)); - - // du_accum += conj(da) * u_up1 + conj(a) * du_up1 - caconjxpy(da, u_up1, du_accum); - caconjxpy(a, du_up1, du_accum); - - const SNAcomplex du_up2 = rootpq2*((ma > 0) ? dulist_buf1[jjup_shared_idx-1] : SNAcomplex(0.,0.)); - - // du_accum += conj(db) * u_up2 + conj(b) * du_up2 - caconjxpy(db, u_up2, du_accum); - caconjxpy(b, du_up2, du_accum); - - // Cache u_accum, du_accum to scratch memory. - ulist_buf2[jju_shared_idx] = u_accum; - dulist_buf2[jju_shared_idx] = du_accum; + const complex ulist_prev = ulist_wrapper.get(ma); + const complex dulist_prev = dulist_wrapper.get(ma); // Directly accumulate deidrj into sum_tmp - const SNAcomplex du_prod = (dsfacu * u_accum) + (sfac * du_accum); - sum_tmp += du_prod.re * y_local.re + du_prod.im * y_local.im; + const complex du_prod = (dsfacu * ulist_prev) + (sfac * dulist_prev); + dedr_full_sum += du_prod.re * y_local.re + du_prod.im * y_local.im; - // copy left side to right side with inversion symmetry VMK 4.4(2) - // u[ma-j][mb-j] = (-1)^(ma-mb)*Conj([u[ma][mb]) - if (j%2==1 && mb+1==n_mb) { - int sign_factor = (((ma+mb)%2==0)?1:-1); + } + //} // end reference loop over j_bend - const int jju_shared_flip = (j+1-mb)*(j+1)-(ma+1); + // dedr gets zeroed out at the start of each iteration in compute_cayley_klein + Kokkos::atomic_add(&(dedr(iatom_mod + vector_length * iatom_div, jnbor, dir)), static_cast(2.0) * dedr_full_sum); - if (sign_factor == 1) { - u_accum.im = -u_accum.im; - du_accum.im = -du_accum.im; - } else { - u_accum.re = -u_accum.re; - du_accum.re = -du_accum.re; - } - - // We don't need the second half of the tile for the deidrj accumulation. - // That's taken care of by the symmetry factor above. - // We do need it for ortho polynomial generation, though - ulist_buf2[jju_shared_flip] = u_accum; - dulist_buf2[jju_shared_flip] = du_accum; - } - - }, dedr_sum); - - // swap buffers - auto tmp = ulist_buf1; ulist_buf1 = ulist_buf2; ulist_buf2 = tmp; - tmp = dulist_buf1; dulist_buf1 = dulist_buf2; dulist_buf2 = tmp; - - // Accumulate dedr. This "should" be in a single, but - // a Kokkos::single call implies a warp sync, and we may - // as well avoid that. This does no harm as long as the - // final assignment is in a single block. - //Kokkos::single(Kokkos::PerThread(team), [=]() { - dedr_full_sum += dedr_sum; - //}); - } - - // Store the accumulated dedr. - Kokkos::single(Kokkos::PerThread(team), [&] () { - dedr(iatom,jnbor,dir) = dedr_full_sum*2.0; - }); } @@ -1025,9 +1068,9 @@ void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPoli advantage of the symmetry of the Wigner U matrices. * ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) +void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) { for (int jelem = 0; jelem < nelements; jelem++) { for (int j = 0; j <= twojmax; j++) { @@ -1042,8 +1085,8 @@ void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy(0.),static_cast(0.)); + if (m % (j+2) == 0 && (!chem_flag || ielem == jelem || wselfall_flag)) { init.re = wself; } //need to map iatom to element ulisttot(jjup, jelem, iatom) = init; }); @@ -1059,11 +1102,11 @@ void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - double rsq, r, x, y, z, z0, theta0; + real rsq, r, x, y, z, z0, theta0; // utot(j,ma,mb) = 0 for all j,ma,ma // utot(j,ma,ma) = 1 for all j,ma @@ -1089,9 +1132,9 @@ void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi_cpu(const int& iter) +void SNAKokkos::compute_zi_cpu(const int& iter) { const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1106,22 +1149,22 @@ void SNAKokkos::compute_zi_cpu(const int& iter) const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const double *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); int idouble = 0; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - zlist(jjz, idouble, iatom).re = 0.0; - zlist(jjz, idouble, iatom).im = 0.0; + zlist(jjz, idouble, iatom).re = static_cast(0.0); + zlist(jjz, idouble, iatom).im = static_cast(0.0); int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; int icgb = mb1min*(j2+1) + mb2max; for(int ib = 0; ib < nb; ib++) { - double suma1_r = 0.0; - double suma1_i = 0.0; + real suma1_r = static_cast(0.0); + real suma1_i = static_cast(0.0); int ma1 = ma1min; int ma2 = ma2max; @@ -1158,9 +1201,9 @@ void SNAKokkos::compute_zi_cpu(const int& iter) compute Bi by summing conj(Ui)*Zi, CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) +void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -1186,11 +1229,11 @@ void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy(0.0); + real sumzu_temp = static_cast(0.0); const int bound = (j+2)/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,(j+1)*bound), - [&] (const int mbma, double& sum) { + [&] (const int mbma, real& sum) { //for(int mb = 0; 2*mb < j; mb++) //for(int ma = 0; ma <= j; ma++) { const int ma = mbma % (j + 1); @@ -1209,7 +1252,7 @@ void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::compute_bi_cpu(const typename Kokkos::TeamPolicy(0.5)* (ulisttot_full(jju_index, elem3, iatom).re * zlist(jjz_index, jalloy, iatom).re + ulisttot_full(jju_index, elem3, iatom).im * zlist(jjz_index, jalloy, iatom).im); } // end if jeven Kokkos::single(Kokkos::PerThread(team), [&] () { - sumzu *= 2.0; + sumzu *= static_cast(2.0); // apply bzero shift @@ -1260,12 +1303,12 @@ void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi_cpu(int iter, - const Kokkos::View &beta) +void SNAKokkos::compute_yi_cpu(int iter, + const Kokkos::View &beta) { - double betaj; + real betaj; const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1280,15 +1323,15 @@ void SNAKokkos::compute_yi_cpu(int iter, const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const double *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - double ztmp_r = 0.0; - double ztmp_i = 0.0; + real ztmp_r = 0.0; + real ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -1296,8 +1339,8 @@ void SNAKokkos::compute_yi_cpu(int iter, for (int ib = 0; ib < nb; ib++) { - double suma1_r = 0.0; - double suma1_i = 0.0; + real suma1_r = 0.0; + real suma1_i = 0.0; int ma1 = ma1min; int ma2 = ma2max; @@ -1368,22 +1411,21 @@ void SNAKokkos::compute_yi_cpu(int iter, data layout ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - double rsq, r, x, y, z, z0, theta0, cs, sn; - double dz0dr; + real rsq, r, x, y, z, z0, theta0, cs, sn; + real dz0dr; x = rij(iatom,jnbor,0); y = rij(iatom,jnbor,1); z = rij(iatom,jnbor,2); rsq = x * x + y * y + z * z; r = sqrt(rsq); - double rscale0 = rfac0 * MY_PI / (rcutij(iatom,jnbor) - rmin0); + auto rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); theta0 = (r - rmin0) * rscale0; - cs = cos(theta0); - sn = sin(theta0); + sincos_wrapper(theta0, &sn, &cs); z0 = r * cs / sn; dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; @@ -1400,16 +1442,16 @@ void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - t_scalar3 final_sum; + t_scalar3 final_sum; const int jelem = element(iatom, jnbor); //for(int j = 0; j <= twojmax; j++) { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,twojmax+1), - [&] (const int& j, t_scalar3& sum_tmp) { + [&] (const int& j, t_scalar3& sum_tmp) { int jju_half = idxu_half_block[j]; int jju_cache = idxu_cache_block[j]; @@ -1467,12 +1509,12 @@ void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - double r, double wj, double rcut, int jelem) +void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real& r, const real& wj, const real& rcut, int jelem) { - const double sfac = compute_sfac(r, rcut) * wj; + const auto sfac = compute_sfac(r, rcut) * wj; Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,twojmax+1), [&] (const int& j) { @@ -1497,19 +1539,18 @@ void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - double x, double y, double z, - double z0, double r) +void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real& x, const real& y, const real& z, const real& z0, const real& r) { - double r0inv; - double a_r, b_r, a_i, b_i; - double rootpq; + real r0inv; + real a_r, b_r, a_i, b_i; + real rootpq; // compute Cayley-Klein parameters for unit quaternion - r0inv = 1.0 / sqrt(r * r + z0 * z0); + r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); a_r = r0inv * z0; a_i = -r0inv * z; b_r = r0inv * y; @@ -1589,23 +1630,23 @@ void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy Uses same cached data layout of ulist ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - double x, double y, double z, - double z0, double r, double dz0dr, - double wj, double rcut) +void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real& x, const real& y, const real& z, + const real& z0, const real& r, const real& dz0dr, + const real& wj, const real& rcut) { -double r0inv; - double a_r, a_i, b_r, b_i; - double da_r[3], da_i[3], db_r[3], db_i[3]; - double dz0[3], dr0inv[3], dr0invdr; - double rootpq; + real r0inv; + real a_r, a_i, b_r, b_i; + real da_r[3], da_i[3], db_r[3], db_i[3]; + real dz0[3], dr0inv[3], dr0invdr; + real rootpq; - double rinv = 1.0 / r; - double ux = x * rinv; - double uy = y * rinv; - double uz = z * rinv; + real rinv = 1.0 / r; + real ux = x * rinv; + real uy = y * rinv; + real uz = z * rinv; r0inv = 1.0 / sqrt(r * r + z0 * z0); a_r = z0 * r0inv; @@ -1720,8 +1761,8 @@ double r0inv; }); } - double sfac = compute_sfac(r, rcut); - double dsfac = compute_dsfac(r, rcut); + real sfac = compute_sfac(r, rcut); + real dsfac = compute_dsfac(r, rcut); sfac *= wj; dsfac *= wj; @@ -1755,9 +1796,9 @@ double r0inv; factorial n, wrapper for precomputed table ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::factorial(int n) +double SNAKokkos::factorial(int n) { //if (n < 0 || n > nmaxfactorial) { // char str[128]; @@ -1772,8 +1813,8 @@ double SNAKokkos::factorial(int n) factorial n table, size SNA::nmaxfactorial+1 ------------------------------------------------------------------------- */ -template -const double SNAKokkos::nfac_table[] = { +template +const double SNAKokkos::nfac_table[] = { 1, 1, 2, @@ -1948,9 +1989,9 @@ const double SNAKokkos::nfac_table[] = { the function delta given by VMK Eq. 8.2(1) ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::deltacg(int j1, int j2, int j) +double SNAKokkos::deltacg(int j1, int j2, int j) { double sfaccg = factorial((j1 + j2 + j) / 2 + 1); return sqrt(factorial((j1 + j2 - j) / 2) * @@ -1963,9 +2004,9 @@ double SNAKokkos::deltacg(int j1, int j2, int j) the quasi-binomial formula VMK 8.2.1(3) ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_clebsch_gordan() +void SNAKokkos::init_clebsch_gordan() { auto h_cglist = Kokkos::create_mirror_view(cglist); @@ -2033,23 +2074,23 @@ void SNAKokkos::init_clebsch_gordan() the p = 0, q = 0 entries are allocated and skipped for convenience. ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_rootpqarray() +void SNAKokkos::init_rootpqarray() { auto h_rootpqarray = Kokkos::create_mirror_view(rootpqarray); for (int p = 1; p <= twojmax; p++) for (int q = 1; q <= twojmax; q++) - h_rootpqarray(p,q) = sqrt(static_cast(p)/q); + h_rootpqarray(p,q) = static_cast(sqrt(static_cast(p)/q)); Kokkos::deep_copy(rootpqarray,h_rootpqarray); } /* ---------------------------------------------------------------------- */ -template +template inline -int SNAKokkos::compute_ncoeff() +int SNAKokkos::compute_ncoeff() { int ncount; @@ -2070,88 +2111,72 @@ int SNAKokkos::compute_ncoeff() /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -double SNAKokkos::compute_sfac(double r, double rcut) +real SNAKokkos::compute_sfac(real r, real rcut) { - if (switch_flag == 0) return 1.0; + constexpr real one = static_cast(1.0); + constexpr real zero = static_cast(0.0); + constexpr real onehalf = static_cast(0.5); + if (switch_flag == 0) return one; if (switch_flag == 1) { - if(r <= rmin0) return 1.0; - else if(r > rcut) return 0.0; + if(r <= rmin0) return one; + else if(r > rcut) return zero; else { - double rcutfac = MY_PI / (rcut - rmin0); - return 0.5 * (cos((r - rmin0) * rcutfac) + 1.0); + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + return onehalf * (cos((r - rmin0) * rcutfac) + one); } } - return 0.0; + return zero; } /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -double SNAKokkos::compute_dsfac(double r, double rcut) +real SNAKokkos::compute_dsfac(real r, real rcut) { - if (switch_flag == 0) return 0.0; + constexpr real zero = static_cast(0.0); + constexpr real onehalf = static_cast(0.5); + if (switch_flag == 0) return zero; if (switch_flag == 1) { - if(r <= rmin0) return 0.0; - else if(r > rcut) return 0.0; + if(r <= rmin0) return zero; + else if(r > rcut) return zero; else { - double rcutfac = MY_PI / (rcut - rmin0); - return -0.5 * sin((r - rmin0) * rcutfac) * rcutfac; + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + return -onehalf * sin((r - rmin0) * rcutfac) * rcutfac; } } - return 0.0; + return zero; } -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_s_dsfac(const double r, const double rcut, double& sfac, double& dsfac) { - if (switch_flag == 0) { sfac = 0.; dsfac = 0.; } +void SNAKokkos::compute_s_dsfac(const real r, const real rcut, real& sfac, real& dsfac) { + constexpr real one = static_cast(1.0); + constexpr real zero = static_cast(0.0); + constexpr real onehalf = static_cast(0.5); + if (switch_flag == 0) { sfac = zero; dsfac = zero; } else if (switch_flag == 1) { - if (r <= rmin0) { sfac = 1.0; dsfac = 0.0; } - else if (r > rcut) { sfac = 0.; dsfac = 0.; } + if (r <= rmin0) { sfac = one; dsfac = zero; } + else if (r > rcut) { sfac = zero; dsfac = zero; } else { - const double rcutfac = MY_PI / (rcut - rmin0); - double sn, cs; - sincos((r - rmin0) * rcutfac, &sn, &cs); - sfac = 0.5 * (cs + 1.0); - dsfac = -0.5 * sn * rcutfac; + const auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + real sn, cs; + sincos_wrapper((r - rmin0) * rcutfac, &sn, &cs); // need to create a wrapper + sfac = onehalf * (cs + one); + dsfac = -onehalf * sn * rcutfac; } - } else { sfac = 0.; dsfac = 0.; } -} - -/* ---------------------------------------------------------------------- */ - -// efficient complex FMA (i.e., y += a x) -template -KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::caxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y) { - y.re += a.re * x.re; - y.re -= a.im * x.im; - y.im += a.im * x.re; - y.im += a.re * x.im; -} - -/* ---------------------------------------------------------------------- */ - -// efficient complex FMA, conjugate of scalar (i.e.) y += (a.re - i a.im) x) -template -KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::caconjxpy(const SNAcomplex& a, const SNAcomplex& x, SNAcomplex& y) { - y.re += a.re * x.re; - y.re += a.im * x.im; - y.im -= a.im * x.re; - y.im += a.re * x.im; + } else { sfac = zero; dsfac = zero; } } /* ---------------------------------------------------------------------- */ // set direction of batched Duidrj -template +template KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::set_dir(int dir_) { +void SNAKokkos::set_dir(int dir_) { dir = dir_; } @@ -2159,8 +2184,8 @@ void SNAKokkos::set_dir(int dir_) { memory usage of arrays ------------------------------------------------------------------------- */ -template -double SNAKokkos::memory_usage() +template +double SNAKokkos::memory_usage() { int jdimpq = twojmax + 2; int jdim = twojmax + 1; @@ -2168,45 +2193,53 @@ double SNAKokkos::memory_usage() bytes = 0; - bytes += jdimpq*jdimpq * sizeof(double); // pqarray - bytes += idxcg_max * sizeof(double); // cglist + bytes += jdimpq*jdimpq * sizeof(real); // pqarray + bytes += idxcg_max * sizeof(real); // cglist #ifdef LMP_KOKKOS_GPU if (!host_flag) { - auto natom_pad = (natom+32-1)/32; + auto natom_pad = (natom+vector_length-1)/vector_length; - bytes += natom * idxu_half_max * nelements * sizeof(double); // ulisttot_re - bytes += natom * idxu_half_max * nelements * sizeof(double); // ulisttot_im - bytes += natom_pad * idxu_max * nelements * sizeof(double) * 2; // ulisttot_pack + bytes += natom_pad * nmax * sizeof(real) * 2; // a_pack + bytes += natom_pad * nmax * sizeof(real) * 2; // b_pack + bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // da_pack + bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // db_pack + bytes += natom_pad * nmax * 4 * sizeof(real); // sfac_pack - bytes += natom_pad * idxz_max * ndoubles * sizeof(double) * 2; // zlist_pack - bytes += natom_pad * idxb_max * ntriples * sizeof(double); // blist_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(double); // ylist_pack_re - bytes += natom_pad * idxu_half_max * nelements * sizeof(double); // ylist_pack_im - bytes += natom * idxu_half_max * nelements * sizeof(double) * 2; // ylist + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_re_pack + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_im_pack + bytes += natom_pad * idxu_max * nelements * sizeof(real) * 2; // ulisttot_pack + + bytes += natom_pad * idxz_max * ndoubles * sizeof(real) * 2; // zlist_pack + bytes += natom_pad * idxb_max * ntriples * sizeof(real); // blist_pack + + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_re + bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_im } else { #endif - bytes += natom * nmax * idxu_cache_max * sizeof(double) * 2; // ulist - bytes += natom * idxu_half_max * nelements * sizeof(double) * 2; // ulisttot + bytes += natom * nmax * idxu_cache_max * sizeof(real) * 2; // ulist + bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ulisttot + bytes += natom * idxu_max * nelements * sizeof(real) * 2; // ulisttot_full - bytes += natom * idxz_max * ndoubles * sizeof(double) * 2; // zlist - bytes += natom * idxb_max * ntriples * sizeof(double); // blist + bytes += natom * idxz_max * ndoubles * sizeof(real) * 2; // zlist + bytes += natom * idxb_max * ntriples * sizeof(real); // blist - bytes += natom * idxu_half_max * nelements * sizeof(double) * 2; // ylist + bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ylist - bytes += natom * nmax * idxu_cache_max * 3 * sizeof(double) * 2; // dulist + bytes += natom * nmax * idxu_cache_max * 3 * sizeof(real) * 2; // dulist #ifdef LMP_KOKKOS_GPU } #endif - bytes += natom * nmax * 3 * sizeof(double); // dedr + bytes += natom * nmax * 3 * sizeof(real); // dedr bytes += jdim * jdim * jdim * sizeof(int); // idxcg_block bytes += jdim * sizeof(int); // idxu_block bytes += jdim * sizeof(int); // idxu_half_block + bytes += idxu_max * sizeof(FullHalfMapper); // idxu_full_half bytes += jdim * sizeof(int); // idxu_cache_block bytes += jdim * jdim * jdim * sizeof(int); // idxz_block bytes += jdim * jdim * jdim * sizeof(int); // idxb_block @@ -2214,12 +2247,12 @@ double SNAKokkos::memory_usage() bytes += idxz_max * 10 * sizeof(int); // idxz bytes += idxb_max * 3 * sizeof(int); // idxb - bytes += jdim * sizeof(double); // bzero + bytes += jdim * sizeof(real); // bzero - bytes += natom * nmax * 3 * sizeof(double); // rij - bytes += natom * nmax * sizeof(int); // inside - bytes += natom * nmax * sizeof(double); // wj - bytes += natom * nmax * sizeof(double); // rcutij + bytes += natom * nmax * 3 * sizeof(real); // rij + bytes += natom * nmax * sizeof(real); // inside + bytes += natom * nmax * sizeof(real); // wj + bytes += natom * nmax * sizeof(real); // rcutij return bytes; } From bc0b963f98e27c81bd0aedadf87a0de84882bc11 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 20:25:42 -0500 Subject: [PATCH 169/187] remove extra empty line --- doc/src/Build_package.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index 63312d7aa8..f9fc52f8db 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -1,5 +1,4 @@ Include packages in build - ========================= In LAMMPS, a package is a group of files that enable a specific set of From 0e83e792d038e34ec26df96601bbb43150112c0c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 29 Dec 2020 20:31:00 -0500 Subject: [PATCH 170/187] add false positives --- doc/utils/sphinx-config/false_positives.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 0dff97459a..200b66bcc1 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1919,6 +1919,7 @@ mK mkdir mkv mliap +mliappy mlparks Mniszewski mnt @@ -2509,6 +2510,7 @@ Pstart Pstop pstyle Ptarget +pth pthread pthreads ptm @@ -2537,6 +2539,7 @@ pymodule pymol pypar pythonic +pytorch Pyy pz Pz From eef28b58abb68ee0f37630a76bb71a60141e6b69 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 08:55:32 -0500 Subject: [PATCH 171/187] remove extra word --- doc/src/fix_ave_correlate.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/fix_ave_correlate.rst b/doc/src/fix_ave_correlate.rst index 386b16ff9a..58aff114af 100644 --- a/doc/src/fix_ave_correlate.rst +++ b/doc/src/fix_ave_correlate.rst @@ -93,7 +93,7 @@ from a compute, fix, or variable, then see the :doc:`fix ave/chunk ` commands. If you wish to convert a per-atom quantity into a single global value, see the :doc:`compute reduce ` command. -The input values must either be all scalars. What kinds of +The input values must be all scalars. What kinds of correlations between input values are calculated is determined by the *type* keyword as discussed below. From 382ade15fed87947aa17010498e272a64f84ea7d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:01:37 -0500 Subject: [PATCH 172/187] more consistent formatting of for/while loops and if statements --- src/COLLOID/pair_brownian.cpp | 18 +- src/COLLOID/pair_brownian_poly.cpp | 18 +- src/COLLOID/pair_lubricate.cpp | 18 +- src/COLLOID/pair_lubricateU.cpp | 50 +- src/COLLOID/pair_lubricateU_poly.cpp | 38 +- src/COLLOID/pair_lubricate_poly.cpp | 20 +- src/COMPRESS/dump_atom_gz.cpp | 2 +- src/COMPRESS/dump_atom_zstd.cpp | 2 +- src/COMPRESS/dump_cfg_gz.cpp | 2 +- src/COMPRESS/dump_cfg_zstd.cpp | 2 +- src/COMPRESS/dump_custom_gz.cpp | 2 +- src/COMPRESS/dump_custom_zstd.cpp | 2 +- src/COMPRESS/dump_local_gz.cpp | 2 +- src/COMPRESS/dump_local_zstd.cpp | 2 +- src/COMPRESS/dump_xyz_gz.cpp | 2 +- src/COMPRESS/dump_xyz_zstd.cpp | 2 +- src/COMPRESS/zstd_file_writer.cpp | 10 +- src/CORESHELL/compute_temp_cs.cpp | 4 +- src/GPU/pair_eam_alloy_gpu.cpp | 2 +- src/GPU/pair_eam_fs_gpu.cpp | 2 +- src/GPU/pair_vashishta_gpu.cpp | 4 +- src/GRANULAR/fix_wall_gran.cpp | 2 +- src/GRANULAR/pair_granular.cpp | 2 +- src/KIM/kim_query.cpp | 2 +- src/KOKKOS/atom_kokkos.cpp | 4 +- src/KOKKOS/atom_vec_angle_kokkos.cpp | 54 +- src/KOKKOS/atom_vec_atomic_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_bond_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_charge_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 52 +- src/KOKKOS/atom_vec_full_kokkos.cpp | 20 +- src/KOKKOS/atom_vec_kokkos.cpp | 64 +- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 54 +- src/KOKKOS/atom_vec_sphere_kokkos.cpp | 82 +- src/KOKKOS/comm_kokkos.cpp | 18 +- .../compute_orientorder_atom_kokkos.cpp | 36 +- src/KOKKOS/domain_kokkos.cpp | 2 +- src/KOKKOS/fix_enforce2d_kokkos.cpp | 10 +- src/KOKKOS/fix_eos_table_rx_kokkos.cpp | 32 +- src/KOKKOS/fix_langevin_kokkos.cpp | 38 +- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 54 +- src/KOKKOS/fix_rx_kokkos.cpp | 100 +- src/KOKKOS/fix_shardlow_kokkos.cpp | 20 +- src/KOKKOS/kokkos.cpp | 2 +- src/KOKKOS/nbin_kokkos.cpp | 4 +- src/KOKKOS/nbin_ssa_kokkos.cpp | 2 +- src/KOKKOS/neighbor_kokkos.cpp | 8 +- src/KOKKOS/npair_kokkos.cpp | 242 ++-- src/KOKKOS/npair_ssa_kokkos.cpp | 42 +- src/KOKKOS/pair_buck_coul_cut_kokkos.cpp | 2 +- src/KOKKOS/pair_buck_coul_long_kokkos.cpp | 24 +- src/KOKKOS/pair_buck_kokkos.cpp | 2 +- src/KOKKOS/pair_coul_cut_kokkos.cpp | 2 +- src/KOKKOS/pair_coul_debye_kokkos.cpp | 2 +- src/KOKKOS/pair_coul_long_kokkos.cpp | 24 +- src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp | 6 +- src/KOKKOS/pair_eam_alloy_kokkos.cpp | 4 +- src/KOKKOS/pair_eam_fs_kokkos.cpp | 4 +- src/KOKKOS/pair_eam_kokkos.cpp | 2 +- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 160 +-- ..._lj_charmm_coul_charmm_implicit_kokkos.cpp | 20 +- .../pair_lj_charmm_coul_charmm_kokkos.cpp | 20 +- .../pair_lj_charmm_coul_long_kokkos.cpp | 24 +- src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp | 2 +- .../pair_lj_class2_coul_long_kokkos.cpp | 26 +- src/KOKKOS/pair_lj_class2_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp | 4 +- src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | 26 +- src/KOKKOS/pair_lj_cut_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_expand_kokkos.cpp | 2 +- .../pair_lj_gromacs_coul_gromacs_kokkos.cpp | 20 +- src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 2 +- src/KOKKOS/pair_lj_sdk_kokkos.cpp | 4 +- src/KOKKOS/pair_morse_kokkos.cpp | 2 +- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 64 +- src/KOKKOS/pair_reaxc_kokkos.cpp | 50 +- src/KOKKOS/pair_table_kokkos.cpp | 48 +- src/KOKKOS/pair_table_rx_kokkos.cpp | 80 +- src/KOKKOS/pair_yukawa_kokkos.cpp | 2 +- src/KOKKOS/pair_zbl_kokkos.cpp | 2 +- src/KOKKOS/verlet_kokkos.cpp | 14 +- src/KSPACE/pair_lj_long_coul_long.cpp | 2 +- src/KSPACE/pppm_disp.cpp | 6 +- src/MANYBODY/fix_qeq_comb.cpp | 4 +- src/MANYBODY/pair_adp.cpp | 2 +- src/MANYBODY/pair_airebo.cpp | 30 +- src/MANYBODY/pair_bop.cpp | 1102 ++++++++--------- src/MANYBODY/pair_comb.cpp | 4 +- src/MANYBODY/pair_comb3.cpp | 154 +-- src/MANYBODY/pair_eam.cpp | 4 +- src/MANYBODY/pair_eam_alloy.cpp | 2 +- src/MANYBODY/pair_eam_fs.cpp | 2 +- src/MANYBODY/pair_eim.cpp | 2 +- src/MANYBODY/pair_gw.cpp | 2 +- src/MANYBODY/pair_gw_zbl.cpp | 2 +- src/MANYBODY/pair_lcbop.cpp | 6 +- src/MANYBODY/pair_nb3b_harmonic.cpp | 2 +- src/MANYBODY/pair_polymorphic.cpp | 2 +- src/MANYBODY/pair_sw.cpp | 2 +- src/MANYBODY/pair_tersoff.cpp | 2 +- src/MANYBODY/pair_tersoff_mod.cpp | 2 +- src/MANYBODY/pair_tersoff_mod_c.cpp | 2 +- src/MANYBODY/pair_tersoff_zbl.cpp | 2 +- src/MANYBODY/pair_vashishta.cpp | 2 +- src/MISC/compute_ti.cpp | 2 +- src/MISC/fix_gld.cpp | 2 +- src/MISC/xdr_compat.cpp | 8 +- src/MLIAP/mliap_descriptor.cpp | 2 +- src/MLIAP/mliap_descriptor_snap.cpp | 8 +- src/MLIAP/mliap_model_linear.cpp | 2 +- src/MLIAP/mliap_model_python.cpp | 2 +- src/MLIAP/mliap_model_quadratic.cpp | 2 +- src/MOLECULE/angle_table.cpp | 2 +- src/MOLECULE/fix_cmap.cpp | 2 +- src/MOLECULE/pair_tip4p_cut.cpp | 2 +- src/OPT/pair_eam_opt.cpp | 10 +- src/OPT/pair_lj_long_coul_long_opt.cpp | 2 +- src/PYTHON/fix_python_move.cpp | 2 +- src/PYTHON/python_impl.cpp | 4 +- src/QEQ/fix_qeq.cpp | 66 +- src/QEQ/fix_qeq_dynamic.cpp | 16 +- src/QEQ/fix_qeq_fire.cpp | 16 +- src/RIGID/fix_ehex.cpp | 2 +- src/SNAP/compute_sna_atom.cpp | 10 +- src/SNAP/compute_snad_atom.cpp | 10 +- src/SNAP/compute_snap.cpp | 10 +- src/SNAP/compute_snav_atom.cpp | 10 +- src/SNAP/pair_snap.cpp | 4 +- src/SNAP/sna.cpp | 120 +- src/SPIN/fix_nve_spin.cpp | 8 +- src/SPIN/min_spin_cg.cpp | 20 +- src/SPIN/min_spin_lbfgs.cpp | 28 +- src/SPIN/neb_spin.cpp | 2 +- src/SRD/fix_srd.cpp | 4 +- src/USER-ADIOS/dump_atom_adios.cpp | 2 +- src/USER-ADIOS/dump_custom_adios.cpp | 2 +- src/USER-ADIOS/reader_adios.cpp | 2 +- src/USER-ATC/fix_atc.cpp | 12 +- src/USER-AWPMD/fix_nve_awpmd.cpp | 4 +- src/USER-AWPMD/pair_awpmd_cut.cpp | 100 +- src/USER-BOCS/fix_bocs.cpp | 4 +- src/USER-COLVARS/group_ndx.cpp | 2 +- src/USER-DIFFRACTION/compute_saed.cpp | 28 +- src/USER-DIFFRACTION/compute_xrd.cpp | 32 +- src/USER-DIFFRACTION/fix_saed_vtk.cpp | 26 +- src/USER-DPD/compute_dpd.cpp | 4 +- src/USER-DPD/compute_dpd_atom.cpp | 4 +- src/USER-DPD/fix_dpd_energy.cpp | 4 +- src/USER-DPD/fix_eos_cv.cpp | 14 +- src/USER-DPD/fix_eos_table.cpp | 16 +- src/USER-DPD/fix_eos_table_rx.cpp | 78 +- src/USER-DPD/fix_rx.cpp | 242 ++-- src/USER-DPD/fix_shardlow.cpp | 18 +- src/USER-DPD/nbin_ssa.cpp | 12 +- src/USER-DPD/pair_dpd_fdt_energy.cpp | 2 +- src/USER-DPD/pair_exp6_rx.cpp | 106 +- src/USER-DPD/pair_multi_lucy.cpp | 4 +- src/USER-DPD/pair_multi_lucy_rx.cpp | 52 +- src/USER-DPD/pair_table_rx.cpp | 36 +- src/USER-DRUDE/compute_temp_drude.cpp | 6 +- src/USER-DRUDE/fix_drude.cpp | 38 +- src/USER-DRUDE/fix_drude_transform.cpp | 10 +- src/USER-DRUDE/fix_langevin_drude.cpp | 4 +- src/USER-DRUDE/fix_tgnh_drude.cpp | 12 +- src/USER-DRUDE/pair_coul_tt.cpp | 2 +- src/USER-DRUDE/pair_lj_cut_thole_long.cpp | 10 +- src/USER-DRUDE/pair_thole.cpp | 2 +- src/USER-FEP/pair_morse_soft.cpp | 12 +- src/USER-INTEL/fix_intel.cpp | 4 +- src/USER-INTEL/nbin_intel.cpp | 2 +- src/USER-INTEL/npair_full_bin_ghost_intel.cpp | 2 +- .../npair_halffull_newton_intel.cpp | 2 +- src/USER-INTEL/npair_intel.cpp | 2 +- src/USER-INTEL/npair_skip_intel.cpp | 2 +- src/USER-INTEL/pair_airebo_intel.cpp | 4 +- src/USER-INTEL/pair_buck_coul_cut_intel.cpp | 8 +- src/USER-INTEL/pair_buck_coul_long_intel.cpp | 4 +- src/USER-INTEL/pair_buck_intel.cpp | 4 +- src/USER-INTEL/pair_dpd_intel.cpp | 2 +- src/USER-INTEL/pair_eam_alloy_intel.cpp | 2 +- src/USER-INTEL/pair_eam_fs_intel.cpp | 2 +- src/USER-INTEL/pair_eam_intel.cpp | 2 +- src/USER-INTEL/pair_gayberne_intel.cpp | 4 +- .../pair_lj_charmm_coul_charmm_intel.cpp | 4 +- .../pair_lj_charmm_coul_long_intel.cpp | 4 +- .../pair_lj_cut_coul_long_intel.cpp | 4 +- src/USER-INTEL/pair_lj_cut_intel.cpp | 2 +- src/USER-INTEL/pair_sw_intel.cpp | 6 +- src/USER-INTEL/pair_tersoff_intel.cpp | 4 +- src/USER-INTEL/pppm_disp_intel.cpp | 84 +- src/USER-INTEL/pppm_intel.cpp | 30 +- src/USER-LB/fix_lb_fluid.cpp | 740 +++++------ src/USER-LB/fix_lb_momentum.cpp | 38 +- src/USER-LB/fix_lb_pc.cpp | 60 +- src/USER-LB/fix_lb_rigid_pc_sphere.cpp | 128 +- src/USER-LB/fix_lb_viscous.cpp | 10 +- src/USER-MANIFOLD/fix_manifoldforce.cpp | 4 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp | 26 +- src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp | 20 +- src/USER-MANIFOLD/manifold_gaussian_bump.cpp | 6 +- src/USER-MANIFOLD/manifold_thylakoid.cpp | 20 +- .../manifold_thylakoid_shared.cpp | 8 +- src/USER-MEAMC/meam_funcs.cpp | 2 +- src/USER-MEAMC/meam_setup_done.cpp | 6 +- src/USER-MESODPD/fix_edpd_source.cpp | 12 +- src/USER-MESODPD/fix_mvv_dpd.cpp | 2 +- src/USER-MESODPD/fix_mvv_edpd.cpp | 2 +- src/USER-MESODPD/fix_mvv_tdpd.cpp | 6 +- src/USER-MESODPD/fix_tdpd_source.cpp | 12 +- src/USER-MESODPD/pair_edpd.cpp | 28 +- src/USER-MESODPD/pair_mdpd.cpp | 4 +- src/USER-MESODPD/pair_tdpd.cpp | 14 +- src/USER-MGPT/mgpt_linalg.cpp | 30 +- src/USER-MGPT/mgpt_readpot.cpp | 98 +- src/USER-MGPT/mgpt_splinetab.cpp | 14 +- src/USER-MGPT/pair_mgpt.cpp | 422 +++---- src/USER-MISC/angle_gaussian.cpp | 8 +- src/USER-MISC/bond_gaussian.cpp | 8 +- src/USER-MISC/compute_basal_atom.cpp | 8 +- src/USER-MISC/compute_entropy_atom.cpp | 8 +- src/USER-MISC/compute_momentum.cpp | 4 +- src/USER-MISC/compute_stress_mop.cpp | 14 +- src/USER-MISC/compute_stress_mop_profile.cpp | 10 +- src/USER-MISC/dihedral_fourier.cpp | 4 +- src/USER-MISC/dihedral_nharmonic.cpp | 6 +- src/USER-MISC/dihedral_spherical.cpp | 4 +- src/USER-MISC/dihedral_table.cpp | 4 +- src/USER-MISC/dihedral_table_cut.cpp | 2 +- src/USER-MISC/fix_ave_correlate_long.cpp | 4 +- src/USER-MISC/fix_filter_corotate.cpp | 18 +- src/USER-MISC/fix_flow_gauss.cpp | 4 +- src/USER-MISC/fix_gle.cpp | 2 +- src/USER-MISC/fix_npt_cauchy.cpp | 24 +- src/USER-MISC/fix_pafi.cpp | 20 +- src/USER-MISC/fix_pimd.cpp | 130 +- src/USER-MISC/fix_propel_self.cpp | 8 +- src/USER-MISC/fix_rhok.cpp | 4 +- src/USER-MISC/fix_smd.cpp | 2 +- src/USER-MISC/fix_srp.cpp | 36 +- src/USER-MISC/fix_ti_spring.cpp | 2 +- src/USER-MISC/fix_ttm_mod.cpp | 24 +- src/USER-MISC/fix_wall_ees.cpp | 14 +- src/USER-MISC/fix_wall_region_ees.cpp | 26 +- src/USER-MISC/pair_agni.cpp | 2 +- src/USER-MISC/pair_e3b.cpp | 2 +- src/USER-MISC/pair_edip_multi.cpp | 8 +- src/USER-MISC/pair_ilp_graphene_hbn.cpp | 70 +- src/USER-MISC/pair_kolmogorov_crespi_full.cpp | 70 +- src/USER-MISC/pair_kolmogorov_crespi_z.cpp | 4 +- src/USER-MISC/pair_lebedeva_z.cpp | 4 +- src/USER-MISC/pair_local_density.cpp | 4 +- src/USER-MISC/pair_meam_spline.cpp | 84 +- src/USER-MISC/pair_meam_sw_spline.cpp | 86 +- src/USER-MISC/pair_srp.cpp | 30 +- src/USER-MISC/pair_tersoff_table.cpp | 2 +- src/USER-OMP/dihedral_table_omp.cpp | 2 +- src/USER-OMP/fix_nve_sphere_omp.cpp | 2 +- src/USER-OMP/fix_qeq_comb_omp.cpp | 2 +- src/USER-OMP/pair_agni_omp.cpp | 2 +- src/USER-OMP/pair_brownian_omp.cpp | 10 +- src/USER-OMP/pair_brownian_poly_omp.cpp | 10 +- src/USER-OMP/pair_comb_omp.cpp | 2 +- src/USER-OMP/pair_eam_alloy_omp.cpp | 2 +- src/USER-OMP/pair_eam_fs_omp.cpp | 2 +- src/USER-OMP/pair_lj_cut_thole_long_omp.cpp | 10 +- src/USER-OMP/pair_lj_long_coul_long_omp.cpp | 2 +- src/USER-OMP/pair_lubricate_omp.cpp | 10 +- src/USER-OMP/pair_lubricate_poly_omp.cpp | 10 +- src/USER-OMP/pair_meam_spline_omp.cpp | 22 +- src/USER-OMP/pair_reaxc_omp.cpp | 18 +- src/USER-OMP/pair_tersoff_zbl_omp.cpp | 2 +- src/USER-OMP/reaxc_bond_orders_omp.cpp | 22 +- src/USER-OMP/reaxc_bonds_omp.cpp | 2 +- src/USER-OMP/reaxc_forces_omp.cpp | 48 +- src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp | 10 +- src/USER-OMP/reaxc_init_md_omp.cpp | 12 +- src/USER-OMP/reaxc_multi_body_omp.cpp | 18 +- src/USER-OMP/reaxc_nonbonded_omp.cpp | 18 +- src/USER-OMP/reaxc_torsion_angles_omp.cpp | 4 +- src/USER-OMP/reaxc_valence_angles_omp.cpp | 38 +- src/USER-PHONON/dynamical_matrix.cpp | 30 +- src/USER-PHONON/fix_phonon.cpp | 128 +- src/USER-PHONON/third_order.cpp | 44 +- src/USER-PLUMED/fix_plumed.cpp | 4 +- src/USER-PTM/ptm_voronoi_cell.cpp | 310 ++--- src/USER-QTB/fix_qbmsst.cpp | 2 +- src/USER-QTB/fix_qtb.cpp | 2 +- src/USER-QUIP/pair_quip.cpp | 10 +- src/USER-REACTION/fix_bond_react.cpp | 2 +- src/USER-REAXC/fix_qeq_reax.cpp | 24 +- src/USER-REAXC/fix_reaxc_bonds.cpp | 4 +- src/USER-REAXC/pair_reaxc.cpp | 28 +- src/USER-REAXC/reaxc_allocate.cpp | 14 +- src/USER-REAXC/reaxc_bond_orders.cpp | 2 +- src/USER-REAXC/reaxc_bonds.cpp | 2 +- src/USER-REAXC/reaxc_control.cpp | 2 +- src/USER-REAXC/reaxc_ffield.cpp | 2 +- src/USER-REAXC/reaxc_forces.cpp | 6 +- src/USER-REAXC/reaxc_hydrogen_bonds.cpp | 2 +- src/USER-REAXC/reaxc_init_md.cpp | 14 +- src/USER-REAXC/reaxc_io_tools.cpp | 10 +- src/USER-REAXC/reaxc_lookup.cpp | 42 +- src/USER-REAXC/reaxc_nonbonded.cpp | 12 +- src/USER-REAXC/reaxc_torsion_angles.cpp | 12 +- src/USER-REAXC/reaxc_traj.cpp | 8 +- src/USER-REAXC/reaxc_valence_angles.cpp | 2 +- src/USER-SCAFACOS/scafacos.cpp | 4 +- .../compute_smd_triangle_vertices.cpp | 2 +- src/USER-SMD/pair_smd_tlsph.cpp | 2 +- src/USER-SMTBQ/pair_smtbq.cpp | 50 +- src/USER-TALLY/compute_pe_mol_tally.cpp | 2 +- src/USER-UEF/dump_cfg_uef.cpp | 2 +- src/USER-UEF/uef_utils.cpp | 6 +- src/USER-VTK/dump_vtk.cpp | 14 +- src/atom.cpp | 4 +- src/comm_tiled.cpp | 2 +- src/compute_hexorder_atom.cpp | 4 +- src/compute_orientorder_atom.cpp | 36 +- src/fix_adapt.cpp | 12 +- src/fix_ave_histo_weight.cpp | 2 +- src/fix_deform.cpp | 2 +- src/fix_nh.cpp | 4 +- src/fix_nh_sphere.cpp | 6 +- src/fix_nve_sphere.cpp | 2 +- src/fix_temp_csvr.cpp | 2 +- src/hashlittle.cpp | 4 +- src/info.cpp | 88 +- src/library.cpp | 48 +- src/modify.cpp | 2 +- src/neighbor.cpp | 6 +- src/pair_coul_streitz.cpp | 6 +- src/potential_file_reader.cpp | 2 +- src/reader_native.cpp | 2 +- src/region.cpp | 6 +- src/region_block.cpp | 4 +- src/region_cone.cpp | 4 +- src/region_cylinder.cpp | 4 +- src/region_intersect.cpp | 2 +- src/region_prism.cpp | 2 +- src/tokenizer.cpp | 22 +- src/update.cpp | 2 +- src/utils.cpp | 12 +- src/variable.cpp | 4 +- 345 files changed, 4259 insertions(+), 4259 deletions(-) diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index ea23478805..cdfb379087 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -99,20 +99,20 @@ void PairBrownian::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -494,7 +494,7 @@ void PairBrownian::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { @@ -514,14 +514,14 @@ void PairBrownian::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index e25ef37f04..15afd56886 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -82,20 +82,20 @@ void PairBrownianPoly::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (j = 0; j < 3; j++){ + for (j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -355,7 +355,7 @@ void PairBrownianPoly::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { @@ -375,14 +375,14 @@ void PairBrownianPoly::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index d813b794f1..64b7aa2e30 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -155,20 +155,20 @@ void PairLubricate::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -559,7 +559,7 @@ void PairLubricate::init_style() // are re-calculated at every step. shearing = flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = flagdeform = 1; if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) @@ -584,15 +584,15 @@ void PairLubricate::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index 3974b12b56..c047ce6a07 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -158,8 +158,8 @@ void PairLubricateU::compute(int eflag, int vflag) // store back the saved forces and torques in original arrays - for(i=0;iprd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -813,20 +813,20 @@ void PairLubricateU::compute_RU() double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1013,7 +1013,7 @@ void PairLubricateU::compute_RU() torque[i][1] -= vxmu2f*ty; torque[i][2] -= vxmu2f*tz; - if(newton_pair || j < nlocal) { + if (newton_pair || j < nlocal) { torque[j][0] -= vxmu2f*tx; torque[j][1] -= vxmu2f*ty; torque[j][2] -= vxmu2f*tz; @@ -1084,20 +1084,20 @@ void PairLubricateU::compute_RU(double **x) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1284,7 +1284,7 @@ void PairLubricateU::compute_RU(double **x) torque[i][1] -= vxmu2f*ty; torque[i][2] -= vxmu2f*tz; - if(newton_pair || j < nlocal) { + if (newton_pair || j < nlocal) { torque[j][0] -= vxmu2f*tx; torque[j][1] -= vxmu2f*ty; torque[j][2] -= vxmu2f*tz; @@ -1791,7 +1791,7 @@ void PairLubricateU::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { @@ -1811,14 +1811,14 @@ void PairLubricateU::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 6b44c4e077..49c77e9b60 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -126,8 +126,8 @@ void PairLubricateUPoly::compute(int eflag, int vflag) // Store back the saved forces and torques in original arrays - for(i=0;iprd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -626,20 +626,20 @@ void PairLubricateUPoly::compute_RU(double **x) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (j = 0; j < 3; j++){ + for (j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1155,10 +1155,10 @@ void PairLubricateUPoly::init_style() // are re-calculated at every step. flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) flagdeform = 1; - else if (strstr(modify->fix[i]->style,"wall") != nullptr){ + else if (strstr(modify->fix[i]->style,"wall") != nullptr) { if (flagwall) error->all(FLERR, "Cannot use multiple fix wall commands with " @@ -1176,14 +1176,14 @@ void PairLubricateUPoly::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); @@ -1214,7 +1214,7 @@ void PairLubricateUPoly::init_style() if (!flagVF) vol_f = 0; if (!comm->me) { - if(logfile) + if (logfile) fprintf(logfile, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", vol_f,vol_P,vol_T); if (screen) diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index b35411ab4b..a395f8c67e 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -137,20 +137,20 @@ void PairLubricatePoly::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -461,7 +461,7 @@ void PairLubricatePoly::init_style() // are re-calculated at every step. shearing = flagdeform = flagwall = 0; - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"deform") == 0) { shearing = flagdeform = 1; if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) @@ -478,7 +478,7 @@ void PairLubricatePoly::init_style() if (wallfix->xflag) flagwall = 2; // Moving walls exist } - if (strstr(modify->fix[i]->style,"wall") != nullptr){ + if (strstr(modify->fix[i]->style,"wall") != nullptr) { flagwall = 1; // Walls exist if (((FixWall *) modify->fix[i])->xflag ) { flagwall = 2; // Moving walls exist @@ -492,14 +492,14 @@ void PairLubricatePoly::init_style() if (!flagwall) vol_T = domain->xprd*domain->yprd*domain->zprd; else { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COMPRESS/dump_atom_gz.cpp b/src/COMPRESS/dump_atom_gz.cpp index 946ea57bfd..7c30d7c101 100644 --- a/src/COMPRESS/dump_atom_gz.cpp +++ b/src/COMPRESS/dump_atom_gz.cpp @@ -168,7 +168,7 @@ void DumpAtomGZ::write() int DumpAtomGZ::modify_param(int narg, char **arg) { int consumed = DumpAtom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_atom_zstd.cpp b/src/COMPRESS/dump_atom_zstd.cpp index 3313b8d78d..f51a8b393b 100644 --- a/src/COMPRESS/dump_atom_zstd.cpp +++ b/src/COMPRESS/dump_atom_zstd.cpp @@ -171,7 +171,7 @@ void DumpAtomZstd::write() int DumpAtomZstd::modify_param(int narg, char **arg) { int consumed = DumpAtom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_cfg_gz.cpp b/src/COMPRESS/dump_cfg_gz.cpp index e50e13ff4e..9beb606b24 100644 --- a/src/COMPRESS/dump_cfg_gz.cpp +++ b/src/COMPRESS/dump_cfg_gz.cpp @@ -176,7 +176,7 @@ void DumpCFGGZ::write() int DumpCFGGZ::modify_param(int narg, char **arg) { int consumed = DumpCFG::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index ff8b7c395a..13890334ba 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -173,7 +173,7 @@ void DumpCFGZstd::write() int DumpCFGZstd::modify_param(int narg, char **arg) { int consumed = DumpCFG::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_custom_gz.cpp b/src/COMPRESS/dump_custom_gz.cpp index e36dea7d21..f345f4b111 100644 --- a/src/COMPRESS/dump_custom_gz.cpp +++ b/src/COMPRESS/dump_custom_gz.cpp @@ -168,7 +168,7 @@ void DumpCustomGZ::write() int DumpCustomGZ::modify_param(int narg, char **arg) { int consumed = DumpCustom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_custom_zstd.cpp b/src/COMPRESS/dump_custom_zstd.cpp index 8937ce04c9..81ace6172f 100644 --- a/src/COMPRESS/dump_custom_zstd.cpp +++ b/src/COMPRESS/dump_custom_zstd.cpp @@ -171,7 +171,7 @@ void DumpCustomZstd::write() int DumpCustomZstd::modify_param(int narg, char **arg) { int consumed = DumpCustom::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_local_gz.cpp b/src/COMPRESS/dump_local_gz.cpp index 17eecc95fd..e0d2f0d2dd 100644 --- a/src/COMPRESS/dump_local_gz.cpp +++ b/src/COMPRESS/dump_local_gz.cpp @@ -183,7 +183,7 @@ void DumpLocalGZ::write() int DumpLocalGZ::modify_param(int narg, char **arg) { int consumed = DumpLocal::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_local_zstd.cpp b/src/COMPRESS/dump_local_zstd.cpp index 8a7a8cf19b..c03670ffba 100644 --- a/src/COMPRESS/dump_local_zstd.cpp +++ b/src/COMPRESS/dump_local_zstd.cpp @@ -171,7 +171,7 @@ void DumpLocalZstd::write() int DumpLocalZstd::modify_param(int narg, char **arg) { int consumed = DumpLocal::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/dump_xyz_gz.cpp b/src/COMPRESS/dump_xyz_gz.cpp index c84c83b9cb..21a55f6b07 100644 --- a/src/COMPRESS/dump_xyz_gz.cpp +++ b/src/COMPRESS/dump_xyz_gz.cpp @@ -147,7 +147,7 @@ void DumpXYZGZ::write() int DumpXYZGZ::modify_param(int narg, char **arg) { int consumed = DumpXYZ::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { if (strcmp(arg[0],"compression_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); int min_level = Z_DEFAULT_COMPRESSION; diff --git a/src/COMPRESS/dump_xyz_zstd.cpp b/src/COMPRESS/dump_xyz_zstd.cpp index 0cc65a03b8..9c220bdca7 100644 --- a/src/COMPRESS/dump_xyz_zstd.cpp +++ b/src/COMPRESS/dump_xyz_zstd.cpp @@ -145,7 +145,7 @@ void DumpXYZZstd::write() int DumpXYZZstd::modify_param(int narg, char **arg) { int consumed = DumpXYZ::modify_param(narg, arg); - if(consumed == 0) { + if (consumed == 0) { try { if (strcmp(arg[0],"checksum") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index 2631faa4ad..9f69f95395 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -48,7 +48,7 @@ ZstdFileWriter::~ZstdFileWriter() void ZstdFileWriter::open(const std::string &path) { - if(isopen()) return; + if (isopen()) return; fp = fopen(path.c_str(), "wb"); @@ -72,7 +72,7 @@ void ZstdFileWriter::open(const std::string &path) size_t ZstdFileWriter::write(const void * buffer, size_t length) { - if(!isopen()) return 0; + if (!isopen()) return 0; ZSTD_inBuffer input = { buffer, length, 0 }; ZSTD_EndDirective mode = ZSTD_e_continue; @@ -90,7 +90,7 @@ size_t ZstdFileWriter::write(const void * buffer, size_t length) void ZstdFileWriter::flush() { - if(!isopen()) return; + if (!isopen()) return; size_t remaining; ZSTD_inBuffer input = { nullptr, 0, 0 }; @@ -109,7 +109,7 @@ void ZstdFileWriter::flush() void ZstdFileWriter::close() { - if(!isopen()) return; + if (!isopen()) return; size_t remaining; ZSTD_inBuffer input = { nullptr, 0, 0 }; @@ -144,7 +144,7 @@ void ZstdFileWriter::setCompressionLevel(int level) const int min_level = ZSTD_minCLevel(); const int max_level = ZSTD_maxCLevel(); - if(level < min_level || level > max_level) + if (level < min_level || level > max_level) throw FileWriterException(fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); compression_level = level; diff --git a/src/CORESHELL/compute_temp_cs.cpp b/src/CORESHELL/compute_temp_cs.cpp index 92a9fd04e7..4bf74a3b7e 100644 --- a/src/CORESHELL/compute_temp_cs.cpp +++ b/src/CORESHELL/compute_temp_cs.cpp @@ -232,7 +232,7 @@ double ComputeTempCS::compute_scalar() double t = 0.0; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { vthermal[0] = v[i][0] - vint[i][0]; vthermal[1] = v[i][1] - vint[i][1]; @@ -271,7 +271,7 @@ void ComputeTempCS::compute_vector() double t[6]; for (int i = 0; i < 6; i++) t[i] = 0.0; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (rmass) massone = rmass[i]; else massone = mass[type[i]]; diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index 7da95cdc11..c1370af307 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -370,7 +370,7 @@ void PairEAMAlloyGPU::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/alloy", unit_convert_flag); diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index d613069a9a..ce3ea8bb0b 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -370,7 +370,7 @@ void PairEAMFSGPU::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/fs", unit_convert_flag); diff --git a/src/GPU/pair_vashishta_gpu.cpp b/src/GPU/pair_vashishta_gpu.cpp index 6a7ea52a54..df17b2091a 100644 --- a/src/GPU/pair_vashishta_gpu.cpp +++ b/src/GPU/pair_vashishta_gpu.cpp @@ -141,7 +141,7 @@ void PairVashishtaGPU::compute(int eflag, int vflag) void PairVashishtaGPU::allocate() { - if(!allocated) { + if (!allocated) { PairVashishta::allocate(); } int n = atom->ntypes; @@ -260,7 +260,7 @@ void PairVashishtaGPU::init_style() double PairVashishtaGPU::init_one(int i, int j) { - if(!gpu_allocated) { + if (!gpu_allocated) { allocate(); } if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 7218149d08..f52b976b63 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -1303,7 +1303,7 @@ void FixWallGran::granular(double rsq, double dx, double dy, double dz, relrot2 = omega[1]; relrot3 = omega[2]; } - if (roll_model != ROLL_NONE){ + if (roll_model != ROLL_NONE) { // rolling velocity, see eq. 31 of Wang et al, Particuology v 23, p 49 (2015) // This is different from the Marshall papers, diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index fe88d0755f..215926e23e 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -536,7 +536,7 @@ void PairGranular::compute(int eflag, int vflag) } if (roll_model[itype][jtype] != ROLL_NONE || - twist_model[itype][jtype] != TWIST_NONE){ + twist_model[itype][jtype] != TWIST_NONE) { relrot1 = omega[i][0] - omega[j][0]; relrot2 = omega[i][1] - omega[j][1]; relrot3 = omega[i][2] - omega[j][2]; diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 564f063668..faf1d26909 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -252,7 +252,7 @@ char *do_query(char *qfunction, char * model_name, int narg, char **arg, } } else { query += fmt::format("&{}=[", key); - while (n != std::string::npos){ + while (n != std::string::npos) { std::string sval = val.substr(0, n); if (utils::is_integer(sval) || utils::is_double(sval) || diff --git a/src/KOKKOS/atom_kokkos.cpp b/src/KOKKOS/atom_kokkos.cpp index 0b50f2d3d8..c41a42c99a 100644 --- a/src/KOKKOS/atom_kokkos.cpp +++ b/src/KOKKOS/atom_kokkos.cpp @@ -230,9 +230,9 @@ void AtomKokkos::sort() reallocate memory to the pointer selected by the mask ------------------------------------------------------------------------- */ -void AtomKokkos::grow(unsigned int mask){ +void AtomKokkos::grow(unsigned int mask) { - if (mask & SPECIAL_MASK){ + if (mask & SPECIAL_MASK) { memoryKK->destroy_kokkos(k_special, special); sync(Device, mask); modified(Device, mask); diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index b15fc2965b..39897018ec 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -281,10 +281,10 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -296,7 +296,7 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -310,8 +310,8 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, } } else { atomKK->sync(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -323,7 +323,7 @@ int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -396,11 +396,11 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -414,7 +414,7 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -431,8 +431,8 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li } else { atomKK->sync(Device,X_MASK); atomKK->modified(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -446,7 +446,7 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, @@ -492,7 +492,7 @@ struct AtomVecAngleKokkos_UnpackComm { void AtomVecAngleKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); struct AtomVecAngleKokkos_UnpackComm f(atomKK->k_x,buf,first); @@ -641,7 +641,7 @@ void AtomVecAngleKokkos::unpack_comm_vel(int n, int first, double *buf) int AtomVecAngleKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK); int m = 0; @@ -658,7 +658,7 @@ int AtomVecAngleKokkos::pack_reverse(int n, int first, double *buf) void AtomVecAngleKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) + if (n > 0) atomKK->modified(Host,F_MASK); int m = 0; @@ -742,7 +742,7 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -756,7 +756,7 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -939,7 +939,7 @@ struct AtomVecAngleKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -963,7 +963,7 @@ void AtomVecAngleKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecAngleKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_molecule,first); Kokkos::parallel_for(n,f); @@ -1129,7 +1129,7 @@ struct AtomVecAngleKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 num_angle, angle_per_atom angle_type, angle_per_atom angle_atom1, angle_atom2, @@ -1178,7 +1178,7 @@ struct AtomVecAngleKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -1220,12 +1220,12 @@ int AtomVecAngleKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_ X_FLOAT hi ) { const int elements = 17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecAngleKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -1333,7 +1333,7 @@ struct AtomVecAngleKokkos_UnpackExchangeFunctor { _angle_atom2(atom->k_angle_atom2.view()), _angle_atom3(atom->k_angle_atom3.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements =17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; const int maxsendlist = (buf.template view().extent(0)* buf.template view().extent(1))/elements; @@ -1386,7 +1386,7 @@ int AtomVecAngleKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int n int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, ExecutionSpace space) { const size_t elements = 17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecAngleKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index 013b55c959..c1ae398e22 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -200,7 +200,7 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,dx,dy,dz); @@ -214,7 +214,7 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,dx,dy,dz); @@ -374,7 +374,7 @@ struct AtomVecAtomicKokkos_UnpackBorder { typename ArrayTypes::t_int_1d &type, typename ArrayTypes::t_int_1d &mask, const int& first): - _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_first(first){ + _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_first(first) { }; KOKKOS_INLINE_FUNCTION @@ -396,7 +396,7 @@ void AtomVecAtomicKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecAtomicKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,first); Kokkos::parallel_for(n,f); } else { @@ -504,7 +504,7 @@ struct AtomVecAtomicKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 11; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -527,7 +527,7 @@ struct AtomVecAtomicKokkos_PackExchangeFunctor { _buf(mysend,10) = d_ubuf(_image[i]).d; const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -546,11 +546,11 @@ struct AtomVecAtomicKokkos_PackExchangeFunctor { int AtomVecAtomicKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d k_sendlist,DAT::tdual_int_1d k_copylist,ExecutionSpace space,int dim,X_FLOAT lo,X_FLOAT hi ) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/11) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/11) { int newsize = nsend*11/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecAtomicKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); return nsend*11; @@ -615,7 +615,7 @@ struct AtomVecAtomicKokkos_UnpackExchangeFunctor { _mask(atom->k_mask.view()), _image(atom->k_image.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 11; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -644,7 +644,7 @@ struct AtomVecAtomicKokkos_UnpackExchangeFunctor { /* ---------------------------------------------------------------------- */ int AtomVecAtomicKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv,int nlocal,int dim,X_FLOAT lo,X_FLOAT hi,ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecAtomicKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/11,f); diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index 91d7dbef63..dd973a9369 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -250,7 +250,7 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -264,7 +264,7 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -447,7 +447,7 @@ struct AtomVecBondKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -471,7 +471,7 @@ void AtomVecBondKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecBondKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_molecule,first); Kokkos::parallel_for(n,f); @@ -621,7 +621,7 @@ struct AtomVecBondKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 to store buffer length @@ -661,7 +661,7 @@ struct AtomVecBondKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -696,12 +696,12 @@ int AtomVecBondKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2 X_FLOAT hi ) { const int elements = 16+atomKK->maxspecial+atomKK->bond_per_atom+atomKK->bond_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecBondKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -794,7 +794,7 @@ struct AtomVecBondKokkos_UnpackExchangeFunctor { _bond_type(atom->k_bond_type.view()), _bond_atom(atom->k_bond_atom.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements = 16+atom->maxspecial+atom->bond_per_atom+atom->bond_per_atom; const int maxsendlist = (buf.template view().extent(0)* buf.template view().extent(1))/elements; @@ -840,7 +840,7 @@ int AtomVecBondKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nr int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, ExecutionSpace space) { const size_t elements = 16+atomKK->maxspecial+atomKK->bond_per_atom+atomKK->bond_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecBondKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 698703371f..4416ab34b8 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -267,7 +267,7 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); @@ -281,7 +281,7 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); @@ -463,7 +463,7 @@ struct AtomVecChargeKokkos_UnpackBorder { typename ArrayTypes::t_int_1d &mask, typename ArrayTypes::t_float_1d &q, const int& first): - _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_q(q),_first(first){ + _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_q(q),_first(first) { }; KOKKOS_INLINE_FUNCTION @@ -485,7 +485,7 @@ void AtomVecChargeKokkos::unpack_border_kokkos(const int &n, const int &first, if (first+n >= nmax) { grow(first+n+100); } - if(space==Host) { + if (space==Host) { struct AtomVecChargeKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_q,first); Kokkos::parallel_for(n,f); @@ -618,7 +618,7 @@ struct AtomVecChargeKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 12; const int maxsendlist = (buf.template view().extent(0)* buf.template view().extent(1))/elements; @@ -643,7 +643,7 @@ struct AtomVecChargeKokkos_PackExchangeFunctor { _buf(mysend,11) = _q[i]; const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -667,11 +667,11 @@ int AtomVecChargeKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat ExecutionSpace space,int dim, X_FLOAT lo,X_FLOAT hi ) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/12) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/12) { int newsize = nsend*12/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecChargeKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -740,7 +740,7 @@ struct AtomVecChargeKokkos_UnpackExchangeFunctor { _image(atom->k_image.view()), _q(atom->k_q.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 12; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -772,7 +772,7 @@ struct AtomVecChargeKokkos_UnpackExchangeFunctor { int AtomVecChargeKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv, int nlocal,int dim,X_FLOAT lo,X_FLOAT hi, ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecChargeKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/12,f); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 8a733f66e4..26fcda983b 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -267,10 +267,10 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -286,7 +286,7 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -304,8 +304,8 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, } } else { atomKK->sync(Device,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -321,7 +321,7 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, buf,list,iswap, @@ -409,11 +409,11 @@ struct AtomVecDPDKokkos_PackCommSelf { int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -429,7 +429,7 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -448,8 +448,8 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list } else { atomKK->sync(Device,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Device,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -465,7 +465,7 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, nfirst,list,iswap, @@ -527,7 +527,7 @@ struct AtomVecDPDKokkos_UnpackComm { void AtomVecDPDKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); struct AtomVecDPDKokkos_UnpackComm f(atomKK->k_x, @@ -716,7 +716,7 @@ void AtomVecDPDKokkos::unpack_comm_vel(int n, int first, double *buf) int AtomVecDPDKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK); int m = 0; @@ -733,7 +733,7 @@ int AtomVecDPDKokkos::pack_reverse(int n, int first, double *buf) void AtomVecDPDKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) { + if (n > 0) { atomKK->sync(Host,F_MASK); atomKK->modified(Host,F_MASK); } @@ -831,7 +831,7 @@ int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DA dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -849,7 +849,7 @@ int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DA } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1134,7 +1134,7 @@ void AtomVecDPDKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK| DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK| UCG_MASK|UCGNEW_MASK|DVECTOR_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecDPDKokkos_UnpackBorder f(buf.view(), h_x,h_tag,h_type,h_mask, h_dpdTheta,h_uCond,h_uMech,h_uChem,h_uCG,h_uCGnew, @@ -1326,7 +1326,7 @@ struct AtomVecDPDKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 17; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -1355,7 +1355,7 @@ struct AtomVecDPDKokkos_PackExchangeFunctor { _buf(mysend,16) = _uCGnew[i]; const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -1380,7 +1380,7 @@ struct AtomVecDPDKokkos_PackExchangeFunctor { int AtomVecDPDKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d k_sendlist,DAT::tdual_int_1d k_copylist,ExecutionSpace space,int dim,X_FLOAT lo,X_FLOAT hi ) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/17) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/17) { int newsize = nsend*17/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } @@ -1388,7 +1388,7 @@ int AtomVecDPDKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d MASK_MASK | IMAGE_MASK| DPDTHETA_MASK | UCOND_MASK | UMECH_MASK | UCHEM_MASK | UCG_MASK | UCGNEW_MASK | DVECTOR_MASK); - if(space == Host) { + if (space == Host) { AtomVecDPDKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); } else { @@ -1469,7 +1469,7 @@ struct AtomVecDPDKokkos_UnpackExchangeFunctor { _mask(atom->k_mask.view()), _image(atom->k_image.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { const size_t elements = 17; const int maxsendlist = (buf.template view().extent(0)*buf.template view().extent(1))/elements; @@ -1504,7 +1504,7 @@ struct AtomVecDPDKokkos_UnpackExchangeFunctor { /* ---------------------------------------------------------------------- */ int AtomVecDPDKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv,int nlocal,int dim,X_FLOAT lo,X_FLOAT hi,ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecDPDKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/17,f); diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 2c85e4129b..6f8673bbc8 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -381,7 +381,7 @@ int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); @@ -395,7 +395,7 @@ int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); @@ -586,7 +586,7 @@ struct AtomVecFullKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_q(q),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -611,7 +611,7 @@ void AtomVecFullKokkos::unpack_border_kokkos(const int &n, const int &first, atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|Q_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|Q_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecFullKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_q,h_molecule,first); Kokkos::parallel_for(n,f); @@ -824,7 +824,7 @@ struct AtomVecFullKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 num_angle, angle_per_atom angle_type, angle_per_atom angle_atom1, angle_atom2, @@ -895,7 +895,7 @@ struct AtomVecFullKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -955,12 +955,12 @@ int AtomVecFullKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2 { const int elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecFullKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -1106,7 +1106,7 @@ struct AtomVecFullKokkos_UnpackExchangeFunctor { _improper_atom3(atom->k_improper_atom3.view()), _improper_atom4(atom->k_improper_atom4.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; @@ -1178,7 +1178,7 @@ int AtomVecFullKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nr ExecutionSpace space) { const size_t elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecFullKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 35ed9160d2..86c79141c0 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -112,10 +112,10 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -127,7 +127,7 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -141,8 +141,8 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, } } else { sync(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -154,7 +154,7 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -225,11 +225,11 @@ struct AtomVecKokkos_PackCommSelf { int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -241,7 +241,7 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -256,8 +256,8 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c } else { sync(Device,X_MASK); modified(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -269,7 +269,7 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -361,10 +361,10 @@ struct AtomVecKokkos_PackCommSelfFused { int AtomVecKokkos::pack_comm_self_fused(const int &n, const DAT::tdual_int_2d &list, const DAT::tdual_int_1d &sendnum_scan, const DAT::tdual_int_1d &firstrecv, const DAT::tdual_int_1d &pbc_flag, const DAT::tdual_int_2d &pbc, const DAT::tdual_int_1d &g2l) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); @@ -378,7 +378,7 @@ int AtomVecKokkos::pack_comm_self_fused(const int &n, const DAT::tdual_int_2d &l } else { sync(Device,X_MASK); modified(Device,X_MASK); - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); @@ -421,7 +421,7 @@ struct AtomVecKokkos_UnpackComm { void AtomVecKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); struct AtomVecKokkos_UnpackComm f(atomKK->k_x,buf,first); @@ -530,7 +530,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK|V_MASK); if (pbc_flag) { if (deform_vremap) { @@ -552,7 +552,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -571,7 +571,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -591,9 +591,9 @@ int AtomVecKokkos::pack_comm_vel_kokkos( } } else { sync(Device,X_MASK|V_MASK); - if(pbc_flag) { - if(deform_vremap) { - if(domain->triclinic) { + if (pbc_flag) { + if (deform_vremap) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -611,7 +611,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -630,7 +630,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, @@ -692,7 +692,7 @@ struct AtomVecKokkos_UnpackCommVel { void AtomVecKokkos::unpack_comm_vel_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { sync(Host,X_MASK|V_MASK); modified(Host,X_MASK|V_MASK); struct AtomVecKokkos_UnpackCommVel f(atomKK->k_x,atomKK->k_v,buf,first); @@ -865,7 +865,7 @@ struct AtomVecKokkos_PackReverse { int AtomVecKokkos::pack_reverse_kokkos(const int &n, const int &first, const DAT::tdual_ffloat_2d &buf ) { - if(commKK->reverse_comm_on_host) { + if (commKK->reverse_comm_on_host) { sync(Host,F_MASK); struct AtomVecKokkos_PackReverse f(atomKK->k_f,buf,first); Kokkos::parallel_for(n,f); @@ -911,7 +911,7 @@ struct AtomVecKokkos_UnPackReverseSelf { int AtomVecKokkos::unpack_reverse_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, const int nfirst) { - if(commKK->reverse_comm_on_host) { + if (commKK->reverse_comm_on_host) { sync(Host,F_MASK); struct AtomVecKokkos_UnPackReverseSelf f(atomKK->k_f,nfirst,list,iswap); Kokkos::parallel_for(n,f); @@ -966,7 +966,7 @@ void AtomVecKokkos::unpack_reverse_kokkos(const int &n, // Check whether to always run reverse communication on the host // Choose correct reverse UnPackReverse kernel - if(commKK->reverse_comm_on_host) { + if (commKK->reverse_comm_on_host) { struct AtomVecKokkos_UnPackReverse f(atomKK->k_f,buf,list,iswap); Kokkos::parallel_for(n,f); modified(Host,F_MASK); @@ -981,7 +981,7 @@ void AtomVecKokkos::unpack_reverse_kokkos(const int &n, int AtomVecKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) sync(Host,F_MASK); int m = 0; @@ -1007,7 +1007,7 @@ void AtomVecKokkos::unpack_reverse(int n, int *list, double *buf) h_f(j,2) += buf[m++]; } - if(n > 0) + if (n > 0) modified(Host,F_MASK); } diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index 20a748191c..2fb33e02b7 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -360,10 +360,10 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -375,7 +375,7 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -389,8 +389,8 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, } } else { atomKK->sync(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -402,7 +402,7 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackComm f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -476,11 +476,11 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d const int & iswap, const int nfirst, const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -492,7 +492,7 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -507,8 +507,8 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d } else { atomKK->sync(Device,X_MASK); atomKK->modified(Device,X_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -520,7 +520,7 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecMolecularKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); @@ -564,7 +564,7 @@ struct AtomVecMolecularKokkos_UnpackComm { void AtomVecMolecularKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); struct AtomVecMolecularKokkos_UnpackComm f(atomKK->k_x,buf,first); @@ -713,7 +713,7 @@ void AtomVecMolecularKokkos::unpack_comm_vel(int n, int first, double *buf) int AtomVecMolecularKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK); int m = 0; @@ -730,7 +730,7 @@ int AtomVecMolecularKokkos::pack_reverse(int n, int first, double *buf) void AtomVecMolecularKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) + if (n > 0) atomKK->modified(Host,F_MASK); int m = 0; @@ -814,7 +814,7 @@ int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendli dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -828,7 +828,7 @@ int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendli } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); @@ -1011,7 +1011,7 @@ struct AtomVecMolecularKokkos_UnpackBorder { typename AT::t_tagint_1d &molecule, const int& first): _buf(buf),_x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), - _first(first){ + _first(first) { }; KOKKOS_INLINE_FUNCTION @@ -1035,7 +1035,7 @@ void AtomVecMolecularKokkos::unpack_border_kokkos(const int &n, const int &first atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); while (first+n >= nmax) grow(0); atomKK->modified(space,X_MASK|TAG_MASK|TYPE_MASK|MASK_MASK|MOLECULE_MASK); - if(space==Host) { + if (space==Host) { struct AtomVecMolecularKokkos_UnpackBorder f(buf.view(),h_x,h_tag,h_type,h_mask,h_molecule,first); Kokkos::parallel_for(n,f); @@ -1240,7 +1240,7 @@ struct AtomVecMolecularKokkos_PackExchangeFunctor { _sendlist(sendlist.template view()), _copylist(copylist.template view()), _nlocal(nlocal),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { // 3 comp of x, 3 comp of v, 1 tag, 1 type, 1 mask, 1 image, 1 molecule, 3 nspecial, // maxspecial special, 1 num_bond, bond_per_atom bond_type, bond_per_atom bond_atom, // 1 num_angle, angle_per_atom angle_type, angle_per_atom angle_atom1, angle_atom2, @@ -1309,7 +1309,7 @@ struct AtomVecMolecularKokkos_PackExchangeFunctor { const int j = _copylist(mysend); - if(j>-1) { + if (j>-1) { _xw(i,0) = _x(j,0); _xw(i,1) = _x(j,1); _xw(i,2) = _x(j,2); @@ -1368,12 +1368,12 @@ int AtomVecMolecularKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfl { const int elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(nsend > (int) (k_buf.view().extent(0)* + if (nsend > (int) (k_buf.view().extent(0)* k_buf.view().extent(1))/elements) { int newsize = nsend*elements/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } - if(space == Host) { + if (space == Host) { AtomVecMolecularKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); @@ -1517,7 +1517,7 @@ struct AtomVecMolecularKokkos_UnpackExchangeFunctor { _improper_atom3(atom->k_improper_atom3.view()), _improper_atom4(atom->k_improper_atom4.view()), _nlocal(nlocal.template view()),_dim(dim), - _lo(lo),_hi(hi){ + _lo(lo),_hi(hi) { elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; @@ -1589,7 +1589,7 @@ int AtomVecMolecularKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,i ExecutionSpace space) { const size_t elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecMolecularKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 22d10e4632..451e9d737e 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -274,10 +274,10 @@ int AtomVecSphereKokkos::pack_comm_kokkos( return AtomVecKokkos::pack_comm_kokkos(n,list,iswap,buf,pbc_flag,pbc); // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -295,7 +295,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -315,8 +315,8 @@ int AtomVecSphereKokkos::pack_comm_kokkos( } } else { atomKK->sync(Device,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -334,7 +334,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -461,11 +461,11 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( const int &pbc_flag, const int* const pbc) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); - if(pbc_flag) { - if(deform_vremap) { - if(domain->triclinic) { + if (pbc_flag) { + if (deform_vremap) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -507,7 +507,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -550,7 +550,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -594,9 +594,9 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } else { atomKK->sync(Device,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); - if(pbc_flag) { - if(deform_vremap) { - if(domain->triclinic) { + if (pbc_flag) { + if (deform_vremap) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -638,7 +638,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -681,7 +681,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( } } } else { - if(domain->triclinic) { + if (domain->triclinic) { if (radvary == 0) { struct AtomVecSphereKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, @@ -792,11 +792,11 @@ int AtomVecSphereKokkos::pack_comm_self( // Fallback to AtomVecKokkos if radvary == 0 if (radvary == 0) return AtomVecKokkos::pack_comm_self(n,list,iswap,nfirst,pbc_flag,pbc); - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK); atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -814,7 +814,7 @@ int AtomVecSphereKokkos::pack_comm_self( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -835,8 +835,8 @@ int AtomVecSphereKokkos::pack_comm_self( } else { atomKK->sync(Device,X_MASK|RADIUS_MASK|RMASS_MASK); atomKK->modified(Device,X_MASK|RADIUS_MASK|RMASS_MASK); - if(pbc_flag) { - if(domain->triclinic) { + if (pbc_flag) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -854,7 +854,7 @@ int AtomVecSphereKokkos::pack_comm_self( Kokkos::parallel_for(n,f); } } else { - if(domain->triclinic) { + if (domain->triclinic) { struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, @@ -923,7 +923,7 @@ void AtomVecSphereKokkos::unpack_comm_kokkos( AtomVecKokkos::unpack_comm_kokkos(n,first,buf); return; } - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK); struct AtomVecSphereKokkos_UnpackComm f( atomKK->k_x, @@ -995,7 +995,7 @@ struct AtomVecSphereKokkos_UnpackCommVel { void AtomVecSphereKokkos::unpack_comm_vel_kokkos( const int &n, const int &first, const DAT::tdual_xfloat_2d &buf ) { - if(commKK->forward_comm_on_host) { + if (commKK->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); if (radvary == 0) { struct AtomVecSphereKokkos_UnpackCommVel f( @@ -1352,7 +1352,7 @@ int AtomVecSphereKokkos::unpack_comm_hybrid(int n, int first, double *buf) int AtomVecSphereKokkos::pack_reverse(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,F_MASK|TORQUE_MASK); int m = 0; @@ -1372,7 +1372,7 @@ int AtomVecSphereKokkos::pack_reverse(int n, int first, double *buf) int AtomVecSphereKokkos::pack_reverse_hybrid(int n, int first, double *buf) { - if(n > 0) + if (n > 0) atomKK->sync(Host,TORQUE_MASK); int m = 0; @@ -1389,7 +1389,7 @@ int AtomVecSphereKokkos::pack_reverse_hybrid(int n, int first, double *buf) void AtomVecSphereKokkos::unpack_reverse(int n, int *list, double *buf) { - if(n > 0) { + if (n > 0) { atomKK->modified(Host,F_MASK|TORQUE_MASK); } @@ -1409,7 +1409,7 @@ void AtomVecSphereKokkos::unpack_reverse(int n, int *list, double *buf) int AtomVecSphereKokkos::unpack_reverse_hybrid(int n, int *list, double *buf) { - if(n > 0) { + if (n > 0) { atomKK->modified(Host,TORQUE_MASK); } @@ -1502,7 +1502,7 @@ int AtomVecSphereKokkos::pack_border_kokkos( dy = pbc[1]; dz = pbc[2]; } - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1519,7 +1519,7 @@ int AtomVecSphereKokkos::pack_border_kokkos( } } else { dx = dy = dz = 0; - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1697,7 +1697,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( dz = pbc[2]; } if (!deform_vremap) { - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1721,7 +1721,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; dvz = pbc[2]*h_rate[2]; - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1742,7 +1742,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( } } } else { - if(space==Host) { + if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), iswap,h_x,h_tag,h_type,h_mask, @@ -1926,7 +1926,7 @@ struct AtomVecSphereKokkos_UnpackBorder { void AtomVecSphereKokkos::unpack_border_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf,ExecutionSpace space) { while (first+n >= nmax) grow(0); - if(space==Host) { + if (space==Host) { struct AtomVecSphereKokkos_UnpackBorder f(buf.view(), h_x,h_tag,h_type,h_mask, h_radius,h_rmass, @@ -2034,7 +2034,7 @@ void AtomVecSphereKokkos::unpack_border_vel_kokkos( const int &n, const int &first, const DAT::tdual_xfloat_2d &buf,ExecutionSpace space) { while (first+n >= nmax) grow(0); - if(space==Host) { + if (space==Host) { struct AtomVecSphereKokkos_UnpackBorderVel f(buf.view(), h_x,h_tag,h_type,h_mask, h_radius,h_rmass, @@ -2212,7 +2212,7 @@ int AtomVecSphereKokkos::pack_exchange_kokkos( DAT::tdual_int_1d k_copylist, ExecutionSpace space,int dim,X_FLOAT lo,X_FLOAT hi) { - if(nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/16) { + if (nsend > (int) (k_buf.view().extent(0)*k_buf.view().extent(1))/16) { int newsize = nsend*17/k_buf.view().extent(1)+1; k_buf.resize(newsize,k_buf.view().extent(1)); } @@ -2220,7 +2220,7 @@ int AtomVecSphereKokkos::pack_exchange_kokkos( MASK_MASK | IMAGE_MASK| RADIUS_MASK | RMASS_MASK | OMEGA_MASK); - if(space == Host) { + if (space == Host) { AtomVecSphereKokkos_PackExchangeFunctor f(atomKK,k_buf,k_sendlist,k_copylist,atom->nlocal,dim,lo,hi); Kokkos::parallel_for(nsend,f); } else { @@ -2338,7 +2338,7 @@ struct AtomVecSphereKokkos_UnpackExchangeFunctor { /* ---------------------------------------------------------------------- */ int AtomVecSphereKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf,int nrecv,int nlocal,int dim,X_FLOAT lo,X_FLOAT hi,ExecutionSpace space) { - if(space == Host) { + if (space == Host) { k_count.h_view(0) = nlocal; AtomVecSphereKokkos_UnpackExchangeFunctor f(atomKK,k_buf,k_count,dim,lo,hi); Kokkos::parallel_for(nrecv/16,f); diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 2ef4b14d4f..ddfa5530b8 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -571,10 +571,10 @@ void CommKokkos::reverse_comm_dump(Dump *dump) void CommKokkos::exchange() { - if(atom->nextra_grow + atom->nextra_border) { - if(!exchange_comm_classic) { + if (atom->nextra_grow + atom->nextra_border) { + if (!exchange_comm_classic) { static int print = 1; - if(print && comm->me==0) { + if (print && comm->me==0) { error->warning(FLERR,"Fixes cannot yet send exchange data in Kokkos communication, " "switching to classic exchange/border communication"); } @@ -625,7 +625,7 @@ struct BuildExchangeListFunctor { void operator() (int i) const { if (_x(i,_dim) < _lo || _x(i,_dim) >= _hi) { const int mysend=Kokkos::atomic_fetch_add(&_nsend(),1); - if(mysend < (int)_sendlist.extent(0)) { + if (mysend < (int)_sendlist.extent(0)) { _sendlist(mysend) = i; _sendflag(i) = 1; } @@ -713,7 +713,7 @@ void CommKokkos::exchange_device() int sendpos = nlocal-1; nlocal -= k_count.h_view(); - for(int i = 0; i < k_count.h_view(); i++) { + for (int i = 0; i < k_count.h_view(); i++) { if (k_exchange_sendlist.h_view(i)= lo && x(i,dim) <= hi) { sendlist(iswap,mysend++) = i; } @@ -979,7 +979,7 @@ void CommKokkos::borders_device() { k_sendlist.modify(); - if(k_total_send.h_view() >= maxsendlist[iswap]) { + if (k_total_send.h_view() >= maxsendlist[iswap]) { grow_list(iswap,k_total_send.h_view()); k_total_send.h_view() = 0; @@ -1227,7 +1227,7 @@ void CommKokkos::grow_send_kokkos(int n, int flag, ExecutionSpace space) maxsend = static_cast (BUFFACTOR * n); int maxsend_border = (maxsend+BUFEXTRA+5)/atom->avec->size_border + 2; if (flag) { - if(space == Device) + if (space == Device) k_buf_send.modify(); else k_buf_send.modify(); @@ -1280,7 +1280,7 @@ void CommKokkos::grow_list(int /*iswap*/, int n) memoryKK->grow_kokkos(k_sendlist,sendlist,maxswap,size,"comm:sendlist"); - for(int i=0;i()(i,0); } } diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 3703769e90..8cac92240f 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -241,7 +241,7 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder int ncount = 0; Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,jnum), [&] (const int jj, int& count) { - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { int j = d_neighbors(i,jj); j &= NEIGHMASK; const F_FLOAT delx = x(j,0) - xtmp; @@ -439,14 +439,14 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int /*ncount*/, int ii const double r1 = d_rlist(ii,ineigh,1); const double r2 = d_rlist(ii,ineigh,2); const double rmag = sqrt(r0*r0 + r1*r1 + r2*r2); - if(rmag <= MY_EPSILON) { + if (rmag <= MY_EPSILON) { return; } const double costheta = r2 / rmag; SNAcomplex expphi = {r0,r1}; const double rxymag = sqrt(expphi.re*expphi.re+expphi.im*expphi.im); - if(rxymag <= MY_EPSILON) { + if (rxymag <= MY_EPSILON) { expphi.re = 1.0; expphi.im = 0.0; } else { @@ -466,14 +466,14 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int /*ncount*/, int ii const double polar_pf = polar_prefactor(l, 0, costheta); Kokkos::atomic_add(&(d_qnm(ii,il,l).re), polar_pf); SNAcomplex expphim = {expphi.re,expphi.im}; - for(int m = 1; m <= +l; m++) { + for (int m = 1; m <= +l; m++) { const double prefactor = polar_prefactor(l, m, costheta); SNAcomplex ylm = {prefactor * expphim.re, prefactor * expphim.im}; //d_qnm(ii,il,m+l).re += ylm.re; //d_qnm(ii,il,m+l).im += ylm.im; Kokkos::atomic_add(&(d_qnm(ii,il,m+l).re), ylm.re); Kokkos::atomic_add(&(d_qnm(ii,il,m+l).im), ylm.im); - if(m & 1) { + if (m & 1) { //d_qnm(ii,il,-m+l).re -= ylm.re; //d_qnm(ii,il,-m+l).im += ylm.im; Kokkos::atomic_add(&(d_qnm(ii,il,-m+l).re), -ylm.re); @@ -508,7 +508,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co double facn = 1.0 / ncount; for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { d_qnm(ii,il,m).re *= facn; d_qnm(ii,il,m).im *= facn; } @@ -522,7 +522,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co int l = d_qlist[il]; double qnormfac = sqrt(MY_4PI/(2*l+1)); double qm_sum = 0.0; - for(int m = 0; m < 2*l+1; m++) + for (int m = 0; m < 2*l+1; m++) qm_sum += d_qnm(ii,il,m).re*d_qnm(ii,il,m).re + d_qnm(ii,il,m).im*d_qnm(ii,il,m).im; d_qnarray(i,jj++) = qnormfac * sqrt(qm_sum); } @@ -534,8 +534,8 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { int m = m1 + m2 - l; SNAcomplex qm1qm2; qm1qm2.re = d_qnm(ii,il,m1).re*d_qnm(ii,il,m2).re - d_qnm(ii,il,m1).im*d_qnm(ii,il,m2).im; @@ -555,8 +555,8 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { const int m = m1 + m2 - l; SNAcomplex qm1qm2; qm1qm2.re = d_qnm(ii,il,m1).re*d_qnm(ii,il,m2).re - d_qnm(ii,il,m1).im*d_qnm(ii,il,m2).im; @@ -581,14 +581,14 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co const int il = iqlcomp; const int l = qlcomp; if (d_qnarray(i,il) < QEPSILON) - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { d_qnarray(i,jj++) = 0.0; d_qnarray(i,jj++) = 0.0; } else { const double qnormfac = sqrt(MY_4PI/(2*l+1)); const double qnfac = qnormfac/d_qnarray(i,il); - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { d_qnarray(i,jj++) = d_qnm(ii,il,m).re * qnfac; d_qnarray(i,jj++) = d_qnm(ii,il,m).im * qnfac; } @@ -665,8 +665,8 @@ void ComputeOrientOrderAtomKokkos::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) + for (int m1 = 0; m1 < 2*l+1; m1++) + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) idxcg_count++; } idxcg_max = idxcg_count; @@ -676,9 +676,9 @@ void ComputeOrientOrderAtomKokkos::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { aa2 = m1 - l; - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { bb2 = m2 - l; m = aa2 + bb2 + l; @@ -727,7 +727,7 @@ void ComputeOrientOrderAtomKokkos::check_team_size_for(int inum, int team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; } diff --git a/src/KOKKOS/domain_kokkos.cpp b/src/KOKKOS/domain_kokkos.cpp index e124d98f7e..0d03f6c910 100644 --- a/src/KOKKOS/domain_kokkos.cpp +++ b/src/KOKKOS/domain_kokkos.cpp @@ -235,7 +235,7 @@ struct DomainPBCFunctor { x(_x.view()), v(_v.view()), mask(_mask.view()), image(_image.view()), deform_groupbit(_deform_groupbit), - xperiodic(_xperiodic), yperiodic(_yperiodic), zperiodic(_zperiodic){ + xperiodic(_xperiodic), yperiodic(_yperiodic), zperiodic(_zperiodic) { lo[0]=_lo[0]; lo[1]=_lo[1]; lo[2]=_lo[2]; hi[0]=_hi[0]; hi[1]=_hi[1]; hi[2]=_hi[2]; period[0]=_period[0]; period[1]=_period[1]; period[2]=_period[2]; diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 2294c24b11..8608b90543 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -77,7 +77,7 @@ void FixEnforce2DKokkos::post_force(int /*vflag*/) if (atomKK->torque_flag) flag_mask |= 4; copymode = 1; - switch( flag_mask ){ + switch( flag_mask ) { case 0:{ FixEnforce2DKokkosPostForceFunctor functor(this); Kokkos::parallel_for(nlocal,functor); @@ -139,21 +139,21 @@ template KOKKOS_INLINE_FUNCTION void FixEnforce2DKokkos::post_force_item( int i ) const { - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { v(i,2) = 0.0; f(i,2) = 0.0; - if(omega_flag){ + if (omega_flag) { omega(i,0) = 0.0; omega(i,1) = 0.0; } - if(angmom_flag){ + if (angmom_flag) { angmom(i,0) = 0.0; angmom(i,1) = 0.0; } - if(torque_flag){ + if (torque_flag) { torque(i,0) = 0.0; torque(i,1) = 0.0; } diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index 2bf2812e0b..a14e301bfa 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -193,7 +193,7 @@ KOKKOS_INLINE_FUNCTION void FixEOStableRXKokkos::operator()(TagFixEOStableRXInit, const int &i) const { double tmp; if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) k_error_flag.template view()() = 1; energy_lookup(i,dpdTheta[i],tmp); uCond[i] = 0.0; @@ -233,7 +233,7 @@ void FixEOStableRXKokkos::post_integrate() template KOKKOS_INLINE_FUNCTION void FixEOStableRXKokkos::operator()(TagFixEOStableRXTemperatureLookup2, const int &i) const { - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); if (dpdTheta[i] <= 0.0) k_error_flag.template view()() = 1; @@ -314,7 +314,7 @@ void FixEOStableRXKokkos::energy_lookup(int id, double thetai, doubl nTotal = 1.0; } - for(int ispecies=0;ispecieslo); thetai = MAX(thetai,d_table_const.lo(ispecies)); @@ -364,7 +364,7 @@ void FixEOStableRXKokkos::temperature_lookup(int id, double ui, doub // Store the current thetai in t1 t1 = MAX(thetai,lo); t1 = MIN(t1,hi); - if(t1==hi) delta = -delta; + if (t1==hi) delta = -delta; // Compute u1 at thetai energy_lookup(id,t1,u1); @@ -382,9 +382,9 @@ void FixEOStableRXKokkos::temperature_lookup(int id, double ui, doub f2 = u2 - ui; // Apply the Secant Method - for(it=0; it()() = 2; + for (it=0; it()() = 2; temp = t1; temp = MAX(temp,lo); temp = MIN(temp,hi); @@ -392,15 +392,15 @@ void FixEOStableRXKokkos::temperature_lookup(int id, double ui, doub break; } temp = t2 - f2*(t2-t1)/(f2-f1); - if(fabs(temp-t2) < tolerance) break; + if (fabs(temp-t2) < tolerance) break; f1 = f2; t1 = t2; t2 = temp; energy_lookup(id,t2,u2); f2 = u2 - ui; } - if(it==maxit){ - if(std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) + if (it==maxit) { + if (std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) k_error_flag.template view()() = 2; else k_error_flag.template view()() = 3; @@ -440,7 +440,7 @@ void FixEOStableRXKokkos::unpack_forward_comm(int n, int first, doub m = 0; last = first + n ; - for (ii = first; ii < last; ii++){ + for (ii = first; ii < last; ii++) { h_uChem[ii] = buf[m++]; h_uCG[ii] = buf[m++]; h_uCGnew[ii] = buf[m++]; @@ -518,24 +518,24 @@ void FixEOStableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->hi,h_table->hi,ntables,"Table::hi"); memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->r,h_table->r,ntables,tablength,"Table::r"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->de,h_table->de,ntables,tlm1,"Table::de"); } - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->lo[i] = tb->lo; h_table->hi[i] = tb->hi; h_table->invdelta[i] = tb->invdelta; - for(int j = 0; jr.extent(1); j++) + for (int j = 0; jr.extent(1); j++) h_table->r(i,j) = tb->r[j]; - for(int j = 0; je.extent(1); j++) + for (int j = 0; je.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; jde.extent(1); j++) + for (int j = 0; jde.extent(1); j++) h_table->de(i,j) = tb->de[j]; } diff --git a/src/KOKKOS/fix_langevin_kokkos.cpp b/src/KOKKOS/fix_langevin_kokkos.cpp index b5973e25a0..0dcaabb39c 100644 --- a/src/KOKKOS/fix_langevin_kokkos.cpp +++ b/src/KOKKOS/fix_langevin_kokkos.cpp @@ -61,7 +61,7 @@ FixLangevinKokkos::FixLangevinKokkos(LAMMPS *lmp, int narg, char **a for (int i = 1; i <= ntypes; i++) ratio[i] = 1.0; k_ratio.template modify(); - if(gjfflag){ + if (gjfflag) { grow_arrays(atomKK->nmax); atom->add_callback(Atom::GROW); // initialize franprev to zero @@ -76,7 +76,7 @@ FixLangevinKokkos::FixLangevinKokkos(LAMMPS *lmp, int narg, char **a k_franprev.template modify(); k_lv.template modify(); } - if(zeroflag){ + if (zeroflag) { k_fsumall = tdual_double_1d_3n("langevin:fsumall"); h_fsumall = k_fsumall.template view(); d_fsumall = k_fsumall.template view(); @@ -97,8 +97,8 @@ FixLangevinKokkos::~FixLangevinKokkos() memoryKK->destroy_kokkos(k_gfactor2,gfactor2); memoryKK->destroy_kokkos(k_ratio,ratio); memoryKK->destroy_kokkos(k_flangevin,flangevin); - if(gjfflag) memoryKK->destroy_kokkos(k_franprev,franprev); - if(gjfflag) memoryKK->destroy_kokkos(k_lv,lv); + if (gjfflag) memoryKK->destroy_kokkos(k_franprev,franprev); + if (gjfflag) memoryKK->destroy_kokkos(k_lv,lv); memoryKK->destroy_kokkos(k_tforce,tforce); } @@ -108,13 +108,13 @@ template void FixLangevinKokkos::init() { FixLangevin::init(); - if(oflag) + if (oflag) error->all(FLERR,"Fix langevin omega is not yet implemented with kokkos"); - if(ascale) + if (ascale) error->all(FLERR,"Fix langevin angmom is not yet implemented with kokkos"); - if(gjfflag && tbiasflag) + if (gjfflag && tbiasflag) error->all(FLERR,"Fix langevin gjf + tbias is not yet implemented with kokkos"); - if(gjfflag && tbiasflag) + if (gjfflag && tbiasflag) error->warning(FLERR,"Fix langevin gjf + kokkos is not implemented with random gaussians"); // prefactors are modified in the init @@ -182,8 +182,8 @@ void FixLangevinKokkos::post_force(int /*vflag*/) k_gfactor1.template sync(); k_gfactor2.template sync(); k_ratio.template sync(); - if(gjfflag) k_franprev.template sync(); - if(gjfflag) k_lv.template sync(); + if (gjfflag) k_franprev.template sync(); + if (gjfflag) k_lv.template sync(); boltz = force->boltz; dt = update->dt; @@ -217,7 +217,7 @@ void FixLangevinKokkos::post_force(int /*vflag*/) } // account for bias velocity - if(tbiasflag == BIAS){ + if (tbiasflag == BIAS) { atomKK->sync(temperature->execution_space,temperature->datamask_read); temperature->compute_scalar(); temperature->remove_bias_all(); // modifies velocities @@ -516,7 +516,7 @@ void FixLangevinKokkos::post_force(int /*vflag*/) } - if(tbiasflag == BIAS){ + if (tbiasflag == BIAS) { atomKK->sync(temperature->execution_space,temperature->datamask_read); temperature->restore_bias_all(); // modifies velocities atomKK->modified(temperature->execution_space,temperature->datamask_modify); @@ -566,8 +566,8 @@ FSUM FixLangevinKokkos::post_force_item(int i) const if (mask[i] & groupbit) { rand_type rand_gen = rand_pool.get_state(); - if(Tp_TSTYLEATOM) tsqrt_t = sqrt(d_tforce[i]); - if(Tp_RMASS){ + if (Tp_TSTYLEATOM) tsqrt_t = sqrt(d_tforce[i]); + if (Tp_RMASS) { gamma1 = -rmass[i] / t_period / ftm2v; gamma2 = sqrt(rmass[i]) * fran_prop_const / ftm2v; gamma1 *= 1.0/d_ratio[type[i]]; @@ -581,7 +581,7 @@ FSUM FixLangevinKokkos::post_force_item(int i) const fran[1] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); fran[2] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); - if(Tp_BIAS){ + if (Tp_BIAS) { fdrag[0] = gamma1*v(i,0); fdrag[1] = gamma1*v(i,1); fdrag[2] = gamma1*v(i,2); @@ -625,7 +625,7 @@ FSUM FixLangevinKokkos::post_force_item(int i) const f(i,2) += fdrag[2] + fran[2]; if (Tp_TALLY) { - if (Tp_GJF){ + if (Tp_GJF) { fdrag[0] = gamma1*d_lv(i,0)/gjfsib/gjfsib; fdrag[1] = gamma1*d_lv(i,1)/gjfsib/gjfsib; fdrag[2] = gamma1*d_lv(i,2)/gjfsib/gjfsib; @@ -794,7 +794,7 @@ void FixLangevinKokkos::end_of_step() FixLangevinKokkosTallyEnergyFunctor tally_functor(this); Kokkos::parallel_reduce(nlocal,tally_functor,energy_onestep); - if (gjfflag){ + if (gjfflag) { if (rmass.data()) { FixLangevinKokkosEndOfStepFunctor functor(this); Kokkos::parallel_for(nlocal,functor); @@ -817,7 +817,7 @@ void FixLangevinKokkos::end_of_step_item(int i) const { tmp[0] = v(i,0); tmp[1] = v(i,1); tmp[2] = v(i,2); - if (!osflag){ + if (!osflag) { v(i,0) = d_lv(i,0); v(i,1) = d_lv(i,1); v(i,2) = d_lv(i,2); @@ -848,7 +848,7 @@ void FixLangevinKokkos::end_of_step_rmass_item(int i) const tmp[0] = v(i,0); tmp[1] = v(i,1); tmp[2] = v(i,2); - if (!osflag){ + if (!osflag) { v(i,0) = d_lv(i,0); v(i,1) = d_lv(i,1); v(i,2) = d_lv(i,2); diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index c96f5ded68..e81579061b 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -139,8 +139,8 @@ void FixQEqReaxKokkos::init_shielding_k() k_shield = DAT::tdual_ffloat_2d("qeq/kk:shield",ntypes+1,ntypes+1); d_shield = k_shield.template view(); - for( i = 1; i <= ntypes; ++i ) - for( j = 1; j <= ntypes; ++j ) + for ( i = 1; i <= ntypes; ++i ) + for ( j = 1; j <= ntypes; ++j ) k_shield.h_view(i,j) = pow( gamma[i] * gamma[j], -1.5 ); k_shield.template modify(); @@ -1053,7 +1053,7 @@ void FixQEqReaxKokkos::sparse13_item(int ii) const const int i = d_ilist[ii]; if (mask[i] & groupbit) { F_FLOAT tmp = 0.0; - for(int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { + for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { const int j = d_jlist(jj); tmp += d_val(jj) * d_s[j]; a_o[j] += d_val(jj) * d_s[i]; @@ -1106,7 +1106,7 @@ void FixQEqReaxKokkos::sparse23_item(int ii) const const int i = d_ilist[ii]; if (mask[i] & groupbit) { F_FLOAT tmp = 0.0; - for(int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { + for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { const int j = d_jlist(jj); tmp += d_val(jj) * d_d[j]; a_o[j] += d_val(jj) * d_d[i]; @@ -1166,7 +1166,7 @@ void FixQEqReaxKokkos::sparse33_item(int ii) const const int i = d_ilist[ii]; if (mask[i] & groupbit) { F_FLOAT tmp = 0.0; - for(int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { + for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { const int j = d_jlist(jj); tmp += d_val(jj) * d_t[j]; a_o[j] += d_val(jj) * d_t[i]; @@ -1371,11 +1371,11 @@ void FixQEqReaxKokkos::operator()(TagFixQEqReaxPackForwardComm, cons if (pack_flag == 1) d_buf[i] = d_d[j]; - else if( pack_flag == 2 ) + else if ( pack_flag == 2 ) d_buf[i] = d_s[j]; - else if( pack_flag == 3 ) + else if ( pack_flag == 3 ) d_buf[i] = d_t[j]; - else if( pack_flag == 4 ) + else if ( pack_flag == 4 ) d_buf[i] = q[j]; } @@ -1394,11 +1394,11 @@ KOKKOS_INLINE_FUNCTION void FixQEqReaxKokkos::operator()(TagFixQEqReaxUnpackForwardComm, const int &i) const { if (pack_flag == 1) d_d[i + first] = d_buf[i]; - else if( pack_flag == 2) + else if ( pack_flag == 2) d_s[i + first] = d_buf[i]; - else if( pack_flag == 3) + else if ( pack_flag == 3) d_t[i + first] = d_buf[i]; - else if( pack_flag == 4) + else if ( pack_flag == 4) q[i + first] = d_buf[i]; } @@ -1412,13 +1412,13 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu int m; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = h_d[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = h_s[list[m]]; - else if( pack_flag == 3 ) - for(m = 0; m < n; m++) buf[m] = h_t[list[m]]; - else if( pack_flag == 4 ) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + for (m = 0; m < n; m++) buf[m] = h_d[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = h_s[list[m]]; + else if ( pack_flag == 3 ) + for (m = 0; m < n; m++) buf[m] = h_t[list[m]]; + else if ( pack_flag == 4 ) + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; return n; } @@ -1431,13 +1431,13 @@ void FixQEqReaxKokkos::unpack_forward_comm(int n, int first, double int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; - else if( pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; - else if( pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) h_d[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) h_s[i] = buf[m]; + else if ( pack_flag == 3) + for (m = 0, i = first; m < n; m++, i++) h_t[i] = buf[m]; + else if ( pack_flag == 4) + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -1446,7 +1446,7 @@ template int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) { + for (m = 0, i = first; m < n; m++, i++) { buf[m] = h_o[i]; } return n; @@ -1457,7 +1457,7 @@ int FixQEqReaxKokkos::pack_reverse_comm(int n, int first, double *bu template void FixQEqReaxKokkos::unpack_reverse_comm(int n, int *list, double *buf) { - for(int m = 0; m < n; m++) { + for (int m = 0; m < n; m++) { h_o[list[m]] += buf[m]; } } diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 81ac590471..7a8bfbf9dd 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -130,7 +130,7 @@ void FixRxKokkos::init() bool eos_flag = false; for (int i = 0; i < modify->nfix; i++) if (utils::strmatch(modify->fix[i]->style,"^eos/table/rx")) eos_flag = true; - if(!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); + if (!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); if (update_kinetics_data) create_kinetics_data(); @@ -322,7 +322,7 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto // 1) k_rhs (0.0, y, f1, userData); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f1[k] *= h; ytmp[k] = y[k] + c21 * f1[k]; } @@ -330,7 +330,7 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto // 2) k_rhs(0.0, ytmp, f2, userData); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f2[k] *= h; ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; } @@ -429,7 +429,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do // Compute WRMS norm of y'' double yddnrm = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { double ydd = (ydot1[k] - ydot[k]) / hg; double wterr = ydd / (relTol * fabs( y[k] ) + absTol); yddnrm += wterr * wterr; @@ -441,7 +441,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do //std::cout << "ydot " << ydot[neq-1] << std::endl; // should we accept this? - if (hnew_is_ok || iter == max_iters){ + if (hnew_is_ok || iter == max_iters) { hnew = hg; //if (iter == max_iters) // fprintf(stderr, "ERROR_HIN_MAX_ITERS\n"); @@ -510,7 +510,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector double t = 0.0; - if (h < h_min){ + if (h < h_min) { //fprintf(stderr,"hin not implemented yet\n"); //exit(-1); nfe = k_rkf45_h0 (neq, t, t_stop, h_min, h_max, h, y, rwork, userData); @@ -530,7 +530,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector // Estimate the solution error. // ... weighted 2-norm of the error. double err2 = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); err2 += wterr * wterr; } @@ -538,7 +538,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector double err = fmax( uround, sqrt( err2 / double(nspecies) )); // Accept the solution? - if (err <= 1.0 || h <= h_min){ + if (err <= 1.0 || h <= h_min) { t += h; nst++; @@ -571,7 +571,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector nit++; nfe += 6; - if (maxIters && nit > maxIters){ + if (maxIters && nit > maxIters) { //fprintf(stderr,"atom[%d] took too many iterations in rkf45 %d %e %e\n", id, nit, t, t_stop); counter.nFails ++; break; @@ -643,7 +643,7 @@ void FixRxKokkos::rkf45_step (const int neq, const double h, double // 1) rhs (0.0, y, f1, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f1[k] *= h; ytmp[k] = y[k] + c21 * f1[k]; } @@ -651,7 +651,7 @@ void FixRxKokkos::rkf45_step (const int neq, const double h, double // 2) rhs(0.0, ytmp, f2, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f2[k] *= h; ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; } @@ -748,7 +748,7 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl // Compute WRMS norm of y'' double yddnrm = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { double ydd = (ydot1[k] - ydot[k]) / hg; double wterr = ydd / (relTol * fabs( y[k] ) + absTol); yddnrm += wterr * wterr; @@ -760,7 +760,7 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl //std::cout << "ydot " << ydot[neq-1] << std::endl; // should we accept this? - if (hnew_is_ok || iter == max_iters){ + if (hnew_is_ok || iter == max_iters) { hnew = hg; if (iter == max_iters) fprintf(stderr, "ERROR_HIN_MAX_ITERS\n"); @@ -827,7 +827,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * double t = 0.0; - if (h < h_min){ + if (h < h_min) { //fprintf(stderr,"hin not implemented yet\n"); //exit(-1); nfe = rkf45_h0 (neq, t, t_stop, h_min, h_max, h, y, rwork, v_param); @@ -836,7 +836,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * //printf("t= %e t_stop= %e h= %e\n", t, t_stop, h); // Integrate until we reach the end time. - while (fabs(t - t_stop) > tround){ + while (fabs(t - t_stop) > tround) { double *yout = rwork; double *eout = yout + neq; @@ -846,7 +846,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * // Estimate the solution error. // ... weighted 2-norm of the error. double err2 = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); err2 += wterr * wterr; } @@ -854,7 +854,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * double err = fmax( uround, sqrt( err2 / double(nspecies) )); // Accept the solution? - if (err <= 1.0 || h <= h_min){ + if (err <= 1.0 || h <= h_min) { t += h; nst++; @@ -887,7 +887,7 @@ void FixRxKokkos::rkf45(const int neq, const double t_stop, double * nit++; nfe += 6; - if (maxIters && nit > maxIters){ + if (maxIters && nit > maxIters) { //fprintf(stderr,"atom[%d] took too many iterations in rkf45 %d %e %e\n", id, nit, t, t_stop); counter.nFails ++; break; @@ -928,14 +928,14 @@ int FixRxKokkos::rhs_dense(double /*t*/, const double *y, double *dy //const double VDPD = domain->xprd * domain->yprd * domain->zprd / atom->natoms; //const int nspecies = atom->nspecies_dpd; - for(int ispecies=0; ispecies::rhs_dense(double /*t*/, const double *y, double *dy } // Construct the reaction rates for each species - for(int ispecies=0; ispecies::rhs_sparse(double /*t*/, const double *y, double *d for (int i = 0; i < nreactions; ++i) { double rxnRateLawForward; - if (isIntegral(i)){ + if (isIntegral(i)) { rxnRateLawForward = kFor[i] * powint( conc[ nuk(i,0) ], inu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -992,7 +992,7 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d } } else { rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], nu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1008,10 +1008,10 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d for (int k = 0; k < nspecies; ++k) dydt[k] = 0.0; - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { // Reactants ... dydt[ nuk(i,0) ] -= nu(i,0) * rxnRateLaw[i]; - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1020,7 +1020,7 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d // Products ... dydt[ nuk(i,maxReactants) ] += nu(i,maxReactants) * rxnRateLaw[i]; - for (int kk = maxReactants+1; kk < maxSpecies; ++kk){ + for (int kk = maxReactants+1; kk < maxSpecies; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1074,14 +1074,14 @@ int FixRxKokkos::k_rhs_dense(double /*t*/, const VectorType& y, Vect //const double VDPD = domain->xprd * domain->yprd * domain->zprd / atom->natoms; //const int nspecies = atom->nspecies_dpd; - for(int ispecies=0; ispecies::k_rhs_dense(double /*t*/, const VectorType& y, Vect } // Construct the reaction rates for each species - for(int ispecies=0; ispecies::k_rhs_sparse(double /*t*/, const VectorType& y, Vec for (int i = 0; i < nreactions; ++i) { double rxnRateLawForward; - if (isIntegral(i)){ + if (isIntegral(i)) { rxnRateLawForward = kFor[i] * powint( conc[ nuk(i,0) ], inu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1139,7 +1139,7 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec } } else { rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], nu(i,0) ); - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1155,10 +1155,10 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec for (int k = 0; k < nspecies; ++k) dydt[k] = 0.0; - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { // Reactants ... dydt[ nuk(i,0) ] -= nu(i,0) * rxnRateLaw[i]; - for (int kk = 1; kk < maxReactants; ++kk){ + for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1167,7 +1167,7 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec // Products ... dydt[ nuk(i,maxReactants) ] += nu(i,maxReactants) * rxnRateLaw[i]; - for (int kk = maxReactants+1; kk < maxSpecies; ++kk){ + for (int kk = maxReactants+1; kk < maxSpecies; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; //if (k != SparseKinetics_invalidIndex) @@ -1686,7 +1686,7 @@ void FixRxKokkos::solve_reactions(const int /*vflag*/, const bool is // getElapsedTime(timer_ODE, timer_stop), nlocal, TotalCounters.nFuncs, TotalCounters.nSteps); // Warn the user if a failure was detected in the ODE solver. - if (TotalCounters.nFails > 0){ + if (TotalCounters.nFails > 0) { char sbuf[128]; sprintf(sbuf,"in FixRX::pre_force, ODE solver failed for %d atoms.", TotalCounters.nFails); error->warning(FLERR, sbuf); @@ -1752,7 +1752,7 @@ void FixRxKokkos::odeDiagnostics(void) double min_per_proc[numCounters]; // Compute counters per dpd time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { my_vals[i] = this->diagnosticCounter[i] / nTimes; //printf("my sum[%d] = %f %d\n", i, my_vals[i], comm->me); } @@ -1767,7 +1767,7 @@ void FixRxKokkos::odeDiagnostics(void) double avg_per_atom[numCounters], avg_per_proc[numCounters]; // Averages per-ODE and per-proc per time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { avg_per_atom[i] = sums[i] / nODEs; avg_per_proc[i] = sums[i] / comm->nprocs; } @@ -1775,7 +1775,7 @@ void FixRxKokkos::odeDiagnostics(void) // Sum up the differences from each task. double sum_sq[2*numCounters]; double my_sum_sq[2*numCounters]; - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { double diff_i = my_vals[i] - avg_per_proc[i]; my_sum_sq[i] = diff_i * diff_i; } @@ -1835,7 +1835,7 @@ void FixRxKokkos::odeDiagnostics(void) TimerType timer_stop = getTimeStamp(); double time_local = getElapsedTime( timer_start, timer_stop ); - if (comm->me == 0){ + if (comm->me == 0) { char smesg[128]; #define print_mesg(smesg) {\ @@ -1849,7 +1849,7 @@ void FixRxKokkos::odeDiagnostics(void) print_mesg(smesg); // only valid for single time-step! - if (diagnosticFrequency == 1){ + if (diagnosticFrequency == 1) { double rms_per_ODE[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_ODE[i] = sqrt( sum_sq[i+numCounters] / nODEs ); @@ -1867,7 +1867,7 @@ void FixRxKokkos::odeDiagnostics(void) sprintf(smesg, " AVG per Proc : %-12.5g | %-12.5g | %-12.5g | %-12.5g", avg_per_proc[StepSum], avg_per_proc[FuncSum], avg_per_proc[TimeSum], avg_per_proc[AtomSum]); print_mesg(smesg); - if (comm->nprocs > 1){ + if (comm->nprocs > 1) { double rms_per_proc[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_proc[i] = sqrt( sum_sq[i] / comm->nprocs ); @@ -2206,7 +2206,7 @@ int FixRxKokkos::pack_forward_comm(int n, int *list, double *buf, in int m = 0; for (int ii = 0; ii < n; ii++) { const int jj = list[ii]; - for(int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { buf[m++] = h_dvector(ispecies,jj); buf[m++] = h_dvector(ispecies+nspecies,jj); } @@ -2228,8 +2228,8 @@ void FixRxKokkos::unpack_forward_comm(int n, int first, double *buf) const int last = first + n ; int m = 0; - for (int ii = first; ii < last; ii++){ - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ii = first; ii < last; ii++) { + for (int ispecies = 0; ispecies < nspecies; ispecies++) { h_dvector(ispecies,ii) = buf[m++]; h_dvector(ispecies+nspecies,ii) = buf[m++]; } diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 564c405894..d8c4931e0e 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -79,7 +79,7 @@ FixShardlowKokkos::FixShardlowKokkos(LAMMPS *lmp, int narg, char **a // k_pairDPD = (PairDPDfdtKokkos *) force->pair_match("dpd/fdt",1); k_pairDPDE = dynamic_cast *>(force->pair_match("dpd/fdt/energy",0)); -// if(k_pairDPDE){ +// if (k_pairDPDE) { comm_forward = 3; comm_reverse = 5; // } else { @@ -88,7 +88,7 @@ FixShardlowKokkos::FixShardlowKokkos(LAMMPS *lmp, int narg, char **a // } - if(/* k_pairDPD == nullptr &&*/ k_pairDPDE == nullptr) + if (/* k_pairDPD == nullptr &&*/ k_pairDPDE == nullptr) error->all(FLERR,"Must use pair_style "/*"dpd/fdt/kk or "*/"dpd/fdt/energy/kk with fix shardlow/kk"); #ifdef DEBUG_SSA_PAIR_CT @@ -160,7 +160,7 @@ void FixShardlowKokkos::init() k_params.h_view(j,i) = k_params.h_view(i,j); - if(ik_cutsq.h_view(i,j); } @@ -196,7 +196,7 @@ void FixShardlowKokkos::pre_neighbor() if (domain->triclinic) error->all(FLERR,"Fix shardlow does not yet support triclinic geometries"); - if(rcut >= bbx || rcut >= bby || rcut>= bbz ) + if (rcut >= bbx || rcut >= bby || rcut>= bbz ) { char fmt[] = {"Shardlow algorithm requires sub-domain length > 2*(rcut+skin). Either reduce the number of processors requested, or change the cutoff/skin: rcut= %e bbx= %e bby= %e bbz= %e\n"}; char *msg = (char *) malloc(sizeof(fmt) + 4*15); @@ -231,7 +231,7 @@ void FixShardlowKokkos::pre_neighbor() massPerI = false; masses = atomKK->k_mass.view(); } -// if(k_pairDPDE){ +// if (k_pairDPDE) { dpdTheta = atomKK->k_dpdTheta.view(); //} else { @@ -632,7 +632,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) for (workPhase = 0; workPhase < ssa_phaseCt; ++workPhase) { int workItemCt = h_ssa_phaseLen[workPhase]; - if(atom->ntypes > MAX_TYPES_STACKPARAMS) + if (atom->ntypes > MAX_TYPES_STACKPARAMS) Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); else Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); @@ -649,7 +649,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) comm->forward_comm_fix(this); atomKK->modified(Host,V_MASK); - if(k_pairDPDE){ + if (k_pairDPDE) { // Zero out the ghosts' uCond & uMech to be used as delta accumulators // memset(&(atom->uCond[nlocal]), 0, sizeof(double)*nghost); // memset(&(atom->uMech[nlocal]), 0, sizeof(double)*nghost); @@ -667,7 +667,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) // process neighbors in this AIR atomKK->sync(execution_space,X_MASK | V_MASK | TYPE_MASK | RMASS_MASK | UCOND_MASK | UMECH_MASK | DPDTHETA_MASK); - if(atom->ntypes > MAX_TYPES_STACKPARAMS) + if (atom->ntypes > MAX_TYPES_STACKPARAMS) Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); else Kokkos::parallel_for(Kokkos::RangePolicy >(0,workItemCt),*this); @@ -759,7 +759,7 @@ int FixShardlowKokkos::pack_reverse_comm(int n, int first, double *b buf[m++] = h_v(i, 0) - h_v_t0(i - nlocal, 0); buf[m++] = h_v(i, 1) - h_v_t0(i - nlocal, 1); buf[m++] = h_v(i, 2) - h_v_t0(i - nlocal, 2); - if(k_pairDPDE){ + if (k_pairDPDE) { buf[m++] = h_uCond(i); // for ghosts, this is an accumulated delta buf[m++] = h_uMech(i); // for ghosts, this is an accumulated delta } @@ -781,7 +781,7 @@ void FixShardlowKokkos::unpack_reverse_comm(int n, int *list, double h_v(j, 0) += buf[m++]; h_v(j, 1) += buf[m++]; h_v(j, 2) += buf[m++]; - if(k_pairDPDE){ + if (k_pairDPDE) { h_uCond(j) += buf[m++]; // add in the accumulated delta h_uMech(j) += buf[m++]; // add in the accumulated delta } diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index ff1b736bf0..6a1059490f 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -237,7 +237,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) gpu_aware_flag = 0; char* str; if ((str = getenv("OMPI_MCA_pml_pami_enable_cuda"))) - if((strcmp(str,"1") == 0)) { + if ((strcmp(str,"1") == 0)) { have_gpu_aware = 1; gpu_aware_flag = 1; } diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 712ea345cf..8234ceea6f 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -111,7 +111,7 @@ void NBinKokkos::bin_atoms() Kokkos::parallel_for(atom->nlocal+atom->nghost, f); deep_copy(h_resize, d_resize); - if(h_resize()) { + if (h_resize()) { atoms_per_bin += 16; k_bins = DAT::tdual_int_2d("bins", mbins, atoms_per_bin); @@ -135,7 +135,7 @@ void NBinKokkos::binatomsItem(const int &i) const atom2bin(i) = ibin; const int ac = Kokkos::atomic_fetch_add(&bincount[ibin], (int)1); - if(ac < (int)bins.extent(1)) { + if (ac < (int)bins.extent(1)) { bins(ibin, ac) = i; } else { d_resize() = 1; diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 8c9ccb5f59..276c3bee36 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -156,7 +156,7 @@ void NBinSSAKokkos::bin_atoms() // actually bin the ghost atoms { - if(ghosts_per_gbin > (int) gbins.extent(1)) { + if (ghosts_per_gbin > (int) gbins.extent(1)) { k_gbins = DAT::tdual_int_2d("gbins", 8, ghosts_per_gbin); gbins = k_gbins.view(); } diff --git a/src/KOKKOS/neighbor_kokkos.cpp b/src/KOKKOS/neighbor_kokkos.cpp index 5417386a17..5394929e73 100644 --- a/src/KOKKOS/neighbor_kokkos.cpp +++ b/src/KOKKOS/neighbor_kokkos.cpp @@ -329,7 +329,7 @@ void NeighborKokkos::operator()(TagNeighborXhold, const int &i) cons /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_ex_type_grow_kokkos(){ +void NeighborKokkos::modify_ex_type_grow_kokkos() { memoryKK->grow_kokkos(k_ex1_type,ex1_type,maxex_type,"neigh:ex1_type"); k_ex1_type.modify(); memoryKK->grow_kokkos(k_ex2_type,ex2_type,maxex_type,"neigh:ex2_type"); @@ -337,7 +337,7 @@ void NeighborKokkos::modify_ex_type_grow_kokkos(){ } /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_ex_group_grow_kokkos(){ +void NeighborKokkos::modify_ex_group_grow_kokkos() { memoryKK->grow_kokkos(k_ex1_group,ex1_group,maxex_group,"neigh:ex1_group"); k_ex1_group.modify(); memoryKK->grow_kokkos(k_ex2_group,ex2_group,maxex_group,"neigh:ex2_group"); @@ -345,13 +345,13 @@ void NeighborKokkos::modify_ex_group_grow_kokkos(){ } /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_mol_group_grow_kokkos(){ +void NeighborKokkos::modify_mol_group_grow_kokkos() { memoryKK->grow_kokkos(k_ex_mol_group,ex_mol_group,maxex_mol,"neigh:ex_mol_group"); k_ex_mol_group.modify(); } /* ---------------------------------------------------------------------- */ -void NeighborKokkos::modify_mol_intra_grow_kokkos(){ +void NeighborKokkos::modify_mol_intra_grow_kokkos() { memoryKK->grow_kokkos(k_ex_mol_intra,ex_mol_intra,maxex_mol,"neigh:ex_mol_intra"); k_ex_mol_intra.modify(); } diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index f7e8c0e82d..564e1b0b98 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -303,7 +303,7 @@ void NPairKokkos::build(NeighList *list_) } Kokkos::deep_copy(h_scalars, d_scalars); - if(data.h_resize()) { + if (data.h_resize()) { list->maxneighs = data.h_new_maxneighs() * 1.2; list->d_neighbors = typename AT::t_neighbors_2d(Kokkos::NoInit("neighbors"), list->d_neighbors.extent(0), list->maxneighs); data.neigh_list.d_neighbors = list->d_neighbors; @@ -410,24 +410,24 @@ void NeighborKokkosExecute:: = d_stencil; // loop over all bins in neighborhood (includes ibin) - if(HalfNeigh) - for(int m = 0; m < c_bincount(ibin); m++) { + if (HalfNeigh) + for (int m = 0; m < c_bincount(ibin); m++) { const int j = c_bins(ibin,m); const int jtype = type(j); //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using HalfNeighborlists - if((j == i) || (HalfNeigh && !Newton && (j < i)) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -436,38 +436,38 @@ void NeighborKokkosExecute:: /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::t_int_1d_const_um =Kokkos::subview(bins,jbin,ALL); - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); const int jtype = type(j); - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -477,14 +477,14 @@ void NeighborKokkosExecute:: } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = NeighborKokkosExecute::find_special(i,j); @@ -493,19 +493,19 @@ void NeighborKokkosExecute:: /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n:: neigh_list.d_numneigh(i) = n; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } neigh_list.d_ilist(i) = i; @@ -562,7 +562,7 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli const int ibin = dev.league_rank()*BINS_PER_TEAM+MY_BIN; - if(ibin >= mbins) return; + if (ibin >= mbins) return; X_FLOAT* other_x = sharedmem; other_x = other_x + 5*atoms_per_bin*MY_BIN; @@ -570,7 +570,7 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli int bincount_current = c_bincount[ibin]; - for(int kk = 0; kk < TEAMS_PER_BIN; kk++) { + for (int kk = 0; kk < TEAMS_PER_BIN; kk++) { const int MY_II = dev.team_rank()%atoms_per_bin+kk*dev.team_size(); const int i = MY_II < bincount_current ? c_bins(ibin, MY_II) : -1; /* if necessary, goto next page and add pages */ @@ -583,7 +583,7 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli int itype; const AtomNeighbors neighbors_i = neigh_list.get_neighbors((i>=0&&i= 0) { + if (i >= 0) { xtmp = x(i, 0); ytmp = x(i, 1); ztmp = x(i, 2); @@ -596,23 +596,23 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli other_id[MY_II] = i; int test = (__syncthreads_count(i >= 0 && i <= nlocal) == 0); - if(test) return; + if (test) return; - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 4 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using halfneighborlists - if((j == i) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(Tri) { + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -622,13 +622,13 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { int which = 0; if (!moltemplate) @@ -638,19 +638,19 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_ItemCuda(typename Kokkos::TeamPoli const typename ArrayTypes::t_int_1d_const_um stencil = d_stencil; - for(int k = 0; k < nstencil; k++) { + for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - if(ibin == jbin) continue; + if (ibin == jbin) continue; bincount_current = c_bincount[jbin]; int j = MY_II < bincount_current ? c_bins(jbin, MY_II) : -1; - if(j >= 0) { + if (j >= 0) { other_x[MY_II] = x(j, 0); other_x[MY_II + atoms_per_bin] = x(j, 1); other_x[MY_II + 2 * atoms_per_bin] = x(j, 2); @@ -680,16 +680,16 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli __syncthreads(); - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 8 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { const int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; //if(HalfNeigh && (j < i)) continue; - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -699,14 +699,14 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; const X_FLOAT rsq = delx * delx + dely * dely + delz * delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { int which = 0; if (!moltemplate) @@ -716,19 +716,19 @@ void NeighborKokkosExecute::build_ItemCuda(typename Kokkos::TeamPoli /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_ItemCuda(typename Kokkos::TeamPoli __syncthreads(); } - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { neigh_list.d_numneigh(i) = n; neigh_list.d_ilist(i) = i; } - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } } } @@ -787,14 +787,14 @@ void NeighborKokkosExecute:: const int ibin = c_atom2bin(i); for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); if (HalfNeigh && j <= i) continue; else if (j == i) continue; const int jtype = type[j]; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j,0); const X_FLOAT dely = ytmp - x(j,1); @@ -810,19 +810,19 @@ void NeighborKokkosExecute:: /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n:: ybin2 < 0 || ybin2 >= mbiny || zbin2 < 0 || zbin2 >= mbinz) continue; const int jbin = ibin + stencil[k]; - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); if (HalfNeigh && j <= i) continue; else if (j == i) continue; const int jtype = type[j]; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j,0); const X_FLOAT dely = ytmp - x(j,1); @@ -858,7 +858,7 @@ void NeighborKokkosExecute:: const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq <= cutneighsq(itype,jtype)) { - if(n:: neigh_list.d_numneigh(i) = n; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } neigh_list.d_ilist(i) = i; } @@ -902,18 +902,18 @@ void NeighborKokkosExecute:: const int mask_history = 3 << SBBITS; // loop over all bins in neighborhood (includes ibin) - if(HalfNeigh) - for(int m = 0; m < c_bincount(ibin); m++) { + if (HalfNeigh) + for (int m = 0; m < c_bincount(ibin); m++) { const int j = c_bins(ibin,m); const int jtype = type(j); //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using HalfNeighborlists - if((j == i) || (HalfNeigh && !Newton && (j < i)) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); @@ -922,29 +922,29 @@ void NeighborKokkosExecute:: const X_FLOAT radsum = radi + radius(j); const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n::t_int_1d_const_um =Kokkos::subview(bins,jbin,ALL); - for(int m = 0; m < c_bincount(jbin); m++) { + for (int m = 0; m < c_bincount(jbin); m++) { const int j = c_bins(jbin,m); const int jtype = type(j); - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -954,7 +954,7 @@ void NeighborKokkosExecute:: } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); @@ -963,9 +963,9 @@ void NeighborKokkosExecute:: const X_FLOAT radsum = radi + radius(j); const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n:: neigh_list.d_numneigh(i) = n; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } neigh_list.d_ilist(i) = i; @@ -1005,7 +1005,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const int ibin = dev.league_rank()*BINS_PER_TEAM+MY_BIN; - if(ibin >= mbins) return; + if (ibin >= mbins) return; X_FLOAT* other_x = sharedmem; other_x = other_x + 6*atoms_per_bin*MY_BIN; @@ -1013,7 +1013,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team int bincount_current = c_bincount[ibin]; - for(int kk = 0; kk < TEAMS_PER_BIN; kk++) { + for (int kk = 0; kk < TEAMS_PER_BIN; kk++) { const int MY_II = dev.team_rank()%atoms_per_bin+kk*dev.team_size(); const int i = MY_II < bincount_current ? c_bins(ibin, MY_II) : -1; /* if necessary, goto next page and add pages */ @@ -1028,7 +1028,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const AtomNeighbors neighbors_i = neigh_list.get_neighbors((i>=0&&i= 0) { + if (i >= 0) { xtmp = x(i, 0); ytmp = x(i, 1); ztmp = x(i, 2); @@ -1043,23 +1043,23 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team other_id[MY_II] = i; int test = (__syncthreads_count(i >= 0 && i <= nlocal) == 0); - if(test) return; + if (test) return; - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 4 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; //for same bin as atom i skip j if i==j and skip atoms "below and to the left" if using halfneighborlists - if((j == i) || + if ((j == i) || (HalfNeigh && !Newton && (j < i)) || (HalfNeigh && Newton && ((j < i) || ((j >= nlocal) && ((x(j, 2) < ztmp) || (x(j, 2) == ztmp && x(j, 1) < ytmp) || (x(j, 2) == ztmp && x(j, 1) == ytmp && x(j, 0) < xtmp))))) ) continue; - if(Tri) { + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -1069,7 +1069,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; const X_FLOAT delz = ztmp - other_x[m + 2 * atoms_per_bin]; @@ -1077,8 +1077,8 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const X_FLOAT radsum = radi + other_x[m + 4 * atoms_per_bin]; const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n::build_ItemSizeCuda(typename Kokkos::Team const typename ArrayTypes::t_int_1d_const_um stencil = d_stencil; - for(int k = 0; k < nstencil; k++) { + for (int k = 0; k < nstencil; k++) { const int jbin = ibin + stencil[k]; - if(ibin == jbin) continue; + if (ibin == jbin) continue; bincount_current = c_bincount[jbin]; int j = MY_II < bincount_current ? c_bins(jbin, MY_II) : -1; - if(j >= 0) { + if (j >= 0) { other_x[MY_II] = x(j, 0); other_x[MY_II + atoms_per_bin] = x(j, 1); other_x[MY_II + 2 * atoms_per_bin] = x(j, 2); @@ -1110,16 +1110,16 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team __syncthreads(); - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { #pragma unroll 8 - for(int m = 0; m < bincount_current; m++) { + for (int m = 0; m < bincount_current; m++) { const int j = other_id[m]; const int jtype = other_x[m + 3 * atoms_per_bin]; - if(HalfNeigh && (j < i)) continue; - if(HalfNeigh && !Newton && (j < i)) continue; - if(!HalfNeigh && j==i) continue; - if(Tri) { + if (HalfNeigh && (j < i)) continue; + if (HalfNeigh && !Newton && (j < i)) continue; + if (!HalfNeigh && j==i) continue; + if (Tri) { if (x(j,2) < ztmp) continue; if (x(j,2) == ztmp) { if (x(j,1) < ytmp) continue; @@ -1129,7 +1129,7 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team } } } - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - other_x[m]; const X_FLOAT dely = ytmp - other_x[m + atoms_per_bin]; @@ -1138,8 +1138,8 @@ void NeighborKokkosExecute::build_ItemSizeCuda(typename Kokkos::Team const X_FLOAT radsum = radi + other_x[m + 4 * atoms_per_bin]; const X_FLOAT cutsq = (radsum + skin) * (radsum + skin); - if(rsq <= cutsq) { - if(n::build_ItemSizeCuda(typename Kokkos::Team __syncthreads(); } - if(i >= 0 && i < nlocal) { + if (i >= 0 && i < nlocal) { neigh_list.d_numneigh(i) = n; neigh_list.d_ilist(i) = i; } - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop + if (n > new_maxneighs()) new_maxneighs() = n; // avoid atomics, safe because in while loop } } } diff --git a/src/KOKKOS/npair_ssa_kokkos.cpp b/src/KOKKOS/npair_ssa_kokkos.cpp index 742cfe515d..a3608fd35a 100644 --- a/src/KOKKOS/npair_ssa_kokkos.cpp +++ b/src/KOKKOS/npair_ssa_kokkos.cpp @@ -489,7 +489,7 @@ fprintf(stdout, "tota%03d total %3d could use %6d inums, expected %6d inums. inu deep_copy(data.h_resize, data.resize); - if(data.h_resize()) { + if (data.h_resize()) { deep_copy(data.h_new_maxneighs, data.new_maxneighs); list->maxneighs = data.h_new_maxneighs() * 1.2; list->d_neighbors = typename ArrayTypes::t_neighbors_2d("neighbors", list->d_neighbors.extent(0), list->maxneighs); @@ -571,13 +571,13 @@ void NPairSSAKokkosExecute::build_locals_onePhase(const bool firstTr for (; jl < c_bincount(jbin); ++jl) { const int j = c_bins(jbin, jl); const int jtype = type(j); - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -586,19 +586,19 @@ void NPairSSAKokkosExecute::build_locals_onePhase(const bool firstTr /* onemols[imol]->nspecial[iatom], */ /* tag[j]-tagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_locals_onePhase(const bool firstTr if (n > 0) { neigh_list.d_numneigh(inum) = n; neigh_list.d_ilist(inum++) = i; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); + if (n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); } } } @@ -699,13 +699,13 @@ void NPairSSAKokkosExecute::build_ghosts_onePhase(int workPhase) con for (int jl = 0; jl < c_bincount(jbin); ++jl) { const int j = c_bins(jbin, jl); const int jtype = type(j); - if(exclude && exclusion(i,j,itype,jtype)) continue; + if (exclude && exclusion(i,j,itype,jtype)) continue; const X_FLOAT delx = xtmp - x(j, 0); const X_FLOAT dely = ytmp - x(j, 1); const X_FLOAT delz = ztmp - x(j, 2); const X_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq <= cutneighsq(itype,jtype)) { + if (rsq <= cutneighsq(itype,jtype)) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(j,i); @@ -714,19 +714,19 @@ void NPairSSAKokkosExecute::build_ghosts_onePhase(int workPhase) con /* onemols[jmol]->nspecial[jatom], */ /* tag[i]-jtagprev); */ /* else which = 0; */ - if (which == 0){ - if(n 0) { - if(n::build_ghosts_onePhase(int workPhase) con if (n > 0) { neigh_list.d_numneigh(gNdx) = n; neigh_list.d_ilist(gNdx++) = i; - if(n > neigh_list.maxneighs) { + if (n > neigh_list.maxneighs) { resize() = 1; - if(n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); + if (n > new_maxneighs()) Kokkos::atomic_fetch_max(&new_maxneighs(),n); } } } diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index d3b00329d8..eb7b9ffd6e 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -335,7 +335,7 @@ double PairBuckCoulCutKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -228,7 +228,7 @@ F_FLOAT PairBuckCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -267,7 +267,7 @@ F_FLOAT PairBuckCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -335,7 +335,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -345,7 +345,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -357,7 +357,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -368,7 +368,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -380,7 +380,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -391,7 +391,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -403,7 +403,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -414,7 +414,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -497,7 +497,7 @@ double PairBuckCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).offset = offset[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -190,7 +190,7 @@ F_FLOAT PairCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -229,7 +229,7 @@ F_FLOAT PairCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -293,7 +293,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -303,7 +303,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -315,7 +315,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -326,7 +326,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -338,7 +338,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -349,7 +349,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -361,7 +361,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -372,7 +372,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -447,7 +447,7 @@ double PairCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) if (splitFDT_flag) { if (!a0_is_zero) { - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == HALF) { if (newton_pair) { if (evflag) Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); @@ -287,7 +287,7 @@ void PairDPDfdtEnergyKokkos::compute(int eflag_in, int vflag_in) // loop over neighbors of my atoms - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == HALF) { if (newton_pair) { if (evflag) Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); @@ -671,7 +671,7 @@ double PairDPDfdtEnergyKokkos::init_one(int i, int j) k_params.h_view(i,j).kappa = kappa[i][j]; k_params.h_view(i,j).alpha = alpha[i][j]; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::operator()(TagPairEAMAlloyKernelC (p); @@ -985,7 +985,7 @@ void PairEAMAlloyKokkos::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 54397cea51..56a351a1ad 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -725,7 +725,7 @@ void PairEAMFSKokkos::operator()(TagPairEAMFSKernelC (p); @@ -985,7 +985,7 @@ void PairEAMFSKokkos::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/fs", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index bcbddea28d..e5c9eada71 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -721,7 +721,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelC (p); diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index bc60bab85c..855d2b259a 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -582,8 +582,8 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -599,7 +599,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxCompute()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -694,7 +694,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxCompute::operator()(TagPairExp6rxComputeNoAtomics()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -973,7 +973,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics::operator()(TagPairExp6rxComputeNoAtomics::operator()(TagPairExp6rxComputeNoAtomics()() = 1; // A3. Compute some convenient quantities for evaluating the force @@ -1068,7 +1068,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics::operator()(TagPairExp6rxComputeNoAtomics::vectorized_operator(const int &ii, EV_FLOAT& double fpairOldEXP6_12 = 0.0; double fpairOldEXP6_21 = 0.0; - if(rmOld12_ij!=0.0 && rmOld21_ij!=0.0) + if (rmOld12_ij!=0.0 && rmOld21_ij!=0.0) { hasError |= (alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0); @@ -1387,7 +1387,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& double durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); double rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1427,7 +1427,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1465,7 +1465,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& evdwlOld_j[jlane] = evdwlOld; } - if(rm12_ij!=0.0 && rm21_ij!=0.0) + if (rm12_ij!=0.0 && rm21_ij!=0.0) { hasError |= (alpha21_ij == 6.0 || alpha12_ij == 6.0); @@ -1483,7 +1483,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& double durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); double rin1 = shift*rm12_ij*func_rin(alpha12_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1515,7 +1515,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); - if(r < rin1){ + if (r < rin1) { const double rin6 = rin1*rin1*rin1*rin1*rin1*rin1; const double rin6inv = 1.0/rin6; @@ -1807,7 +1807,7 @@ void PairExp6rxKokkos::read_file(char *file) n = strlen(words[1]) + 1; params[nparams].potential = new char[n]; strcpy(params[nparams].potential,words[1]); - if (strcmp(params[nparams].potential,"exp6") == 0){ + if (strcmp(params[nparams].potential,"exp6") == 0) { params[nparams].alpha = atof(words[2]); params[nparams].epsilon = atof(words[3]); params[nparams].rm = atof(words[4]); @@ -1890,7 +1890,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nTotalold = 0.0; // Compute the total number of molecules in the old and new CG particle as well as the total number of molecules in the fluid portion of the old and new CG particle - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += dvector(ispecies,id); nTotalold += dvector(ispecies+nspecies,id); @@ -1903,7 +1903,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nMoleculesOFA += dvector(ispecies,id); } } - if(nTotal < MY_EPSILON || nTotalold < MY_EPSILON) + if (nTotal < MY_EPSILON || nTotalold < MY_EPSILON) k_error_flag.template view()() = 1; // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) @@ -1915,7 +1915,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub if (iparam < 0 || d_params[iparam].potentialType != exp6PotentialType ) continue; // If Site1 matches a pure species, then grab the parameters - if (isite1 == d_params[iparam].ispecies){ + if (isite1 == d_params[iparam].ispecies) { rm1_old = d_params[iparam].rm; rm1 = d_params[iparam].rm; epsilon1_old = d_params[iparam].epsilon; @@ -1931,7 +1931,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub } // If Site2 matches a pure species, then grab the parameters - if (isite2 == d_params[iparam].ispecies){ + if (isite2 == d_params[iparam].ispecies) { rm2_old = d_params[iparam].rm; rm2 = d_params[iparam].rm; epsilon2_old = d_params[iparam].epsilon; @@ -1952,9 +1952,9 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub rmi = d_params[iparam].rm; epsiloni = d_params[iparam].epsilon; alphai = d_params[iparam].alpha; - if(nMoleculesOFA::getMixingWeights(int id,double &epsilon1,doub rmj = d_params[jparam].rm; epsilonj = d_params[jparam].epsilon; alphaj = d_params[jparam].alpha; - if(nMoleculesOFA::getMixingWeights(int id,double &epsilon1,doub epsilonij = sqrt(epsiloni*epsilonj); alphaij = sqrt(alphai*alphaj); - if(fractionOFAold > 0.0){ + if (fractionOFAold > 0.0) { rm3_old += xMolei_old*xMolej_old*rm3ij; epsilon_old += xMolei_old*xMolej_old*rm3ij*epsilonij; alpha_old += xMolei_old*xMolej_old*rm3ij*epsilonij*alphaij; } - if(fractionOFA > 0.0){ + if (fractionOFA > 0.0) { rm3 += xMolei*xMolej*rm3ij; epsilon += xMolei*xMolej*rm3ij*epsilonij; alpha += xMolei*xMolej*rm3ij*epsilonij*alphaij; @@ -1988,9 +1988,9 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub } } - if (isOneFluidApprox(isite1)){ + if (isOneFluidApprox(isite1)) { rm1 = cbrt(rm3); - if(rm1 < MY_EPSILON) { + if (rm1 < MY_EPSILON) { rm1 = 0.0; epsilon1 = 0.0; alpha1 = 0.0; @@ -2002,7 +2002,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub fraction1 = fractionOFA; rm1_old = cbrt(rm3_old); - if(rm1_old < MY_EPSILON) { + if (rm1_old < MY_EPSILON) { rm1_old = 0.0; epsilon1_old = 0.0; alpha1_old = 0.0; @@ -2013,18 +2013,18 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nMoleculesOld1 = 1.0-(nTotalold-nMoleculesOFAold); fractionOld1 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon1,rm1); exponentScaling(nMoleculesOFAold,epsilon1_old,rm1_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha1,epsilon1,rm1); polynomialScaling(nMoleculesOFAold,alpha1_old,epsilon1_old,rm1_old); } } - if (isOneFluidApprox(isite2)){ + if (isOneFluidApprox(isite2)) { rm2 = cbrt(rm3); - if(rm2 < MY_EPSILON) { + if (rm2 < MY_EPSILON) { rm2 = 0.0; epsilon2 = 0.0; alpha2 = 0.0; @@ -2036,7 +2036,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub fraction2 = fractionOFA; rm2_old = cbrt(rm3_old); - if(rm2_old < MY_EPSILON) { + if (rm2_old < MY_EPSILON) { rm2_old = 0.0; epsilon2_old = 0.0; alpha2_old = 0.0; @@ -2047,46 +2047,46 @@ void PairExp6rxKokkos::getMixingWeights(int id,double &epsilon1,doub nMoleculesOld2 = 1.0-(nTotalold-nMoleculesOFAold); fractionOld2 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon2,rm2); exponentScaling(nMoleculesOFAold,epsilon2_old,rm2_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha2,epsilon2,rm2); polynomialScaling(nMoleculesOFAold,alpha2_old,epsilon2_old,rm2_old); } } // Check that no fractions are less than zero - if(fraction1 < 0.0 || nMolecules1 < 0.0){ - if(fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON){ + if (fraction1 < 0.0 || nMolecules1 < 0.0) { + if (fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMolecules1 = 0.0; fraction1 = 0.0; } - if(fraction2 < 0.0 || nMolecules2 < 0.0){ - if(fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON){ + if (fraction2 < 0.0 || nMolecules2 < 0.0) { + if (fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMolecules2 = 0.0; fraction2 = 0.0; } - if(fractionOld1 < 0.0 || nMoleculesOld1 < 0.0){ - if(fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON){ + if (fractionOld1 < 0.0 || nMoleculesOld1 < 0.0) { + if (fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMoleculesOld1 = 0.0; fractionOld1 = 0.0; } - if(fractionOld2 < 0.0 || nMoleculesOld2 < 0.0){ - if(fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON){ + if (fractionOld2 < 0.0 || nMoleculesOld2 < 0.0) { + if (fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON) { k_error_flag.template view()() = 2; } nMoleculesOld2 = 0.0; fractionOld2 = 0.0; } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -2298,9 +2298,9 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if(nMoleculesOFA[id]::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { double xMolej, xMolej_old; - if(nMoleculesOFA[id] 0.0){ + if (fractionOFAold[id] > 0.0) { rm3_old[id] += xMolei_old[id]*xMolej_old*rm3ij; epsilon_old[id] += xMolei_old[id]*xMolej_old*rm3ij*epsilonij; alpha_old[id] += xMolei_old[id]*xMolej_old*rm3ij*epsilonij*alphaij; } - if(fractionOFA[id] > 0.0){ + if (fractionOFA[id] > 0.0) { rm3[id] += xMolei[id]*xMolej*rm3ij; epsilon[id] += xMolei[id]*xMolej*rm3ij*epsilonij; alpha[id] += xMolei[id]*xMolej*rm3ij*epsilonij*alphaij; @@ -2352,7 +2352,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { rm1[id] = cbrt(rm3[id]); - if(rm1[id] < MY_EPSILON) { + if (rm1[id] < MY_EPSILON) { rm1[id] = 0.0; epsilon1[id] = 0.0; alpha1[id] = 0.0; @@ -2364,7 +2364,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fraction1[id] = fractionOFA[id]; rm1_old[id] = cbrt(rm3_old[id]); - if(rm1_old[id] < MY_EPSILON) { + if (rm1_old[id] < MY_EPSILON) { rm1_old[id] = 0.0; epsilon1_old[id] = 0.0; alpha1_old[id] = 0.0; @@ -2376,7 +2376,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fractionOld1[id] = fractionOFAold[id]; } - if(scalingFlag == EXPONENT) { + if (scalingFlag == EXPONENT) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2386,7 +2386,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int exponentScaling(nMoleculesOFAold[id],epsilon1_old[id],rm1_old[id]); } } - else if(scalingFlag == POLYNOMIAL){ + else if (scalingFlag == POLYNOMIAL) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2406,7 +2406,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { rm2[id] = cbrt(rm3[id]); - if(rm2[id] < MY_EPSILON) { + if (rm2[id] < MY_EPSILON) { rm2[id] = 0.0; epsilon2[id] = 0.0; alpha2[id] = 0.0; @@ -2418,7 +2418,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fraction2[id] = fractionOFA[id]; rm2_old[id] = cbrt(rm3_old[id]); - if(rm2_old[id] < MY_EPSILON) { + if (rm2_old[id] < MY_EPSILON) { rm2_old[id] = 0.0; epsilon2_old[id] = 0.0; alpha2_old[id] = 0.0; @@ -2430,7 +2430,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int fractionOld2[id] = fractionOFAold[id]; } - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2440,7 +2440,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int exponentScaling(nMoleculesOFAold[id],epsilon2_old[id],rm2_old[id]); } } - else if(scalingFlag == POLYNOMIAL){ + else if (scalingFlag == POLYNOMIAL) { #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif @@ -2458,36 +2458,36 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if(fraction1[id] < 0.0 || nMolecules1[id] < 0.0){ - if(fraction1[id] < -MY_EPSILON || nMolecules1[id] < -MY_EPSILON){ + if (fraction1[id] < 0.0 || nMolecules1[id] < 0.0) { + if (fraction1[id] < -MY_EPSILON || nMolecules1[id] < -MY_EPSILON) { errorFlag2 = 2; } nMolecules1[id] = 0.0; fraction1[id] = 0.0; } - if(fraction2[id] < 0.0 || nMolecules2[id] < 0.0){ - if(fraction2[id] < -MY_EPSILON || nMolecules2[id] < -MY_EPSILON){ + if (fraction2[id] < 0.0 || nMolecules2[id] < 0.0) { + if (fraction2[id] < -MY_EPSILON || nMolecules2[id] < -MY_EPSILON) { errorFlag2 = 2; } nMolecules2[id] = 0.0; fraction2[id] = 0.0; } - if(fractionOld1[id] < 0.0 || nMoleculesOld1[id] < 0.0){ - if(fractionOld1[id] < -MY_EPSILON || nMoleculesOld1[id] < -MY_EPSILON){ + if (fractionOld1[id] < 0.0 || nMoleculesOld1[id] < 0.0) { + if (fractionOld1[id] < -MY_EPSILON || nMoleculesOld1[id] < -MY_EPSILON) { errorFlag2 = 2; } nMoleculesOld1[id] = 0.0; fractionOld1[id] = 0.0; } - if(fractionOld2[id] < 0.0 || nMoleculesOld2[id] < 0.0){ - if(fractionOld2[id] < -MY_EPSILON || nMoleculesOld2[id] < -MY_EPSILON){ + if (fractionOld2[id] < 0.0 || nMoleculesOld2[id] < 0.0) { + if (fractionOld2[id] < -MY_EPSILON || nMoleculesOld2[id] < -MY_EPSILON) { errorFlag2 = 2; } nMoleculesOld2[id] = 0.0; fractionOld2[id] = 0.0; } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old[id] = fractionOld1[id]; mixWtSite1[id] = fraction1[id]; mixWtSite2old[id] = fractionOld2[id]; @@ -2518,17 +2518,17 @@ void PairExp6rxKokkos::exponentScaling(double phi, double &epsilon, { double powfuch; - if(exponentEpsilon < 0.0){ + if (exponentEpsilon < 0.0) { powfuch = pow(phi,-exponentEpsilon); - if(powfuch::expValue(double value) const { double returnValue; - if(value < DBL_MIN_EXP) returnValue = 0.0; + if (value < DBL_MIN_EXP) returnValue = 0.0; else returnValue = exp(value); return returnValue; diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index 208fb8165b..577fac7437 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -151,7 +151,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::compute(int eflag_in, int copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -338,7 +338,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -348,7 +348,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -360,7 +360,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -371,7 +371,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -383,7 +383,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -394,7 +394,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -406,7 +406,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -417,7 +417,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -499,7 +499,7 @@ double PairLJCharmmCoulCharmmImplicitKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_i copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -339,7 +339,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -349,7 +349,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -361,7 +361,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -372,7 +372,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -384,7 +384,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -395,7 +395,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -407,7 +407,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -418,7 +418,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -500,7 +500,7 @@ double PairLJCharmmCoulCharmmKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -255,7 +255,7 @@ F_FLOAT PairLJCharmmCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -292,7 +292,7 @@ KOKKOS_INLINE_FUNCTION F_FLOAT PairLJCharmmCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -360,7 +360,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -370,7 +370,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -382,7 +382,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -393,7 +393,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -405,7 +405,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -416,7 +416,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -428,7 +428,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -439,7 +439,7 @@ void PairLJCharmmCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -508,7 +508,7 @@ double PairLJCharmmCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::PairLJClass2CoulLongKokkos(LAMMPS *lmp): template PairLJClass2CoulLongKokkos::~PairLJClass2CoulLongKokkos() { - if (!copymode){ + if (!copymode) { memoryKK->destroy_kokkos(k_cutsq, cutsq); memoryKK->destroy_kokkos(k_cut_ljsq, cut_ljsq); } @@ -137,7 +137,7 @@ void PairLJClass2CoulLongKokkos::compute(int eflag_in, int vflag_in) copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -206,7 +206,7 @@ F_FLOAT PairLJClass2CoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -265,7 +265,7 @@ F_FLOAT PairLJClass2CoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -330,7 +330,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -340,7 +340,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -352,7 +352,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -363,7 +363,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -375,7 +375,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -386,7 +386,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -398,7 +398,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -409,7 +409,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -491,7 +491,7 @@ double PairLJClass2CoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).offset = offset[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::PairLJCutCoulCutKokkos(LAMMPS *lmp):PairLJCu template PairLJCutCoulCutKokkos::~PairLJCutCoulCutKokkos() { - if (allocated){ + if (allocated) { memoryKK->destroy_kokkos(k_cutsq, cutsq); memoryKK->destroy_kokkos(k_cut_ljsq, cut_ljsq); memoryKK->destroy_kokkos(k_cut_coulsq, cut_coulsq); @@ -327,7 +327,7 @@ double PairLJCutCoulCutKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::~PairLJCutCoulLongKokkos() memoryKK->destroy_kokkos(k_vatom,vatom); eatom = nullptr; vatom = nullptr; - if (allocated){ + if (allocated) { memoryKK->destroy_kokkos(k_cutsq, cutsq); memoryKK->destroy_kokkos(k_cut_ljsq, cut_ljsq); } @@ -142,7 +142,7 @@ void PairLJCutCoulLongKokkos::compute(int eflag_in, int vflag_in) // loop over neighbors of my atoms EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -206,7 +206,7 @@ KOKKOS_INLINE_FUNCTION F_FLOAT PairLJCutCoulLongKokkos:: compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -263,7 +263,7 @@ F_FLOAT PairLJCutCoulLongKokkos:: compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { - if(Specialisation::DoTable && rsq > tabinnersq) { + if (Specialisation::DoTable && rsq > tabinnersq) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; @@ -328,7 +328,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -338,7 +338,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -350,7 +350,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -361,7 +361,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -373,7 +373,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -384,7 +384,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -396,7 +396,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -407,7 +407,7 @@ void PairLJCutCoulLongKokkos::init_tables(double cut_coul, double *c host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -489,7 +489,7 @@ double PairLJCutCoulLongKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).offset = offset[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).shift = shift[i][j]; k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag copymode = 1; EV_FLOAT ev; - if(ncoultablebits) + if (ncoultablebits) ev = pair_compute,CoulLongTable<1> > (this,(NeighListKokkos*)list); else @@ -324,7 +324,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = rtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -334,7 +334,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do { host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = drtable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -346,7 +346,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); // Copy ftable and dftable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -357,7 +357,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dftable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -369,7 +369,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); // Copy ctable and dctable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = ctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -380,7 +380,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = dctable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -392,7 +392,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); // Copy etable and detable - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = etable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -403,7 +403,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); - for(int i = 0; i < ntable; i++) { + for (int i = 0; i < ntable; i++) { h_table(i) = detable[i]; } Kokkos::deep_copy(d_table,h_table); @@ -489,7 +489,7 @@ double PairLJGromacsCoulGromacsKokkos::init_one(int i, int j) k_params.h_view(i,j).cut_coulsq = cut_coulsqm; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cut_inner = cut_inner[i][j]; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(i,j).lj_type = lj_type[i][j]; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::compute(int eflag_in, int vflag_in) if (tabstyle == LOOKUP) compute_style(eflag_in,vflag_in); - else if(tabstyle == LINEAR) + else if (tabstyle == LINEAR) compute_style(eflag_in,vflag_in); copymode = 0; @@ -321,8 +321,8 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXComputeinnersq || rho[j]*rho[j] < tb->innersq){ - if (rho[i]*rho[i] < d_table_const.innersq(tidx) || rho[j]*rho[j] < d_table_const.innersq(tidx)){ + //if (rho[i]*rho[i] < tb->innersq || rho[j]*rho[j] < tb->innersq) { + if (rho[i]*rho[i] < d_table_const.innersq(tidx) || rho[j]*rho[j] < d_table_const.innersq(tidx)) { k_error_flag.template view()() = 1; } @@ -331,7 +331,7 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute (((rho[i]*rho[i]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); //jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); jtable = static_cast (((rho[j]*rho[j]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { k_error_flag.template view()() = 2; } //A_i = tb->f[itable]; @@ -349,22 +349,22 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute ((rho[i]*rho[i] - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); //jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); jtable = static_cast ((rho[j]*rho[j] - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { k_error_flag.template view()() = 2; } - if(itable<0) itable=0; - if(itable>=tlm1) itable=tlm1; - if(jtable<0) jtable=0; - if(jtable>=tlm1)jtable=tlm1; + if (itable<0) itable=0; + if (itable>=tlm1) itable=tlm1; + if (jtable<0) jtable=0; + if (jtable>=tlm1)jtable=tlm1; //fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); fraction_i = (((rho[i]*rho[i]) - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx)); //fraction_j = (((rho[j]*rho[j]) - tb->rsq[jtable]) * tb->invdelta); fraction_j = (((rho[j]*rho[j]) - d_table_const.rsq(tidx,jtable)) * d_table_const.invdelta(tidx)); - if(itable==0) fraction_i=0.0; - if(itable==tlm1) fraction_i=0.0; - if(jtable==0) fraction_j=0.0; - if(jtable==tlm1) fraction_j=0.0; + if (itable==0) fraction_i=0.0; + if (itable==tlm1) fraction_i=0.0; + if (jtable==0) fraction_j=0.0; + if (jtable==tlm1) fraction_j=0.0; //A_i = tb->f[itable] + fraction_i*tb->df[itable]; A_i = d_table_const.f(tidx,itable) + fraction_i*d_table_const.df(tidx,itable); @@ -405,10 +405,10 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute= tlm1){ + if (itable >= tlm1) { k_error_flag.template view()() = 2; } - if(itable==0) fraction_i=0.0; + if (itable==0) fraction_i=0.0; //else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); else fraction_i = (((rho[i]*rho[i]) - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx)); //evdwl = tb->e[itable] + fraction_i*tb->de[itable]; @@ -547,7 +547,7 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXComputeLoca const double pi = MathConst::MY_PI; - for (int jj = 0; jj < jnum; jj++){ + for (int jj = 0; jj < jnum; jj++) { const int j = (d_neighbors(i,jj) & NEIGHMASK); const int jtype = type[j]; @@ -598,44 +598,44 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi nTotal = 0.0; nTotalOld = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += dvector(ispecies,id); nTotalOld += dvector(ispecies+nspecies,id); } - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = dvector(isite1+nspecies,id); nMolecules1 = dvector(isite1,id); fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = dvector(isite2+nspecies,id); nMolecules2 = dvector(isite2,id); fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += dvector(ispecies+nspecies,id); nMoleculesOFA += dvector(ispecies,id); fractionOFAold += dvector(ispecies+nspecies,id) / nTotalOld; fractionOFA += dvector(ispecies,id) / nTotal; } - if (isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if (isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -643,7 +643,7 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -862,12 +862,12 @@ void PairMultiLucyRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->innersq,h_table->innersq,ntables,"Table::innersq"); memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tlm1,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tlm1,"Table::f"); } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -875,21 +875,21 @@ void PairMultiLucyRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->df,h_table->df,ntables,tlm1,"Table::df"); } - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->innersq[i] = tb->innersq; h_table->invdelta[i] = tb->invdelta; - for(int j = 0; j < (int)h_table->rsq.extent(1); j++) + for (int j = 0; j < (int)h_table->rsq.extent(1); j++) h_table->rsq(i,j) = tb->rsq[j]; - for(int j = 0; j < (int)h_table->e.extent(1); j++) + for (int j = 0; j < (int)h_table->e.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; j < (int)h_table->de.extent(1); j++) + for (int j = 0; j < (int)h_table->de.extent(1); j++) h_table->de(i,j) = tb->de[j]; - for(int j = 0; j < (int)h_table->f.extent(1); j++) + for (int j = 0; j < (int)h_table->f.extent(1); j++) h_table->f(i,j) = tb->f[j]; - for(int j = 0; j < (int)h_table->df.extent(1); j++) + for (int j = 0; j < (int)h_table->df.extent(1); j++) h_table->df(i,j) = tb->df[j]; } diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index eea397dc69..5d48b429cc 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -462,12 +462,12 @@ int PairReaxCKokkos::Init_Lookup_Tables() LR = (LR_lookup_table**) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table*), "lookup:LR"); - for( i = 0; i < num_atom_types+1; ++i ) + for ( i = 0; i < num_atom_types+1; ++i ) LR[i] = (LR_lookup_table*) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table), "lookup:LR[i]"); - for( i = 1; i <= num_atom_types; ++i ) { - for( j = i; j <= num_atom_types; ++j ) { + for ( i = 1; i <= num_atom_types; ++i ) { + for ( j = i; j <= num_atom_types; ++j ) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; LR[i][j].n = control->tabulate + 2; @@ -487,7 +487,7 @@ int PairReaxCKokkos::Init_Lookup_Tables() smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for( r = 1; r <= control->tabulate; ++r ) { + for ( r = 1; r <= control->tabulate; ++r ) { LR_vdW_Coulomb(i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -546,9 +546,9 @@ void PairReaxCKokkos::Deallocate_Lookup_Tables() ntypes = atom->ntypes; - for( i = 0; i <= ntypes; ++i ) { + for ( i = 0; i <= ntypes; ++i ) { if (map[i] == -1) continue; - for( j = i; j <= ntypes; ++j ) { + for ( j = i; j <= ntypes; ++j ) { if (map[i] == -1) continue; if (LR[i][j].n) { sfree( control->error_ptr, LR[i][j].y, "LR[i,j].y" ); @@ -601,7 +601,7 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ dTap += k_tap.h_view[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -626,7 +626,7 @@ void PairReaxCKokkos::LR_vdW_Coulomb( int i, int j, double r_ij, LR_ Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); lr->e_vdW += Tap * e_core; @@ -1475,7 +1475,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsFull, const int & const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; if (rsq > cutoffsq) continue; @@ -1643,7 +1643,7 @@ void PairReaxCKokkos::operator()(PairReaxBuildListsHalf, const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; if (rsq > cutoffsq) continue; @@ -1928,10 +1928,10 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder2, const int &ii) d_C4dbopi2(i,j_index) = d_BO_pi2(i,j_index) * A3_ji; } - if(d_BO(i,j_index) < 1e-10) d_BO(i,j_index) = 0.0; - if(d_BO_s(i,j_index) < 1e-10) d_BO_s(i,j_index) = 0.0; - if(d_BO_pi(i,j_index) < 1e-10) d_BO_pi(i,j_index) = 0.0; - if(d_BO_pi2(i,j_index) < 1e-10) d_BO_pi2(i,j_index) = 0.0; + if (d_BO(i,j_index) < 1e-10) d_BO(i,j_index) = 0.0; + if (d_BO_s(i,j_index) < 1e-10) d_BO_s(i,j_index) = 0.0; + if (d_BO_pi(i,j_index) < 1e-10) d_BO_pi(i,j_index) = 0.0; + if (d_BO_pi2(i,j_index) < 1e-10) d_BO_pi2(i,j_index) = 0.0; total_bo += d_BO(i,j_index); @@ -2330,7 +2330,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) tan_ijk_i = cos_ijk / 1e-10; - else if( sin_ijk <= 0 && sin_ijk >= -1e-10 ) + else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) tan_ijk_i = -cos_ijk / 1e-10; else tan_ijk_i = cos_ijk / sin_ijk; exp_tor2_ik = exp( -p_tor2 * BOA_ik ); exp_cot2_ik = exp( -p_cot2 * SQR(BOA_ik -1.5) ); - for(int l = 0; l < 3; l++) fktmp[l] = 0.0; + for (int l = 0; l < 3; l++) fktmp[l] = 0.0; for (int ll = l_start; ll < l_end; ll++) { int l = d_bo_list[ll]; @@ -2643,7 +2643,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_jil <= 1e-10) tan_jil_i = cos_jil / 1e-10; - else if( sin_jil <= 0 && sin_jil >= -1e-10 ) + else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) tan_jil_i = -cos_jil / 1e-10; else tan_jil_i = cos_jil / sin_jil; @@ -2703,9 +2703,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) sin_ijk_rnd = 1e-10; - else if( sin_ijk <= 0 && sin_ijk >= -1e-10 ) sin_ijk_rnd = -1e-10; + else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) sin_ijk_rnd = -1e-10; if (sin_jil >= 0 && sin_jil <= 1e-10) sin_jil_rnd = 1e-10; - else if( sin_jil <= 0 && sin_jil >= -1e-10 ) sin_jil_rnd = -1e-10; + else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) sin_jil_rnd = -1e-10; // dcos_omega_di for (int d = 0; d < 3; d++) dcos_omega_dk[d] = ((htra-arg*hnra)/rik) * delik[d] - dellk[d]; @@ -2944,7 +2944,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeHydrogen::~PairTableKokkos() template void PairTableKokkos::compute(int eflag_in, int vflag_in) { - if(update_table) + if (update_table) create_kokkos_tables(); - if(tabstyle == LOOKUP) + if (tabstyle == LOOKUP) compute_style(eflag_in,vflag_in); - if(tabstyle == LINEAR) + if (tabstyle == LINEAR) compute_style(eflag_in,vflag_in); - if(tabstyle == SPLINE) + if (tabstyle == SPLINE) compute_style(eflag_in,vflag_in); - if(tabstyle == BITMAP) + if (tabstyle == BITMAP) compute_style(eflag_in,vflag_in); } @@ -117,7 +117,7 @@ void PairTableKokkos::compute_style(int eflag_in, int vflag_in) // loop over neighbors of my atoms EV_FLOAT ev; - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == FULL) { PairComputeFunctor,FULL,false,S_TableCompute > ff(this,(NeighListKokkos*) list); @@ -262,12 +262,12 @@ void PairTableKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); memoryKK->create_kokkos(d_table->deltasq6,h_table->deltasq6,ntables,"Table::deltasq6"); - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tlm1,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tlm1,"Table::f"); } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -275,7 +275,7 @@ void PairTableKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->df,h_table->df,ntables,tlm1,"Table::df"); } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -283,7 +283,7 @@ void PairTableKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->f2,h_table->f2,ntables,tablength,"Table::f2"); } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { int ntable = 1 << tablength; memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,ntable,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,ntable,"Table::e"); @@ -295,7 +295,7 @@ void PairTableKokkos::create_kokkos_tables() - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->nshiftbits[i] = tb->nshiftbits; @@ -304,21 +304,21 @@ void PairTableKokkos::create_kokkos_tables() h_table->invdelta[i] = tb->invdelta; h_table->deltasq6[i] = tb->deltasq6; - for(int j = 0; j < (int) h_table->rsq.extent(1); j++) + for (int j = 0; j < (int) h_table->rsq.extent(1); j++) h_table->rsq(i,j) = tb->rsq[j]; - for(int j = 0; j < (int) h_table->drsq.extent(1); j++) + for (int j = 0; j < (int) h_table->drsq.extent(1); j++) h_table->drsq(i,j) = tb->drsq[j]; - for(int j = 0; j < (int) h_table->e.extent(1); j++) + for (int j = 0; j < (int) h_table->e.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; j < (int) h_table->de.extent(1); j++) + for (int j = 0; j < (int) h_table->de.extent(1); j++) h_table->de(i,j) = tb->de[j]; - for(int j = 0; j < (int) h_table->f.extent(1); j++) + for (int j = 0; j < (int) h_table->f.extent(1); j++) h_table->f(i,j) = tb->f[j]; - for(int j = 0; j < (int) h_table->df.extent(1); j++) + for (int j = 0; j < (int) h_table->df.extent(1); j++) h_table->df(i,j) = tb->df[j]; - for(int j = 0; j < (int) h_table->e2.extent(1); j++) + for (int j = 0; j < (int) h_table->e2.extent(1); j++) h_table->e2(i,j) = tb->e2[j]; - for(int j = 0; j < (int) h_table->f2.extent(1); j++) + for (int j = 0; j < (int) h_table->f2.extent(1); j++) h_table->f2(i,j) = tb->f2[j]; } @@ -334,14 +334,14 @@ void PairTableKokkos::create_kokkos_tables() Kokkos::deep_copy(d_table->deltasq6,h_table->deltasq6); d_table_const.deltasq6 = d_table->deltasq6; - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { Kokkos::deep_copy(d_table->e,h_table->e); d_table_const.e = d_table->e; Kokkos::deep_copy(d_table->f,h_table->f); d_table_const.f = d_table->f; } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -354,7 +354,7 @@ void PairTableKokkos::create_kokkos_tables() d_table_const.df = d_table->df; } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -367,7 +367,7 @@ void PairTableKokkos::create_kokkos_tables() d_table_const.f2 = d_table->f2; } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -476,7 +476,7 @@ double PairTableKokkos::init_one(int i, int j) tabindex[j][i] = tabindex[i][j]; - if(i= 0); assert(id < (int)dvector.extent(1)); - for (int ispecies = 0; ispecies < nspecies; ++ispecies){ + for (int ispecies = 0; ispecies < nspecies; ++ispecies) { assert(ispecies < (int)dvector.extent(0)); nTotal += dvector(ispecies,id); assert(ispecies+nspecies < (int)dvector.extent(0)); @@ -82,39 +82,39 @@ void getMixingWeights( assert(isite1 < nspecies); assert(isite2 >= 0); assert(isite2 < nspecies); - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = dvector(isite1+nspecies,id); nMolecules1 = dvector(isite1,id); fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = dvector(isite2+nspecies,id); nMolecules2 = dvector(isite2,id); fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += dvector(ispecies+nspecies,id); nMoleculesOFA += dvector(ispecies,id); fractionOFAold += dvector(ispecies+nspecies,id)/nTotalOld; fractionOFA += dvector(ispecies,id)/nTotal; } - if(isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if(isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -122,7 +122,7 @@ void getMixingWeights( } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -183,15 +183,15 @@ PairTableRXKokkos::~PairTableRXKokkos() template void PairTableRXKokkos::compute(int eflag_in, int vflag_in) { - if(update_table) + if (update_table) create_kokkos_tables(); - if(tabstyle == LOOKUP) + if (tabstyle == LOOKUP) compute_style(eflag_in,vflag_in); - if(tabstyle == LINEAR) + if (tabstyle == LINEAR) compute_style(eflag_in,vflag_in); - if(tabstyle == SPLINE) + if (tabstyle == SPLINE) compute_style(eflag_in,vflag_in); - if(tabstyle == BITMAP) + if (tabstyle == BITMAP) compute_style(eflag_in,vflag_in); } @@ -456,7 +456,7 @@ compute_item( auto rsq = delx*delx + dely*dely + delz*delz; auto jtype = type(j); - if(rsq < (STACKPARAMS ? m_cutsq[itype][jtype] : d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS ? m_cutsq[itype][jtype] : d_cutsq(itype,jtype))) { auto mixWtSite1old_j = mixWtSite1old(j); auto mixWtSite2old_j = mixWtSite2old(j); auto mixWtSite1_j = mixWtSite1(j); @@ -669,7 +669,7 @@ void PairTableRXKokkos::compute_style(int eflag_in, int vflag_in) dynamic_cast*>(list); EV_FLOAT ev; - if(atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (atom->ntypes > MAX_TYPES_STACKPARAMS) { if (neighflag == HALFTHREAD) { if (newton_pair) { compute_all_items( @@ -805,12 +805,12 @@ void PairTableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->invdelta,h_table->invdelta,ntables,"Table::invdelta"); memoryKK->create_kokkos(d_table->deltasq6,h_table->deltasq6,ntables,"Table::deltasq6"); - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tlm1,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tlm1,"Table::f"); } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -818,7 +818,7 @@ void PairTableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->df,h_table->df,ntables,tlm1,"Table::df"); } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,tablength,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,tablength,"Table::e"); memoryKK->create_kokkos(d_table->f,h_table->f,ntables,tablength,"Table::f"); @@ -826,7 +826,7 @@ void PairTableRXKokkos::create_kokkos_tables() memoryKK->create_kokkos(d_table->f2,h_table->f2,ntables,tablength,"Table::f2"); } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { int ntable = 1 << tablength; memoryKK->create_kokkos(d_table->rsq,h_table->rsq,ntables,ntable,"Table::rsq"); memoryKK->create_kokkos(d_table->e,h_table->e,ntables,ntable,"Table::e"); @@ -838,7 +838,7 @@ void PairTableRXKokkos::create_kokkos_tables() - for(int i=0; i < ntables; i++) { + for (int i=0; i < ntables; i++) { Table* tb = &tables[i]; h_table->nshiftbits[i] = tb->nshiftbits; @@ -847,21 +847,21 @@ void PairTableRXKokkos::create_kokkos_tables() h_table->invdelta[i] = tb->invdelta; h_table->deltasq6[i] = tb->deltasq6; - for(int j = 0; j < (int)h_table->rsq.extent(1); j++) + for (int j = 0; j < (int)h_table->rsq.extent(1); j++) h_table->rsq(i,j) = tb->rsq[j]; - for(int j = 0; j < (int)h_table->drsq.extent(1); j++) + for (int j = 0; j < (int)h_table->drsq.extent(1); j++) h_table->drsq(i,j) = tb->drsq[j]; - for(int j = 0; j < (int)h_table->e.extent(1); j++) + for (int j = 0; j < (int)h_table->e.extent(1); j++) h_table->e(i,j) = tb->e[j]; - for(int j = 0; j < (int)h_table->de.extent(1); j++) + for (int j = 0; j < (int)h_table->de.extent(1); j++) h_table->de(i,j) = tb->de[j]; - for(int j = 0; j < (int)h_table->f.extent(1); j++) + for (int j = 0; j < (int)h_table->f.extent(1); j++) h_table->f(i,j) = tb->f[j]; - for(int j = 0; j < (int)h_table->df.extent(1); j++) + for (int j = 0; j < (int)h_table->df.extent(1); j++) h_table->df(i,j) = tb->df[j]; - for(int j = 0; j < (int)h_table->e2.extent(1); j++) + for (int j = 0; j < (int)h_table->e2.extent(1); j++) h_table->e2(i,j) = tb->e2[j]; - for(int j = 0; j < (int)h_table->f2.extent(1); j++) + for (int j = 0; j < (int)h_table->f2.extent(1); j++) h_table->f2(i,j) = tb->f2[j]; } @@ -877,14 +877,14 @@ void PairTableRXKokkos::create_kokkos_tables() Kokkos::deep_copy(d_table->deltasq6,h_table->deltasq6); d_table_const.deltasq6 = d_table->deltasq6; - if(tabstyle == LOOKUP) { + if (tabstyle == LOOKUP) { Kokkos::deep_copy(d_table->e,h_table->e); d_table_const.e = d_table->e; Kokkos::deep_copy(d_table->f,h_table->f); d_table_const.f = d_table->f; } - if(tabstyle == LINEAR) { + if (tabstyle == LINEAR) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -897,7 +897,7 @@ void PairTableRXKokkos::create_kokkos_tables() d_table_const.df = d_table->df; } - if(tabstyle == SPLINE) { + if (tabstyle == SPLINE) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -910,7 +910,7 @@ void PairTableRXKokkos::create_kokkos_tables() d_table_const.f2 = d_table->f2; } - if(tabstyle == BITMAP) { + if (tabstyle == BITMAP) { Kokkos::deep_copy(d_table->rsq,h_table->rsq); d_table_const.rsq = d_table->rsq; Kokkos::deep_copy(d_table->e,h_table->e); @@ -1038,14 +1038,14 @@ void PairTableRXKokkos::coeff(int narg, char **arg) bcast_table(tb); nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); int n; n = strlen(arg[4]) + 1; site1 = new char[n]; strcpy(site1,arg[4]); int ispecies; - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) @@ -1055,7 +1055,7 @@ void PairTableRXKokkos::coeff(int narg, char **arg) site2 = new char[n]; strcpy(site2,arg[5]); - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site2,"1fluid") != 0) @@ -1122,8 +1122,8 @@ void PairTableRXKokkos::coeff(int narg, char **arg) else { isite1 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site1, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site1, atom->dname[k]) == 0) { isite1 = k; break; } @@ -1137,8 +1137,8 @@ void PairTableRXKokkos::coeff(int narg, char **arg) else { isite2 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site2, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site2, atom->dname[k]) == 0) { isite2 = ispecies; break; } @@ -1162,7 +1162,7 @@ double PairTableRXKokkos::init_one(int i, int j) tabindex[j][i] = tabindex[i][j]; - if(i::init_one(int i, int j) k_params.h_view(i,j).cutsq = cutone*cutone; k_params.h_view(j,i) = k_params.h_view(i,j); - if(i::init_one(int i, int j) k_sw4.modify(); k_sw5.modify(); - if(istamp(Timer::BOND); } - if(force->kspace) { + if (force->kspace) { force->kspace->setup(); if (kspace_compute_flag) { atomKK->sync(force->kspace->execution_space,force->kspace->datamask_read); @@ -271,7 +271,7 @@ void VerletKokkos::setup_minimal(int flag) timer->stamp(Timer::BOND); } - if(force->kspace) { + if (force->kspace) { force->kspace->setup(); if (kspace_compute_flag) { atomKK->sync(force->kspace->execution_space,force->kspace->datamask_read); @@ -480,11 +480,11 @@ void VerletKokkos::run(int n) timer->stamp(Timer::PAIR); } - if(execute_on_host) { - if(pair_compute_flag && force->pair->datamask_modify!=(F_MASK | ENERGY_MASK | VIRIAL_MASK)) + if (execute_on_host) { + if (pair_compute_flag && force->pair->datamask_modify!=(F_MASK | ENERGY_MASK | VIRIAL_MASK)) Kokkos::fence(); atomKK->sync_overlapping_device(Host,~(~datamask_read_host|(F_MASK | ENERGY_MASK | VIRIAL_MASK))); - if(pair_compute_flag && force->pair->execution_space!=Host) { + if (pair_compute_flag && force->pair->execution_space!=Host) { Kokkos::deep_copy(LMPHostType(),atomKK->k_f.h_view,0.0); } } @@ -520,8 +520,8 @@ void VerletKokkos::run(int n) timer->stamp(Timer::KSPACE); } - if(execute_on_host && !std::is_same::value) { - if(f_merge_copy.extent(0)k_f.extent(0)) { + if (execute_on_host && !std::is_same::value) { + if (f_merge_copy.extent(0)k_f.extent(0)) { f_merge_copy = DAT::t_f_array("VerletKokkos::f_merge_copy",atomKK->k_f.extent(0)); } f = atomKK->k_f.d_view; diff --git a/src/KSPACE/pair_lj_long_coul_long.cpp b/src/KSPACE/pair_lj_long_coul_long.cpp index 27f30ab3a8..ffe7de067b 100644 --- a/src/KSPACE/pair_lj_long_coul_long.cpp +++ b/src/KSPACE/pair_lj_long_coul_long.cpp @@ -530,7 +530,7 @@ void PairLJLongCoulLong::compute(int eflag, int vflag) if (rsq < cut_ljsqi[typej]) { // lj if (order6) { // long-range lj - if(!ndisptablebits || rsq <= tabinnerdispsq) { // series real space + if (!ndisptablebits || rsq <= tabinnerdispsq) { // series real space double rn = r2inv*r2inv*r2inv; double x2 = g2*rsq, a2 = 1.0/x2; x2 = a2*exp(-x2)*lj4i[typej]; diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 0c412cc923..2500336e8f 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1220,7 +1220,7 @@ void PPPMDisp::compute(int eflag, int vflag) for (i = 0; i < 6; i++) virial[i] = 0.5*qscale*volume*virial_all[i]; MPI_Allreduce(virial_6,virial_all,6,MPI_DOUBLE,MPI_SUM,world); for (i = 0; i < 6; i++) virial[i] += 0.5*volume*virial_all[i]; - if (function[1]+function[2]+function[3]){ + if (function[1]+function[2]+function[3]) { double a = MY_PI*MY_PIS/(6*volume)*pow(g_ewald_6,3)*csumij; virial[0] -= a; virial[1] -= a; @@ -8155,7 +8155,7 @@ int PPPMDisp::timing_1d(int n, double &time1d) for (int i = 0; i < n; i++) { fft1->timing1d(work1,nfft_both,1); fft2->timing1d(work1,nfft_both,-1); - if (differentiation_flag != 1){ + if (differentiation_flag != 1) { fft2->timing1d(work1,nfft_both,-1); fft2->timing1d(work1,nfft_both,-1); } @@ -8173,7 +8173,7 @@ int PPPMDisp::timing_1d(int n, double &time1d) for (int i = 0; i < n; i++) { fft1_6->timing1d(work1_6,nfft_both_6,1); fft2_6->timing1d(work1_6,nfft_both_6,-1); - if (differentiation_flag != 1){ + if (differentiation_flag != 1) { fft2_6->timing1d(work1_6,nfft_both_6,-1); fft2_6->timing1d(work1_6,nfft_both_6,-1); } diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 4edc38b112..75abba2f09 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -227,8 +227,8 @@ void FixQEQComb::post_force(int /*vflag*/) } comm->forward_comm_fix(this); - if(comb) enegtot = comb->yasu_char(qf,igroup); - if(comb3) enegtot = comb3->combqeq(qf,igroup); + if (comb) enegtot = comb->yasu_char(qf,igroup); + if (comb3) enegtot = comb3->combqeq(qf,igroup); enegtot /= ngroup; enegchk = enegmax = 0.0; diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index 401c1f35ad..02af7bf308 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -543,7 +543,7 @@ void PairADP::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "adp"); try { diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index 4a0c2a874d..44042bd133 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -3489,7 +3489,7 @@ void PairAIREBO::read_file(char *filename) // global parameters current_section = "global parameters"; - for(int i = 0; i < (int)params.size(); i++) { + for (int i = 0; i < (int)params.size(); i++) { *params[i] = reader.next_double(); } @@ -4381,22 +4381,22 @@ void PairAIREBO::spline_init() // make top end of piCC flat instead of zero i = 4; - for (j = 0; j < 4; j++){ - for (k = 1; k < 11; k++){ + for (j = 0; j < 4; j++) { + for (k = 1; k < 11; k++) { piCCf[i][j][k] = piCCf[i-1][j][k]; } } - for (i = 0; i < 4; i++){ // also enforces some symmetry - for (j = i+1; j < 5; j++){ - for (k = 1; k < 11; k++){ + for (i = 0; i < 4; i++) { // also enforces some symmetry + for (j = i+1; j < 5; j++) { + for (k = 1; k < 11; k++) { piCCf[i][j][k] = piCCf[j][i][k]; } } } for (k = 1; k < 11; k++) piCCf[4][4][k] = piCCf[3][4][k]; k = 10; - for (i = 0; i < 5; i++){ - for (j = 0; j < 5; j++){ + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { piCCf[i][j][k] = piCCf[i][j][k-1]; } } @@ -4424,22 +4424,22 @@ void PairAIREBO::spline_init() // also enforces some symmetry i = 4; - for (j = 0; j < 4; j++){ - for (k = 1; k < 11; k++){ + for (j = 0; j < 4; j++) { + for (k = 1; k < 11; k++) { piCHf[i][j][k] = piCHf[i-1][j][k]; } } - for (i = 0; i < 4; i++){ - for (j = i+1; j < 5; j++){ - for (k = 1; k < 11; k++){ + for (i = 0; i < 4; i++) { + for (j = i+1; j < 5; j++) { + for (k = 1; k < 11; k++) { piCHf[i][j][k] = piCHf[j][i][k]; } } } for (k = 1; k < 11; k++) piCHf[4][4][k] = piCHf[3][4][k]; k = 10; - for (i = 0; i < 5; i++){ - for (j = 0; j < 5; j++){ + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { piCHf[i][j][k] = piCHf[i][j][k-1]; } } diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index 29fd8b63c6..9f12b0755a 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -181,7 +181,7 @@ PairBOP::PairBOP(LAMMPS *lmp) : Pair(lmp) PairBOP::~PairBOP() { - if(allocated) { + if (allocated) { memory_theta_destroy(); if (otfly==0) memory->destroy(cos_index); delete [] map; @@ -319,16 +319,16 @@ void PairBOP::compute(int eflag, int vflag) itype=map[type[i]]+1; iilist=firstneigh[i]; nlisti=BOP_total[i]; - for(jj=0;jj=i_tag) { + if (j_tag>=i_tag) { sigB_0=sigmaBo(ii,jj); piB_0=PiBo(ii,jj); - if(otfly==0) { - if(neigh_flag[temp_ij]) { + if (otfly==0) { + if (neigh_flag[temp_ij]) { dpr1=(dRepul[temp_ij]-2.0*dBetaS[temp_ij]*sigB_0 -2.0*dBetaP[temp_ij]*piB_0)/rij[temp_ij]; ftmp1=dpr1*disij[0][temp_ij]; @@ -345,7 +345,7 @@ void PairBOP::compute(int eflag, int vflag) dE=-2.0*betaS[temp_ij]*sigB_0-2.0*betaP[temp_ij]*piB_0; totE+=dE+repul[temp_ij]; - if(evflag) { + if (evflag) { ev_tally_full(i,repul[temp_ij],dE,0.0,0.0,0.0,0.0); ev_tally_full(j,repul[temp_ij],dE,0.0,0.0,0.0,0.0); ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0,-ftmp1,-ftmp2,-ftmp3, @@ -354,9 +354,9 @@ void PairBOP::compute(int eflag, int vflag) } } else { - if(itype==jtype) + if (itype==jtype) iij=itype-1; - else if(itype1.0) + if (ps>1.0) ps=1.0; betaS_ij=((pBetaS3[iij][ks-1]*ps+pBetaS2[iij][ks-1])*ps +pBetaS1[iij][ks-1])*ps+pBetaS[iij][ks-1]; @@ -404,7 +404,7 @@ void PairBOP::compute(int eflag, int vflag) dE=-2.0*betaS_ij*sigB_0-2.0*betaP_ij*piB_0; totE+=dE+repul_ij; - if(evflag) { + if (evflag) { ev_tally_full(i,repul_ij,dE,0.0,0.0,0.0,0.0); ev_tally_full(j,repul_ij,dE,0.0,0.0,0.0,0.0); ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0,-ftmp1,-ftmp2,-ftmp3, @@ -423,16 +423,16 @@ void PairBOP::compute(int eflag, int vflag) itype=map[type[i]]+1; iilist=firstneigh[i]; nlisti=BOP_total3[i]; - for(jj=0;jj1.0) + if (ps>1.0) ps=1.0; value=((pLong3[i12][ks-1]*ps+pLong2[i12][ks-1])*ps+ pLong1[i12][ks-1])*ps+pLong[i12][ks-1]; - if(value<=0.0) value=pLong[i12][ks-1]; + if (value<=0.0) value=pLong[i12][ks-1]; dvalue=(pLong6[i12][ks-1]*ps+ pLong5[i12][ks-1])*ps+pLong4[i12][ks-1]; dpr1=-dvalue/r_ij; @@ -469,7 +469,7 @@ void PairBOP::compute(int eflag, int vflag) f[j][1]=f[j][1]-ftmp2; f[j][2]=f[j][2]-ftmp3; totE=totE-value; - if(evflag) { + if (evflag) { ev_tally_full(i,0,-value,0.0,0.0,0.0,0.0); ev_tally_full(j,0,-value,0.0,0.0,0.0,0.0); ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0,-ftmp1,-ftmp2,-ftmp3, @@ -717,7 +717,7 @@ double PairBOP::init_one(int i, int j) else ij=jj*bop_types-jj*(jj+1)/2+ii-1; - if(rcut[ij]>rcut3[ij]) { + if (rcut[ij]>rcut3[ij]) { cutghost[i][j] = rcut[ij]; cutghost[j][i] = cutghost[i][j]; cutsq[i][j] = rcut[ij]*rcut[ij]; @@ -759,7 +759,7 @@ void PairBOP::gneigh() double **x = atom->x; int *type = atom->type; - if(allocate_neigh==0) { + if (allocate_neigh==0) { memory->create(BOP_index,nall,"BOP_index"); memory->create(BOP_index3,nall,"BOP_index3"); memory->create(BOP_total,nall,"BOP_total"); @@ -777,7 +777,7 @@ void PairBOP::gneigh() ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; - if(bop_step==0) { + if (bop_step==0) { maxneigh=0; maxneigh3=0; maxnall=0; @@ -786,7 +786,7 @@ void PairBOP::gneigh() neigh_total3=0; cos_total=0; for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } dis[0]=x[j][0]-x[i][0]; @@ -814,10 +814,10 @@ void PairBOP::gneigh() +dis[1]*dis[1] +dis[2]*dis[2]; r=sqrt(rsq); - if(r<=rcut[i12]) { + if (r<=rcut[i12]) { max_check++; } - if(r<=rcut3[i12]) { + if (r<=rcut3[i12]) { max_check3++; } } @@ -829,23 +829,23 @@ void PairBOP::gneigh() neigh_total+=max_check; neigh_total3+=max_check3; - if(max_check>maxneigh||max_check3>maxneigh3){ + if (max_check>maxneigh||max_check3>maxneigh3) { maxneigh=max_check; maxneigh3=max_check3; } - if(otfly==0) { + if (otfly==0) { cos_index[i]=cos_total; cos_total+=max_check*(max_check-1)/2; } } maxnall=nall; - if(update_list!=0) + if (update_list!=0) memory_theta_grow(); else memory_theta_create(); neigh_t=0; for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } dis[0]=x[j][0]-x[i][0]; @@ -872,15 +872,15 @@ void PairBOP::gneigh() +dis[1]*dis[1] +dis[2]*dis[2]; r=sqrt(rsq); - if(r<=rcut[i12]) { + if (r<=rcut[i12]) { temp_ij=BOP_index[i]+max_check; - if(i==0) { + if (i==0) { } neigh_index[temp_ij]=jj; neigh_flag[temp_ij]=1; max_check++; } - if(r<=rcut3[i12]) { + if (r<=rcut3[i12]) { temp_ij=BOP_index3[i]+max_check3; neigh_index3[temp_ij]=jj; neigh_flag3[temp_ij]=1; @@ -888,9 +888,9 @@ void PairBOP::gneigh() } } } - if(otfly==0) { + if (otfly==0) { for (ii = 0; ii < nall; ii++) { - if(ii=neigh_total) { + if (temp_ij>=neigh_total) { } - if(temp_ij<0) { + if (temp_ij<0) { } jtype = map[type[j]]+1; - if(itype==jtype) + if (itype==jtype) i12=itype-1; - else if(itype=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } disij[0][temp_ij]=x[j][0]-x[i][0]; @@ -923,7 +923,7 @@ void PairBOP::gneigh() +disij[1][temp_ij]*disij[1][temp_ij] +disij[2][temp_ij]*disij[2][temp_ij]; rij[temp_ij]=sqrt(rsq); - if(rij[temp_ij]<=rcut[i12]) { + if (rij[temp_ij]<=rcut[i12]) { max_check++; } else @@ -932,7 +932,7 @@ void PairBOP::gneigh() } neigh_t+=max_check; for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { + if (i12>=npairs) { error->one(FLERR,"Too many atom pairs for pair bop"); } ps=rij[temp_ij]*rdr[i12]+1.0; ks=(int)ps; - if(nr-11.0) + if (ps>1.0) ps=1.0; betaS[temp_ij]=((pBetaS3[i12][ks-1]*ps+pBetaS2[i12][ks-1])*ps+pBetaS1[i12][ks-1])*ps+pBetaS[i12][ks-1]; dBetaS[temp_ij]=(pBetaS6[i12][ks-1]*ps+pBetaS5[i12][ks-1])*ps @@ -977,29 +977,29 @@ void PairBOP::gneigh() } for (ii = 0; ii < nall; ii++) { n=0; - if(ii=cos_total) { + for (kk=jj+1;kk=cos_total) { error->one(FLERR,"Too many atom triplets for pair bop"); } temp_ik=BOP_index[i]+kk; temp_ijk=cos_index[i]+n; - if(temp_ijk>=cos_total) { + if (temp_ijk>=cos_total) { error->one(FLERR,"Too many atom triplets for pair bop"); } rk2=rij[temp_ik]*rij[temp_ik]; rj1k1=rij[temp_ij]*rij[temp_ik]; rj2k2=rj1k1*rj1k1; - if(temp_ijk>=cos_total) { + if (temp_ijk>=cos_total) { error->one(FLERR,"Too many atom triplets for pair bop"); } cosAng[temp_ijk]=(disij[0][temp_ij]*disij[0][temp_ik]+disij[1][temp_ij] @@ -1128,12 +1128,12 @@ double PairBOP::sigmaBo(int itmp, int jtmp) ilist = list->ilist; firstneigh = list->firstneigh; - if(nb_sg==0) { + if (nb_sg==0) { nb_sg=(maxneigh)*(maxneigh/2); } create_sigma(nb_sg); sigB=0; - if(itmpnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1166,27 +1166,27 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_ij].temp=temp_ij; bt_sg[nb_ij].i=i; bt_sg[nb_ij].j=j; - if(j_tag>=i_tag) { - if(itype==jtype) + if (j_tag>=i_tag) { + if (itype==jtype) iij=itype-1; - else if(itype1.0) + if (ps>1.0) ps=1.0; betaS_ij=((pBetaS3[iij][ks-1]*ps+pBetaS2[iij][ks-1])*ps +pBetaS1[iij][ks-1])*ps+pBetaS[iij][ks-1]; @@ -1209,7 +1209,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[iij][ks-1]; } } else { - if(neigh_flag[temp_ij]) { + if (neigh_flag[temp_ij]) { pass_ij=1; dis_ij[0]=disij[0][temp_ij]; dis_ij[1]=disij[1][temp_ij]; @@ -1219,7 +1219,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_ij=dBetaS[temp_ij]; } } - if(pass_ij==1) { + if (pass_ij==1) { nSigBk=0; //AA-EE1 are the components making up Eq. 30 (a) @@ -1249,16 +1249,16 @@ double PairBOP::sigmaBo(int itmp, int jtmp) //k is loop over all neighbors of i again with j neighbor of i nlisti=BOP_total[i]; - for(ktmp=0;ktmp1.0) + if (ps>1.0) ps=1.0; betaS_ik=((pBetaS3[iik][ks-1]*ps+pBetaS2[iik][ks-1])*ps +pBetaS1[iik][ks-1])*ps+pBetaS[iik][ks-1]; @@ -1301,7 +1301,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[iik][ks-1]; } } else { - if(neigh_flag[temp_ik]) { + if (neigh_flag[temp_ik]) { pass_ik=1; dis_ik[0]=disij[0][temp_ik]; dis_ik[1]=disij[1][temp_ik]; @@ -1311,17 +1311,17 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_ik=dBetaS[temp_ik]; } } - if(pass_ik==1) { + if (pass_ik==1) { //find neighbor of i that is equal to k nlistj=BOP_total[j]; - for(jNeik=0;jNeiknb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1390,7 +1390,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_ik].j=k; nb_jk=nb_t; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1398,7 +1398,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jk].temp=temp_jk; bt_sg[nb_jk].i=j; bt_sg[nb_jk].j=k; - if(otfly==1) { + if (otfly==1) { cosAng_jik=(dis_ij[0]*dis_ik[0]+dis_ij[1]*dis_ik[1] +dis_ij[2]*dis_ik[2])/(r_ij*r_ik); dcA_jik[0][0]=(dis_ik[0]*r_ij*r_ik-cosAng_jik @@ -1415,8 +1415,8 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dcA_jik[2][1]=(dis_ij[2]*r_ij*r_ik-cosAng_jik *dis_ik[2]*r_ij*r_ij)/(r_ij*r_ij*r_ik*r_ik); } else { - if(ktmp!=jtmp) { - if(jtmp1.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor1=((gfunc3[jtype][itype][ktype][ks]*ps+ @@ -1458,7 +1458,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor1=gpara[jtype-1][itype-1][ktype-1][0]; gprime1=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -1600,7 +1600,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_jk[2]*r_ij*r_ij)/(r_ij*r_ij*r_jk*r_jk); } } else { - if(neigh_flag[temp_jkp]) { + if (neigh_flag[temp_jkp]) { pass_jkp=1; dis_jkp[0]=disij[0][temp_jkp]; dis_jkp[1]=disij[1][temp_jkp]; @@ -1608,7 +1608,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_jkp=rij[temp_jkp]; betaS_jkp=betaS[temp_jkp]; dBetaS_jkp=dBetaS[temp_jkp]; - if(ji1.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][jtype][ktype][ks]*ps+ @@ -1651,13 +1651,13 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][jtype-1][ktype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[itype][jtype][jtype][ks]*ps+ @@ -1715,7 +1715,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[itype-1][ktype-1][jtype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_ikp=((pBetaS3[iikp][ks-1]*ps+pBetaS2[iikp][ks-1])*ps +pBetaS1[iikp][ks-1])*ps+pBetaS[iikp][ks-1]; @@ -1824,7 +1824,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[iikp][ks-1]; } } else { - if(neigh_flag[temp_ikp]) { + if (neigh_flag[temp_ikp]) { pass_ikp=1; dis_ikp[0]=disij[0][temp_ikp]; dis_ikp[1]=disij[1][temp_ikp]; @@ -1834,10 +1834,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_ikp=dBetaS[temp_ikp]; } } - if(pass_ikp==1) { + if (pass_ikp==1) { nb_ikp=nb_t; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -1845,7 +1845,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_ikp].temp=temp_ikp; bt_sg[nb_ikp].i=i; bt_sg[nb_ikp].j=kp; - if(otfly==1) { + if (otfly==1) { cosAng_jikp=(dis_ij[0]*dis_ikp[0]+dis_ij[1]*dis_ikp[1] +dis_ij[2]*dis_ikp[2])/(r_ij*r_ikp); dcA_jikp[0][0]=(dis_ikp[0]*r_ij*r_ikp-cosAng_jikp @@ -1875,7 +1875,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dcA_kikp[2][1]=(dis_ik[2]*r_ik*r_ikp-cosAng_kikp *dis_ikp[2]*r_ik*r_ik)/(r_ik*r_ik*r_ikp*r_ikp); } else { - if(jtmp1.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[jtype][itype][kptype][ks]*ps+ @@ -1934,21 +1934,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[jtype-1][itype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[ktype][itype][kptype][ks]*ps+ @@ -1962,7 +1962,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[ktype-1][itype-1][kptype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_kkp=((pBetaS3[ikkp][ks-1]*ps+pBetaS2[ikkp][ks-1])*ps +pBetaS1[ikkp][ks-1])*ps+pBetaS[ikkp][ks-1]; @@ -2080,7 +2080,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +pBetaS4[ikkp][ks-1]; } } else { - if(neigh_flag[temp_kkp]) { + if (neigh_flag[temp_kkp]) { pass_kkp=1; dis_kkp[0]=disij[0][temp_kkp]; dis_kkp[1]=disij[1][temp_kkp]; @@ -2090,13 +2090,13 @@ double PairBOP::sigmaBo(int itmp, int jtmp) dBetaS_kkp=dBetaS[temp_kkp]; } } - if(pass_kkp==1) { + if (pass_kkp==1) { sig_flag=0; - for(nsearch=0;nsearchnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2156,14 +2156,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_kkp].i=k; bt_sg[nb_kkp].j=kp; amean=cosAng_ikkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][ktype][kptype][ks]*ps+ @@ -2177,7 +2177,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][ktype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -2350,10 +2350,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_kkp=sqrt(rsq_kkp); ps=r_kkp*rdr[ikkp]+1.0; ks=(int)ps; - if(nr-11.0) + if (ps>1.0) ps=1.0; betaS_kkp=((pBetaS3[ikkp][ks-1]*ps+pBetaS2[ikkp][ks-1])*ps +pBetaS1[ikkp][ks-1])*ps+pBetaS[ikkp][ks-1]; @@ -2414,7 +2414,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_kkp=rij[temp_kkp]; betaS_kkp=betaS[temp_kkp]; dBetaS_kkp=dBetaS[temp_kkp]; - if(jinb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2500,7 +2500,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jkp].j=kp; nb_kkp=nb_t; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2509,14 +2509,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_kkp].i=k; bt_sg[nb_kkp].j=kp; amean=cosAng_ijkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][jtype][kptype][ks]*ps+ @@ -2530,21 +2530,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][jtype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[itype][ktype][kptype][ks]*ps+ @@ -2558,21 +2558,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[itype-1][ktype-1][kptype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor4=((gfunc3[jtype][kptype][ktype][ks]*ps+ @@ -2586,7 +2586,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor4=gpara[jtype-1][kptype-1][ktype-1][0]; gprime4=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jk=((pBetaS3[ijk][ks-1]*ps+pBetaS2[ijk][ks-1])*ps +pBetaS1[ijk][ks-1])*ps+pBetaS[ijk][ks-1]; @@ -2753,7 +2753,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_jk[2]*r_ij*r_ij)/(r_ij*r_ij*r_jk*r_jk); } } else { - if(neigh_flag[temp_jk]) { + if (neigh_flag[temp_jk]) { pass_jk=1; dis_jk[0]=disij[0][temp_jk]; dis_jk[1]=disij[1][temp_jk]; @@ -2761,7 +2761,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_jk=rij[temp_jk]; betaS_jk=betaS[temp_jk]; dBetaS_jk=dBetaS[temp_jk]; - if(ktmpnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -2793,14 +2793,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jk].i=j; bt_sg[nb_jk].j=k; amean=cosAng_ijk; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor1=((gfunc3[itype][jtype][ktype][ks]*ps+ @@ -2814,7 +2814,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor1=gpara[itype-1][jtype-1][ktype-1][0]; gprime1=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -2947,7 +2947,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_jkp[2]*r_jk*r_jk)/(r_jk*r_jk*r_jkp*r_jkp); } } else { - if(neigh_flag[temp_jkp]) { + if (neigh_flag[temp_jkp]) { pass_jkp=1; dis_jkp[0]=disij[0][temp_jkp]; dis_jkp[1]=disij[1][temp_jkp]; @@ -2955,7 +2955,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_jkp=rij[temp_jkp]; betaS_jkp=betaS[temp_jkp]; dBetaS_jkp=dBetaS[temp_jkp]; - if(jinb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -3005,14 +3005,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_jkp].i=j; bt_sg[nb_jkp].j=kp; amean=cosAng_ijkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[itype][jtype][kptype][ks]*ps+ @@ -3026,21 +3026,21 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[itype-1][jtype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor3=((gfunc3[ktype][jtype][kptype][ks]*ps+ @@ -3054,7 +3054,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor3=gpara[ktype-1][jtype-1][kptype-1][0]; gprime3=0.0; xrun=1.0; - for(lp1=1;lp11.0) + if (ps>1.0) ps=1.0; betaS_kkp=((pBetaS3[ikkp][ks-1]*ps+pBetaS2[ikkp][ks-1])*ps +pBetaS1[ikkp][ks-1])*ps+pBetaS[ikkp][ks-1]; @@ -3217,7 +3217,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *dis_kkp[2]*r_jk*r_jk)/(r_jk*r_jk*r_kkp*r_kkp); } } else { - if(neigh_flag[temp_kkp]) { + if (neigh_flag[temp_kkp]) { pass_kkp=1; dis_kkp[0]=disij[0][temp_kkp]; dis_kkp[1]=disij[1][temp_kkp]; @@ -3225,7 +3225,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) r_kkp=rij[temp_kkp]; betaS_kkp=betaS[temp_kkp]; dBetaS_kkp=dBetaS[temp_kkp]; - if(kNeijnb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -3257,14 +3257,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[nb_kkp].i=k; bt_sg[nb_kkp].j=kp; amean=cosAng_jkkp; - if(amean<-1.0) amean=-1.0; - if(npower<=2) { + if (amean<-1.0) amean=-1.0; + if (npower<=2) { ps=(amean-1.0)*rdtheta+1.0; ks=(int)ps; - if(ntheta-11.0) + if (ps>1.0) ps=1.0; ks=ks-1; gfactor2=((gfunc3[jtype][ktype][kptype][ks]*ps+ @@ -3278,7 +3278,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) gfactor2=gpara[jtype-1][ktype-1][kptype-1][0]; gprime2=0.0; xrun=1.0; - for(lp1=1;lp1-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { bt_sg[m].dAAC[0]=bt_sg[m].dAA[0] +bt_sg[m].dBB[0]; bt_sg[m].dAAC[1]=bt_sg[m].dAA[1] @@ -3372,10 +3372,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bndtmp1=bndtmp1*dBetaS_ij/r_ij; bndtmp2=betaS_ij*bndtmp*sigma_c[iij]; setting=0; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { temp_kk=bt_sg[m].temp; - if(temp_kk==temp_ij&&setting==0) { + if (temp_kk==temp_ij&&setting==0) { bt_sg[m].dSigB1[0]=bndtmp1*dis_ij[0] +bndtmp2*bt_sg[m].dAAC[0]; bt_sg[m].dSigB1[1]=bndtmp1*dis_ij[1] @@ -3384,7 +3384,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +bndtmp2*bt_sg[m].dAAC[2]; setting=1; } - else if(temp_kk==temp_ji&&setting==0) { + else if (temp_kk==temp_ji&&setting==0) { bt_sg[m].dSigB1[0]=-bndtmp1*dis_ij[0] +bndtmp2*bt_sg[m].dAAC[0]; bt_sg[m].dSigB1[1]=-bndtmp1*dis_ij[1] @@ -3402,14 +3402,14 @@ double PairBOP::sigmaBo(int itmp, int jtmp) } } } else { - if(sig_flag==0) { - if(AA<0.0) + if (sig_flag==0) { + if (AA<0.0) AA=0.0; - if(BB<0.0) + if (BB<0.0) BB=0.0; - if(CC<0.0) + if (CC<0.0) CC=0.0; - if(DD<0.0) + if (DD<0.0) DD=0.0; // AA and BB are the representations of (a) Eq. 34 and (b) Eq. 9 @@ -3421,11 +3421,11 @@ double PairBOP::sigmaBo(int itmp, int jtmp) DDC=CC+DD; //EEC is a modified form of (a) Eq. 33 - if(DDC-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { bt_sg[m].dAAC[0]=bt_sg[m].dAA[0] +bt_sg[m].dBB[0]; bt_sg[m].dAAC[1]=bt_sg[m].dAA[1] @@ -3473,8 +3473,8 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *(1.0+sigma_a[iij]*GGC)+sigma_c[iij]*(AAC+sigma_a[iij]*EE +sigma_a[iij]*FFC*(2.0+GGC))+small4; UTcom=-0.5*UT*UT*UT; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { bt_sg[m].dUT[0]=UTcom*(bt_sg[m].dEEC[0]*FF +EEC*bt_sg[m].dFF[0]+bt_sg[m].dBBC[0]); bt_sg[m].dUT[1]=UTcom*(bt_sg[m].dEEC[1]*FF @@ -3496,7 +3496,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) } } psign=1.0; - if(1.0+sigma_a[iij]*GGC<0.0) + if (1.0+sigma_a[iij]*GGC<0.0) psign=-1.0; bndtmp0=1.0/sqrt(bndtmp); sigB1=psign*betaS_ij*(1.0+sigma_a[iij]*GGC)*bndtmp0; @@ -3515,10 +3515,10 @@ double PairBOP::sigmaBo(int itmp, int jtmp) *(2.0*(FF+sigma_delta[iij]*sigma_delta[iij])*(1.0 +sigma_a[iij]*GGC)*sigma_a[iij]+sigma_c[iij]*sigma_a[iij]*FFC); setting=0; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { temp_kk=bt_sg[m].temp; - if(temp_kk==temp_ij&&setting==0) { + if (temp_kk==temp_ij&&setting==0) { bt_sg[m].dSigB1[0]=bndtmp1*dis_ij[0] +(bndtmp2*bt_sg[m].dAAC[0] +bndtmp3*bt_sg[m].dEE[0] @@ -3536,7 +3536,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) +bndtmp5*bt_sg[m].dGGC[2]); setting=1; } - else if(temp_kk==temp_ji&&setting==0) { + else if (temp_kk==temp_ji&&setting==0) { bt_sg[m].dSigB1[0]=-bndtmp1*dis_ij[0] +(bndtmp2*bt_sg[m].dAAC[0] +bndtmp3*bt_sg[m].dEE[0] @@ -3577,8 +3577,8 @@ double PairBOP::sigmaBo(int itmp, int jtmp) // sigB is the final expression for (a) Eq. 6 and (b) Eq. 11 - if(nb_t==0) { - if(j>i) { + if (nb_t==0) { + if (j>i) { bt_sg[0].dSigB1[0]=bndtmp1*dis_ij[0]; bt_sg[0].dSigB1[1]=bndtmp1*dis_ij[1]; bt_sg[0].dSigB1[2]=bndtmp1*dis_ij[2]; @@ -3588,13 +3588,13 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[0].dSigB1[1]=-bndtmp1*dis_ij[1]; bt_sg[0].dSigB1[2]=-bndtmp1*dis_ij[2]; } - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { bt_sg[0].dAA[pp]=0.0; bt_sg[0].dBB[pp]=0.0; bt_sg[0].dAAC[pp]=0.0; bt_sg[0].dSigB1[pp]=0.0; bt_sg[0].dSigB[pp]=0.0; - if(sigma_f[iij]!=0.5&&sigma_k[iij]!=0.0) { + if (sigma_f[iij]!=0.5&&sigma_k[iij]!=0.0) { bt_sg[0].dCC[pp]=0.0; bt_sg[0].dDD[pp]=0.0; bt_sg[0].dEE[pp]=0.0; @@ -3613,7 +3613,7 @@ double PairBOP::sigmaBo(int itmp, int jtmp) bt_sg[0].j=j; bt_sg[0].temp=temp_ij; nb_t++; - if(nb_t>nb_sg) { + if (nb_t>nb_sg) { new_n_tot=nb_sg+maxneigh; grow_sigma(nb_sg,new_n_tot); nb_sg=new_n_tot; @@ -3621,35 +3621,35 @@ double PairBOP::sigmaBo(int itmp, int jtmp) } ps=sigB1*rdBO+1.0; ks=(int)ps; - if(nBOt-11.0) + if (ps>1.0) ps=1.0; dsigB1=((FsigBO3[iij][ks-1]*ps+FsigBO2[iij][ks-1])*ps +FsigBO1[iij][ks-1])*ps+FsigBO[iij][ks-1]; dsigB2=(FsigBO6[iij][ks-1]*ps+FsigBO5[iij][ks-1])*ps+FsigBO4[iij][ks-1]; - for(m=0;m-1)&&(bt_sg[m].j>-1)) { + for (m=0;m-1)&&(bt_sg[m].j>-1)) { temp_kk=bt_sg[m].temp; bt_i=bt_sg[m].i; bt_j=bt_sg[m].j; - if(sigma_f[iij]==0.5&&sigma_k[iij]==0.0) { + if (sigma_f[iij]==0.5&&sigma_k[iij]==0.0) { sigB=dsigB1; pp1=2.0*betaS_ij; xtmp[0]=x[bt_j][0]-x[bt_i][0]; xtmp[1]=x[bt_j][1]-x[bt_i][1]; xtmp[2]=x[bt_j][2]-x[bt_i][2]; - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { bt_sg[m].dSigB[pp]=dsigB2*bt_sg[m].dSigB1[pp]; } - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { ftmp[pp]=pp1*bt_sg[m].dSigB[pp]; f[bt_i][pp]-=ftmp[pp]; f[bt_j][pp]+=ftmp[pp]; } - if(evflag) { + if (evflag) { ev_tally_xyz(bt_i,bt_j,nlocal,newton_pair,0.0,0.0,ftmp[0],ftmp[1] ,ftmp[2],xtmp[0],xtmp[1],xtmp[2]); } @@ -3668,18 +3668,18 @@ double PairBOP::sigmaBo(int itmp, int jtmp) xtmp[0]=x[bt_j][0]-x[bt_i][0]; xtmp[1]=x[bt_j][1]-x[bt_i][1]; xtmp[2]=x[bt_j][2]-x[bt_i][2]; - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { bt_sg[m].dSigB[pp]=dsigB2*part2*bt_sg[m].dSigB1[pp] -part3*bt_sg[m].dEE1[pp] +part4*(bt_sg[m].dFF[pp] +0.5*bt_sg[m].dAAC[pp]); } - for(pp=0;pp<3;pp++) { + for (pp=0;pp<3;pp++) { ftmp[pp]=pp1*bt_sg[m].dSigB[pp]; f[bt_i][pp]-=ftmp[pp]; f[bt_j][pp]+=ftmp[pp]; } - if(evflag) { + if (evflag) { ev_tally_xyz(bt_i,bt_j,nlocal,newton_pair,0.0,0.0,ftmp[0],ftmp[1] ,ftmp[2],xtmp[0],xtmp[1],xtmp[2]); } @@ -3776,10 +3776,10 @@ double PairBOP::PiBo(int itmp, int jtmp) firstneigh = list->firstneigh; ilist = list->ilist; n=0; - if(nb_pi>16) { + if (nb_pi>16) { nb_pi=16; } - if(nb_pi==0) { + if (nb_pi==0) { nb_pi=(maxneigh)*(maxneigh/2); } @@ -3793,8 +3793,8 @@ double PairBOP::PiBo(int itmp, int jtmp) // j is a loop over all neighbors of i iilist=firstneigh[i]; - for(m=0;m=i_tag) { - if(itype==jtype) + if (j_tag>=i_tag) { + if (itype==jtype) iij=itype-1; - else if(itypenb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -3849,7 +3849,7 @@ double PairBOP::PiBo(int itmp, int jtmp) bt_pi[nb_ij].j=j; bt_pi[nb_ij].temp=temp_ij; pass_ij=0; - if(otfly==1) { + if (otfly==1) { dis_ij[0]=x[j][0]-x[i][0]; dis_ij[1]=x[j][1]-x[i][1]; dis_ij[2]=x[j][2]-x[i][2]; @@ -3857,14 +3857,14 @@ double PairBOP::PiBo(int itmp, int jtmp) +dis_ij[1]*dis_ij[1] +dis_ij[2]*dis_ij[2]; r_ij=sqrt(rsq_ij); - if(r_ij<=rcut[iij]) { + if (r_ij<=rcut[iij]) { pass_ij=1; ps=r_ij*rdr[iij]+1.0; ks=(int)ps; - if(nr-11.0) + if (ps>1.0) ps=1.0; betaP_ij=((pBetaP3[iij][ks-1]*ps+pBetaP2[iij][ks-1])*ps +pBetaP1[iij][ks-1])*ps+pBetaP[iij][ks-1]; @@ -3872,7 +3872,7 @@ double PairBOP::PiBo(int itmp, int jtmp) +pBetaP4[iij][ks-1]; } } else { - if(neigh_flag[temp_ij]) { + if (neigh_flag[temp_ij]) { pass_ij=1; dis_ij[0]=disij[0][temp_ij]; dis_ij[1]=disij[1][temp_ij]; @@ -3887,23 +3887,23 @@ double PairBOP::PiBo(int itmp, int jtmp) AA=0.0; BB=0.0; - if(pass_ij==1) { + if (pass_ij==1) { nPiBk=0; nlisti=BOP_total[i]; - for(ktmp=0;ktmp1.0) + if (ps>1.0) ps=1.0; betaS_ik=((pBetaS3[iik][ks-1]*ps+pBetaS2[iik][ks-1])*ps +pBetaS1[iik][ks-1])*ps+pBetaS[iik][ks-1]; @@ -3944,7 +3944,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_ik[2]*r_ij*r_ij)/(r_ij*r_ij*r_ik*r_ik); } } else { - if(neigh_flag[temp_ik]) { + if (neigh_flag[temp_ik]) { pass_ik=1; dis_ik[0]=disij[0][temp_ik]; dis_ik[1]=disij[1][temp_ik]; @@ -3954,7 +3954,7 @@ double PairBOP::PiBo(int itmp, int jtmp) dBetaS_ik=dBetaS[temp_ik]; betaP_ik=betaP[temp_ik]; dBetaP_ik=dBetaP[temp_ik]; - if(jtmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4043,30 +4043,30 @@ double PairBOP::PiBo(int itmp, int jtmp) // j and k and k' are different neighbors of i - for(ltmp=0;ltmp1.0) + if (ps>1.0) ps=1.0; betaS_ikp=((pBetaS3[iikp][ks-1]*ps+pBetaS2[iikp][ks-1])*ps +pBetaS1[iikp][ks-1])*ps+pBetaS[iikp][ks-1]; @@ -4121,7 +4121,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_ikp[2]*r_ik*r_ik)/(r_ik*r_ik*r_ikp*r_ikp); } } else { - if(neigh_flag[temp_ikp]) { + if (neigh_flag[temp_ikp]) { pass_ikp=1; dis_ikp[0]=disij[0][temp_ikp]; dis_ikp[1]=disij[1][temp_ikp]; @@ -4132,7 +4132,7 @@ double PairBOP::PiBo(int itmp, int jtmp) betaP_ikp=betaP[temp_ikp]; dBetaP_ikp=dBetaP[temp_ikp]; nkikp=ltmp*(2*nlisti-ltmp-1)/2+(ktmp-ltmp)-1; - if(jtmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4242,13 +4242,13 @@ double PairBOP::PiBo(int itmp, int jtmp) //j is a neighbor of i and k is a neighbor of j and equal to i - for(ki=0;ki1.0) + if (ps>1.0) ps=1.0; betaS_jk=((pBetaS3[ijk][ks-1]*ps+pBetaS2[ijk][ks-1])*ps +pBetaS1[ijk][ks-1])*ps+pBetaS[ijk][ks-1]; @@ -4325,7 +4325,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_jk[2]*r_ij*r_ij)/(r_ij*r_ij*r_jk*r_jk); } } else { - if(neigh_flag[temp_jk]) { + if (neigh_flag[temp_jk]) { pass_jk=1; dis_jk[0]=disij[0][temp_jk]; dis_jk[1]=disij[1][temp_jk]; @@ -4335,7 +4335,7 @@ double PairBOP::PiBo(int itmp, int jtmp) dBetaS_jk=dBetaS[temp_jk]; betaP_jk=betaP[temp_jk]; dBetaP_jk=dBetaP[temp_jk]; - if(ktmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4425,30 +4425,30 @@ double PairBOP::PiBo(int itmp, int jtmp) //j is a neighbor of i and k and k' are different neighbors of j not equal to i - for(ltmp=0;ltmp1.0) + if (ps>1.0) ps=1.0; betaS_jkp=((pBetaS3[ijkp][ks-1]*ps+pBetaS2[ijkp][ks-1])*ps +pBetaS1[ijkp][ks-1])*ps+pBetaS[ijkp][ks-1]; @@ -4503,7 +4503,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_jkp[2]*r_jk*r_jk)/(r_jk*r_jk*r_jkp*r_jkp); } } else { - if(neigh_flag[temp_jkp]) { + if (neigh_flag[temp_jkp]) { pass_jkp=1; dis_jkp[0]=disij[0][temp_jkp]; dis_jkp[1]=disij[1][temp_jkp]; @@ -4514,7 +4514,7 @@ double PairBOP::PiBo(int itmp, int jtmp) betaP_jkp=betaP[temp_jkp]; dBetaP_jkp=dBetaP[temp_jkp]; nkjkp=ltmp*(2*nlistj-ltmp-1)/2+(ktmp-ltmp)-1; - if(kinb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4621,30 +4621,30 @@ double PairBOP::PiBo(int itmp, int jtmp) //j and k' are different neighbors of i and k is a neighbor of j not equal to i - for(ltmp=0;ltmp1.0) + if (ps>1.0) ps=1.0; betaS_ikp=((pBetaS3[iikp][ks-1]*ps+pBetaS2[iikp][ks-1])*ps +pBetaS1[iikp][ks-1])*ps+pBetaS[iikp][ks-1]; @@ -4685,7 +4685,7 @@ double PairBOP::PiBo(int itmp, int jtmp) *dis_ikp[2]*r_ij*r_ij)/(r_ij*r_ij*r_ikp*r_ikp); } } else { - if(neigh_flag[temp_ikp]) { + if (neigh_flag[temp_ikp]) { pass_ikp=1; dis_ikp[0]=disij[0][temp_ikp]; dis_ikp[1]=disij[1][temp_ikp]; @@ -4695,7 +4695,7 @@ double PairBOP::PiBo(int itmp, int jtmp) dBetaS_ikp=dBetaS[temp_ikp]; betaP_ikp=betaP[temp_ikp]; dBetaP_ikp=dBetaP[temp_ikp]; - if(ltmpnb_pi) { + if (nb_t>nb_pi) { new_n_tot=nb_pi+maxneigh; grow_pi(nb_pi,new_n_tot); nb_pi=new_n_tot; @@ -4799,14 +4799,14 @@ double PairBOP::PiBo(int itmp, int jtmp) } } } - if(pi_flag==0) + if (pi_flag==0) nPiBk=nPiBk+1; } } } n++; pp2=2.0*betaP_ij; - for(m=0;m cutmax) cutmax = rcut[i]; @@ -4995,67 +4995,67 @@ void _noopt PairBOP::read_table(char *filename) small3[i] = values.next_double(); } - if(format == 3) { - for(int i = 0; i < bop_types; i++) - for(int j = 0; j < bop_types; j++) - for(int k = j; k < bop_types; k++) { - if(npower <= 2) { + if (format == 3) { + for (int i = 0; i < bop_types; i++) + for (int j = 0; j < bop_types; j++) + for (int k = j; k < bop_types; k++) { + if (npower <= 2) { reader.next_dvector(&gfunc[j][i][k][0], ntheta); } else { reader.next_dvector(&gpara[j][i][k][0], npower+1); } } } else { - for(int i = 0; i < bop_types; i++) - for(int j = 0; j < bop_types; j++) - for(int k = 0; k < bop_types; k++) { + for (int i = 0; i < bop_types; i++) + for (int j = 0; j < bop_types; j++) + for (int k = 0; k < bop_types; k++) { reader.next_dvector(&gpara[i][j][k][0], 3); gpara[j][i][k][3] = 0; } } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&pRepul[i][0], nr); } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&pBetaS[i][0], nr); } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&pBetaP[i][0], nr); } - for(int i = 0; i < npairs; i++) { + for (int i = 0; i < npairs; i++) { reader.next_dvector(&FsigBO[i][0], nBOt); } - for(int i = 0; i < bop_types; i++) { + for (int i = 0; i < bop_types; i++) { pro_delta[i] = reader.next_double(); } - for(int i = 0; i < bop_types; i++) { + for (int i = 0; i < bop_types; i++) { pro[i] = reader.next_double(); } - for(int i=0;ircutall) + for (int i=0; i < npairs; i++) { + if (rcut[i]>rcutall) rcutall=rcut[i]; - if(rcut3[i]>rcutall) + if (rcut3[i]>rcutall) rcutall=rcut3[i]; rcutsq[i]=rcut[i]*rcut[i]; dr[i]=rcut[i]/((double)nr-1.0); @@ -5238,7 +5238,7 @@ void _noopt PairBOP::read_table(char *filename) MPI_Bcast(&npairs,1,MPI_INT,0,world); MPI_Bcast(&npower,1,MPI_INT,0,world); - if (comm->me != 0){ + if (comm->me != 0) { allocate_tables(); allocate(); } @@ -5312,7 +5312,7 @@ void _noopt PairBOP::read_table(char *filename) MPI_Bcast(&FsigBO4[0][0],npairs*nBOt,MPI_DOUBLE,0,world); MPI_Bcast(&FsigBO5[0][0],npairs*nBOt,MPI_DOUBLE,0,world); MPI_Bcast(&FsigBO6[0][0],npairs*nBOt,MPI_DOUBLE,0,world); - if(npower<=2){ + if (npower<=2) { MPI_Bcast(&gfunc[0][0][0][0],bop_types*bop_types*bop_types*ntheta,MPI_DOUBLE,0,world); MPI_Bcast(&gfunc1[0][0][0][0],bop_types*bop_types*bop_types*ntheta,MPI_DOUBLE,0,world); MPI_Bcast(&gfunc2[0][0][0][0],bop_types*bop_types*bop_types*ntheta,MPI_DOUBLE,0,world); @@ -5440,7 +5440,7 @@ double PairBOP::memory_usage() bytes += nall * sizeof(double); // BOP_total bytes += nall * sizeof(double); - if(otfly==0) { + if (otfly==0) { // cosAng bytes += cos_total* sizeof(double); // dcAng @@ -5542,7 +5542,7 @@ double PairBOP::memory_usage() bytes += maxneigh*(maxneigh/2) *sizeof(B_PI); // bt_sigma bytes += maxneigh*(maxneigh/2) *sizeof(B_SG); - if(npower<=2) { + if (npower<=2) { // gfunc bytes += bop_types*bop_types*bop_types*ntheta *sizeof(double); // gfunc1 @@ -5568,14 +5568,14 @@ double PairBOP::memory_usage() void PairBOP::memory_theta_create() { neigh_ct=(maxneigh-1)*(maxneigh-1)*(maxneigh-1); - if(neigh_ct<1) neigh_ct=1; + if (neigh_ct<1) neigh_ct=1; memory->create(itypeSigBk,neigh_ct,"itypeSigBk"); memory->create(itypePiBk,neigh_ct,"itypePiBk"); memory->create(neigh_flag,neigh_total,"neigh_flag"); memory->create(neigh_flag3,neigh_total3,"neigh_flag3"); memory->create(neigh_index,neigh_total,"neigh_index"); memory->create(neigh_index3,neigh_total3,"neigh_index3"); - if(otfly==0) { + if (otfly==0) { memory->create(cosAng,cos_total,"BOP:cosAng"); memory->create(dcAng,cos_total,3,2,"BOP:dcAng"); memory->create(disij,3,neigh_total,"disij"); @@ -5595,14 +5595,14 @@ void PairBOP::memory_theta_create() void PairBOP::memory_theta_grow() { neigh_ct=(maxneigh-1)*(maxneigh-1)*(maxneigh-1); - if(neigh_ct<1) neigh_ct=1; + if (neigh_ct<1) neigh_ct=1; memory->grow(itypeSigBk,neigh_ct,"itypeSigBk"); memory->grow(itypePiBk,neigh_ct,"itypePiBk"); memory->grow(neigh_flag,neigh_total,"neigh_flag"); memory->grow(neigh_flag3,neigh_total3,"neigh_flag3"); memory->grow(neigh_index,neigh_total,"neigh_index"); memory->grow(neigh_index3,neigh_total3,"neigh_index3"); - if(otfly==0) { + if (otfly==0) { memory->grow(cosAng,cos_total,"BOP:cosAng"); memory->grow(dcAng,cos_total,3,2,"BOP:dcAng"); memory->grow(disij,3,neigh_total,"disij"); @@ -5634,7 +5634,7 @@ void PairBOP::memory_theta_destroy() neigh_flag3 = nullptr; neigh_index = nullptr; neigh_index3 = nullptr; - if(otfly==0) { + if (otfly==0) { memory->destroy(cosAng); memory->destroy(dcAng); memory->destroy(disij); @@ -5670,11 +5670,11 @@ void PairBOP::grow_pi(int n1, int n2) int i,j; B_PI *bt_temp; bt_temp = (B_PI *) memory->smalloc(n1*sizeof(B_PI),"BOP:b_temp"); - for(i=0;idestroy(bt_pi); bt_pi=nullptr; bt_pi = (B_PI *) memory->smalloc(n2*sizeof(B_PI),"BOP:bt_pi"); - for(i=0;ismalloc(n1*sizeof(B_SG),"BOP:bt_temp"); - for(i=0;idestroy(bt_sg); bt_sg=nullptr; bt_sg = (B_SG *) memory->smalloc(n2*sizeof(B_SG),"BOP:bt_sg"); - for(i=0;i 0.0 ) { + if (params[iparam_ij].hfocor > 0.0 ) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -727,7 +727,7 @@ void PairComb::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index ddf4695df7..30abb43dfc 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -346,7 +346,7 @@ void PairComb3::read_lib() ntab = reader.next_int(); - for (i = 0; i < (ntab + 1); i++){ + for (i = 0; i < (ntab + 1); i++) { values = reader.next_values(4); values.skip(1); pang[i] = values.next_double(); @@ -381,7 +381,7 @@ void PairComb3::read_lib() jj = values.next_int(); kk = values.next_int(); - for(iii = 0; iii < 2; iii++) { + for (iii = 0; iii < 2; iii++) { mm = iii*32; reader.next_dvector(&pcn_cubs[ll][ii][jj][kk][mm], 32); } @@ -446,7 +446,7 @@ void PairComb3::read_lib() ii = values.next_int(); jj = values.next_int(); kk = values.next_int() - 1; - for(iii=0; iii<2; iii++) { + for (iii=0; iii<2; iii++) { mm=iii*32; reader.next_dvector(&tor_spl[ll][ii][jj][kk][mm], 32); } @@ -672,7 +672,7 @@ void PairComb3::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } @@ -1143,11 +1143,11 @@ void PairComb3::compute(int eflag, int vflag) srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); srmu = sqrt(1.0-srmu*srmu); - if(srmu > 0.1) { + if (srmu > 0.1) { for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj l = sht_llist[ll]; - if(l==i || l==j || l==k) continue; + if (l==i || l==j || l==k) continue; ltype = map[type[l]]; @@ -1199,7 +1199,7 @@ void PairComb3::compute(int eflag, int vflag) , rsq1, rsq2, delrl, delrk, j, ycn); // radical initialization: apply only to CC,CO,OC bonds - if(params[iparam_ji].rad_flag > 0 + if (params[iparam_ji].rad_flag > 0 && params[iparam_jl].ielementgp == 1 && params[iparam_jl].jelementgp == 1) { iparam_lj = elem2param[ltype][jtype][jtype]; @@ -1275,7 +1275,7 @@ void PairComb3::compute(int eflag, int vflag) srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); srmu = sqrt(1.0-srmu*srmu); - if(srmu > 0.1) { + if (srmu > 0.1) { for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj l = sht_llist[ll]; if (l==i||l==j||l==k) continue; @@ -1304,7 +1304,7 @@ void PairComb3::compute(int eflag, int vflag) } } - if( params[iparam_ijk].rad_flag>=1 && + if ( params[iparam_ijk].rad_flag>=1 && params[iparam_ijk].ielementgp==1 && params[iparam_ijk].kelementgp==1) { iparam_ki = elem2param[ktype][itype][itype]; @@ -1400,7 +1400,7 @@ void PairComb3::compute(int eflag, int vflag) } // radical i-j-l-p: apply to all CC,CO,OC bonds - if( params[iparam_jil].rad_flag >= 1 && + if ( params[iparam_jil].rad_flag >= 1 && params[iparam_jil].ielementgp == 1 && params[iparam_jil].kelementgp == 1 ) { iparam_lj = elem2param[ltype][jtype][jtype]; @@ -1894,7 +1894,7 @@ void PairComb3::comb_bij_d(double zet, Param *param, double r, int i, zeta = pow(zetang,pow_n)+pcorn; tmp_tbij=pow_n*pow(zetang,(pow_n-1.0)); - if ((1.0 + zeta) < 0.1 ){ + if ((1.0 + zeta) < 0.1 ) { zeta=0.1-1.0; tbij = pow(1.0 + zeta, -0.5/pow_n); tbij1=0.0; @@ -1948,22 +1948,22 @@ void PairComb3::coord(Param *param, double r, int i, pcorn = dpcorn = dxccij = dxchij = dxcoij = 0.0; pcorn = 0.0; dpcorn = 0.0; - if(xcntot < 0.0) xcntot = 0.0; + if (xcntot < 0.0) xcntot = 0.0; if (tri_flag>0) { - if(jele_gp==1) xcccn = xcccn-comb_fc(r,param)*param->pcross; - if(jele_gp==2) xchcn = xchcn-comb_fc(r,param)*param->pcross; - if(jele_gp==3) xcocn = xcocn-comb_fc(r,param)*param->pcross; - if(xcccn < 0.0) xcccn = 0.0; - if(xchcn < 0.0) xchcn = 0.0; - if(xcocn < 0.0) xcocn = 0.0; - if(xcccn > maxx) xcccn = maxx; - if(xchcn > maxy) xchcn = maxy; - if(xcocn > maxz) xcocn = maxz; + if (jele_gp==1) xcccn = xcccn-comb_fc(r,param)*param->pcross; + if (jele_gp==2) xchcn = xchcn-comb_fc(r,param)*param->pcross; + if (jele_gp==3) xcocn = xcocn-comb_fc(r,param)*param->pcross; + if (xcccn < 0.0) xcccn = 0.0; + if (xchcn < 0.0) xchcn = 0.0; + if (xcocn < 0.0) xcocn = 0.0; + if (xcccn > maxx) xcccn = maxx; + if (xchcn > maxy) xchcn = maxy; + if (xcocn > maxz) xcocn = maxz; double xcntritot=xcccn+xchcn+xcocn; - if(xcntritot > maxxcn[tri_flag-1]) { + if (xcntritot > maxxcn[tri_flag-1]) { pcorn = vmaxxcn[tri_flag-1]+(xcntot-maxxcn[tri_flag-1])*dvmaxxcn[tri_flag-1]; dxccij = dxchij = dxcoij = dvmaxxcn[tri_flag-1]; } @@ -1998,17 +1998,17 @@ void PairComb3::cntri_int(int tri_flag, double xval, double yval, { double x; vval = 0.0; dvalx = 0.0; dvaly = 0.0; dvalz = 0.0; - if(ixmin >= maxx-1) { ixmin=maxx-1; } - if(iymin >= maxy-1) { iymin=maxy-1; } - if(izmin >= maxz-1) { izmin=maxz-1; } + if (ixmin >= maxx-1) { ixmin=maxx-1; } + if (iymin >= maxy-1) { iymin=maxy-1; } + if (izmin >= maxz-1) { izmin=maxz-1; } for (int j=0; j<64; j++) { x = pcn_cubs[tri_flag-1][ixmin][iymin][izmin][j] *pow(xval,iin3[j][0])*pow(yval,iin3[j][1]) *pow(zval,iin3[j][2]); vval += x; - if(xval>1.0e-8) {dvalx += x*iin3[j][0]/xval;} - if(yval>1.0e-8) {dvaly += x*iin3[j][1]/yval;} - if(zval>1.0e-8) {dvalz += x*iin3[j][2]/zval;} + if (xval>1.0e-8) {dvalx += x*iin3[j][0]/xval;} + if (yval>1.0e-8) {dvaly += x*iin3[j][1]/yval;} + if (zval>1.0e-8) {dvalz += x*iin3[j][2]/zval;} } } @@ -2045,7 +2045,7 @@ double PairComb3::comb_gijk(double costheta, Param *param, double nco_tmp) gmu = gmu2+qtheta*(gmu1-gmu2); return gmu*pcross; - } else if (param->ang_flag==2){ + } else if (param->ang_flag==2) { double qtheta, gmu1, gmu2; double ch6 = ch_a[6]*rmu6; double ch5 = ch_a[5]*rmu5; @@ -2104,7 +2104,7 @@ void PairComb3::comb_gijk_d(double costheta, Param *param, double nco_tmp, dgmu2 = dpang[k]+(dpang[k+1]-dpang[k])*(rrmu-k); gijk_d = pcross*(dgmu2+qtheta*(dgmu1-dgmu2)); com3jk = dqtheta * (gmu1-gmu2); - } else if(param->ang_flag==2) { + } else if (param->ang_flag==2) { double qtheta, dqtheta, gmu1, gmu2, dgmu1,dgmu2; double ch6 = ch_a[6]; double ch5 = ch_a[5]; @@ -2191,11 +2191,11 @@ void PairComb3::comb_zetaterm_d(double prefac_ij1, double prefac_ij2, costheta_d(rij_hat,rij,rik_hat,rik,dcosdri,dcosdrj,dcosdrk); // com6 & com7 - if(icontrol > 0){ - if(parami->kelementgp==1) {com6 = prefac_ij3*pcrossk*dfc_k;} - if(parami->kelementgp==2) {com6 = prefac_ij4*pcrossk*dfc_k;} - if(parami->kelementgp==3) {com6 = prefac_ij5*pcrossk*dfc_k;} - if(parami->rad_flag>=1 || parami->tor_flag!=0) + if (icontrol > 0) { + if (parami->kelementgp==1) {com6 = prefac_ij3*pcrossk*dfc_k;} + if (parami->kelementgp==2) {com6 = prefac_ij4*pcrossk*dfc_k;} + if (parami->kelementgp==3) {com6 = prefac_ij5*pcrossk*dfc_k;} + if (parami->rad_flag>=1 || parami->tor_flag!=0) {com6+=prefac_ij2*pcrossk*dfc_k;} } else { com6 = prefac_ij2*pcrossi*dfc_k; @@ -2475,9 +2475,9 @@ void PairComb3::tables() iparam_ij = elem2param[itype][jtype][jtype]; // parameter check: eps > 0 - if(params[iparam_ij].vdwflag > 0) { + if (params[iparam_ij].vdwflag > 0) { - if(params[iparam_ij].vdwflag==1){ + if (params[iparam_ij].vdwflag==1) { rvdw[0][inty] = params[iparam_ij].bigr + params[iparam_ij].bigd; } else { @@ -2530,8 +2530,8 @@ void PairComb3::tables() vepst = params[iparam_ij].veps; vsigt = vsigt*vsigt*vsigt*vsigt*vsigt*vsigt; - if(params[iparam_ij].vdwflag>0) { - if(r <= rvdw[0][inty]) { + if (params[iparam_ij].vdwflag>0) { + if (r <= rvdw[0][inty]) { vvdw[k][inty] = 0.0; vdvdw[k][inty] = 0.0; } @@ -2656,27 +2656,27 @@ void PairComb3::direct(Param *parami, Param *paramj, int mr1, pot_tmp = for_tmp = 0.0; icurl=jcurl=0; - if(ielegp==2 && curli>curlij0) { + if (ielegp==2 && curli>curlij0) { icurl=1; curlij1=curli; } - if(jelegp==2 && curlj>curlji0) { + if (jelegp==2 && curlj>curlji0) { jcurl=1; curlji1=curlj; } - if(icurl==1 || jcurl ==1) { + if (icurl==1 || jcurl ==1) { xcoij = xcotmp[i]; xcoji = xcotmp[j]; fcp1j = comb_fc_d(r,parami); - if(icurl==1) { + if (icurl==1) { curli=curlij1+(curlij0-curlij1)*comb_fc_curl(xcoij,parami); dcurlij=fcp1j*(curlij0-curlij1)*comb_fc_curl_d(xcoij,parami); } - if(jcurl==1) { + if (jcurl==1) { curlj=curlji1+(curlji0-curlji1)*comb_fc_curl(xcoji,paramj); dcurlji=fcp1j*(curlji0-curlji1)*comb_fc_curl_d(xcoji,paramj); } @@ -2705,10 +2705,10 @@ void PairComb3::direct(Param *parami, Param *paramj, int mr1, smf1n = iq * curlj * (dafbn-dfafbnl)*esucon/r; smf1j = jq * curli * (dafbj-dfafbnl)*esucon/r; - if(jcurl==1 && ielegp == 3 && dcurlji != 0.0){ + if (jcurl==1 && ielegp == 3 && dcurlji != 0.0) { smf1n += dcurlji*iq*(afbn-fafbnl)*esucon/r; } - if(icurl==1 && jelegp == 3 && dcurlij != 0.0){ + if (icurl==1 && jelegp == 3 && dcurlij != 0.0) { smf1j += dcurlij*jq*(afbj-fafbnl)*esucon/r; } @@ -2798,12 +2798,12 @@ void PairComb3::rad_calc(double r, Param *parami, Param *paramj, yrad = -comb_fc(r,paramj)*paramj->pcross + ycn; zcon = 1.0 + pow(kconjug,2) + pow(lconjug,2); - if(xrad < 0.0) xrad = 0.0; - if(yrad < 0.0) yrad = 0.0; - if(zcon < 1.0) zcon = 1.0; - if(xrad > maxxc) xrad = maxxc; - if(yrad > maxyc) yrad = maxyc; - if(zcon > maxconj) zcon = maxconj; + if (xrad < 0.0) xrad = 0.0; + if (yrad < 0.0) yrad = 0.0; + if (zcon < 1.0) zcon = 1.0; + if (xrad > maxxc) xrad = maxxc; + if (yrad > maxyc) yrad = maxyc; + if (zcon > maxconj) zcon = maxconj; ixmin = int(xrad+1.0e-12); iymin = int(yrad+1.0e-12); izmin = int(zcon+1.0e-12); @@ -2835,17 +2835,17 @@ void PairComb3::rad_int(int radindx,double xrad, double yrad, double zcon, int l int j; double x; vrad = pradx = prady = pradz = 0.0; - if(l >= maxxc-1) { l=maxxc-1;} - if(m >= maxyc-1) { m=maxyc-1; } - if(n >= maxconj-1) { n=maxconj-1;} + if (l >= maxxc-1) { l=maxxc-1;} + if (m >= maxyc-1) { m=maxyc-1; } + if (n >= maxconj-1) { n=maxconj-1;} for (j=0; j<64; j++) { x = rad_spl[radindx][l][m][n-1][j] * pow(xrad,iin3[j][0]) * pow(yrad,iin3[j][1]) * pow(zcon,iin3[j][2]); vrad += x; - if(xrad > 1.0e-8) pradx += x*iin3[j][0]/xrad; - if(yrad > 1.0e-8) prady += x*iin3[j][1]/yrad; - if(zcon > 1.0e-8) pradz += x*iin3[j][2]/zcon; + if (xrad > 1.0e-8) pradx += x*iin3[j][0]/xrad; + if (yrad > 1.0e-8) prady += x*iin3[j][1]/yrad; + if (zcon > 1.0e-8) pradz += x*iin3[j][2]/zcon; } } @@ -2933,7 +2933,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, vec3_scale(-1.0,delrl,delrl); rmul = sqrt(1.0-rmul*rmul); - if(rmul > 0.1 ) { + if (rmul > 0.1 ) { double fc1k, fc1l, TT1, TT2, rmut, btt, tork[3], torl[3]; fc1k = comb_fc(rik,paramk); @@ -2948,7 +2948,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, torl[2] = delrj[0]*delrl[1] - delrj[1]*delrl[0]; TT2 = vec3_dot(tork,torl); rmut = pow((TT2/TT1),2); - if(torindx>=1) { + if (torindx>=1) { btt = 1.0 - rmut; return btt * fc1k * fc1l; } @@ -2976,7 +2976,7 @@ void PairComb3::tor_calc(double r, Param *parami, Param *paramj, vtor = dtorx = dtory = dtorz = 0.0; torindx=parami->tor_flag; - if(torindx<0){ + if (torindx<0) { vtor=1.0; dtorx=0.0; dtory=0.0; @@ -3026,18 +3026,18 @@ void PairComb3::tor_int(int torindx,double xtor, double ytor, double zcon, int l double x; vtor = dtorx = dtory = dtorz = 0.0; - if(l >= maxxc-1) { l=maxxc-1; } //boundary condition changed - if(m >= maxyc-1) { m=maxyc-1; } - if(n >= maxconj-1) { n=maxconj-1; } + if (l >= maxxc-1) { l=maxxc-1; } //boundary condition changed + if (m >= maxyc-1) { m=maxyc-1; } + if (n >= maxconj-1) { n=maxconj-1; } for (j=0; j<64; j++) { x = tor_spl[torindx][l][m][n-1][j] * pow(xtor,iin3[j][0]) * pow(ytor,iin3[j][1]) * pow(zcon,iin3[j][2]); vtor += x; - if(xtor > 1.0e-8 ) dtorx += x*iin3[j][0]/xtor; - if(ytor > 1.0e-8 ) dtory += x*iin3[j][1]/ytor; - if(zcon > 1.0e-8 ) dtorz += x*iin3[j][2]/zcon; + if (xtor > 1.0e-8 ) dtorx += x*iin3[j][0]/xtor; + if (ytor > 1.0e-8 ) dtory += x*iin3[j][1]/ytor; + if (zcon > 1.0e-8 ) dtorz += x*iin3[j][2]/zcon; } } @@ -3063,9 +3063,9 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, rmul = vec3_dot(delrj,delrl)/(rij*rjl); vec3_scale(-1.0,delrl,delrl); srmul = sqrt(1.0-rmul*rmul); - if(acos(rmul) > MY_PI) srmul = -srmul; + if (acos(rmul) > MY_PI) srmul = -srmul; - if(srmul > 0.1 ) { + if (srmul > 0.1 ) { double fc1k, fcp1k, fc1l, fcp1l, srmul2, dt1dik, dt1djl; double TT1, TT2, rmut, btt, tork[3], torl[3]; double dt2dik[3], dt2djl[3], dt2dij[3], AA, AA2; @@ -3104,7 +3104,7 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, rmut = TT2/TT1; - if(torindx>=1) { + if (torindx>=1) { btt = 1.0 - pow(rmut,2); AA = -2.0 * ptorr * rmut * fc1k * fc1l / TT1; } @@ -3325,7 +3325,7 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) double eneg = 0.0; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { eneg += qf[i]; itag=tag[i]; } @@ -3386,23 +3386,23 @@ void PairComb3::qfo_direct(Param *parami, Param *paramj, int mr1, esucon=force->qqr2e; icurl = jcurl = 0; - if(ielegp==2 && curli>curlij0) { + if (ielegp==2 && curli>curlij0) { icurl=1; curlij1=curli; } - if(jelegp==2 && curlj>curlji0) { + if (jelegp==2 && curlj>curlji0) { jcurl=1; curlji1=curlj; } - if(icurl==1 || jcurl ==1) { + if (icurl==1 || jcurl ==1) { double xcoij= xcotmp[i]; double xcoji= xcotmp[j]; - if(icurl==1) { + if (icurl==1) { curli=curlij1+(curlij0-curlij1)*comb_fc_curl(xcoij,parami); } - if(jcurl==1) { + if (jcurl==1) { curlj=curlji1+(curlji0-curlji1)*comb_fc_curl(xcoji,paramj); } } @@ -3584,7 +3584,7 @@ void PairComb3::dipole_init(Param *parami, Param *paramj, double fac11, int intj = paramj->ielement; int inty = intype[inti][intj]; - for(nm=0; nm<3; nm++) Qext[nm] = 0.0; + for (nm=0; nm<3; nm++) Qext[nm] = 0.0; r = sqrt(rsq); r3 = r * rsq; diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index 343363a691..d8760cd55a 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -466,7 +466,7 @@ void PairEAM::read_file(char *filename) Funcfl *file = &funcfl[nfuncfl-1]; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam", unit_convert_flag); // transparently convert units for supported conversions @@ -518,7 +518,7 @@ void PairEAM::read_file(char *filename) MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { memory->create(file->frho, (file->nrho+1), "pair:frho"); memory->create(file->rhor, (file->nr+1), "pair:rhor"); memory->create(file->zr, (file->nr+1), "pair:zr"); diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index 50d73f89c2..e1c43b9d99 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -117,7 +117,7 @@ void PairEAMAlloy::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index 463166d22a..05e5e2b323 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -117,7 +117,7 @@ void PairEAMFS::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/fs", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index dbb16125c7..f95a43ed67 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -476,7 +476,7 @@ void PairEIM::read_file(char *filename) setfl->tp = new int[npair]; // read potential file - if( comm->me == 0) { + if ( comm->me == 0) { EIMPotentialFileReader reader(lmp, filename, unit_convert_flag); reader.get_global(setfl); diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 675ec1b3fe..32ace05546 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -467,7 +467,7 @@ void PairGW::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index c8fe598e46..bee8efb692 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -165,7 +165,7 @@ void PairGWZBL::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index df43aac9d2..09ea20df52 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -1220,7 +1220,7 @@ void PairLCBOP::spline_init() { // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ){ +// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { // file << x << " "; // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; @@ -1231,7 +1231,7 @@ void PairLCBOP::spline_init() { // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ){ +// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { // file << x << " "; // for( double y=0; y<=3.0+0.0001; y+=0.1 ) { // double dF_dx; @@ -1247,7 +1247,7 @@ void PairLCBOP::spline_init() { // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ){ +// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { // file << x << " "; // for( double y=0; y<=3.0+0.0001; y+=0.1 ) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 8e1468271e..7e53dcc39c 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -360,7 +360,7 @@ void PairNb3bHarmonic::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index e256063b73..ee736cfe5b 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -646,7 +646,7 @@ void PairPolymorphic::read_file(char *file) MPI_Bcast(&npair, 1, MPI_INT, 0, world); MPI_Bcast(&ntriple, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { delete [] match; match = new int[nelements]; delete [] pairParameters; diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index 708027913c..c94e75b4a2 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -437,7 +437,7 @@ void PairSW::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index dbb7cd2f48..bcfcb149b4 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -496,7 +496,7 @@ void PairTersoff::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 6ea7758d61..f5e4d21ffc 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -148,7 +148,7 @@ void PairTersoffMOD::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index 8582e39ef1..c2cbcdd2d9 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -142,7 +142,7 @@ void PairTersoffMODC::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index 0c0c58322a..aee9eda71f 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -173,7 +173,7 @@ void PairTersoffZBL::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index d5a1374a80..32f3212d75 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -452,7 +452,7 @@ void PairVashishta::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/MISC/compute_ti.cpp b/src/MISC/compute_ti.cpp index 135e4eab91..e81dd81c86 100644 --- a/src/MISC/compute_ti.cpp +++ b/src/MISC/compute_ti.cpp @@ -216,7 +216,7 @@ double ComputeTI::compute_scalar() eng = force->kspace->energy; else { double *eatom = force->kspace->eatom; - for(int i = 0; i < nlocal; i++) + for (int i = 0; i < nlocal; i++) if ((ilo[m]<=type[i])&(ihi[m]>=type[i])) eng += eatom[i]; MPI_Allreduce(&eng,&engall,1,MPI_DOUBLE,MPI_SUM,world); diff --git a/src/MISC/fix_gld.cpp b/src/MISC/fix_gld.cpp index 282a98b4f8..d78dd67bdb 100644 --- a/src/MISC/fix_gld.cpp +++ b/src/MISC/fix_gld.cpp @@ -67,7 +67,7 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : int seed = utils::inumeric(FLERR,arg[6],false,lmp); // 7 = series type - if(strcmp(arg[7],"pprony") == 0) { + if (strcmp(arg[7],"pprony") == 0) { series_type = 1; // series type 1 is 'positive Prony series' } else { error->all(FLERR,"Fix gld series type must be pprony for now"); diff --git a/src/MISC/xdr_compat.cpp b/src/MISC/xdr_compat.cpp index 7483b4aa18..675afb835e 100644 --- a/src/MISC/xdr_compat.cpp +++ b/src/MISC/xdr_compat.cpp @@ -60,7 +60,7 @@ static xdr_uint32_t xdr_swapbytes(xdr_uint32_t x) char *px=(char *)&x; char *py=(char *)&y; - for(i=0;i<4;i++) + for (i=0;i<4;i++) py[i]=px[3-i]; return y; @@ -469,7 +469,7 @@ xdr_double(XDR *xdrs, double *dp) int *ip; xdr_int32_t tmp[2]; - if(LSW<0) { + if (LSW<0) { double x=0.987654321; /* Just a number */ /* Possible representations in IEEE double precision: @@ -484,9 +484,9 @@ xdr_double(XDR *xdrs, double *dp) unsigned char ix = *((char *)&x); - if(ix==0xdd || ix==0x3f) + if (ix==0xdd || ix==0x3f) LSW=1; /* Big endian word order */ - else if(ix==0xb8 || ix==0x3c) + else if (ix==0xb8 || ix==0x3c) LSW=0; /* Small endian word order */ else { /* Catch strange errors */ printf("Error when detecting floating-point word order.\n" diff --git a/src/MLIAP/mliap_descriptor.cpp b/src/MLIAP/mliap_descriptor.cpp index ac168dc94b..29b1736f4e 100644 --- a/src/MLIAP/mliap_descriptor.cpp +++ b/src/MLIAP/mliap_descriptor.cpp @@ -26,5 +26,5 @@ MLIAPDescriptor::MLIAPDescriptor(LAMMPS *lmp) : Pointers(lmp) {} /* ---------------------------------------------------------------------- */ -MLIAPDescriptor::~MLIAPDescriptor(){} +MLIAPDescriptor::~MLIAPDescriptor() {} diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp index 2cb88de6b4..275eadd74e 100644 --- a/src/MLIAP/mliap_descriptor_snap.cpp +++ b/src/MLIAP/mliap_descriptor_snap.cpp @@ -171,7 +171,7 @@ void MLIAPDescriptorSNAP::compute_forces(class MLIAPData* data) for (int jj = 0; jj < ninside; jj++) { int j = snaptr->inside[jj]; - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -245,7 +245,7 @@ void MLIAPDescriptorSNAP::compute_force_gradients(class MLIAPData* data) for (int jj = 0; jj < ninside; jj++) { const int j = snaptr->inside[jj]; - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -318,7 +318,7 @@ void MLIAPDescriptorSNAP::compute_descriptor_gradients(class MLIAPData* data) ij = ij0; for (int jj = 0; jj < ninside; jj++) { - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -500,7 +500,7 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename) cut = 2.0*radelem[ielem]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[ielem][ielem] = cut*cut; - for(int jelem = ielem+1; jelem < nelements; jelem++) { + for (int jelem = ielem+1; jelem < nelements; jelem++) { cut = (radelem[ielem]+radelem[jelem])*rcutfac; cutsq[ielem][jelem] = cutsq[jelem][ielem] = cut*cut; } diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp index 3c8f9aa39a..9d19dcf381 100644 --- a/src/MLIAP/mliap_model_linear.cpp +++ b/src/MLIAP/mliap_model_linear.cpp @@ -32,7 +32,7 @@ MLIAPModelLinear::MLIAPModelLinear(LAMMPS* lmp, char* coefffilename) : /* ---------------------------------------------------------------------- */ -MLIAPModelLinear::~MLIAPModelLinear(){} +MLIAPModelLinear::~MLIAPModelLinear() {} /* ---------------------------------------------------------------------- get number of parameters diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp index e47356390f..823cee711f 100644 --- a/src/MLIAP/mliap_model_python.cpp +++ b/src/MLIAP/mliap_model_python.cpp @@ -73,7 +73,7 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS* lmp, char* coefffilename) : /* ---------------------------------------------------------------------- */ -MLIAPModelPython::~MLIAPModelPython(){ +MLIAPModelPython::~MLIAPModelPython() { MLIAPPY_unload_model(this); } diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp index 915ec30435..0b640189b4 100644 --- a/src/MLIAP/mliap_model_quadratic.cpp +++ b/src/MLIAP/mliap_model_quadratic.cpp @@ -35,7 +35,7 @@ MLIAPModelQuadratic::MLIAPModelQuadratic(LAMMPS* lmp, char* coefffilename) : /* ---------------------------------------------------------------------- */ -MLIAPModelQuadratic::~MLIAPModelQuadratic(){} +MLIAPModelQuadratic::~MLIAPModelQuadratic() {} /* ---------------------------------------------------------------------- get number of parameters diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index a8c57918b4..4dfb4f0988 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -241,7 +241,7 @@ void AngleTable::coeff(int narg, char **arg) // convert theta from degrees to radians - for (int i = 0; i < tb->ninput; i++){ + for (int i = 0; i < tb->ninput; i++) { tb->afile[i] *= MY_PI/180.0; tb->ffile[i] *= 180.0/MY_PI; } diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index f48d5254cf..d8aee3e181 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -1376,7 +1376,7 @@ void FixCMAP::copy_arrays(int i, int j, int /*delflag*/) { num_crossterm[j] = num_crossterm[i]; - for (int k = 0; k < num_crossterm[j]; k++){ + for (int k = 0; k < num_crossterm[j]; k++) { crossterm_type[j][k] = crossterm_type[i][k]; crossterm_atom1[j][k] = crossterm_atom1[i][k]; crossterm_atom2[j][k] = crossterm_atom2[i][k]; diff --git a/src/MOLECULE/pair_tip4p_cut.cpp b/src/MOLECULE/pair_tip4p_cut.cpp index 055ac539c8..3f30122a65 100644 --- a/src/MOLECULE/pair_tip4p_cut.cpp +++ b/src/MOLECULE/pair_tip4p_cut.cpp @@ -264,7 +264,7 @@ void PairTIP4PCut::compute(int eflag, int vflag) f[iH2][1] += fH[1]; f[iH2][2] += fH[2]; - if(vflag) { + if (vflag) { xH1 = x[iH1]; xH2 = x[iH2]; v[0] = x[i][0]*fO[0] + xH1[0]*fH[0] + xH2[0]*fH[0]; diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp index 7238927367..c89afad705 100644 --- a/src/OPT/pair_eam_opt.cpp +++ b/src/OPT/pair_eam_opt.cpp @@ -116,7 +116,7 @@ void PairEAMOpt::eval() for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) { fast_alpha_t* _noalias tab = &fast_alpha[i*ntypes*nr+j*nr]; if (type2rhor[i+1][j+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor0i = rhor_spline[type2rhor[i+1][j+1]][m][6]; tab[m].rhor1i = rhor_spline[type2rhor[i+1][j+1]][m][5]; tab[m].rhor2i = rhor_spline[type2rhor[i+1][j+1]][m][4]; @@ -124,7 +124,7 @@ void PairEAMOpt::eval() } } if (type2rhor[j+1][i+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor0j = rhor_spline[type2rhor[j+1][i+1]][m][6]; tab[m].rhor1j = rhor_spline[type2rhor[j+1][i+1]][m][5]; tab[m].rhor2j = rhor_spline[type2rhor[j+1][i+1]][m][4]; @@ -139,14 +139,14 @@ void PairEAMOpt::eval() for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) { fast_gamma_t* _noalias tab = &fast_gamma[i*ntypes*nr+j*nr]; if (type2rhor[i+1][j+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor4i = rhor_spline[type2rhor[i+1][j+1]][m][2]; tab[m].rhor5i = rhor_spline[type2rhor[i+1][j+1]][m][1]; tab[m].rhor6i = rhor_spline[type2rhor[i+1][j+1]][m][0]; } } if (type2rhor[j+1][i+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].rhor4j = rhor_spline[type2rhor[j+1][i+1]][m][2]; tab[m].rhor5j = rhor_spline[type2rhor[j+1][i+1]][m][1]; tab[m].rhor6j = rhor_spline[type2rhor[j+1][i+1]][m][0]; @@ -154,7 +154,7 @@ void PairEAMOpt::eval() } } if (type2z2r[i+1][j+1] >= 0) { - for(int m = 1; m <= nr; m++) { + for (int m = 1; m <= nr; m++) { tab[m].z2r0 = z2r_spline[type2z2r[i+1][j+1]][m][6]; tab[m].z2r1 = z2r_spline[type2z2r[i+1][j+1]][m][5]; tab[m].z2r2 = z2r_spline[type2z2r[i+1][j+1]][m][4]; diff --git a/src/OPT/pair_lj_long_coul_long_opt.cpp b/src/OPT/pair_lj_long_coul_long_opt.cpp index 592f93a656..0ead71befb 100644 --- a/src/OPT/pair_lj_long_coul_long_opt.cpp +++ b/src/OPT/pair_lj_long_coul_long_opt.cpp @@ -616,7 +616,7 @@ void PairLJLongCoulLongOpt::eval() if (rsq < cut_ljsqi[typej]) { // lj if (ORDER6) { // long-range lj - if(!LJTABLE || rsq <= tabinnerdispsq) { // series real space + if (!LJTABLE || rsq <= tabinnerdispsq) { // series real space double rn = r2inv*r2inv*r2inv; double x2 = g2*rsq, a2 = 1.0/x2; x2 = a2*exp(-x2)*lj4i[typej]; diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index d738d21c5b..18047b794e 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -109,7 +109,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : FixPythonMove::~FixPythonMove() { PyGILState_STATE gstate = PyGILState_Ensure(); - if(py_move) Py_DECREF((PyObject*) py_move); + if (py_move) Py_DECREF((PyObject*) py_move); PyGILState_Release(gstate); } diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 42b1135ceb..260454d150 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -72,7 +72,7 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // With Python 3.7 this function is now called by Py_Initialize() // Deprecated since version 3.9, will be removed in version 3.11 #if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 7 - if(!PyEval_ThreadsInitialized()) { + if (!PyEval_ThreadsInitialized()) { PyEval_InitThreads(); } #endif @@ -90,7 +90,7 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) PythonImpl::~PythonImpl() { - if(pyMain) { + if (pyMain) { // clean up PyGILState_STATE gstate = PyGILState_Ensure(); diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 9f47d89097..555b9d2770 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -103,7 +103,7 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - for( int i = 0; i < atom->nmax; i++ ) + for ( int i = 0; i < atom->nmax; i++ ) for (int j = 0; j < nprev; ++j ) s_hist[i][j] = t_hist[i][j] = atom->q[i]; @@ -234,7 +234,7 @@ void FixQEq::allocate_matrix() numneigh = list->numneigh; m = 0; - for( ii = 0; ii < inum; ii++ ) { + for ( ii = 0; ii < inum; ii++ ) { i = ilist[ii]; m += numneigh[i]; } @@ -306,7 +306,7 @@ void FixQEq::init_storage() nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for( int i = 0; i < nall; i++ ) { + for ( int i = 0; i < nall; i++ ) { Hdia_inv[i] = 1. / eta[atom->type[i]]; b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; @@ -352,7 +352,7 @@ int FixQEq::CG( double *b, double *x ) vector_sum( r , 1., b, -1., q, inum ); - for( ii = 0; ii < inum; ++ii ) { + for ( ii = 0; ii < inum; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) d[i] = r[i] * Hdia_inv[i]; @@ -362,7 +362,7 @@ int FixQEq::CG( double *b, double *x ) b_norm = parallel_norm( b, inum ); sig_new = parallel_dot( r, d, inum); - for( loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop ) { + for ( loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop ) { comm->forward_comm_fix(this); sparse_matvec( &H, d, q ); comm->reverse_comm_fix(this); @@ -373,7 +373,7 @@ int FixQEq::CG( double *b, double *x ) vector_add( x, alfa, d, inum ); vector_add( r, -alfa, q, inum ); - for( ii = 0; ii < inum; ++ii ) { + for ( ii = 0; ii < inum; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) p[i] = r[i] * Hdia_inv[i]; @@ -406,19 +406,19 @@ void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for( i = 0; i < nlocal; ++i ) { + for ( i = 0; i < nlocal; ++i ) { if (atom->mask[i] & groupbit) b[i] = eta[ atom->type[i] ] * x[i]; } - for( i = nlocal; i < nall; ++i ) { + for ( i = nlocal; i < nall; ++i ) { if (atom->mask[i] & groupbit) b[i] = 0; } - for( i = 0; i < nlocal; ++i ) { + for ( i = 0; i < nlocal; ++i ) { if (atom->mask[i] & groupbit) { - for( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { + for ( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; b[i] += A->val[itr_j] * x[j]; b[j] += A->val[itr_j] * x[i]; @@ -444,12 +444,12 @@ void FixQEq::calculate_Q() t_sum = parallel_vector_acc( t, inum); u = s_sum / t_sum; - for( ii = 0; ii < inum; ++ii ) { + for ( ii = 0; ii < inum; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) { q[i] = s[i] - u * t[i]; - for( k = 4; k > 0; --k ) { + for ( k = 4; k > 0; --k ) { s_hist[i][k] = s_hist[i][k-1]; t_hist[i][k] = t_hist[i][k-1]; } @@ -470,13 +470,13 @@ int FixQEq::pack_forward_comm(int n, int *list, double *buf, int m; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = d[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = s[list[m]]; - else if( pack_flag == 3 ) - for(m = 0; m < n; m++) buf[m] = t[list[m]]; - else if( pack_flag == 4 ) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + for (m = 0; m < n; m++) buf[m] = d[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = s[list[m]]; + else if ( pack_flag == 3 ) + for (m = 0; m < n; m++) buf[m] = t[list[m]]; + else if ( pack_flag == 4 ) + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; else m = 0; return m; @@ -489,13 +489,13 @@ void FixQEq::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; - else if( pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; - else if( pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; + else if ( pack_flag == 3) + for (m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; + else if ( pack_flag == 4) + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -503,7 +503,7 @@ void FixQEq::unpack_forward_comm(int n, int first, double *buf) int FixQEq::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) buf[m] = q[i]; + for (m = 0, i = first; m < n; m++, i++) buf[m] = q[i]; return m; } @@ -513,7 +513,7 @@ void FixQEq::unpack_reverse_comm(int n, int *list, double *buf) { int m; - for(m = 0; m < n; m++) q[list[m]] += buf[m]; + for (m = 0; m < n; m++) q[list[m]] += buf[m]; } /* ---------------------------------------------------------------------- @@ -591,7 +591,7 @@ double FixQEq::parallel_norm( double *v, int n ) my_sum = 0.0; norm_sqr = 0.0; - for( ii = 0; ii < n; ++ii ) { + for ( ii = 0; ii < n; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_sum += v[i]*v[i]; @@ -616,7 +616,7 @@ double FixQEq::parallel_dot( double *v1, double *v2, int n) my_dot = 0.0; res = 0.0; - for( ii = 0; ii < n; ++ii ) { + for ( ii = 0; ii < n; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_dot += v1[i] * v2[i]; @@ -641,7 +641,7 @@ double FixQEq::parallel_vector_acc( double *v, int n ) my_acc = 0.0; res = 0.0; - for( ii = 0; ii < n; ++ii ) { + for ( ii = 0; ii < n; ++ii ) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_acc += v[i]; @@ -662,7 +662,7 @@ void FixQEq::vector_sum( double* dest, double c, double* v, ilist = list->ilist; - for( --k; k>=0; --k ) { + for ( --k; k>=0; --k ) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] = c * v[kk] + d * y[kk]; @@ -678,7 +678,7 @@ void FixQEq::vector_add( double* dest, double c, double* v, int k ) ilist = list->ilist; - for( --k; k>=0; --k ) { + for ( --k; k>=0; --k ) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] += c * v[kk]; diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index da4ef98591..6fc98410eb 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -249,9 +249,9 @@ int FixQEqDynamic::pack_forward_comm(int n, int *list, double *buf, int m=0; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = qf[list[m]]; + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; } @@ -263,9 +263,9 @@ void FixQEqDynamic::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -273,7 +273,7 @@ void FixQEqDynamic::unpack_forward_comm(int n, int first, double *buf) int FixQEqDynamic::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; + for (m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; return m; } @@ -283,7 +283,7 @@ void FixQEqDynamic::unpack_reverse_comm(int n, int *list, double *buf) { int m; - for(m = 0; m < n; m++) qf[list[m]] += buf[m]; + for (m = 0; m < n; m++) qf[list[m]] += buf[m]; } /* ---------------------------------------------------------------------- */ diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 3d0313c789..613d6998aa 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -313,9 +313,9 @@ int FixQEqFire::pack_forward_comm(int n, int *list, double *buf, int m = 0; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if( pack_flag == 2 ) - for(m = 0; m < n; m++) buf[m] = qf[list[m]]; + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + else if ( pack_flag == 2 ) + for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; } @@ -327,9 +327,9 @@ void FixQEqFire::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; - else if( pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + else if ( pack_flag == 2) + for (m = 0, i = first; m < n; m++, i++) qf[i] = buf[m]; } /* ---------------------------------------------------------------------- */ @@ -337,7 +337,7 @@ void FixQEqFire::unpack_forward_comm(int n, int first, double *buf) int FixQEqFire::pack_reverse_comm(int n, int first, double *buf) { int i, m; - for(m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; + for (m = 0, i = first; m < n; m++, i++) buf[m] = qf[i]; return m; } @@ -347,7 +347,7 @@ void FixQEqFire::unpack_reverse_comm(int n, int *list, double *buf) { int m; - for(m = 0; m < n; m++) qf[list[m]] += buf[m]; + for (m = 0; m < n; m++) qf[list[m]] += buf[m]; } /* ---------------------------------------------------------------------- */ diff --git a/src/RIGID/fix_ehex.cpp b/src/RIGID/fix_ehex.cpp index 73776d5220..a3346b3d1c 100644 --- a/src/RIGID/fix_ehex.cpp +++ b/src/RIGID/fix_ehex.cpp @@ -273,7 +273,7 @@ void FixEHEX::rescale() { vsub[1] = (scale-1.0) * vcm[1]; vsub[2] = (scale-1.0) * vcm[2]; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (scalingmask[i]) { diff --git a/src/SNAP/compute_sna_atom.cpp b/src/SNAP/compute_sna_atom.cpp index d96849915f..8e26d44f61 100644 --- a/src/SNAP/compute_sna_atom.cpp +++ b/src/SNAP/compute_sna_atom.cpp @@ -64,9 +64,9 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq @@ -74,11 +74,11 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : double cut; cutmax = 0.0; memory->create(cutsq,ntypes+1,ntypes+1,"sna/atom:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -115,7 +115,7 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_sna_atom:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute sna/atom command"); diff --git a/src/SNAP/compute_snad_atom.cpp b/src/SNAP/compute_snad_atom.cpp index 35cbb9225c..b9ab2f54ae 100644 --- a/src/SNAP/compute_snad_atom.cpp +++ b/src/SNAP/compute_snad_atom.cpp @@ -62,9 +62,9 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : rcutfac = atof(arg[3]); rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq @@ -72,11 +72,11 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : double cut; cutmax = 0.0; memory->create(cutsq,ntypes+1,ntypes+1,"sna/atom:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -113,7 +113,7 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_snad_atom:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute snad/atom command"); diff --git a/src/SNAP/compute_snap.cpp b/src/SNAP/compute_snap.cpp index 9f25fdbff9..eca832f665 100644 --- a/src/SNAP/compute_snap.cpp +++ b/src/SNAP/compute_snap.cpp @@ -68,9 +68,9 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : rcutfac = atof(arg[3]); rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq @@ -78,11 +78,11 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : double cut; cutmax = 0.0; memory->create(cutsq,ntypes+1,ntypes+1,"snap:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; if (cut > cutmax) cutmax = cut; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -119,7 +119,7 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_snap:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute snap command"); diff --git a/src/SNAP/compute_snav_atom.cpp b/src/SNAP/compute_snav_atom.cpp index 3772a92ad7..42a54e6cb1 100644 --- a/src/SNAP/compute_snav_atom.cpp +++ b/src/SNAP/compute_snav_atom.cpp @@ -61,17 +61,17 @@ ComputeSNAVAtom::ComputeSNAVAtom(LAMMPS *lmp, int narg, char **arg) : rcutfac = atof(arg[3]); rfac0 = atof(arg[4]); twojmax = atoi(arg[5]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) radelem[i+1] = atof(arg[6+i]); - for(int i = 0; i < ntypes; i++) + for (int i = 0; i < ntypes; i++) wjelem[i+1] = atof(arg[6+ntypes+i]); // construct cutsq double cut; memory->create(cutsq,ntypes+1,ntypes+1,"sna/atom:cutsq"); - for(int i = 1; i <= ntypes; i++) { + for (int i = 1; i <= ntypes; i++) { cut = 2.0*radelem[i]*rcutfac; cutsq[i][i] = cut*cut; - for(int j = i+1; j <= ntypes; j++) { + for (int j = i+1; j <= ntypes; j++) { cut = (radelem[i]+radelem[j])*rcutfac; cutsq[i][j] = cutsq[j][i] = cut*cut; } @@ -108,7 +108,7 @@ ComputeSNAVAtom::ComputeSNAVAtom(LAMMPS *lmp, int narg, char **arg) : chemflag = 1; memory->create(map,ntypes+1,"compute_sna_atom:map"); nelements = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - for(int i = 0; i < ntypes; i++) { + for (int i = 0; i < ntypes; i++) { int jelem = utils::inumeric(FLERR,arg[iarg+2+i],false,lmp); if (jelem < 0 || jelem >= nelements) error->all(FLERR,"Illegal compute snav/atom command"); diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index a7ea6de591..6240059a68 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -177,7 +177,7 @@ void PairSNAP::compute(int eflag, int vflag) for (int jj = 0; jj < ninside; jj++) { int j = snaptr->inside[jj]; - if(chemflag) + if (chemflag) snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj], snaptr->rcutij[jj],jj, snaptr->element[jj]); else @@ -344,7 +344,7 @@ void PairSNAP::compute_bispectrum() else snaptr->compute_bi(0); - for (int icoeff = 0; icoeff < ncoeff; icoeff++){ + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { bispectrum[ii][icoeff] = snaptr->blist[icoeff]; } } diff --git a/src/SNAP/sna.cpp b/src/SNAP/sna.cpp index 3c7a40c0dc..d2b423d5db 100644 --- a/src/SNAP/sna.cpp +++ b/src/SNAP/sna.cpp @@ -152,7 +152,7 @@ SNA::SNA(LAMMPS* lmp, double rfac0_in, int twojmax_in, if (bzero_flag) { double www = wself*wself*wself; - for(int j = 0; j <= twojmax; j++) + for (int j = 0; j <= twojmax; j++) if (bnorm_flag) bzero[j] = www; else @@ -187,9 +187,9 @@ void SNA::build_indexlist() "sna:idxcg_block"); int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { idxcg_block[j1][j2][j] = idxcg_count; for (int m1 = 0; m1 <= j1; m1++) for (int m2 = 0; m2 <= j2; m2++) @@ -205,10 +205,10 @@ void SNA::build_indexlist() int idxu_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { idxu_block[j] = idxu_count; - for(int mb = 0; mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) + for (int mb = 0; mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) idxu_count++; } idxu_max = idxu_count; @@ -216,18 +216,18 @@ void SNA::build_indexlist() // index list for beta and B int idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) idxb_count++; idxb_max = idxb_count; idxb = new SNA_BINDICES[idxb_max]; idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) { idxb[idxb_count].j1 = j1; idxb[idxb_count].j2 = j2; @@ -240,9 +240,9 @@ void SNA::build_indexlist() memory->create(idxb_block, jdim, jdim, jdim, "sna:idxb_block"); idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { if (j >= j1) { idxb_block[j1][j2][j] = idxb_count; idxb_count++; @@ -253,9 +253,9 @@ void SNA::build_indexlist() int idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) for (int mb = 0; 2*mb <= j; mb++) for (int ma = 0; ma <= j; ma++) idxz_count++; @@ -267,9 +267,9 @@ void SNA::build_indexlist() "sna:idxz_block"); idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { idxz_block[j1][j2][j] = idxz_count; // find right beta[jjb] entry @@ -309,7 +309,7 @@ void SNA::init() void SNA::grow_rij(int newnmax) { - if(newnmax <= nmax) return; + if (newnmax <= nmax) return; nmax = newnmax; @@ -345,7 +345,7 @@ void SNA::compute_ui(int jnum, int ielem) zero_uarraytot(ielem); - for(int j = 0; j < jnum; j++) { + for (int j = 0; j < jnum; j++) { x = rij[j][0]; y = rij[j][1]; z = rij[j][2]; @@ -375,8 +375,8 @@ void SNA::compute_zi() int idouble = 0; double * zptr_r; double * zptr_i; - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) { zptr_r = &zlist_r[idouble*idxz_max]; zptr_i = &zlist_i[idouble*idxz_max]; @@ -448,18 +448,18 @@ void SNA::compute_yi(const double* beta) double betaj; int itriple; - for(int ielem1 = 0; ielem1 < nelements; ielem1++) - for(int j = 0; j <= twojmax; j++) { + for (int ielem1 = 0; ielem1 < nelements; ielem1++) + for (int j = 0; j <= twojmax; j++) { jju = idxu_block[j]; - for(int mb = 0; 2*mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) { ylist_r[ielem1*idxu_max+jju] = 0.0; ylist_i[ielem1*idxu_max+jju] = 0.0; jju++; } // end loop over ma, mb } // end loop over j - for(int elem1 = 0; elem1 < nelements; elem1++) + for (int elem1 = 0; elem1 < nelements; elem1++) for (int elem2 = 0; elem2 < nelements; elem2++) { for (int jjz = 0; jjz < idxz_max; jjz++) { const int j1 = idxz[jjz].j1; @@ -522,7 +522,7 @@ void SNA::compute_yi(const double* beta) } jju = idxz[jjz].jju; - for(int elem3 = 0; elem3 < nelements; elem3++) { + for (int elem3 = 0; elem3 < nelements; elem3++) { // pick out right beta value if (j >= j1) { const int jjb = idxb_block[j1][j2][j]; @@ -560,22 +560,22 @@ void SNA::compute_yi(const double* beta) void SNA::compute_deidrj(double* dedr) { - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] = 0.0; int jelem = elem_duarray; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { int jju = idxu_block[j]; - for(int mb = 0; 2*mb < j; mb++) - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb < j; mb++) + for (int ma = 0; ma <= j; ma++) { double* dudr_r = dulist_r[jju]; double* dudr_i = dulist_i[jju]; double jjjmambyarray_r = ylist_r[jelem*idxu_max+jju]; double jjjmambyarray_i = ylist_i[jelem*idxu_max+jju]; - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] += dudr_r[k] * jjjmambyarray_r + dudr_i[k] * jjjmambyarray_i; @@ -587,13 +587,13 @@ void SNA::compute_deidrj(double* dedr) if (j%2 == 0) { int mb = j/2; - for(int ma = 0; ma < mb; ma++) { + for (int ma = 0; ma < mb; ma++) { double* dudr_r = dulist_r[jju]; double* dudr_i = dulist_i[jju]; double jjjmambyarray_r = ylist_r[jelem*idxu_max+jju]; double jjjmambyarray_i = ylist_i[jelem*idxu_max+jju]; - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] += dudr_r[k] * jjjmambyarray_r + dudr_i[k] * jjjmambyarray_i; @@ -605,7 +605,7 @@ void SNA::compute_deidrj(double* dedr) double jjjmambyarray_r = ylist_r[jelem*idxu_max+jju]; double jjjmambyarray_i = ylist_i[jelem*idxu_max+jju]; - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] += (dudr_r[k] * jjjmambyarray_r + dudr_i[k] * jjjmambyarray_i)*0.5; @@ -615,7 +615,7 @@ void SNA::compute_deidrj(double* dedr) } // end loop over j - for(int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) dedr[k] *= 2.0; } @@ -693,9 +693,9 @@ void SNA::compute_bi(int ielem) { } // end loop over JJ } else { int itriple = 0; - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) { - for(int elem3 = 0; elem3 < nelements; elem3++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) { + for (int elem3 = 0; elem3 < nelements; elem3++) { for (int jjb = 0; jjb < idxb_max; jjb++) { const int j = idxb[jjb].j; blist[itriple*idxb_max+jjb] -= bzero[j]; @@ -749,11 +749,11 @@ void SNA::compute_dbidrj() // set all the derivatives to zero once - for(int jjb = 0; jjb < idxb_max; jjb++) { + for (int jjb = 0; jjb < idxb_max; jjb++) { - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) - for(int elem3 = 0; elem3 < nelements; elem3++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) + for (int elem3 = 0; elem3 < nelements; elem3++) { itriple = (elem1 * nelements + elem2) * nelements + elem3; @@ -767,7 +767,7 @@ void SNA::compute_dbidrj() int elem3 = elem_duarray; - for(int jjb = 0; jjb < idxb_max; jjb++) { + for (int jjb = 0; jjb < idxb_max; jjb++) { const int j1 = idxb[jjb].j1; const int j2 = idxb[jjb].j2; const int j = idxb[jjb].j; @@ -775,8 +775,8 @@ void SNA::compute_dbidrj() // Sum terms Conj(dudr(j,ma,mb))*z(j1,j2,j,ma,mb) - for(int elem1 = 0; elem1 < nelements; elem1++) - for(int elem2 = 0; elem2 < nelements; elem2++) { + for (int elem1 = 0; elem1 < nelements; elem1++) + for (int elem2 = 0; elem2 < nelements; elem2++) { jjz = idxz_block[j1][j2][j]; jju = idxu_block[j]; @@ -975,7 +975,7 @@ void SNA::compute_duidrj(double* rij, double wj, double rcut, int jj, int jelem) void SNA::zero_uarraytot(int ielem) { - for(int jelem = 0; jelem < nelements; jelem++) + for (int jelem = 0; jelem < nelements; jelem++) for (int j = 0; j <= twojmax; j++) { int jju = idxu_block[j]; for (int mb = 0; mb <= j; mb++) { @@ -1389,9 +1389,9 @@ void SNA::init_clebsch_gordan() int ifac; int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { for (int m1 = 0; m1 <= j1; m1++) { aa2 = 2 * m1 - j1; @@ -1402,7 +1402,7 @@ void SNA::init_clebsch_gordan() bb2 = 2 * m2 - j2; m = (aa2 + bb2 + j) / 2; - if(m < 0 || m > j) { + if (m < 0 || m > j) { cglist[idxcg_count] = 0.0; idxcg_count++; continue; @@ -1516,8 +1516,8 @@ double SNA::compute_sfac(double r, double rcut) { if (switch_flag == 0) return 1.0; if (switch_flag == 1) { - if(r <= rmin0) return 1.0; - else if(r > rcut) return 0.0; + if (r <= rmin0) return 1.0; + else if (r > rcut) return 0.0; else { double rcutfac = MY_PI / (rcut - rmin0); return 0.5 * (cos((r - rmin0) * rcutfac) + 1.0); @@ -1532,8 +1532,8 @@ double SNA::compute_dsfac(double r, double rcut) { if (switch_flag == 0) return 0.0; if (switch_flag == 1) { - if(r <= rmin0) return 0.0; - else if(r > rcut) return 0.0; + if (r <= rmin0) return 0.0; + else if (r > rcut) return 0.0; else { double rcutfac = MY_PI / (rcut - rmin0); return -0.5 * sin((r - rmin0) * rcutfac) * rcutfac; diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 6d4ff8bedd..30a18fb301 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -323,13 +323,13 @@ void FixNVESpin::initial_integrate(int /*vflag*/) } } else if (sector_flag == 0) { // serial seq. update comm->forward_comm(); // comm. positions of ghost atoms - for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal + for (int i = 0; i < nlocal; i++) { // advance quarter s for nlocal if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } } - for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal + for (int i = nlocal-1; i >= 0; i--) { // advance quarter s for nlocal if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); @@ -376,13 +376,13 @@ void FixNVESpin::initial_integrate(int /*vflag*/) } } else if (sector_flag == 0) { // serial seq. update comm->forward_comm(); // comm. positions of ghost atoms - for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal-1 + for (int i = 0; i < nlocal; i++) { // advance quarter s for nlocal-1 if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } } - for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal-1 + for (int i = nlocal-1; i >= 0; i--) { // advance quarter s for nlocal-1 if (mask[i] & groupbit) { ComputeInteractionsSpin(i); AdvanceSingleSpin(i); diff --git a/src/SPIN/min_spin_cg.cpp b/src/SPIN/min_spin_cg.cpp index 094986dc7b..de2bd5c3ae 100644 --- a/src/SPIN/min_spin_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -103,7 +103,7 @@ void MinSpinCG::init() // set back use_line_search to 0 if more than one replica - if (linestyle == 3 && nreplica == 1){ + if (linestyle == 3 && nreplica == 1) { use_line_search = 1; } else{ @@ -208,7 +208,7 @@ int MinSpinCG::iterate(int maxiter) if (use_line_search) { // here we need to do line search - if (local_iter == 0){ + if (local_iter == 0) { calc_gradient(); } @@ -344,7 +344,7 @@ void MinSpinCG::calc_search_direction() factor = 0.0; - if (local_iter == 0 || local_iter % 5 == 0){ // steepest descent direction + if (local_iter == 0 || local_iter % 5 == 0) { // steepest descent direction for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = -g_cur[i] * factor; g_old[i] = g_cur[i] * factor; @@ -425,12 +425,12 @@ void MinSpinCG::rodrigues_rotation(const double *upp_tr, double *out) if (fabs(upp_tr[0]) < 1.0e-40 && fabs(upp_tr[1]) < 1.0e-40 && - fabs(upp_tr[2]) < 1.0e-40){ + fabs(upp_tr[2]) < 1.0e-40) { // if upp_tr is zero, return unity matrix - for(int k = 0; k < 3; k++){ - for(int m = 0; m < 3; m++){ + for (int k = 0; k < 3; k++) { + for (int m = 0; m < 3; m++) { if (m == k) out[3 * k + m] = 1.0; else out[3 * k + m] = 0.0; } @@ -481,9 +481,9 @@ void MinSpinCG::rodrigues_rotation(const double *upp_tr, double *out) void MinSpinCG::vm3(const double *m, const double *v, double *out) { - for(int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { out[i] = 0.0; - for(int j = 0; j < 3; j++) out[i] += *(m + 3 * j + i) * v[j]; + for (int j = 0; j < 3; j++) out[i] += *(m + 3 * j + i) * v[j]; } } @@ -550,7 +550,7 @@ int MinSpinCG::calc_and_make_step(double a, double b, int index) der_e_cur = e_and_d[1]; index++; - if (adescent(eprevious,e_and_d[0]) || index == 5){ + if (adescent(eprevious,e_and_d[0]) || index == 5) { MPI_Bcast(&b,1,MPI_DOUBLE,0,world); for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = b * p_s[i]; @@ -590,7 +590,7 @@ int MinSpinCG::calc_and_make_step(double a, double b, int index) Approximate descent ------------------------------------------------------------------------- */ -int MinSpinCG::adescent(double phi_0, double phi_j){ +int MinSpinCG::adescent(double phi_0, double phi_j) { double eps = 1.0e-6; diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index b11cdf16f3..1f8d72664d 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -108,7 +108,7 @@ void MinSpinLBFGS::init() // set back use_line_search to 0 if more than one replica - if (linestyle == 3 && nreplica == 1){ + if (linestyle == 3 && nreplica == 1) { use_line_search = 1; } else{ @@ -221,7 +221,7 @@ int MinSpinLBFGS::iterate(int maxiter) if (use_line_search) { // here we need to do line search - if (local_iter == 0){ + if (local_iter == 0) { eprevious = ecurrent; ecurrent = energy_force(0); calc_gradient(); @@ -370,7 +370,7 @@ void MinSpinLBFGS::calc_search_direction() factor = 1.0; } - if (local_iter == 0){ // steepest descent direction + if (local_iter == 0) { // steepest descent direction //if no line search then calculate maximum rotation if (use_line_search == 0) @@ -379,7 +379,7 @@ void MinSpinLBFGS::calc_search_direction() for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = -g_cur[i] * factor * scaling;; g_old[i] = g_cur[i] * factor; - for (int k = 0; k < num_mem; k++){ + for (int k = 0; k < num_mem; k++) { ds[k][i] = 0.0; dy[k][i] = 0.0; } @@ -405,7 +405,7 @@ void MinSpinLBFGS::calc_search_direction() if (fabs(dyds_global) > 1.0e-60) rho[m_index] = 1.0 / dyds_global; else rho[m_index] = 1.0e60; - if (rho[m_index] < 0.0){ + if (rho[m_index] < 0.0) { local_iter = 0; return calc_search_direction(); } @@ -418,7 +418,7 @@ void MinSpinLBFGS::calc_search_direction() } // loop over last m indecies - for(int k = num_mem - 1; k > -1; k--) { + for (int k = num_mem - 1; k > -1; k--) { // this loop should run from the newest memory to the oldest one. c_ind = (k + m_index + 1) % num_mem; @@ -473,7 +473,7 @@ void MinSpinLBFGS::calc_search_direction() } } - for (int k = 0; k < num_mem; k++){ + for (int k = 0; k < num_mem; k++) { // this loop should run from the oldest memory to the newest one. if (local_iter < num_mem) c_ind = k; @@ -551,11 +551,11 @@ void MinSpinLBFGS::rodrigues_rotation(const double *upp_tr, double *out) if (fabs(upp_tr[0]) < 1.0e-40 && fabs(upp_tr[1]) < 1.0e-40 && - fabs(upp_tr[2]) < 1.0e-40){ + fabs(upp_tr[2]) < 1.0e-40) { // if upp_tr is zero, return unity matrix - for(int k = 0; k < 3; k++){ - for(int m = 0; m < 3; m++){ + for (int k = 0; k < 3; k++) { + for (int m = 0; m < 3; m++) { if (m == k) out[3 * k + m] = 1.0; else out[3 * k + m] = 0.0; } @@ -606,9 +606,9 @@ void MinSpinLBFGS::rodrigues_rotation(const double *upp_tr, double *out) void MinSpinLBFGS::vm3(const double *m, const double *v, double *out) { - for(int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { out[i] = 0.0; - for(int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) out[i] += *(m + 3 * j + i) * v[j]; } } @@ -673,7 +673,7 @@ int MinSpinLBFGS::calc_and_make_step(double a, double b, int index) der_e_cur = e_and_d[1]; index++; - if (adescent(eprevious,e_and_d[0]) || index == 5){ + if (adescent(eprevious,e_and_d[0]) || index == 5) { MPI_Bcast(&b,1,MPI_DOUBLE,0,world); for (int i = 0; i < 3 * nlocal; i++) { p_s[i] = b * p_s[i]; @@ -713,7 +713,7 @@ int MinSpinLBFGS::calc_and_make_step(double a, double b, int index) Approximate descent ------------------------------------------------------------------------- */ -int MinSpinLBFGS::adescent(double phi_0, double phi_j){ +int MinSpinLBFGS::adescent(double phi_0, double phi_j) { double eps = 1.0e-6; diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index 2aa1b7f84d..cbb495db8e 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -242,7 +242,7 @@ void NEBSpin::run() timer->init(); timer->barrier_start(); - // if(ireplica != 0 && ireplica != nreplica -1) + // if (ireplica != 0 && ireplica != nreplica -1) while (update->minimize->niter < n1steps) { update->minimize->run(nevery); diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index dfccfe4c92..d8c5ef2cee 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -993,7 +993,7 @@ void FixSRD::reset_velocities() if (shifts[shiftflag].commflag) xbin_comm(shiftflag,1); if (tstat) { - for (i = 0; i < nbins; i++){ + for (i = 0; i < nbins; i++) { n = vbin[i].n; if (n <= 1) continue; @@ -1034,7 +1034,7 @@ void FixSRD::reset_velocities() if (shifts[shiftflag].commflag) xbin_comm(shiftflag,1); } - for (i = 0; i < nbins; i++){ + for (i = 0; i < nbins; i++) { if (vbin[i].owner) { if (vbin[i].n > 1) { srd_bin_temp += vbin[i].value[0]/(vbin[i].n-dof_temp); diff --git a/src/USER-ADIOS/dump_atom_adios.cpp b/src/USER-ADIOS/dump_atom_adios.cpp index e08485b0fa..5d4bbd2377 100644 --- a/src/USER-ADIOS/dump_atom_adios.cpp +++ b/src/USER-ADIOS/dump_atom_adios.cpp @@ -39,7 +39,7 @@ class DumpAtomADIOSInternal { public: - DumpAtomADIOSInternal(){}; + DumpAtomADIOSInternal() {}; ~DumpAtomADIOSInternal() = default; // name of adios group, referrable in adios2_config.xml diff --git a/src/USER-ADIOS/dump_custom_adios.cpp b/src/USER-ADIOS/dump_custom_adios.cpp index 8fbce9f847..18a3c7ef9e 100644 --- a/src/USER-ADIOS/dump_custom_adios.cpp +++ b/src/USER-ADIOS/dump_custom_adios.cpp @@ -110,7 +110,7 @@ class DumpCustomADIOSInternal { public: - DumpCustomADIOSInternal(){}; + DumpCustomADIOSInternal() {}; ~DumpCustomADIOSInternal() = default; // name of adios group, referrable in adios2_config.xml diff --git a/src/USER-ADIOS/reader_adios.cpp b/src/USER-ADIOS/reader_adios.cpp index 2acf6dedfa..5cb0cb12ea 100644 --- a/src/USER-ADIOS/reader_adios.cpp +++ b/src/USER-ADIOS/reader_adios.cpp @@ -50,7 +50,7 @@ class ReadADIOSInternal { public: - ReadADIOSInternal(){}; + ReadADIOSInternal() {}; ~ReadADIOSInternal() = default; // name of adios group, referrable in adios2_config.xml diff --git a/src/USER-ATC/fix_atc.cpp b/src/USER-ATC/fix_atc.cpp index cf7339c75d..82fbfcc958 100644 --- a/src/USER-ATC/fix_atc.cpp +++ b/src/USER-ATC/fix_atc.cpp @@ -669,7 +669,7 @@ void FixATC::unpack_forward_comm(int n, int first, double *buf) pack values in local atom-based arrays for restart file ------------------------------------------------------------------------- */ -int FixATC::pack_restart(int /* i */, double * /* buf */){ +int FixATC::pack_restart(int /* i */, double * /* buf */) { return 0; } @@ -677,14 +677,14 @@ int FixATC::pack_restart(int /* i */, double * /* buf */){ unpack values from atom->extra array to restart the fix ------------------------------------------------------------------------- */ -void FixATC::unpack_restart(int /* nlocal */, int /* nth */){ +void FixATC::unpack_restart(int /* nlocal */, int /* nth */) { } /* ---------------------------------------------------------------------- maxsize of any atom's restart data ------------------------------------------------------------------------- */ -int FixATC::maxsize_restart(){ +int FixATC::maxsize_restart() { return 0; } @@ -692,7 +692,7 @@ int FixATC::maxsize_restart(){ size of atom nlocal's restart data ------------------------------------------------------------------------- */ -int FixATC::size_restart(int /* nlocal */){ +int FixATC::size_restart(int /* nlocal */) { return 0; } @@ -700,7 +700,7 @@ int FixATC::size_restart(int /* nlocal */){ pack entire state of Fix into one write ------------------------------------------------------------------------- */ -void FixATC::write_restart(FILE * /* fp */){ +void FixATC::write_restart(FILE * /* fp */) { char ** args = new char*[2]; args[0] = new char[50]; @@ -722,7 +722,7 @@ void FixATC::write_restart(FILE * /* fp */){ use state info from restart file to restart the Fix ------------------------------------------------------------------------- */ -void FixATC::restart(char * /* buf */){ +void FixATC::restart(char * /* buf */) { char ** args = new char*[2]; args[0] = new char[50]; diff --git a/src/USER-AWPMD/fix_nve_awpmd.cpp b/src/USER-AWPMD/fix_nve_awpmd.cpp index 2b837b8905..bd2668da09 100644 --- a/src/USER-AWPMD/fix_nve_awpmd.cpp +++ b/src/USER-AWPMD/fix_nve_awpmd.cpp @@ -96,7 +96,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */) if (mask[i] & groupbit) { double dtfm = dtf / mass[type[i]]; double dtfmr=dtfm; - for(int j=0;j<3;j++){ + for (int j=0;j<3;j++) { x[i][j] += dtv*vforce[i][j]; v[i][j] += dtfm*f[i][j]; } @@ -109,7 +109,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */) /* ---------------------------------------------------------------------- */ -void FixNVEAwpmd::final_integrate(){} +void FixNVEAwpmd::final_integrate() {} /* ---------------------------------------------------------------------- */ diff --git a/src/USER-AWPMD/pair_awpmd_cut.cpp b/src/USER-AWPMD/pair_awpmd_cut.cpp index c714f4e8ab..19bb06ad87 100644 --- a/src/USER-AWPMD/pair_awpmd_cut.cpp +++ b/src/USER-AWPMD/pair_awpmd_cut.cpp @@ -82,21 +82,21 @@ PairAWPMDCut::~PairAWPMDCut() struct cmp_x{ double **xx; double tol; - cmp_x(double **xx_=nullptr, double tol_=1e-12):xx(xx_),tol(tol_){} + cmp_x(double **xx_=nullptr, double tol_=1e-12):xx(xx_),tol(tol_) {} bool operator()(const pair &left, const pair &right) const { - if(left.first==right.first){ + if (left.first==right.first) { double d=xx[left.second][0]-xx[right.second][0]; - if(d<-tol) + if (d<-tol) return true; - else if(d>tol) + else if (d>tol) return false; d=xx[left.second][1]-xx[right.second][1]; - if(d<-tol) + if (d<-tol) return true; - else if(d>tol) + else if (d>tol) return false; d=xx[left.second][2]-xx[right.second][2]; - if(d<-tol) + if (d<-tol) return true; else return false; @@ -139,7 +139,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) // width pbc - if(width_pbc<0) + if (width_pbc<0) wpmd->Lextra=2*half_box_length; else wpmd->Lextra=width_pbc; @@ -163,7 +163,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; j &= NEIGHMASK; - if(j>=nlocal){ // this is a ghost + if (j>=nlocal) { // this is a ghost Vector_3 rj=Vector_3(x[j][0],x[j][1],x[j][2]); int jtype = type[j]; double rsq=(ri-rj).norm2(); @@ -186,9 +186,9 @@ void PairAWPMDCut::compute(int eflag, int vflag) // local particles are all there idmap[make_pair(atom->tag[i],i)]=i; bool i_local= i res=idmap.insert(make_pair(make_pair(atom->tag[j],j),j)); bool have_it=!res.second; - if(have_it){ // the clone of this particle is already listed - if(res.first->second!=j) // check that was not the very same particle + if (have_it) { // the clone of this particle is already listed + if (res.first->second!=j) // check that was not the very same particle gmap[j]=-1; // filter out continue; } bool j_local= jadd_ion(q[i], Vector_3(x[i][0],x[i][1],x[i][2]),itag[i] : -atom->tag[i]); - else if(spin[i]==1 || spin[i]==-1){ // electron, sort them according to the tag + else if (spin[i]==1 || spin[i]==-1) { // electron, sort them according to the tag etmap[etag[i]].push_back(i); } else @@ -242,19 +242,19 @@ void PairAWPMDCut::compute(int eflag, int vflag) } // ion force vector Vector_3 *fi=nullptr; - if(wpmd->ni) + if (wpmd->ni) fi= new Vector_3[wpmd->ni]; // adding electrons - for(map >::iterator it=etmap.begin(); it!= etmap.end(); ++it){ + for (map >::iterator it=etmap.begin(); it!= etmap.end(); ++it) { vector &el=it->second; - if(!el.size()) // should not happen + if (!el.size()) // should not happen continue; int s=spin[el[0]] >0 ? 0 : 1; wpmd->add_electron(s); // starts adding the spits - for(size_t k=0;kall(FLERR,logfmt("WP splits for one electron should have the same spin (at particles %d, %d)!",el[0],i)); double m= atom->mass ? atom->mass[type[i]] : force->e_mass; Vector_3 xx=Vector_3(x[i][0],x[i][1],x[i][2]); @@ -275,7 +275,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) // get forces from the AWPMD solver object for (int ii = 0; ii < inum; ii++) { int i = ilist[ii]; - if(gmap[i]<0) // this particle was filtered out + if (gmap[i]<0) // this particle was filtered out continue; if (spin[i]==0) { // this is an ion, copying forces int ion=gmap[i]; @@ -289,12 +289,12 @@ void PairAWPMDCut::compute(int eflag, int vflag) } } - if(fi) + if (fi) delete [] fi; // update LAMMPS energy if (eflag_either) { - if (eflag_global){ + if (eflag_global) { eng_coul+= wpmd->get_energy(); // pvector = [KE, Pauli, ecoul, radial_restraint] pvector[0] = wpmd->Ee[0]+wpmd->Ee[1]; @@ -405,7 +405,7 @@ void PairAWPMDCut::allocate() // [flex_press] -- set flexible pressure flag // -1 for length means default setting (L/2 for cutoff and L for width PBC) -void PairAWPMDCut::settings(int narg, char **arg){ +void PairAWPMDCut::settings(int narg, char **arg) { if (narg < 1) error->all(FLERR,"Illegal pair_style command"); cut_global = utils::numeric(FLERR,arg[0],false,lmp); @@ -413,46 +413,46 @@ void PairAWPMDCut::settings(int narg, char **arg){ ermscale=1.; width_pbc=0.; - for(int i=1;iapprox=AWPMD::HARTREE; - else if(!strcmp(arg[i],"dproduct")) + else if (!strcmp(arg[i],"dproduct")) wpmd->approx=AWPMD::DPRODUCT; - else if(!strcmp(arg[i],"uhf")) + else if (!strcmp(arg[i],"uhf")) wpmd->approx=AWPMD::UHF; - else if(!strcmp(arg[i],"free")) + else if (!strcmp(arg[i],"free")) wpmd->constraint=AWPMD::NONE; - else if(!strcmp(arg[i],"fix")){ + else if (!strcmp(arg[i],"fix")) { wpmd->constraint=AWPMD::FIX; i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'fix' should be followed by a number in awpmd/cut"); wpmd->w0=utils::numeric(FLERR,arg[i],false,lmp); } - else if(!strcmp(arg[i],"harm")){ + else if (!strcmp(arg[i],"harm")) { wpmd->constraint=AWPMD::HARM; i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'harm' should be followed by a number in awpmd/cut"); wpmd->w0=utils::numeric(FLERR,arg[i],false,lmp); wpmd->set_harm_constr(wpmd->w0); } - else if(!strcmp(arg[i],"pbc")){ + else if (!strcmp(arg[i],"pbc")) { i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'pbc' should be followed by a number in awpmd/cut"); width_pbc=utils::numeric(FLERR,arg[i],false,lmp); } - else if(!strcmp(arg[i],"relax")) + else if (!strcmp(arg[i],"relax")) wpmd->constraint=AWPMD::RELAX; - else if(!strcmp(arg[i],"ermscale")){ + else if (!strcmp(arg[i],"ermscale")) { i++; - if(i>=narg) + if (i>=narg) error->all(FLERR,"Setting 'ermscale' should be followed by a number in awpmd/cut"); ermscale=utils::numeric(FLERR,arg[i],false,lmp); } - else if(!strcmp(arg[i],"flex_press")) + else if (!strcmp(arg[i],"flex_press")) flexible_pressure_flag = 1; } } @@ -472,7 +472,7 @@ void PairAWPMDCut::coeff(int narg, char **arg) double delz = domain->boxhi[2]-domain->boxlo[2]; half_box_length = 0.5 * MIN(delx, MIN(dely, delz)); //} - if(cut_global<0) + if (cut_global<0) cut_global=half_box_length; if (!allocated) { @@ -517,7 +517,7 @@ void PairAWPMDCut::init_style() "q, spin, eradius, erforce"); /* - if(vflag_atom){ // can't compute virial per atom + if (vflag_atom) { // can't compute virial per atom //warning-> error->all(FLERR,"Pair style awpmd can't compute per atom virials"); }*/ @@ -550,7 +550,7 @@ void PairAWPMDCut::init_style() int irequest = neighbor->request(this,instance_me); neighbor->requests[irequest]->newton = 2; - if(force->e_mass==0. || force->hhmrr2e==0. || force->mvh2r==0.) + if (force->e_mass==0. || force->hhmrr2e==0. || force->mvh2r==0.) error->all(FLERR,"Pair style awpmd requires e_mass and conversions hhmrr2e, mvh2r to be properly set for unit system"); wpmd->me=force->e_mass; @@ -685,7 +685,7 @@ void PairAWPMDCut::min_xf_get(int /* ignore */) if (spin[i]) { min_var[7*i] = log(eradius[i]); min_varforce[7*i] = eradius[i]*erforce[i]; - for(int j=0;j<3;j++){ + for (int j=0;j<3;j++) { min_var[7*i+1+3*j] = v[i][j]; min_varforce[7*i+1+3*j] = vforce[i][j]; } @@ -697,7 +697,7 @@ void PairAWPMDCut::min_xf_get(int /* ignore */) min_varforce[7*i+6] = csforce[i][1]; } else { - for(int j=0;j<7;j++) + for (int j=0;j<7;j++) min_var[7*i+j] = min_varforce[7*i+j] = 0.0; } } @@ -717,9 +717,9 @@ void PairAWPMDCut::min_x_set(int /* ignore */) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (spin[i]){ + if (spin[i]) { eradius[i]=exp(min_var[7*i]); - for(int j=0;j<3;j++) + for (int j=0;j<3;j++) v[i][j]=min_var[7*i+1+3*j]; ervel[i]=min_var[7*i+4]; cs[i][0]=min_var[7*i+5]; diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index b3cf98a8f5..6a984edf60 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -804,7 +804,7 @@ int FixBocs::build_cubic_splines(double **data) double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z; // 2020-07-17 ag: // valgrind says that we read/write a[n] down in the - // for(int j=n-1; j>=0; j--) loop below + // for (int j=n-1; j>=0; j--) loop below // and I agree. // So the size of a must be n+1, not n as was found // in the original code. @@ -858,7 +858,7 @@ int FixBocs::build_cubic_splines(double **data) c[n] = 0.0; d[n] = 0.0; - for(int j=n-1; j>=0; j--) + for (int j=n-1; j>=0; j--) { c[j] = z[j] - mu[j]*c[j+1]; diff --git a/src/USER-COLVARS/group_ndx.cpp b/src/USER-COLVARS/group_ndx.cpp index c5f40c41e5..96c3663ca0 100644 --- a/src/USER-COLVARS/group_ndx.cpp +++ b/src/USER-COLVARS/group_ndx.cpp @@ -115,7 +115,7 @@ static void write_group(FILE *fp, int gid, Atom *atom, Group *group, int me, if (me == 0) { int i, j; - for(i=0, j=0; i < num; ++i) { + for (i=0, j=0; i < num; ++i) { fprintf(fp,fmt,recvlist[i]); ++j; if (j == cols) { diff --git a/src/USER-DIFFRACTION/compute_saed.cpp b/src/USER-DIFFRACTION/compute_saed.cpp index b0c52b06fc..a241d084be 100644 --- a/src/USER-DIFFRACTION/compute_saed.cpp +++ b/src/USER-DIFFRACTION/compute_saed.cpp @@ -79,11 +79,11 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : // Define atom types for atomic scattering factor coefficients int iarg = 4; ztype = new int[ntypes]; - for (int i = 0; i < ntypes; i++){ + for (int i = 0; i < ntypes; i++) { ztype[i] = SAEDmaxType + 1; } for (int i=0; iprd; - if (periodicity[0]){ + if (periodicity[0]) { prd_inv[0] = 1 / prd[0]; ave_inv += prd_inv[0]; } - if (periodicity[1]){ + if (periodicity[1]) { prd_inv[1] = 1 / prd[1]; ave_inv += prd_inv[1]; } - if (periodicity[2]){ + if (periodicity[2]) { prd_inv[2] = 1 / prd[2]; ave_inv += prd_inv[2]; } // Using the average inverse dimensions for non-periodic direction ave_inv = ave_inv / (periodicity[0] + periodicity[1] + periodicity[2]); - if (!periodicity[0]){ + if (!periodicity[0]) { prd_inv[0] = ave_inv; } - if (!periodicity[1]){ + if (!periodicity[1]) { prd_inv[1] = ave_inv; } - if (!periodicity[2]){ + if (!periodicity[2]) { prd_inv[2] = ave_inv; } } @@ -213,7 +213,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -293,7 +293,7 @@ void ComputeSAED::init() int n = 0; // Zone 0 0 0 flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -452,16 +452,16 @@ void ComputeSAED::compute_vector() // Calculate the atomic structure factor by type // determining parameter set to use based on S = sin(theta)/lambda <> 2 - for (int ii = 0; ii < ntypes; ii++){ + for (int ii = 0; ii < ntypes; ii++) { f[ii] = 0; - for (int C = 0; C < 5; C++){ + for (int C = 0; C < 5; C++) { int D = C + offset; f[ii] += ASFSAED[ztype[ii]][D] * exp(-1*ASFSAED[ztype[ii]][5+D] * SinTheta_lambda * SinTheta_lambda); } } // Evaluate the structure factor equation -- looping over all atoms - for (int ii = 0; ii < nlocalgroup; ii++){ + for (int ii = 0; ii < nlocalgroup; ii++) { typei=typelocal[ii]-1; inners = 2 * MY_PI * (K[0] * xlocal[3*ii+0] + K[1] * xlocal[3*ii+1] + K[2] * xlocal[3*ii+2]); diff --git a/src/USER-DIFFRACTION/compute_xrd.cpp b/src/USER-DIFFRACTION/compute_xrd.cpp index c168b032ca..3d3bc17c74 100644 --- a/src/USER-DIFFRACTION/compute_xrd.cpp +++ b/src/USER-DIFFRACTION/compute_xrd.cpp @@ -80,11 +80,11 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : // Define atom types for atomic scattering factor coefficients int iarg = 4; ztype = new int[ntypes]; - for (int i = 0; i < ntypes; i++){ + for (int i = 0; i < ntypes; i++) { ztype[i] = XRDmaxType + 1; } for (int i = 0; i < ntypes; i++) { - for(int j = 0; j < XRDmaxType; j++){ + for (int j = 0; j < XRDmaxType; j++) { if (strcasecmp(arg[iarg],XRDtypeList[j]) == 0) { ztype[i] = j; } @@ -109,7 +109,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal Compute XRD Command"); Min2Theta = atof(arg[iarg+1]) / 2; Max2Theta = atof(arg[iarg+2]) / 2; - if (Max2Theta > MY_PI ){ + if (Max2Theta > MY_PI ) { Min2Theta = Min2Theta * MY_PI / 180; // converting to radians if necessary Max2Theta = Max2Theta * MY_PI / 180; radflag = 0; @@ -162,28 +162,28 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : double ave_inv = 0.0; prd = domain->prd; - if (periodicity[0]){ + if (periodicity[0]) { prd_inv[0] = 1 / prd[0]; ave_inv += prd_inv[0]; } - if (periodicity[1]){ + if (periodicity[1]) { prd_inv[1] = 1 / prd[1]; ave_inv += prd_inv[1]; } - if (periodicity[2]){ + if (periodicity[2]) { prd_inv[2] = 1 / prd[2]; ave_inv += prd_inv[2]; } // Using the average inverse dimensions for non-periodic direction ave_inv = ave_inv / (periodicity[0] + periodicity[1] + periodicity[2]); - if (!periodicity[0]){ + if (!periodicity[0]) { prd_inv[0] = ave_inv; } - if (!periodicity[1]){ + if (!periodicity[1]) { prd_inv[1] = ave_inv; } - if (!periodicity[2]){ + if (!periodicity[2]) { prd_inv[2] = ave_inv; } } @@ -261,7 +261,7 @@ void ComputeXRD::init() double ang = 0.0; double convf = 360 / MY_PI; - if (radflag ==1){ + if (radflag ==1) { convf = 1; } @@ -400,16 +400,16 @@ void ComputeXRD::compute_array() Fatom2 = 0.0; // Calculate the atomic structure factor by type - for (int ii = 0; ii < ntypes; ii++){ + for (int ii = 0; ii < ntypes; ii++) { f[ii] = 0; - for (int C = 0; C < 8 ; C+=2){ + for (int C = 0; C < 8 ; C+=2) { f[ii] += ASFXRD[ztype[ii]][C] * exp(-1 * ASFXRD[ztype[ii]][C+1] * SinTheta_lambda * SinTheta_lambda ); } f[ii] += ASFXRD[ztype[ii]][8]; } // Evaluate the structure factor equation -- looping over all atoms - for (int ii = 0; ii < nlocalgroup; ii++){ + for (int ii = 0; ii < nlocalgroup; ii++) { typei=typelocal[ii]-1; inners = 2 * MY_PI * (K[0] * xlocal[3*ii] + K[1] * xlocal[3*ii+1] + K[2] * xlocal[3*ii+2]); @@ -456,16 +456,16 @@ void ComputeXRD::compute_array() Fatom2 = 0.0; // Calculate the atomic structure factor by type - for (int ii = 0; ii < ntypes; ii++){ + for (int ii = 0; ii < ntypes; ii++) { f[ii] = 0; - for (int C = 0; C < 8 ; C+=2){ + for (int C = 0; C < 8 ; C+=2) { f[ii] += ASFXRD[ztype[ii]][C] * exp(-1 * ASFXRD[ztype[ii]][C+1] * SinTheta_lambda * SinTheta_lambda ); } f[ii] += ASFXRD[ztype[ii]][8]; } // Evaluate the structure factor equation -- looping over all atoms - for (int ii = 0; ii < nlocalgroup; ii++){ + for (int ii = 0; ii < nlocalgroup; ii++) { typei=typelocal[ii]-1; inners = 2 * MY_PI * (K[0] * xlocal[3*ii] + K[1] * xlocal[3*ii+1] + K[2] * xlocal[3*ii+2]); diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.cpp b/src/USER-DIFFRACTION/fix_saed_vtk.cpp index e5480bfd33..0791b25aaa 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.cpp +++ b/src/USER-DIFFRACTION/fix_saed_vtk.cpp @@ -56,7 +56,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : nvalues = 0; int iarg = 6; while (iarg < narg) { - if (strncmp(arg[iarg],"c_",2) == 0){ + if (strncmp(arg[iarg],"c_",2) == 0) { nvalues++; iarg++; } else break; @@ -153,7 +153,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // SAED specific paramaters needed int *periodicity = domain->periodicity; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { } else { R_Ewald = (1 / lambda); double Rnorm = R_Ewald/ sqrt(Zone[0] * Zone[0] + @@ -167,28 +167,28 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : double ave_inv = 0.0; prd = domain->prd; - if (periodicity[0]){ + if (periodicity[0]) { prd_inv[0] = 1 / prd[0]; ave_inv += prd_inv[0]; } - if (periodicity[1]){ + if (periodicity[1]) { prd_inv[1] = 1 / prd[1]; ave_inv += prd_inv[1]; } - if (periodicity[2]){ + if (periodicity[2]) { prd_inv[2] = 1 / prd[2]; ave_inv += prd_inv[2]; } // Using the average inverse dimensions for non-periodic direction ave_inv = ave_inv / (periodicity[0] + periodicity[1] + periodicity[2]); - if (!periodicity[0]){ + if (!periodicity[0]) { prd_inv[0] = ave_inv; } - if (!periodicity[1]){ + if (!periodicity[1]) { prd_inv[1] = ave_inv; } - if (!periodicity[2]){ + if (!periodicity[2]) { prd_inv[2] = ave_inv; } @@ -200,7 +200,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : } // Find integer dimensions of the reciprocal lattice box bounds - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int i=0; i<3; i++) { dK[i] = prd_inv[i]*c[i]; Knmax[i] = ceil(Kmax / dK[i]); @@ -233,7 +233,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ){ + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { if ( i < Knmin[0] ) Knmin[0] = i; if ( j < Knmin[1] ) Knmin[1] = j; @@ -251,7 +251,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // Finding dimensions for vtk files for (int i=0; i<3; i++) { - if ( ( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) ) ){ + if ( ( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) ) ) { Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ); } else Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ) + 1; } @@ -452,7 +452,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ){ + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { for (int k = Knmin[2]; k <= Knmax[2]; k++) { for (int j = Knmin[1]; j <= Knmax[1]; j++) { for (int i = Knmin[0]; i <= Knmax[0]; i++) { @@ -485,7 +485,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ){ + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { fprintf(fp,"%g\n",vector_total[NROW1]/norm); fflush(fp); NROW2++; diff --git a/src/USER-DPD/compute_dpd.cpp b/src/USER-DPD/compute_dpd.cpp index e92be891f1..437d4c9bc6 100644 --- a/src/USER-DPD/compute_dpd.cpp +++ b/src/USER-DPD/compute_dpd.cpp @@ -66,8 +66,8 @@ void ComputeDpd::compute_vector() for (int i = 0; i < size_vector; i++) dpdU[i] = 0.0; - for (int i = 0; i < nlocal; i++){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { dpdU[0] += uCond[i]; dpdU[1] += uMech[i]; dpdU[2] += uChem[i]; diff --git a/src/USER-DPD/compute_dpd_atom.cpp b/src/USER-DPD/compute_dpd_atom.cpp index ae6b6217a3..8b203b4c0b 100644 --- a/src/USER-DPD/compute_dpd_atom.cpp +++ b/src/USER-DPD/compute_dpd_atom.cpp @@ -81,8 +81,8 @@ void ComputeDpdAtom::compute_peratom() array_atom = dpdAtom; } - for (int i = 0; i < nlocal; i++){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { dpdAtom[i][0] = uCond[i]; dpdAtom[i][1] = uMech[i]; dpdAtom[i][2] = uChem[i]; diff --git a/src/USER-DPD/fix_dpd_energy.cpp b/src/USER-DPD/fix_dpd_energy.cpp index 9bbd9f59d8..dae250203d 100644 --- a/src/USER-DPD/fix_dpd_energy.cpp +++ b/src/USER-DPD/fix_dpd_energy.cpp @@ -63,7 +63,7 @@ void FixDPDenergy::initial_integrate(int /*vflag*/) double *duCond = pairDPDE->duCond; double *duMech = pairDPDE->duMech; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { uCond[i] += 0.5*update->dt*duCond[i]; uMech[i] += 0.5*update->dt*duMech[i]; } @@ -81,7 +81,7 @@ void FixDPDenergy::final_integrate() double *duCond = pairDPDE->duCond; double *duMech = pairDPDE->duMech; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { uCond[i] += 0.5*update->dt*duCond[i]; uMech[i] += 0.5*update->dt*duMech[i]; } diff --git a/src/USER-DPD/fix_eos_cv.cpp b/src/USER-DPD/fix_eos_cv.cpp index dabcfec46a..1bcdb9dbc6 100644 --- a/src/USER-DPD/fix_eos_cv.cpp +++ b/src/USER-DPD/fix_eos_cv.cpp @@ -30,7 +30,7 @@ FixEOScv::FixEOScv(LAMMPS *lmp, int narg, char **arg) : { if (narg != 4) error->all(FLERR,"Illegal fix eos/cv command"); cvEOS = utils::numeric(FLERR,arg[3],false,lmp); - if(cvEOS <= 0.0) error->all(FLERR,"EOS cv must be > 0.0"); + if (cvEOS <= 0.0) error->all(FLERR,"EOS cv must be > 0.0"); nevery = 1; @@ -58,14 +58,14 @@ void FixEOScv::init() double *uMech = atom->uMech; double *dpdTheta = atom->dpdTheta; - if(this->restart_reset){ + if (this->restart_reset) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) dpdTheta[i] = (uCond[i]+uMech[i])/cvEOS; } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); uCond[i] = 0.0; uMech[i] = cvEOS*dpdTheta[i]; @@ -84,9 +84,9 @@ void FixEOScv::post_integrate() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { dpdTheta[i] = (uCond[i]+uMech[i])/cvEOS; - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -102,9 +102,9 @@ void FixEOScv::end_of_step() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { dpdTheta[i] = (uCond[i]+uMech[i])/cvEOS; - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } diff --git a/src/USER-DPD/fix_eos_table.cpp b/src/USER-DPD/fix_eos_table.cpp index b827c1e42f..0d23f32b4e 100644 --- a/src/USER-DPD/fix_eos_table.cpp +++ b/src/USER-DPD/fix_eos_table.cpp @@ -111,14 +111,14 @@ void FixEOStable::init() double *dpdTheta = atom->dpdTheta; double tmp; - if(this->restart_reset){ + if (this->restart_reset) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) temperature_lookup(uCond[i]+uMech[i],dpdTheta[i]); } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); energy_lookup(dpdTheta[i],tmp); uCond[i] = 0.0; @@ -138,9 +138,9 @@ void FixEOStable::post_integrate() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(uCond[i]+uMech[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -156,9 +156,9 @@ void FixEOStable::end_of_step() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(uCond[i]+uMech[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -406,7 +406,7 @@ void FixEOStable::energy_lookup(double t, double &u) double fraction; Table *tb = &tables[0]; - if(t < tb->lo || t > tb->hi){ + if (t < tb->lo || t > tb->hi) { printf("Temperature=%lf TableMin=%lf TableMax=%lf\n",t,tb->lo,tb->hi); error->one(FLERR,"Temperature is not within table cutoffs"); } @@ -428,7 +428,7 @@ void FixEOStable::temperature_lookup(double u, double &t) double fraction; Table *tb = &tables[1]; - if(u < tb->lo || u > tb->hi){ + if (u < tb->lo || u > tb->hi) { printf("Energy=%lf TableMin=%lf TableMax=%lf\n",u,tb->lo,tb->hi); error->one(FLERR,"Energy is not within table cutoffs"); } diff --git a/src/USER-DPD/fix_eos_table_rx.cpp b/src/USER-DPD/fix_eos_table_rx.cpp index 6193effe62..28cd4eb4c3 100644 --- a/src/USER-DPD/fix_eos_table_rx.cpp +++ b/src/USER-DPD/fix_eos_table_rx.cpp @@ -54,7 +54,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) : if (utils::strmatch(modify->fix[i]->style,"^rx")) { rx_flag = true; nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); } if (strcmp(arg[3],"linear") == 0) tabstyle = LINEAR; @@ -70,7 +70,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) : int me; MPI_Comm_rank(world,&me); - for (int ii=0;iisrealloc(tables,(ntables+1)*sizeof(Table),"eos:table/rx"); tables2 = (Table *) @@ -91,7 +91,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) : if (me == 0) read_table(tb,tb2,arg[4],arg[6]); - for (int ii=0;iiuCG; double *uCGnew = atom->uCGnew; - if(!this->restart_reset){ + if (!this->restart_reset) { for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { duChem = uCG[i] - uCGnew[i]; uChem[i] += duChem; uCG[i] = 0.0; @@ -222,14 +222,14 @@ void FixEOStableRX::init() double *dpdTheta = atom->dpdTheta; double tmp; - if(this->restart_reset){ + if (this->restart_reset) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); energy_lookup(i,dpdTheta[i],tmp); uCond[i] = 0.0; @@ -252,9 +252,9 @@ void FixEOStableRX::post_integrate() double *dpdTheta = atom->dpdTheta; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -277,7 +277,7 @@ void FixEOStableRX::end_of_step() comm->reverse_comm_fix(this); for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { duChem = uCG[i] - uCGnew[i]; uChem[i] += duChem; uCG[i] = 0.0; @@ -288,9 +288,9 @@ void FixEOStableRX::end_of_step() comm->forward_comm_fix(this); for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); - if(dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= 0.0) error->one(FLERR,"Internal temperature <= zero"); } } @@ -371,9 +371,9 @@ void FixEOStableRX::read_file(char *file) for (ispecies = 0; ispecies < nspecies; ispecies++) if (strcmp(words[0],&atom->dname[ispecies][0]) == 0) break; - if (ispecies < nspecies){ + if (ispecies < nspecies) { dHf[ispecies] = atof(words[1]); - if(nwords > min_params_per_line+1){ + if (nwords > min_params_per_line+1) { energyCorr[ispecies] = atof(words[2]); tempCorrCoeff[ispecies] = atof(words[3]); moleculeCorrCoeff[ispecies] = atof(words[4]); @@ -451,7 +451,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) memory->create(tb2->rfile,tb2->ninput,"eos:rfile"); memory->create(tb2->efile,tb2->ninput,"eos:efile"); - for (int ispecies=1;ispeciesninput = tb->ninput; @@ -476,7 +476,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) utils::sfgets(FLERR,line,MAXLINE,fp,file,error); nwords = utils::count_words(utils::trim_comment(line)); - if(nwords != nspecies+2){ + if (nwords != nspecies+2) { printf("nwords=%d nspecies=%d\n",nwords,nspecies); error->all(FLERR,"Illegal fix eos/table/rx command"); } @@ -485,7 +485,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) word = strtok(nullptr," \t\n\r\f"); rtmp = atof(word); - for (int icolumn=0;icolumnone(FLERR,"Invalid keyword in fix eos/table/rx parameters"); word = strtok(nullptr," \t\n\r\f"); - if(rx_flag){ + if (rx_flag) { while (word) { for (ispecies = 0; ispecies < nspecies; ispecies++) - if (strcmp(word,&atom->dname[ispecies][0]) == 0){ + if (strcmp(word,&atom->dname[ispecies][0]) == 0) { eosSpecies[ncolumn] = ispecies; ncolumn++; break; } - if (ispecies == nspecies){ + if (ispecies == nspecies) { printf("name=%s not found in species list\n",word); error->one(FLERR,"Invalid keyword in fix eos/table/rx parameters"); } @@ -596,9 +596,9 @@ void FixEOStableRX::param_extract(Table *tb, char *line) } for (int icolumn = 0; icolumn < ncolumn; icolumn++) - if(eosSpecies[icolumn]==-1) + if (eosSpecies[icolumn]==-1) error->one(FLERR,"EOS data is missing from fix eos/table/rx tabe"); - if(ncolumn != nspecies){ + if (ncolumn != nspecies) { printf("ncolumns=%d nspecies=%d\n",ncolumn,nspecies); error->one(FLERR,"The number of columns in fix eos/table/rx does not match the number of species"); } @@ -703,10 +703,10 @@ void FixEOStableRX::energy_lookup(int id, double thetai, double &ui) nTotalPG = 0.0; nPG = 0; - if(rx_flag){ - for(int ispecies=0;ispeciesdvector[ispecies][id]; - if(fabs(moleculeCorrCoeff[ispecies]) > tolerance){ + if (fabs(moleculeCorrCoeff[ispecies]) > tolerance) { nPG++; nTotalPG += atom->dvector[ispecies][id]; } @@ -715,7 +715,7 @@ void FixEOStableRX::energy_lookup(int id, double thetai, double &ui) nTotal = 1.0; } - for(int ispecies=0;ispecieslo); thetai = MIN(thetai,tb->hi); @@ -728,9 +728,9 @@ void FixEOStableRX::energy_lookup(int id, double thetai, double &ui) uTmp += dHf[ispecies]; uTmp += tempCorrCoeff[ispecies]*thetai; // temperature correction uTmp += energyCorr[ispecies]; // energy correction - if(nPG > 0) ui += moleculeCorrCoeff[ispecies]*nTotalPG/double(nPG); // molecule correction + if (nPG > 0) ui += moleculeCorrCoeff[ispecies]*nTotalPG/double(nPG); // molecule correction - if(rx_flag) nMolecules = atom->dvector[ispecies][id]; + if (rx_flag) nMolecules = atom->dvector[ispecies][id]; else nMolecules = 1.0; ui += nMolecules*uTmp; } @@ -756,7 +756,7 @@ void FixEOStableRX::temperature_lookup(int id, double ui, double &thetai) // Store the current thetai in t1 t1 = MAX(thetai,tb->lo); t1 = MIN(t1,tb->hi); - if(t1==tb->hi) delta = -delta; + if (t1==tb->hi) delta = -delta; // Compute u1 at thetai energy_lookup(id,t1,u1); @@ -774,9 +774,9 @@ void FixEOStableRX::temperature_lookup(int id, double ui, double &thetai) f2 = u2 - ui; // Apply the Secant Method - for(it=0; itone(FLERR,"NaN detected in secant solver."); + for (it=0; itone(FLERR,"NaN detected in secant solver."); temp = t1; temp = MAX(temp,tb->lo); temp = MIN(temp,tb->hi); @@ -786,17 +786,17 @@ void FixEOStableRX::temperature_lookup(int id, double ui, double &thetai) break; } temp = t2 - f2*(t2-t1)/(f2-f1); - if(fabs(temp-t2) < tolerance) break; + if (fabs(temp-t2) < tolerance) break; f1 = f2; t1 = t2; t2 = temp; energy_lookup(id,t2,u2); f2 = u2 - ui; } - if(it==maxit){ + if (it==maxit) { char str[256]; sprintf(str,"Maxit exceeded in secant solver: id=%d ui=%lf thetai=%lf t1=%lf t2=%lf f1=%lf f2=%lf\n",id,ui,thetai,t1,t2,f1,f2); - if(std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) + if (std::isnan(f1) || std::isnan(f2) || std::isnan(ui) || std::isnan(thetai) || std::isnan(t1) || std::isnan(t2)) error->one(FLERR,"NaN detected in secant solver."); error->one(FLERR,str); } @@ -833,7 +833,7 @@ void FixEOStableRX::unpack_forward_comm(int n, int first, double *buf) m = 0; last = first + n ; - for (ii = first; ii < last; ii++){ + for (ii = first; ii < last; ii++) { uChem[ii] = buf[m++]; uCG[ii] = buf[m++]; uCGnew[ii] = buf[m++]; diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 4f7edfe14a..ad3bf7c30c 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -99,11 +99,11 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : { char *word = arg[iarg++]; - if (strcmp(word,"none") == 0){ + if (strcmp(word,"none") == 0) { wtFlag = 0; localTempFlag = NONE; } - else if (strcmp(word,"lucy") == 0){ + else if (strcmp(word,"lucy") == 0) { wtFlag = LUCY; localTempFlag = HARMONIC; } @@ -127,7 +127,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, errmsg); } - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { std::string msg = "FixRX: matrix format is "; if (useSparseKinetics) msg += std::string("sparse"); @@ -164,25 +164,25 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : absTol = 1.0e-8; diagnosticFrequency = 0; - for (int i = 0; i < numDiagnosticCounters; ++i){ + for (int i = 0; i < numDiagnosticCounters; ++i) { diagnosticCounter[i] = 0; diagnosticCounterPerODE[i] = nullptr; } - if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg==8){ + if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg==8) { char *word = arg[iarg++]; minSteps = atoi( word ); - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { char msg[128]; sprintf(msg, "FixRX: RK4 numSteps= %d", minSteps); error->message(FLERR, msg); } } - else if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg>8){ + else if (odeIntegrationFlag == ODE_LAMMPS_RK4 && narg>8) { error->all(FLERR,"Illegal fix rx command. Too many arguments for RK4 solver."); } - else if (odeIntegrationFlag == ODE_LAMMPS_RKF45){ + else if (odeIntegrationFlag == ODE_LAMMPS_RKF45) { // Must have four options. if (narg < 11) error->all(FLERR,"Illegal fix rx command. Too few arguments for RKF45 solver."); @@ -198,7 +198,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) : // maxIters must be at least minSteps. maxIters = std::max( minSteps, maxIters ); - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { //printf("FixRX: RKF45 minSteps= %d maxIters= %d absTol= %e relTol= %e\n", minSteps, maxIters, absTol, relTol); char msg[128]; sprintf(msg, "FixRX: RKF45 minSteps= %d maxIters= %d relTol= %.1e absTol= %.1e diagnosticFrequency= %d", minSteps, maxIters, relTol, absTol, diagnosticFrequency); @@ -224,7 +224,7 @@ FixRX::~FixRX() if (copymode) return; // De-Allocate memory to prevent memory leak - for (int ii = 0; ii < nreactions; ii++){ + for (int ii = 0; ii < nreactions; ii++) { delete [] stoich[ii]; delete [] stoichReactants[ii]; delete [] stoichProducts[ii]; @@ -240,7 +240,7 @@ FixRX::~FixRX() delete [] id_fix_species; delete [] id_fix_species_old; - if (useSparseKinetics){ + if (useSparseKinetics) { memory->destroy( sparseKinetics_nu ); memory->destroy( sparseKinetics_nuk ); memory->destroy( sparseKinetics_inu ); @@ -258,7 +258,7 @@ void FixRX::post_constructor() char **tmpspecies = new char*[maxspecies]; int tmpmaxstrlen = 0; - for(int jj=0; jj < maxspecies; jj++) + for (int jj=0; jj < maxspecies; jj++) tmpspecies[jj] = nullptr; // open file on proc 0 @@ -304,17 +304,17 @@ void FixRX::post_constructor() nwords = 0; word = strtok(line," \t\n\r\f"); - while (word != nullptr){ + while (word != nullptr) { word = strtok(nullptr, " \t\n\r\f"); match=false; - for(int jj=0;jj=maxspecies) + if (!match) { + if (nUniqueSpecies+1>=maxspecies) error->all(FLERR,"Exceeded the maximum number of species permitted in fix rx."); tmpspecies[nUniqueSpecies] = new char[strlen(word)+1]; strcpy(tmpspecies[nUniqueSpecies],word); @@ -322,7 +322,7 @@ void FixRX::post_constructor() nUniqueSpecies++; } word = strtok(nullptr, " \t\n\r\f"); - if(strcmp(word,"+") != 0 && strcmp(word,"=") != 0) break; + if (strcmp(word,"+") != 0 && strcmp(word,"=") != 0) break; word = strtok(nullptr, " \t\n\r\f"); } } @@ -355,7 +355,7 @@ void FixRX::post_constructor() newarg2[2] = (char *) "property/atom"; char *str1 = new char[tmpmaxstrlen+3]; char *str2 = new char[tmpmaxstrlen+6]; - for(int ii=0; iiadd_fix(nspecies+5,newarg2,1); fix_species_old = (FixPropertyAtom *) modify->fix[modify->nfix-1]; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); - for(int jj=0;jjme == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { for (int k = 0; k < nspecies; ++k) printf("atom->dname[%d]= %s\n", k, atom->dname[k]); printf("stoich[][]\n"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0, nprod_i = 0; printf("%d: ", i); - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { printf(" %g", stoich[i][k]); if (stoich[i][k] < 0.0) nreac_i++; else if (stoich[i][k] > 0.0) nprod_i++; @@ -425,10 +425,10 @@ void FixRX::initSparse() } printf("stoichReactants[][]\n"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0; printf("%d: ", i); - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { printf(" %g", stoichReactants[i][k]); if (stoichReactants[i][k] > 0.0) nreac_i++; } @@ -436,10 +436,10 @@ void FixRX::initSparse() } printf("stoichProducts[][]\n"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nprod_i = 0; printf("%d: ", i); - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { printf(" %g", stoichProducts[i][k]); if (stoichProducts[i][k] > 0.0) nprod_i++; } @@ -453,15 +453,15 @@ void FixRX::initSparse() int mxreac = 0; int mxspec = 0; int nIntegral = 0; - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0, nprod_i = 0; std::string pstr, rstr; bool allAreIntegral = true; - for (int k = 0; k < nspecies; ++k){ + for (int k = 0; k < nspecies; ++k) { if (stoichReactants[i][k] == 0 and stoichProducts[i][k] == 0) nzeros++; - if (stoichReactants[i][k] > 0.0){ + if (stoichReactants[i][k] > 0.0) { allAreIntegral &= (std::fmod( stoichReactants[i][k], 1.0 ) == 0.0); nreac_i++; @@ -472,7 +472,7 @@ void FixRX::initSparse() sprintf(digit, "%4.1f ", stoichReactants[i][k]); rstr += digit; rstr += atom->dname[k]; } - if (stoichProducts[i][k] > 0.0){ + if (stoichProducts[i][k] > 0.0) { allAreIntegral &= (std::fmod( stoichProducts[i][k], 1.0 ) == 0.0); nprod_i++; @@ -494,7 +494,7 @@ void FixRX::initSparse() if (allAreIntegral) nIntegral++; } - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { char msg[256]; sprintf(msg, "FixRX: Sparsity of Stoichiometric Matrix= %.1f%% non-zeros= %d nspecies= %d nreactions= %d maxReactants= %d maxProducts= %d maxSpecies= %d integralReactions= %d", 100*(double(nzeros) / (nspecies * nreactions)), nzeros, nspecies, nreactions, mxreac, mxprod, (mxreac + mxprod), SparseKinetics_enableIntegralReactions); error->message(FLERR, msg); @@ -510,16 +510,16 @@ void FixRX::initSparse() memory->create( sparseKinetics_nuk, nreactions, sparseKinetics_maxSpecies, "sparseKinetics_nuk"); for (int i = 0; i < nreactions; ++i) - for (int k = 0; k < sparseKinetics_maxSpecies; ++k){ + for (int k = 0; k < sparseKinetics_maxSpecies; ++k) { sparseKinetics_nu [i][k] = 0.0; sparseKinetics_nuk[i][k] = SparseKinetics_invalidIndex; // Initialize with an invalid index. } - if (SparseKinetics_enableIntegralReactions){ + if (SparseKinetics_enableIntegralReactions) { memory->create( sparseKinetics_inu, nreactions, sparseKinetics_maxSpecies, "sparseKinetics_inu"); memory->create( sparseKinetics_isIntegralReaction, nreactions, "sparseKinetics_isIntegralReaction"); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { sparseKinetics_isIntegralReaction[i] = false; for (int k = 0; k < sparseKinetics_maxSpecies; ++k) sparseKinetics_inu[i][k] = 0; @@ -530,19 +530,19 @@ void FixRX::initSparse() // Measure the distribution of the # of moles for the ::fastpowi function. std::vector nu_bin(10); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { int nreac_i = 0, nprod_i = 0; bool isIntegral_i = true; - for (int k = 0; k < nspecies; ++k){ - if (stoichReactants[i][k] > 0.0){ + for (int k = 0; k < nspecies; ++k) { + if (stoichReactants[i][k] > 0.0) { const int idx = nreac_i; sparseKinetics_nu [i][idx] = stoichReactants[i][k]; sparseKinetics_nuk[i][idx] = k; isIntegral_i &= (std::fmod( stoichReactants[i][k], 1.0 ) == 0.0); - if (SparseKinetics_enableIntegralReactions){ + if (SparseKinetics_enableIntegralReactions) { sparseKinetics_inu[i][idx] = (int)sparseKinetics_nu[i][idx]; - if (isIntegral_i){ + if (isIntegral_i) { if (sparseKinetics_inu[i][idx] >= (int)nu_bin.size()) nu_bin.resize( sparseKinetics_inu[i][idx] ); @@ -552,15 +552,15 @@ void FixRX::initSparse() nreac_i++; } - if (stoichProducts[i][k] > 0.0){ + if (stoichProducts[i][k] > 0.0) { const int idx = sparseKinetics_maxReactants + nprod_i; sparseKinetics_nu [i][idx] = stoichProducts[i][k]; sparseKinetics_nuk[i][idx] = k; isIntegral_i &= (std::fmod( sparseKinetics_nu[i][idx], 1.0 ) == 0.0); - if (SparseKinetics_enableIntegralReactions){ + if (SparseKinetics_enableIntegralReactions) { sparseKinetics_inu[i][idx] = (int) sparseKinetics_nu[i][idx]; - if (isIntegral_i){ + if (isIntegral_i) { if (sparseKinetics_inu[i][idx] >= (int)nu_bin.size()) nu_bin.resize( sparseKinetics_inu[i][idx] ); @@ -576,17 +576,17 @@ void FixRX::initSparse() sparseKinetics_isIntegralReaction[i] = isIntegral_i; } - if (comm->me == 0 and Verbosity > 1){ + if (comm->me == 0 and Verbosity > 1) { for (int i = 1; i < nu_bin.size(); ++i) if (nu_bin[i] > 0) printf("nu_bin[%d] = %d\n", i, nu_bin[i]); - for (int i = 0; i < nreactions; ++i){ + for (int i = 0; i < nreactions; ++i) { std::string pstr, rstr; - for (int kk = 0; kk < sparseKinetics_maxReactants; kk++){ + for (int kk = 0; kk < sparseKinetics_maxReactants; kk++) { const int k = sparseKinetics_nuk[i][kk]; - if (k != SparseKinetics_invalidIndex){ + if (k != SparseKinetics_invalidIndex) { if (rstr.length() > 0) rstr += " + "; @@ -600,9 +600,9 @@ void FixRX::initSparse() } } - for (int kk = sparseKinetics_maxReactants; kk < sparseKinetics_maxSpecies; kk++){ + for (int kk = sparseKinetics_maxReactants; kk < sparseKinetics_maxSpecies; kk++) { const int k = sparseKinetics_nuk[i][kk]; - if (k != SparseKinetics_invalidIndex){ + if (k != SparseKinetics_invalidIndex) { if (pstr.length() > 0) pstr += " + "; @@ -646,7 +646,7 @@ void FixRX::init() bool eos_flag = false; for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"eos/table/rx") == 0) eos_flag = true; - if(!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); + if (!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified"); // need a half neighbor list // built whenever re-neighboring occurs @@ -673,7 +673,7 @@ void FixRX::setup_pre_force(int /*vflag*/) int newton_pair = force->newton_pair; double tmp; - if(restartFlag){ + if (restartFlag) { restartFlag = 0; } else @@ -686,7 +686,7 @@ void FixRX::setup_pre_force(int /*vflag*/) double *rwork = new double[8*nspecies]; - if(localTempFlag){ + if (localTempFlag) { int count = nlocal + (newton_pair ? nghost : 0); dpdThetaLocal = new double[count]; memset(dpdThetaLocal, 0, sizeof(double)*count); @@ -694,16 +694,16 @@ void FixRX::setup_pre_force(int /*vflag*/) } for (int id = 0; id < nlocal; id++) - for (int ispecies=0; ispeciesdvector[ispecies][id]; atom->dvector[ispecies+nspecies][id] = tmp; } for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { // Set the reaction rate constants to zero: no reactions occur at step 0 - for(int irxn=0;irxnforward_comm_fix(this); - if(localTempFlag) delete [] dpdThetaLocal; + if (localTempFlag) delete [] dpdThetaLocal; delete [] userData.kFor; delete [] userData.rxnRateLaw; @@ -734,7 +734,7 @@ void FixRX::pre_force(int /*vflag*/) double *dpdTheta = atom->dpdTheta; int newton_pair = force->newton_pair; - if(localTempFlag){ + if (localTempFlag) { int count = nlocal + (newton_pair ? nghost : 0); dpdThetaLocal = new double[count]; memset(dpdThetaLocal, 0, sizeof(double)*count); @@ -805,7 +805,7 @@ void FixRX::pre_force(int /*vflag*/) // Communicate the updated momenta and velocities to all nodes comm->forward_comm_fix(this); - if(localTempFlag) delete [] dpdThetaLocal; + if (localTempFlag) delete [] dpdThetaLocal; //TimerType timer_stop = getTimeStamp(); @@ -818,14 +818,14 @@ void FixRX::pre_force(int /*vflag*/) // getElapsedTime(timer_ODE, timer_stop), nlocal, nFuncs, nSteps); // Warn the user if a failure was detected in the ODE solver. - if (nFails > 0){ + if (nFails > 0) { char sbuf[128]; sprintf(sbuf,"in FixRX::pre_force, ODE solver failed for %d atoms.", nFails); error->warning(FLERR, sbuf); } // Compute and report ODE diagnostics, if requested. - if (odeIntegrationFlag == ODE_LAMMPS_RKF45 && diagnosticFrequency != 0){ + if (odeIntegrationFlag == ODE_LAMMPS_RKF45 && diagnosticFrequency != 0) { // Update the counters. diagnosticCounter[StepSum] += nSteps; diagnosticCounter[FuncSum] += nFuncs; @@ -907,14 +907,14 @@ void FixRX::read_file(char *file) stoich = new double*[nreactions]; stoichReactants = new double*[nreactions]; stoichProducts = new double*[nreactions]; - for (int ii=0;iidname[ispecies][0]) == 0){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { + if (strcmp(word,&atom->dname[ispecies][0]) == 0) { stoich[nreactions][ispecies] += sign*tmpStoich; - if(sign<0.0) + if (sign<0.0) stoichReactants[nreactions][ispecies] += tmpStoich; else stoichProducts[nreactions][ispecies] += tmpStoich; break; } } - if(ispecies==nspecies){ + if (ispecies==nspecies) { if (comm->me) { fprintf(stderr,"%s mol fraction is not found in data file\n",word); fprintf(stderr,"nspecies=%d ispecies=%d\n",nspecies,ispecies); @@ -966,16 +966,16 @@ void FixRX::read_file(char *file) error->all(FLERR,"Illegal fix rx command"); } word = strtok(nullptr, " \t\n\r\f"); - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); - if(strcmp(word,"=") == 0) sign = 1.0; - if(strcmp(word,"+") != 0 && strcmp(word,"=") != 0){ - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (strcmp(word,"=") == 0) sign = 1.0; + if (strcmp(word,"+") != 0 && strcmp(word,"=") != 0) { + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); Arr[nreactions] = atof(word); word = strtok(nullptr, " \t\n\r\f"); - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); nArr[nreactions] = atof(word); word = strtok(nullptr, " \t\n\r\f"); - if(word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); + if (word==nullptr) error->all(FLERR,"Missing parameters in reaction kinetic equation"); Ea[nreactions] = atof(word); sign = -1.0; break; @@ -1063,10 +1063,10 @@ void FixRX::rk4(int id, double *rwork, void* v_params) } // end for (int step... // Store the solution back in atom->dvector. - for (int ispecies = 0; ispecies < nspecies; ispecies++){ - if(y[ispecies] < -MY_EPSILON) + for (int ispecies = 0; ispecies < nspecies; ispecies++) { + if (y[ispecies] < -MY_EPSILON) error->one(FLERR,"Computed concentration in RK4 solver is < -10*DBL_EPSILON"); - else if(y[ispecies] < MY_EPSILON) + else if (y[ispecies] < MY_EPSILON) y[ispecies] = 0.0; atom->dvector[ispecies][id] = y[ispecies]; } @@ -1128,7 +1128,7 @@ void FixRX::rkf45_step (const int neq, const double h, double y[], double y_out[ // 1) rhs (0.0, y, f1, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f1[k] *= h; ytmp[k] = y[k] + c21 * f1[k]; } @@ -1136,7 +1136,7 @@ void FixRX::rkf45_step (const int neq, const double h, double y[], double y_out[ // 2) rhs(0.0, ytmp, f2, v_param); - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { f2[k] *= h; ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; } @@ -1232,7 +1232,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, // Compute WRMS norm of y'' double yddnrm = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { double ydd = (ydot1[k] - ydot[k]) / hg; double wterr = ydd / (relTol * fabs( y[k] ) + absTol); yddnrm += wterr * wterr; @@ -1244,7 +1244,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, //std::cout << "ydot " << ydot[neq-1] << std::endl; // should we accept this? - if (hnew_is_ok || iter == max_iters){ + if (hnew_is_ok || iter == max_iters) { hnew = hg; if (iter == max_iters) fprintf(stderr, "ERROR_HIN_MAX_ITERS\n"); @@ -1319,7 +1319,7 @@ void FixRX::odeDiagnostics(void) double max_per_proc[numCounters]; double min_per_proc[numCounters]; - if(1) + if (1) { static bool firstStep = true; @@ -1392,7 +1392,7 @@ void FixRX::odeDiagnostics(void) } // Compute counters per dpd time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { my_vals[i] = this->diagnosticCounter[i] / nTimes; //printf("my sum[%d] = %f %d\n", i, my_vals[i], comm->me); } @@ -1407,7 +1407,7 @@ void FixRX::odeDiagnostics(void) double avg_per_atom[numCounters], avg_per_proc[numCounters]; // Averages per-ODE and per-proc per time-step. - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { avg_per_atom[i] = sums[i] / nODEs; avg_per_proc[i] = sums[i] / comm->nprocs; } @@ -1415,7 +1415,7 @@ void FixRX::odeDiagnostics(void) // Sum up the differences from each task. double sum_sq[2*numCounters]; double my_sum_sq[2*numCounters]; - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { double diff_i = my_vals[i] - avg_per_proc[i]; my_sum_sq[i] = diff_i * diff_i; } @@ -1423,20 +1423,20 @@ void FixRX::odeDiagnostics(void) double max_per_ODE[numCounters], min_per_ODE[numCounters]; // Process the per-ODE RMS of the # of steps/funcs - if (diagnosticFrequency == 1){ + if (diagnosticFrequency == 1) { double my_max[numCounters], my_min[numCounters]; const int nlocal = atom->nlocal; const int *mask = atom->mask; - for (int i = 0; i < numCounters; ++i){ + for (int i = 0; i < numCounters; ++i) { my_sum_sq[i+numCounters] = 0; my_max[i] = 0; my_min[i] = DBL_MAX; - if (diagnosticCounterPerODE[i] != nullptr){ + if (diagnosticCounterPerODE[i] != nullptr) { for (int j = 0; j < nlocal; ++j) - if (mask[j] & groupbit){ + if (mask[j] & groupbit) { double diff = double(diagnosticCounterPerODE[i][j]) - avg_per_atom[i]; my_sum_sq[i+numCounters] += diff*diff; @@ -1457,7 +1457,7 @@ void FixRX::odeDiagnostics(void) TimerType timer_stop = getTimeStamp(); double time_local = getElapsedTime( timer_start, timer_stop ); - if (comm->me == 0){ + if (comm->me == 0) { char smesg[128]; #define print_mesg(smesg) {\ @@ -1471,7 +1471,7 @@ void FixRX::odeDiagnostics(void) print_mesg(smesg); // only valid for single time-step! - if (diagnosticFrequency == 1){ + if (diagnosticFrequency == 1) { double rms_per_ODE[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_ODE[i] = sqrt( sum_sq[i+numCounters] / nODEs ); @@ -1489,7 +1489,7 @@ void FixRX::odeDiagnostics(void) sprintf(smesg, " AVG per Proc : %-12.5g | %-12.5g | %-12.5g | %-12.5g", avg_per_proc[StepSum], avg_per_proc[FuncSum], avg_per_proc[TimeSum], avg_per_proc[AtomSum]); print_mesg(smesg); - if (comm->nprocs > 1){ + if (comm->nprocs > 1) { double rms_per_proc[numCounters]; for (int i = 0; i < numCounters; ++i) rms_per_proc[i] = sqrt( sum_sq[i] / comm->nprocs ); @@ -1534,7 +1534,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) const int neq = nspecies; // Update ConcOld and initialize the ODE solution vector y[]. - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { const double tmp = atom->dvector[ispecies][id]; atom->dvector[ispecies+nspecies][id] = tmp; y[ispecies] = tmp; @@ -1563,7 +1563,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) double t = 0.0; - if (h < h_min){ + if (h < h_min) { //fprintf(stderr,"hin not implemented yet\n"); //exit(-1); nfe = rkf45_h0 (neq, t, t_stop, h_min, h_max, h, y, y + neq, v_param); @@ -1572,7 +1572,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) //printf("t= %e t_stop= %e h= %e\n", t, t_stop, h); // Integrate until we reach the end time. - while (fabs(t - t_stop) > tround){ + while (fabs(t - t_stop) > tround) { double *yout = y + neq; double *eout = yout + neq; @@ -1582,7 +1582,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) // Estimate the solution error. // ... weighted 2-norm of the error. double err2 = 0.0; - for (int k = 0; k < neq; k++){ + for (int k = 0; k < neq; k++) { const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); err2 += wterr * wterr; } @@ -1590,7 +1590,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) double err = fmax( uround, sqrt( err2 / double(nspecies) )); // Accept the solution? - if (err <= 1.0 || h <= h_min){ + if (err <= 1.0 || h <= h_min) { t += h; nst++; @@ -1623,7 +1623,7 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) nit++; nfe += 6; - if (maxIters && nit > maxIters){ + if (maxIters && nit > maxIters) { //fprintf(stderr,"atom[%d] took too many iterations in rkf45 %d %e %e\n", id, nit, t, t_stop); //nFails ++; ode_counter[3] ++; @@ -1638,17 +1638,17 @@ void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) ode_counter[2] += nfe; //if (diagnosticFrequency == 1 && diagnosticCounterPerODE[StepSum] != nullptr) - if (diagnosticCounterPerODE[StepSum] != nullptr){ + if (diagnosticCounterPerODE[StepSum] != nullptr) { diagnosticCounterPerODE[StepSum][id] = nst; diagnosticCounterPerODE[FuncSum][id] = nfe; } //printf("id= %d nst= %d nit= %d\n", id, nst, nit); // Store the solution back in atom->dvector. - for (int ispecies = 0; ispecies < nspecies; ispecies++){ - if(y[ispecies] < -1.0e-10) + for (int ispecies = 0; ispecies < nspecies; ispecies++) { + if (y[ispecies] < -1.0e-10) error->one(FLERR,"Computed concentration in RKF45 solver is < -1.0e-10"); - else if(y[ispecies] < MY_EPSILON) + else if (y[ispecies] < MY_EPSILON) y[ispecies] = 0.0; atom->dvector[ispecies][id] = y[ispecies]; } @@ -1677,14 +1677,14 @@ int FixRX::rhs_dense(double /*t*/, const double *y, double *dydt, void *params) const double VDPD = domain->xprd * domain->yprd * domain->zprd / atom->natoms; const int nspecies = atom->nspecies_dpd; - for(int ispecies=0; ispeciesreverse_comm_fix(this); // self-interaction for local temperature - for (i = 0; i < nlocal; i++){ + for (i = 0; i < nlocal; i++) { // Lucy Weight Function - if(wtFlag==LUCY){ + if (wtFlag==LUCY) { wij = 1.0; dpdThetaLocal[i] += wij / dpdTheta[i]; } @@ -1874,7 +1874,7 @@ void FixRX::computeLocalTemperature() // Normalized local temperature dpdThetaLocal[i] = dpdThetaLocal[i] / sumWeights[i]; - if(localTempFlag == HARMONIC) + if (localTempFlag == HARMONIC) dpdThetaLocal[i] = 1.0 / dpdThetaLocal[i]; } @@ -1892,7 +1892,7 @@ int FixRX::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, in m = 0; for (ii = 0; ii < n; ii++) { jj = list[ii]; - for(int ispecies=0;ispeciesdvector[ispecies][jj]; buf[m++] = tmp; tmp = atom->dvector[ispecies+nspecies][jj]; @@ -1911,8 +1911,8 @@ void FixRX::unpack_forward_comm(int n, int first, double *buf) m = 0; last = first + n ; - for (ii = first; ii < last; ii++){ - for(int ispecies=0;ispeciesdvector[ispecies][ii] = tmp; tmp = buf[m++]; diff --git a/src/USER-DPD/fix_shardlow.cpp b/src/USER-DPD/fix_shardlow.cpp index 98e043fe08..e5bccf4192 100644 --- a/src/USER-DPD/fix_shardlow.cpp +++ b/src/USER-DPD/fix_shardlow.cpp @@ -99,7 +99,7 @@ FixShardlow::FixShardlow(LAMMPS *lmp, int narg, char **arg) : pairDPDE = (PairDPDfdtEnergy *) force->pair_match("dpd/fdt/energy/kk",1); maxRNG = 0; - if(pairDPDE){ + if (pairDPDE) { comm_forward = 3; comm_reverse = 5; } else { @@ -107,7 +107,7 @@ FixShardlow::FixShardlow(LAMMPS *lmp, int narg, char **arg) : comm_reverse = 3; } - if(pairDPD == nullptr && pairDPDE == nullptr) + if (pairDPD == nullptr && pairDPDE == nullptr) error->all(FLERR,"Must use pair_style dpd/fdt or dpd/fdt/energy with fix shardlow"); } @@ -159,10 +159,10 @@ void FixShardlow::setup(int /*vflag*/) strstr(modify->fix[i]->style,"gle") || strstr(modify->fix[i]->style,"gld")) error->all(FLERR,"Cannot use constant temperature integration routines with USER-DPD."); - for (int i = 0; i < modify->nfix; i++){ + for (int i = 0; i < modify->nfix; i++) { if (utils::strmatch(modify->fix[i]->style,"^shardlow")) fixShardlow = true; - if (utils::strmatch(modify->fix[i]->style,"^nve") || utils::strmatch(modify->fix[i]->style,"^nph")){ - if(fixShardlow) break; + if (utils::strmatch(modify->fix[i]->style,"^nve") || utils::strmatch(modify->fix[i]->style,"^nph")) { + if (fixShardlow) break; else error->all(FLERR,"The deterministic integrator must follow fix shardlow in the input file."); } if (i == modify->nfix-1) error->all(FLERR,"A deterministic integrator (e.g. fix nve or fix nph) is required when using fix shardlow."); @@ -547,7 +547,7 @@ void FixShardlow::initial_integrate(int /*vflag*/) if (domain->triclinic) error->all(FLERR,"Fix shardlow does not yet support triclinic geometries"); - if(rcut >= bbx || rcut >= bby || rcut>= bbz ) + if (rcut >= bbx || rcut >= bby || rcut>= bbz ) { char fmt[] = {"Shardlow algorithm requires sub-domain length > 2*(rcut+skin). Either reduce the number of processors requested, or change the cutoff/skin: rcut= %e bbx= %e bby= %e bbz= %e\n"}; char *msg = (char *) malloc(sizeof(fmt) + 4*15); @@ -611,7 +611,7 @@ void FixShardlow::initial_integrate(int /*vflag*/) // Communicate the updated velocities to all nodes comm->forward_comm_fix(this); - if(useDPDE){ + if (useDPDE) { // Zero out the ghosts' uCond & uMech to be used as delta accumulators memset(&(atom->uCond[nlocal]), 0, sizeof(double)*nghost); memset(&(atom->uMech[nlocal]), 0, sizeof(double)*nghost); @@ -693,7 +693,7 @@ int FixShardlow::pack_reverse_comm(int n, int first, double *buf) buf[m++] = v[i][0] - v_t0[i - nlocal][0]; buf[m++] = v[i][1] - v_t0[i - nlocal][1]; buf[m++] = v[i][2] - v_t0[i - nlocal][2]; - if(pairDPDE){ + if (pairDPDE) { buf[m++] = uCond[i]; // for ghosts, this is an accumulated delta buf[m++] = uMech[i]; // for ghosts, this is an accumulated delta } @@ -717,7 +717,7 @@ void FixShardlow::unpack_reverse_comm(int n, int *list, double *buf) v[j][0] += buf[m++]; v[j][1] += buf[m++]; v[j][2] += buf[m++]; - if(pairDPDE){ + if (pairDPDE) { uCond[j] += buf[m++]; // add in the accumulated delta uMech[j] += buf[m++]; // add in the accumulated delta } diff --git a/src/USER-DPD/nbin_ssa.cpp b/src/USER-DPD/nbin_ssa.cpp index 81eeb68ceb..db3425c259 100644 --- a/src/USER-DPD/nbin_ssa.cpp +++ b/src/USER-DPD/nbin_ssa.cpp @@ -142,9 +142,9 @@ int NBinSSA::coord2ssaAIR(const double *x) if (x[0] < domain->sublo[0]) ix = -1; if (x[0] >= domain->subhi[0]) ix = 1; - if(iz < 0){ + if (iz < 0) { return -1; - } else if(iz == 0){ + } else if (iz == 0) { if (iy<0) return -1; // bottom left/middle/right if ((iy==0) && (ix<0) ) return -1; // left atoms if ((iy==0) && (ix==0)) return 0; // Locally owned atoms @@ -152,10 +152,10 @@ int NBinSSA::coord2ssaAIR(const double *x) if ((iy>0) && (ix==0)) return 1; // Top-middle atoms if ((iy>0) && (ix!=0)) return 3; // Top-right and top-left atoms } else { // iz > 0 - if((ix==0) && (iy==0)) return 4; // Back atoms - if((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms - if((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms - if((ix!=0) && (iy!=0)) return 7; // Back corner atoms + if ((ix==0) && (iy==0)) return 4; // Back atoms + if ((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms + if ((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms + if ((ix!=0) && (iy!=0)) return 7; // Back corner atoms } return -2; diff --git a/src/USER-DPD/pair_dpd_fdt_energy.cpp b/src/USER-DPD/pair_dpd_fdt_energy.cpp index 98eb4e8315..a97abcc84c 100644 --- a/src/USER-DPD/pair_dpd_fdt_energy.cpp +++ b/src/USER-DPD/pair_dpd_fdt_energy.cpp @@ -420,7 +420,7 @@ void PairDPDfdtEnergy::init_style() bool eos_flag = false; for (int i = 0; i < modify->nfix; i++) if (utils::strmatch(modify->fix[i]->style,"^eos")) eos_flag = true; - if(!eos_flag) error->all(FLERR,"pair_style dpd/fdt/energy requires an EOS fix to be specified"); + if (!eos_flag) error->all(FLERR,"pair_style dpd/fdt/energy requires an EOS fix to be specified"); } /* ---------------------------------------------------------------------- diff --git a/src/USER-DPD/pair_exp6_rx.cpp b/src/USER-DPD/pair_exp6_rx.cpp index fa28c75f6c..d387ffa3c5 100644 --- a/src/USER-DPD/pair_exp6_rx.cpp +++ b/src/USER-DPD/pair_exp6_rx.cpp @@ -99,7 +99,7 @@ PairExp6rx::~PairExp6rx() memory->destroy(cutsq); memory->destroy(cut); } - if(scalingFlag == POLYNOMIAL){ + if (scalingFlag == POLYNOMIAL) { memory->destroy(coeffAlpha); memory->destroy(coeffEps); memory->destroy(coeffRm); @@ -306,8 +306,8 @@ void PairExp6rx::compute(int eflag, int vflag) fpairOldEXP6_12 = 0.0; fpairOldEXP6_21 = 0.0; - if(rmOld12_ij!=0.0 && rmOld21_ij!=0.0){ - if(alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0) + if (rmOld12_ij!=0.0 && rmOld21_ij!=0.0) { + if (alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0) error->all(FLERR,"alpha_ij is 6.0 in pair exp6"); // A3. Compute some convenient quantities for evaluating the force @@ -323,7 +323,7 @@ void PairExp6rx::compute(int eflag, int vflag) urc = buck1*(6.0*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -363,7 +363,7 @@ void PairExp6rx::compute(int eflag, int vflag) durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -400,8 +400,8 @@ void PairExp6rx::compute(int eflag, int vflag) uCG[j] += 0.5*evdwlOld; } - if(rm12_ij!=0.0 && rm21_ij!=0.0){ - if(alpha21_ij == 6.0 || alpha12_ij == 6.0) + if (rm12_ij!=0.0 && rm21_ij!=0.0) { + if (alpha21_ij == 6.0 || alpha12_ij == 6.0) error->all(FLERR,"alpha_ij is 6.0 in pair exp6"); // A3. Compute some convenient quantities for evaluating the force @@ -418,7 +418,7 @@ void PairExp6rx::compute(int eflag, int vflag) durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm12_ij*func_rin(alpha12_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -450,7 +450,7 @@ void PairExp6rx::compute(int eflag, int vflag) durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); - if(r < rin1){ + if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; rin6inv = 1.0/rin6; @@ -593,7 +593,7 @@ void PairExp6rx::coeff(int narg, char **arg) utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); read_file(arg[2]); n = strlen(arg[3]) + 1; @@ -601,7 +601,7 @@ void PairExp6rx::coeff(int narg, char **arg) strcpy(site1,arg[3]); int ispecies; - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) @@ -611,7 +611,7 @@ void PairExp6rx::coeff(int narg, char **arg) site2 = new char[n]; strcpy(site2,arg[4]); - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site2,"1fluid") != 0) @@ -664,13 +664,13 @@ void PairExp6rx::coeff(int narg, char **arg) setup(); double cut_one = cut_global; - if (strcmp(arg[5],"exponent") == 0){ + if (strcmp(arg[5],"exponent") == 0) { scalingFlag = EXPONENT; exponentR = utils::numeric(FLERR,arg[6],false,lmp); exponentEpsilon = utils::numeric(FLERR,arg[7],false,lmp); if (narg > 9) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg == 9) cut_one = utils::numeric(FLERR,arg[8],false,lmp); - } else if (strcmp(arg[5],"polynomial") == 0){ + } else if (strcmp(arg[5],"polynomial") == 0) { scalingFlag = POLYNOMIAL; memory->create(coeffAlpha,6,"pair:coeffAlpha"); memory->create(coeffEps,6,"pair:coeffEps"); @@ -678,7 +678,7 @@ void PairExp6rx::coeff(int narg, char **arg) read_file2(arg[6]); if (narg > 8) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg == 8) cut_one = utils::numeric(FLERR,arg[7],false,lmp); - } else if (strcmp(arg[5],"none") == 0){ + } else if (strcmp(arg[5],"none") == 0) { scalingFlag = NONE; if (narg > 7) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg == 7) cut_one = utils::numeric(FLERR,arg[6],false,lmp); @@ -813,7 +813,7 @@ void PairExp6rx::read_file(char *file) n = strlen(words[1]) + 1; params[nparams].potential = new char[n]; strcpy(params[nparams].potential,words[1]); - if (strcmp(params[nparams].potential,"exp6") == 0){ + if (strcmp(params[nparams].potential,"exp6") == 0) { params[nparams].alpha = atof(words[2]); params[nparams].epsilon = atof(words[3]); params[nparams].rm = atof(words[4]); @@ -901,15 +901,15 @@ void PairExp6rx::read_file2(char *file) words[nwords++] = strtok(line," \t\n\r\f"); while ((words[nwords++] = strtok(nullptr," \t\n\r\f"))) continue; - if (strcmp(words[0],"alpha") == 0){ + if (strcmp(words[0],"alpha") == 0) { for (int ii=1; iidvector[ispecies][id]; nTotalOld += atom->dvector[ispecies+nspecies][id]; @@ -1062,7 +1062,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double nMoleculesOFA += atom->dvector[ispecies][id]; } } - if(nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) + if (nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) error->all(FLERR,"The number of molecules in CG particle is less than 10*DBL_EPSILON."); // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) @@ -1074,7 +1074,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double if (iparam < 0 || params[iparam].potentialType != exp6PotentialType ) continue; // If Site1 matches a pure species, then grab the parameters - if (isite1 == params[iparam].ispecies){ + if (isite1 == params[iparam].ispecies) { rm1_old = params[iparam].rm; rm1 = params[iparam].rm; epsilon1_old = params[iparam].epsilon; @@ -1090,7 +1090,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double } // If Site2 matches a pure species, then grab the parameters - if (isite2 == params[iparam].ispecies){ + if (isite2 == params[iparam].ispecies) { rm2_old = params[iparam].rm; rm2 = params[iparam].rm; epsilon2_old = params[iparam].epsilon; @@ -1111,9 +1111,9 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double rmi = params[iparam].rm; epsiloni = params[iparam].epsilon; alphai = params[iparam].alpha; - if(nMoleculesOFAdvector[ispecies][id]/nMoleculesOFA; - if(nMoleculesOFAolddvector[ispecies+nspecies][id]/nMoleculesOFAold; for (int jspecies = 0; jspecies < nspecies; jspecies++) { @@ -1123,9 +1123,9 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double rmj = params[jparam].rm; epsilonj = params[jparam].epsilon; alphaj = params[jparam].alpha; - if(nMoleculesOFAdvector[jspecies][id]/nMoleculesOFA; - if(nMoleculesOFAolddvector[jspecies+nspecies][id]/nMoleculesOFAold; rmij = (rmi+rmj)/2.0; @@ -1133,12 +1133,12 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double epsilonij = sqrt(epsiloni*epsilonj); alphaij = sqrt(alphai*alphaj); - if(fractionOFAold > 0.0){ + if (fractionOFAold > 0.0) { rm3_old += xMolei_old*xMolej_old*rm3ij; epsilon_old += xMolei_old*xMolej_old*rm3ij*epsilonij; alpha_old += xMolei_old*xMolej_old*rm3ij*epsilonij*alphaij; } - if(fractionOFA > 0.0){ + if (fractionOFA > 0.0) { rm3 += xMolei*xMolej*rm3ij; epsilon += xMolei*xMolej*rm3ij*epsilonij; alpha += xMolei*xMolej*rm3ij*epsilonij*alphaij; @@ -1147,9 +1147,9 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double } } - if (isOneFluidApprox(isite1)){ + if (isOneFluidApprox(isite1)) { rm1 = cbrt(rm3); - if(rm1 < MY_EPSILON) { + if (rm1 < MY_EPSILON) { rm1 = 0.0; epsilon1 = 0.0; alpha1 = 0.0; @@ -1161,7 +1161,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double fraction1 = fractionOFA; rm1_old = cbrt(rm3_old); - if(rm1_old < MY_EPSILON) { + if (rm1_old < MY_EPSILON) { rm1_old = 0.0; epsilon1_old = 0.0; alpha1_old = 0.0; @@ -1172,18 +1172,18 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); fractionOld1 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon1,rm1); exponentScaling(nMoleculesOFAold,epsilon1_old,rm1_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha1,epsilon1,rm1); polynomialScaling(nMoleculesOFAold,alpha1_old,epsilon1_old,rm1_old); } } - if (isOneFluidApprox(isite2)){ + if (isOneFluidApprox(isite2)) { rm2 = cbrt(rm3); - if(rm2 < MY_EPSILON) { + if (rm2 < MY_EPSILON) { rm2 = 0.0; epsilon2 = 0.0; alpha2 = 0.0; @@ -1195,7 +1195,7 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double fraction2 = fractionOFA; rm2_old = cbrt(rm3_old); - if(rm2_old < MY_EPSILON) { + if (rm2_old < MY_EPSILON) { rm2_old = 0.0; epsilon2_old = 0.0; alpha2_old = 0.0; @@ -1206,46 +1206,46 @@ void PairExp6rx::getMixingWeights(int id,double &epsilon1,double &alpha1,double nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); fractionOld2 = fractionOFAold; - if(scalingFlag == EXPONENT){ + if (scalingFlag == EXPONENT) { exponentScaling(nMoleculesOFA,epsilon2,rm2); exponentScaling(nMoleculesOFAold,epsilon2_old,rm2_old); - } else if(scalingFlag == POLYNOMIAL){ + } else if (scalingFlag == POLYNOMIAL) { polynomialScaling(nMoleculesOFA,alpha2,epsilon2,rm2); polynomialScaling(nMoleculesOFAold,alpha2_old,epsilon2_old,rm2_old); } } // Check that no fractions are less than zero - if(fraction1 < 0.0 || nMolecules1 < 0.0){ - if(fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON){ + if (fraction1 < 0.0 || nMolecules1 < 0.0) { + if (fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMolecules1 = 0.0; fraction1 = 0.0; } - if(fraction2 < 0.0 || nMolecules2 < 0.0){ - if(fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON){ + if (fraction2 < 0.0 || nMolecules2 < 0.0) { + if (fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMolecules2 = 0.0; fraction2 = 0.0; } - if(fractionOld1 < 0.0 || nMoleculesOld1 < 0.0){ - if(fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON){ + if (fractionOld1 < 0.0 || nMoleculesOld1 < 0.0) { + if (fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMoleculesOld1 = 0.0; fractionOld1 = 0.0; } - if(fractionOld2 < 0.0 || nMoleculesOld2 < 0.0){ - if(fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON){ + if (fractionOld2 < 0.0 || nMoleculesOld2 < 0.0) { + if (fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON) { error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON"); } nMoleculesOld2 = 0.0; fractionOld2 = 0.0; } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; @@ -1264,17 +1264,17 @@ void PairExp6rx::exponentScaling(double phi, double &epsilon, double &rm) const { double powfuch; - if(exponentEpsilon < 0.0){ + if (exponentEpsilon < 0.0) { powfuch = pow(phi,-exponentEpsilon); - if(powfuchone(FLERR,"Density < table inner cutoff"); itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); if (tabstyle == LOOKUP) evdwl = tb->e[itable]; - else if (tabstyle == LINEAR){ + else if (tabstyle == LINEAR) { if (itable >= tlm1) error->one(FLERR,"Density > table outer cutoff"); - if(itable==0) fraction_i=0.0; + if (itable==0) fraction_i=0.0; else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); evdwl = tb->e[itable] + fraction_i*tb->de[itable]; } else error->one(FLERR,"Only LOOKUP and LINEAR table styles have been implemented for pair multi/lucy"); diff --git a/src/USER-DPD/pair_multi_lucy_rx.cpp b/src/USER-DPD/pair_multi_lucy_rx.cpp index c4cc537b18..e1a263b7dc 100644 --- a/src/USER-DPD/pair_multi_lucy_rx.cpp +++ b/src/USER-DPD/pair_multi_lucy_rx.cpp @@ -193,7 +193,7 @@ void PairMultiLucyRX::compute(int eflag, int vflag) mixWtSite2old_j = mixWtSite2old[j]; tb = &tables[tabindex[itype][jtype]]; - if (rho[i]*rho[i] < tb->innersq || rho[j]*rho[j] < tb->innersq){ + if (rho[i]*rho[i] < tb->innersq || rho[j]*rho[j] < tb->innersq) { printf("Table inner cutoff = %lf\n",sqrt(tb->innersq)); printf("rho[%d]=%lf\n",i,rho[i]); printf("rho[%d]=%lf\n",j,rho[j]); @@ -202,7 +202,7 @@ void PairMultiLucyRX::compute(int eflag, int vflag) if (tabstyle == LOOKUP) { itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { printf("Table outer index = %d\n",tlm1); printf("itableIndex=%d rho[%d]=%lf\n",itable,i,rho[i]); printf("jtableIndex=%d rho[%d]=%lf\n",jtable,j,rho[j]); @@ -218,23 +218,23 @@ void PairMultiLucyRX::compute(int eflag, int vflag) } else if (tabstyle == LINEAR) { itable = static_cast ((rho[i]*rho[i] - tb->innersq) * tb->invdelta); jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); - if (itable >= tlm1 || jtable >= tlm1){ + if (itable >= tlm1 || jtable >= tlm1) { printf("Table outer index = %d\n",tlm1); printf("itableIndex=%d rho[%d]=%lf\n",itable,i,rho[i]); printf("jtableIndex=%d rho[%d]=%lf\n",jtable,j,rho[j]); error->one(FLERR,"Density > table outer cutoff"); } - if(itable<0) itable=0; - if(itable>=tlm1) itable=tlm1; - if(jtable<0) jtable=0; - if(jtable>=tlm1)jtable=tlm1; + if (itable<0) itable=0; + if (itable>=tlm1) itable=tlm1; + if (jtable<0) jtable=0; + if (jtable>=tlm1)jtable=tlm1; fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); fraction_j = (((rho[j]*rho[j]) - tb->rsq[jtable]) * tb->invdelta); - if(itable==0) fraction_i=0.0; - if(itable==tlm1) fraction_i=0.0; - if(jtable==0) fraction_j=0.0; - if(jtable==tlm1) fraction_j=0.0; + if (itable==0) fraction_i=0.0; + if (itable==tlm1) fraction_i=0.0; + if (jtable==0) fraction_j=0.0; + if (jtable==tlm1) fraction_j=0.0; A_i = tb->f[itable] + fraction_i*tb->df[itable]; A_j = tb->f[jtable] + fraction_j*tb->df[jtable]; @@ -267,12 +267,12 @@ void PairMultiLucyRX::compute(int eflag, int vflag) tb = &tables[tabindex[itype][itype]]; itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); if (tabstyle == LOOKUP) evdwl = tb->e[itable]; - else if (tabstyle == LINEAR){ - if (itable >= tlm1){ + else if (tabstyle == LINEAR) { + if (itable >= tlm1) { printf("itableIndex=%d rho[%d]=%lf\n",itable,i,rho[i]); error->one(FLERR,"Density > table outer cutoff"); } - if(itable==0) fraction_i=0.0; + if (itable==0) fraction_i=0.0; else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); evdwl = tb->e[itable] + fraction_i*tb->de[itable]; } else error->one(FLERR,"Only LOOKUP and LINEAR table styles have been implemented for pair multi/lucy/rx"); @@ -442,7 +442,7 @@ void PairMultiLucyRX::coeff(int narg, char **arg) else { isite1 = nspecies; for (int ispecies = 0; ispecies < nspecies; ++ispecies) - if (strcmp(site1, atom->dname[ispecies]) == 0){ + if (strcmp(site1, atom->dname[ispecies]) == 0) { isite1 = ispecies; break; } @@ -456,7 +456,7 @@ void PairMultiLucyRX::coeff(int narg, char **arg) else { isite2 = nspecies; for (int ispecies = 0; ispecies < nspecies; ++ispecies) - if (strcmp(site2, atom->dname[ispecies]) == 0){ + if (strcmp(site2, atom->dname[ispecies]) == 0) { isite2 = ispecies; break; } @@ -894,7 +894,7 @@ void PairMultiLucyRX::computeLocalDensity() // rho = density at each atom // loop over neighbors of my atoms - for (int ii = 0; ii < inum; ii++){ + for (int ii = 0; ii < inum; ii++) { const int i = ilist[ii]; const double xtmp = x[i][0]; @@ -907,7 +907,7 @@ void PairMultiLucyRX::computeLocalDensity() const int *jlist = firstneigh[i]; const int jnum = numneigh[i]; - for (int jj = 0; jj < jnum; jj++){ + for (int jj = 0; jj < jnum; jj++) { const int j = (jlist[jj] & NEIGHMASK); const int jtype = type[j]; @@ -960,44 +960,44 @@ void PairMultiLucyRX::getMixingWeights(int id, double &mixWtSite1old, double &mi nTotal = 0.0; nTotalOld = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += atom->dvector[ispecies][id]; nTotalOld += atom->dvector[ispecies+nspecies][id]; } - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = atom->dvector[isite1+nspecies][id]; nMolecules1 = atom->dvector[isite1][id]; fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = atom->dvector[isite2+nspecies][id]; nMolecules2 = atom->dvector[isite2][id]; fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += atom->dvector[ispecies+nspecies][id]; nMoleculesOFA += atom->dvector[ispecies][id]; fractionOFAold += atom->dvector[ispecies+nspecies][id] / nTotalOld; fractionOFA += atom->dvector[ispecies][id] / nTotal; } - if (isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if (isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -1005,7 +1005,7 @@ void PairMultiLucyRX::getMixingWeights(int id, double &mixWtSite1old, double &mi } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; diff --git a/src/USER-DPD/pair_table_rx.cpp b/src/USER-DPD/pair_table_rx.cpp index c418ebd4b3..6c975c97f3 100644 --- a/src/USER-DPD/pair_table_rx.cpp +++ b/src/USER-DPD/pair_table_rx.cpp @@ -198,14 +198,14 @@ void PairTableRX::compute(int eflag, int vflag) if (tabstyle == LOOKUP) evdwl = tb->e[itable]; - else if (tabstyle == LINEAR || tabstyle == BITMAP){ + else if (tabstyle == LINEAR || tabstyle == BITMAP) { evdwl = tb->e[itable] + fraction*tb->de[itable]; } else evdwl = a * tb->e[itable] + b * tb->e[itable+1] + ((a*a*a-a)*tb->e2[itable] + (b*b*b-b)*tb->e2[itable+1]) * tb->deltasq6; - if (isite1 == isite2){ + if (isite1 == isite2) { evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwl; evdwl = sqrt(mixWtSite1_i*mixWtSite2_j)*evdwl; } else { @@ -321,14 +321,14 @@ void PairTableRX::coeff(int narg, char **arg) bcast_table(tb); nspecies = atom->nspecies_dpd; - if(nspecies==0) error->all(FLERR,"There are no rx species specified."); + if (nspecies==0) error->all(FLERR,"There are no rx species specified."); int n; n = strlen(arg[4]) + 1; site1 = new char[n]; strcpy(site1,arg[4]); int ispecies; - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) @@ -338,7 +338,7 @@ void PairTableRX::coeff(int narg, char **arg) site2 = new char[n]; strcpy(site2,arg[5]); - for (ispecies = 0; ispecies < nspecies; ispecies++){ + for (ispecies = 0; ispecies < nspecies; ispecies++) { if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; } if (ispecies == nspecies && strcmp(site2,"1fluid") != 0) @@ -405,8 +405,8 @@ void PairTableRX::coeff(int narg, char **arg) else { isite1 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site1, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site1, atom->dname[k]) == 0) { isite1 = k; break; } @@ -420,8 +420,8 @@ void PairTableRX::coeff(int narg, char **arg) else { isite2 = nspecies; - for (int k = 0; k < nspecies; k++){ - if (strcmp(site2, atom->dname[k]) == 0){ + for (int k = 0; k < nspecies; k++) { + if (strcmp(site2, atom->dname[k]) == 0) { isite2 = ispecies; break; } @@ -519,46 +519,46 @@ void PairTableRX::getMixingWeights(int id, double &mixWtSite1old, double &mixWtS nTotal = 0.0; nTotalOld = 0.0; - for (int ispecies = 0; ispecies < nspecies; ++ispecies){ + for (int ispecies = 0; ispecies < nspecies; ++ispecies) { nTotal += atom->dvector[ispecies][id]; nTotalOld += atom->dvector[ispecies+nspecies][id]; } - if(nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) + if (nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) error->all(FLERR,"The number of molecules in CG particle is less than 10*DBL_EPSILON."); - if (isOneFluid(isite1) == false){ + if (isOneFluid(isite1) == false) { nMoleculesOld1 = atom->dvector[isite1+nspecies][id]; nMolecules1 = atom->dvector[isite1][id]; fractionOld1 = nMoleculesOld1/nTotalOld; fraction1 = nMolecules1/nTotal; } - if (isOneFluid(isite2) == false){ + if (isOneFluid(isite2) == false) { nMoleculesOld2 = atom->dvector[isite2+nspecies][id]; nMolecules2 = atom->dvector[isite2][id]; fractionOld2 = nMoleculesOld2/nTotalOld; fraction2 = nMolecules2/nTotal; } - if (isOneFluid(isite1) || isOneFluid(isite2)){ + if (isOneFluid(isite1) || isOneFluid(isite2)) { nMoleculesOFAold = 0.0; nMoleculesOFA = 0.0; fractionOFAold = 0.0; fractionOFA = 0.0; - for (int ispecies = 0; ispecies < nspecies; ispecies++){ + for (int ispecies = 0; ispecies < nspecies; ispecies++) { if (isite1 == ispecies || isite2 == ispecies) continue; nMoleculesOFAold += atom->dvector[ispecies+nspecies][id]; nMoleculesOFA += atom->dvector[ispecies][id]; fractionOFAold += atom->dvector[ispecies+nspecies][id]/nTotalOld; fractionOFA += atom->dvector[ispecies][id]/nTotal; } - if(isOneFluid(isite1)){ + if (isOneFluid(isite1)) { nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules1 = 1.0-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } - if(isOneFluid(isite2)){ + if (isOneFluid(isite2)) { nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); nMolecules2 = 1.0-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; @@ -566,7 +566,7 @@ void PairTableRX::getMixingWeights(int id, double &mixWtSite1old, double &mixWtS } } - if(fractionalWeighting){ + if (fractionalWeighting) { mixWtSite1old = fractionOld1; mixWtSite1 = fraction1; mixWtSite2old = fractionOld2; diff --git a/src/USER-DRUDE/compute_temp_drude.cpp b/src/USER-DRUDE/compute_temp_drude.cpp index b2e07bd68d..fe75c10fe3 100644 --- a/src/USER-DRUDE/compute_temp_drude.cpp +++ b/src/USER-DRUDE/compute_temp_drude.cpp @@ -155,8 +155,8 @@ void ComputeTempDrude::compute_vector() double ecore, edrude; double *vcore, *vdrude; double kineng_core_loc = 0., kineng_drude_loc = 0.; - for (int i=0; inlocal; int *type = atom->type; @@ -113,10 +113,10 @@ void FixDrude::build_drudeid(){ if (atom->molecular == Atom::MOLECULAR) { // Build list of my atoms' bond partners - for (int i=0; inum_bond[i]; k++){ + for (int k=0; knum_bond[i]; k++) { core_drude_vec.push_back(atom->tag[i]); core_drude_vec.push_back(atom->bond_atom[i][k]); } @@ -129,7 +129,7 @@ void FixDrude::build_drudeid(){ atommols = atom->avec->onemols; // Build list of my atoms' bond partners - for (int i=0; imolindex[i]; int iatom = atom->molatom[i]; tagint *batom = atommols[imol]->bond_atom[iatom]; @@ -138,7 +138,7 @@ void FixDrude::build_drudeid(){ if (drudetype[type[i]] == NOPOL_TYPE) continue; drudeid[i] = 0; - for (int k=0; ktag[i]); core_drude_vec.push_back(batom[k]+tagprev); } @@ -152,8 +152,8 @@ void FixDrude::build_drudeid(){ // Build the list of my Drudes' tags // The only bond partners of a Drude particle is its core, // so fill drudeid for my Drudes. - for (int i=0; itag[i]); drudeid[i] = *partner_set[i].begin(); // only one 1-2 neighbor, the core } @@ -172,7 +172,7 @@ void FixDrude::build_drudeid(){ * Look in my cores' bond partner tags if there is a Drude tag. * If so fill this core's dureid. ------------------------------------------------------------------------- */ -void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr){ +void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr) { // Search for the drude partner of my cores FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -190,7 +190,7 @@ void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr){ for (int i=0; i 0) continue; for (it = partner_set[i].begin(); it != partner_set[i].end(); it++) { // Drude-core are 1-2 neighbors - if (drude_set.count(*it) > 0){ + if (drude_set.count(*it) > 0) { drudeid[i] = *it; break; } @@ -202,7 +202,7 @@ void FixDrude::ring_search_drudeid(int size, char *cbuf, void *ptr){ * buffer contains bond partners. Look for my atoms and add their partner's * tag in its set of bond partners. ------------------------------------------------------------------------- */ -void FixDrude::ring_build_partner(int size, char *cbuf, void *ptr){ +void FixDrude::ring_build_partner(int size, char *cbuf, void *ptr) { // Add partners from incoming list FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -270,7 +270,7 @@ int FixDrude::unpack_exchange(int nlocal, double *buf) int FixDrude::pack_border(int n, int *list, double *buf) { int m = 0; - for (int i=0; inlocal; @@ -330,7 +330,7 @@ void FixDrude::rebuild_special(){ for (int i=0; itag[i]); - } else if (drudetype[type[i]] == CORE_TYPE){ + } else if (drudetype[type[i]] == CORE_TYPE) { core_drude_vec.push_back(atom->tag[i]); core_drude_vec.push_back(drudeid[i]); } @@ -380,7 +380,7 @@ void FixDrude::rebuild_special(){ * When receive buffer, build a set of drude tags, look into my atoms' * special list if some tags are drude particles. If so, remove it. ------------------------------------------------------------------------- */ -void FixDrude::ring_remove_drude(int size, char *cbuf, void *ptr){ +void FixDrude::ring_remove_drude(int size, char *cbuf, void *ptr) { // Remove all drude particles from special list FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -416,7 +416,7 @@ void FixDrude::ring_remove_drude(int size, char *cbuf, void *ptr){ * Loop on my atoms' special list to find core tags. Insert their Drude * particle if they have one. ------------------------------------------------------------------------- */ -void FixDrude::ring_add_drude(int size, char *cbuf, void *ptr){ +void FixDrude::ring_add_drude(int size, char *cbuf, void *ptr) { // Assume special array size is big enough // Add all particle just after their core in the special list FixDrude *fdptr = (FixDrude *) ptr; @@ -473,7 +473,7 @@ void FixDrude::ring_add_drude(int size, char *cbuf, void *ptr){ * in the buffer. Loop on my Drude particles and copy their special * info from that of their core if the latter is found in the map. ------------------------------------------------------------------------- */ -void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr){ +void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr) { // Copy special list of drude from its core (except itself) FixDrude *fdptr = (FixDrude *) ptr; Atom *atom = fdptr->atom; @@ -520,8 +520,8 @@ void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr){ * Set drudeid when a new atom is created, * special list must be up-to-date * ----------------------------------------------------------------------*/ -void FixDrude::set_arrays(int i){ - if (drudetype[atom->type[i]] != NOPOL_TYPE){ +void FixDrude::set_arrays(int i) { + if (drudetype[atom->type[i]] != NOPOL_TYPE) { if (atom->nspecial[i] ==0) error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template"); drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list } else { diff --git a/src/USER-DRUDE/fix_drude_transform.cpp b/src/USER-DRUDE/fix_drude_transform.cpp index 659984131c..d75481c2c8 100644 --- a/src/USER-DRUDE/fix_drude_transform.cpp +++ b/src/USER-DRUDE/fix_drude_transform.cpp @@ -83,7 +83,7 @@ void FixDrudeTransform::setup(int) { int j = atom->map(drudeid[i]); // i is drude, j is core if (mcoeff_loc[type[i]] < 1.5) { // already done - if (mcoeff_loc[type[j]] > 1.5){ // not yet done ?? + if (mcoeff_loc[type[j]] > 1.5) { // not yet done ?? error->all(FLERR,"There must be one Drude type per core type");} continue; } @@ -103,28 +103,28 @@ void FixDrudeTransform::setup(int) { /* ---------------------------------------------------------------------- */ namespace LAMMPS_NS { // required for specialization template <> -void FixDrudeTransform::initial_integrate(int){ +void FixDrudeTransform::initial_integrate(int) { comm->forward_comm_fix(this); real_to_reduced(); //comm->forward_comm_fix(this); // Normally not needed } template <> -void FixDrudeTransform::final_integrate(){ +void FixDrudeTransform::final_integrate() { comm->forward_comm_fix(this); real_to_reduced(); //comm->forward_comm_fix(this); // Normally not needed } template <> -void FixDrudeTransform::initial_integrate(int){ +void FixDrudeTransform::initial_integrate(int) { comm->forward_comm_fix(this); reduced_to_real(); //comm->forward_comm_fix(this); // Normally not needed } template <> -void FixDrudeTransform::final_integrate(){ +void FixDrudeTransform::final_integrate() { comm->forward_comm_fix(this); reduced_to_real(); //comm->forward_comm_fix(this); // Normally not needed diff --git a/src/USER-DRUDE/fix_langevin_drude.cpp b/src/USER-DRUDE/fix_langevin_drude.cpp index 2b45862868..4e905d16d3 100644 --- a/src/USER-DRUDE/fix_langevin_drude.cpp +++ b/src/USER-DRUDE/fix_langevin_drude.cpp @@ -271,7 +271,7 @@ void FixLangevinDrude::post_force(int /*vflag*/) Gcore = mi / t_period_core / ftm2v; Ccore = sqrt(2.0 * Gcore * kb * t_target_core / dt / ftm2v / mvv2e); if (temperature) temperature->remove_bias(i, v[i]); - for(int k = 0; k < dim; k++){ + for (int k = 0; k < dim; k++) { fcore[k] = Ccore * random_core->gaussian() - Gcore * v[i][k]; if (zero) fcoreloc[k] += fcore[k]; f[i][k] += fcore[k]; @@ -326,7 +326,7 @@ void FixLangevinDrude::post_force(int /*vflag*/) } } - if(zero) { // Remove the drift + if (zero) { // Remove the drift MPI_Allreduce(fcoreloc, fcoresum, dim, MPI_DOUBLE, MPI_SUM, world); for (int k=0; k (list[n++]); if (tstat_flag && m == mtchain) { - for (int ich = 0; ich < mtchain; ich++){ + for (int ich = 0; ich < mtchain; ich++) { etamol[ich] = list[n++]; etaint[ich] = list[n++]; etadrude[ich] = list[n++]; } - for (int ich = 0; ich < mtchain; ich++){ + for (int ich = 0; ich < mtchain; ich++) { etamol_dot[ich] = list[n++]; etaint_dot[ich] = list[n++]; etadrude_dot[ich] = list[n++]; @@ -1509,7 +1509,7 @@ double FixTGNHDrude::compute_scalar() energy += ke2mol_target * etamol[0] + 0.5 * etamol_mass[0] * etamol_dot[0] * etamol_dot[0]; energy += ke2int_target * etaint[0] + 0.5 * etaint_mass[0] * etaint_dot[0] * etaint_dot[0]; energy += ke2drude_target * etadrude[0] + 0.5 * etadrude_mass[0] * etadrude_dot[0] * etadrude_dot[0]; - for (ich = 1; ich < mtchain; ich++){ + for (ich = 1; ich < mtchain; ich++) { energy += kt * etamol[ich] + 0.5*etamol_mass[ich]*etamol_dot[ich]*etamol_dot[ich]; energy += kt * etaint[ich] + 0.5*etaint_mass[ich]*etaint_dot[ich]*etaint_dot[ich]; energy += kt_drude * etadrude[ich] + 0.5*etadrude_mass[ich]*etadrude_dot[ich]*etadrude_dot[ich]; @@ -1565,7 +1565,7 @@ double FixTGNHDrude::compute_vector(int n) { if (!temp_computed_end_of_step) compute_temp_mol_int_drude(true); - switch (n){ + switch (n) { case 0: return t_mol; case 1: @@ -1711,7 +1711,7 @@ void FixTGNHDrude::nhc_temp_integrate() // update masses of thermostat in case target temperature changes etamol_mass[0] = ke2mol_target / (t_freq*t_freq); etaint_mass[0] = ke2int_target / (t_freq*t_freq); - for (int ich = 1; ich < mtchain; ich++){ + for (int ich = 1; ich < mtchain; ich++) { etamol_mass[ich] = boltz * t_target / (t_freq*t_freq); etaint_mass[ich] = boltz * t_target / (t_freq*t_freq); } diff --git a/src/USER-DRUDE/pair_coul_tt.cpp b/src/USER-DRUDE/pair_coul_tt.cpp index a051b6e3c6..a807ea3c16 100644 --- a/src/USER-DRUDE/pair_coul_tt.cpp +++ b/src/USER-DRUDE/pair_coul_tt.cpp @@ -163,7 +163,7 @@ void PairCoulTT::compute(int eflag, int vflag) dcoul = qqrd2e * qi * qj *scale[itype][jtype] * rinv; factor_f = (-beta*gamma + r*betaprime*gamma + r*beta*gammaprime)*factor_coul; - if(eflag) factor_e = - beta*gamma*factor_coul; + if (eflag) factor_e = - beta*gamma*factor_coul; fpair = factor_f * dcoul * r2inv; f[i][0] += delx*fpair; diff --git a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp index 6046061aa5..84437f408a 100644 --- a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp +++ b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp @@ -131,7 +131,7 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) jlist = firstneigh[i]; jnum = numneigh[i]; - if (drudetype[type[i]] != NOPOL_TYPE){ + if (drudetype[type[i]] != NOPOL_TYPE) { di = atom->map(drudeid[i]); if (di < 0) error->all(FLERR, "Drude partner not found"); di_closest = domain->closest_image(i, di); @@ -187,9 +187,9 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) } if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE){ - if (j != di_closest){ - if (drudetype[type[j]] == CORE_TYPE){ + drudetype[type[j]] != NOPOL_TYPE) { + if (j != di_closest) { + if (drudetype[type[j]] == CORE_TYPE) { dj = atom->map(drudeid[j]); dqj = -q[dj]; } else dqj = qj; @@ -231,7 +231,7 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) } if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE && j != di_closest){ + drudetype[type[j]] != NOPOL_TYPE && j != di_closest) { ecoul += factor_e * dcoul; } } else ecoul = 0.0; diff --git a/src/USER-DRUDE/pair_thole.cpp b/src/USER-DRUDE/pair_thole.cpp index d95309406a..418705e0a3 100644 --- a/src/USER-DRUDE/pair_thole.cpp +++ b/src/USER-DRUDE/pair_thole.cpp @@ -137,7 +137,7 @@ void PairThole::compute(int eflag, int vflag) exp_asr = exp(-asr); dcoul = qqrd2e * qi * qj *scale[itype][jtype] * rinv; factor_f = 0.5*(2. + (exp_asr * (-2. - asr * (2. + asr)))) - factor_coul; - if(eflag) factor_e = 0.5*(2. - (exp_asr * (2. + asr))) - factor_coul; + if (eflag) factor_e = 0.5*(2. - (exp_asr * (2. + asr))) - factor_coul; fpair = factor_f * dcoul * r2inv; f[i][0] += delx*fpair; diff --git a/src/USER-FEP/pair_morse_soft.cpp b/src/USER-FEP/pair_morse_soft.cpp index f7216829d6..d429503237 100644 --- a/src/USER-FEP/pair_morse_soft.cpp +++ b/src/USER-FEP/pair_morse_soft.cpp @@ -35,7 +35,7 @@ using namespace MathSpecial; PairMorseSoft::~PairMorseSoft() { - if(allocated){ + if (allocated) { memory->destroy(lambda); } } @@ -108,7 +108,7 @@ void PairMorseSoft::compute(int eflag, int vflag) V0 = D * dexp * ( dexp - 2.0 ); B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; - if (l >= shift_range){ + if (l >= shift_range) { s1 = (l - 1.0) / (shift_range - 1.0); phi = V0 + B*dexp3 * s1; @@ -121,7 +121,7 @@ void PairMorseSoft::compute(int eflag, int vflag) phi *= llf; // Force computation: - if (r == 0.0){ + if (r == 0.0) { fpair = 0.0; } else { fpair = 3.0*a*B*dexp3 + 2.0*a*D*(dexp2 - dexp); @@ -256,7 +256,7 @@ double PairMorseSoft::init_one(int i, int j) V0 = D * dexp * ( dexp - 2.0 ); B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; - if (l >= shift_range){ + if (l >= shift_range) { s1 = (l - 1.0) / (shift_range - 1.0); offset[i][j] = V0 + B*dexp3 * s1; } else { @@ -415,7 +415,7 @@ double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double V0 = D * dexp * ( dexp - 2.0 ); B = -2.0 * D * iea2 * ( ea - 1.0 ) / 3.0; - if (l >= shift_range){ + if (l >= shift_range) { s1 = (l - 1.0) / (shift_range - 1.0); phi = V0 + B*dexp3 * s1; @@ -428,7 +428,7 @@ double PairMorseSoft::single(int /*i*/, int /*j*/, int itype, int jtype, double phi *= llf; // Force computation: - if (r == 0.0){ + if (r == 0.0) { fforce = 0.0; } else { fforce = 3.0*a*B*dexp3 + 2.0*a*D*(dexp2 - dexp); diff --git a/src/USER-INTEL/fix_intel.cpp b/src/USER-INTEL/fix_intel.cpp index 95c2ec320a..ea65a91953 100644 --- a/src/USER-INTEL/fix_intel.cpp +++ b/src/USER-INTEL/fix_intel.cpp @@ -783,7 +783,7 @@ void FixIntel::add_oresults(const ft * _noalias const f_in, if (_nthreads > INTEL_HTHREADS) packthreads = _nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { #if defined(_OPENMP) @@ -1266,7 +1266,7 @@ int FixIntel::set_host_affinity(const int nomp) if (nlwp <= plwp) continue; CPU_ZERO(&cpuset); - for(int i=0; i * buffers) { if (comm->nthreads > INTEL_HTHREADS) nthreads = comm->nthreads; else nthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(nthreads > INTEL_HTHREADS) + #pragma omp parallel if (nthreads > INTEL_HTHREADS) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/npair_full_bin_ghost_intel.cpp b/src/USER-INTEL/npair_full_bin_ghost_intel.cpp index 2475b69b8f..d15c5d9d4e 100644 --- a/src/USER-INTEL/npair_full_bin_ghost_intel.cpp +++ b/src/USER-INTEL/npair_full_bin_ghost_intel.cpp @@ -216,7 +216,7 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, const int * _noalias const bins = this->bins; const int cop = _fix->coprocessor_number(); const int separate_buffers = _fix->separate_buffers(); - #pragma offload target(mic:cop) if(offload) \ + #pragma offload target(mic:cop) if (offload) \ in(x:length(e_nall+1) alloc_if(0) free_if(0)) \ in(tag:length(tag_size) alloc_if(0) free_if(0)) \ in(special:length(special_size*maxspecial) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/npair_halffull_newton_intel.cpp b/src/USER-INTEL/npair_halffull_newton_intel.cpp index de0fa9c17d..b45c1a8023 100644 --- a/src/USER-INTEL/npair_halffull_newton_intel.cpp +++ b/src/USER-INTEL/npair_halffull_newton_intel.cpp @@ -151,7 +151,7 @@ void NPairHalffullNewtonIntel::build_t3(NeighList *list, int *numhalf) if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int tid, ifrom, ito; diff --git a/src/USER-INTEL/npair_intel.cpp b/src/USER-INTEL/npair_intel.cpp index 5c6a0cf1b5..c224775a26 100644 --- a/src/USER-INTEL/npair_intel.cpp +++ b/src/USER-INTEL/npair_intel.cpp @@ -211,7 +211,7 @@ void NPairIntel::bin_newton(const int offload, NeighList *list, const int * _noalias const bins = this->bins; const int cop = _fix->coprocessor_number(); const int separate_buffers = _fix->separate_buffers(); - #pragma offload target(mic:cop) if(offload) \ + #pragma offload target(mic:cop) if (offload) \ in(x:length(e_nall+1) alloc_if(0) free_if(0)) \ in(tag:length(tag_size) alloc_if(0) free_if(0)) \ in(special:length(special_size*maxspecial) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/npair_skip_intel.cpp b/src/USER-INTEL/npair_skip_intel.cpp index 5d88fe511d..4f6648ddc1 100644 --- a/src/USER-INTEL/npair_skip_intel.cpp +++ b/src/USER-INTEL/npair_skip_intel.cpp @@ -95,7 +95,7 @@ void NPairSkipIntel::build_t(NeighList *list, int *numhalf, int *cnumneigh, packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int tid, ifrom, ito; diff --git a/src/USER-INTEL/pair_airebo_intel.cpp b/src/USER-INTEL/pair_airebo_intel.cpp index a25a2d403d..f8f094ec9f 100644 --- a/src/USER-INTEL/pair_airebo_intel.cpp +++ b/src/USER-INTEL/pair_airebo_intel.cpp @@ -308,7 +308,7 @@ void PairAIREBOIntel::compute( if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -450,7 +450,7 @@ void PairAIREBOIntel::eval( if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ in(numneigh:length(0) alloc_if(0) free_if(0)) \ in(numneighhalf:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp index 3da131684c..1aec1dcbf7 100644 --- a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp @@ -90,7 +90,7 @@ void PairBuckCoulCutIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -177,7 +177,7 @@ void PairBuckCoulCutIntel::eval(const int offload, const int vflag, const int ncoulshiftbits = this->ncoulshiftbits; if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy, c_cut:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ @@ -273,10 +273,10 @@ void PairBuckCoulCutIntel::eval(const int offload, const int vflag, forcecoul = qqrd2e * qtmp*q[j]/r; if (EFLAG) ecoul = forcecoul; - if (sbindex){ + if (sbindex) { const flt_t factor_coul = special_coul[sbindex]; forcecoul *= factor_coul; - if(EFLAG) + if (EFLAG) ecoul *= factor_coul; } diff --git a/src/USER-INTEL/pair_buck_coul_long_intel.cpp b/src/USER-INTEL/pair_buck_coul_long_intel.cpp index 6ab255d5d7..d56b0dfd24 100644 --- a/src/USER-INTEL/pair_buck_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_long_intel.cpp @@ -90,7 +90,7 @@ void PairBuckCoulLongIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -200,7 +200,7 @@ void PairBuckCoulLongIntel::eval(const int offload, const int vflag, #endif if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy:length(0) alloc_if(0) free_if(0)) \ in(rho_inv:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_buck_intel.cpp b/src/USER-INTEL/pair_buck_intel.cpp index afa9b448b5..77f6a1136c 100644 --- a/src/USER-INTEL/pair_buck_intel.cpp +++ b/src/USER-INTEL/pair_buck_intel.cpp @@ -83,7 +83,7 @@ void PairBuckIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -162,7 +162,7 @@ void PairBuckIntel::eval(const int offload, const int vflag, // Redeclare as local variables for offload if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_dpd_intel.cpp b/src/USER-INTEL/pair_dpd_intel.cpp index a0a71e4a37..45da3cccd7 100644 --- a/src/USER-INTEL/pair_dpd_intel.cpp +++ b/src/USER-INTEL/pair_dpd_intel.cpp @@ -99,7 +99,7 @@ void PairDPDIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/pair_eam_alloy_intel.cpp b/src/USER-INTEL/pair_eam_alloy_intel.cpp index 0da792b4e0..04ee07ca82 100644 --- a/src/USER-INTEL/pair_eam_alloy_intel.cpp +++ b/src/USER-INTEL/pair_eam_alloy_intel.cpp @@ -116,7 +116,7 @@ void PairEAMAlloyIntel::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/USER-INTEL/pair_eam_fs_intel.cpp b/src/USER-INTEL/pair_eam_fs_intel.cpp index 8b1437203f..0eb2cda43d 100644 --- a/src/USER-INTEL/pair_eam_fs_intel.cpp +++ b/src/USER-INTEL/pair_eam_fs_intel.cpp @@ -116,7 +116,7 @@ void PairEAMFSIntel::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(lmp, filename, "eam/fs", unit_convert_flag); // transparently convert units for supported conversions diff --git a/src/USER-INTEL/pair_eam_intel.cpp b/src/USER-INTEL/pair_eam_intel.cpp index a25d588ecf..206bdd5ee6 100644 --- a/src/USER-INTEL/pair_eam_intel.cpp +++ b/src/USER-INTEL/pair_eam_intel.cpp @@ -95,7 +95,7 @@ void PairEAMIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/pair_gayberne_intel.cpp b/src/USER-INTEL/pair_gayberne_intel.cpp index c34c6965de..fd79b5812b 100644 --- a/src/USER-INTEL/pair_gayberne_intel.cpp +++ b/src/USER-INTEL/pair_gayberne_intel.cpp @@ -93,7 +93,7 @@ void PairGayBerneIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -276,7 +276,7 @@ void PairGayBerneIntel::eval(const int offload, const int vflag, double *timer_compute = fix->off_watch_pair(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj:length(0) alloc_if(0) free_if(0)) \ in(ijc,lj34,ic:length(0) alloc_if(0) free_if(0)) \ in(rsq_formi, delx_formi, dely_formi: length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp index 8f4dba4a24..850af0de6f 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -86,7 +86,7 @@ void PairLJCharmmCoulCharmmIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -184,7 +184,7 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, double *timer_compute = fix->off_watch_pair(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(cutsq,lj:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp index ffed4853ba..ad15c045ab 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -87,7 +87,7 @@ void PairLJCharmmCoulLongIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -202,7 +202,7 @@ void PairLJCharmmCoulLongIntel::eval(const int offload, const int vflag, #endif if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(cutsq,lj:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp index c1d85ad37f..d6d763677c 100644 --- a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp @@ -88,7 +88,7 @@ void PairLJCutCoulLongIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -197,7 +197,7 @@ void PairLJCutCoulLongIntel::eval(const int offload, const int vflag, #endif if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(special_lj,special_coul:length(0) alloc_if(0) free_if(0)) \ in(c_force, c_energy:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_lj_cut_intel.cpp b/src/USER-INTEL/pair_lj_cut_intel.cpp index 8697a4f548..6499f1cec8 100644 --- a/src/USER-INTEL/pair_lj_cut_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_intel.cpp @@ -79,7 +79,7 @@ void PairLJCutIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-INTEL/pair_sw_intel.cpp b/src/USER-INTEL/pair_sw_intel.cpp index 1af8d3e972..984b2100a3 100644 --- a/src/USER-INTEL/pair_sw_intel.cpp +++ b/src/USER-INTEL/pair_sw_intel.cpp @@ -110,7 +110,7 @@ void PairSWIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -227,7 +227,7 @@ void PairSWIntel::eval(const int offload, const int vflag, int *overflow = fix->get_off_overflow_flag(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(p2,p2f,p2f2,p2e,p3:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ in(cnumneigh:length(0) alloc_if(0) free_if(0)) \ @@ -646,7 +646,7 @@ void PairSWIntel::eval(const int offload, const int vflag, int *overflow = fix->get_off_overflow_flag(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(p2,p2f,p2f2,p2e,p3:length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ in(cnumneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pair_tersoff_intel.cpp b/src/USER-INTEL/pair_tersoff_intel.cpp index b86be522bf..bce2045f26 100644 --- a/src/USER-INTEL/pair_tersoff_intel.cpp +++ b/src/USER-INTEL/pair_tersoff_intel.cpp @@ -123,7 +123,7 @@ void PairTersoffIntel::compute(int eflag, int vflag, if (nthreads > INTEL_HTHREADS) packthreads = nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; @@ -309,7 +309,7 @@ void PairTersoffIntel::eval(const int offload, const int vflag, int *overflow = fix->get_off_overflow_flag(); double *timer_compute = fix->off_watch_pair(); if (offload) fix->start_watch(TIME_OFFLOAD_LATENCY); - #pragma offload target(mic:_cop) if(offload) \ + #pragma offload target(mic:_cop) if (offload) \ in(c_inner, c_outer :length(0) alloc_if(0) free_if(0)) \ in(c_inner_cutoff :length(0) alloc_if(0) free_if(0)) \ in(firstneigh:length(0) alloc_if(0) free_if(0)) \ diff --git a/src/USER-INTEL/pppm_disp_intel.cpp b/src/USER-INTEL/pppm_disp_intel.cpp index 5a119e4470..88fb6374ab 100644 --- a/src/USER-INTEL/pppm_disp_intel.cpp +++ b/src/USER-INTEL/pppm_disp_intel.cpp @@ -148,7 +148,7 @@ void PPPMDispIntel::init() memory->create(rho6_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmdispintel:rho6_lookup"); - if(differentiation_flag == 1) { + if (differentiation_flag == 1) { memory->destroy(drho_lookup); memory->create(drho_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmdispintel:drho_lookup"); @@ -198,7 +198,7 @@ void PPPMDispIntel::compute(int eflag, int vflag) memory->destroy(particle_ekx); memory->destroy(particle_eky); memory->destroy(particle_ekz); - if (function[2] == 1){ + if (function[2] == 1) { memory->destroy(particle_ekx0); memory->destroy(particle_eky0); memory->destroy(particle_ekz0); @@ -231,7 +231,7 @@ void PPPMDispIntel::compute(int eflag, int vflag) memory->create(particle_ekx, nmax, "pppmdispintel:pekx"); memory->create(particle_eky, nmax, "pppmdispintel:peky"); memory->create(particle_ekz, nmax, "pppmdispintel:pekz"); - if (function[2] == 1){ + if (function[2] == 1) { memory->create(particle_ekx0, nmax, "pppmdispintel:pekx0"); memory->create(particle_eky0, nmax, "pppmdispintel:peky0"); memory->create(particle_ekz0, nmax, "pppmdispintel:pekz0"); @@ -752,7 +752,7 @@ void PPPMDispIntel::particle_map(double delx, double dely, double delz, #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ shared(nlocal, nthr, delx, dely, delz, sft, p2g, nup, nlow, nxlo,\ - nylo, nzlo, nxhi, nyhi, nzhi) reduction(+:flag) if(!_use_lrt) + nylo, nzlo, nxhi, nyhi, nzhi) reduction(+:flag) if (!_use_lrt) #endif { double **x = atom->x; @@ -825,7 +825,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { double *q = atom->q; @@ -877,7 +877,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -931,7 +931,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) // reduce all the perthread_densities into global_density #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -941,7 +941,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -973,7 +973,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { int type; @@ -1026,7 +1026,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -1081,7 +1081,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) // reduce all the perthread_densities into global_density #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -1091,7 +1091,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -1174,7 +1174,7 @@ void PPPMDispIntel::make_rho_a(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -1256,7 +1256,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { int type; @@ -1308,7 +1308,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -1354,7 +1354,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) for (int l = 0; l < order; l++) { int mzyx = l + mzy; FFT_SCALAR w0 = x0*rho[0][l]; - for(int k = 0; k < nsplit; k++) + for (int k = 0; k < nsplit; k++) my_density[mzyx + k*ngrid_6] += x0*rho[0][l]; } } @@ -1365,7 +1365,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) // reduce all the perthread_densities into global_density #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -1375,7 +1375,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -1408,7 +1408,7 @@ void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1558,7 +1558,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1625,7 +1625,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -1694,7 +1694,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx[i] += ekx[l]; particle_eky[i] += eky[l]; particle_ekz[i] += ekz[l]; @@ -1756,7 +1756,7 @@ void PPPMDispIntel::fieldforce_g_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1903,7 +1903,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -1968,7 +1968,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -2037,7 +2037,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx[i] += ekx[l]; particle_eky[i] += eky[l]; particle_ekz[i] += ekz[l]; @@ -2100,7 +2100,7 @@ void PPPMDispIntel::fieldforce_a_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { double **x = atom->x; @@ -2334,7 +2334,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -2399,7 +2399,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -2515,7 +2515,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx0[i] += ekx0[l]; particle_eky0[i] += eky0[l]; particle_ekz0[i] += ekz0[l]; @@ -2625,7 +2625,7 @@ void PPPMDispIntel::fieldforce_none_ik(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -2784,7 +2784,7 @@ void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { @@ -2849,7 +2849,7 @@ void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho6_lookup[idx][k]; rho[1][k] = rho6_lookup[idy][k]; rho[2][k] = rho6_lookup[idz][k]; @@ -2934,7 +2934,7 @@ void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { for (int k = 0; k < nsplit; k++) { ekx_tot[k] += ekx[k*INTEL_P3M_ALIGNED_MAXORDER+l]; eky_tot[k] += eky[k*INTEL_P3M_ALIGNED_MAXORDER+l]; @@ -2993,9 +2993,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for (int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-1; l>=0; l--){ + for (int l=order-1; l>=0; l--) { r1 = rho_coeff[l][k] + r1*dx; } rho_lookup[i][k-nlower] = r1; @@ -3007,9 +3007,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-2; l>=0; l--){ + for (int l=order-2; l>=0; l--) { r1 = drho_coeff[l][k] + r1*dx; } drho_lookup[i][k-nlower] = r1; @@ -3027,9 +3027,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for (int k=nlower_6; k<=nupper_6;k++){ + for (int k=nlower_6; k<=nupper_6;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order_6-1; l>=0; l--){ + for (int l=order_6-1; l>=0; l--) { r1 = rho_coeff_6[l][k] + r1*dx; } rho6_lookup[i][k-nlower_6] = r1; @@ -3041,9 +3041,9 @@ void PPPMDispIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k=nlower_6; k<=nupper_6;k++){ + for (int k=nlower_6; k<=nupper_6;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order_6-2; l>=0; l--){ + for (int l=order_6-2; l>=0; l--) { r1 = drho_coeff_6[l][k] + r1*dx; } drho6_lookup[i][k-nlower_6] = r1; diff --git a/src/USER-INTEL/pppm_intel.cpp b/src/USER-INTEL/pppm_intel.cpp index bf55dc3d2e..6e836dd3b3 100644 --- a/src/USER-INTEL/pppm_intel.cpp +++ b/src/USER-INTEL/pppm_intel.cpp @@ -125,7 +125,7 @@ void PPPMIntel::init() memory->destroy(rho_lookup); memory->create(rho_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmintel:rho_lookup"); - if(differentiation_flag == 1) { + if (differentiation_flag == 1) { memory->destroy(drho_lookup); memory->create(drho_lookup, rho_points, INTEL_P3M_ALIGNED_MAXORDER, "pppmintel:drho_lookup"); @@ -378,7 +378,7 @@ void PPPMIntel::particle_map(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) reduction(+:flag) if(!_use_lrt) + shared(nlocal, nthr) reduction(+:flag) if (!_use_lrt) #endif { const flt_t lo0 = boxlo[0]; @@ -452,7 +452,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, nlocal, global_density) if(!_use_lrt) + shared(nthr, nlocal, global_density) if (!_use_lrt) #endif { const int nix = nxhi_out - nxlo_out + 1; @@ -501,7 +501,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -555,7 +555,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) if (nthr > 1) { #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nthr, global_density) if(!_use_lrt) + shared(nthr, global_density) if (!_use_lrt) #endif { int ifrom, ito, tid; @@ -565,7 +565,7 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) #pragma simd #endif for (int i = ifrom; i < ito; i++) { - for(int j = 1; j < nthr; j++) { + for (int j = 1; j < nthr; j++) { global_density[i] += perthread_density[j-1][i]; } } @@ -604,7 +604,7 @@ void PPPMIntel::fieldforce_ik(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { const flt_t lo0 = boxlo[0]; @@ -755,7 +755,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #if defined(_OPENMP) #pragma omp parallel LMP_DEFAULT_NONE \ - shared(nlocal, nthr) if(!_use_lrt) + shared(nlocal, nthr) if (!_use_lrt) #endif { const flt_t ftwo_pi = MY_PI * 2.0; @@ -814,7 +814,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { + for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { rho[0][k] = rho_lookup[idx][k]; rho[1][k] = rho_lookup[idy][k]; rho[2][k] = rho_lookup[idz][k]; @@ -884,7 +884,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) #endif - for (int l = 0; l < order; l++){ + for (int l = 0; l < order; l++) { particle_ekx[i] += ekx[l]; particle_eky[i] += eky[l]; particle_ekz[i] += ekz[l]; @@ -943,9 +943,9 @@ void PPPMIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for (int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-1; l>=0; l--){ + for (int l=order-1; l>=0; l--) { r1 = rho_coeff[l][k] + r1*dx; } rho_lookup[i][k-nlower] = r1; @@ -957,9 +957,9 @@ void PPPMIntel::precompute_rho() #if defined(LMP_SIMD_COMPILER) #pragma simd #endif - for(int k=nlower; k<=nupper;k++){ + for (int k=nlower; k<=nupper;k++) { FFT_SCALAR r1 = ZEROF; - for(int l=order-2; l>=0; l--){ + for (int l=order-2; l>=0; l--) { r1 = drho_coeff[l][k] + r1*dx; } drho_lookup[i][k-nlower] = r1; @@ -1005,7 +1005,7 @@ void PPPMIntel::pack_buffers() if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; else packthreads = 1; #if defined(_OPENMP) - #pragma omp parallel if(packthreads > 1) + #pragma omp parallel if (packthreads > 1) #endif { int ifrom, ito, tid; diff --git a/src/USER-LB/fix_lb_fluid.cpp b/src/USER-LB/fix_lb_fluid.cpp index bf67502759..351e078dad 100644 --- a/src/USER-LB/fix_lb_fluid.cpp +++ b/src/USER-LB/fix_lb_fluid.cpp @@ -84,7 +84,7 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : // the 15 velocity D3Q15 model is used. //===================================================================================================== - if(narg <7) error->all(FLERR,"Illegal fix lb/fluid command"); + if (narg <7) error->all(FLERR,"Illegal fix lb/fluid command"); if (comm->style != 0) error->universe_all(FLERR,"Fix lb/fluid can only currently be used with " @@ -120,73 +120,73 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : NodeArea = nullptr; int iarg = 7; - while (iarg < narg){ - if(strcmp(arg[iarg],"setArea")==0){ - if(setGamma == 1) + while (iarg < narg) { + if (strcmp(arg[iarg],"setArea")==0) { + if (setGamma == 1) error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); setArea = 1; int itype = atoi(arg[iarg+1]); double areafactor = atof(arg[iarg+2]); - if(itype <= 0 || itype > atom->ntypes || areafactor < 0.0) + if (itype <= 0 || itype > atom->ntypes || areafactor < 0.0) error->all(FLERR,"Illegal fix lb/fluid command: setArea"); - if(NodeArea == nullptr){ + if (NodeArea == nullptr) { NodeArea = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; + for (int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; } NodeArea[itype] = areafactor; iarg += 3; } - else if(strcmp(arg[iarg],"setGamma")==0){ - if(setArea == 1) + else if (strcmp(arg[iarg],"setGamma")==0) { + if (setArea == 1) error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); setGamma = 1; double Gammaone; Gammaone = atof(arg[iarg+1]); - if(Gamma == nullptr) + if (Gamma == nullptr) Gamma = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) Gamma[i] = Gammaone; + for (int i=0; i<=atom->ntypes; i++) Gamma[i] = Gammaone; iarg += 2; } - else if(strcmp(arg[iarg],"scaleGamma")==0){ - if(setGamma == 0) + else if (strcmp(arg[iarg],"scaleGamma")==0) { + if (setGamma == 0) error->all(FLERR,"Illegal fix lb/fluid command: must set a value for Gamma before scaling it"); int itype = atoi(arg[iarg+1]); double scalefactor = atof(arg[iarg+2]); - if(itype <= 0 || itype > atom->ntypes || scalefactor < 0.0) + if (itype <= 0 || itype > atom->ntypes || scalefactor < 0.0) error->all(FLERR,"Illegal fix lb/fluid command: scaleGamma"); Gamma[itype] *= scalefactor; iarg += 3; } - else if(strcmp(arg[iarg],"dx")==0){ + else if (strcmp(arg[iarg],"dx")==0) { dx_lb = atof(arg[iarg+1]); iarg += 2; setdx = 0; } - else if(strcmp(arg[iarg],"dm")==0){ + else if (strcmp(arg[iarg],"dm")==0) { dm_lb = atof(arg[iarg+1]); iarg += 2; } - else if(strcmp(arg[iarg],"a0")==0){ + else if (strcmp(arg[iarg],"a0")==0) { a_0_real = atof(arg[iarg+1]); iarg += 2; seta0 = 0; } - else if(strcmp(arg[iarg],"noise")== 0){ + else if (strcmp(arg[iarg],"noise")== 0) { noisestress = 1; T = atof(arg[iarg+1]); seed = atoi(arg[iarg+2]); iarg += 3; } - else if(strcmp(arg[iarg],"calcforce")==0){ + else if (strcmp(arg[iarg],"calcforce")==0) { force_diagnostic = atoi(arg[iarg+1]); igroupforce=group->find(arg[iarg+2]); iarg += 3; } - else if(strcmp(arg[iarg],"trilinear")==0){ + else if (strcmp(arg[iarg],"trilinear")==0) { trilinear_stencil = 1; iarg += 1; } - else if(strcmp(arg[iarg],"read_restart")==0){ + else if (strcmp(arg[iarg],"read_restart")==0) { readrestart = 1; int nlength = strlen(arg[iarg+1]) + 16; char *filename = new char[nlength]; @@ -195,28 +195,28 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : delete [] filename; iarg += 2; } - else if(strcmp(arg[iarg],"write_restart")==0){ + else if (strcmp(arg[iarg],"write_restart")==0) { printrestart = atoi(arg[iarg+1]); iarg += 2; } - else if(strcmp(arg[iarg],"zwall_velocity")==0){ - if(domain->periodicity[2]!=0) error->all(FLERR,"fix lb/fluid error: setting \ + else if (strcmp(arg[iarg],"zwall_velocity")==0) { + if (domain->periodicity[2]!=0) error->all(FLERR,"fix lb/fluid error: setting \ a z wall velocity without implementing fixed BCs in z"); vwbt = atof(arg[iarg+1]); vwtp = atof(arg[iarg+2]); iarg += 3; } - else if(strcmp(arg[iarg],"bodyforce")==0){ + else if (strcmp(arg[iarg],"bodyforce")==0) { bodyforcex = atof(arg[iarg+1]); bodyforcey = atof(arg[iarg+2]); bodyforcez = atof(arg[iarg+3]); iarg += 4; } - else if(strcmp(arg[iarg],"printfluid")==0){ + else if (strcmp(arg[iarg],"printfluid")==0) { printfluid = atoi(arg[iarg+1]); iarg += 2; } - else if(strcmp(arg[iarg],"D3Q19")==0){ + else if (strcmp(arg[iarg],"D3Q19")==0) { numvel = 19; iarg += 1; } @@ -226,7 +226,7 @@ a z wall velocity without implementing fixed BCs in z"); //-------------------------------------------------------------------------- //Choose between D3Q15 and D3Q19 functions: //-------------------------------------------------------------------------- - if(numvel == 15){ + if (numvel == 15) { initializeLB = &FixLbFluid::initializeLB15; equilibriumdist = &FixLbFluid::equilibriumdist15; update_full = &FixLbFluid::update_full15; @@ -244,8 +244,8 @@ a z wall velocity without implementing fixed BCs in z"); grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - for(int i=0; inmax; i++) - for(int j=0; j<3; j++) + for (int i=0; inmax; i++) + for (int j=0; j<3; j++) hydroF[i][j] = 0.0; Ng_lb = nullptr; @@ -276,12 +276,12 @@ a z wall velocity without implementing fixed BCs in z"); // Set the lattice Boltzmann dx if it wasn't specified in the // input. //-------------------------------------------------------------------------- - if(setdx == 1){ + if (setdx == 1) { double dx_lb1 = sqrt(3.0*viscosity*dt_lb/densityinit_real); double mindomain = std::min(std::min(domain->xprd/comm->procgrid[0],domain->yprd/comm->procgrid[1]),domain->zprd/comm->procgrid[2]); dx_lb = mindomain/floor(mindomain/dx_lb1); - if(comm->me==0){ + if (comm->me==0) { char str[128]; sprintf(str,"Setting the lattice-Boltzmann dx to %10.6f",dx_lb); error->message(FLERR,str); @@ -291,21 +291,21 @@ a z wall velocity without implementing fixed BCs in z"); // If the area per node has not been set by the user, set to the // default value of dx_lb*dx_lb. //-------------------------------------------------------------------------- - if(setGamma == 0){ - if(setArea == 0){ - if(comm->me==0){ + if (setGamma == 0) { + if (setArea == 0) { + if (comm->me==0) { error->message(FLERR,"Assuming an area per node of dx*dx for all of the MD particles. This should only be used if these all correspond to point particles; otherwise, change using the setArea keyword"); } NodeArea = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; + for (int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; } - for(int i=0; i<=atom->ntypes; i++) - if(NodeArea[i] < 0.0) NodeArea[i] = dx_lb*dx_lb; + for (int i=0; i<=atom->ntypes; i++) + if (NodeArea[i] < 0.0) NodeArea[i] = dx_lb*dx_lb; } //-------------------------------------------------------------------------- // Set a0 if it wasn't specified in the input //-------------------------------------------------------------------------- - if(seta0 == 1) + if (seta0 == 1) a_0_real = 0.33333333*dx_lb*dx_lb/dt_lb/dt_lb; //-------------------------------------------------------------------------- @@ -319,8 +319,8 @@ a z wall velocity without implementing fixed BCs in z"); double aa; double eps=1.0e-8; aa = (domain->xprd/comm->procgrid[0])/dx_lb; - if(fabs(aa - floor(aa+0.5)) > eps){ - if(domain->boundary[0][0] != 0){ + if (fabs(aa - floor(aa+0.5)) > eps) { + if (domain->boundary[0][0] != 0) { error->all(FLERR,"the x-direction must be periodic"); } char errormessage[200]; @@ -328,8 +328,8 @@ a z wall velocity without implementing fixed BCs in z"); error->all(FLERR,errormessage); } aa = (domain->yprd/comm->procgrid[1])/dx_lb; - if(fabs(aa - floor(aa+0.5)) > eps){ - if(domain->boundary[1][0] != 0){ + if (fabs(aa - floor(aa+0.5)) > eps) { + if (domain->boundary[1][0] != 0) { error->all(FLERR,"the y-direction must be periodic"); } char errormessage[200]; @@ -337,8 +337,8 @@ a z wall velocity without implementing fixed BCs in z"); error->all(FLERR,errormessage); } aa = (domain->zprd/comm->procgrid[2])/dx_lb; - if(fabs(aa - floor(aa+0.5)) > eps){ - if(domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3){ + if (fabs(aa - floor(aa+0.5)) > eps) { + if (domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3) { error->all(FLERR,"the z-direction can not have shrink-wrap boundary conditions"); } char errormessage[200]; @@ -364,19 +364,19 @@ a z wall velocity without implementing fixed BCs in z"); // In order to calculate the fluid forces correctly, need to have atleast // 5 grid points in each direction per processor. //-------------------------------------------------------------------------- - if(subNbx<7 || subNby < 7 || subNbz<7) + if (subNbx<7 || subNby < 7 || subNbz<7) error->all(FLERR,"Need at least 5 grid points in each direction per processor"); // If there are walls in the z-direction add an extra grid point. - if(domain->periodicity[2]==0){ + if (domain->periodicity[2]==0) { Nbz += 1; - if(comm->myloc[2]==comm->procgrid[2]-1) + if (comm->myloc[2]==comm->procgrid[2]-1) subNbz += 1; } - if(comm->me==0){ + if (comm->me==0) { char str[128]; - if(setdx == 1){ + if (setdx == 1) { sprintf(str,"Using a lattice-Boltzmann grid of %i by %i by %i total grid points. To change, use the dx keyword",Nbx,Nby,Nbz); } else { sprintf(str,"Using a lattice-Boltzmann grid of %i by %i by %i total grid points.",Nbx,Nby,Nbz); @@ -471,7 +471,7 @@ a z wall velocity without implementing fixed BCs in z"); memory->create(mg_lb,numvel,numvel,"FixLbFluid:mg_lb"); memory->create(e,numvel,3,"FixLbFluid:e"); memory->create(feq,subNbx,subNby,subNbz,numvel,"FixLbFluid:feq"); - if(typeLB == 2){ + if (typeLB == 2) { memory->create(feqold,subNbx,subNby,subNbz,numvel,"FixLbFluid:feqold"); memory->create(feqn,subNbx,subNby,subNbz,numvel,"FixLbFluid:feqn"); memory->create(feqoldn,subNbx,subNby,subNbz,numvel,"FixLbFluid:feqoldn"); @@ -480,9 +480,9 @@ a z wall velocity without implementing fixed BCs in z"); memory->create(fnew,subNbx,subNby,subNbz,numvel,"FixLbFluid:fnew"); memory->create(density_lb,subNbx+3,subNby+3,subNbz+3,"FixLbFluid:density_lb"); memory->create(u_lb,subNbx+3,subNby+3,subNbz+3,3,"FixLbFluid:u_lb"); - if(printfluid > 0){ + if (printfluid > 0) { memory->create(buf,subNbx,subNby,subNbzmax,4,"FixLbFluid:buf"); - if(me==0) + if (me==0) memory->create(altogether,Nbx,Nby,Nbz,4,"FixLbFluid:altogether"); } memory->create(Ff,subNbx+3,subNby+3,subNbz+3,3,"FixLbFluid:Ff"); @@ -490,7 +490,7 @@ a z wall velocity without implementing fixed BCs in z"); memory->create(Fftempy,subNbx+3,5,subNbz+3,3,"FixLbFluid:Fftempy"); memory->create(Fftempz,subNbx+3,subNby+3,5,3,"FixLbFluid:Fftempz"); - if(noisestress==1){ + if (noisestress==1) { random = new RanMars(lmp,seed + comm->me); } @@ -518,7 +518,7 @@ FixLbFluid::~FixLbFluid() memory->destroy(mg_lb); memory->destroy(e); memory->destroy(feq); - if(typeLB == 2){ + if (typeLB == 2) { memory->destroy(feqold); memory->destroy(feqn); memory->destroy(feqoldn); @@ -527,8 +527,8 @@ FixLbFluid::~FixLbFluid() memory->destroy(fnew); memory->destroy(density_lb); memory->destroy(u_lb); - if(printfluid>0){ - if(me==0) + if (printfluid>0) { + if (me==0) memory->destroy(altogether); memory->destroy(buf); } @@ -537,11 +537,11 @@ FixLbFluid::~FixLbFluid() memory->destroy(Fftempy); memory->destroy(Fftempz); - if(noisestress==1){ + if (noisestress==1) { delete random; } - if(setGamma == 1){ + if (setGamma == 1) { delete [] Gamma; } else { delete [] NodeArea; @@ -583,7 +583,7 @@ void FixLbFluid::init(void) double dt_lb_now; dt_lb_now=nevery*(update->dt); - if(fabs(dt_lb_now - dt_lb) > 1.0e-12){ + if (fabs(dt_lb_now - dt_lb) > 1.0e-12) { error->warning(FLERR,"Timestep has changed between runs with the same lb/fluid. Unphysical results may occur"); } @@ -596,11 +596,11 @@ void FixLbFluid::init(void) Nby_now = (int)(domain->yprd/dx_lb + 0.5); Nbz_now = (int)(domain->zprd/dx_lb + 0.5); // If there are walls in the z-direction add an extra grid point. - if(domain->periodicity[2]==0){ + if (domain->periodicity[2]==0) { Nbz_now += 1; } - if(Nbx_now != Nbx || Nby_now != Nby || Nbz_now != Nbz){ + if (Nbx_now != Nbx || Nby_now != Nby || Nbz_now != Nbz) { error->all(FLERR,"the simulation domain can not change shape between runs with the same lb/fluid"); } @@ -610,13 +610,13 @@ void FixLbFluid::init(void) // shrink-wrap is not compatible in any dimension. // fixed only works in the z-direction. //-------------------------------------------------------------------------- - if(domain->boundary[0][0] != 0){ + if (domain->boundary[0][0] != 0) { error->all(FLERR,"the x-direction must be periodic"); } - if(domain->boundary[1][0] != 0){ + if (domain->boundary[1][0] != 0) { error->all(FLERR,"the y-direction must be periodic"); } - if(domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3){ + if (domain->boundary[2][0] == 2 || domain->boundary[2][0] == 3) { error->all(FLERR,"the z-direction can not have shrink-wrap boundary conditions"); } @@ -624,33 +624,33 @@ void FixLbFluid::init(void) // Check if the lb/viscous fix is also called: //-------------------------------------------------------------------------- groupbit_viscouslb = groupbit_pc = groupbit_rigid_pc_sphere = 0; - for (i = 0; i < modify->nfix; i++){ - if (strcmp(modify->fix[i]->style,"lb/viscous") == 0){ + for (i = 0; i < modify->nfix; i++) { + if (strcmp(modify->fix[i]->style,"lb/viscous") == 0) { fixviscouslb = 1; groupbit_viscouslb = group->bitmask[modify->fix[i]->igroup]; } - if(strcmp(modify->fix[i]->style,"lb/pc")==0){ + if (strcmp(modify->fix[i]->style,"lb/pc")==0) { groupbit_pc = group->bitmask[modify->fix[i]->igroup]; } - if(strcmp(modify->fix[i]->style,"lb/rigid/pc/sphere")==0){ + if (strcmp(modify->fix[i]->style,"lb/rigid/pc/sphere")==0) { groupbit_rigid_pc_sphere = group->bitmask[modify->fix[i]->igroup]; } } // Warn if the fluid force is not applied to any of the particles. - if(!(groupbit_viscouslb || groupbit_pc || groupbit_rigid_pc_sphere) && comm->me==0){ + if (!(groupbit_viscouslb || groupbit_pc || groupbit_rigid_pc_sphere) && comm->me==0) { error->message(FLERR,"Not adding the fluid force to any of the MD particles. To add this force use one of the lb/viscous, lb/pc, or lb/rigid/pc/sphere fixes"); } // If fix lb/viscous is called for a particular atom, make sure // lb/pc or lb/rigid/pc/sphere are not: - if(fixviscouslb == 1){ + if (fixviscouslb == 1) { int *mask = atom->mask; int nlocal = atom->nlocal; - for(j=0; jone(FLERR,"should not use the lb/viscous command when integrating with the lb/pc fix"); - if((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_rigid_pc_sphere)) + if ((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_rigid_pc_sphere)) error->one(FLERR,"should not use the lb/viscous command when integrating with the lb/rigid/pc/sphere fix"); } } @@ -662,7 +662,7 @@ void FixLbFluid::setup(int /*vflag*/) //-------------------------------------------------------------------------- // Need to calculate the force on the fluid for a restart run. //-------------------------------------------------------------------------- - if(step > 0) + if (step > 0) calc_fluidforce(); } @@ -673,14 +673,14 @@ void FixLbFluid::initial_integrate(int /*vflag*/) //-------------------------------------------------------------------------- static int printheader = 1; - if(printheader == 1){ - if(force_diagnostic > 0 && me == 0){ + if (printheader == 1) { + if (force_diagnostic > 0 && me == 0) { printf("-------------------------------------------------------------------------------\n"); printf(" F_x F_y F_z T_x T_y T_z\n"); printf("-------------------------------------------------------------------------------\n"); } - if(printfluid > 0 && me == 0){ + if (printfluid > 0 && me == 0) { printf("---------------------------------------------------------------------\n"); printf(" density u_x u_y u_z \n"); printf("---------------------------------------------------------------------\n"); @@ -710,7 +710,7 @@ void FixLbFluid::initial_integrate(int /*vflag*/) // Store the equilibrium distribution function, it is needed in // the next time step by the update routine. //-------------------------------------------------------------------------- - if(typeLB == 2){ + if (typeLB == 2) { std::swap(feqold,feq); std::swap(feqoldn,feqn); } @@ -718,23 +718,23 @@ void FixLbFluid::initial_integrate(int /*vflag*/) //-------------------------------------------------------------------------- // Perform diagnostics, and print output for the graphics program //-------------------------------------------------------------------------- - if(printfluid > 0 && update->ntimestep > 0 && (update->ntimestep % printfluid == 0)) + if (printfluid > 0 && update->ntimestep > 0 && (update->ntimestep % printfluid == 0)) streamout(); } void FixLbFluid::post_force(int /*vflag*/) { - if(fixviscouslb==1) + if (fixviscouslb==1) calc_fluidforce(); } void FixLbFluid::end_of_step() { - if(fixviscouslb==0) + if (fixviscouslb==0) calc_fluidforce(); - if(printrestart>0){ - if((update->ntimestep)%printrestart == 0){ + if (printrestart>0) { + if ((update->ntimestep)%printrestart == 0) { write_restartfile(); } } @@ -807,8 +807,8 @@ void FixLbFluid::calc_fluidforce(void) forceloc[0] = forceloc[1] = forceloc[2] = 0.0; torqueloc[0] = torqueloc[1] = torqueloc[2] = 0.0; - for(i=0; inmax; i++) - for(j=0; j<3; j++) + for (i=0; inmax; i++) + for (j=0; j<3; j++) hydroF[i][j] = 0.0; @@ -821,16 +821,16 @@ void FixLbFluid::calc_fluidforce(void) int *type = atom->type; double sum[4],xcm[4]; - if(force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ + if (force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)) { //Calculate the center of mass of the particle group //(needed to calculate the torque). sum[0] = sum[1] = sum[2] = sum[3] = 0.0; - for(i=0; ibitmask[igroupforce]){ + for (i=0; ibitmask[igroupforce]) { domain->unmap(x[i],image[i],unwrap); - if(rmass) massone = rmass[i]; + if (rmass) massone = rmass[i]; else massone = mass[type[i]]; sum[0] += unwrap[0]*massone; @@ -848,16 +848,16 @@ void FixLbFluid::calc_fluidforce(void) //-------------------------------------------------------------------------- //Calculate the contribution to the force on the fluid. //-------------------------------------------------------------------------- - for(i=0; i 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ - if(mask[i] & group->bitmask[igroupforce]){ + if (force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)) { + if (mask[i] & group->bitmask[igroupforce]) { domain->unmap(x[i],image[i],unwrap); dx = unwrap[0] - xcm[0]; @@ -879,7 +879,7 @@ void FixLbFluid::calc_fluidforce(void) //Communicate the force contributions which lie outside the local processor //sub domain. //-------------------------------------------------------------------------- - for(i=0; i<10; i++) + for (i=0; i<10; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&Ff[0][0][0][0],1,passxu,comm->procneigh[0][0],10,world,&requests[0]); MPI_Isend(&Ff[subNbx+2][0][0][0],1,passxu,comm->procneigh[0][0],20,world,&requests[1]); @@ -893,9 +893,9 @@ void FixLbFluid::calc_fluidforce(void) MPI_Irecv(&Fftempx[4][0][0][0],1,passxtemp,comm->procneigh[0][0],50,world,&requests[9]); MPI_Waitall(10,requests,MPI_STATUS_IGNORE); - for(j=0; jprocneigh[1][0],10,world,&requests[0]); MPI_Isend(&Ff[0][subNby+2][0][0],1,passyu,comm->procneigh[1][0],20,world,&requests[1]); @@ -919,9 +919,9 @@ void FixLbFluid::calc_fluidforce(void) MPI_Irecv(&Fftempy[0][4][0][0],1,passytemp,comm->procneigh[1][0],50,world,&requests[9]); MPI_Waitall(10,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],10,world,&requests[0]); MPI_Isend(&Ff[0][0][subNbz+2][0],1,passzu,comm->procneigh[2][0],20,world,&requests[1]); @@ -945,9 +945,9 @@ void FixLbFluid::calc_fluidforce(void) MPI_Irecv(&Fftempz[0][0][4][0],1,passztemp,comm->procneigh[2][0],50,world,&requests[9]); MPI_Waitall(10,requests,MPI_STATUS_IGNORE); - for(i=0; i 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ + if (force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)) { force[0] = force[1] = force[2] = 0.0; torque[0] = torque[1] = torque[2] =0.0; MPI_Allreduce(&forceloc[0],&force[0],3,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&torqueloc[0],&torque[0],3,MPI_DOUBLE,MPI_SUM,world); - if(me==0){ + if (me==0) { printf("%E %E %E %E %E %E\n",force[0],force[1],force[2], torque[0],torque[1],torque[2]); @@ -1025,38 +1025,38 @@ void FixLbFluid::peskin_interpolation(int i) // Calculate the interpolation weights, and interpolated values of // the fluid velocity, and density. //-------------------------------------------------------------------------- - for(ii=-1; ii<3; ii++){ + for (ii=-1; ii<3; ii++) { rsq=(-dx1+ii)*(-dx1+ii); - if(rsq>=4) { + if (rsq>=4) { weightx=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(jj=-1; jj<3; jj++){ + for (jj=-1; jj<3; jj++) { rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) { + if (rsq>=4) { weighty=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(kk=-1; kk<3; kk++){ + for (kk=-1; kk<3; kk++) { rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) { + if (rsq>=4) { weightz=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; @@ -1068,35 +1068,35 @@ void FixLbFluid::peskin_interpolation(int i) //The atom is allowed to be within one lattice grid point outside the //local processor sub-domain. - if(ixp < -1 || ixp > (subNbx+1) || iyp < -1 || iyp > (subNby+1) || izp < -1 || izp > (subNbz+1)) + if (ixp < -1 || ixp > (subNbx+1) || iyp < -1 || iyp > (subNby+1) || izp < -1 || izp > (subNbz+1)) error->one(FLERR,"Atom outside local processor simulation domain. Either unstable fluid pararmeters, or \ require more frequent neighborlist rebuilds"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == 0 && izp < 1) + if (domain->periodicity[2] == 0 && comm->myloc[2] == 0 && izp < 1) error->warning(FLERR,"Atom too close to lower z wall. Unphysical results may occur"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) )) + if (domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) )) error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; FfP[isten] = weightx*weighty*weightz; // interpolated velocity based on delta function. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { unode[k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; } - if(setGamma==0) + if (setGamma==0) mnode += density_lb[ixp][iyp][izp]*FfP[isten]; isten++; } } } - if(setGamma==0){ + if (setGamma==0) { mnode *= NodeArea[type[i]]; - if(rmass) massone = rmass[i]; + if (rmass) massone = rmass[i]; else massone = mass[type[i]]; massone = massone/dm_lb; @@ -1106,25 +1106,25 @@ require more frequent neighborlist rebuilds"); } isten=0; - for(ii=-1; ii<3; ii++) - for(jj=-1; jj<3; jj++) - for(kk=-1; kk<3; kk++){ + for (ii=-1; ii<3; ii++) + for (jj=-1; jj<3; jj++) + for (kk=-1; kk<3; kk++) { ixp = ix+ii; iyp = iy+jj; izp = iz+kk; - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; // Compute the force on the fluid. Need to convert the velocity from // LAMMPS units to LB units. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { Ff[ixp][iyp][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[isten]; } isten++; } - for(k=0; k<3; k++) + for (k=0; k<3; k++) hydroF[i][k] = -1.0*gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*dm_lb*dx_lb/dt_lb/dt_lb; } @@ -1191,13 +1191,13 @@ void FixLbFluid::trilinear_interpolation(int i) //The atom is allowed to be within one lattice grid point outside the //local processor sub-domain. - if(ix < 0 || ixp > (subNbx+1) || iy < 0 || iyp > (subNby+1) || iz < 0 || izp > (subNbz+1)) + if (ix < 0 || ixp > (subNbx+1) || iy < 0 || iyp > (subNby+1) || iz < 0 || izp > (subNbz+1)) error->one(FLERR,"Atom outside local processor simulation domain. Either unstable fluid pararmeters, or \ require more frequent neighborlist rebuilds"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == 0 && (iz < 1 || izp < 1)) + if (domain->periodicity[2] == 0 && comm->myloc[2] == 0 && (iz < 1 || izp < 1)) error->warning(FLERR,"Atom too close to lower z wall. Unphysical results may occur"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) || iz > (subNbz-2))) + if (domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) || iz > (subNbz-2))) error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); @@ -1212,7 +1212,7 @@ require more frequent neighborlist rebuilds"); + u_lb[ixp][iyp][izp][k]*FfP[7]; } - if(setGamma==0){ + if (setGamma==0) { mnode = density_lb[ix][iy][iz]*FfP[0] + density_lb[ix][iy][izp]*FfP[1] + density_lb[ix][iyp][iz]*FfP[2] @@ -1224,7 +1224,7 @@ require more frequent neighborlist rebuilds"); mnode *= NodeArea[type[i]]; - if(rmass) massone = rmass[i]; + if (rmass) massone = rmass[i]; else massone = mass[type[i]]; massone = massone/dm_lb; @@ -1234,7 +1234,7 @@ require more frequent neighborlist rebuilds"); } - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { Ff[ix][iy][iz][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[0]; Ff[ix][iy][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[1]; Ff[ix][iyp][iz][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[2]; @@ -1245,7 +1245,7 @@ require more frequent neighborlist rebuilds"); Ff[ixp][iyp][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[7]; } - for(k=0; k<3; k++) + for (k=0; k<3; k++) hydroF[i][k] = -1.0*gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*dm_lb*dx_lb/dt_lb/dt_lb; } @@ -1266,7 +1266,7 @@ void FixLbFluid::read_restartfile(void) int gsizes[4] = {Nbx,Nby,Nbz,numvel}; int lsizes[4] = {subNbx-2,subNby-2,subNbz-2,numvel}; int starts[4] = {comm->myloc[0]*(subNbx-2),comm->myloc[1]*(subNby-2),comm->myloc[2]*(subNbz-2),0}; - if(domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1){ + if (domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1) { starts[2] = comm->myloc[2]*(subNbz-3); } @@ -1280,7 +1280,7 @@ void FixLbFluid::read_restartfile(void) MPI_INFO_NULL); MPI_File_seek(pFileRead,0,MPI_SEEK_SET); MPI_File_read_all(pFileRead,&f_lb[0][0][0][0],1,realtype,&status); - if(typeLB == 2){ + if (typeLB == 2) { MPI_File_read_all(pFileRead,&feqold[0][0][0][0],1,realtype,&status); MPI_File_read_all(pFileRead,&feqoldn[0][0][0][0],1,realtype,&status); } @@ -1313,7 +1313,7 @@ void FixLbFluid::write_restartfile(void) int gsizes[4] = {Nbx,Nby,Nbz,numvel}; int lsizes[4] = {subNbx-2,subNby-2,subNbz-2,numvel}; int starts[4] = {comm->myloc[0]*(subNbx-2),comm->myloc[1]*(subNby-2),comm->myloc[2]*(subNbz-2),0}; - if(domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1){ + if (domain->periodicity[2]==0 && comm->myloc[2]==comm->procgrid[2]-1) { starts[2] = comm->myloc[2]*(subNbz-3); } @@ -1325,7 +1325,7 @@ void FixLbFluid::write_restartfile(void) MPI_File_set_view(fh,0,MPI_DOUBLE,filetype,(char *) "native",MPI_INFO_NULL); MPI_File_write_all(fh,&f_lb[0][0][0][0],1,realtype,&status); - if(typeLB == 2){ + if (typeLB == 2) { MPI_File_write_all(fh,&feqold[0][0][0][0],1,realtype,&status); MPI_File_write_all(fh,&feqoldn[0][0][0][0],1,realtype,&status); } @@ -1353,15 +1353,15 @@ void FixLbFluid::rescale(void) tau=(3.0*viscosity/densityinit_real)*dt_lb*dt_lb/dx_lb/dx_lb; tau /= dt_lb; - if(typeLB==1) + if (typeLB==1) tau = tau + 0.5; - if(setGamma == 0){ - for(int i=0; i<= atom->ntypes; i++){ + if (setGamma == 0) { + for (int i=0; i<= atom->ntypes; i++) { NodeArea[i] = NodeArea[i]/dx_lb/dx_lb; } } else { - for(int i=0; i<= atom->ntypes; i++){ + for (int i=0; i<= atom->ntypes; i++) { Gamma[i] = Gamma[i]*dt_lb/dm_lb; } } @@ -1371,38 +1371,38 @@ void FixLbFluid::rescale(void) a_0 = a_0_real*dt_lb*dt_lb/(dx_lb*dx_lb); // Warn if using the D3Q19 model with noise, and a0 is too small. - if(numvel==19 && noisestress==1 && a_0 < 0.2){ + if (numvel==19 && noisestress==1 && a_0 < 0.2) { error->warning(FLERR,"Fix lb/fluid WARNING: Chosen value for a0 may be too small. \ Check temperature reproduction.\n"); } - if(noisestress==1){ - if(a_0>0.5555555){ + if (noisestress==1) { + if (a_0>0.5555555) { error->all(FLERR,"Fix lb/fluid ERROR: the Lattice Boltzmann dx and dt need \ to be chosen such that the scaled a_0 < 5/9\n"); } } // Courant Condition: - if(a_0 >= 1.0){ + if (a_0 >= 1.0) { error->all(FLERR,"Fix lb/fluid ERROR: the lattice Boltzmann dx and dt do not \ satisfy the Courant condition.\n"); } kB = (force->boltz/force->mvv2e)*dt_lb*dt_lb/dx_lb/dx_lb/dm_lb; - if(typeLB==1){ + if (typeLB==1) { expminusdtovertau = 0.0; Dcoeff = 0.0; namp = 2.0*kB*T*(tau-0.5)/3.0; noisefactor = 1.0; - if(a_0 <= 0.333333333333333){ + if (a_0 <= 0.333333333333333) { K_0 = 5.17*(0.333333333333333 - a_0); } else { K_0 = 2.57*(a_0 - 0.333333333333333); } dtoverdtcollision = dt_lb*6.0*viscosity/densityinit_real/dx_lb/dx_lb; - } else if(typeLB==2){ + } else if (typeLB==2) { expminusdtovertau=exp(-1.0/tau); Dcoeff=(1.0-(1.0-expminusdtovertau)*tau); namp = 2.0*kB*T/3.; @@ -1565,18 +1565,18 @@ void FixLbFluid::initializeLB15(void) mg_lb[14][10]=sqrt(2.);mg_lb[14][11]=sqrt(2.);mg_lb[14][12]=sqrt(2.); mg_lb[14][13]=sqrt(2.);mg_lb[14][14]=sqrt(2.); - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -1860,13 +1860,13 @@ void FixLbFluid::initialize_feq(void) } MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -1874,13 +1874,13 @@ void FixLbFluid::initialize_feq(void) } MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -1889,11 +1889,11 @@ void FixLbFluid::initialize_feq(void) MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); //Save feqold. - if(typeLB == 2){ - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); @@ -1916,7 +1916,7 @@ void FixLbFluid::initialize_feq(void) MPI_Irecv(&feqoldn[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],10,world,&requests[7]); MPI_Waitall(8,requests,MPI_STATUS_IGNORE); - for(i=0; i<8; i++) + for (i=0; i<8; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[0][1][1][0],1,passyf,comm->procneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); @@ -1928,7 +1928,7 @@ void FixLbFluid::initialize_feq(void) MPI_Irecv(&feqoldn[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],10,world,&requests[7]); MPI_Waitall(8,requests,MPI_STATUS_IGNORE); - for(i=0; i<8; i++) + for (i=0; i<8; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); @@ -1994,14 +1994,14 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i // Need one-sided derivatives for the boundary of the domain, if fixed boundary // conditions are used. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0 && k==1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==0 && k==1) { drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - density_lb[i][j][k+2])/2.0; drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - 5.0*density_lb[i][j][k+1] + 2.0*rho); } - if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ + if (comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2) { drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - density_lb[i][j][k-2])/2.0; drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - @@ -2017,7 +2017,7 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i dPdrho = a_0; //assuming here that kappa_lb = 0. - if(typeLB==1){ + if (typeLB==1) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* @@ -2030,7 +2030,7 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - } else if(typeLB==2){ + } else if (typeLB==2) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* @@ -2079,17 +2079,17 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i for (int ii=0; ii<15; ii++) feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - if(typeLB == 2){ + if (typeLB == 2) { feqn[i][j][k][l] = feq[i][j][k][l]; } } - if(noisestress==1){ + if (noisestress==1) { std = sqrt(namp*rho); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[0][jj] = std*random->gaussian(); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[1][jj] = std*random->gaussian(); etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); @@ -2172,14 +2172,14 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i // Need one-sided derivatives for the boundary of the domain, if fixed boundary // conditions are used. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0 && k==1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==0 && k==1) { drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - density_lb[i][j][k+2])/2.0; drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - 5.0*density_lb[i][j][k+1] + 2.0*rho); } - if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ + if (comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2) { drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - density_lb[i][j][k-2])/2.0; drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - @@ -2195,7 +2195,7 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i dPdrho = a_0; //assuming here that kappa_lb = 0. - if(typeLB==1){ + if (typeLB==1) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* @@ -2208,7 +2208,7 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - } else if(typeLB==2){ + } else if (typeLB==2) { Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* @@ -2260,17 +2260,17 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i for (int ii=0; ii<19; ii++) feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - if(typeLB == 2){ + if (typeLB == 2) { feqn[i][j][k][l] = feq[i][j][k][l]; } } - if(noisestress==1){ + if (noisestress==1) { std = sqrt(namp*rho); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[0][jj] = std*random->gaussian(); - for(jj=0; jj<3; jj++) + for (jj=0; jj<3; jj++) S[1][jj] = std*random->gaussian(); etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); @@ -2322,7 +2322,7 @@ void FixLbFluid::parametercalc_full(void) // routine, and use these to calculate the density and velocity on the // boundary. //-------------------------------------------------------------------------- - for(i=0; i<4; i++) + for (i=0; i<4; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&f_lb[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[0]); MPI_Irecv(&f_lb[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[1]); @@ -2331,7 +2331,7 @@ void FixLbFluid::parametercalc_full(void) parametercalc_part(1,subNbx-1,1,subNby-1,1,subNbz-1); MPI_Waitall(4,requests,MPI_STATUS_IGNORE); - for(i=0; i<4; i++) + for (i=0; i<4; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&f_lb[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[0]); MPI_Irecv(&f_lb[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[1]); @@ -2341,7 +2341,7 @@ void FixLbFluid::parametercalc_full(void) parametercalc_part(subNbx-1,subNbx,1,subNby-1,1,subNbz-1); MPI_Waitall(4,requests,MPI_STATUS_IGNORE); - for(i=0; i<4; i++) + for (i=0; i<4; i++) requests[i]=MPI_REQUEST_NULL; MPI_Isend(&f_lb[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[0]); MPI_Irecv(&f_lb[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[1]); @@ -2358,10 +2358,10 @@ void FixLbFluid::parametercalc_full(void) // Send the remaining portions of the u array (and density array if Gamma // is set the default way). //-------------------------------------------------------------------------- - if(setGamma == 0) numrequests = 12; + if (setGamma == 0) numrequests = 12; else numrequests = 6; - for(i=0; iprocneigh[0][0],10,world,&requests2[0]); MPI_Isend(&u_lb[3][0][0][0],1,passxu,comm->procneigh[0][0],20,world,&requests2[1]); @@ -2369,7 +2369,7 @@ void FixLbFluid::parametercalc_full(void) MPI_Irecv(&u_lb[subNbx][0][0][0],1,passxu,comm->procneigh[0][1],10,world,&requests2[3]); MPI_Irecv(&u_lb[subNbx+1][0][0][0],1,passxu,comm->procneigh[0][1],20,world,&requests2[4]); MPI_Irecv(&u_lb[subNbx+2][0][0][0],1,passxu,comm->procneigh[0][0],30,world,&requests2[5]); - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[2][0][0],1,passxrho,comm->procneigh[0][0],40,world,&requests2[6]); MPI_Isend(&density_lb[3][0][0],1,passxrho,comm->procneigh[0][0],50,world,&requests2[7]); MPI_Isend(&density_lb[subNbx-3][0][0],1,passxrho,comm->procneigh[0][1],60,world,&requests2[8]); @@ -2379,7 +2379,7 @@ void FixLbFluid::parametercalc_full(void) } MPI_Waitall(numrequests,requests2,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],10,world,&requests2[0]); MPI_Isend(&u_lb[0][3][0][0],1,passyu,comm->procneigh[1][0],20,world,&requests2[1]); @@ -2387,7 +2387,7 @@ void FixLbFluid::parametercalc_full(void) MPI_Irecv(&u_lb[0][subNby][0][0],1,passyu,comm->procneigh[1][1],10,world,&requests2[3]); MPI_Irecv(&u_lb[0][subNby+1][0][0],1,passyu,comm->procneigh[1][1],20,world,&requests2[4]); MPI_Irecv(&u_lb[0][subNby+2][0][0],1,passyu,comm->procneigh[1][0],30,world,&requests2[5]); - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[0][2][0],1,passyrho,comm->procneigh[1][0],40,world,&requests2[6]); MPI_Isend(&density_lb[0][3][0],1,passyrho,comm->procneigh[1][0],50,world,&requests2[7]); MPI_Isend(&density_lb[0][subNby-3][0],1,passyrho,comm->procneigh[1][1],60,world,&requests2[8]); @@ -2397,27 +2397,27 @@ void FixLbFluid::parametercalc_full(void) } MPI_Waitall(numrequests,requests2,MPI_STATUS_IGNORE); - for(i=0; i<12; i++) + for (i=0; i<12; i++) requests2[i]=MPI_REQUEST_NULL; int requestcount=0; - if(domain->periodicity[2]!=0 || comm->myloc[2] != 0){ + if (domain->periodicity[2]!=0 || comm->myloc[2] != 0) { MPI_Isend(&u_lb[0][0][2][0],1,passzu,comm->procneigh[2][0],10,world,&requests2[requestcount]); MPI_Isend(&u_lb[0][0][3][0],1,passzu,comm->procneigh[2][0],20,world,&requests2[requestcount+1]); MPI_Irecv(&u_lb[0][0][subNbz+2][0],1,passzu,comm->procneigh[2][0],30,world,&requests2[requestcount+2]); requestcount=requestcount+3; - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[0][0][2],1,passzrho,comm->procneigh[2][0],40,world,&requests2[requestcount]); MPI_Isend(&density_lb[0][0][3],1,passzrho,comm->procneigh[2][0],50,world,&requests2[requestcount+1]); MPI_Irecv(&density_lb[0][0][subNbz+2],1,passzrho,comm->procneigh[2][0],60,world,&requests2[requestcount+2]); requestcount=requestcount+3; } } - if(domain->periodicity[2]!=0 || comm->myloc[2] != (comm->procgrid[2]-1)){ + if (domain->periodicity[2]!=0 || comm->myloc[2] != (comm->procgrid[2]-1)) { MPI_Isend(&u_lb[0][0][subNbz-3][0],1,passzu,comm->procneigh[2][1],30,world,&requests2[requestcount]); MPI_Irecv(&u_lb[0][0][subNbz][0],1,passzu,comm->procneigh[2][1],10,world,&requests2[requestcount+1]); MPI_Irecv(&u_lb[0][0][subNbz+1][0],1,passzu,comm->procneigh[2][1],20,world,&requests2[requestcount+2]); requestcount=requestcount+3; - if(setGamma==0){ + if (setGamma==0) { MPI_Isend(&density_lb[0][0][subNbz-3],1,passzrho,comm->procneigh[2][1],60,world,&requests2[requestcount]); MPI_Irecv(&density_lb[0][0][subNbz],1,passzrho,comm->procneigh[2][1],40,world,&requests2[requestcount+1]); MPI_Irecv(&density_lb[0][0][subNbz+1],1,passzrho,comm->procneigh[2][1],50,world,&requests2[requestcount+2]); @@ -2436,9 +2436,9 @@ void FixLbFluid::parametercalc_part(int xstart, int xend, int ystart, int yend, { int i,j,k,m; - for(i=xstart; iperiodicity[2]==0){ - if(comm->myloc[2]==0){ - if(k==1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==0) { + if (k==1) { u_lb[i][j][k][2]=0.0; } } - if(comm->myloc[2]==comm->procgrid[2]-1){ - if(k==subNbz-2){ + if (comm->myloc[2]==comm->procgrid[2]-1) { + if (k==subNbz-2) { u_lb[i][j][k][2]=0.0; } } @@ -2487,20 +2487,20 @@ void FixLbFluid::update_periodic(int xstart, int xend, int ystart, int yend, int int i,j,k,m; int imod,jmod,kmod,imodm,jmodm,kmodm; - for(i=xstart; ime==0){ + // if (comm->me==0) { // printf("%16.12f %16.12f %16.12f %16.12f\n",mass*dm_lb,momentum[0]*dm_lb*dx_lb/dt_lb,momentum[1]*dm_lb*dx_lb/dt_lb,momentum[2]*dm_lb*dx_lb/dt_lb); // } sizeloc=(subNbx*subNby*subNbz*4); MPI_Allreduce(&sizeloc,&size,1,MPI_INT,MPI_MAX,world); - if(me==0){ - for(iproc=0; iproc < comm->nprocs; iproc++){ - if(iproc){ + if (me==0) { + for (iproc=0; iproc < comm->nprocs; iproc++) { + if (iproc) { MPI_Irecv(&buf[0][0][0][0],size,MPI_DOUBLE,iproc,0,world,&request_recv); MPI_Wait(&request_recv,&status); @@ -2577,19 +2577,19 @@ void FixLbFluid::streamout(void) jend=static_cast (buf[0][0][1][1]); kend=static_cast (buf[0][0][1][2]); - for(i=istart; imyloc[0]*(subNbx-2); jstart=comm->myloc[1]*(subNby-2); - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==comm->procgrid[2]-1){ + if (domain->periodicity[2]==0) { + if (comm->myloc[2]==comm->procgrid[2]-1) { kstart=comm->myloc[2]*(subNbz-3); } else { kstart=comm->myloc[2]*(subNbz-2); @@ -2623,9 +2623,9 @@ void FixLbFluid::streamout(void) iend=istart+subNbx-2; jend=jstart+subNby-2; kend=kstart+subNbz-2; - for(i=0; iperiodicity[2]==0){ + if (domain->periodicity[2]==0) { - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -2694,13 +2694,13 @@ void FixLbFluid::update_full15(void) MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -2710,13 +2710,13 @@ void FixLbFluid::update_full15(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -2726,15 +2726,15 @@ void FixLbFluid::update_full15(void) update_periodic(1,subNbx-1,subNby-2,subNby-1,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - if(typeLB==1){ + if (typeLB==1) { update_periodic(1,subNbx-1,1,subNby-1,1,2); update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); - } else if(typeLB==2){ - if(comm->myloc[2]==0){ - for(i=1; imyloc[2]==0) { + for (i=1; imyloc[2]==comm->procgrid[2]-1){ - for(i=1;imyloc[2]==comm->procgrid[2]-1) { + for (i=1;imyloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Isend(&fnew[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&req_send15); MPI_Irecv(&fnew[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&req_recv25); } - if(comm->myloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Isend(&fnew[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&req_send25); MPI_Irecv(&fnew[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&req_recv15); } - if(comm->myloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Wait(&req_send15,&status); MPI_Wait(&req_recv25,&status); - for(i=1;imyloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Wait(&req_send25,&status); MPI_Wait(&req_recv15,&status); - for(i=1;iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -2965,13 +2965,13 @@ void FixLbFluid::update_full15(void) update_periodic(2,subNbx-2,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -2981,13 +2981,13 @@ void FixLbFluid::update_full15(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -3024,7 +3024,7 @@ void FixLbFluid::update_full19(void) //-------------------------------------------------------------------------- // If using the standard LB integrator, do not need to send info about feqn. //-------------------------------------------------------------------------- - if(typeLB == 1){ + if (typeLB == 1) { numrequests = 4; } else { numrequests = 8; @@ -3033,15 +3033,15 @@ void FixLbFluid::update_full19(void) //-------------------------------------------------------------------------- // Fixed z boundary conditions. //-------------------------------------------------------------------------- - if(domain->periodicity[2]==0){ + if (domain->periodicity[2]==0) { - for(i=0; iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -3050,13 +3050,13 @@ void FixLbFluid::update_full19(void) update_periodic(2,subNbx-2,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -3066,13 +3066,13 @@ void FixLbFluid::update_full19(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); @@ -3082,15 +3082,15 @@ void FixLbFluid::update_full19(void) update_periodic(1,subNbx-1,subNby-2,subNby-1,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - if(typeLB==1){ + if (typeLB==1) { update_periodic(1,subNbx-1,1,subNby-1,1,2); update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); - } else if(typeLB==2){ - if(comm->myloc[2]==0){ - for(i=1; imyloc[2]==0) { + for (i=1; imyloc[2]==comm->procgrid[2]-1){ - for(i=1;imyloc[2]==comm->procgrid[2]-1) { + for (i=1;imyloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Isend(&fnew[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&req_send15); MPI_Irecv(&fnew[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&req_recv25); } - if(comm->myloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Isend(&fnew[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&req_send25); MPI_Irecv(&fnew[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&req_recv15); } - if(comm->myloc[2]==0){ + if (comm->myloc[2]==0) { MPI_Wait(&req_send15,&status); MPI_Wait(&req_recv25,&status); - for(i=1;imyloc[2]==comm->procgrid[2]-1){ + if (comm->myloc[2]==comm->procgrid[2]-1) { MPI_Wait(&req_send25,&status); MPI_Wait(&req_recv15,&status); - for(i=1;iprocneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feq[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feq[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); MPI_Irecv(&feq[subNbx-1][1][1][0],1,passxf,comm->procneigh[0][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[1][1][1][0],1,passxf,comm->procneigh[0][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][1][1][0],1,passxf,comm->procneigh[0][0],20,world,&requests[5]); MPI_Isend(&feqn[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],20,world,&requests[6]); @@ -3311,13 +3311,13 @@ void FixLbFluid::update_full19(void) update_periodic(2,subNbx-2,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feq[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); MPI_Irecv(&feq[0][subNby-1][1][0],1,passyf,comm->procneigh[1][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][1][1][0],1,passyf,comm->procneigh[1][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][1][0],1,passyf,comm->procneigh[1][0],20,world,&requests[5]); MPI_Isend(&feqn[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],20,world,&requests[6]); @@ -3327,13 +3327,13 @@ void FixLbFluid::update_full19(void) update_periodic(subNbx-2,subNbx-1,2,subNby-2,2,subNbz-2); MPI_Waitall(numrequests,requests,MPI_STATUS_IGNORE); - for(i=0; iprocneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feq[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feq[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); MPI_Irecv(&feq[0][0][subNbz-1][0],1,passzf,comm->procneigh[2][1],15,world,&requests[3]); - if(typeLB == 2){ + if (typeLB == 2) { MPI_Isend(&feqn[0][0][1][0],1,passzf,comm->procneigh[2][0],10,world,&requests[4]); MPI_Irecv(&feqn[0][0][0][0],1,passzf,comm->procneigh[2][0],20,world,&requests[5]); MPI_Isend(&feqn[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],20,world,&requests[6]); diff --git a/src/USER-LB/fix_lb_momentum.cpp b/src/USER-LB/fix_lb_momentum.cpp index 81acdbef45..9a305f6fe1 100644 --- a/src/USER-LB/fix_lb_momentum.cpp +++ b/src/USER-LB/fix_lb_momentum.cpp @@ -70,8 +70,8 @@ FixLbMomentum::FixLbMomentum(LAMMPS *lmp, int narg, char **arg) : if (group->count(igroup) == 0.0) error->all(FLERR,"Fix lb/momentum group has no atoms"); - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0) + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; @@ -135,9 +135,9 @@ void FixLbMomentum::end_of_step() masslbloc = 0.0; momentumlbloc[0] = momentumlbloc[1] = momentumlbloc[2] = 0.0; - for(int i = 1; ie; //Subtract vcm from the fluid. - for(int i=0; ifeqold; double ****feqoldn = fix_lb_fluid->feqoldn; density_old = 0.0; u_old[0] = u_old[1] = u_old[2] = 0.0; - for(int l=0; lntypes+1]; int groupbit_lb_fluid = 0; - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0){ + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) { fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup]; } - if(groupbit_lb_fluid == 0) + if (groupbit_lb_fluid == 0) error->all(FLERR,"the lb/fluid fix must also be used if using the lb/pc fix"); int *mask = atom->mask; int nlocal = atom->nlocal; - for(int j=0; jone(FLERR,"can only use the lb/pc fix for an atom if also using the lb/fluid fix for that atom"); } @@ -109,7 +109,7 @@ void FixLbPC::init() dtv = update->dt; dtf = update->dt * force->ftm2v; - for(int i=0; i<=atom->ntypes; i++) + for (int i=0; i<=atom->ntypes; i++) Gamma_MD[i] = Gamma[i]*dm_lb/dt_lb; } @@ -132,7 +132,7 @@ void FixLbPC::initial_integrate(int /*vflag*/) { compute_up(); - for(int i=0; itrilinear_stencil; - for(i=0; i=4) { + if (rsq>=4) { weightx=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(jj=-1; jj<3; jj++){ + for (jj=-1; jj<3; jj++) { rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) { + if (rsq>=4) { weighty=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(kk=-1; kk<3; kk++){ + for (kk=-1; kk<3; kk++) { rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) { + if (rsq>=4) { weightz=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; @@ -423,13 +423,13 @@ int FixLbPC::unpack_exchange(int nlocal, double *buf) izp = iz+kk; - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; FfP[isten] = weightx*weighty*weightz; // interpolated velocity based on delta function. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { up[i][k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; } } @@ -460,7 +460,7 @@ int FixLbPC::unpack_exchange(int nlocal, double *buf) + u_lb[ixp][iyp][izp][k]*FfP[7]; } } - for(k=0; k<3; k++) + for (k=0; k<3; k++) up[i][k] = up[i][k]*dx_lb/dt_lb; } diff --git a/src/USER-LB/fix_lb_rigid_pc_sphere.cpp b/src/USER-LB/fix_lb_rigid_pc_sphere.cpp index dd4b7b8647..88eb54593a 100644 --- a/src/USER-LB/fix_lb_rigid_pc_sphere.cpp +++ b/src/USER-LB/fix_lb_rigid_pc_sphere.cpp @@ -286,10 +286,10 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : iarg += 5; // specify if certain particles are inside the rigid spherical body, // and therefore should not - } else if(strcmp(arg[iarg],"innerNodes")==0){ + } else if (strcmp(arg[iarg],"innerNodes")==0) { inner_nodes = 1; igroupinner = group->find(arg[iarg+1]); - if(igroupinner == -1) + if (igroupinner == -1) error->all(FLERR,"Could not find fix lb/rigid/pc/sphere innerNodes group ID"); iarg += 2; } else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); @@ -328,16 +328,16 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : //count the number of atoms in the shell. if (inner_nodes == 1) { int *mask = atom->mask; - for(ibody=0; ibodybitmask[igroupinner])){ - if(body[i] >= 0) ncount[body[i]]++; + for (ibody=0; ibodybitmask[igroupinner])) { + if (body[i] >= 0) ncount[body[i]]++; } } MPI_Allreduce(ncount,nrigid_shell,nbody,MPI_INT,MPI_SUM,world); } else { - for(ibody=0; ibody < nbody; ibody++) nrigid_shell[ibody]=nrigid[ibody]; + for (ibody=0; ibody < nbody; ibody++) nrigid_shell[ibody]=nrigid[ibody]; } delete [] ncount; @@ -365,29 +365,29 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : int groupbit_lb_fluid = 0; - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0){ + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) { fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup]; } - if(groupbit_lb_fluid == 0) + if (groupbit_lb_fluid == 0) error->all(FLERR,"the lb/fluid fix must also be used if using the lb/rigid/pc/sphere fix"); int *mask = atom->mask; - if(inner_nodes == 1){ - for(int j=0; jbitmask[igroupinner]) && !(mask[j] & groupbit_lb_fluid)) + if (inner_nodes == 1) { + for (int j=0; jbitmask[igroupinner]) && !(mask[j] & groupbit_lb_fluid)) error->one(FLERR,"use the innerNodes keyword in the lb/rigid/pc/sphere fix for atoms which do not interact with the lb/fluid"); // If inner nodes are present, which should not interact with the fluid, make // sure these are not used by the lb/fluid fix to apply a force to the fluid. - if((mask[j] & groupbit) && (mask[j] & groupbit_lb_fluid) && (mask[j] & group->bitmask[igroupinner])) + if ((mask[j] & groupbit) && (mask[j] & groupbit_lb_fluid) && (mask[j] & group->bitmask[igroupinner])) error->one(FLERR,"the inner nodes specified in lb/rigid/pc/sphere should not be included in the lb/fluid fix"); } } else { - for(int j=0; jone(FLERR,"use the innerNodes keyword in the lb/rigid/pc/sphere fix for atoms which do not interact with the lb/fluid"); } } @@ -497,7 +497,7 @@ void FixLbRigidPCSphere::init() MPI_Allreduce(&flag,&extended,1,MPI_INT,MPI_MAX,world); } - if(extended) + if (extended) error->warning(FLERR,"Fix lb/rigid/pc/sphere assumes point particles"); // compute masstotal & center-of-mass of each rigid body @@ -530,8 +530,8 @@ void FixLbRigidPCSphere::init() sum[ibody][1] += yunwrap * massone; sum[ibody][2] += zunwrap * massone; sum[ibody][3] += massone; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][4] += massone; } } else { @@ -558,10 +558,10 @@ void FixLbRigidPCSphere::init() for (ibody = 0; ibody < nbody; ibody++) for (i = 0; i < 6; i++) sum[ibody][i] = 0.0; - for (i=0; ibitmask[igroupinner])){ + for (i=0; ibitmask[igroupinner])) { ibody = body[i]; xbox = (image[i] & IMGMASK) - IMGMAX; @@ -601,26 +601,26 @@ void FixLbRigidPCSphere::init() MPI_Allreduce(sum[0],all[0],6*nbody,MPI_DOUBLE,MPI_SUM,world); - for(ibody=0; ibody < nbody; ibody++){ + for (ibody=0; ibody < nbody; ibody++) { sphereradius[ibody] = sqrt(all[ibody][0]/nrigid_shell[ibody]); Gamma_MD[ibody] = all[ibody][1]*dm_lb/dt_lb/nrigid_shell[ibody]; } // Check that all atoms in the rigid body have the same value of gamma. double eps = 1.0e-7; - for (i=0; ibitmask[igroupinner])){ + for (i=0; ibitmask[igroupinner])) { ibody = body[i]; - if(Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) + if (Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) error->one(FLERR,"All atoms in a rigid body must have the same gamma value"); } } else { ibody = body[i]; - if(Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) + if (Gamma_MD[ibody]*dt_lb/dm_lb - Gamma[type[i]] > eps) error->one(FLERR,"All atoms in a rigid body must have the same gamma value"); } } @@ -790,8 +790,8 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) if (rmass) massone = rmass[i]; else massone = mass[type[i]]; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][0] += up[i][0]*massone; sum[ibody][1] += up[i][1]*massone; sum[ibody][2] += up[i][2]*massone; @@ -812,10 +812,10 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) //Store the total torque due to the fluid. for (ibody = 0; ibody < nbody; ibody++) - for(i = 0; i < 6; i++) sum[ibody][i] = 0.0; + for (i = 0; i < 6; i++) sum[ibody][i] = 0.0; - for(i = 0; iunmap(x[i],image[i],unwrap); @@ -827,8 +827,8 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) if (rmass) massone = rmass[i]; else massone = mass[type[i]]; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][0] += Gamma_MD[ibody]*(dy * ((up[i][2]-vcm[ibody][2])) - dz * ((up[i][1]-vcm[ibody][1]))); sum[ibody][1] += Gamma_MD[ibody]*(dz * ((up[i][0]-vcm[ibody][0])) - @@ -898,15 +898,15 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) expminusdttimesgamma = exp(-Gamma_MD[ibody]*dtv*nrigid_shell[ibody]/masstotal[ibody]); force_factor = force->ftm2v/Gamma_MD[ibody]/nrigid_shell[ibody]; - if(fflag[ibody][0]==1){ + if (fflag[ibody][0]==1) { vcm[ibody][0] = expminusdttimesgamma*(vcm[ibody][0] - ucm[ibody][0] - fcm[ibody][0]*force_factor) + ucm[ibody][0] + fcm[ibody][0]*force_factor; } - if(fflag[ibody][1]==1){ + if (fflag[ibody][1]==1) { vcm[ibody][1] = expminusdttimesgamma*(vcm[ibody][1] - ucm[ibody][1] - fcm[ibody][1]*force_factor) + ucm[ibody][1] + fcm[ibody][1]*force_factor; } - if(fflag[ibody][2]==1){ + if (fflag[ibody][2]==1) { vcm[ibody][2] = expminusdttimesgamma*(vcm[ibody][2] - ucm[ibody][2] - fcm[ibody][2]*force_factor) + ucm[ibody][2] + fcm[ibody][2]*force_factor; } @@ -916,19 +916,19 @@ void FixLbRigidPCSphere::initial_integrate(int vflag) expminusdttimesgamma = exp(-dtv*torque_factor); - if(tflag[ibody][0]==1){ + if (tflag[ibody][0]==1) { omega[ibody][0] = expminusdttimesgamma*(omega[ibody][0] - (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][0] + torque_fluid[ibody][0])) + (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][0] + torque_fluid[ibody][0]); } - if(tflag[ibody][1]==1){ + if (tflag[ibody][1]==1) { omega[ibody][1] = expminusdttimesgamma*(omega[ibody][1] - (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][1] + torque_fluid[ibody][1])) + (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][1] + torque_fluid[ibody][1]); } - if(tflag[ibody][2]==1){ + if (tflag[ibody][2]==1) { omega[ibody][2] = expminusdttimesgamma*(omega[ibody][2] - (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* (force->ftm2v*torque[ibody][2] + torque_fluid[ibody][2])) + (3.0/(2.0*nrigid_shell[ibody]*sphereradius[ibody]*sphereradius[ibody]*Gamma_MD[ibody]))* @@ -1040,8 +1040,8 @@ void FixLbRigidPCSphere::final_integrate() dy = unwrap[1] - xcm[ibody][1]; dz = unwrap[2] - xcm[ibody][2]; - if(inner_nodes == 1){ - if(!(mask[i] & group->bitmask[igroupinner])){ + if (inner_nodes == 1) { + if (!(mask[i] & group->bitmask[igroupinner])) { sum[ibody][0] += up[i][0]*massone; sum[ibody][1] += up[i][1]*massone; sum[ibody][2] += up[i][2]*massone; @@ -1148,7 +1148,7 @@ void FixLbRigidPCSphere::set_v() dz = zunwrap - xcm[ibody][2]; // save old velocities for virial. - if(evflag){ + if (evflag) { v0 = v[i][0]; v1 = v[i][1]; v2 = v[i][2]; @@ -1242,7 +1242,7 @@ void FixLbRigidPCSphere::set_xv() dz = zunwrap - xcm_old[ibody][2]; // save old positions and velocities for virial - if(evflag){ + if (evflag) { x0 = xunwrap; x1 = yunwrap; x2 = zunwrap; @@ -1578,8 +1578,8 @@ double FixLbRigidPCSphere::compute_array(int i, int j) double FfP[64]; - for(i=0; i=4) { + if (rsq>=4) { weightx=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(jj=-1; jj<3; jj++){ + for (jj=-1; jj<3; jj++) { rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) { + if (rsq>=4) { weighty=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } - for(kk=-1; kk<3; kk++){ + for (kk=-1; kk<3; kk++) { rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) { + if (rsq>=4) { weightz=0.0; } else { r=sqrt(rsq); - if(rsq>1){ + if (rsq>1) { weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else { weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; @@ -1646,13 +1646,13 @@ double FixLbRigidPCSphere::compute_array(int i, int j) izp = iz+kk; - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if (ixp==-1) ixp=subNbx+2; + if (iyp==-1) iyp=subNby+2; + if (izp==-1) izp=subNbz+2; FfP[isten] = weightx*weighty*weightz; // interpolated velocity based on delta function. - for(k=0; k<3; k++){ + for (k=0; k<3; k++) { up[i][k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; } } @@ -1683,7 +1683,7 @@ double FixLbRigidPCSphere::compute_array(int i, int j) + u_lb[ixp][iyp][izp][k]*FfP[7]; } } - for(k=0; k<3; k++) + for (k=0; k<3; k++) up[i][k] = up[i][k]*dx_lb/dt_lb; } diff --git a/src/USER-LB/fix_lb_viscous.cpp b/src/USER-LB/fix_lb_viscous.cpp index d796942941..08a0a10356 100644 --- a/src/USER-LB/fix_lb_viscous.cpp +++ b/src/USER-LB/fix_lb_viscous.cpp @@ -37,19 +37,19 @@ FixLbViscous::FixLbViscous(LAMMPS *lmp, int narg, char **arg) : int groupbit_lb_fluid = 0; - for(int ifix=0; ifixnfix; ifix++) - if(strcmp(modify->fix[ifix]->style,"lb/fluid")==0){ + for (int ifix=0; ifixnfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"lb/fluid")==0) { fix_lb_fluid = (FixLbFluid *)modify->fix[ifix]; groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup]; } - if(groupbit_lb_fluid == 0) + if (groupbit_lb_fluid == 0) error->all(FLERR,"the lb/fluid fix must also be used if using the lb/viscous fix"); int *mask = atom->mask; int nlocal = atom->nlocal; - for(int j=0; jone(FLERR,"to apply a fluid force onto an atom, the lb/fluid fix must be used for that atom."); } diff --git a/src/USER-MANIFOLD/fix_manifoldforce.cpp b/src/USER-MANIFOLD/fix_manifoldforce.cpp index 37f9fac522..bcb14ce1f9 100644 --- a/src/USER-MANIFOLD/fix_manifoldforce.cpp +++ b/src/USER-MANIFOLD/fix_manifoldforce.cpp @@ -86,7 +86,7 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) : // equal style vars (so that they are not overwritten each time step). double *params = ptr_m->params; - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { if (was_var( arg[i+4] )) error->all(FLERR,"Equal-style variables not allowed with fix manifoldforce"); @@ -157,7 +157,7 @@ void FixManifoldForce::post_force(int /*vflag*/) double n[3]; double invn2; double dot; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { // Determine normal of particle: ptr_m->n(x[i],n); diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index 49f24fb5b6..bea7955d33 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -117,7 +117,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, error->all(FLERR, msg); } // Loop over manifold args: - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { int len = 0, offset = 0; if (was_var( arg[i+6] )) { len = strlen(arg[i+6]) - 1; // -1 because -2 for v_, +1 for \0. @@ -135,7 +135,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, ptr_m->params = new double[nvars]; if (!ptr_m->params ) error->all(FLERR,"Failed to allocate params!"); - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { // If param i was variable type, it will be set later... ptr_m->params[i] = is_var[i] ? 0.0 : utils::numeric( FLERR, arg[i+6] ,false,lmp); } @@ -144,7 +144,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, // Loop over rest of args: int argi = 6 + nvars; - while( argi < narg ){ + while( argi < narg ) { if (strcmp(arg[argi], "every") == 0) { nevery = utils::inumeric(FLERR,arg[argi+1],false,lmp); next_output = update->ntimestep + nevery; @@ -170,7 +170,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, FixNVEManifoldRattle::~FixNVEManifoldRattle() { if (tstrs) { - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { delete [] tstrs[i]; } delete [] tstrs; @@ -277,7 +277,7 @@ void FixNVEManifoldRattle::update_var_params() double *ptr_params = ptr_m->params; - for( int i = 0; i < nvars; ++i ){ + for( int i = 0; i < nvars; ++i ) { if (is_var[i]) { tvars[i] = input->variable->find(tstrs[i]); if (tvars[i] < 0) { @@ -306,8 +306,8 @@ int FixNVEManifoldRattle::dof(int /*igroup*/) int *mask = atom->mask; int nlocal = atom->nlocal; int natoms = 0; - for( int i = 0; i < nlocal; ++i ){ - if(mask[i] & groupbit) ++natoms; + for( int i = 0; i < nlocal; ++i ) { + if (mask[i] & groupbit) ++natoms; } int dofs; @@ -362,7 +362,7 @@ void FixNVEManifoldRattle::final_integrate() ---------------------------------------------------------------------------*/ void FixNVEManifoldRattle::end_of_step() { - if (nevery && (update->ntimestep == next_output)){ + if (nevery && (update->ntimestep == next_output)) { if (comm->me == 0) { print_stats( "nve/manifold/rattle" ); next_output += nevery; @@ -386,21 +386,21 @@ void FixNVEManifoldRattle::nve_x_rattle(int igroup, int groupbit) int nlocal = atom->nlocal; int natoms = 0; - if (igroup == atom->firstgroup){ + if (igroup == atom->firstgroup) { nlocal = atom->nfirst; } if (rmass) { - for (int i = 0; i < nlocal; i++){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { natoms++; dtfm = dtf / rmass[i]; rattle_manifold_x( x[i], v[i], f[i], dtv, dtfm, atom->tag[i] ); } } } else { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { natoms++; dtfm = dtf / mass[type[i]]; @@ -442,7 +442,7 @@ void FixNVEManifoldRattle::nve_v_rattle(int igroup, int groupbit) } } } else { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { dtfm = dtf / mass[type[i]]; rattle_manifold_v( v[i], f[i], x[i], dtfm, atom->tag[i] ); diff --git a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp index 76f6ddb3df..d8a5360506 100644 --- a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp @@ -165,7 +165,7 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg, eta_dot[mtchain] = 0.0; eta_dot[mtchain] = 0.0; - for( int ich = 0; ich < mtchain; ++ich ){ + for( int ich = 0; ich < mtchain; ++ich ) { eta[ich] = eta_dot[ich] = eta_dotdot[ich] = 0.0; } @@ -232,11 +232,11 @@ void FixNVTManifoldRattle::setup(int /*vflag*/) // Compute/set eta-masses: double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] - boltz * t_target ) / eta_mass[ich]; } @@ -249,7 +249,7 @@ void FixNVTManifoldRattle::compute_temp_target() tdof = temperature->dof; double delta = update->ntimestep - update->beginstep; - if (delta != 0.0){ + if (delta != 0.0) { delta /= update->endstep - update->beginstep; } @@ -268,7 +268,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() double expfac, kecurrent = tdof * boltz * t_current; double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } @@ -278,7 +278,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0; } - for( ich = mtchain-1; ich > 0; --ich ){ + for( ich = mtchain-1; ich > 0; --ich ) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dot[ich] += eta_dotdot[ich] * dt4; @@ -311,14 +311,14 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0.0; } - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { eta[ich] += dthalf*eta_dot[ich]; } eta_dot[0] *= expfac; eta_dot[0] += eta_dotdot[0]*dt4; eta_dot[0] *= expfac; - for( int ich = 1; ich < mtchain; ++ich ){ + for( int ich = 1; ich < mtchain; ++ich ) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] @@ -340,7 +340,7 @@ void FixNVTManifoldRattle::nh_v_temp() if (which == NOBIAS) { - for( int i = 0; i < nlocal; ++i ){ + for( int i = 0; i < nlocal; ++i ) { if (mask[i] & groupbit) { v[i][0] *= factor_eta; v[i][1] *= factor_eta; @@ -348,7 +348,7 @@ void FixNVTManifoldRattle::nh_v_temp() } } } else if (which == BIAS) { - for( int i = 0; i < nlocal; ++i ){ + for( int i = 0; i < nlocal; ++i ) { if (mask[i] & groupbit) { temperature->remove_bias(i,v[i]); v[i][0] *= factor_eta; diff --git a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp index 7b0d7d4d3a..0864e1e2f2 100644 --- a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp +++ b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp @@ -69,7 +69,7 @@ public: double ff = x(t) - xx; double ffp = xp(t); // double l = 1.0 / ( 1 + res*res ); - for( int i = 0; i < maxit; ++i ){ + for( int i = 0; i < maxit; ++i ) { t -= ff / ffp; ff = x(t) - xx; ffp = xp(t); @@ -294,7 +294,7 @@ void manifold_gaussian_bump::make_lut() cubic_hermite pchip( lut_x0, lut_x1, f_at_rc, 0.0, fp_at_rc, 0.0, error ); double xx = lut_x0; - for( int i = 0; i <= lut_Nbins; ++i ){ + for( int i = 0; i <= lut_Nbins; ++i ) { lut_z[i] = pchip.y_from_x( xx ); lut_zp[i] = pchip.yp_from_x( xx ); xx += lut_dx; @@ -355,7 +355,7 @@ void manifold_gaussian_bump::test_lut() FILE *fp = fopen( "test_lut_gaussian.dat", "w" ); double dx = 0.1; - for( double xx = 0; xx < 20; xx += dx ){ + for( double xx = 0; xx < 20; xx += dx ) { x[0] = xx; x[1] = 0.0; x[2] = 0.0; diff --git a/src/USER-MANIFOLD/manifold_thylakoid.cpp b/src/USER-MANIFOLD/manifold_thylakoid.cpp index a1d2c7a62f..c4dfd33c30 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid.cpp @@ -25,7 +25,7 @@ manifold_thylakoid::manifold_thylakoid( LAMMPS *lmp, int /*narg*/, char ** /*arg manifold_thylakoid::~manifold_thylakoid() { - for(std::size_t i = 0; i < parts.size(); ++i) { + for (std::size_t i = 0; i < parts.size(); ++i) { delete parts[i]; } } @@ -60,14 +60,14 @@ void manifold_thylakoid::checkup() if (comm->me == 0 ) { fprintf(screen,"This is checkup of thylakoid %p\n", this); fprintf(screen,"I have %ld parts. They are:\n", parts.size()); - for( int i = 0; i < (int)parts.size(); ++i ){ + for ( int i = 0; i < (int)parts.size(); ++i ) { fprintf(screen, "[%f, %f] x [%f, %f] x [%f, %f]\n", parts[i]->xlo, parts[i]->xhi, parts[i]->ylo, parts[i]->yhi, parts[i]->zlo, parts[i]->zhi ); } fprintf(screen,"My params are:\n"); - for( int i = 0; i < NPARAMS; ++i ){ + for ( int i = 0; i < NPARAMS; ++i ) { fprintf(screen,"%f\n", params[i]); } } @@ -79,7 +79,7 @@ double manifold_thylakoid::g( const double *x ) int err = 0; std::size_t idx; thyla_part *p = get_thyla_part(x,&err,&idx); - if(err){ + if (err) { char msg[2048]; sprintf(msg,"Error getting thyla_part for x = (%f, %f, %f)",x[0],x[1],x[2]); error->one(FLERR,msg); @@ -101,7 +101,7 @@ void manifold_thylakoid::n( const double *x, double *n ) int err = 0; std::size_t idx; thyla_part *p = get_thyla_part(x,&err,&idx); - if(err){ + if (err) { char msg[2048]; sprintf(msg,"Error getting thyla_part for x = (%f, %f, %f)",x[0],x[1],x[2]); error->one(FLERR,msg); @@ -120,7 +120,7 @@ void manifold_thylakoid::n( const double *x, double *n ) thyla_part *manifold_thylakoid::get_thyla_part( const double *x, int * /*err_flag*/, std::size_t *idx ) { - for( std::size_t i = 0; i < parts.size(); ++i ){ + for ( std::size_t i = 0; i < parts.size(); ++i ) { thyla_part *p = parts[i]; if (is_in_domain(p,x)) { if (idx != nullptr) *idx = i; @@ -185,17 +185,17 @@ void manifold_thylakoid::init_domains() #ifndef USE_PHONY_LAMMPS char msg[2048]; - if(x1 > domain->boxhi[0]){ + if (x1 > domain->boxhi[0]) { sprintf(msg,"Expected xhi larger than current box has: %f > %f", x1, domain->boxhi[0]); error->one(FLERR,msg); } - if(y1 > domain->boxhi[1]){ + if (y1 > domain->boxhi[1]) { sprintf(msg,"Expected yhi larger than current box has: %f > %f", y1, domain->boxhi[1]); error->one(FLERR,msg); } - // if(z1 > domain->boxhi[2]){ + // if (z1 > domain->boxhi[2]) { // sprintf(msg,"Expected zhi larger than current box has: %f > %f", // z1, domain->boxhi[2]); // error->one(FLERR,msg); @@ -604,7 +604,7 @@ thyla_part *manifold_thylakoid::make_cyl_to_plane_part(double X0, double R0, dou void manifold_thylakoid::print_part_data( FILE *fp_doms, FILE *fp_coms ) { - for( std::size_t i = 0; i < parts.size(); ++i ){ + for ( std::size_t i = 0; i < parts.size(); ++i ) { thyla_part *p = parts[i]; fprintf(fp_doms, "%f %f\n", p->xlo, p->ylo); fprintf(fp_doms, "%f %f\n", p->xlo, p->yhi); diff --git a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp index 1c6b4dd06a..c0b6871ea8 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp @@ -10,7 +10,7 @@ thyla_part::thyla_part( int type, double *args, double xlo, double ylo, double z : type(type), xlo(xlo), xhi(xhi), ylo(ylo), yhi(yhi), zlo(zlo), zhi(zhi) { - switch(type){ + switch(type) { case THYLA_TYPE_PLANE: // a*(x-x0) + b*(y-y0) + c*(z-z0) = 0 params[0] = args[0]; // a params[1] = args[1]; // b @@ -40,7 +40,7 @@ thyla_part::thyla_part( int type, double *args, double xlo, double ylo, double z // The others should be 1. if ( (args[0] != 1.0) && (args[0] != 0.0) && (args[1] != 1.0) && (args[1] != 0.0) && - (args[2] != 1.0) && (args[2] != 0.0) ){ + (args[2] != 1.0) && (args[2] != 0.0) ) { err_flag = -1; } break; @@ -83,7 +83,7 @@ thyla_part::~thyla_part() double thyla_part::g(const double *x) { - switch(type){ + switch(type) { case THYLA_TYPE_PLANE:{ // a*(x-x0) + b*(y-y0) + c*(z-z0) = 0 double a = params[0]; double b = params[1]; @@ -144,7 +144,7 @@ double thyla_part::g(const double *x) void thyla_part::n( const double *x, double *n ) { - switch(type){ + switch(type) { case THYLA_TYPE_PLANE:{ // a*(x-x0) + b*(y-y0) + c*(z-z0) = 0 double a = params[0]; double b = params[1]; diff --git a/src/USER-MEAMC/meam_funcs.cpp b/src/USER-MEAMC/meam_funcs.cpp index 7f4067a1e5..7292dd64b0 100644 --- a/src/USER-MEAMC/meam_funcs.cpp +++ b/src/USER-MEAMC/meam_funcs.cpp @@ -383,7 +383,7 @@ MEAM::get_Zij2(const lattice_t latt, const double cmin, const double cmax, } // Compute screening for each first neighbor - if (latt==DIA3){ // special case for 3NN diamond structure + if (latt==DIA3) { // special case for 3NN diamond structure C = 1.0; } else { C = 4.0 / (a * a) - 1.0; diff --git a/src/USER-MEAMC/meam_setup_done.cpp b/src/USER-MEAMC/meam_setup_done.cpp index 84a11c607b..3a62bf0942 100644 --- a/src/USER-MEAMC/meam_setup_done.cpp +++ b/src/USER-MEAMC/meam_setup_done.cpp @@ -488,8 +488,8 @@ MEAM::phi_meam(double r, int a, int b) } else if (this->lattce_meam[a][b] == CH4) { phi_m = (5 * Eu - F1 - 4*F2)/4; - } else if (this->lattce_meam[a][b] == ZIG){ - if (a==b){ + } else if (this->lattce_meam[a][b] == ZIG) { + if (a==b) { phi_m = (2 * Eu - F1 - F2) / Z12; } else{ Z1 = get_Zij(this->lattce_meam[a][b]); @@ -504,7 +504,7 @@ MEAM::phi_meam(double r, int a, int b) } } else if (this->lattce_meam[a][b] == TRI) { - if (a==b){ + if (a==b) { phi_m = (3.0*Eu - 2.0*F1 - F2) / Z12; } else { Z1 = get_Zij(this->lattce_meam[a][b]); diff --git a/src/USER-MESODPD/fix_edpd_source.cpp b/src/USER-MESODPD/fix_edpd_source.cpp index 39c250141e..98a36e589a 100644 --- a/src/USER-MESODPD/fix_edpd_source.cpp +++ b/src/USER-MESODPD/fix_edpd_source.cpp @@ -37,7 +37,7 @@ FixEDPDSource::FixEDPDSource(LAMMPS *lmp, int narg, char **arg) : else error->all(FLERR,"Illegal fix edpd/source command"); iarg++; - if(option == 0){ + if (option == 0) { if (narg != 9 ) error->all(FLERR,"Illegal fix edpd/source command (5 args for sphere)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -45,7 +45,7 @@ FixEDPDSource::FixEDPDSource(LAMMPS *lmp, int narg, char **arg) : radius = utils::numeric(FLERR,arg[iarg++],false,lmp); value = utils::numeric(FLERR,arg[iarg++],false,lmp); } - else if(option == 1){ + else if (option == 1) { if (narg != 11 ) error->all(FLERR,"Illegal fix edpd/edpd command (7 args for cuboid)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -94,19 +94,19 @@ void FixEDPDSource::post_force(int /*vflag*/) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if(option == 0){ + if (option == 0) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; rsq = drx*drx + dry*dry + drz*drz; - if(rsq < radius_sq) + if (rsq < radius_sq) edpd_flux[i] += value*edpd_cv[i]; } - else if(option == 1){ + else if (option == 1) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; - if(fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) + if (fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) edpd_flux[i] += value*edpd_cv[i]; } } diff --git a/src/USER-MESODPD/fix_mvv_dpd.cpp b/src/USER-MESODPD/fix_mvv_dpd.cpp index d8b36e12f4..7d8658a065 100644 --- a/src/USER-MESODPD/fix_mvv_dpd.cpp +++ b/src/USER-MESODPD/fix_mvv_dpd.cpp @@ -39,7 +39,7 @@ FixMvvDPD::FixMvvDPD(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix mvv/dpd command"); verlet = 0.5; - if(narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); + if (narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); dynamic_group_allow = 1; time_integrate = 1; diff --git a/src/USER-MESODPD/fix_mvv_edpd.cpp b/src/USER-MESODPD/fix_mvv_edpd.cpp index 9cb4b86d85..200ab2564e 100644 --- a/src/USER-MESODPD/fix_mvv_edpd.cpp +++ b/src/USER-MESODPD/fix_mvv_edpd.cpp @@ -48,7 +48,7 @@ FixMvvEDPD::FixMvvEDPD(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix mvv/edpd command"); verlet = 0.5; - if(narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); + if (narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); dynamic_group_allow = 1; time_integrate = 1; diff --git a/src/USER-MESODPD/fix_mvv_tdpd.cpp b/src/USER-MESODPD/fix_mvv_tdpd.cpp index 84a7fdbaf9..8819595174 100644 --- a/src/USER-MESODPD/fix_mvv_tdpd.cpp +++ b/src/USER-MESODPD/fix_mvv_tdpd.cpp @@ -44,7 +44,7 @@ FixMvvTDPD::FixMvvTDPD(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix mvv/tdpd command"); verlet = 0.5; - if(narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); + if (narg > 3) verlet = utils::numeric(FLERR,arg[3],false,lmp); cc_species = atom->cc_species; @@ -107,7 +107,7 @@ void FixMvvTDPD::initial_integrate(int /*vflag*/) v[i][0] += 2.0 * verlet * dtfm * f[i][0]; v[i][1] += 2.0 * verlet * dtfm * f[i][1]; v[i][2] += 2.0 * verlet * dtfm * f[i][2]; - for(int k = 0; k < cc_species; k++) + for (int k = 0; k < cc_species; k++) cc[i][k] += 0.5 * dtv * cc_flux[i][k]; } } @@ -140,7 +140,7 @@ void FixMvvTDPD::final_integrate() v[i][0] = vest[i][0] + dtfm * f[i][0]; v[i][1] = vest[i][1] + dtfm * f[i][1]; v[i][2] = vest[i][2] + dtfm * f[i][2]; - for(int k = 0; k < cc_species; k++) + for (int k = 0; k < cc_species; k++) cc[i][k] += 0.5 * dtv * cc_flux[i][k]; } } diff --git a/src/USER-MESODPD/fix_tdpd_source.cpp b/src/USER-MESODPD/fix_tdpd_source.cpp index 25a8332e9f..c0669552ff 100644 --- a/src/USER-MESODPD/fix_tdpd_source.cpp +++ b/src/USER-MESODPD/fix_tdpd_source.cpp @@ -38,7 +38,7 @@ FixTDPDSource::FixTDPDSource(LAMMPS *lmp, int narg, char **arg) : else error->all(FLERR,"Illegal fix tdpd/source command"); iarg++; - if(option == 0){ + if (option == 0) { if (narg != 10 ) error->all(FLERR,"Illegal fix tdpd/source command (5 args for sphere)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -46,7 +46,7 @@ FixTDPDSource::FixTDPDSource(LAMMPS *lmp, int narg, char **arg) : radius = utils::numeric(FLERR,arg[iarg++],false,lmp); value = utils::numeric(FLERR,arg[iarg++],false,lmp); } - else if(option == 1){ + else if (option == 1) { if (narg != 12 ) error->all(FLERR,"Illegal fix tdpd/edpd command (7 args for cuboid)"); center[0] = utils::numeric(FLERR,arg[iarg++],false,lmp); center[1] = utils::numeric(FLERR,arg[iarg++],false,lmp); @@ -94,19 +94,19 @@ void FixTDPDSource::post_force(int /*vflag*/) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if(option == 0){ + if (option == 0) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; rsq = drx*drx + dry*dry + drz*drz; - if(rsq < radius_sq) + if (rsq < radius_sq) cc_flux[i][cc_index-1] += value; } - else if(option == 1){ + else if (option == 1) { drx = x[i][0] - center[0]; dry = x[i][1] - center[1]; drz = x[i][2] - center[2]; - if(fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) + if (fabs(drx) <= 0.5*dLx && fabs(dry) <= 0.5*dLy && fabs(drz) <= 0.5*dLz) cc_flux[i][cc_index-1] += value; } } diff --git a/src/USER-MESODPD/pair_edpd.cpp b/src/USER-MESODPD/pair_edpd.cpp index c3b4d3b1fe..f7201052ff 100644 --- a/src/USER-MESODPD/pair_edpd.cpp +++ b/src/USER-MESODPD/pair_edpd.cpp @@ -162,9 +162,9 @@ void PairEDPD::compute(int eflag, int vflag) T_pow[3] = T_pow[0]*T_pow[2]; double power_d = power[itype][jtype]; - if(power_flag){ + if (power_flag) { double factor = 1.0; - for(int k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) factor += sc[itype][jtype][k]*T_pow[k]; power_d *= factor; } @@ -197,9 +197,9 @@ void PairEDPD::compute(int eflag, int vflag) randnumT = MAX(-5.0,MIN(randnum,5.0)); double kappaT = kappa[itype][jtype]; - if(kappa_flag) { + if (kappa_flag) { double factor = 1.0; - for(int k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) factor += kc[itype][jtype][k]*T_pow[k]; kappaT *= factor; } @@ -350,11 +350,11 @@ void PairEDPD::coeff(int narg, char **arg) powerT[i][j]= powerT_one; cutT[i][j] = cutT_one; - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) sc[i][j][k] = sc_one[k]; - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) kc[i][j][k] = kc_one[k]; @@ -399,11 +399,11 @@ double PairEDPD::init_one(int i, int j) kappa[j][i] = kappa[i][j]; powerT[j][i]= powerT[i][j]; - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) sc[j][i][k] = sc[i][j][k]; - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) kc[j][i][k] = kc[i][j][k]; @@ -429,11 +429,11 @@ void PairEDPD::write_restart(FILE *fp) fwrite(&kappa[i][j],sizeof(double),1,fp); fwrite(&powerT[i][j],sizeof(double),1,fp); fwrite(&cutT[i][j],sizeof(double),1,fp); - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) fwrite(&sc[i][j][k],sizeof(double),1,fp); - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) fwrite(&kc[i][j][k],sizeof(double),1,fp); } @@ -464,11 +464,11 @@ void PairEDPD::read_restart(FILE *fp) utils::sfread(FLERR,&kappa[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR,&powerT[i][j],sizeof(double),1,fp,nullptr,error); utils::sfread(FLERR,&cutT[i][j],sizeof(double),1,fp,nullptr,error); - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) utils::sfread(FLERR,&sc[i][j][k],sizeof(double),1,fp,nullptr,error); - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) utils::sfread(FLERR,&kc[i][j][k],sizeof(double),1,fp,nullptr,error); } @@ -479,11 +479,11 @@ void PairEDPD::read_restart(FILE *fp) MPI_Bcast(&kappa[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&powerT[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cutT[i][j],1,MPI_DOUBLE,0,world); - if(power_flag) + if (power_flag) for (int k = 0; k < 4; k++) MPI_Bcast(&sc[i][j][k],1,MPI_DOUBLE,0,world); - if(kappa_flag) + if (kappa_flag) for (int k = 0; k < 4; k++) MPI_Bcast(&kc[i][j][k],1,MPI_DOUBLE,0,world); } diff --git a/src/USER-MESODPD/pair_mdpd.cpp b/src/USER-MESODPD/pair_mdpd.cpp index 0506886861..4dc42eb56a 100644 --- a/src/USER-MESODPD/pair_mdpd.cpp +++ b/src/USER-MESODPD/pair_mdpd.cpp @@ -241,7 +241,7 @@ void PairMDPD::settings(int narg, char **arg) void PairMDPD::coeff(int narg, char **arg) { - if(narg != 7 ) error->all(FLERR,"Incorrect args for pair coefficients\n itype jtype A B gamma cutA cutB"); + if (narg != 7 ) error->all(FLERR,"Incorrect args for pair coefficients\n itype jtype A B gamma cutA cutB"); if (!allocated) allocate(); int ilo,ihi,jlo,jhi; @@ -254,7 +254,7 @@ void PairMDPD::coeff(int narg, char **arg) double cut_one = utils::numeric(FLERR,arg[5],false,lmp); double cut_two = utils::numeric(FLERR,arg[6],false,lmp); - if(cut_one < cut_two) error->all(FLERR,"Incorrect args for pair coefficients\n cutA should be larger than cutB."); + if (cut_one < cut_two) error->all(FLERR,"Incorrect args for pair coefficients\n cutA should be larger than cutB."); int count = 0; for (int i = ilo; i <= ihi; i++) { diff --git a/src/USER-MESODPD/pair_tdpd.cpp b/src/USER-MESODPD/pair_tdpd.cpp index 88d89a860d..a416d94a00 100644 --- a/src/USER-MESODPD/pair_tdpd.cpp +++ b/src/USER-MESODPD/pair_tdpd.cpp @@ -159,7 +159,7 @@ void PairTDPD::compute(int eflag, int vflag) // chemical concentration transport if (r < cutcc[itype][jtype]) { - for(int k=0; k b) + else if (a > b) return 1; else return 0; @@ -66,7 +66,7 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub FILE *in = fopen(potin_file,"r"); char line[1024]; - if(in == nullptr) { + if (in == nullptr) { fprintf(stderr,"@%s:%d: Error reading potin file. Can not open file \'%s\'.\n", __FILE__,__LINE__,potin_file); exit(1); @@ -80,22 +80,22 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub double r0x,r1x,drx; int nrx,i; - if(line[strspn(line," \t")] == '#') continue; + if (line[strspn(line," \t")] == '#') continue; - if(n == 0) { + if (n == 0) { metal[0] = 0; - if(sscanf(line,"%s %d %d",metal,&ipot,&mode) != 3) { + if (sscanf(line,"%s %d %d",metal,&ipot,&mode) != 3) { fprintf(stderr,"@%s:%d: Error on potin file. line = %s\n", __FILE__,__LINE__,line); exit(1); } } else { metalx[0] = 0; - if(sscanf(line,"%s %d %d",metalx,&ipotx,&modex) != 3) { + if (sscanf(line,"%s %d %d",metalx,&ipotx,&modex) != 3) { fprintf(stderr,"@%s:%d: Error on potin file. line = %s\n", __FILE__,__LINE__,line); exit(1); - } else if(strcmp(metal,metalx) != 0 || ipot != ipotx || mode != modex) { + } else if (strcmp(metal,metalx) != 0 || ipot != ipotx || mode != modex) { fprintf(stderr,"@%s:%d: Error on potin file, parameter mismatch:\n" " metal = \'%s\' ipot = %d mode = %d\n" " metalx = \'%s\' ipotx = %d modex = %d\n", @@ -108,39 +108,39 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub fgets(line,sizeof(line),in); sscanf(line,"%lf %lf %lf %lf",&zval,&ivol,&rws,&mass); - if(n >= vsize) { + if (n >= vsize) { vsize = 2*vsize; volarr = (double *) realloc(volarr,sizeof(double) * vsize); } volarr[n] = ivol; n = n + 1; - for(i = 0; i<5; i++) + for (i = 0; i<5; i++) fgets(line,sizeof(line),in); sscanf(line,"%lf %lf %lf",&r0x,&r1x,&drx); nrx = (int) ((r1x-r0x)/drx + 1.1); /* Really: 1+round((r1-r0)/dr) */ - for(i = 0; i nvol = %d, vol0 = %.6f, x0= %.6f, x1 = %.6f, dx = %.6f\n", nvol,vol0,x0,x1,dx); } @@ -214,8 +214,8 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl anorm3 = s*ss + 2.0*( p*pp + d*dd + f*ff); anorm4 = ss*ss + 2.0*(pp*pp + dd*dd + ff*ff); /* - for(i = 1; i<=lmax; i++) { - for(j = 1; j<=lmax; j++) + for (i = 1; i<=lmax; i++) { + for (j = 1; j<=lmax; j++) del0.m[i][j] = 0.0; del0[i][i] = 1.0; } @@ -237,10 +237,10 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl in = fopen(potin_file,"r"); int *tag = new int[nx]; - for(i = 0; i 1e-3) + if (fabs(volguess/ivol - 1.0) > 1e-3) printf("Wrong volume guess, i=%d volgues=%15.5e ivol=%15.5e\n", i,volguess,ivol); }*/ double ifrac = (pow(ivol/vol0,1.0/3.0) - x0)/((x1-x0)/(nx-1)); i = (int) (ifrac + 0.1); - if(fabs(i - ifrac) > 0.01) { + if (fabs(i - ifrac) > 0.01) { printf("Volume point not in table... ii=%d i=%d ifrac=%15.5e vol=%15.5e\n", ii,i,ifrac,ivol); printf("vol0 = %15.5e zval = %15.5e mass = %15.5e\n",vol0,zval,mass); exit(1); - } else if(tag[i] == 1) { + } else if (tag[i] == 1) { printf("Duplicate volume point in table.... ii=%d i=%d ifrac=%15.5e vol=%15.5e\n", ii,i,ifrac,ivol); exit(1); @@ -334,7 +334,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl fgets(line,sizeof(line),in); sscanf(line,"%lf %lf %lf %lf %lf", &vatab[i],&vbtab[i],&vctab[i],&vdtab[i],&vetab[i]); - if(ipot == 1) { + if (ipot == 1) { vatab[i] *= vdtab[i]; vctab[i] *= vctab[i]; vetab[i] *= vetab[i]; @@ -346,14 +346,14 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl sscanf(line,"%lf %lf %lf",&r0x,&r1x,&drx); nrx = (int) ((r1x-r0x)/drx + 1.1); /* Really: 1+round((r1-r0)/dr) */ - if(ii == 0) { + if (ii == 0) { r0 = r0x; r1 = r1x; dr = drx; nr = nrx; vpairtab = new double[nx*nr]; } else { /* Check that {r0,r1,dr,nr}x == {r0,r1,dr,nr} */ } - for(j = 0; j= r0rws) { + if (bscreen == 1 && rrws >= r0rws) { double arg = rrws/r0rwstab[i]; double arg1 = arg - 1.0; double arg12 = arg1*arg1; double f,dp; - if(mode <= 2) { + if (mode <= 2) { f = fgauss(arg,al); dp=2.*al*arg*arg1; } @@ -407,16 +407,16 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl double vpair_tmp = vpairtab[i*nr+j]; vpairtab[i*nr+j] = vpairtab[i*nr+j]*fscr + v2a - v2b; - if(0) if(fabs(vol-ivol) < 0.01) { + if (0) if (fabs(vol-ivol) < 0.01) { static FILE *xfile = nullptr; - if(j == 0) { + if (j == 0) { xfile = fopen("mgpt5-pot.dat","w"); fprintf(xfile,"%%%% vol = %15.5e ivol = %15.5e i = %d ii = %d\n", vol,ivol,i,ii); } fprintf(xfile,"%15.5e %15.5e %15.5e %15.5e %15.5e %20.10e\n", r,vpair_tmp,fscr,v2a,v2b,flr); - if(j == nr-1) fclose(xfile); + if (j == nr-1) fclose(xfile); } @@ -426,8 +426,8 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl } fclose(in); - for(i = 0; i0; i--) { + for (int i = n-1; i>0; i--) { double q = A[i-1][2] / A[i][1]; A[i-1][1] = A[i-1][1] - q*A[i][0]; y[i-1] = y[i-1] - q*y[i]; @@ -28,7 +28,7 @@ static void trisolve(int n,double A[][3],double y[]) { /* Forward substitution */ y[0] = y[0] / A[0][1]; - for(int i = 1; i n-1) idx = n-1; + if (idx < 0) idx = 0; + if (idx > n-1) idx = n-1; xhat = xhat - idx; p = C[idx]; - if(0) { + if (0) { *y = p[0] + xhat*(p[1] + xhat*(p[2] + xhat*p[3])); *dy = p[1] + xhat*(2*p[2] + xhat*3*p[3]); diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index c056258127..b358b12857 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -51,7 +51,7 @@ using namespace LAMMPS_NS; #endif static double gettime(int x = 0) { - if(1) { + if (1) { /* struct timeval tv; gettimeofday(&tv,nullptr); @@ -93,7 +93,7 @@ PairMGPT::PairMGPT(LAMMPS *lmp) : Pair(lmp) PairMGPT::~PairMGPT() { - if(allocated) { + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cutghost); @@ -107,8 +107,8 @@ static double t_make_b2 = 0.0,n_make_b2 = 0.0; template void fmatconv(intype *array) { outtype *cast = (outtype *) array; - for(int i = 0; iHz.m)) & 31) == 0 ); rij = 0.0; - for(p = 0; p<3; p++) { + for (p = 0; p<3; p++) { rrij[p] = xx[i][p] - xx[j][p]; rij = rij + rrij[p]*rrij[p]; } /* Zero all matrix elements */ - for(i = 0; i<8; i++) - for(j = 0; j<8; j++) { + for (i = 0; i<8; i++) + for (j = 0; j<8; j++) { bptr->H.m[i][j] = 0.0; bptr->Hx.m[i][j] = 0.0; bptr->Hy.m[i][j] = 0.0; @@ -140,9 +140,9 @@ void PairMGPT::make_bond(const double xx[][3],int i,int j,bond_data *bptr) { bptr->Hz.m[j][i] = 0.0; } - if(rij <= rcrit*rcrit) { + if (rij <= rcrit*rcrit) { t0 = gettime(); - if(lang == 3) { + if (lang == 3) { hamltn_5_raw(rrij[0],rrij[1],rrij[2], bptr->H.m ,bptr->Hx.m, bptr->Hy.m,bptr->Hz.m,&bptr->fl_deriv_sum); @@ -159,7 +159,7 @@ void PairMGPT::make_bond(const double xx[][3],int i,int j,bond_data *bptr) { bptr->fl_deriv_sum = 0.0; } - if(linalg.single) { + if (linalg.single) { fmatconv(&(bptr->H.m[1][0])); fmatconv(&(bptr->Hx.m[1][0])); fmatconv(&(bptr->Hy.m[1][0])); @@ -174,12 +174,12 @@ static inline double mtrace(int n,double A[8][8],double B[8][8]) { double s; t0 = gettime(); - if(n == 5) s = mtrace_5(A,B); - else if(n == 7) s = mtrace_7(A,B); + if (n == 5) s = mtrace_5(A,B); + else if (n == 7) s = mtrace_7(A,B); else { s = 0.0; - for(int i = 1; i<=n; i++) - for(int j = 1; j<=n; j++) + for (int i = 1; i<=n; i++) + for (int j = 1; j<=n; j++) s = s + A[i][j]*B[i][j]; } t1 = gettime(); @@ -192,7 +192,7 @@ static inline double mtrace(int n,double A[8][8],double B[8][8]) { void PairMGPT::make_triplet(bond_data *ij_bond,bond_data *ik_bond, triplet_data *triptr) { - if(1) { + if (1) { const trmul_fun tr_mul = linalg.tr_mul; tr_mul(&(ij_bond->H.m[1][0]), &(ik_bond->H.m[1][0]) ,&(triptr->H1H2.m[1][0]) ); tr_mul(&(ij_bond->Hx.m[1][0]),&(ik_bond->H.m[1][0]) ,&(triptr->H1xH2.m[1][0])); @@ -227,28 +227,28 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i triplet_data *tptr = 0; t0 = gettime(); - if(recompute == 0) { + if (recompute == 0) { bij = bhash->Lookup(Doublet(i,j)); bik = bhash->Lookup(Doublet(i,k)); } - if(bij == 0) { - if(recompute == 0) + if (bij == 0) { + if (recompute == 0) bij = bhash->Insert(Doublet(i,j)); else bij = &bij_work; - if(i < j) + if (i < j) make_bond(xx,i,j,bij); else make_bond(xx,j,i,bij); } - if(bik == 0) { - if(recompute == 0) + if (bik == 0) { + if (recompute == 0) bik = bhash->Insert(Doublet(i,k)); else bik = &bik_work; - if(i < k) + if (i < k) make_bond(xx,i,k,bik); else make_bond(xx,k,i,bik); @@ -257,7 +257,7 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i t_make_b += t1-t0; t0 = gettime(); - if(bij != 0 && bij != 0) { + if (bij != 0 && bij != 0) { tptr = twork; make_triplet(bij,bik,tptr); *dvir_ij_p = bij->fl_deriv_sum; @@ -290,7 +290,7 @@ double PairMGPT::numderiv3t(double xx[][3],int i,int j,int k,int p) { xx[i][p] = xsave - delta; make_bond(xx,i,j,&Bij); - if(0) { /* This bond doesn't change when i is perturbed */ + if (0) { /* This bond doesn't change when i is perturbed */ make_bond(xx,j,k,&Bjk); } make_bond(xx,k,i,&Bki); @@ -342,7 +342,7 @@ double PairMGPT::numderiv4(double xx[][3],int i,int j,int k,int m,int p) { xx[i][p] = xsave - delta; make_bond(xx,i,j,&Bij); - if(0) { /* Only the i coordinates changed... */ + if (0) { /* Only the i coordinates changed... */ make_bond(xx,j,k,&Bjk); make_bond(xx,k,m,&Bkm); } @@ -365,14 +365,14 @@ void PairMGPT::force_debug_3t(double xx[][3], dfj[0] = dfjx; dfj[1] = dfjy; dfj[2] = dfjz; dfk[0] = dfkx; dfk[1] = dfky; dfk[2] = dfkz; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { /* Compute numerical derivatives by displacing atoms i,j,k */ double ndfi,ndfj,ndfk; ndfi = -numderiv3t(xx,i,j,k,p); ndfj = -numderiv3t(xx,j,k,i,p); ndfk = -numderiv3t(xx,k,i,j,p); - if((fabs(dfi[p] - ndfi) > dtol && + if ((fabs(dfi[p] - ndfi) > dtol && fabs(dfi[p] - ndfi) > dtol*fabs(ndfi)) || (fabs(dfj[p] - ndfj) > dtol && fabs(dfj[p] - ndfj) > dtol*fabs(ndfj)) || @@ -398,14 +398,14 @@ void PairMGPT::force_debug_3v(double xx[][3], dfj[0] = dfjx; dfj[1] = dfjy; dfj[2] = dfjz; dfk[0] = dfkx; dfk[1] = dfky; dfk[2] = dfkz; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { /* Compute numerical derivatives by displacing atoms i,j,k */ double ndfi,ndfj,ndfk; ndfi = -numderiv3v(xx,i,j,k,p,i0); ndfj = -numderiv3v(xx,i,j,k,p,j0); ndfk = -numderiv3v(xx,i,j,k,p,k0); - if((fabs(dfi[p] - ndfi) > dtol && + if ((fabs(dfi[p] - ndfi) > dtol && fabs(dfi[p] - ndfi) > dtol*fabs(ndfi)) || (fabs(dfj[p] - ndfj) > dtol && fabs(dfj[p] - ndfj) > dtol*fabs(ndfj)) || @@ -436,14 +436,14 @@ void PairMGPT::force_debug_4(double xx[][3], const int ii0[] = {i0,j0,k0,m0},ii[] = {i,j,k,m,i,j,k}; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { /* Compute numerical derivatives by displacing atoms i,j,k,m */ double ndfi,ndfj,ndfk,ndfm; - if(1) { + if (1) { double ndf[] = {0.0,0.0,0.0,0.0}; - for(int s = 0; s<4; s++) - for(int t = 0; t<4; t++) - if(ii[s] == ii0[t]) + for (int s = 0; s<4; s++) + for (int t = 0; t<4; t++) + if (ii[s] == ii0[t]) ndf[t] = -numderiv4(xx,ii[s],ii[s+1],ii[s+2],ii[s+3],p); ndfi = ndf[0]; ndfj = ndf[1]; ndfk = ndf[2]; ndfm = ndf[3]; @@ -454,7 +454,7 @@ void PairMGPT::force_debug_4(double xx[][3], ndfm = -numderiv4(xx,m,i,j,k,p); } - if((fabs(dfi[p] - ndfi) > dtol && + if ((fabs(dfi[p] - ndfi) > dtol && fabs(dfi[p] - ndfi) > dtol*fabs(ndfi)) || (fabs(dfj[p] - ndfj) > dtol && fabs(dfj[p] - ndfj) > dtol*fabs(ndfj)) || @@ -501,7 +501,7 @@ void PairMGPT::force_debug_4(double xx[][3], &(T45->H1H2x.m[1][0]),&utr4x.d, \ &(T45->H1H2y.m[1][0]),&utr4y.d, \ &(T45->H1H2z.m[1][0]),&utr4z.d); \ - if(linalg.single) { \ + if (linalg.single) { \ trd1x = utr1x.f; trd2x = utr2x.f; trd3x = utr3x.f; trd4x = utr4x.f; \ trd1y = utr1y.f; trd2y = utr2y.f; trd3y = utr3y.f; trd4y = utr4y.f; \ trd1z = utr1z.f; trd2z = utr2z.f; trd3z = utr3z.f; trd4z = utr4z.f; \ @@ -679,7 +679,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, { double vtot = 1.0; double ntot = atom->natoms; - for(i = 0; i<3; i++) + for (i = 0; i<3; i++) vtot = vtot * (domain->boxhi[i] - domain->boxlo[i]); rhoinv = vtot / ntot; } @@ -705,47 +705,47 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, const int triclinic = domain->triclinic; double alpha[3] = {0.0,0.0,0.0}; - if(triclinic) { + if (triclinic) { double E[3][3],EX[3][3]; int cyc[] = {0,1,2,0,1}; ss = (double (*)[3]) memory->smalloc(sizeof(double [3]) * ntot, "mgpt: local reduced coordinate vector."); - for(i = 0; i<3; i++) { - for(j = 0; j<3; j++) + for (i = 0; i<3; i++) { + for (j = 0; j<3; j++) E[i][j] = 0.0; E[i][i] = domain->subhi_lamda[i] - domain->sublo_lamda[i]; domain->lamda2x(E[i],EX[i]); } - for(i = 0; i<3; i++) { + for (i = 0; i<3; i++) { int i1 = cyc[i+1],i2 = cyc[i+2]; double dot = 0.0,ns2 = 0.0; - for(j = 0; j<3; j++) { + for (j = 0; j<3; j++) { int j1 = cyc[j+1],j2 = cyc[j+2]; double cj = EX[i1][j1]*EX[i2][j2] - EX[i1][j2]*EX[i2][j1]; ns2 = ns2 + cj*cj; dot = dot + EX[i][j]*cj; } alpha[i] = E[i][i] / (dot/sqrt(ns2)); - if(comm->me == 0) { + if (comm->me == 0) { static int count = 0; - if(count < 3) + if (count < 3) printf("@@@ alpha(%d) = %15.5e\n",i+1,alpha[i]); count++; } - if(alpha[i] < 0.0) alpha[i] = -alpha[i]; + if (alpha[i] < 0.0) alpha[i] = -alpha[i]; } } else ss = xx; nneitot = 0; - for(ix = 0; ixx[ix][p]; ff[ix][p] = 0.0; } - if(triclinic) + if (triclinic) domain->x2lamda(xx[ix],ss[ix]); nneitot = nneitot + nnei[ix]; } @@ -766,22 +766,22 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, int c_p = 0, c_t = 0, c_q = 0; - if(0) - if(domain->triclinic) { - if(comm->me == 0) + if (0) + if (domain->triclinic) { + if (comm->me == 0) printf("Can not handle triclinic box yet\n"); error->all(__FILE__,__LINE__,"Can not handle triclinic cell with mgpt yet."); } /* - for(i = 0; i 0.0) { + if (w2 > 0.0) { /* Compute pair energy/force */ @@ -814,20 +814,20 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, df = df / rij * w2; - if(pair_energies == 0) de_pair = 0.0; + if (pair_energies == 0) de_pair = 0.0; e_pair = e_pair + de_pair; c_p++; - if(pair_forces == 0) df = 0.0; + if (pair_forces == 0) df = 0.0; - if(volpres_flag && pair_energies) { + if (volpres_flag && pair_energies) { double dvir; splinepot.eval_vir(rij,&dvir); volvir2 = volvir2 - dvir * w2; /* Per-atom virial contribution of volumetric energy term */ - if(vflag_atom) - for(int pp = 0; pp<3; pp++) { + if (vflag_atom) + for (int pp = 0; pp<3; pp++) { //virial[i] = virial[i] + rhoinv*e_scale*volvir2; vatom[i][pp] -= 0.5 * rhoinv*e_scale*dvir*w2; vatom[j][pp] -= 0.5 * rhoinv*e_scale*dvir*w2; @@ -847,7 +847,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, fiz = fiz + df*drijz; fjz = fjz - df*drijz; - if(evflag) { + if (evflag) { //ev_tally(i,j,nloc,newton_pair,de_pair,0.0,df,-drijx,-drijy,-drijz); /* To fix stress-per-atom scaling, and sign */ ev_tally(i,j,nloc,newton_pair,de_pair,0.0,-df * e_scale,-drijx,-drijy,-drijz); @@ -861,7 +861,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } } - if(rij2 < rcut2_bond && c2_outside(ss[i],ss[j],triclinic,alpha) == 0) { + if (rij2 < rcut2_bond && c2_outside(ss[i],ss[j],triclinic,alpha) == 0) { /* Add j to short neighbor list for i. Insert j to keep list sorted. @@ -874,7 +874,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } nlist_short[p+1] = j; first[i+1] = first[i+1] + 1; - if(first[i+1] > nneitot) { + if (first[i+1] > nneitot) { printf("nneitot = %d, short list full. i=%d\n", nneitot,i); error->one(__FILE__,__LINE__,"Shit! Short list full\n"); @@ -892,7 +892,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ntpair += nnei[i]; } - for(i = 0; i i) continue; /* Require k i) continue; /* Require k 0.0) { + if (w3 > 0.0) { triplet_defer = 0; dvir_ij = dvir_jk = dvir_ki = 0.0; - if(c_ij && c_jk) + if (c_ij && c_jk) T12 = get_triplet(xx,j,i,k,&bond_hash,&T12work,&dvir_ij,&dvir_jk); - if(c_ki && c_jk) + if (c_ki && c_jk) T23 = get_triplet(xx,k,i,j,&bond_hash,&T23work,&dvir_ki,&dvir_jk); - if(c_ij && c_ki) + if (c_ij && c_ki) T31 = get_triplet(xx,i,j,k,&bond_hash,&T31work,&dvir_ij,&dvir_ki); - if(evflag) { + if (evflag) { fsave[0][0] = fix; fsave[0][1] = fiy; fsave[0][2] = fiz; fsave[1][0] = fjx; fsave[1][1] = fjy; fsave[1][2] = fjz; fsave[2][0] = fkx; fsave[2][1] = fky; fsave[2][2] = fkz; @@ -981,10 +981,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, double xvir3t,xvir3v; xvir3t = xvir3v = 0.0; - if(T12 && T23) { + if (T12 && T23) { bond_data *bki = bond_hash.Lookup(Doublet(k,i)); - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr0 = transtrace(T12->H1H2,bki->H); double dvir = ((dvir_ij + dvir_jk + bki->fl_deriv_sum)*splinepot.vc + splinepot.dvc)*tr0*w3/anorm3; @@ -1010,7 +1010,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(bki->Hy.m[1][0]),&utr3y.d, &(bki->Hz.m[1][0]),&utr3z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd3x = utr3x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd3y = utr3y.f; trd1z = utr1z.f; trd2z = utr2z.f; trd3z = utr3z.f; @@ -1033,20 +1033,20 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfkz = ( ( sjk)*trd2z + (-ski)*trd3z ) * (vc / anorm3); } - if(triplet_debug) + if (triplet_debug) force_debug_3t(xx,i,j,k, i,j,k, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } - if(T12 != 0) { + if (T12 != 0) { //printf("T12 i,j,k = %d,%d,%d\n",i,j,k); mcount++; - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr1 = transtrace(T12->H1H2,T12->H1H2); double dvir = (2.0*(dvir_ij + dvir_jk)*splinepot.vd + splinepot.dvd)*tr1*w3/anorm4; @@ -1065,7 +1065,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(T12->H1H2x.m[1][0]),&utr2x.d, &(T12->H1H2y.m[1][0]),&utr2y.d, &(T12->H1H2z.m[1][0]),&utr2z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd1z = utr1z.f; trd2z = utr2z.f; @@ -1088,21 +1088,21 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfjz = -(dfiz + dfkz); } - if(triplet_debug) /* Compare forces to numerical derivatives */ + if (triplet_debug) /* Compare forces to numerical derivatives */ force_debug_3v(xx,i,j,k, j,i,k, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } - if(T23 != 0) { + if (T23 != 0) { //printf("T23 i,j,k = %d,%d,%d\n",i,j,k); mcount++; - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr2 = transtrace(T23->H1H2,T23->H1H2); double dvir = (2.0*(dvir_jk + dvir_ki)*splinepot.vd + splinepot.dvd)*tr2*w3/anorm4; @@ -1121,7 +1121,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(T23->H1H2x.m[1][0]),&utr2x.d, &(T23->H1H2y.m[1][0]),&utr2y.d, &(T23->H1H2z.m[1][0]),&utr2z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd1z = utr1z.f; trd2z = utr2z.f; @@ -1144,21 +1144,21 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfkz = -(dfiz + dfjz); } - if(triplet_debug) /* Compare forces to numerical derivatives */ + if (triplet_debug) /* Compare forces to numerical derivatives */ force_debug_3v(xx,i,j,k, k,i,j, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } - if(T31 != 0) { + if (T31 != 0) { //printf("T31 i,j,k = %d,%d,%d\n",i,j,k); mcount++; - if(three_body_energies && evflag) { + if (three_body_energies && evflag) { tr3 = transtrace(T31->H1H2,T31->H1H2); double dvir = (2.0*(dvir_ki + dvir_ij)*splinepot.vd + splinepot.dvd)*tr3*w3/anorm4; @@ -1177,7 +1177,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, &(T31->H1H2x.m[1][0]),&utr2x.d, &(T31->H1H2y.m[1][0]),&utr2y.d, &(T31->H1H2z.m[1][0]),&utr2z.d); - if(linalg.single) { + if (linalg.single) { trd1x = utr1x.f; trd2x = utr2x.f; trd1y = utr1y.f; trd2y = utr2y.f; trd1z = utr1z.f; trd2z = utr2z.f; @@ -1201,13 +1201,13 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } - if(triplet_debug) /* Compare forces to numerical derivatives */ + if (triplet_debug) /* Compare forces to numerical derivatives */ force_debug_3v(xx,i,j,k, i,j,k, dfix,dfiy,dfiz, dfjx,dfjy,dfjz, dfkx,dfky,dfkz); - if(three_body_forces) + if (three_body_forces) accumulate_forces_3(w3); } @@ -1220,10 +1220,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, //printf("xxxx %6d %6d %6d :: %20.10e\n",1,2,3,de_triplet); - if(evflag) { + if (evflag) { double drji[3],drki[3]; double fj[3] = {fjx,fjy,fjz},fk[3] = {fkx,fky,fkz}; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { drji[p] = xx[j][p] - xx[i][p]; drki[p] = xx[k][p] - xx[i][p]; /* To fix stress-per-atom scaling. */ @@ -1233,10 +1233,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ev_tally3(i,j,k,de_triplet,0.0,fj,fk,drji,drki); - if(volpres_flag && vflag_atom) { + if (volpres_flag && vflag_atom) { //virial[i] = virial[i] - (vir3v + vir3t) * rhoinv*e_scale; double dvir = -(xvir3v + xvir3t) * rhoinv*e_scale * (1.0/3.0); - for(int pp = 0; pp<3; pp++) { + for (int pp = 0; pp<3; pp++) { vatom[i][pp] += dvir; vatom[j][pp] += dvir; vatom[k][pp] += dvir; @@ -1255,8 +1255,8 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, triplet_defer = 1; } - if(four_body_energies || four_body_forces) - if(j < i) { /* Search for quadruplet */ + if (four_body_energies || four_body_forces) + if (j < i) { /* Search for quadruplet */ tx0 = gettime(); mj = first[j]; @@ -1267,7 +1267,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, */ while(nlist_short[mj] < i && nlist_short[mk] < i) { - if(mj >= first[j+1] || mk >= first[k+1]) { + if (mj >= first[j+1] || mk >= first[k+1]) { printf("Illegal quad...\n" " j=%d first[j]=%d first[j+1]=%d mj=%d\n" " k=%d first[k]=%d first[k+1]=%d mk=%d\n", @@ -1276,7 +1276,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, error->one(__FILE__,__LINE__,"Shit, brkoen quad loop"); } - if(nlist_short[mj] == nlist_short[mk]) { + if (nlist_short[mj] == nlist_short[mk]) { /* Closed quadruplet */ m = nlist_short[mj]; c_jm = c_km = 1; @@ -1287,25 +1287,25 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, w4 = get_weight(triclinic,ss[i],ss[j],ss[k],ss[m]); - if(w4 > 0.0) { + if (w4 > 0.0) { /* Alrady know ij,jk,ki,jm,km bonds. Look for im bond. */ mi = first[i]; while(mi < first[i+1] && nlist_short[mi] < m) mi = mi + 1; - if(mi < first[i+1] && nlist_short[mi] == m) + if (mi < first[i+1] && nlist_short[mi] == m) c_im = 1; else c_im = 0; - if(c_im == 0 || c_jk == 0 || (c_jk && c_im && m < k)) { + if (c_im == 0 || c_jk == 0 || (c_jk && c_im && m < k)) { - if(triplet_defer) { + if (triplet_defer) { dvir_ij = dvir_jk = dvir_ki = 0.0; - if(c_ij && c_jk) + if (c_ij && c_jk) T12 = get_triplet(xx,j,i,k,&bond_hash,&T12work,&dvir_ij,&dvir_jk); - if(c_ki && c_jk) + if (c_ki && c_jk) T23 = get_triplet(xx,k,i,j,&bond_hash,&T23work,&dvir_ki,&dvir_jk); - if(c_ij && c_ki) + if (c_ij && c_ki) T31 = get_triplet(xx,i,j,k,&bond_hash,&T31work,&dvir_ij,&dvir_ki); triplet_defer = 0; } @@ -1314,7 +1314,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, fmx = fmy = fmz = 0.0; double xvir4 = 0.0; - if(evflag) { + if (evflag) { fsave[0][0] = fix; fsave[0][1] = fiy; fsave[0][2] = fiz; fsave[1][0] = fjx; fsave[1][1] = fjy; fsave[1][2] = fjz; fsave[2][0] = fkx; fsave[2][1] = fky; fsave[2][2] = fkz; @@ -1329,15 +1329,15 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dvir_im = dvir_jm = dvir_km = 0.0; T45 = T56 = T64 = 0; - if(T12 != 0 && c_km && c_im) + if (T12 != 0 && c_km && c_im) T45 = get_triplet(xx,m,i,k,&bond_hash,&T45work,&dvir_im,&dvir_km); - if(T23 != 0 && c_im && c_jm) + if (T23 != 0 && c_im && c_jm) T56 = get_triplet(xx,m,i,j,&bond_hash,&T56work,&dvir_im,&dvir_jm); - if(T31 != 0 && c_jm && c_km) + if (T31 != 0 && c_jm && c_km) T64 = get_triplet(xx,m,j,k,&bond_hash,&T64work,&dvir_jm,&dvir_km); - if(T12 != 0 && T45 != 0) { - if(four_body_energies && evflag) { + if (T12 != 0 && T45 != 0) { + if (four_body_energies && evflag) { tr1 = transtrace(T12->H1H2,T45->H1H2); double dvir = ( (dvir_ij + dvir_jk + dvir_im + dvir_km)*splinepot.ve + splinepot.dve )*tr1*w4/anorm4; @@ -1356,17 +1356,17 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfix_update_4a(z); } - if(quad_debug) /* Compare forces to numerical derivatives */ + if (quad_debug) /* Compare forces to numerical derivatives */ force_debug_4(xx,i,j,k,m, i,j,k,m, dfix,dfiy,dfiz , dfjx,dfjy,dfjz, dfkx,dfky,dfkz , dfmx,dfmy,dfmz); - if(four_body_forces) + if (four_body_forces) accumulate_forces_4(w4); } - if(T23 != 0 && T56 != 0) { - if(four_body_energies && evflag) { + if (T23 != 0 && T56 != 0) { + if (four_body_energies && evflag) { tr2 = transtrace(T23->H1H2,T56->H1H2); double dvir = ( (dvir_ki + dvir_jk + dvir_im + dvir_jm)*splinepot.ve + splinepot.dve )*tr2*w4/anorm4; @@ -1385,18 +1385,18 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfix_update_4b(z); } - if(quad_debug) /* Compare forces to numerical derivatives */ + if (quad_debug) /* Compare forces to numerical derivatives */ force_debug_4(xx,i,j,k,m, i,m,j,k, dfix,dfiy,dfiz , dfjx,dfjy,dfjz, dfkx,dfky,dfkz , dfmx,dfmy,dfmz); - if(four_body_forces) + if (four_body_forces) accumulate_forces_4(w4); } - if(T31 != 0 && T64 != 0) { - if(four_body_energies && evflag) { + if (T31 != 0 && T64 != 0) { + if (four_body_energies && evflag) { tr3 = transtrace(T31->H1H2,T64->H1H2); double dvir = ( (dvir_ki + dvir_ij + dvir_jm + dvir_km)*splinepot.ve + splinepot.dve )*tr3*w4/anorm4; @@ -1416,29 +1416,29 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, dfix_update_4c(z); } - if(quad_debug) /* Compare forces to numerical derivatives */ + if (quad_debug) /* Compare forces to numerical derivatives */ force_debug_4(xx,i,j,k,m, i,j,m,k, dfix,dfiy,dfiz , dfjx,dfjy,dfjz, dfkx,dfky,dfkz , dfmx,dfmy,dfmz); - if(four_body_forces) + if (four_body_forces) accumulate_forces_4(w4); } double de_quad = splinepot.ve*(tr1 + tr2 + tr3)/anorm4 * e_scale * w4; e_quad = e_quad + de_quad; - if((T12 && T45) || + if ((T12 && T45) || (T23 && T56) || (T31 && T64)) { c_q++; } - if(evflag) { + if (evflag) { double drim[3],drjm[3],drkm[3]; double fi[3] = {fix,fiy,fiz}; double fj[3] = {fjx,fjy,fjz}; double fk[3] = {fkx,fky,fkz}; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { drim[p] = xx[i][p] - xx[m][p]; drjm[p] = xx[j][p] - xx[m][p]; drkm[p] = xx[k][p] - xx[m][p]; @@ -1449,10 +1449,10 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ev_tally4(i,j,k,m,de_quad,fi,fj,fk,drim,drjm,drkm); - if(volpres_flag && vflag_atom) { + if (volpres_flag && vflag_atom) { //virial[i] = virial[i] - vir4 * rhoinv*e_scale; double dvir = -xvir4 * rhoinv*e_scale * (1.0/4.0); - for(int pp = 0; pp<3; pp++) { + for (int pp = 0; pp<3; pp++) { vatom[i][pp] += dvir; vatom[j][pp] += dvir; vatom[k][pp] += dvir; @@ -1474,7 +1474,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } mj = mj + 1; mk = mk + 1; - } else if(nlist_short[mj] < nlist_short[mk]) { + } else if (nlist_short[mj] < nlist_short[mk]) { mj = mj + 1; } else { mk = mk + 1; @@ -1505,15 +1505,15 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, ff[i][1] += fiy * e_scale; ff[i][2] += fiz * e_scale; - if(single_energies == 1 && i < nloc) { + if (single_energies == 1 && i < nloc) { const double evol0 = splinepot.evol0; - if(eflag_global) { + if (eflag_global) { e_single = e_single + evol0 * e_scale; eng_vdwl = eng_vdwl + evol0 * e_scale; } - if(eflag_atom) eatom[i] = eatom[i] + evol0 * e_scale; - if(volpres_flag && vflag_atom) { - for(int pp = 0; pp<3; pp++) + if (eflag_atom) eatom[i] = eatom[i] + evol0 * e_scale; + if (volpres_flag && vflag_atom) { + for (int pp = 0; pp<3; pp++) vatom[i][pp] = vatom[i][pp] - rhoinv*splinepot.devol0*e_scale; } @@ -1522,13 +1522,13 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } tx0 = gettime(); - for(i = 0; if[i][p] = atom->f[i][p] + ff[i][p]; memory->sfree(nlist_short); memory->sfree(first); - if(ss != xx) memory->sfree(ss); + if (ss != xx) memory->sfree(ss); memory->sfree(ff); memory->sfree(xx); tx1 = gettime(); @@ -1541,7 +1541,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, #ifdef TIMING_ON - if(comm->me == 0) { + if (comm->me == 0) { double tsum = (tmem+tsort+tpair+tlookup+ttriplet+tquad); double nsum = (ntmem+ntsort+ntpair+ntlookup+nttriplet+ntquad); //double adj = ((t1-t0)-tsum)/nsum; @@ -1624,7 +1624,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } #endif - if(volpres_flag) { + if (volpres_flag) { /* Include contributions to the pressure due to derivatines of the energy with respect to the potential input volume. @@ -1635,29 +1635,29 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, /* double vtot = 1.0; double ntot = atom->natoms; - for(i = 0; i<3; i++) + for (i = 0; i<3; i++) vtot = vtot * (domain->boxhi[i] - domain->boxlo[i]); double rhoinv = vtot / ntot; */ - if(single_energies) // Virial correction for self energy - for(i = 0; i<3; i++) { + if (single_energies) // Virial correction for self energy + for (i = 0; i<3; i++) { //virial[i] = virial[i] + nloc*pot_input_vol*pvol0*e_scale; virial[i] = virial[i] - nloc*rhoinv*splinepot.devol0*e_scale; } - if(pair_energies) // Virial correction for pair energy - for(i = 0; i<3; i++) + if (pair_energies) // Virial correction for pair energy + for (i = 0; i<3; i++) virial[i] = virial[i] + rhoinv*e_scale*volvir2; - if(three_body_energies) // Virial correction for three body enegries - for(i = 0; i<3; i++) { + if (three_body_energies) // Virial correction for three body enegries + for (i = 0; i<3; i++) { //virial[i] = virial[i] - pot_input_vol*(e_triplet_c*pc + (e_triplet-e_triplet_c)*pd); virial[i] = virial[i] - (vir3v + vir3t) * rhoinv*e_scale; } - if(four_body_energies) // Virial correction for four body enegries - for(i = 0; i<3; i++) { + if (four_body_energies) // Virial correction for four body enegries + for (i = 0; i<3; i++) { //virial[i] = virial[i] - pot_input_vol*e_quad*pe; virial[i] = virial[i] - vir4 * rhoinv*e_scale; } @@ -1679,66 +1679,66 @@ void PairMGPT::compute(int eflag, int vflag) //printf("newton_pair = %d, newton = %d, tag_enable = %d\n",force->newton_pair,force->newton,atom->tag_enable); - if(newton_pair == 0) { + if (newton_pair == 0) { printf("This is a problem. MGPT requires newton_pair flag to be on. Exiting...\n"); exit(1); } - if(atom->tag_enable == 0) { + if (atom->tag_enable == 0) { printf("This is a problem. MGPT requires tag_enable flag to be on. Exiting...\n"); exit(1); } compute_x(listfull->numneigh,listfull->firstneigh,&e_s,&e_p,&e_t,&e_q,evflag,newton_pair); - if(0) { // Stupid force calculation / verification + if (0) { // Stupid force calculation / verification int ii,nmax=-1; - for(ii = 0; iiinum + listfull->gnum; ii++) { + for (ii = 0; iiinum + listfull->gnum; ii++) { int i = listfull->ilist[ii]; - if(i > nmax) nmax = i; + if (i > nmax) nmax = i; } nmax++; double *ffwork = new double[3*nmax]; double *ffloc = new double[3*listfull->inum]; double *ffloc2 = new double[3*listfull->inum]; double **ffptr = new double *[nmax]; - for(ii = 0; iiinum + listfull->gnum; ii++) + for (ii = 0; iiinum + listfull->gnum; ii++) ffptr[ii] = &ffwork[3*ii]; printf("Computing boundary forces\n"); - for(ii = 0; iiinum; ii++) { + for (ii = 0; iiinum; ii++) { ffloc2[3*ii] = 0.0; ffloc2[3*ii+1] = 0.0; ffloc2[3*ii+2] = 0.0; int i = listfull->ilist[ii]; - for(int jj = 0; jjinum+listfull->gnum; jj++) { + for (int jj = 0; jjinum+listfull->gnum; jj++) { int j = listfull->ilist[jj]; - if(atom->tag[i] == atom->tag[j]) - for(int p = 0; p<3; p++) + if (atom->tag[i] == atom->tag[j]) + for (int p = 0; p<3; p++) ffloc2[3*ii+p] += atom->f[j][p]; } } printf("Starting main displacement force calculation\n"); - for(ii = 0; iiinum; ii++) { + for (ii = 0; iiinum; ii++) { int i = listfull->ilist[ii]; double **atom_f_save = atom->f; atom->f = ffptr; - for(int p = 0; p<3; p++) { + for (int p = 0; p<3; p++) { double xsave = atom->x[i][p]; const double delta = 1e-3; atom->x[i][p] = xsave + delta; - for(int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; + for (int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; compute_x(listfull->numneigh, listfull->firstneigh, &e_s,&e_p,&e_t,&e_q,evflag,newton_pair); double e1 = e_s + e_p + e_t + e_q; atom->x[i][p] = xsave - delta; - for(int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; + for (int jj = 0; jj<3*nmax; jj++) ffwork[jj] = 0.0; compute_x(listfull->numneigh, listfull->firstneigh, &e_s,&e_p,&e_t,&e_q,evflag,newton_pair); @@ -1769,10 +1769,10 @@ void PairMGPT::compute(int eflag, int vflag) } - if(0) { + if (0) { printf("\nForces MGPT:\n"); const int iimax = (listfull->inum < 10) ? listfull->inum : 10; - for(int ii = 0; iiilist[ii]; printf("%4d = %20.10e %20.10e %20.10e\n", i,atom->f[i][0],atom->f[i][1],atom->f[i][2]); @@ -1780,7 +1780,7 @@ void PairMGPT::compute(int eflag, int vflag) printf("\n\n"); } - if(vflag_fdotr) { + if (vflag_fdotr) { //printf("##### Using virial_compute!!!\n"); virial_fdotr_compute(); } @@ -1792,8 +1792,8 @@ void PairMGPT::allocate() int n = atom->ntypes; memory->create(setflag,n+1,n+1,"pair:setflag"); - for(int i = 0; i <= n; i++) - for(int j = 0; j <= n; j++) + for (int i = 0; i <= n; i++) + for (int j = 0; j <= n; j++) setflag[i][j] = 0; memory->create(cutsq,n+1,n+1,"pair:cutsq"); @@ -1805,7 +1805,7 @@ void PairMGPT::allocate() ------------------------------------------------------------------------- */ void PairMGPT::settings(int narg, char **/*arg*/) { - if(narg != 0) error->all(__FILE__,__LINE__,"Illegal pair_style command"); + if (narg != 0) error->all(__FILE__,__LINE__,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -1816,18 +1816,18 @@ void PairMGPT::coeff(int narg, char **arg) { int single_precision = 0; - if(narg < 5) + if (narg < 5) error->all(__FILE__,__LINE__, "Not enough arguments for mgpt (MGPT) pair coefficients."); - if(!allocated) allocate(); + if (!allocated) allocate(); // Make sure I,J args are * * - if(strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) + if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) error->all(__FILE__,__LINE__,"Incorrect args for pair coefficients"); double vol; - if(sscanf(arg[4], "%lg", &vol) != 1 || vol <= 0.0) + if (sscanf(arg[4], "%lg", &vol) != 1 || vol <= 0.0) error->all(__FILE__,__LINE__,"Invalid volume in mgpt (MGPT) pair coefficients."); volpres_flag = 1; @@ -1838,11 +1838,11 @@ void PairMGPT::coeff(int narg, char **arg) int iarg = 5; while (iarg < narg) { - if(strcmp(arg[iarg],"volpress") == 0) { /* Volumetric pressure flag */ + if (strcmp(arg[iarg],"volpress") == 0) { /* Volumetric pressure flag */ if (iarg+2 > narg) error->all(FLERR,"Incorrect args for pair coefficients"); - if(strcmp(arg[iarg+1],"yes") == 0) volpres_flag = 1; - else if(strcmp(arg[iarg+1],"no") == 0) volpres_flag = 0; + if (strcmp(arg[iarg+1],"yes") == 0) volpres_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) volpres_flag = 0; else { char line[1024]; sprintf(line,"(In %s:%d) Invalid value for volumetric pressure argument.\n" @@ -1852,16 +1852,16 @@ void PairMGPT::coeff(int narg, char **arg) } volpres_tag = 1; iarg += 2; - if(comm->me == 0) printf("* volpress: volpres_flag = %d [%s %s]\n",volpres_flag,arg[iarg-2],arg[iarg-1]); - } else if(strcmp(arg[iarg],"nbody") == 0) { + if (comm->me == 0) printf("* volpress: volpres_flag = %d [%s %s]\n",volpres_flag,arg[iarg-2],arg[iarg-1]); + } else if (strcmp(arg[iarg],"nbody") == 0) { if (iarg+2 > narg) error->all(FLERR,"Incorrect args for pair coefficients"); - if(strspn(arg[iarg+1],"1234") == strlen(arg[iarg+1])) { + if (strspn(arg[iarg+1],"1234") == strlen(arg[iarg+1])) { nbody_flag = 0; - for(int i = 0; i<4; i++) - if(strchr(arg[iarg+1],'1'+i) != nullptr) { + for (int i = 0; i<4; i++) + if (strchr(arg[iarg+1],'1'+i) != nullptr) { nbody_flag = nbody_flag + (1<me == 0) printf("Explicitly adding %d-tuple forces.\n",i+1); + if (comm->me == 0) printf("Explicitly adding %d-tuple forces.\n",i+1); } } else { char line[1024]; @@ -1874,11 +1874,11 @@ void PairMGPT::coeff(int narg, char **arg) } nbody_tag = 1; iarg += 2; - } else if(strcmp(arg[iarg],"precision") == 0) { + } else if (strcmp(arg[iarg],"precision") == 0) { if (iarg+2 > narg) error->all(FLERR,"Incorrect args for pair coefficients"); - if(strcmp(arg[iarg+1],"single") == 0) single_precision = 1; - else if(strcmp(arg[iarg+1],"double") == 0) single_precision = 0; + if (strcmp(arg[iarg+1],"single") == 0) single_precision = 1; + else if (strcmp(arg[iarg+1],"double") == 0) single_precision = 0; else { char line[1024]; sprintf(line,"(In %s:%d) Invalid value for precision argument.\n" @@ -1888,7 +1888,7 @@ void PairMGPT::coeff(int narg, char **arg) } precision_tag = 1; iarg += 2; - if(comm->me == 0) printf("* precision: single_flag = %d [%s %s]\n",single_precision,arg[iarg-2],arg[iarg-1]); + if (comm->me == 0) printf("* precision: single_flag = %d [%s %s]\n",single_precision,arg[iarg-2],arg[iarg-1]); } else { char line[1024]; sprintf(line,"(In %s:%d) Invalid argument. Allowed arguments are:\n" @@ -1900,10 +1900,10 @@ void PairMGPT::coeff(int narg, char **arg) } } - if(comm->me == 0) + if (comm->me == 0) printf("Volumetric pressure is %s.\n",volpres_flag ? "on" : "off"); - if(comm->me == 0) { + if (comm->me == 0) { FILE *parmin_fp = utils::open_potential(arg[2],lmp,nullptr); FILE *potin_fp = utils::open_potential(arg[3],lmp,nullptr); if (parmin_fp == nullptr || potin_fp == nullptr) { @@ -1920,14 +1920,14 @@ void PairMGPT::coeff(int narg, char **arg) /* Set up default and requested nbody forces to include */ { int nbody_default = (1<<0) + (1<<1) + (1<<2) + (1<<3); - if(splinepot.vd == 0.0 && splinepot.dvd == 0.0) + if (splinepot.vd == 0.0 && splinepot.dvd == 0.0) nbody_default -= (1<<2); // No 3-body contributions - if(splinepot.ve == 0.0 && splinepot.dve == 0.0) + if (splinepot.ve == 0.0 && splinepot.dve == 0.0) nbody_default -= (1<<3); // No 4-body contributions - if(nbody_tag == 0) nbody_flag = nbody_default; + if (nbody_tag == 0) nbody_flag = nbody_default; - if(nbody_flag != nbody_default) { + if (nbody_flag != nbody_default) { printf("Warning: nbody=%d (suggested=%d) set to disregard multibody-forces in potential.\n", nbody_flag,nbody_default); } @@ -1943,7 +1943,7 @@ void PairMGPT::coeff(int narg, char **arg) memory, and then broadcast contents of arrays. */ MPI_Bcast(&splinepot,sizeof(splinepot),MPI_BYTE,0,world); - if(comm->me != 0) { + if (comm->me != 0) { splinepot.vpair_spline = new double[splinepot.nr-1][4]; splinepot.dvpair_spline = new double[splinepot.nr-1][4]; } @@ -1954,10 +1954,10 @@ void PairMGPT::coeff(int narg, char **arg) lmax = splinepot.lmax; lang = splinepot.lang; //ipot = splinepot.ipot; - for(int i = 0; i<(int) (sizeof(ddl)/sizeof(double)); i++) + for (int i = 0; i<(int) (sizeof(ddl)/sizeof(double)); i++) ddl[i] = splinepot.ddl[i]; - for(int i = 0; i rmax) cutoff = rcrit; + if (rcrit > rmax) cutoff = rcrit; // Set LAMMPS pair interaction flags. - for(int i = 1; i <= atom->ntypes; i++) { - for(int j = 1; j <= atom->ntypes; j++) { + for (int i = 1; i <= atom->ntypes; i++) { + for (int j = 1; j <= atom->ntypes; j++) { setflag[i][j] = 1; cutsq[i][j] = cutoff; cutghost[i][j] = cutoff; @@ -1980,12 +1980,12 @@ void PairMGPT::coeff(int narg, char **arg) } // Set atomic mass. - for(int i = 1; i <= atom->ntypes; i++) + for (int i = 1; i <= atom->ntypes; i++) atom->set_mass(FLERR,i, splinepot.mass); // Initialize linear algebra routines. linalg = mgpt_linalg(lmax,single_precision); - if(comm->me == 0) + if (comm->me == 0) printf("%s",linalg.msg); } @@ -1995,7 +1995,7 @@ void PairMGPT::coeff(int narg, char **arg) ------------------------------------------------------------------------- */ void PairMGPT::init_style() { - if(force->newton_pair == 0) + if (force->newton_pair == 0) error->all(__FILE__,__LINE__,"Pair style mgpt requires newton pair on."); // Need full neighbor list. @@ -2016,8 +2016,8 @@ void PairMGPT::init_style() ------------------------------------------------------------------------- */ void PairMGPT::init_list(int id, NeighList *ptr) { - if(id == 1) listfull = ptr; - else if(id == 2) listhalf = ptr; + if (id == 1) listfull = ptr; + else if (id == 2) listhalf = ptr; } /* ---------------------------------------------------------------------- @@ -2056,13 +2056,13 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh */ double rpi = 1.0/rp; - if(mode <= 4) { + if (mode <= 4) { t = pow(rp*ri,p1); s = -p1 * t * ri; t_rp_ti = p1*rpi; t_p1_ti = log(rp*ri); } else { - if(pn == 1.0) { + if (pn == 1.0) { double p1_rpi = -p1*rpi; t = exp(p1 + r*p1_rpi); s = p1_rpi * t; @@ -2107,7 +2107,7 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh q_al = u*u; exp_q = exp(-q); - if(mode <= 2) { + if (mode <= 2) { fl_0 = exp_q * t; fl_x = exp_q*(tx - t*qx); fl_y = exp_q*(ty - t*qy); diff --git a/src/USER-MISC/angle_gaussian.cpp b/src/USER-MISC/angle_gaussian.cpp index 554b19cfb5..66da9e792e 100644 --- a/src/USER-MISC/angle_gaussian.cpp +++ b/src/USER-MISC/angle_gaussian.cpp @@ -244,7 +244,7 @@ void AngleGaussian::write_restart(FILE *fp) { fwrite(&angle_temperature[1],sizeof(double),atom->nangletypes,fp); fwrite(&nterms[1],sizeof(int),atom->nangletypes,fp); - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { fwrite(alpha[i],sizeof(double),nterms[i],fp); fwrite(width[i],sizeof(double),nterms[i],fp); fwrite(theta0[i],sizeof(double),nterms[i],fp); @@ -267,21 +267,21 @@ void AngleGaussian::read_restart(FILE *fp) MPI_Bcast(&nterms[1],atom->nangletypes,MPI_INT,0,world); // allocate - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { alpha[i] = new double [nterms[i]]; width[i] = new double [nterms[i]]; theta0[i] = new double [nterms[i]]; } if (comm->me == 0) { - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,theta0[i],sizeof(double),nterms[i],fp,nullptr,error); } } - for(int i = 1; i <= atom->nangletypes; i++) { + for (int i = 1; i <= atom->nangletypes; i++) { MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(theta0[i],nterms[i],MPI_DOUBLE,0,world); diff --git a/src/USER-MISC/bond_gaussian.cpp b/src/USER-MISC/bond_gaussian.cpp index b1e9d3d66b..42f76eda75 100644 --- a/src/USER-MISC/bond_gaussian.cpp +++ b/src/USER-MISC/bond_gaussian.cpp @@ -200,7 +200,7 @@ void BondGaussian::write_restart(FILE *fp) { fwrite(&bond_temperature[1],sizeof(double),atom->nbondtypes,fp); fwrite(&nterms[1],sizeof(int),atom->nbondtypes,fp); - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { fwrite(alpha[i],sizeof(double),nterms[i],fp); fwrite(width[i],sizeof(double),nterms[i],fp); fwrite(r0[i],sizeof(double),nterms[i],fp); @@ -223,21 +223,21 @@ void BondGaussian::read_restart(FILE *fp) MPI_Bcast(&nterms[1],atom->nbondtypes,MPI_INT,0,world); // allocate - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { alpha[i] = new double [nterms[i]]; width[i] = new double [nterms[i]]; r0[i] = new double [nterms[i]]; } if (comm->me == 0) { - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); utils::sfread(FLERR,r0[i],sizeof(double),nterms[i],fp,nullptr,error); } } - for(int i = 1; i <= atom->nbondtypes; i++) { + for (int i = 1; i <= atom->nbondtypes; i++) { MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); MPI_Bcast(r0[i],nterms[i],MPI_DOUBLE,0,world); diff --git a/src/USER-MISC/compute_basal_atom.cpp b/src/USER-MISC/compute_basal_atom.cpp index 01a623b4a9..a73f401120 100644 --- a/src/USER-MISC/compute_basal_atom.cpp +++ b/src/USER-MISC/compute_basal_atom.cpp @@ -289,7 +289,7 @@ void ComputeBasalAtom::compute_peratom() } var5 = var6 = var7 = 0.0; //find standard deviations - for (j=0;j 0){ + if (Mag > 0) { BPV[i][0] = BPV[i][0]/Mag; BPV[i][1] = BPV[i][1]/Mag; BPV[i][2] = BPV[i][2]/Mag; diff --git a/src/USER-MISC/compute_entropy_atom.cpp b/src/USER-MISC/compute_entropy_atom.cpp index cc1b81fc97..1362da447b 100644 --- a/src/USER-MISC/compute_entropy_atom.cpp +++ b/src/USER-MISC/compute_entropy_atom.cpp @@ -247,7 +247,7 @@ void ComputeEntropyAtom::compute_peratom() // loop over list of all neighbors within force cutoff // initialize gofr - for(int k=0;k (nbin-1)) minbin=nbin-1; maxbin=bin + deltabin; if (maxbin > (nbin-1)) maxbin=nbin-1; - for(int k=minbin;kprd[i]; } @@ -180,7 +180,7 @@ void ComputeStressMop::init() // Warnings - if (me==0){ + if (me==0) { //Compute stress/mop only accounts for pair interactions. // issue a warning if any intramolecular potential or Kspace is defined. @@ -327,7 +327,7 @@ void ComputeStressMop::compute_pairs() values_local[m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; values_local[m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; } - else if ( ((xi[dir]pos)) || ((xi[dir]pos1)) ){ + else if ( ((xi[dir]pos)) || ((xi[dir]pos1)) ) { pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -359,13 +359,13 @@ void ComputeStressMop::compute_pairs() // Compute kinetic contribution to pressure // counts local particles transfers across the plane - if (which[m] == KIN || which[m] == TOTAL){ + if (which[m] == KIN || which[m] == TOTAL) { double sgn; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { // skip if I is not in group - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { itype = type[i]; @@ -402,7 +402,7 @@ void ComputeStressMop::compute_pairs() double pos_temp = pos+copysign(1.0,domain->prd_half[dir]-pos)*domain->prd[dir]; if (fabs(xi[dir]-pos)ndihedraltypes,fp); - for(int i = 1; i <= atom->ndihedraltypes; i++) { + for (int i = 1; i <= atom->ndihedraltypes; i++) { fwrite(k[i],sizeof(double),nterms[i],fp); fwrite(multiplicity[i],sizeof(int),nterms[i],fp); fwrite(shift[i],sizeof(double),nterms[i],fp); @@ -410,7 +410,7 @@ void DihedralFourier::write_data(FILE *fp) for (int i = 1; i <= atom->ndihedraltypes; i++) { fprintf(fp,"%d %d",i,nterms[i]); - for(int j = 0; j < nterms[i]; j++) + for (int j = 0; j < nterms[i]; j++) fprintf(fp," %g %d %g",k[i][j],multiplicity[i][j],shift[i][j]); fprintf(fp,"\n"); } diff --git a/src/USER-MISC/dihedral_nharmonic.cpp b/src/USER-MISC/dihedral_nharmonic.cpp index f1b01d031f..1041062530 100644 --- a/src/USER-MISC/dihedral_nharmonic.cpp +++ b/src/USER-MISC/dihedral_nharmonic.cpp @@ -307,7 +307,7 @@ void DihedralNHarmonic::coeff(int narg, char **arg) void DihedralNHarmonic::write_restart(FILE *fp) { fwrite(&nterms[1],sizeof(int),atom->ndihedraltypes,fp); - for(int i = 1; i <= atom->ndihedraltypes; i++) + for (int i = 1; i <= atom->ndihedraltypes; i++) fwrite(a[i],sizeof(double),nterms[i],fp); } @@ -325,11 +325,11 @@ void DihedralNHarmonic::read_restart(FILE *fp) MPI_Bcast(&nterms[1],atom->ndihedraltypes,MPI_INT,0,world); // allocate - for(int i = 1; i <= atom->ndihedraltypes; i++) + for (int i = 1; i <= atom->ndihedraltypes; i++) a[i] = new double [nterms[i]]; if (comm->me == 0) { - for(int i = 1; i <= atom->ndihedraltypes; i++) + for (int i = 1; i <= atom->ndihedraltypes; i++) utils::sfread(FLERR,a[i],sizeof(double),nterms[i],fp,nullptr,error); } diff --git a/src/USER-MISC/dihedral_spherical.cpp b/src/USER-MISC/dihedral_spherical.cpp index 2c12266d85..2f77887de9 100644 --- a/src/USER-MISC/dihedral_spherical.cpp +++ b/src/USER-MISC/dihedral_spherical.cpp @@ -479,7 +479,7 @@ void DihedralSpherical::compute(int eflag, int vflag) // d U d U d phi d U d theta1 d U d theta2 // -f = ----- = ----- * ----- + -------*------- + --------*-------- // d x d phi d x d theta1 d X d theta2 d X - for(int d=0; d < g_dim; ++d) { + for (int d=0; d < g_dim; ++d) { f1[d] = m_du_dphi*dphi_dx1[d]+m_du_dth1*dth1_dx1[d]; //note: dth2_dx1[d]=0 f2[d] = m_du_dphi*dphi_dx2[d]+m_du_dth1*dth1_dx2[d]+m_du_dth2*dth2_dx2[d]; @@ -731,7 +731,7 @@ void DihedralSpherical::write_restart(FILE *fp) { fwrite(&nterms[1],sizeof(int),atom->ndihedraltypes,fp); - for(int i = 1; i <= atom->ndihedraltypes; i++) { + for (int i = 1; i <= atom->ndihedraltypes; i++) { fwrite(Ccoeff[i],sizeof(double),nterms[i],fp); fwrite(phi_mult[i],sizeof(double),nterms[i],fp); fwrite(phi_shift[i],sizeof(double),nterms[i],fp); diff --git a/src/USER-MISC/dihedral_table.cpp b/src/USER-MISC/dihedral_table.cpp index 11b5016a9a..30e6192275 100644 --- a/src/USER-MISC/dihedral_table.cpp +++ b/src/USER-MISC/dihedral_table.cpp @@ -204,7 +204,7 @@ static int cyc_spline(double const *xa, // The for loop sets up the equations we need to solve. // Later we invoke the GSL tridiagonal matrix solver to solve them. - for(int i=0; i < n; i++) { + for (int i=0; i < n; i++) { // I have to lookup xa[i+1] and xa[i-1]. This gets tricky because of // periodic boundary conditions. We handle that now. @@ -675,7 +675,7 @@ void DihedralTable::compute(int eflag, int vflag) // d U d U d phi // -f = ----- = ----- * ----- // d x d phi d x - for(int d=0; d < g_dim; ++d) { + for (int d=0; d < g_dim; ++d) { f1[d] = m_du_dphi * dphi_dx1[d]; f2[d] = m_du_dphi * dphi_dx2[d]; f3[d] = m_du_dphi * dphi_dx3[d]; diff --git a/src/USER-MISC/dihedral_table_cut.cpp b/src/USER-MISC/dihedral_table_cut.cpp index 4c008bed6d..ed7b3ac0d6 100644 --- a/src/USER-MISC/dihedral_table_cut.cpp +++ b/src/USER-MISC/dihedral_table_cut.cpp @@ -221,7 +221,7 @@ static int cyc_spline(double const *xa, // The for loop sets up the equations we need to solve. // Later we invoke the GSL tridiagonal matrix solver to solve them. - for(int i=0; i < n; i++) { + for (int i=0; i < n; i++) { // I have to lookup xa[i+1] and xa[i-1]. This gets tricky because of // periodic boundary conditions. We handle that now. diff --git a/src/USER-MISC/fix_ave_correlate_long.cpp b/src/USER-MISC/fix_ave_correlate_long.cpp index bbf106e68a..a9c8228871 100644 --- a/src/USER-MISC/fix_ave_correlate_long.cpp +++ b/src/USER-MISC/fix_ave_correlate_long.cpp @@ -491,7 +491,7 @@ void FixAveCorrelateLong::end_of_step() evaluate(); if (fp && me == 0) { - if(overwrite) fseek(fp,filepos,SEEK_SET); + if (overwrite) fseek(fp,filepos,SEEK_SET); fprintf(fp,"# Timestep: " BIGINT_FORMAT "\n", ntimestep); for (unsigned int i=0;idt*nevery); @@ -590,7 +590,7 @@ void FixAveCorrelateLong::accumulate() /* ---------------------------------------------------------------------- Add a scalar value to the autocorrelator k of pair i ------------------------------------------------------------------------- */ -void FixAveCorrelateLong::add(const int i, const double w, const int k){ +void FixAveCorrelateLong::add(const int i, const double w, const int k) { // If we exceed the correlator side, the value is discarded if (k == numcorrelators) return; if (k > kmax) kmax=k; diff --git a/src/USER-MISC/fix_filter_corotate.cpp b/src/USER-MISC/fix_filter_corotate.cpp index 1bcf3cee21..4f1feeaa6c 100644 --- a/src/USER-MISC/fix_filter_corotate.cpp +++ b/src/USER-MISC/fix_filter_corotate.cpp @@ -260,14 +260,14 @@ void FixFilterCorotate::init() int i; // error if more than one filter int count = 0; - for (i = 0; i < modify->nfix; i++){ + for (i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"filter/corotate") == 0) count++; } if (count > 1) error->all(FLERR,"More than one fix filter/corotate"); // check for fix shake: count = 0; - for (i = 0; i < modify->nfix; i++){ + for (i = 0; i < modify->nfix; i++) { if (strcmp(modify->fix[i]->style,"shake") == 0) count++; } if (count > 1) @@ -353,7 +353,7 @@ void FixFilterCorotate::pre_neighbor() nlist = 0; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (shake_flag[i]) { if (shake_flag[i] == 2) { atom1 = atom->map(shake_atom[i][0]); @@ -682,11 +682,11 @@ void FixFilterCorotate::setup(int vflag) ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); } -void FixFilterCorotate::setup_pre_force_respa(int vflag,int ilevel){ +void FixFilterCorotate::setup_pre_force_respa(int vflag,int ilevel) { pre_force_respa(vflag,ilevel,0); } -//void FixFilterCorotate::setup_post_force_respa(int vflag,int ilevel){ +//void FixFilterCorotate::setup_post_force_respa(int vflag,int ilevel) { // post_force_respa(vflag,ilevel,0); //} @@ -944,7 +944,7 @@ void FixFilterCorotate::find_clusters() m = 0; while (m < size) { i = atom->map(buf[m]); - for (j = 0; j < npartner[i]; j++){ + for (j = 0; j < npartner[i]; j++) { if (buf[m+1] == partner_tag[i][j]) break; } partner_mask[i][j] = buf[m+2]; @@ -965,7 +965,7 @@ void FixFilterCorotate::find_clusters() // else it's an error flag = 0; - for (i = 0; i < nlocal; i++){ + for (i = 0; i < nlocal; i++) { for (j = 0; j < npartner[i]; j++) { if (partner_type[i][j] == 0) flag = 1; if (!(mask[i] & groupbit)) continue; @@ -1072,7 +1072,7 @@ void FixFilterCorotate::find_clusters() m = 0; while (m < size) { i = atom->map(buf[m]); - for (j = 0; j < npartner[i]; j++){ + for (j = 0; j < npartner[i]; j++) { if (buf[m+1] == partner_tag[i][j]) break; } partner_nshake[i][j] = buf[m+2]; @@ -1132,7 +1132,7 @@ void FixFilterCorotate::find_clusters() shake_type[i][3] = 0; if (nshake[i] == 1) { - for (j = 0; j < npartner[i]; j++){ + for (j = 0; j < npartner[i]; j++) { if (partner_shake[i][j]) break; } if (partner_nshake[i][j] == 1 && tag[i] < partner_tag[i][j]) { diff --git a/src/USER-MISC/fix_flow_gauss.cpp b/src/USER-MISC/fix_flow_gauss.cpp index 422c002158..0dabf82436 100644 --- a/src/USER-MISC/fix_flow_gauss.cpp +++ b/src/USER-MISC/fix_flow_gauss.cpp @@ -175,7 +175,7 @@ void FixFlowGauss::post_force(int /*vflag*/) f_thisProc[ii]=0.0; //add all forces on each processor - for(ii=0; iinarg) error->all(FLERR,"Did not specify C matrix for non-equilibrium GLE"); diff --git a/src/USER-MISC/fix_npt_cauchy.cpp b/src/USER-MISC/fix_npt_cauchy.cpp index a28363ff8e..cb7ca713a1 100644 --- a/src/USER-MISC/fix_npt_cauchy.cpp +++ b/src/USER-MISC/fix_npt_cauchy.cpp @@ -2754,23 +2754,23 @@ void FixNPTCauchy::CauchyStat_Step(double (&Fi)[3][3], double (&Fdot)[3][3], uv(5,1)=1; uv(5,2)=3; uv(6,1)=1; uv(6,2)=2; - for(int ii = 1;ii <= 6;ii++) { + for (int ii = 1;ii <= 6;ii++) { i=uv(ii,1); j=uv(ii,2); deltastress(ii)=setcauchy(i,j)-cauchy(i,j); - if(ii>3) deltastress(ii)=deltastress(ii)*2.0; + if (ii>3) deltastress(ii)=deltastress(ii)*2.0; fdotvec(ii)=Fdot(i,j)*deltat; } - for(int ii = 1;ii <= 6;ii++) { + for (int ii = 1;ii <= 6;ii++) { i=uv(ii,1); j=uv(ii,2); - for(int jj = 1;jj <= 6;jj++) { + for (int jj = 1;jj <= 6;jj++) { m=uv(jj,1); n=uv(jj,2); dsds(ii,jj) = Fi(i,m)*Fi(j,n) + Fi(i,n)*Fi(j,m) + Fi(j,m)*Fi(i,n) + Fi(j,n)*Fi(i,m); - for(int l = 1;l <= 3;l++) { - for(int k = 1;k <= 3;k++) { + for (int l = 1;l <= 3;l++) { + for (int k = 1;k <= 3;k++) { dsdf(ii,jj) = dsdf(ii,jj) + cauchy(k,l)* ( Fi(i,k)*Fi(j,l)*Fi(n,m) - Fi(i,m)*Fi(j,l)*Fi(n,k) - Fi(i,k)*Fi(j,m)*Fi(n,l) ); } @@ -2779,21 +2779,21 @@ void FixNPTCauchy::CauchyStat_Step(double (&Fi)[3][3], double (&Fdot)[3][3], } jac=volume/volume0; - for(int ii = 1;ii <= 6;ii++) { - for(int jj = 1;jj <= 6;jj++) { + for (int ii = 1;ii <= 6;ii++) { + for (int jj = 1;jj <= 6;jj++) { dsds(ii,jj)=dsds(ii,jj)*jac/4.0; dsdf(ii,jj)=dsdf(ii,jj)*jac; } } - for(int ii = 1;ii <= 6;ii++) { - for(int jj = 1;jj <= 6;jj++) { + for (int ii = 1;ii <= 6;ii++) { + for (int jj = 1;jj <= 6;jj++) { deltaF(ii)=deltaF(ii)+dsdf(ii,jj)*fdotvec(jj); } } - for(int ii = 1;ii <= 6;ii++) { - for(int jj = 1;jj <= 6;jj++) { + for (int ii = 1;ii <= 6;ii++) { + for (int jj = 1;jj <= 6;jj++) { deltaPK(ii)=deltaPK(ii)+alpha*dsds(ii,jj)*deltastress(jj); } deltaPK(ii)=deltaPK(ii)+alpha*deltaF(ii); diff --git a/src/USER-MISC/fix_pafi.cpp b/src/USER-MISC/fix_pafi.cpp index 2d229062de..ec0733657a 100644 --- a/src/USER-MISC/fix_pafi.cpp +++ b/src/USER-MISC/fix_pafi.cpp @@ -286,7 +286,7 @@ void FixPAFI::post_force(int /*vflag*/) } } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -318,7 +318,7 @@ void FixPAFI::post_force(int /*vflag*/) results_all[4] = proj_all[5]; // dX.f force_flag = 1; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { f[i][0] -= proj_all[0] * path[i][3] + c_v_all[0]/c_v_all[9]; @@ -336,7 +336,7 @@ void FixPAFI::post_force(int /*vflag*/) } if (od_flag == 0) { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (rmass) mass_f = sqrt(rmass[i]); else mass_f = sqrt(mass[type[i]]); @@ -351,7 +351,7 @@ void FixPAFI::post_force(int /*vflag*/) } } } else { - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (rmass) mass_f = sqrt(rmass[i]); @@ -449,7 +449,7 @@ void FixPAFI::min_post_force(int /*vflag*/) } } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -482,7 +482,7 @@ void FixPAFI::min_post_force(int /*vflag*/) MPI_Bcast(results_all,5,MPI_DOUBLE,0,world); force_flag = 1; - for (int i = 0; i < nlocal; i++){ + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { f[i][0] -= proj_all[0] * path[i][3] + c_v_all[0]/c_v_all[9]; @@ -544,7 +544,7 @@ void FixPAFI::initial_integrate(int /*vflag*/) proj[1] += v[i][2] * path[i][5]; // v.n } } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -566,7 +566,7 @@ void FixPAFI::initial_integrate(int /*vflag*/) MPI_Allreduce(proj,proj_all,5,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(c_v,c_v_all,10,MPI_DOUBLE,MPI_SUM,world); - if (od_flag == 0){ + if (od_flag == 0) { if (rmass) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -650,7 +650,7 @@ void FixPAFI::final_integrate() proj[0] += f[i][1] * path[i][4]; // f.n proj[0] += f[i][2] * path[i][5]; // f.n } - if (com_flag == 0){ + if (com_flag == 0) { c_v[9] += 1.0; } else { for (int i = 0; i < nlocal; i++) @@ -665,7 +665,7 @@ void FixPAFI::final_integrate() MPI_Allreduce(proj,proj_all,5,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(c_v,c_v_all,10,MPI_DOUBLE,MPI_SUM,world); - if (od_flag == 0){ + if (od_flag == 0) { if (rmass) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { diff --git a/src/USER-MISC/fix_pimd.cpp b/src/USER-MISC/fix_pimd.cpp index 020799a943..5571f1cf35 100644 --- a/src/USER-MISC/fix_pimd.cpp +++ b/src/USER-MISC/fix_pimd.cpp @@ -52,34 +52,34 @@ FixPIMD::FixPIMD(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) nhc_nchain = 2; sp = 1.0; - for(int i=3; iuniverse_all(FLERR,"Unknown method parameter for fix pimd"); } - else if(strcmp(arg[i],"fmass")==0) + else if (strcmp(arg[i],"fmass")==0) { fmass = atof(arg[i+1]); - if(fmass<0.0 || fmass>1.0) error->universe_all(FLERR,"Invalid fmass value for fix pimd"); + if (fmass<0.0 || fmass>1.0) error->universe_all(FLERR,"Invalid fmass value for fix pimd"); } - else if(strcmp(arg[i],"sp")==0) + else if (strcmp(arg[i],"sp")==0) { sp = atof(arg[i+1]); - if(fmass<0.0) error->universe_all(FLERR,"Invalid sp value for fix pimd"); + if (fmass<0.0) error->universe_all(FLERR,"Invalid sp value for fix pimd"); } - else if(strcmp(arg[i],"temp")==0) + else if (strcmp(arg[i],"temp")==0) { nhc_temp = atof(arg[i+1]); - if(nhc_temp<0.0) error->universe_all(FLERR,"Invalid temp value for fix pimd"); + if (nhc_temp<0.0) error->universe_all(FLERR,"Invalid temp value for fix pimd"); } - else if(strcmp(arg[i],"nhc")==0) + else if (strcmp(arg[i],"nhc")==0) { nhc_nchain = atoi(arg[i+1]); - if(nhc_nchain<2) error->universe_all(FLERR,"Invalid nhc value for fix pimd"); + if (nhc_nchain<2) error->universe_all(FLERR,"Invalid nhc value for fix pimd"); } else error->universe_all(arg[i],i+1,"Unknown keyword for fix pimd"); } @@ -155,7 +155,7 @@ void FixPIMD::init() if (atom->map_style == Atom::MAP_NONE) error->all(FLERR,"Fix pimd requires an atom map, see atom_modify"); - if(universe->me==0 && screen) fprintf(screen,"Fix pimd initializing Path-Integral ...\n"); + if (universe->me==0 && screen) fprintf(screen,"Fix pimd initializing Path-Integral ...\n"); // prepare the constants @@ -190,7 +190,7 @@ void FixPIMD::init() omega_np = sqrt(np) / (hbar * beta) * sqrt(force->mvv2e); fbond = - _fbond * force->mvv2e; - if(universe->me==0) + if (universe->me==0) printf("Fix pimd -P/(beta^2 * hbar^2) = %20.7lE (kcal/mol/A^2)\n\n", fbond); dtv = update->dt; @@ -200,17 +200,17 @@ void FixPIMD::init() mass = new double [atom->ntypes+1]; - if(method==CMD || method==NMPIMD) nmpimd_init(); - else for(int i=1; i<=atom->ntypes; i++) mass[i] = atom->mass[i] / np * fmass; + if (method==CMD || method==NMPIMD) nmpimd_init(); + else for (int i=1; i<=atom->ntypes; i++) mass[i] = atom->mass[i] / np * fmass; - if(!nhc_ready) nhc_init(); + if (!nhc_ready) nhc_init(); } /* ---------------------------------------------------------------------- */ void FixPIMD::setup(int vflag) { - if(universe->me==0 && screen) fprintf(screen,"Setting up Path-Integral ...\n"); + if (universe->me==0 && screen) fprintf(screen,"Setting up Path-Integral ...\n"); post_force(vflag); } @@ -234,12 +234,12 @@ void FixPIMD::final_integrate() void FixPIMD::post_force(int /*flag*/) { - for(int i=0; inlocal; i++) for(int j=0; j<3; j++) atom->f[i][j] /= np; + for (int i=0; inlocal; i++) for(int j=0; j<3; j++) atom->f[i][j] /= np; comm_exec(atom->x); spring_force(); - if(method==CMD || method==NMPIMD) + if (method==CMD || method==NMPIMD) { /* forward comm for the force on ghost atoms */ @@ -267,29 +267,29 @@ void FixPIMD::nhc_init() double mass0 = KT * tau * tau; int max = 3 * atom->nlocal; - for(int i=0; iiworld==0) ; else nhc_eta_mass[i][ichain] *= fmass; + if ((method==CMD || method==NMPIMD) && universe->iworld==0) ; else nhc_eta_mass[i][ichain] *= fmass; } nhc_eta_dot[i][nhc_nchain] = 0.0; - for(int ichain=1; ichainmvv2e - KT) / nhc_eta_mass[i][ichain]; } // Zero NH acceleration for CMD - if(method==CMD && universe->iworld==0) for(int i=0; iiworld==0) for (int i=0; ix; double **v = atom->v; - if(method==CMD || method==NMPIMD) + if (method==CMD || method==NMPIMD) { nmpimd_fill(atom->v); comm_exec(atom->v); @@ -313,7 +313,7 @@ void FixPIMD::nhc_update_x() nmpimd_transform(buf_beads, v, M_xp2x[universe->iworld]); } - for(int i=0; iv; double **f = atom->f; - for(int i=0; iiworld==0) return; + if (method==CMD && universe->iworld==0) return; double expfac; int nmax = 3 * atom->nlocal; @@ -350,7 +350,7 @@ void FixPIMD::nhc_update_v() double dt4 = 0.25 * update->dt; double dt8 = 0.125 * update->dt; - for(int i=0; i0; ichain--) + for (int ichain=nhc_nchain-1; ichain>0; ichain--) { expfac = exp(-dt8 * eta_dot[ichain+1]); eta_dot[ichain] *= expfac; @@ -388,14 +388,14 @@ void FixPIMD::nhc_update_v() kecurrent = force->boltz * t_current; eta_dotdot[0] = (kecurrent - KT) / nhc_eta_mass[i][0]; - for(int ichain=0; ichainiworld; - for(int i=1; i<=atom->ntypes; i++) + for (int i=1; i<=atom->ntypes; i++) { mass[i] = atom->mass[i]; - if(iworld) + if (iworld) { mass[i] *= lam[iworld]; mass[i] *= fmass; @@ -491,10 +491,10 @@ void FixPIMD::nmpimd_transform(double** src, double** des, double *vector) int n = atom->nlocal; int m = 0; - for(int i=0; ime - comm->nprocs; int rank_next = universe->me + comm->nprocs; - if(rank_last<0) rank_last += universe->nprocs; - if(rank_next>=universe->nprocs) rank_next -= universe->nprocs; + if (rank_last<0) rank_last += universe->nprocs; + if (rank_next>=universe->nprocs) rank_next -= universe->nprocs; plan_send[0] = rank_next; plan_send[1] = rank_last; plan_recv[0] = rank_last; plan_recv[1] = rank_next; @@ -579,13 +579,13 @@ void FixPIMD::comm_init() plan_recv = new int [size_plan]; mode_index = new int [size_plan]; - for(int i=0; ime + comm->nprocs * (i+1); - if(plan_send[i]>=universe->nprocs) plan_send[i] -= universe->nprocs; + if (plan_send[i]>=universe->nprocs) plan_send[i] -= universe->nprocs; plan_recv[i] = universe->me - comm->nprocs * (i+1); - if(plan_recv[i]<0) plan_recv[i] += universe->nprocs; + if (plan_recv[i]<0) plan_recv[i] += universe->nprocs; mode_index[i]=(universe->iworld+i+1)%(universe->nworlds); } @@ -594,14 +594,14 @@ void FixPIMD::comm_init() x_last = (universe->iworld-1+universe->nworlds)%(universe->nworlds); } - if(buf_beads) + if (buf_beads) { - for(int i=0; inlocal; - if(nlocal > max_nlocal) + if (nlocal > max_nlocal) { max_nlocal = nlocal+200; int size = sizeof(double) * max_nlocal * 3; buf_recv = (double*) memory->srealloc(buf_recv, size, "FixPIMD:x_recv"); - for(int i=0; isrealloc(buf_beads[i], size, "FixPIMD:x_beads[i]"); } @@ -626,7 +626,7 @@ void FixPIMD::comm_exec(double **ptr) // go over comm plans - for(int iplan = 0; iplan max_nsend) + if (nsend > max_nsend) { max_nsend = nsend+200; tag_send = (tagint*) memory->srealloc(tag_send, sizeof(tagint)*max_nsend, "FixPIMD:tag_send"); @@ -654,11 +654,11 @@ void FixPIMD::comm_exec(double **ptr) double *wrap_ptr = buf_send; int ncpy = sizeof(double)*3; - for(int i=0; imap(tag_send[i]); - if(index<0) + if (index<0) { char error_line[256]; @@ -846,7 +846,7 @@ int FixPIMD::size_restart(int /*nlocal*/) double FixPIMD::compute_vector(int n) { - if(n==0) { return spring_energy; } - if(n==1) { return t_sys; } + if (n==0) { return spring_energy; } + if (n==1) { return t_sys; } return 0.0; } diff --git a/src/USER-MISC/fix_propel_self.cpp b/src/USER-MISC/fix_propel_self.cpp index 9299f4d23b..8617fb0d3d 100644 --- a/src/USER-MISC/fix_propel_self.cpp +++ b/src/USER-MISC/fix_propel_self.cpp @@ -171,8 +171,8 @@ void FixPropelSelf::post_force_quaternion(int /* vflag */ ) // Add the active force to the atom force: - for( int i = 0; i < nlocal; ++i ){ - if( mask[i] & groupbit ){ + for ( int i = 0; i < nlocal; ++i ) { + if ( mask[i] & groupbit ) { if (filter_by_type && !apply_to_type[type[i]]) { continue; } @@ -206,8 +206,8 @@ void FixPropelSelf::post_force_velocity(int /*vflag*/) // Add the active force to the atom force: - for(int i = 0; i < nlocal; ++i) { - if( mask[i] & groupbit ){ + for (int i = 0; i < nlocal; ++i) { + if ( mask[i] & groupbit ) { if (filter_by_type && !apply_to_type[type[i]]) { continue; } diff --git a/src/USER-MISC/fix_rhok.cpp b/src/USER-MISC/fix_rhok.cpp index e63ba88b93..a84d9dae4d 100644 --- a/src/USER-MISC/fix_rhok.cpp +++ b/src/USER-MISC/fix_rhok.cpp @@ -235,9 +235,9 @@ FixRhok::compute_vector( int inI ) { if (inI == 0) return mRhoKGlobal[0]; // Real part - else if( inI == 1 ) + else if ( inI == 1 ) return mRhoKGlobal[1]; // Imagniary part - else if( inI == 2 ) + else if ( inI == 2 ) return sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] + mRhoKGlobal[1]*mRhoKGlobal[1] ); else diff --git a/src/USER-MISC/fix_smd.cpp b/src/USER-MISC/fix_smd.cpp index 2d6117608a..828ceda0ed 100644 --- a/src/USER-MISC/fix_smd.cpp +++ b/src/USER-MISC/fix_smd.cpp @@ -223,7 +223,7 @@ void FixSMD::smd_tether() if (!zflag) dz = 0.0; r = sqrt(dx*dx + dy*dy + dz*dz); if (styleflag & SMD_CVEL) { - if(r > SMALL) { + if (r > SMALL) { dr = r - r0 - r_old; fx = k_smd*dx*dr/r; fy = k_smd*dy*dr/r; diff --git a/src/USER-MISC/fix_srp.cpp b/src/USER-MISC/fix_srp.cpp index 70398711d9..254a66f2f2 100644 --- a/src/USER-MISC/fix_srp.cpp +++ b/src/USER-MISC/fix_srp.cpp @@ -134,8 +134,8 @@ void FixSRP::init() char c0[20]; char c1[20]; - for(int z = 1; z < atom->ntypes; z++) { - if(z == bptype) + for (int z = 1; z < atom->ntypes; z++) { + if (z == bptype) continue; sprintf(c0, "%d", z); arg1[2] = c0; @@ -175,7 +175,7 @@ void FixSRP::setup_pre_force(int /*zz*/) memory->create(tagold,nall,"fix_srp:tagold"); memory->create(dlist,nall,"fix_srp:dlist"); - for (i = 0; i < nall; i++){ + for (i = 0; i < nall; i++) { xold[i][0] = x[i][0]; xold[i][1] = x[i][1]; xold[i][2] = x[i][2]; @@ -209,7 +209,7 @@ void FixSRP::setup_pre_force(int /*zz*/) // consider only the user defined bond type // btype of zero considers all bonds - if(btype > 0 && bondlist[n][2] != btype) + if (btype > 0 && bondlist[n][2] != btype) continue; i = bondlist[n][0]; @@ -226,7 +226,7 @@ void FixSRP::setup_pre_force(int /*zz*/) dely = xold[j][1] - xold[i][1]; delz = xold[j][2] - xold[i][2]; rsq = delx*delx + dely*dely + delz*delz; - if(rsq > rsqold) rsqold = rsq; + if (rsq > rsqold) rsqold = rsq; // make one particle for each bond // i is local @@ -255,7 +255,7 @@ void FixSRP::setup_pre_force(int /*zz*/) int nadd_all = 0, ndel_all = 0; MPI_Allreduce(&ndel,&ndel_all,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&nadd,&nadd_all,1,MPI_INT,MPI_SUM,world); - if(comm->me == 0){ + if (comm->me == 0) { sprintf(str, "Removed/inserted %d/%d bond particles.", ndel_all,nadd_all); error->message(FLERR,str); } @@ -285,7 +285,7 @@ void FixSRP::setup_pre_force(int /*zz*/) cutghostmin = comm->cutghost[2]/length2; // stop if cutghost is insufficient - if (cutneighmax_srp > cutghostmin){ + if (cutneighmax_srp > cutghostmin) { sprintf(str, "Communication cutoff too small for fix srp. " "Need %f, current %f.", cutneighmax_srp, cutghostmin); error->all(FLERR,str); @@ -327,14 +327,14 @@ void FixSRP::setup_pre_force(int /*zz*/) // zero all forces - for(i = 0; i < nall; i++) + for (i = 0; i < nall; i++) atom->f[i][0] = atom->f[i][1] = atom->f[i][2] = 0.0; // do not include bond particles in thermo output // remove them from all groups. set their velocity to zero. - for(i=0; i< nlocal; i++) - if(atom->type[i] == bptype) { + for (i=0; i< nlocal; i++) + if (atom->type[i] == bptype) { atom->mask[i] = 0; atom->v[i][0] = atom->v[i][1] = atom->v[i][2] = 0.0; } @@ -355,15 +355,15 @@ void FixSRP::pre_exchange() int i,j; int nlocal = atom->nlocal; - for(int ii = 0; ii < nlocal; ii++){ - if(atom->type[ii] != bptype) continue; + for (int ii = 0; ii < nlocal; ii++) { + if (atom->type[ii] != bptype) continue; i = atom->map(static_cast(array[ii][0])); - if(i < 0) error->all(FLERR,"Fix SRP failed to map atom"); + if (i < 0) error->all(FLERR,"Fix SRP failed to map atom"); i = domain->closest_image(ii,i); j = atom->map(static_cast(array[ii][1])); - if(j < 0) error->all(FLERR,"Fix SRP failed to map atom"); + if (j < 0) error->all(FLERR,"Fix SRP failed to map atom"); j = domain->closest_image(ii,j); // position of bond particle ii @@ -462,7 +462,7 @@ int FixSRP::unpack_border(int n, int first, double *buf) int m = 0; last = first + n; - for (i = first; i < last; i++){ + for (i = first; i < last; i++) { array[i][0] = buf[m++]; array[i][1] = buf[m++]; } @@ -484,8 +484,8 @@ void FixSRP::post_run() int* dlist; memory->create(dlist,nlocal,"fix_srp:dlist"); - for (int i = 0; i < nlocal; i++){ - if(atom->type[i] == bptype) + for (int i = 0; i < nlocal; i++) { + if (atom->type[i] == bptype) dlist[i] = 1; else dlist[i] = 0; @@ -574,7 +574,7 @@ void FixSRP::unpack_restart(int nlocal, int nth) // unpack the Nth first values this way because other fixes pack them int m = 0; - for (int i = 0; i < nth; i++){ + for (int i = 0; i < nth; i++) { m += static_cast (extra[nlocal][m]); } diff --git a/src/USER-MISC/fix_ti_spring.cpp b/src/USER-MISC/fix_ti_spring.cpp index 88219a66cb..3a87dfa96d 100644 --- a/src/USER-MISC/fix_ti_spring.cpp +++ b/src/USER-MISC/fix_ti_spring.cpp @@ -380,7 +380,7 @@ double FixTISpring::switch_func(double t) double FixTISpring::dswitch_func(double t) { - if(sf == 1) return 1.0/t_switch; + if (sf == 1) return 1.0/t_switch; double t2 = t*t; double t4 = t2*t2; diff --git a/src/USER-MISC/fix_ttm_mod.cpp b/src/USER-MISC/fix_ttm_mod.cpp index e6aa062b39..a776e7e1da 100644 --- a/src/USER-MISC/fix_ttm_mod.cpp +++ b/src/USER-MISC/fix_ttm_mod.cpp @@ -290,8 +290,8 @@ void FixTTMMod::post_force(int /*vflag*/) double vsq = v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]; if (vsq > v_0_sq) gamma1 *= (gamma_p + gamma_s)/gamma_p; gamma2 = gfactor2[type[i]] * tsqrt; - if (ixnode >= surface_l){ - if (ixnode < surface_r){ + if (ixnode >= surface_l) { + if (ixnode < surface_r) { flangevin[i][0] = gamma1*v[i][0] + gamma2*(random->uniform()-0.5); flangevin[i][1] = gamma1*v[i][1] + gamma2*(random->uniform()-0.5); flangevin[i][2] = gamma1*v[i][2] + gamma2*(random->uniform()-0.5); @@ -320,8 +320,8 @@ void FixTTMMod::post_force(int /*vflag*/) double diff_x = (x_at - x_surf)*(x_at - x_surf); diff_x = pow(diff_x,0.5); double len_factor = diff_x/(diff_x+free_path); - if (movsur == 1){ - if (x_at >= x_surf){ + if (movsur == 1) { + if (x_at >= x_surf) { flangevin[i][0] -= pres_factor/ionic_density*((C_ir*T_ir*free_path/(diff_x+free_path)/(diff_x+free_path)) + (len_factor/dx)*(C_ir*T_ir-C_i*T_i)); flangevin[i][1] -= pres_factor/ionic_density/dy*(C_iu*T_iu-C_i*T_i); @@ -337,8 +337,8 @@ void FixTTMMod::post_force(int /*vflag*/) f[i][2] += flangevin[i][2]; } } - if (movsur == 1){ - if (ixnode < surface_l){ + if (movsur == 1) { + if (ixnode < surface_l) { t_surface_l = ixnode; } } @@ -629,12 +629,12 @@ void FixTTMMod::end_of_step() int *mask = atom->mask; int nlocal = atom->nlocal; - if (movsur == 1){ + if (movsur == 1) { for (int ixnode = 0; ixnode < nxnodes; ixnode++) for (int iynode = 0; iynode < nynodes; iynode++) - for (int iznode = 0; iznode < nznodes; iznode++){ + for (int iznode = 0; iznode < nznodes; iznode++) { double TTT = T_electron[ixnode][iynode][iznode]; - if (TTT > 0){ + if (TTT > 0) { if (ixnode < t_surface_l) t_surface_l = ixnode; } @@ -659,7 +659,7 @@ void FixTTMMod::end_of_step() while (ixnode < 0) ixnode += nxnodes; while (iynode < 0) iynode += nynodes; while (iznode < 0) iznode += nznodes; - if (ixnode >= t_surface_l){ + if (ixnode >= t_surface_l) { if (ixnode < surface_r) net_energy_transfer[ixnode][iynode][iznode] += (flangevin[i][0]*v[i][0] + flangevin[i][1]*v[i][1] + @@ -748,7 +748,7 @@ void FixTTMMod::end_of_step() double ixnode_d = double(ixnode); double surface_d = double(t_surface_l); mult_factor = 0.0; - if (duration < width){ + if (duration < width) { if (ixnode >= t_surface_l) mult_factor = (intensity/(dx*skin_layer_d))*exp((-1.0)*(ixnode_d - surface_d)/skin_layer_d); } if (ixnode < t_surface_l) net_energy_transfer_all[ixnode][iynode][iznode] = 0.0; @@ -862,7 +862,7 @@ void FixTTMMod::end_of_step() if (nsum_all[ixnode][iynode][iznode] > 0) { T_a = sum_mass_vsq_all[ixnode][iynode][iznode]/ (3.0*force->boltz*nsum_all[ixnode][iynode][iznode]/force->mvv2e); - if (movsur == 1){ + if (movsur == 1) { if (T_electron[ixnode][iynode][iznode]==0.0) T_electron[ixnode][iynode][iznode] = electron_temperature_min; } } diff --git a/src/USER-MISC/fix_wall_ees.cpp b/src/USER-MISC/fix_wall_ees.cpp index 554d8870a0..e8e307224f 100644 --- a/src/USER-MISC/fix_wall_ees.cpp +++ b/src/USER-MISC/fix_wall_ees.cpp @@ -122,8 +122,8 @@ void FixWallEES::wall_particle(int m, int which, double coord) double* shape = bonus[ellipsoid[i]].shape;; MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A); MathExtra::transpose_matvec(A,nhat,tempvec); - for(int k = 0; k<3; k++) tempvec[k] *= shape[k]; - for(int k = 0; k<3 ; k++) sigman2 += tempvec[k]*tempvec[k]; + for (int k = 0; k<3; k++) tempvec[k] *= shape[k]; + for (int k = 0; k<3 ; k++) sigman2 += tempvec[k]*tempvec[k]; sigman = sqrt(sigman2); if (delta <= sigman) { @@ -149,7 +149,7 @@ void FixWallEES::wall_particle(int m, int which, double coord) double Lz[3][3] = {{0,-1,0},{1,0,0},{0,0,0}}; - for(int k = 0; k<3; k++) SAn[k] = tempvec[k]; + for (int k = 0; k<3; k++) SAn[k] = tempvec[k]; sigman3 = sigman2 * sigman; sigman4 = sigman2 * sigman2; @@ -189,21 +189,21 @@ void FixWallEES::wall_particle(int m, int which, double coord) MathExtra::matvec(Lx,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[0] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Ly,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[1] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Lz,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; that[2] = MathExtra::dot3(SAn,tempvec2); - for(int j = 0; j<3 ; j++) + for (int j = 0; j<3 ; j++) tor[i][j] += twall * that[j]; } diff --git a/src/USER-MISC/fix_wall_region_ees.cpp b/src/USER-MISC/fix_wall_region_ees.cpp index f88ec3f0b2..ab475ffb9b 100644 --- a/src/USER-MISC/fix_wall_region_ees.cpp +++ b/src/USER-MISC/fix_wall_region_ees.cpp @@ -190,14 +190,14 @@ void FixWallRegionEES::post_force(int /*vflag*/) double* shape = bonus[ellipsoid[i]].shape;; MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A); - for(int which = 0 ; which < 3; which ++){//me + for (int which = 0 ; which < 3; which ++) {//me nhat[which]=1; nhat[(which+1)%3] = 0 ; nhat[(which+2)%3] = 0 ; sn2 = 0 ; MathExtra::transpose_matvec(A,nhat,tempvec); - for(int k = 0; k<3; k++) tempvec[k] *= shape[k]; - for(int k = 0; k<3 ; k++) sn2 += tempvec[k]*tempvec[k]; + for (int k = 0; k<3; k++) tempvec[k] *= shape[k]; + for (int k = 0; k<3 ; k++) sn2 += tempvec[k]*tempvec[k]; sn = sqrt(sn2); tooclose[which] = sn; } @@ -206,13 +206,13 @@ void FixWallRegionEES::post_force(int /*vflag*/) for (m = 0; m < n; m++) { - if (region->contact[m].delx != 0 && region->contact[m].r <= tooclose[0]){ + if (region->contact[m].delx != 0 && region->contact[m].r <= tooclose[0]) { onflag = 1; continue; - } else if (region->contact[m].dely != 0 && region->contact[m].r <= tooclose[1]){ + } else if (region->contact[m].dely != 0 && region->contact[m].r <= tooclose[1]) { onflag = 1; continue; - } else if (region->contact[m].delz !=0 && region->contact[m].r <= tooclose[2]){ + } else if (region->contact[m].delz !=0 && region->contact[m].r <= tooclose[2]) { onflag = 1; continue; } else rinv = 1.0/region->contact[m].r; @@ -323,9 +323,9 @@ void FixWallRegionEES::ees(int m, int i) sigman2 = 0.0; MathExtra::transpose_matvec(A,nhat,tempvec); - for(int k = 0; k<3; k++) tempvec[k] *= shape[k]; - for(int k = 0; k<3; k++) sigman2 += tempvec[k]*tempvec[k]; - for(int k = 0; k<3; k++) SAn[k] = tempvec[k]; + for (int k = 0; k<3; k++) tempvec[k] *= shape[k]; + for (int k = 0; k<3; k++) sigman2 += tempvec[k]*tempvec[k]; + for (int k = 0; k<3; k++) SAn[k] = tempvec[k]; sigman = sqrt(sigman2); delta = fabs(region->contact[m].r); @@ -362,19 +362,19 @@ void FixWallRegionEES::ees(int m, int i) MathExtra::matvec(Lx,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[0] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Ly,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k<3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k<3; k++) tempvec2[k] *= shape[k]; that[1] = MathExtra::dot3(SAn,tempvec2); MathExtra::matvec(Lz,nhat,tempvec); MathExtra::transpose_matvec(A,tempvec,tempvec2); - for(int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; + for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k]; that[2] = MathExtra::dot3(SAn,tempvec2); - for(int j = 0; j<3 ; j++) + for (int j = 0; j<3 ; j++) torque[j] = twall * that[j]; } diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index afb457d9e4..c6cd44871e 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -200,7 +200,7 @@ void PairAGNI::compute(int eflag, int vflag) double ky = 0.0; double kz = 0.0; - for(int k = 0; k < iparam.numeta; ++k) { + for (int k = 0; k < iparam.numeta; ++k) { const double xu = iparam.xU[k][j]; kx += square(Vx[k] - xu); ky += square(Vy[k] - xu); diff --git a/src/USER-MISC/pair_e3b.cpp b/src/USER-MISC/pair_e3b.cpp index 49c483ca1f..dceed1fc57 100644 --- a/src/USER-MISC/pair_e3b.cpp +++ b/src/USER-MISC/pair_e3b.cpp @@ -630,7 +630,7 @@ double PairE3B::init_one(int i, int j) bool PairE3B::checkKeyword(const char *thiskey,const char *test,const int nVal, const int nRem) { if (strcmp(thiskey,test) == 0) { - if(nRemall(FLERR,str); diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 9d36db7041..6aedc863a8 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -365,14 +365,14 @@ void PairEDIPMulti::edip_fc(double r, Param *param, double &f, double &fdr) double x; double v1, v2; - if(r < c + 1E-6) + if (r < c + 1E-6) { f=1.0; fdr=0.0; return; } - if(r > a - 1E-6) + if (r > a - 1E-6) { f=0.0; fdr=0.0; @@ -394,7 +394,7 @@ void PairEDIPMulti::edip_fcut2(double r, Param *param, double &f, double &fdr) double a = param->cutoffA; double v1; - if(r > a - 1E-6) + if (r > a - 1E-6) { f=0.0; fdr=0.0; @@ -466,7 +466,7 @@ void PairEDIPMulti::edip_fcut3(double r, Param *param, double &f, double &fdr) double a = param->cutoffA; double v1; - if(r > a - 1E-6) + if (r > a - 1E-6) { f=0.0; fdr=0.0; diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index f3718834fa..58d9f39dcb 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -782,19 +782,19 @@ void PairILPGrapheneHBN::calc_normal() i = ilist[ii]; // Initialize the arrays - for (id = 0; id < 3; id++){ + for (id = 0; id < 3; id++) { pv12[id] = 0.0; pv31[id] = 0.0; pv23[id] = 0.0; n1[id] = 0.0; dni[id] = 0.0; normal[i][id] = 0.0; - for (ip = 0; ip < 3; ip++){ + for (ip = 0; ip < 3; ip++) { vet[ip][id] = 0.0; dnn[ip][id] = 0.0; dpvdri[ip][id] = 0.0; dnormdri[ip][id][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dpv12[ip][id][m] = 0.0; dpv31[ip][id][m] = 0.0; dpv23[ip][id][m] = 0.0; @@ -828,10 +828,10 @@ void PairILPGrapheneHBN::calc_normal() normal[i][0] = 0.0; normal[i][1] = 0.0; normal[i][2] = 1.0; - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dnormal[id][ip][m][i] = 0.0; } } @@ -877,8 +877,8 @@ void PairILPGrapheneHBN::calc_normal() // derivatives respect to the third neighbor, atom n // derivatives of pv12 to rn is zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -899,15 +899,15 @@ void PairILPGrapheneHBN::calc_normal() dni[1] = (n1[0]*dpvdri[0][1] + n1[1]*dpvdri[1][1] + n1[2]*dpvdri[2][1])/nn; dni[2] = (n1[0]*dpvdri[0][2] + n1[1]*dpvdri[1][2] + n1[2]*dpvdri[2][2])/nn; // derivatives of unit vector ni respect to ri, the result is 3x3 matrix - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = dpvdri[id][ip]/nn - n1[id]*dni[ip]/nn2; } } // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = dpv12[id][ip][m]; } } @@ -915,16 +915,16 @@ void PairILPGrapheneHBN::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } @@ -932,7 +932,7 @@ void PairILPGrapheneHBN::calc_normal() } //############################################################################################## - else if(cont == 3) { + else if (cont == 3) { pv12[0] = vet[0][1]*vet[1][2] - vet[1][1]*vet[0][2]; pv12[1] = vet[0][2]*vet[1][0] - vet[1][2]*vet[0][0]; pv12[2] = vet[0][0]*vet[1][1] - vet[1][0]*vet[0][1]; @@ -958,8 +958,8 @@ void PairILPGrapheneHBN::calc_normal() dpv12[2][2][1] = 0.0; // derivatives respect to the third neighbor, atom n - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -988,8 +988,8 @@ void PairILPGrapheneHBN::calc_normal() dpv31[2][1][2] = -vet[0][0]; dpv31[2][2][2] = 0.0; // derivatives respect to the second neighbor, atom l - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv31[id][ip][1] = 0.0; } } @@ -998,8 +998,8 @@ void PairILPGrapheneHBN::calc_normal() pv23[1] = vet[1][2]*vet[2][0] - vet[2][2]*vet[1][0]; pv23[2] = vet[1][0]*vet[2][1] - vet[2][0]*vet[1][1]; // derivatives respect to the second neighbor, atom k - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv23[id][ip][0] = 0.0; } } @@ -1039,16 +1039,16 @@ void PairILPGrapheneHBN::calc_normal() normal[i][2] = n1[2]/nn; // for the central atoms, dnormdri is always zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; } } // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = (dpv12[id][ip][m] + dpv23[id][ip][m] + dpv31[id][ip][m])/cont; } } @@ -1056,16 +1056,16 @@ void PairILPGrapheneHBN::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index 93bfa8414f..d18d372b8b 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -787,19 +787,19 @@ void PairKolmogorovCrespiFull::calc_normal() i = ilist[ii]; // Initialize the arrays - for (id = 0; id < 3; id++){ + for (id = 0; id < 3; id++) { pv12[id] = 0.0; pv31[id] = 0.0; pv23[id] = 0.0; n1[id] = 0.0; dni[id] = 0.0; normal[i][id] = 0.0; - for (ip = 0; ip < 3; ip++){ + for (ip = 0; ip < 3; ip++) { vet[ip][id] = 0.0; dnn[ip][id] = 0.0; dpvdri[ip][id] = 0.0; dnormdri[ip][id][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dpv12[ip][id][m] = 0.0; dpv31[ip][id][m] = 0.0; dpv23[ip][id][m] = 0.0; @@ -834,10 +834,10 @@ void PairKolmogorovCrespiFull::calc_normal() normal[i][1] = 0.0; normal[i][2] = 1.0; // derivatives of normal vector is zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; - for (m = 0; m < 3; m++){ + for (m = 0; m < 3; m++) { dnormal[id][ip][m][i] = 0.0; } } @@ -881,8 +881,8 @@ void PairKolmogorovCrespiFull::calc_normal() dpv12[2][2][1] = 0.0; // derivatives respect to the third neighbor, atom n - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -903,16 +903,16 @@ void PairKolmogorovCrespiFull::calc_normal() dni[1] = (n1[0]*dpvdri[0][1] + n1[1]*dpvdri[1][1] + n1[2]*dpvdri[2][1])/nn; dni[2] = (n1[0]*dpvdri[0][2] + n1[1]*dpvdri[1][2] + n1[2]*dpvdri[2][2])/nn; // derivatives of unit vector ni respect to ri, the result is 3x3 matrix - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = dpvdri[id][ip]/nn - n1[id]*dni[ip]/nn2; } } // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = dpv12[id][ip][m]; } } @@ -920,16 +920,16 @@ void PairKolmogorovCrespiFull::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } @@ -937,7 +937,7 @@ void PairKolmogorovCrespiFull::calc_normal() } //############################################################################################## - else if(cont == 3) { + else if (cont == 3) { // for the atoms at the edge who has only two neighbor atoms pv12[0] = vet[0][1]*vet[1][2] - vet[1][1]*vet[0][2]; pv12[1] = vet[0][2]*vet[1][0] - vet[1][2]*vet[0][0]; @@ -964,8 +964,8 @@ void PairKolmogorovCrespiFull::calc_normal() dpv12[2][2][1] = 0.0; // derivatives respect to the third neighbor, atom n - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv12[id][ip][2] = 0.0; } } @@ -997,8 +997,8 @@ void PairKolmogorovCrespiFull::calc_normal() dpv31[2][2][2] = 0.0; // derivatives respect to the second neighbor, atom l - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv31[id][ip][1] = 0.0; } } @@ -1007,8 +1007,8 @@ void PairKolmogorovCrespiFull::calc_normal() pv23[1] = vet[1][2]*vet[2][0] - vet[2][2]*vet[1][0]; pv23[2] = vet[1][0]*vet[2][1] - vet[2][0]*vet[1][1]; // derivatives respect to the second neighbor, atom k - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dpv23[id][ip][0] = 0.0; } } @@ -1048,16 +1048,16 @@ void PairKolmogorovCrespiFull::calc_normal() normal[i][2] = n1[2]/nn; // for the central atoms, dnormdri is always zero - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormdri[id][ip][i] = 0.0; } } // end of derivatives of normals respect to atom i // derivatives of non-normalized normal vector, dn1:3x3x3 array - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ - for (m = 0; m < 3; m++){ + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { + for (m = 0; m < 3; m++) { dn1[id][ip][m] = (dpv12[id][ip][m] + dpv23[id][ip][m] + dpv31[id][ip][m])/cont; } } @@ -1065,16 +1065,16 @@ void PairKolmogorovCrespiFull::calc_normal() // derivatives of nn, dnn:3x3 vector // dnn[id][m]: the derivative of nn respect to r[id][m], id,m=0,1,2 // r[id][m]: the id's component of atom m - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { dnn[id][m] = (n1[0]*dn1[0][id][m] + n1[1]*dn1[1][id][m] + n1[2]*dn1[2][id][m])/nn; } } // dnormal[id][ip][m][i]: the derivative of normal[id] respect to r[ip][m], id,ip=0,1,2 // for atom m, which is a neighbor atom of atom i, m=0,jnum-1 - for (m = 0; m < 3; m++){ - for (id = 0; id < 3; id++){ - for (ip = 0; ip < 3; ip++){ + for (m = 0; m < 3; m++) { + for (id = 0; id < 3; id++) { + for (ip = 0; ip < 3; ip++) { dnormal[id][ip][m][i] = dn1[id][ip][m]/nn - n1[id]*dnn[ip][m]/nn2; } } diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index 85c154e103..1bea688be5 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -162,7 +162,7 @@ void PairKolmogorovCrespiZ::compute(int eflag, int vflag) evdwl = -p.A*p.z06/r6+ exp1*sumCff - offset[itype][jtype]; } - if (evflag){ + if (evflag) { ev_tally_xyz(i,j,nlocal,newton_pair,evdwl,0, fsum,fsum,fpair,delx,dely,delz); } @@ -427,7 +427,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) params[nparams].z06 = pow(params[nparams].z0,6); nparams++; - if(nparams >= pow(atom->ntypes,3)) break; + if (nparams >= pow(atom->ntypes,3)) break; } memory->destroy(elem2param); memory->create(elem2param,nelements,nelements,"pair:elem2param"); diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index 4a85ecc60d..a600f5b761 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -158,7 +158,7 @@ void PairLebedevaZ::compute(int eflag, int vflag) evdwl = Ulm - offset[itype][jtype]; } - if (evflag){ + if (evflag) { ev_tally_xyz(i,j,nlocal,newton_pair,evdwl,0, -fxy,-fxy,-fz,delx,dely,delz); } @@ -421,7 +421,7 @@ void PairLebedevaZ::read_file(char *filename) params[nparams].z06 = pow(params[nparams].z0,6); nparams++; - if(nparams >= pow(atom->ntypes,3)) break; + if (nparams >= pow(atom->ntypes,3)) break; } memory->destroy(elem2param); memory->create(elem2param,nelements,nelements,"pair:elem2param"); diff --git a/src/USER-MISC/pair_local_density.cpp b/src/USER-MISC/pair_local_density.cpp index e16892c446..3da1fcbed2 100644 --- a/src/USER-MISC/pair_local_density.cpp +++ b/src/USER-MISC/pair_local_density.cpp @@ -182,7 +182,7 @@ void PairLocalDensity::compute(int eflag, int vflag) } } else { - for (k = 0; k < nLD; k++){ + for (k = 0; k < nLD; k++) { for (i = 0; i < nlocal; i++) { localrho[k][i] = 0.0; fp[k][i] = 0.0; @@ -710,7 +710,7 @@ void PairLocalDensity::parse_file(char *filename) { memory->create(a, nLD, atom->ntypes+1 , "pairLD:a"); memory->create(b, nLD, atom->ntypes+1, "pairLD:b"); if (me == 0) { - for (n = 1; n <= atom->ntypes; n++){ + for (n = 1; n <= atom->ntypes; n++) { for (k = 0; k < nLD; k++) { a[k][n] = 0; b[k][n] = 0; diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index e6071ff592..57981e8922 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -87,7 +87,7 @@ PairMEAMSpline::~PairMEAMSpline() delete[] twoBodyInfo; memory->destroy(Uprime_values); - if(allocated) { + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); @@ -124,15 +124,15 @@ void PairMEAMSpline::compute(int eflag, int vflag) // Determine the maximum number of neighbors a single atom has int newMaxNeighbors = 0; - for(int ii = 0; ii < listfull->inum; ii++) { + for (int ii = 0; ii < listfull->inum; ii++) { int jnum = listfull->numneigh[listfull->ilist[ii]]; - if(jnum > newMaxNeighbors) + if (jnum > newMaxNeighbors) newMaxNeighbors = jnum; } // Allocate array for temporary bond info - if(newMaxNeighbors > maxNeighbors) { + if (newMaxNeighbors > maxNeighbors) { maxNeighbors = newMaxNeighbors; delete[] twoBodyInfo; twoBodyInfo = new MEAM2Body[maxNeighbors]; @@ -141,7 +141,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) // Sum three-body contributions to charge density and // the embedding energy - for(int ii = 0; ii < listfull->inum; ii++) { + for (int ii = 0; ii < listfull->inum; ii++) { int i = listfull->ilist[ii]; int numBonds = 0; @@ -151,7 +151,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) const int ntypes = atom->ntypes; const int itype = atom->type[i]; - for(int jj = 0; jj < listfull->numneigh[i]; jj++) { + for (int jj = 0; jj < listfull->numneigh[i]; jj++) { int j = listfull->firstneigh[i][jj]; j &= NEIGHMASK; @@ -160,7 +160,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) double jdelz = x[j][2] - x[i][2]; double rij_sq = jdelx*jdelx + jdely*jdely + jdelz*jdelz; - if(rij_sq < cutoff*cutoff) { + if (rij_sq < cutoff*cutoff) { double rij = sqrt(rij_sq); double partial_sum = 0; const int jtype = atom->type[j]; @@ -172,7 +172,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) nextTwoBodyInfo->del[1] = jdely / rij; nextTwoBodyInfo->del[2] = jdelz / rij; - for(int kk = 0; kk < numBonds; kk++) { + for (int kk = 0; kk < numBonds; kk++) { const MEAM2Body& bondk = twoBodyInfo[kk]; double cos_theta = (nextTwoBodyInfo->del[0]*bondk.del[0] + nextTwoBodyInfo->del[1]*bondk.del[1] + @@ -194,16 +194,16 @@ void PairMEAMSpline::compute(int eflag, int vflag) - zero_atom_energies[i_to_potl(itype)]; Uprime_values[i] = Uprime_i; - if(eflag) { - if(eflag_global) + if (eflag) { + if (eflag_global) eng_vdwl += embeddingEnergy; - if(eflag_atom) + if (eflag_atom) eatom[i] += embeddingEnergy; } // Compute three-body contributions to force double forces_i[3] = {0, 0, 0}; - for(int jj = 0; jj < numBonds; jj++) { + for (int jj = 0; jj < numBonds; jj++) { const MEAM2Body bondj = twoBodyInfo[jj]; double rij = bondj.r; int j = bondj.tag; @@ -215,7 +215,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) const int jtype = atom->type[j]; MEAM2Body const* bondk = twoBodyInfo; - for(int kk = 0; kk < jj; kk++, ++bondk) { + for (int kk = 0; kk < jj; kk++, ++bondk) { double rik = bondk->r; double cos_theta = (bondj.del[0]*bondk->del[0] + @@ -256,7 +256,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) forces[k][1] += fk[1]; forces[k][2] += fk[2]; - if(evflag) { + if (evflag) { double delta_ij[3]; double delta_ik[3]; delta_ij[0] = bondj.del[0] * rij; @@ -287,11 +287,11 @@ void PairMEAMSpline::compute(int eflag, int vflag) comm->forward_comm_pair(this); // Compute two-body pair interactions - for(int ii = 0; ii < listhalf->inum; ii++) { + for (int ii = 0; ii < listhalf->inum; ii++) { int i = listhalf->ilist[ii]; const int itype = atom->type[i]; - for(int jj = 0; jj < listhalf->numneigh[i]; jj++) { + for (int jj = 0; jj < listhalf->numneigh[i]; jj++) { int j = listhalf->firstneigh[i][jj]; j &= NEIGHMASK; @@ -301,7 +301,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) jdel[2] = x[j][2] - x[i][2]; double rij_sq = jdel[0]*jdel[0] + jdel[1]*jdel[1] + jdel[2]*jdel[2]; - if(rij_sq < cutoff*cutoff) { + if (rij_sq < cutoff*cutoff) { double rij = sqrt(rij_sq); const int jtype = atom->type[j]; @@ -330,7 +330,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) } } - if(vflag_fdotr) + if (vflag_fdotr) virial_fdotr_compute(); } @@ -375,7 +375,7 @@ void PairMEAMSpline::allocate() void PairMEAMSpline::settings(int narg, char **/*arg*/) { - if(narg != 0) error->all(FLERR,"Illegal pair_style command"); + if (narg != 0) error->all(FLERR,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -457,9 +457,9 @@ void PairMEAMSpline::read_file(const char* filename) { int nmultichoose2; // = (n+1)*n/2; - if(comm->me == 0) { + if (comm->me == 0) { FILE *fp = utils::open_potential(filename,lmp,nullptr); - if(fp == nullptr) { + if (fp == nullptr) { char str[1024]; snprintf(str,128,"Cannot open spline MEAM potential file %s", filename); error->one(FLERR,str); @@ -568,18 +568,18 @@ void PairMEAMSpline::read_file(const char* filename) // Determine maximum cutoff radius of all relevant spline functions. cutoff = 0.0; for (int i = 0; i < nmultichoose2; i++) - if(phis[i].cutoff() > cutoff) + if (phis[i].cutoff() > cutoff) cutoff = phis[i].cutoff(); for (int i = 0; i < nelements; i++) - if(rhos[i].cutoff() > cutoff) + if (rhos[i].cutoff() > cutoff) cutoff = rhos[i].cutoff(); for (int i = 0; i < nelements; i++) - if(fs[i].cutoff() > cutoff) + if (fs[i].cutoff() > cutoff) cutoff = fs[i].cutoff(); // Set LAMMPS pair interaction flags. - for(int i = 1; i <= atom->ntypes; i++) { - for(int j = 1; j <= atom->ntypes; j++) { + for (int i = 1; i <= atom->ntypes; i++) { + for (int j = 1; j <= atom->ntypes; j++) { // setflag[i][j] = 1; cutsq[i][j] = cutoff; } @@ -592,7 +592,7 @@ void PairMEAMSpline::read_file(const char* filename) ------------------------------------------------------------------------- */ void PairMEAMSpline::init_style() { - if(force->newton_pair == 0) + if (force->newton_pair == 0) error->all(FLERR,"Pair style meam/spline requires newton pair on"); // Need both full and half neighbor list. @@ -613,8 +613,8 @@ void PairMEAMSpline::init_style() ------------------------------------------------------------------------- */ void PairMEAMSpline::init_list(int id, NeighList *ptr) { - if(id == 1) listfull = ptr; - else if(id == 2) listhalf = ptr; + if (id == 1) listfull = ptr; + else if (id == 2) listhalf = ptr; } /* ---------------------------------------------------------------------- @@ -679,7 +679,7 @@ void PairMEAMSpline::SplineFunction::parse(FILE* fp, Error* error, // Parse number of spline knots. utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); int n = atoi(line); - if(n < 2) + if (n < 2) error->one(FLERR,"Invalid number of spline knots in MEAM potential file"); // Parse first derivatives at beginning and end of spline. @@ -693,10 +693,10 @@ void PairMEAMSpline::SplineFunction::parse(FILE* fp, Error* error, utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); // Parse knot coordinates. - for(int i=0; ione(FLERR,"Invalid knot line in MEAM potential file"); } setKnot(i, x, y); @@ -718,36 +718,36 @@ void PairMEAMSpline::SplineFunction::prepareSpline(Error* error) double* u = new double[N]; Y2[0] = -0.5; u[0] = (3.0/(X[1]-X[0])) * ((Y[1]-Y[0])/(X[1]-X[0]) - deriv0); - for(int i = 1; i <= N-2; i++) { + for (int i = 1; i <= N-2; i++) { double sig = (X[i]-X[i-1]) / (X[i+1]-X[i-1]); double p = sig * Y2[i-1] + 2.0; Y2[i] = (sig - 1.0) / p; u[i] = (Y[i+1]-Y[i]) / (X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]); u[i] = (6.0 * u[i]/(X[i+1]-X[i-1]) - sig*u[i-1])/p; - if(fabs(h*i+xmin - X[i]) > 1e-8) + if (fabs(h*i+xmin - X[i]) > 1e-8) isGridSpline = false; } double qn = 0.5; double un = (3.0/(X[N-1]-X[N-2])) * (derivN - (Y[N-1]-Y[N-2])/(X[N-1]-X[N-2])); Y2[N-1] = (un - qn*u[N-2]) / (qn * Y2[N-2] + 1.0); - for(int k = N-2; k >= 0; k--) { + for (int k = N-2; k >= 0; k--) { Y2[k] = Y2[k] * Y2[k+1] + u[k]; } delete[] u; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(!isGridSpline) + if (!isGridSpline) error->one(FLERR,"Support for MEAM potentials with non-uniform cubic splines has not been enabled in the MEAM potential code. Set SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES in pair_spline_meam.h to 1 to enable it"); #endif // Shift the spline to X=0 to speed up interpolation. - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { Xs[i] = X[i] - xmin; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; + if (i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; Y2[i] /= h*6.0; #endif } @@ -768,7 +768,7 @@ void PairMEAMSpline::SplineFunction::communicate(MPI_Comm& world, int me) MPI_Bcast(&h, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&hsq, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&inv_h, 1, MPI_DOUBLE, 0, world); - if(me != 0) { + if (me != 0) { X = new double[N]; Xs = new double[N]; Y = new double[N]; @@ -790,18 +790,18 @@ void PairMEAMSpline::SplineFunction::writeGnuplot(const char* filename, { FILE* fp = fopen(filename, "w"); fprintf(fp, "#!/usr/bin/env gnuplot\n"); - if(title) fprintf(fp, "set title \"%s\"\n", title); + if (title) fprintf(fp, "set title \"%s\"\n", title); double tmin = X[0] - (X[N-1] - X[0]) * 0.05; double tmax = X[N-1] + (X[N-1] - X[0]) * 0.05; double delta = (tmax - tmin) / (N*200); fprintf(fp, "set xrange [%f:%f]\n", tmin, tmax); fprintf(fp, "plot '-' with lines notitle, '-' with points notitle pt 3 lc 3\n"); - for(double x = tmin; x <= tmax+1e-8; x += delta) { + for (double x = tmin; x <= tmax+1e-8; x += delta) { double y = eval(x); fprintf(fp, "%f %f\n", x, y); } fprintf(fp, "e\n"); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { fprintf(fp, "%f %f\n", X[i], Y[i]); } fprintf(fp, "e\n"); diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index 17511e90b8..09f5fa436d 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -74,7 +74,7 @@ PairMEAMSWSpline::~PairMEAMSWSpline() memory->destroy(Uprime_values); //memory->destroy(ESWprime_values); - if(allocated) { + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); delete [] map; @@ -112,14 +112,14 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) // Determine the maximum number of neighbors a single atom has int newMaxNeighbors = 0; - for(int ii = 0; ii < inum_full; ii++) { + for (int ii = 0; ii < inum_full; ii++) { int jnum = numneigh_full[ilist_full[ii]]; - if(jnum > newMaxNeighbors) newMaxNeighbors = jnum; + if (jnum > newMaxNeighbors) newMaxNeighbors = jnum; } // Allocate array for temporary bond info - if(newMaxNeighbors > maxNeighbors) { + if (newMaxNeighbors > maxNeighbors) { maxNeighbors = newMaxNeighbors; delete[] twoBodyInfo; twoBodyInfo = new MEAM2Body[maxNeighbors]; @@ -128,7 +128,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) // Sum three-body contributions to charge density and // compute embedding energies - for(int ii = 0; ii < inum_full; ii++) { + for (int ii = 0; ii < inum_full; ii++) { int i = ilist_full[ii]; double xtmp = x[i][0]; double ytmp = x[i][1]; @@ -140,7 +140,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) int numBonds = 0; MEAM2Body* nextTwoBodyInfo = twoBodyInfo; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; j &= NEIGHMASK; @@ -149,7 +149,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) double jdelz = x[j][2] - ztmp; double rij_sq = jdelx*jdelx + jdely*jdely + jdelz*jdelz; - if(rij_sq < cutforcesq) { + if (rij_sq < cutforcesq) { double rij = sqrt(rij_sq); double partial_sum = 0; double partial_sum2 = 0; @@ -162,7 +162,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) nextTwoBodyInfo->del[1] = jdely / rij; nextTwoBodyInfo->del[2] = jdelz / rij; - for(int kk = 0; kk < numBonds; kk++) { + for (int kk = 0; kk < numBonds; kk++) { const MEAM2Body& bondk = twoBodyInfo[kk]; double cos_theta = (nextTwoBodyInfo->del[0]*bondk.del[0] + nextTwoBodyInfo->del[1]*bondk.del[1] + @@ -188,16 +188,16 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) double ESWprime_i = 1.0; Uprime_values[i] = Uprime_i; // ESWprime_values[i] = ESWprime_i; - if(eflag) { - if(eflag_global) eng_vdwl += embeddingEnergy + SWEnergy; - if(eflag_atom) eatom[i] += embeddingEnergy + SWEnergy; + if (eflag) { + if (eflag_global) eng_vdwl += embeddingEnergy + SWEnergy; + if (eflag_atom) eatom[i] += embeddingEnergy + SWEnergy; } double forces_i[3] = {0, 0, 0}; // Compute three-body contributions to force - for(int jj = 0; jj < numBonds; jj++) { + for (int jj = 0; jj < numBonds; jj++) { const MEAM2Body bondj = twoBodyInfo[jj]; double rij = bondj.r; int j = bondj.tag; @@ -210,7 +210,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) double forces_j[3] = {0, 0, 0}; MEAM2Body const* bondk = twoBodyInfo; - for(int kk = 0; kk < jj; kk++, ++bondk) { + for (int kk = 0; kk < jj; kk++, ++bondk) { double rik = bondk->r; double cos_theta = (bondj.del[0]*bondk->del[0] + @@ -268,7 +268,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) forces[k][1] += fk[1]; forces[k][2] += fk[2]; - if(evflag) { + if (evflag) { double delta_ij[3]; double delta_ik[3]; delta_ij[0] = bondj.del[0] * rij; @@ -305,7 +305,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) // Compute two-body pair interactions - for(int ii = 0; ii < inum_half; ii++) { + for (int ii = 0; ii < inum_half; ii++) { int i = ilist_half[ii]; double xtmp = x[i][0]; double ytmp = x[i][1]; @@ -313,7 +313,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) int* jlist = firstneigh_half[i]; int jnum = numneigh_half[i]; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; j &= NEIGHMASK; @@ -323,7 +323,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) jdel[2] = x[j][2] - ztmp; double rij_sq = jdel[0]*jdel[0] + jdel[1]*jdel[1] + jdel[2]*jdel[2]; - if(rij_sq < cutforcesq) { + if (rij_sq < cutforcesq) { double rij = sqrt(rij_sq); double rho_prime; @@ -350,7 +350,7 @@ void PairMEAMSWSpline::compute(int eflag, int vflag) } } - if(vflag_fdotr) virial_fdotr_compute(); + if (vflag_fdotr) virial_fdotr_compute(); } /* ---------------------------------------------------------------------- */ @@ -372,7 +372,7 @@ void PairMEAMSWSpline::allocate() void PairMEAMSWSpline::settings(int narg, char **/*arg*/) { - if(narg != 0) error->all(FLERR,"Illegal pair_style command"); + if (narg != 0) error->all(FLERR,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -460,9 +460,9 @@ void PairMEAMSWSpline::coeff(int narg, char **arg) void PairMEAMSWSpline::read_file(const char* filename) { - if(comm->me == 0) { + if (comm->me == 0) { FILE *fp = utils::open_potential(filename,lmp,nullptr); - if(fp == nullptr) { + if (fp == nullptr) { char str[1024]; snprintf(str,1024,"Cannot open spline MEAM potential file %s", filename); error->one(FLERR,str); @@ -498,14 +498,14 @@ void PairMEAMSWSpline::read_file(const char* filename) // Determine maximum cutoff radius of all relevant spline functions. cutoff = 0.0; - if(phi.cutoff() > cutoff) cutoff = phi.cutoff(); - if(rho.cutoff() > cutoff) cutoff = rho.cutoff(); - if(f.cutoff() > cutoff) cutoff = f.cutoff(); - if(F.cutoff() > cutoff) cutoff = F.cutoff(); + if (phi.cutoff() > cutoff) cutoff = phi.cutoff(); + if (rho.cutoff() > cutoff) cutoff = rho.cutoff(); + if (f.cutoff() > cutoff) cutoff = f.cutoff(); + if (F.cutoff() > cutoff) cutoff = F.cutoff(); // Set LAMMPS pair interaction flags. - for(int i = 1; i <= atom->ntypes; i++) { - for(int j = 1; j <= atom->ntypes; j++) { + for (int i = 1; i <= atom->ntypes; i++) { + for (int j = 1; j <= atom->ntypes; j++) { setflag[i][j] = 1; cutsq[i][j] = cutoff; } @@ -525,7 +525,7 @@ void PairMEAMSWSpline::read_file(const char* filename) ------------------------------------------------------------------------- */ void PairMEAMSWSpline::init_style() { - if(force->newton_pair == 0) + if (force->newton_pair == 0) error->all(FLERR,"Pair style meam/sw/spline requires newton pair on"); // Need both full and half neighbor list. @@ -543,8 +543,8 @@ void PairMEAMSWSpline::init_style() ------------------------------------------------------------------------- */ void PairMEAMSWSpline::init_list(int id, NeighList *ptr) { - if(id == 1) listfull = ptr; - else if(id == 2) listhalf = ptr; + if (id == 1) listfull = ptr; + else if (id == 2) listhalf = ptr; } /* ---------------------------------------------------------------------- @@ -604,7 +604,7 @@ void PairMEAMSWSpline::SplineFunction::parse(FILE* fp, Error* error) // Parse number of spline knots. utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); int n = atoi(line); - if(n < 2) + if (n < 2) error->one(FLERR,"Invalid number of spline knots in MEAM potential file"); // Parse first derivatives at beginning and end of spline. @@ -617,10 +617,10 @@ void PairMEAMSWSpline::SplineFunction::parse(FILE* fp, Error* error) utils::sfgets(FLERR,line,MAXLINE,fp,nullptr,error); // Parse knot coordinates. - for(int i=0; ione(FLERR,"Invalid knot line in MEAM potential file"); } setKnot(i, x, y); @@ -642,36 +642,36 @@ void PairMEAMSWSpline::SplineFunction::prepareSpline(Error* error) double* u = new double[N]; Y2[0] = -0.5; u[0] = (3.0/(X[1]-X[0])) * ((Y[1]-Y[0])/(X[1]-X[0]) - deriv0); - for(int i = 1; i <= N-2; i++) { + for (int i = 1; i <= N-2; i++) { double sig = (X[i]-X[i-1]) / (X[i+1]-X[i-1]); double p = sig * Y2[i-1] + 2.0; Y2[i] = (sig - 1.0) / p; u[i] = (Y[i+1]-Y[i]) / (X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]); u[i] = (6.0 * u[i]/(X[i+1]-X[i-1]) - sig*u[i-1])/p; - if(fabs(h*i+xmin - X[i]) > 1e-8) + if (fabs(h*i+xmin - X[i]) > 1e-8) isGridSpline = false; } double qn = 0.5; double un = (3.0/(X[N-1]-X[N-2])) * (derivN - (Y[N-1]-Y[N-2])/(X[N-1]-X[N-2])); Y2[N-1] = (un - qn*u[N-2]) / (qn * Y2[N-2] + 1.0); - for(int k = N-2; k >= 0; k--) { + for (int k = N-2; k >= 0; k--) { Y2[k] = Y2[k] * Y2[k+1] + u[k]; } delete[] u; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(!isGridSpline) + if (!isGridSpline) error->one(FLERR,"Support for MEAM potentials with non-uniform cubic splines has not been enabled in the MEAM potential code. Set SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES in pair_spline_meam.h to 1 to enable it"); #endif // Shift the spline to X=0 to speed up interpolation. - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { Xs[i] = X[i] - xmin; #if !SPLINE_MEAM_SUPPORT_NON_GRID_SPLINES - if(i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; + if (i < N-1) Ydelta[i] = (Y[i+1]-Y[i])/h; Y2[i] /= h*6.0; #endif } @@ -692,7 +692,7 @@ void PairMEAMSWSpline::SplineFunction::communicate(MPI_Comm& world, int me) MPI_Bcast(&h, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&hsq, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&inv_h, 1, MPI_DOUBLE, 0, world); - if(me != 0) { + if (me != 0) { X = new double[N]; Xs = new double[N]; Y = new double[N]; @@ -713,18 +713,18 @@ void PairMEAMSWSpline::SplineFunction::writeGnuplot(const char* filename, const { FILE* fp = fopen(filename, "w"); fprintf(fp, "#!/usr/bin/env gnuplot\n"); - if(title) fprintf(fp, "set title \"%s\"\n", title); + if (title) fprintf(fp, "set title \"%s\"\n", title); double tmin = X[0] - (X[N-1] - X[0]) * 0.05; double tmax = X[N-1] + (X[N-1] - X[0]) * 0.05; double delta = (tmax - tmin) / (N*200); fprintf(fp, "set xrange [%f:%f]\n", tmin, tmax); fprintf(fp, "plot '-' with lines notitle, '-' with points notitle pt 3 lc 3\n"); - for(double x = tmin; x <= tmax+1e-8; x += delta) { + for (double x = tmin; x <= tmax+1e-8; x += delta) { double y = eval(x); fprintf(fp, "%f %f\n", x, y); } fprintf(fp, "e\n"); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { fprintf(fp, "%f %f\n", X[i], Y[i]); } fprintf(fp, "e\n"); diff --git a/src/USER-MISC/pair_srp.cpp b/src/USER-MISC/pair_srp.cpp index 2dd8a675ab..d32d56f5b7 100644 --- a/src/USER-MISC/pair_srp.cpp +++ b/src/USER-MISC/pair_srp.cpp @@ -174,9 +174,9 @@ void PairSRP::compute(int eflag, int vflag) // mapping global to local for atoms inside bond particles // exclude 1-2 neighs if requested - if (neighbor->ago == 0){ + if (neighbor->ago == 0) { remapBonds(nall); - if(exclude) onetwoexclude(ilist, inum, jlist, numneigh, firstneigh); + if (exclude) onetwoexclude(ilist, inum, jlist, numneigh, firstneigh); } // this pair style only used with hybrid @@ -185,7 +185,7 @@ void PairSRP::compute(int eflag, int vflag) // each neigh j is type bptype // using midpoint distance option - if(midpoint){ + if (midpoint) { for (ii = 0; ii < inum; ii++) { @@ -215,7 +215,7 @@ void PairSRP::compute(int eflag, int vflag) dz = 0.5*(x[i0][2] - x[i1][2] + x[j0][2] - x[j1][2]); dijsq = dx*dx + dy*dy + dz*dz; - if (dijsq < cutsq[bptype][bptype]){ + if (dijsq < cutsq[bptype][bptype]) { dij = sqrt(dijsq); if (dij < SMALL) @@ -248,11 +248,11 @@ void PairSRP::compute(int eflag, int vflag) // ************************************************* // - if (eflag){ + if (eflag) { evdwl = 0.5 * a0[bptype][bptype] * cut[bptype][bptype] * wd * wd; } - if (evflag){ + if (evflag) { ev_tally(i0,i1,nlocal,1,0.5*evdwl,0.0,fpair,dx,dy,dz); ev_tally(j0,j1,nlocal,1,0.5*evdwl,0.0,fpair,dx,dy,dz); } @@ -289,7 +289,7 @@ void PairSRP::compute(int eflag, int vflag) getMinDist(x, dx, dy, dz, ti, tj, i0, j0, i1, j1); dijsq = dx*dx + dy*dy + dz*dz; - if (dijsq < cutsq[bptype][bptype]){ + if (dijsq < cutsq[bptype][bptype]) { dij = sqrt(dijsq); @@ -333,11 +333,11 @@ void PairSRP::compute(int eflag, int vflag) // ************************************************* // - if (eflag){ + if (eflag) { evdwl = 0.5 * a0[bptype][bptype] * cut[bptype][bptype] * wd * wd; } - if (evflag){ + if (evflag) { ev_tally(i0,i1,nlocal,1,0.5*evdwl,0.0,0.5*fpair,dx,dy,dz); ev_tally(j0,j1,nlocal,1,0.5*evdwl,0.0,0.5*fpair,dx,dy,dz); } @@ -394,7 +394,7 @@ void PairSRP::settings(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal pair srp command"); if (strcmp(arg[iarg+1],"yes") == 0) exclude = 1; - if (strcmp(arg[iarg+1],"no") == 0){ + if (strcmp(arg[iarg+1],"no") == 0) { if (min) error->all(FLERR,"Illegal exclude option in pair srp command"); exclude = 0; } @@ -552,8 +552,8 @@ inline void PairSRP::getMinDist(double** &x, double &dx, double &dy, double &dz, // handle case of parallel lines // reduce to midpt distance - if (fabs(denom) < SMALL){ - if(denom < 0) denom = -BIG; + if (fabs(denom) < SMALL) { + if (denom < 0) denom = -BIG; else denom = BIG; } @@ -586,7 +586,7 @@ map global id of atoms in stored by each bond particle ------------------------------------------------------- */ inline void PairSRP::remapBonds(int &nall) { - if(nall > maxcount){ + if (nall > maxcount) { memory->grow(segment, nall, 2, "pair:segment"); maxcount = nall; } @@ -600,7 +600,7 @@ inline void PairSRP::remapBonds(int &nall) srp = f_srp->array_atom; for (int i = 0; i < nall; i++) { - if(atom->type[i] == bptype){ + if (atom->type[i] == bptype) { // tmp is local id // tmp == -1 is ok tmp = atom->map((int)srp[i][0]); @@ -643,7 +643,7 @@ inline void PairSRP::onetwoexclude(int* &ilist, int &inum, int* &jlist, int* &nu j1 = segment[j][1]; // check for a 1-2 neigh - if(i0 == i1 || i0 == j1 || i1 == j0 || j0 == j1){ + if (i0 == i1 || i0 == j1 || i1 == j0 || j0 == j1) { j |= ONETWOBIT; jlist[jj] = j; } diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index c4e2d2c993..9eae918128 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -953,7 +953,7 @@ void PairTersoffTable::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/USER-OMP/dihedral_table_omp.cpp b/src/USER-OMP/dihedral_table_omp.cpp index 158f350b6d..6d6acc27e6 100644 --- a/src/USER-OMP/dihedral_table_omp.cpp +++ b/src/USER-OMP/dihedral_table_omp.cpp @@ -344,7 +344,7 @@ void DihedralTableOMP::eval(int nfrom, int nto, ThrData * const thr) // d U d U d phi // -f = ----- = ----- * ----- // d x d phi d x - for(int d=0; d < g_dim; ++d) { + for (int d=0; d < g_dim; ++d) { f1[d] = m_du_dphi * dphi_dx1[d]; f2[d] = m_du_dphi * dphi_dx2[d]; f3[d] = m_du_dphi * dphi_dx3[d]; diff --git a/src/USER-OMP/fix_nve_sphere_omp.cpp b/src/USER-OMP/fix_nve_sphere_omp.cpp index aba966b71d..5e66d0f2c7 100644 --- a/src/USER-OMP/fix_nve_sphere_omp.cpp +++ b/src/USER-OMP/fix_nve_sphere_omp.cpp @@ -126,7 +126,7 @@ void FixNVESphereOMP::initial_integrate(int /* vflag */) // Q = I + vx + vx^2 * (1-c)/s^2 const double s2 = a[0]*a[0] + a[1]*a[1]; - if (s2 != 0.0){ // i.e. the vectors are not parallel + if (s2 != 0.0) { // i.e. the vectors are not parallel const double scale = (1.0 - a[2])/s2; Q[0][0] = 1.0 - scale*a[0]*a[0]; Q[0][1] = -scale*a[0]*a[1]; Q[0][2] = -a[0]; diff --git a/src/USER-OMP/fix_qeq_comb_omp.cpp b/src/USER-OMP/fix_qeq_comb_omp.cpp index a0fb934bf8..957c49abe6 100644 --- a/src/USER-OMP/fix_qeq_comb_omp.cpp +++ b/src/USER-OMP/fix_qeq_comb_omp.cpp @@ -135,7 +135,7 @@ void FixQEQCombOMP::post_force(int /* vflag */) } comm->forward_comm_fix(this); - if(comb) enegtot = comb->yasu_char(qf,igroup); + if (comb) enegtot = comb->yasu_char(qf,igroup); enegtot /= ngroup; enegchk = enegmax = 0.0; diff --git a/src/USER-OMP/pair_agni_omp.cpp b/src/USER-OMP/pair_agni_omp.cpp index 0582133d6c..393503badb 100644 --- a/src/USER-OMP/pair_agni_omp.cpp +++ b/src/USER-OMP/pair_agni_omp.cpp @@ -137,7 +137,7 @@ void PairAGNIOMP::eval(int iifrom, int iito, ThrData * const thr) double ky = 0.0; double kz = 0.0; - for(int k = 0; k < iparam.numeta; ++k) { + for (int k = 0; k < iparam.numeta; ++k) { const double xu = iparam.xU[k][j]; kx += square(Vx[k] - xu); ky += square(Vy[k] - xu); diff --git a/src/USER-OMP/pair_brownian_omp.cpp b/src/USER-OMP/pair_brownian_omp.cpp index b7405a2605..2841c5e840 100644 --- a/src/USER-OMP/pair_brownian_omp.cpp +++ b/src/USER-OMP/pair_brownian_omp.cpp @@ -79,20 +79,20 @@ void PairBrownianOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_brownian_poly_omp.cpp b/src/USER-OMP/pair_brownian_poly_omp.cpp index d7aef4b8b9..d02d13a74e 100644 --- a/src/USER-OMP/pair_brownian_poly_omp.cpp +++ b/src/USER-OMP/pair_brownian_poly_omp.cpp @@ -79,20 +79,20 @@ void PairBrownianPolyOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_comb_omp.cpp b/src/USER-OMP/pair_comb_omp.cpp index e535a3529e..045db5d402 100644 --- a/src/USER-OMP/pair_comb_omp.cpp +++ b/src/USER-OMP/pair_comb_omp.cpp @@ -242,7 +242,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) jtype = map[type[j]]; iparam_ij = elem2param[itype][jtype][jtype]; - if(params[iparam_ij].hfocor > 0.0 ) { + if (params[iparam_ij].hfocor > 0.0 ) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; diff --git a/src/USER-OMP/pair_eam_alloy_omp.cpp b/src/USER-OMP/pair_eam_alloy_omp.cpp index 81bd6474d0..37cc1aa6f1 100644 --- a/src/USER-OMP/pair_eam_alloy_omp.cpp +++ b/src/USER-OMP/pair_eam_alloy_omp.cpp @@ -116,7 +116,7 @@ void PairEAMAlloyOMP::read_file(char *filename) Setfl *file = setfl; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/alloy", unit_convert_flag); diff --git a/src/USER-OMP/pair_eam_fs_omp.cpp b/src/USER-OMP/pair_eam_fs_omp.cpp index c7cd02ba4b..41a2a2eeba 100644 --- a/src/USER-OMP/pair_eam_fs_omp.cpp +++ b/src/USER-OMP/pair_eam_fs_omp.cpp @@ -116,7 +116,7 @@ void PairEAMFSOMP::read_file(char *filename) Fs *file = fs; // read potential file - if(comm->me == 0) { + if (comm->me == 0) { PotentialFileReader reader(PairEAM::lmp, filename, "eam/fs", unit_convert_flag); diff --git a/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp b/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp index ab84b374cb..33968f1710 100644 --- a/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp @@ -146,7 +146,7 @@ void PairLJCutTholeLongOMP::eval(int iifrom, int iito, ThrData * const thr) jnum = numneigh[i]; fxtmp=fytmp=fztmp=0.; - if (drudetype[type[i]] != NOPOL_TYPE){ + if (drudetype[type[i]] != NOPOL_TYPE) { di = atom->map(drudeid[i]); if (di < 0) error->all(FLERR, "Drude partner not found"); di_closest = domain->closest_image(i, di); @@ -202,9 +202,9 @@ void PairLJCutTholeLongOMP::eval(int iifrom, int iito, ThrData * const thr) } if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE){ - if (j != di_closest){ - if (drudetype[type[j]] == CORE_TYPE){ + drudetype[type[j]] != NOPOL_TYPE) { + if (j != di_closest) { + if (drudetype[type[j]] == CORE_TYPE) { dj = atom->map(drudeid[j]); dqj = -q[dj]; } else dqj = qj; @@ -246,7 +246,7 @@ void PairLJCutTholeLongOMP::eval(int iifrom, int iito, ThrData * const thr) } if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; if (drudetype[type[i]] != NOPOL_TYPE && - drudetype[type[j]] != NOPOL_TYPE && j != di_closest){ + drudetype[type[j]] != NOPOL_TYPE && j != di_closest) { ecoul += factor_e * dcoul; } } else ecoul = 0.0; diff --git a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp index f2c8799415..7c258fb94c 100644 --- a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp @@ -718,7 +718,7 @@ void PairLJLongCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr) if (rsq < cut_ljsqi[typej]) { // lj if (ORDER6) { // long-range lj - if(!LJTABLE || rsq <= tabinnerdispsq) { //series real space + if (!LJTABLE || rsq <= tabinnerdispsq) { //series real space double rn = r2inv*r2inv*r2inv; double x2 = g2*rsq, a2 = 1.0/x2; x2 = a2*exp(-x2)*lj4i[typej]; diff --git a/src/USER-OMP/pair_lubricate_omp.cpp b/src/USER-OMP/pair_lubricate_omp.cpp index d78bda9b42..4291850820 100644 --- a/src/USER-OMP/pair_lubricate_omp.cpp +++ b/src/USER-OMP/pair_lubricate_omp.cpp @@ -65,20 +65,20 @@ void PairLubricateOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_lubricate_poly_omp.cpp b/src/USER-OMP/pair_lubricate_poly_omp.cpp index 10738be70a..4226c96e1b 100644 --- a/src/USER-OMP/pair_lubricate_poly_omp.cpp +++ b/src/USER-OMP/pair_lubricate_poly_omp.cpp @@ -65,20 +65,20 @@ void PairLubricatePolyOMP::compute(int eflag, int vflag) double dims[3], wallcoord; if (flagVF) // Flag for volume fraction corrections - if (flagdeform || flagwall == 2){ // Possible changes in volume fraction + if (flagdeform || flagwall == 2) { // Possible changes in volume fraction if (flagdeform && !flagwall) for (int j = 0; j < 3; j++) dims[j] = domain->prd[j]; - else if (flagwall == 2 || (flagdeform && flagwall == 1)){ + else if (flagwall == 2 || (flagdeform && flagwall == 1)) { double wallhi[3], walllo[3]; - for (int j = 0; j < 3; j++){ + for (int j = 0; j < 3; j++) { wallhi[j] = domain->prd[j]; walllo[j] = 0; } - for (int m = 0; m < wallfix->nwall; m++){ + for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE){ + if (wallfix->xstyle[m] == VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/USER-OMP/pair_meam_spline_omp.cpp b/src/USER-OMP/pair_meam_spline_omp.cpp index 500a3d17c7..bb8ab8af7c 100644 --- a/src/USER-OMP/pair_meam_spline_omp.cpp +++ b/src/USER-OMP/pair_meam_spline_omp.cpp @@ -93,9 +93,9 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) // Determine the maximum number of neighbors a single atom has. int myMaxNeighbors = 0; - for(int ii = iifrom; ii < iito; ii++) { + for (int ii = iifrom; ii < iito; ii++) { int jnum = numneigh_full[ilist_full[ii]]; - if(jnum > myMaxNeighbors) myMaxNeighbors = jnum; + if (jnum > myMaxNeighbors) myMaxNeighbors = jnum; } // Allocate array for temporary bond info. @@ -113,7 +113,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) const double cutforcesq = cutoff*cutoff; // Sum three-body contributions to charge density and compute embedding energies. - for(int ii = iifrom; ii < iito; ii++) { + for (int ii = iifrom; ii < iito; ii++) { const int i = ilist_full[ii]; const double xtmp = x[i][0]; @@ -125,7 +125,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) int numBonds = 0; MEAM2Body* nextTwoBodyInfo = myTwoBodyInfo; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { const int j = jlist[jj] & NEIGHMASK; const double jdelx = x[j][0] - xtmp; @@ -145,7 +145,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) nextTwoBodyInfo->del[1] = jdely / rij; nextTwoBodyInfo->del[2] = jdelz / rij; - for(int kk = 0; kk < numBonds; kk++) { + for (int kk = 0; kk < numBonds; kk++) { const MEAM2Body& bondk = myTwoBodyInfo[kk]; double cos_theta = (nextTwoBodyInfo->del[0]*bondk.del[0] + nextTwoBodyInfo->del[1]*bondk.del[1] + @@ -173,7 +173,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) double forces_i[3] = {0.0, 0.0, 0.0}; // Compute three-body contributions to force. - for(int jj = 0; jj < numBonds; jj++) { + for (int jj = 0; jj < numBonds; jj++) { const MEAM2Body bondj = myTwoBodyInfo[jj]; const double rij = bondj.r; const int j = bondj.tag; @@ -185,7 +185,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) double forces_j[3] = {0.0, 0.0, 0.0}; MEAM2Body const* bondk = myTwoBodyInfo; - for(int kk = 0; kk < jj; kk++, ++bondk) { + for (int kk = 0; kk < jj; kk++, ++bondk) { const double rik = bondk->r; const double cos_theta = (bondj.del[0]*bondk->del[0] @@ -226,7 +226,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) forces[k][1] += fk[1]; forces[k][2] += fk[2]; - if(EVFLAG) { + if (EVFLAG) { double delta_ij[3]; double delta_ik[3]; delta_ij[0] = bondj.del[0] * rij; @@ -277,7 +277,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) const int* const * const firstneigh_half = listhalf->firstneigh; // Compute two-body pair interactions. - for(int ii = iifrom; ii < iito; ii++) { + for (int ii = iifrom; ii < iito; ii++) { const int i = ilist_half[ii]; const double xtmp = x[i][0]; const double ytmp = x[i][1]; @@ -286,7 +286,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) const int jnum = numneigh_half[i]; const int itype = atom->type[i]; - for(int jj = 0; jj < jnum; jj++) { + for (int jj = 0; jj < jnum; jj++) { const int j = jlist[jj] & NEIGHMASK; double jdel[3]; @@ -295,7 +295,7 @@ void PairMEAMSplineOMP::eval(int iifrom, int iito, ThrData * const thr) jdel[2] = x[j][2] - ztmp; double rij_sq = jdel[0]*jdel[0] + jdel[1]*jdel[1] + jdel[2]*jdel[2]; - if(rij_sq < cutforcesq) { + if (rij_sq < cutforcesq) { double rij = sqrt(rij_sq); const int jtype = atom->type[j]; diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index 459113bfb8..b717f87d0f 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -241,7 +241,7 @@ void PairReaxCOMP::compute(int eflag, int vflag) #if defined(_OPENMP) #pragma omp parallel for schedule(static) #endif - for(int k = 0; k < system->N; ++k) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -293,7 +293,7 @@ void PairReaxCOMP::compute(int eflag, int vflag) // populate tmpid and tmpbo arrays for fix reax/c/species - if(fixspecies_flag) { + if (fixspecies_flag) { if (system->N > nmax) { memory->destroy(tmpid); memory->destroy(tmpbo); @@ -365,7 +365,7 @@ void PairReaxCOMP::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for( int i = 0; i < LIST_N; ++i ) + for ( int i = 0; i < LIST_N; ++i ) lists[i].allocated = 0; if (fix_reax == nullptr) { @@ -424,7 +424,7 @@ void PairReaxCOMP::setup( ) write_reax_atoms(); int num_nbrs = estimate_reax_lists(); - if(!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, + if (!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, lists+FAR_NBRS)) error->all(FLERR,"Pair reax/c problem in far neighbor list"); @@ -433,7 +433,7 @@ void PairReaxCOMP::setup( ) InitializeOMP( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for( int k = 0; k < system->N; ++k ) { + for ( int k = 0; k < system->N; ++k ) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -446,7 +446,7 @@ void PairReaxCOMP::setup( ) // reset the bond list info for new atoms - for(int k = oldN; k < system->N; ++k) + for (int k = oldN; k < system->N; ++k) Set_End_Index( k, Start_Index( k, lists+BONDS ), lists+BONDS ); // estimate far neighbor list size @@ -472,7 +472,7 @@ void PairReaxCOMP::write_reax_atoms() #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for( int i = 0; i < system->N; ++i ){ + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -596,7 +596,7 @@ void PairReaxCOMP::read_reax_forces(int /* vflag */) #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for( int i = 0; i < system->N; ++i ) { + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -622,7 +622,7 @@ void PairReaxCOMP::FindBond() bond_data *bo_ij; nj = 0; - for( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; diff --git a/src/USER-OMP/pair_tersoff_zbl_omp.cpp b/src/USER-OMP/pair_tersoff_zbl_omp.cpp index d721565d99..44d7994c9e 100644 --- a/src/USER-OMP/pair_tersoff_zbl_omp.cpp +++ b/src/USER-OMP/pair_tersoff_zbl_omp.cpp @@ -190,7 +190,7 @@ void PairTersoffZBLOMP::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/USER-OMP/reaxc_bond_orders_omp.cpp b/src/USER-OMP/reaxc_bond_orders_omp.cpp index 6253df7fe7..ec93d9478d 100644 --- a/src/USER-OMP/reaxc_bond_orders_omp.cpp +++ b/src/USER-OMP/reaxc_bond_orders_omp.cpp @@ -164,7 +164,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: i neighbor - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -194,7 +194,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: j neighbor - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -274,7 +274,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, * forces related to atom i * * first neighbors of atom i * ************************************/ - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -307,7 +307,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, /* force */ rvec_Add(workspace->forceReduction[reductionOffset+i],temp ); - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -463,7 +463,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #endif for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; workspace->Deltap_boc[i] = @@ -483,7 +483,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #endif for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); val_i = sbp_i->valency; Deltap_i = workspace->Deltap[i]; @@ -494,7 +494,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; bo_ij = &( bonds->select.bond_list[pj].bo_data ); if (i < j || workspace->bond_mark[j] > 3) { @@ -652,14 +652,14 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #endif for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; start_i = Start_Index(i, bonds); end_i = End_Index(i, bonds); for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; if (i < j || workspace->bond_mark[j] > 3) { // Computed in previous for-loop @@ -692,9 +692,9 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(j = 0; j < system->N; ++j ) { + for (j = 0; j < system->N; ++j ) { type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; diff --git a/src/USER-OMP/reaxc_bonds_omp.cpp b/src/USER-OMP/reaxc_bonds_omp.cpp index 413d50d0f9..30d50a4e70 100644 --- a/src/USER-OMP/reaxc_bonds_omp.cpp +++ b/src/USER-OMP/reaxc_bonds_omp.cpp @@ -174,7 +174,7 @@ void BondsOMP( reax_system *system, control_params * /* control */, } } } - } // for(i) + } // for (i) } // omp diff --git a/src/USER-OMP/reaxc_forces_omp.cpp b/src/USER-OMP/reaxc_forces_omp.cpp index 849c239ed0..68ab6f933d 100644 --- a/src/USER-OMP/reaxc_forces_omp.cpp +++ b/src/USER-OMP/reaxc_forces_omp.cpp @@ -92,7 +92,7 @@ void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control, #endif /* Implement all force calls as function pointers */ - for( i = 0; i < NUM_INTRS; i++ ) { + for ( i = 0; i < NUM_INTRS; i++ ) { (Interaction_Functions[i])( system, control, data, workspace, lists, out_control ); } @@ -199,7 +199,7 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, // Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); // } - if(control->virial == 0) { + if (control->virial == 0) { #if defined(_OPENMP) #pragma omp for schedule(dynamic,50) @@ -225,7 +225,7 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); } - } // if(virial == 0) + } // if (virial == 0) pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, 0, 1, thr); @@ -284,7 +284,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(int i = 0; i < N; ++i ) { + for (int i = 0; i < N; ++i ) { system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); if (i < N-1) @@ -308,7 +308,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(int i = 0; i < n; ++i ) { + for (int i = 0; i < n; ++i ) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { system->my_atoms[i].num_hbonds = @@ -395,7 +395,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); - for( pj = start_i; pj < end_i; ++pj ) { + for ( pj = start_i; pj < end_i; ++pj ) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); if (nbr_pj->d <= cutoff) { int j = nbr_pj->nbr; @@ -445,7 +445,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, BO = BO_s + BO_pi + BO_pi2; // End top portion of BOp() - if(BO >= bo_cut) { + if (BO >= bo_cut) { int btop_j; // Update indices in critical section @@ -478,12 +478,12 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, btop_i++; num_bonds++; - } // if(BO>=bo_cut) + } // if (BO>=bo_cut) - } // if(cutoff) + } // if (cutoff) - } // for(pj) - } // for(i) + } // for (pj) + } // for (i) // Need to wait for all indices and tmp arrays accumulated. #if defined(_OPENMP) @@ -493,8 +493,8 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, #if defined(_OPENMP) #pragma omp for schedule(dynamic,50) #endif - for(int i=0; iN; i++) - for(int t=0; tN; i++) + for (int t=0; tN + i; workspace->dDeltap_self[i][0] += tmp_ddelta[indx][0]; workspace->dDeltap_self[i][1] += tmp_ddelta[indx][1]; @@ -529,7 +529,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); type_j = atom_j->type; - if(type_j < 0) continue; + if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[type_j]); jhb = sbp_j->p_hbond; @@ -537,30 +537,30 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, int iflag = 0; int jflag = 0; - if(ihb==1 && jhb==2) iflag = 1; - else if(jn && ihb == 2 && jhb == 1) jflag = 1; + if (ihb==1 && jhb==2) iflag = 1; + else if (jn && ihb == 2 && jhb == 1) jflag = 1; - if(iflag || jflag) { - if(iflag) { + if (iflag || jflag) { + if (iflag) { ihb_top = End_Index(atom_i->Hindex, hbonds); Set_End_Index(atom_i->Hindex, ihb_top+1, hbonds); - } else if(jflag) { + } else if (jflag) { jhb_top = End_Index(atom_j->Hindex, hbonds); Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); } - if(iflag) { + if (iflag) { hbonds->select.hbond_list[ihb_top].nbr = j; hbonds->select.hbond_list[ihb_top].scl = 1; hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; - } else if(jflag) { + } else if (jflag) { hbonds->select.hbond_list[jhb_top].nbr = i; hbonds->select.hbond_list[jhb_top].scl = -1; hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; } num_hbonds++; - } // if(iflag || jflag) + } // if (iflag || jflag) } } @@ -569,13 +569,13 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, } // omp critical } - } // if(control->hbond > 0) + } // if (control->hbond > 0) // Zero buffers for others to use as intended. #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for(int i=0; imy_atoms[j].Hindex, hbonds ); hb_end_j = End_Index( system->my_atoms[j].Hindex, hbonds ); - if(type_j < 0) continue; + if (type_j < 0) continue; top = 0; for( pi = start_j; pi < end_j; ++pi ) { pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; bo_ij = &(pbond_ij->bo_data); - if( system->reax_param.sbp[type_i].p_hbond == 2 && + if ( system->reax_param.sbp[type_i].p_hbond == 2 && bo_ij->BO >= HB_THRESHOLD ) hblist[top++] = pi; } @@ -140,7 +140,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; - if(type_k < 0) continue; + if (type_k < 0) continue; nbr_jk = hbond_list[pk].ptr; r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); @@ -153,7 +153,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, if (system->my_atoms[i].orig_id != system->my_atoms[k].orig_id) { bo_ij = &(pbond_ij->bo_data); type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; hbp = &(system->reax_param.hbp[ type_i ][ type_j ][ type_k ]); ++num_hb_intrs; diff --git a/src/USER-OMP/reaxc_init_md_omp.cpp b/src/USER-OMP/reaxc_init_md_omp.cpp index af982443cb..1312953180 100644 --- a/src/USER-OMP/reaxc_init_md_omp.cpp +++ b/src/USER-OMP/reaxc_init_md_omp.cpp @@ -68,26 +68,26 @@ int Init_ListsOMP(reax_system *system, control_params *control, if (control->hbond_cut > 0) { /* init H indexes */ total_hbonds = 0; - for(i = 0; i < system->n; ++i) { + for (i = 0; i < system->n; ++i) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); - if(!Make_List(system->Hcap, total_hbonds, TYP_HBOND, + if (!Make_List(system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS)) { error->one(FLERR, "Not enough space for hbonds list. Terminating!"); } } total_bonds = 0; - for(i = 0; i < system->N; ++i) { + for (i = 0; i < system->N; ++i) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); - if(!Make_List(system->total_cap, bond_cap, TYP_BOND, + if (!Make_List(system->total_cap, bond_cap, TYP_BOND, *lists+BONDS)) { error->one(FLERR, "Not enough space for bonds list. Terminating!\n"); } @@ -101,8 +101,8 @@ int Init_ListsOMP(reax_system *system, control_params *control, /* 3bodies list */ cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); - if(!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, - *lists+THREE_BODIES)){ + if (!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, + *lists+THREE_BODIES)) { error->one(FLERR, "Problem in initializing angles list. Terminating!"); } diff --git a/src/USER-OMP/reaxc_multi_body_omp.cpp b/src/USER-OMP/reaxc_multi_body_omp.cpp index 86ba98631a..52ef7048d6 100644 --- a/src/USER-OMP/reaxc_multi_body_omp.cpp +++ b/src/USER-OMP/reaxc_multi_body_omp.cpp @@ -106,7 +106,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, #endif for ( i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[ type_i ]); /* lone-pair Energy */ @@ -120,7 +120,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, numbonds ++; /* calculate the energy */ - if(numbonds > 0) + if (numbonds > 0) total_Elp += e_lp = p_lp2 * workspace->Delta_lp[i] * inv_expvd2; @@ -128,7 +128,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, 75 * p_lp2 * workspace->Delta_lp[i] * expvd2 * SQR(inv_expvd2); CElp = dElp * workspace->dDelta_lp[i]; - if(numbonds > 0) workspace->CdDelta[i] += CElp; // lp - 1st term + if (numbonds > 0) workspace->CdDelta[i] += CElp; // lp - 1st term /* tally into per-atom energy */ if (system->pair_ptr->evflag) @@ -140,7 +140,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; if (!strcmp( system->reax_param.sbp[type_j].name, "C" )) { twbp = &( system->reax_param.tbp[type_i][type_j]); @@ -171,7 +171,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, #endif for (i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[ type_i ]); /* over-coordination energy */ @@ -184,7 +184,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; bo_ij = &(bonds->select.bond_list[pj].bo_data); twbp = &(system->reax_param.tbp[ type_i ][ type_j ]); @@ -230,7 +230,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) numbonds ++; - if(numbonds > 0) total_Eun += e_un = + if (numbonds > 0) total_Eun += e_un = -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; CEunder1 = inv_exp_ovun2n * @@ -244,14 +244,14 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, /* tally into per-atom energy */ if (system->pair_ptr->evflag) { eng_tmp = e_ov; - if(numbonds > 0) eng_tmp+= e_un; + if (numbonds > 0) eng_tmp+= e_un; pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, i, system->n, 1, eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); } /* forces */ workspace->CdDelta[i] += CEover3; // OvCoor - 2nd term - if(numbonds > 0) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term + if (numbonds > 0) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { pbond = &(bonds->select.bond_list[pj]); diff --git a/src/USER-OMP/reaxc_nonbonded_omp.cpp b/src/USER-OMP/reaxc_nonbonded_omp.cpp index 301dbe8479..ce463c39ff 100644 --- a/src/USER-OMP/reaxc_nonbonded_omp.cpp +++ b/src/USER-OMP/reaxc_nonbonded_omp.cpp @@ -97,7 +97,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, #pragma omp for schedule(guided) #endif for( i = 0; i < natoms; ++i ) { - if(system->my_atoms[i].type < 0) continue; + if (system->my_atoms[i].type < 0) continue; start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); orig_i = system->my_atoms[i].orig_id; @@ -108,8 +108,8 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { - if(j < natoms) flag = 1; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { if (nbr_pj->dvec[2] > SMALL) flag = 1; @@ -145,7 +145,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, dTap += workspace->Tap[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -174,7 +174,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // innner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); total_EvdW += Tap * e_core; @@ -293,7 +293,7 @@ void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *contro #endif for (i = 0; i < natoms; ++i) { type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if (type_i < 0) continue; start_i = Start_Index(i,far_nbrs); end_i = End_Index(i,far_nbrs); orig_i = system->my_atoms[i].orig_id; @@ -302,12 +302,12 @@ void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *contro nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { - if(j < natoms) flag = 1; + if (nbr_pj->d <= control->nonb_cut) { + if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { if (nbr_pj->dvec[2] > SMALL) flag = 1; diff --git a/src/USER-OMP/reaxc_torsion_angles_omp.cpp b/src/USER-OMP/reaxc_torsion_angles_omp.cpp index 2b9afae341..79fa9e0f47 100644 --- a/src/USER-OMP/reaxc_torsion_angles_omp.cpp +++ b/src/USER-OMP/reaxc_torsion_angles_omp.cpp @@ -202,7 +202,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; @@ -241,7 +241,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-OMP/reaxc_valence_angles_omp.cpp b/src/USER-OMP/reaxc_valence_angles_omp.cpp index c42b97958f..8b6f1e7617 100644 --- a/src/USER-OMP/reaxc_valence_angles_omp.cpp +++ b/src/USER-OMP/reaxc_valence_angles_omp.cpp @@ -177,7 +177,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, pair_reax_ptr = static_cast(system->pair_ptr); class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); - // Run through a minimal for(jnum_intrs / nthreads; @@ -187,7 +187,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, for (j = 0; j < system->N; ++j) { type_j = system->my_atoms[j].type; _my_offset[j] = 0; - if(type_j < 0) continue; + if (type_j < 0) continue; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); @@ -220,7 +220,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, ++my_offset; break; } - } // for(pk) + } // for (pk) /* and this is the second for loop mentioned above */ for (pk = pi+1; pk < end_j; ++pk) { @@ -233,14 +233,14 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, p_ijk->thb = k; ++my_offset; // add this to the list of 3-body interactions - } // for(pk) - } // if() + } // for (pk) + } // if () Set_End_Index(pi, my_offset, thb_intrs ); - } // for(pi) + } // for (pi) // Confirm that thb_intrs->num_intrs / nthreads is enough to hold all angles from a single atom - if(my_offset >= (tid+1)*per_thread) { + if (my_offset >= (tid+1)*per_thread) { char errmsg[512]; snprintf( errmsg, 512, "step%d-ran out of space on angle_list for atom %i:\n" " nthreads= %d, tid=%d, my_offset=%d, per_thread=%d\n" @@ -251,7 +251,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, // Number of angles owned by this atom _my_offset[j] = my_offset - tid * per_thread; - } // for(j) + } // for (j) // Wait for all threads to finish counting angles #if defined(_OPENMP) && !defined(__NVCC__) @@ -266,7 +266,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, int current_count = 0; int m = _my_offset[0]; _my_offset[0] = current_count; - for(j=1; jN; j++) { + for (j=1; jN; j++) { current_count+= m; m = _my_offset[j]; _my_offset[j] = current_count; @@ -286,10 +286,10 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, #endif for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if (type_j < 0) continue; // Skip if no angles for this atom - if(_my_offset[j] == _my_offset[j+1]) continue; + if (_my_offset[j] == _my_offset[j+1]) continue; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); @@ -373,7 +373,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, ++num_thb_intrs; break; } - } // for(pk) + } // for (pk) /* and this is the second for loop mentioned above */ @@ -587,15 +587,15 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, system->pair_ptr->v_tally3( i, j, k, fi_tmp, fk_tmp, delij, delkj); } - } // if(p_val1>0.001) - } // for(cnt) - } // if(j0) - } // for(pk) - } // if(BOA_ij>0) + } // if (p_val1>0.001) + } // for (cnt) + } // if (j0) + } // for (pk) + } // if (BOA_ij>0) Set_End_Index(pi, my_offset, thb_intrs ); - } // for(pi) - } // for(j) + } // for (pi) + } // for (j) } // end omp parallel data->my_en.e_ang = total_Eang; diff --git a/src/USER-PHONON/dynamical_matrix.cpp b/src/USER-PHONON/dynamical_matrix.cpp index b9c42b45d0..798b50fdf7 100644 --- a/src/USER-PHONON/dynamical_matrix.cpp +++ b/src/USER-PHONON/dynamical_matrix.cpp @@ -266,29 +266,29 @@ void DynamicalMatrix::calculateMatrix() update->nsteps = 0; int prog = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if (gm[i-1] < 0) continue; - for (int alpha=0; alpha<3; alpha++){ + for (int alpha=0; alpha<3; alpha++) { displace_atom(local_idx, alpha, 1); update_force(); - for (bigint j=1; j<=natoms; j++){ + for (bigint j=1; j<=natoms; j++) { local_jdx = atom->map(j); if (local_idx >= 0 && local_jdx >= 0 && local_jdx < nlocal - && gm[j-1] >= 0){ - for (int beta=0; beta<3; beta++){ + && gm[j-1] >= 0) { + for (int beta=0; beta<3; beta++) { dynmat[alpha][gm[j-1]*3+beta] -= f[local_jdx][beta]; } } } displace_atom(local_idx,alpha,-2); update_force(); - for (bigint j=1; j<=natoms; j++){ + for (bigint j=1; j<=natoms; j++) { local_jdx = atom->map(j); if (local_idx >= 0 && local_jdx >= 0 && local_jdx < nlocal - && gm[j-1] >= 0){ - for (int beta=0; beta<3; beta++){ + && gm[j-1] >= 0) { + for (int beta=0; beta<3; beta++) { if (atom->rmass_flag == 1) imass = sqrt(m[local_idx] * m[local_jdx]); else @@ -369,7 +369,7 @@ void DynamicalMatrix::displace_atom(int local_idx, int direction, int magnitude) x[local_idx][direction] += del*magnitude; - while (sametag[j] >= 0){ + while (sametag[j] >= 0) { j = sametag[j]; x[j][direction] += del*magnitude; } @@ -524,7 +524,7 @@ void DynamicalMatrix::create_groupmap() bigint *temp_groupmap = new bigint[natoms]; //find number of local atoms in the group (final_gid) - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit) gid += 1; // gid at the end of loop is final_Gid @@ -534,21 +534,21 @@ void DynamicalMatrix::create_groupmap() gid = 0; //create a map between global atom id and group atom id for each proc - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); - if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit){ + if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit) { sub_groupmap[gid] = i; gid += 1; } } //populate arrays for Allgatherv - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i] = 0; } recv[comm->me] = gid; MPI_Allreduce(recv,displs,comm->nprocs,MPI_INT,MPI_SUM,world); - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i]=displs[i]; if (i>0) displs[i] = displs[i-1]+recv[i-1]; else displs[i] = 0; @@ -560,7 +560,7 @@ void DynamicalMatrix::create_groupmap() //populate member groupmap based on temp groupmap bigint j = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { // flag groupmap contents that are in temp_groupmap if (j < gcount && i == temp_groupmap[j]) groupmap[i-1] = j++; diff --git a/src/USER-PHONON/fix_phonon.cpp b/src/USER-PHONON/fix_phonon.cpp index a4915d6930..013b18948a 100644 --- a/src/USER-PHONON/fix_phonon.cpp +++ b/src/USER-PHONON/fix_phonon.cpp @@ -92,13 +92,13 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) nasr = 20; // other command line options - while (iarg < narg){ - if (strcmp(arg[iarg],"sysdim") == 0){ + while (iarg < narg) { + if (strcmp(arg[iarg],"sysdim") == 0) { if (++iarg >= narg) error->all(FLERR,"Illegal fix phonon command: incomplete command line options."); sdim = utils::inumeric(FLERR, arg[iarg],false,lmp); if (sdim < 1) error->all(FLERR,"Illegal fix phonon command: sysdim should not be less than 1."); - } else if (strcmp(arg[iarg],"nasr") == 0){ + } else if (strcmp(arg[iarg],"nasr") == 0) { if (++iarg >= narg) error->all(FLERR,"Illegal fix phonon command: incomplete command line options."); nasr = utils::inumeric(FLERR, arg[iarg],false,lmp); @@ -139,7 +139,7 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) // here the parallization is done on the x direction only nxlo = 0; int *nx_loc = new int [nprocs]; - for (int i = 0; i < nprocs; ++i){ + for (int i = 0; i < nprocs; ++i) { nx_loc[i] = nx / nprocs; if (i < nx%nprocs) ++nx_loc[i]; } @@ -182,7 +182,7 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) else memory->create(Phi_all,1,1,"fix_phonon:Phi_all"); // output some information on the system to log file - if (me == 0){ + if (me == 0) { flog = fopen(logfile, "w"); if (flog == nullptr) { char str[MAXLINE]; @@ -205,7 +205,7 @@ FixPhonon::FixPhonon(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) fprintf(flog,"%d %d %d %d\n", nx, ny, nz, nucell); fprintf(flog,"# l1 l2 l3 k atom_id\n"); int ix, iy, iz, iu; - for (idx = 0; idx < ngroup; ++idx){ + for (idx = 0; idx < ngroup; ++idx) { itag = surf2tag[idx]; iu = idx%nucell; iz = (idx/nucell)%nz; @@ -341,8 +341,8 @@ void FixPhonon::end_of_step() // evaluate R(r) on local proc nfind = 0; - for (i = 0; i < nlocal; ++i){ - if (mask[i] & groupbit){ + for (i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; @@ -361,8 +361,8 @@ void FixPhonon::end_of_step() for (i = 1; i < nprocs; ++i) displs[i] = displs[i-1] + recvcnts[i-1]; MPI_Gatherv(RIloc[0],nfind,MPI_DOUBLE,RIall[0],recvcnts,displs,MPI_DOUBLE,0,world); - if (me == 0){ - for (i = 0; i < ngroup; ++i){ + if (me == 0) { + for (i = 0; i < ngroup; ++i) { idx = static_cast(RIall[i][sysdim]); for (idim = 0; idim < sysdim; ++idim) Rsort[idx][idim] = RIall[i][idim]; } @@ -374,9 +374,9 @@ void FixPhonon::end_of_step() for (idim = 0; idim < fft_dim; ++idim) Rsum[idx][idim] += Rnow[idx][idim]; // FFT R(r) to get R(q) - for (idim = 0; idim < fft_dim; ++idim){ + for (idim = 0; idim < fft_dim; ++idim) { int m = 0; - for (idx = 0; idx < mynpt; ++idx){ + for (idx = 0; idx < mynpt; ++idx) { fft_data[m++] = static_cast(Rnow[idx][idim]); fft_data[m++] = static_cast(0.); } @@ -384,25 +384,25 @@ void FixPhonon::end_of_step() fft->compute(fft_data, fft_data, -1); m = 0; - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { Rqnow[idq][idim] = std::complex(static_cast(fft_data[m]), static_cast(fft_data[m+1])); m += 2; } } // to get sum(R(q).R(q)*) - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { ndim = 0; for (idim = 0; idim < fft_dim; ++idim) for (jdim = 0; jdim < fft_dim; ++jdim) Rqsum[idq][ndim++] += Rqnow[idq][idim] * std::conj(Rqnow[idq][jdim]); } // get basis info - if (fft_dim > sysdim){ + if (fft_dim > sysdim) { double dist2orig[3]; - for (idx = 0; idx < mynpt; ++idx){ + for (idx = 0; idx < mynpt; ++idx) { ndim = sysdim; - for (i = 1; i < nucell; ++i){ + for (i = 1; i < nucell; ++i) { for (idim = 0; idim < sysdim; ++idim) dist2orig[idim] = Rnow[idx][ndim++] - Rnow[idx][idim]; domain->minimum_image(dist2orig); for (idim = 0; idim < sysdim; ++idim) basis[i][idim] += dist2orig[idim]; @@ -477,9 +477,9 @@ void FixPhonon::getmass() type_all = new double[nucell]; for (int i = 0; i < nucell; ++i) mass_one[i] = type_one[i] = 0.; - if (rmass){ - for (int i = 0; i < nlocal; ++i){ - if (mask[i] & groupbit){ + if (rmass) { + for (int i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; int iu = idx%nucell; @@ -488,8 +488,8 @@ void FixPhonon::getmass() } } } else { - for (int i = 0; i < nlocal; ++i){ - if (mask[i] & groupbit){ + for (int i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; int iu = idx%nucell; @@ -506,7 +506,7 @@ void FixPhonon::getmass() basetype = new int[nucell]; double inv_total = 1./double(ntotal); - for (int i = 0; i < nucell; ++i){ + for (int i = 0; i < nucell; ++i) { mass_all[i] *= inv_total; M_inv_sqrt[i] = sqrt(1./mass_all[i]); @@ -528,7 +528,7 @@ void FixPhonon::readmap() int info = 0; // auto-generate mapfile for "cluster" (gamma only system) - if (strcmp(mapfile, "GAMMA") == 0){ + if (strcmp(mapfile, "GAMMA") == 0) { nx = ny = nz = ntotal = 1; nucell = ngroup; @@ -538,7 +538,7 @@ void FixPhonon::readmap() // get atom IDs on local proc int nfind = 0; - for (int i = 0; i < atom->nlocal; ++i){ + for (int i = 0; i < atom->nlocal; ++i) { if (atom->mask[i] & groupbit) tag_loc[nfind++] = atom->tag[i]; } @@ -549,7 +549,7 @@ void FixPhonon::readmap() for (int i = 1; i < nprocs; ++i) displs[i] = displs[i-1] + recvcnts[i-1]; MPI_Allgatherv(tag_loc,nfind,MPI_LMP_TAGINT,tag_all,recvcnts,displs,MPI_LMP_TAGINT,world); - for (int i = 0; i < ngroup; ++i){ + for (int i = 0; i < ngroup; ++i) { itag = tag_all[i]; tag2surf[itag] = i; surf2tag[i] = itag; @@ -563,7 +563,7 @@ void FixPhonon::readmap() // read from map file for others char line[MAXLINE]; FILE *fp = fopen(mapfile, "r"); - if (fp == nullptr){ + if (fp == nullptr) { sprintf(line,"Cannot open input map file %s", mapfile); error->all(FLERR,line); } @@ -584,7 +584,7 @@ void FixPhonon::readmap() int ix, iy, iz, iu; // the remaining lines carry the mapping info - for (int i = 0; i < ngroup; ++i){ + for (int i = 0; i < ngroup; ++i) { if (fgets(line,MAXLINE,fp) == nullptr) {info = 1; break;} ix = utils::inumeric(FLERR, strtok(line, " \n\t\r\f"),false,lmp); iy = utils::inumeric(FLERR, strtok(nullptr, " \n\t\r\f"),false,lmp); @@ -614,7 +614,7 @@ void FixPhonon::readmap() int nlocal = atom->nlocal; for (int i = 0; i < nlocal; ++i) { - if (mask[i] & groupbit){ + if (mask[i] & groupbit) { itag = tag[i]; idx = tag2surf[itag]; if (itag != surf2tag[idx]) @@ -643,9 +643,9 @@ void FixPhonon::postprocess( ) for (idim = 0; idim < fft_dim; ++idim) Rnow[idx][idim] = Rsum[idx][idim] * inv_neval; // to get q - for (idim = 0; idim < fft_dim; ++idim){ + for (idim = 0; idim < fft_dim; ++idim) { int m = 0; - for (idx = 0; idx < mynpt; ++idx){ + for (idx = 0; idx < mynpt; ++idx) { fft_data[m++] = static_cast(Rnow[idx][idim]); fft_data[m++] = static_cast(0.); } @@ -653,14 +653,14 @@ void FixPhonon::postprocess( ) fft->compute(fft_data,fft_data,-1); m = 0; - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { Rqnow[idq][idim] = std::complex(static_cast(fft_data[m]), static_cast(fft_data[m+1])); m += 2; } } // to get G(q) = - q.q - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { ndim = 0; for (idim = 0; idim < fft_dim; ++idim) for (jdim = 0; jdim < fft_dim; ++jdim) Phi_q[idq][ndim++] -= Rqnow[idq][idim] * std::conj(Rqnow[idq][jdim]); @@ -672,13 +672,13 @@ void FixPhonon::postprocess( ) double TempFac = inv_neval * inv_nTemp; double NormFac = TempFac * double(ntotal); - for (idim = 0; idim < sysdim; ++idim){ + for (idim = 0; idim < sysdim; ++idim) { kbtsqrt[idim] = sqrt(TempSum[idim] * NormFac); TempAve += TempSum[idim] * TempFac; } TempAve /= sysdim*boltz; - for (idq = 0; idq < mynq; ++idq){ + for (idq = 0; idq < mynq; ++idq) { GaussJordan(fft_dim, Phi_q[idq]); ndim =0; for (idim = 0; idim < fft_dim; ++idim) @@ -695,7 +695,7 @@ void FixPhonon::postprocess( ) double *basis_root = new double[fft_dim]; if (fft_dim > sysdim) MPI_Reduce(&basis[1][0], &basis_root[sysdim], fft_dim-sysdim, MPI_DOUBLE, MPI_SUM, 0, world); - if (me == 0){ // output dynamic matrix by root + if (me == 0) { // output dynamic matrix by root // get basis info for (idim = 0; idim < sysdim; ++idim) basis_root[idim] = 0.; @@ -748,18 +748,18 @@ void FixPhonon::postprocess( ) EnforceASR(); // to get D = 1/M x Phi - for (idq = 0; idq < ntotal; ++idq){ + for (idq = 0; idq < ntotal; ++idq) { ndim =0; for (idim = 0; idim < fft_dim; ++idim) for (jdim = 0; jdim < fft_dim; ++jdim) Phi_all[idq][ndim++] *= M_inv_sqrt[idim/sysdim]*M_inv_sqrt[jdim/sysdim]; } idq =0; - for (int ix = 0; ix < nx; ++ix){ + for (int ix = 0; ix < nx; ++ix) { double qx = double(ix)/double(nx); - for (int iy = 0; iy < ny; ++iy){ + for (int iy = 0; iy < ny; ++iy) { double qy = double(iy)/double(ny); - for (int iz = 0; iz < nz; ++iz){ + for (int iz = 0; iz < nz; ++iz) { double qz = double(iz)/double(nz); fprintf(flog,"%lg %lg %lg", qx, qy, qz); for (idim = 0; idim < fft_dim2; ++idim) @@ -794,15 +794,15 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) ipiv = new int[n]; for (i = 0; i < n; ++i) ipiv[i] = 0; - for (i = 0; i < n; ++i){ + for (i = 0; i < n; ++i) { big = 0.; - for (j = 0; j < n; ++j){ - if (ipiv[j] != 1){ - for (k = 0; k < n; ++k){ - if (ipiv[k] == 0){ + for (j = 0; j < n; ++j) { + if (ipiv[j] != 1) { + for (k = 0; k < n; ++k) { + if (ipiv[k] == 0) { idr = j*n+k; nmjk = norm(Mat[idr]); - if (nmjk >= big){ + if (nmjk >= big) { big = nmjk; irow = j; icol = k; @@ -812,8 +812,8 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) } } ipiv[icol] += 1; - if (irow != icol){ - for (l = 0; l < n; ++l){ + if (irow != icol) { + for (l = 0; l < n; ++l) { idr = irow*n+l; idc = icol*n+l; dum = Mat[idr]; @@ -830,8 +830,8 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) Mat[idr] = std::complex(1.,0.); idr = icol*n; for (l = 0; l < n; ++l) Mat[idr+l] *= pivinv; - for (ll = 0; ll < n; ++ll){ - if (ll != icol){ + for (ll = 0; ll < n; ++ll) { + if (ll != icol) { idc = ll*n + icol; dum = Mat[idc]; Mat[idc] = 0.; @@ -841,11 +841,11 @@ void FixPhonon::GaussJordan(int n, std::complex *Mat) } } - for (l = n-1; l >= 0; --l){ + for (l = n-1; l >= 0; --l) { int rl = indxr[l]; int cl = indxc[l]; - if (rl != cl){ - for (k = 0; k < n; ++k){ + if (rl != cl) { + for (k = 0; k < n; ++k) { idr = k*n + rl; idc = k*n + cl; dum = Mat[idr]; @@ -867,18 +867,18 @@ void FixPhonon::EnforceASR() { if (nasr < 1) return; - for (int iit = 0; iit < nasr; ++iit){ + for (int iit = 0; iit < nasr; ++iit) { // simple ASR; the resultant matrix might not be symmetric for (int a = 0; a < sysdim; ++a) - for (int b = 0; b < sysdim; ++b){ - for (int k = 0; k < nucell; ++k){ + for (int b = 0; b < sysdim; ++b) { + for (int k = 0; k < nucell; ++k) { double sum = 0.; - for (int kp = 0; kp < nucell; ++kp){ + for (int kp = 0; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; sum += std::real(Phi_all[0][idx]); } sum /= double(nucell); - for (int kp = 0; kp < nucell; ++kp){ + for (int kp = 0; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; Phi_all[0][idx] -= sum; } @@ -887,10 +887,10 @@ void FixPhonon::EnforceASR() // symmetrize for (int k = 0; k < nucell; ++k) - for (int kp = k; kp < nucell; ++kp){ + for (int kp = k; kp < nucell; ++kp) { double csum = 0.; for (int a = 0; a < sysdim; ++a) - for (int b = 0; b < sysdim; ++b){ + for (int b = 0; b < sysdim; ++b) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; int jdx = (kp*sysdim+b)*fft_dim + k*sysdim + a; csum = (std::real(Phi_all[0][idx])+std::real(Phi_all[0][jdx]))*0.5; @@ -902,15 +902,15 @@ void FixPhonon::EnforceASR() // symmetric ASR for (int a = 0; a < sysdim; ++a) - for (int b = 0; b < sysdim; ++b){ - for (int k = 0; k < nucell; ++k){ + for (int b = 0; b < sysdim; ++b) { + for (int k = 0; k < nucell; ++k) { double sum = 0.; - for (int kp = 0; kp < nucell; ++kp){ + for (int kp = 0; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; sum += std::real(Phi_all[0][idx]); } sum /= double(nucell-k); - for (int kp = k; kp < nucell; ++kp){ + for (int kp = k; kp < nucell; ++kp) { int idx = (k*sysdim+a)*fft_dim + kp*sysdim + b; int jdx = (kp*sysdim+b)*fft_dim + k*sysdim + a; Phi_all[0][idx] -= sum; diff --git a/src/USER-PHONON/third_order.cpp b/src/USER-PHONON/third_order.cpp index 32ced74cad..875490d643 100644 --- a/src/USER-PHONON/third_order.cpp +++ b/src/USER-PHONON/third_order.cpp @@ -254,18 +254,18 @@ void ThirdOrder::calculateMatrix() update->nsteps = 0; int prog = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); - for (int alpha=0; alpha<3; alpha++){ - for (bigint j=1; j<=natoms; j++){ + for (int alpha=0; alpha<3; alpha++) { + for (bigint j=1; j<=natoms; j++) { local_jdx = atom->map(j); - for (int beta=0; beta<3; beta++){ + for (int beta=0; beta<3; beta++) { displace_atom(local_idx, alpha, 1); displace_atom(local_jdx, beta, 1); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -275,9 +275,9 @@ void ThirdOrder::calculateMatrix() } displace_atom(local_jdx, beta, -2); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -289,9 +289,9 @@ void ThirdOrder::calculateMatrix() displace_atom(local_idx,alpha,-2); displace_atom(local_jdx, beta, 1); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -301,9 +301,9 @@ void ThirdOrder::calculateMatrix() } displace_atom(local_jdx, beta, -2); update_force(); - for (bigint k=1; k<=natoms; k++){ + for (bigint k=1; k<=natoms; k++) { local_kdx = atom->map(k); - for (int gamma=0; gamma<3; gamma++){ + for (int gamma=0; gamma<3; gamma++) { if (local_idx >= 0 && local_jdx >= 0 && local_kdx >= 0 && gm[i-1] >= 0 && gm[j-1] >= 0 && gm[k-1] >= 0 && local_kdx < nlocal) { @@ -315,7 +315,7 @@ void ThirdOrder::calculateMatrix() displace_atom(local_jdx, beta, 1); displace_atom(local_idx, alpha, 1); MPI_Reduce(dynmat,fdynmat,3*dynlen,MPI_DOUBLE,MPI_SUM,0,world); - if (me == 0){ + if (me == 0) { writeMatrix(fdynmat, gm[i-1], alpha, gm[j-1], beta); } memset(&dynmat[0],0,dynlen*sizeof(double)); @@ -351,7 +351,7 @@ void ThirdOrder::writeMatrix(double *dynmat, bigint i, int a, bigint j, int b) double norm; if (!binaryflag && fp) { clearerr(fp); - for (int k = 0; k < gcount; k++){ + for (int k = 0; k < gcount; k++) { norm = square(dynmat[k*3])+ square(dynmat[k*3+1])+ square(dynmat[k*3+2]); @@ -364,7 +364,7 @@ void ThirdOrder::writeMatrix(double *dynmat, bigint i, int a, bigint j, int b) dynmat[k*3+1] * conversion, dynmat[k*3+2] * conversion); } - } else if (binaryflag && fp){ + } else if (binaryflag && fp) { clearerr(fp); fwrite(&dynmat[0], sizeof(double), dynlen, fp); } @@ -386,7 +386,7 @@ void ThirdOrder::displace_atom(int local_idx, int direction, int magnitude) x[local_idx][direction] += del*magnitude; - while (sametag[j] >= 0){ + while (sametag[j] >= 0) { j = sametag[j]; x[j][direction] += del*magnitude; } @@ -518,7 +518,7 @@ void ThirdOrder::create_groupmap() bigint *temp_groupmap = new bigint[natoms]; //find number of local atoms in the group (final_gid) - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if ((local_idx >= 0) && (local_idx < nlocal) && mask[local_idx] & groupbit) gid += 1; // gid at the end of loop is final_Gid @@ -528,22 +528,22 @@ void ThirdOrder::create_groupmap() gid = 0; //create a map between global atom id and group atom id for each proc - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { local_idx = atom->map(i); if ((local_idx >= 0) && (local_idx < nlocal) - && (mask[local_idx] & groupbit)){ + && (mask[local_idx] & groupbit)) { sub_groupmap[gid] = i; gid += 1; } } //populate arrays for Allgatherv - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i] = 0; } recv[comm->me] = gid; MPI_Allreduce(recv,displs,comm->nprocs,MPI_INT,MPI_SUM,world); - for (int i=0; inprocs; i++){ + for (int i=0; inprocs; i++) { recv[i]=displs[i]; if (i>0) displs[i] = displs[i-1]+recv[i-1]; else displs[i] = 0; @@ -556,7 +556,7 @@ void ThirdOrder::create_groupmap() //populate member groupmap based on temp groupmap bigint j = 0; - for (bigint i=1; i<=natoms; i++){ + for (bigint i=1; i<=natoms; i++) { // flag groupmap contents that are in temp_groupmap if (j < gcount && i == temp_groupmap[j]) groupmap[i-1] = j++; diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index 1fc19a7724..e2246adcd9 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -118,7 +118,7 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : // LAMMPS units wrt kj/mol - nm - ps // Set up units - if(strcmp(update->unit_style,"lj") == 0) { + if (strcmp(update->unit_style,"lj") == 0) { // LAMMPS units lj p->cmd("setNaturalUnits"); } else { @@ -486,7 +486,7 @@ void FixPlumed::post_force(int /* vflag */) // do the real calculation: p->cmd("performCalc"); - if(plumedStopCondition) timer->force_timeout(); + if (plumedStopCondition) timer->force_timeout(); // retransform virial to lammps representation and assign it to this // fix's virial. If the energy is biased, Plumed is giving back the full diff --git a/src/USER-PTM/ptm_voronoi_cell.cpp b/src/USER-PTM/ptm_voronoi_cell.cpp index 60ef4cf87b..5b29706b82 100644 --- a/src/USER-PTM/ptm_voronoi_cell.cpp +++ b/src/USER-PTM/ptm_voronoi_cell.cpp @@ -76,13 +76,13 @@ voronoicell_base::voronoicell_base() : ds2(new int[current_delete2_size]), stacke2(ds2+current_delete_size), current_marginal(init_marginal), marg(new int[current_marginal]) { int i; - for(i=0;i<3;i++) { + for (i=0;i<3;i++) { mem[i]=init_n_vertices;mec[i]=0; mep[i]=new int[init_n_vertices*((i<<1)+1)]; } mem[3]=init_3_vertices;mec[3]=0; mep[3]=new int[init_3_vertices*7]; - for(i=4;i=0;i--) if(mem[i]>0) delete [] mep[i]; + for (int i=current_vertex_order-1;i>=0;i--) if (mem[i]>0) delete [] mep[i]; delete [] marg; delete [] ds2;delete [] ds; delete [] mep;delete [] mec; @@ -104,7 +104,7 @@ voronoicell_base::~voronoicell_base() { template void voronoicell_base::check_memory_for_copy(vc_class &vc,voronoicell_base* vb) { while(current_vertex_ordercurrent_vertex_order) add_memory_vorder(vc); - for(int i=0;imec[i]) add_memory(vc,i,ds2); + for (int i=0;imec[i]) add_memory(vc,i,ds2); while(current_verticesp) add_memory_vertices(vc); } @@ -122,7 +122,7 @@ void voronoicell_base::check_memory_for_copy(vc_class &vc,voronoicell_base* vb) template void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { int s=(i<<1)+1; - if(mem[i]==0) { + if (mem[i]==0) { vc.n_allocate(i,init_n_vertices); mep[i]=new int[init_n_vertices*s]; mem[i]=init_n_vertices; @@ -132,7 +132,7 @@ void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { } else { int j=0,k,*l; mem[i]<<=1; - if(mem[i]>max_n_vertices) voro_fatal_error("Point memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (mem[i]>max_n_vertices) voro_fatal_error("Point memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Order %d vertex memory scaled up to %d\n",i,mem[i]); #endif @@ -141,25 +141,25 @@ void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { vc.n_allocate_aux1(i); while(j=0) { + if (k>=0) { ed[k]=l+j; vc.n_set_to_aux1_offset(k,m); } else { int *dsp; - for(dsp=ds2;dsp=3 fputs("Relocated dangling pointer",stderr); #endif } - for(k=0;kmax_vertices) voro_fatal_error("Vertex memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (i>max_vertices) voro_fatal_error("Vertex memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Vertex memory scaled up to %d\n",i); #endif double *ppts; pp=new int*[i]; - for(j=0;j void voronoicell_base::add_memory_vorder(vc_class &vc) { int i=(current_vertex_order<<1),j,*p1,**p2; - if(i>max_vertex_order) voro_fatal_error("Vertex order memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (i>max_vertex_order) voro_fatal_error("Vertex order memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Vertex order memory scaled up to %d\n",i); #endif p1=new int[i]; - for(j=0;jmax_delete_size) voro_fatal_error("Delete stack 1 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (current_delete_size>max_delete_size) voro_fatal_error("Delete stack 1 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Delete stack 1 memory scaled up to %d\n",current_delete_size); #endif @@ -244,7 +244,7 @@ void voronoicell_base::add_memory_ds(int *&stackp) { * routine causes a fatal error. */ void voronoicell_base::add_memory_ds2(int *&stackp2) { current_delete2_size<<=1; - if(current_delete2_size>max_delete2_size) voro_fatal_error("Delete stack 2 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); + if (current_delete2_size>max_delete2_size) voro_fatal_error("Delete stack 2 memory allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Delete stack 2 memory scaled up to %d\n",current_delete2_size); #endif @@ -259,7 +259,7 @@ void voronoicell_base::add_memory_ds2(int *&stackp2) { * \param[in] (ymin,ymax) the minimum and maximum y coordinates. * \param[in] (zmin,zmax) the minimum and maximum z coordinates. */ void voronoicell_base::init_base(double xmin,double xmax,double ymin,double ymax,double zmin,double zmax) { - for(int i=0;i inline void voronoicell_base::add_to_stack(vc_class &vc,int lp,int *&stackp2) { (void)vc; - for(int *k(ds2);k=p) throw true; + if (++count>=p) throw true; u=l;up=lp; - for(us=0;us=p) throw true; + if (++count>=p) throw true; u=q;up=qp; - for(us=0;us=current_vertex_order) add_memory_vorder(vc); - if(mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); + if (mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); vc.n_set_pointer(p,nu[p]); ed[p]=mep[nu[p]]+((nu[p]<<1)+1)*mec[nu[p]]++; ed[p][nu[p]<<1]=p; @@ -609,7 +609,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // If i reaches zero, then we have a point in // the plane all of whose edges are outside // the cutting space, so we just exit - if(i==0) return true; + if (i==0) return true; lp=ed[up][i]; lw=m_test(lp,l); } @@ -631,7 +631,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // the remaining one is on the plane. For that case we // have to reduce the edge count by one to prevent // doubling up. - if(i==j&&qw==0) { + if (i==j&&qw==0) { double_edge=true; nu[p]=nu[up]; } else { @@ -642,7 +642,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // already k=1; while(nu[p]>=current_vertex_order) add_memory_vorder(vc); - if(mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); + if (mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); // Copy the edges of the original vertex into the new // one. Delete the edges of the original vertex, and @@ -676,13 +676,13 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq } qs=j; } - if(!double_edge) { + if (!double_edge) { vc.n_copy(p,k,up,qs); vc.n_set(p,0,p_id); } else vc.n_copy(p,0,up,qs); // Add this point to the auxiliary delete stack - if(stackp2==stacke2) add_memory_ds2(stackp2); + if (stackp2==stacke2) add_memory_ds2(stackp2); *(stackp2++)=up; // Look at the edges on either side of the group that was @@ -702,7 +702,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // points lp and up. Create a new vertex between them which // lies on the cutting plane. Since u and l differ by at least // the tolerance, this division should never screw up. - if(stackp==stacke) add_memory_ds(stackp); + if (stackp==stacke) add_memory_ds(stackp); *(stackp++)=up; r=u/(u-l);l=1-r; pts[3*p]=pts[3*lp]*r+pts[3*up]*l; @@ -712,7 +712,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // This point will always have three edges. Connect one of them // to lp. nu[p]=3; - if(mec[3]==mem[3]) add_memory(vc,3,stackp2); + if (mec[3]==mem[3]) add_memory(vc,3,stackp2); vc.n_set_pointer(p,3); vc.n_set(p,0,p_id); vc.n_copy(p,1,up,us); @@ -742,30 +742,30 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq lp=ed[qp][qs]; lw=m_test(lp,l); - if(lw==1) { + if (lw==1) { // The point is still in the cutting space. Just add it // to the delete stack and keep moving. qs=cycle_up(ed[qp][nu[qp]+qs],lp); qp=lp; q=l; - if(stackp==stacke) add_memory_ds(stackp); + if (stackp==stacke) add_memory_ds(stackp); *(stackp++)=qp; - } else if(lw==-1) { + } else if (lw==-1) { // The point is outside of the cutting space, so we've // found an intersected edge. Introduce a regular point // at the point of intersection. Connect it to the // point we just tested. Also connect it to the previous // new point in the facet we're constructing. - if(p==current_vertices) add_memory_vertices(vc); + if (p==current_vertices) add_memory_vertices(vc); r=q/(q-l);l=1-r; pts[3*p]=pts[3*lp]*r+pts[3*qp]*l; pts[3*p+1]=pts[3*lp+1]*r+pts[3*qp+1]*l; pts[3*p+2]=pts[3*lp+2]*r+pts[3*qp+2]*l; nu[p]=3; - if(mec[3]==mem[3]) add_memory(vc,3,stackp2); + if (mec[3]==mem[3]) add_memory(vc,3,stackp2); ls=ed[qp][qs+nu[qp]]; vc.n_set_pointer(p,3); vc.n_set(p,0,p_id); @@ -791,7 +791,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // We're going to introduce a new point right here, but // first we need to figure out the number of edges it // has. - if(p==current_vertices) add_memory_vertices(vc); + if (p==current_vertices) add_memory_vertices(vc); // If the previous vertex detected a double edge, our // new vertex will have one less edge. @@ -816,15 +816,15 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // need to figure out whether we're in a case where we // might be creating a duplicate edge. j=-ed[qp][nu[qp]<<1]; - if(qp==up&&qs==us) { + if (qp==up&&qs==us) { // If we're heading into the final part of the // new facet, then we never worry about the // duplicate edge calculation. new_double_edge=false; - if(j>0) k+=nu[j]; + if (j>0) k+=nu[j]; } else { - if(j>0) { + if (j>0) { // This vertex was visited before, so // count those vertices to the ones we @@ -836,16 +836,16 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // going to move to next is also a // marginal point, so test for that // first. - if(lw==0) { + if (lw==0) { // Now see whether this marginal point // has been visited before. i=-ed[lp][nu[lp]<<1]; - if(i>0) { + if (i>0) { // Now see if the last edge of that other // marginal point actually ends up here. - if(ed[i][nu[i]-1]==j) { + if (ed[i][nu[i]-1]==j) { new_double_edge=true; k-=1; } else new_double_edge=false; @@ -857,7 +857,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // case when that's the way into the end // of the facet, because that way always creates // an edge. - if(j==rp&&lp==up&&ed[qp][nu[qp]+qs]==us) { + if (j==rp&&lp==up&&ed[qp][nu[qp]+qs]==us) { new_double_edge=true; k-=1; } else new_double_edge=false; @@ -868,7 +868,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // The vertex hasn't been visited // before, but let's see if it's // marginal - if(lw==0) { + if (lw==0) { // If it is, we need to check // for the case that it's a @@ -876,7 +876,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // heading right back to where // we came from i=-ed[lp][nu[lp]<<1]; - if(i==cp) { + if (i==cp) { new_double_edge=true; k-=1; } else new_double_edge=false; @@ -888,16 +888,16 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // we are forming. Add memory for it if it doesn't exist // already. while(k>=current_vertex_order) add_memory_vorder(vc); - if(mec[k]==mem[k]) add_memory(vc,k,stackp2); + if (mec[k]==mem[k]) add_memory(vc,k,stackp2); // Now create a new vertex with order k, or augment // the existing one - if(j>0) { + if (j>0) { // If we're augmenting a vertex but we don't // actually need any more edges, just skip this // routine to avoid memory confusion - if(nu[j]!=k) { + if (nu[j]!=k) { // Allocate memory and copy the edges // of the previous instance into it vc.n_set_aux1(k); @@ -915,8 +915,8 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // fewer vertices from the memory // structure edd=mep[nu[j]]+((nu[j]<<1)+1)*--mec[nu[j]]; - if(edd!=ed[j]) { - for(lw=0;lw<=(nu[j]<<1);lw++) ed[j][lw]=edd[lw]; + if (edd!=ed[j]) { + for (lw=0;lw<=(nu[j]<<1);lw++) ed[j][lw]=edd[lw]; vc.n_set_aux2_copy(j,nu[j]); vc.n_copy_pointer(edd[nu[j]<<1],j); ed[edd[nu[j]<<1]]=ed[j]; @@ -930,7 +930,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq vc.n_set_pointer(p,k); ed[p]=mep[k]+((k<<1)+1)*mec[k]++; ed[p][k<<1]=p; - if(stackp2==stacke2) add_memory_ds2(stackp2); + if (stackp2==stacke2) add_memory_ds2(stackp2); *(stackp2++)=qp; pts[3*p]=pts[3*qp]; pts[3*p+1]=pts[3*qp+1]; @@ -944,7 +944,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq // Unless the previous case was a double edge, connect // the first available edge of the new vertex to the // last one in the facet - if(!double_edge) { + if (!double_edge) { ed[j][i]=cp; ed[j][nu[j]+i]=cs; vc.n_set(j,i,p_id); @@ -988,7 +988,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq dsp=ds; while(dsp0) voro_fatal_error("Zero order vertex formed",VOROPP_INTERNAL_ERROR); + if (*mec>0) voro_fatal_error("Zero order vertex formed",VOROPP_INTERNAL_ERROR); // Collapse any order 2 vertices and exit return collapse_order2(vc); @@ -1080,14 +1080,14 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq * was successful. */ template inline bool voronoicell_base::collapse_order2(vc_class &vc) { - if(!collapse_order1(vc)) return false; + if (!collapse_order1(vc)) return false; int a,b,i,j,k,l; while(mec[2]>0) { // Pick a order 2 vertex and read in its edges i=--mec[2]; j=mep[2][5*i];k=mep[2][5*i+1]; - if(j==k) { + if (j==k) { #if VOROPP_VERBOSE >=1 fputs("Order two vertex joins itself",stderr); #endif @@ -1095,33 +1095,33 @@ inline bool voronoicell_base::collapse_order2(vc_class &vc) { } // Scan the edges of j to see if joins k - for(l=0;l=1 - if(i<1) { + if (i<1) { fputs("Zero order vertex formed\n",stderr); return false; } #endif - if(mec[i]==mem[i]) add_memory(vc,i,ds2); + if (mec[i]==mem[i]) add_memory(vc,i,ds2); vc.n_set_aux1(i); - for(l=0;l &v) { v.clear(); int i,j,k,l,m,n; double ux,uy,uz,vx,vy,vz,wx,wy,wz; - for(i=1;i=0) { + if (k>=0) { area=0; ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); @@ -1261,8 +1261,8 @@ void voronoicell_base::face_areas(std::vector &v) { * internal error if it encounters a positive edge. */ inline void voronoicell_base::reset_edges() { int i,j; - for(i=0;i=0) voro_fatal_error("Edge reset routine found a previously untested edge",VOROPP_INTERNAL_ERROR); + for (i=0;i=0) voro_fatal_error("Edge reset routine found a previously untested edge",VOROPP_INTERNAL_ERROR); ed[i][j]=-1-ed[i][j]; } } @@ -1282,9 +1282,9 @@ inline int voronoicell_base::m_test(int n,double &ans) { ans=*(pp++)*px; ans+=*(pp++)*py; ans+=*pp*pz-prsq; - if(ans<-tolerance2) { + if (ans<-tolerance2) { return -1; - } else if(ans>tolerance2) { + } else if (ans>tolerance2) { return 1; } return check_marginal(n,ans); @@ -1304,16 +1304,16 @@ inline int voronoicell_base::m_test(int n,double &ans) { * plane, or 0 if the point is within the plane. */ int voronoicell_base::check_marginal(int n,double &ans) { int i; - for(i=0;imax_marginal) + if (current_marginal>max_marginal) voro_fatal_error("Marginal case buffer allocation exceeded absolute maximum",VOROPP_MEMORY_ERROR); #if VOROPP_VERBOSE >=2 fprintf(stderr,"Marginal cases buffer scaled up to %d\n",i); #endif int *pmarg=new int[current_marginal]; - for(int j=0;j=0) { + if (k>=0) { ed[i][j]=-1-k; q=ne[i][j]; l=cycle_up(ed[i][nu[i]+j],k); do { m=ed[k][l]; ed[k][l]=-1-m; - if(ne[k][l]!=q) fprintf(stderr,"Facet error at (%d,%d)=%d, started from (%d,%d)=%d\n",k,l,ne[k][l],i,j,q); + if (ne[k][l]!=q) fprintf(stderr,"Facet error at (%d,%d)=%d, started from (%d,%d)=%d\n",k,l,ne[k][l],i,j,q); l=cycle_up(ed[k][nu[k]+l],m); k=m; } while (k!=i); @@ -1371,15 +1371,15 @@ voronoicell_neighbor::voronoicell_neighbor() { int i; mne=new int*[current_vertex_order]; ne=new int*[current_vertices]; - for(i=0;i<3;i++) mne[i]=new int[init_n_vertices*i]; + for (i=0;i<3;i++) mne[i]=new int[init_n_vertices*i]; mne[3]=new int[init_3_vertices*3]; - for(i=4;i=0;i--) if(mem[i]>0) delete [] mne[i]; + for (int i=current_vertex_order-1;i>=0;i--) if (mem[i]>0) delete [] mne[i]; delete [] mne; delete [] ne; } @@ -1388,9 +1388,9 @@ voronoicell_neighbor::~voronoicell_neighbor() { void voronoicell_neighbor::neighbors(std::vector &v) { v.clear(); int i,j,k,l,m; - for(i=1;i=0) { + if (k>=0) { v.push_back(ne[i][j]); ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); @@ -1409,9 +1409,9 @@ void voronoicell_neighbor::neighbors(std::vector &v) { * \return The number of faces. */ int voronoicell_base::number_of_faces() { int i,j,k,l,m,s=0; - for(i=1;i=0) { + if (k>=0) { s++; ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); @@ -1435,7 +1435,7 @@ int voronoicell_base::number_of_faces() { void voronoicell_base::vertices(double x,double y,double z,std::vector &v) { v.resize(3*p); double *ptsp=pts; - for(int i=0;i<3*p;i+=3) { + for (int i=0;i<3*p;i+=3) { v[i]=x+*(ptsp++)*0.5; v[i+1]=y+*(ptsp++)*0.5; v[i+2]=z+*(ptsp++)*0.5; @@ -1448,9 +1448,9 @@ void voronoicell_base::vertices(double x,double y,double z,std::vector & void voronoicell_base::face_vertices(std::vector &v) { int i,j,k,l,m,vp(0),vn; v.clear(); - for(i=1;i=0) { + if (k>=0) { v.push_back(0); v.push_back(i); ed[i][j]=-1-k; diff --git a/src/USER-QTB/fix_qbmsst.cpp b/src/USER-QTB/fix_qbmsst.cpp index 26a4716704..82dd76a1b5 100644 --- a/src/USER-QTB/fix_qbmsst.cpp +++ b/src/USER-QTB/fix_qbmsst.cpp @@ -526,7 +526,7 @@ void FixQBMSST::initial_integrate(int /*vflag*/) // load omega_H with calculated spectrum at a specific temperature (corrected spectrum), omega_H is the Fourier transformation of time_H for (int k = 0; k < 2*N_f; k++) { double f_k=(k-N_f)/(2*N_f*h_timestep); //\omega_k=\frac{2\pi}{\delta{}h}\frac{k}{2N_f} for k from -N_f to N_f-1 - if(k == N_f) { + if (k == N_f) { omega_H[k]=sqrt(force->boltz * t_current); } else { double energy_k= force->hplanck * fabs(f_k); diff --git a/src/USER-QTB/fix_qtb.cpp b/src/USER-QTB/fix_qtb.cpp index 16e01faa54..31f0808ca7 100644 --- a/src/USER-QTB/fix_qtb.cpp +++ b/src/USER-QTB/fix_qtb.cpp @@ -201,7 +201,7 @@ void FixQTB::init() // load omega_H with calculated spectrum at a specific temperature (corrected spectrum), omega_H is the Fourier transformation of time_H for (int k = 0; k < 2*N_f; k++) { double f_k=(k-N_f)/(2*N_f*h_timestep); //\omega_k=\frac{2\pi}{\delta{}h}\frac{k}{2N_f} for k from -N_f to N_f-1 - if(k == N_f) { + if (k == N_f) { omega_H[k]=sqrt(force->boltz * t_target); } else { double energy_k= force->hplanck * fabs(f_k); diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 0cbc71e564..3ca19285f6 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -162,17 +162,17 @@ void PairQUIP::compute(int eflag, int vflag) iquip = 0; for (ii = 0; ii < ntotal; ii++) { - for( jj = 0; jj < 3; jj++ ) { + for ( jj = 0; jj < 3; jj++ ) { f[ii][jj] += quip_force[iquip]; iquip++; } } - if(eflag_global) { + if (eflag_global) { eng_vdwl = quip_energy; } - if(eflag_atom) { + if (eflag_atom) { for (ii = 0; ii < ntotal; ii++) { eatom[ii] = quip_local_e[ii]; } @@ -187,9 +187,9 @@ void PairQUIP::compute(int eflag, int vflag) virial[5] = (quip_virial[5] + quip_virial[7])*0.5; } - if(vflag_atom) { + if (vflag_atom) { int iatom = 0; - for(ii = 0; ii < ntotal; ii++) { + for (ii = 0; ii < ntotal; ii++) { vatom[ii][0] += quip_local_virial[iatom+0]; vatom[ii][1] += quip_local_virial[iatom+4]; vatom[ii][2] += quip_local_virial[iatom+8]; diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 2bfc7714be..e5413c6af7 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -3400,7 +3400,7 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) } else if (ptr = strstr(line,"||")) { strcat(constraintstr[myrxn],"||"); *ptr = '\0'; - } else if (i+1 < nconstraints[myrxn]){ + } else if (i+1 < nconstraints[myrxn]) { strcat(constraintstr[myrxn],"&&"); } if (ptr = strchr(line,')')) diff --git a/src/USER-REAXC/fix_qeq_reax.cpp b/src/USER-REAXC/fix_qeq_reax.cpp index 6db17d4d61..abe6f26081 100644 --- a/src/USER-REAXC/fix_qeq_reax.cpp +++ b/src/USER-REAXC/fix_qeq_reax.cpp @@ -811,16 +811,16 @@ int FixQEqReax::pack_forward_comm(int n, int *list, double *buf, int m; if (pack_flag == 1) - for(m = 0; m < n; m++) buf[m] = d[list[m]]; + for (m = 0; m < n; m++) buf[m] = d[list[m]]; else if (pack_flag == 2) - for(m = 0; m < n; m++) buf[m] = s[list[m]]; + for (m = 0; m < n; m++) buf[m] = s[list[m]]; else if (pack_flag == 3) - for(m = 0; m < n; m++) buf[m] = t[list[m]]; + for (m = 0; m < n; m++) buf[m] = t[list[m]]; else if (pack_flag == 4) - for(m = 0; m < n; m++) buf[m] = atom->q[list[m]]; + for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; else if (pack_flag == 5) { m = 0; - for(int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { int j = 2 * list[i]; buf[m++] = d[j ]; buf[m++] = d[j+1]; @@ -837,17 +837,17 @@ void FixQEqReax::unpack_forward_comm(int n, int first, double *buf) int i, m; if (pack_flag == 1) - for(m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) d[i] = buf[m]; else if (pack_flag == 2) - for(m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) s[i] = buf[m]; else if (pack_flag == 3) - for(m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) t[i] = buf[m]; else if (pack_flag == 4) - for(m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; + for (m = 0, i = first; m < n; m++, i++) atom->q[i] = buf[m]; else if (pack_flag == 5) { int last = first + n; m = 0; - for(i = first; i < last; i++) { + for (i = first; i < last; i++) { int j = 2 * i; d[j ] = buf[m++]; d[j+1] = buf[m++]; @@ -863,7 +863,7 @@ int FixQEqReax::pack_reverse_comm(int n, int first, double *buf) if (pack_flag == 5) { m = 0; int last = first + n; - for(i = first; i < last; i++) { + for (i = first; i < last; i++) { int indxI = 2 * i; buf[m++] = q[indxI ]; buf[m++] = q[indxI+1]; @@ -881,7 +881,7 @@ void FixQEqReax::unpack_reverse_comm(int n, int *list, double *buf) { if (pack_flag == 5) { int m = 0; - for(int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { int indxI = 2 * list[i]; q[indxI ] += buf[m++]; q[indxI+1] += buf[m++]; diff --git a/src/USER-REAXC/fix_reaxc_bonds.cpp b/src/USER-REAXC/fix_reaxc_bonds.cpp index 91f7f52ccc..fa115e343e 100644 --- a/src/USER-REAXC/fix_reaxc_bonds.cpp +++ b/src/USER-REAXC/fix_reaxc_bonds.cpp @@ -262,7 +262,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, double cutof3 = reaxc->control->bg_cut; MPI_Request irequest, irequest2; - if (me == 0 ){ + if (me == 0 ) { fprintf(fp,"# Timestep " BIGINT_FORMAT " \n",ntimestep); fprintf(fp,"# \n"); fprintf(fp,"# Number of particles %d \n",natoms); @@ -315,7 +315,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, MPI_Isend(&buf[0],nbuf_local,MPI_DOUBLE,0,0,world,&irequest2); MPI_Wait(&irequest2,MPI_STATUS_IGNORE); } - if(me ==0) fprintf(fp,"# \n"); + if (me ==0) fprintf(fp,"# \n"); } diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index d3507bdf85..1fb6eb9005 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -420,7 +420,7 @@ void PairReaxC::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for( int i = 0; i < LIST_N; ++i ) + for ( int i = 0; i < LIST_N; ++i ) if (lists[i].allocated != 1) lists[i].allocated = 0; @@ -470,7 +470,7 @@ void PairReaxC::setup( ) int num_nbrs = estimate_reax_lists(); if (num_nbrs < 0) error->all(FLERR,"Too many neighbors for pair style reax/c"); - if(!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, + if (!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, lists+FAR_NBRS)) error->all(FLERR,"Pair reax/c problem in far neighbor list"); (lists+FAR_NBRS)->error_ptr=error; @@ -478,7 +478,7 @@ void PairReaxC::setup( ) write_reax_lists(); Initialize( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for( int k = 0; k < system->N; ++k ) { + for ( int k = 0; k < system->N; ++k ) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -491,7 +491,7 @@ void PairReaxC::setup( ) // reset the bond list info for new atoms - for(int k = oldN; k < system->N; ++k) + for (int k = oldN; k < system->N; ++k) Set_End_Index( k, Start_Index( k, lists+BONDS ), lists+BONDS ); // check if I need to shrink/extend my data-structs @@ -560,7 +560,7 @@ void PairReaxC::compute(int eflag, int vflag) Compute_Forces(system,control,data,workspace,&lists,out_control,mpi_data); read_reax_forces(vflag); - for(int k = 0; k < system->N; ++k) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -616,7 +616,7 @@ void PairReaxC::compute(int eflag, int vflag) // populate tmpid and tmpbo arrays for fix reax/c/species int i, j; - if(fixspecies_flag) { + if (fixspecies_flag) { if (system->N > nmax) { memory->destroy(tmpid); memory->destroy(tmpbo); @@ -645,7 +645,7 @@ void PairReaxC::write_reax_atoms() if (system->N > system->total_cap) error->all(FLERR,"Too many ghost atoms"); - for( int i = 0; i < system->N; ++i ){ + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -703,13 +703,13 @@ int PairReaxC::estimate_reax_lists() int numall = list->inum + list->gnum; - for( itr_i = 0; itr_i < numall; ++itr_i ){ + for ( itr_i = 0; itr_i < numall; ++itr_i ) { i = ilist[itr_i]; marked[i] = 1; ++num_marked; jlist = firstneigh[i]; - for( itr_j = 0; itr_j < numneigh[i]; ++itr_j ){ + for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -751,7 +751,7 @@ int PairReaxC::write_reax_lists() int numall = list->inum + list->gnum; - for( itr_i = 0; itr_i < numall; ++itr_i ){ + for ( itr_i = 0; itr_i < numall; ++itr_i ) { i = ilist[itr_i]; jlist = firstneigh[i]; Set_Start_Index( i, num_nbrs, far_nbrs ); @@ -761,7 +761,7 @@ int PairReaxC::write_reax_lists() else cutoff_sqr = control->bond_cut*control->bond_cut; - for( itr_j = 0; itr_j < numneigh[i]; ++itr_j ){ + for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -784,7 +784,7 @@ int PairReaxC::write_reax_lists() void PairReaxC::read_reax_forces(int /*vflag*/) { - for( int i = 0; i < system->N; ++i ) { + for ( int i = 0; i < system->N; ++i ) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -846,7 +846,7 @@ double PairReaxC::memory_usage() bytes += lists->num_intrs * sizeof(far_neighbor_data); bytes += lists->num_intrs * sizeof(hbond_data); - if(fixspecies_flag) + if (fixspecies_flag) bytes += 2 * nmax * MAXSPECBOND * sizeof(double); return bytes; @@ -864,7 +864,7 @@ void PairReaxC::FindBond() for (i = 0; i < system->n; i++) { nj = 0; - for( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; diff --git a/src/USER-REAXC/reaxc_allocate.cpp b/src/USER-REAXC/reaxc_allocate.cpp index 8e7c8b2b23..f017eae41e 100644 --- a/src/USER-REAXC/reaxc_allocate.cpp +++ b/src/USER-REAXC/reaxc_allocate.cpp @@ -322,7 +322,7 @@ static void Reallocate_Neighbor_List( reax_list *far_nbrs, int n, int num_intrs ) { Delete_List( far_nbrs); - if(!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs )){ + if (!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs )) { far_nbrs->error_ptr->one(FLERR,"Problem in initializing far neighbors list"); } } @@ -361,7 +361,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, *total_bonds = 0; *est_3body = 0; - for( i = 0; i < system->N; ++i ){ + for( i = 0; i < system->N; ++i ) { *est_3body += SQR(system->my_atoms[i].num_bonds); *total_bonds += system->my_atoms[i].num_bonds; } @@ -374,7 +374,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, #endif Delete_List( bonds); - if(!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds)) { + if (!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds)) { bonds->error_ptr->one(FLERR, "Not enough space for bonds list"); } @@ -410,13 +410,13 @@ void ReAllocate( reax_system *system, control_params *control, realloc = &(workspace->realloc); - if( system->n >= DANGER_ZONE * system->local_cap || + if ( system->n >= DANGER_ZONE * system->local_cap || (0 && system->n <= LOOSE_ZONE * system->local_cap) ) { system->local_cap = MAX( (int)(system->n * safezone), mincap ); } int Nflag = 0; - if( system->N >= DANGER_ZONE * system->total_cap || + if ( system->N >= DANGER_ZONE * system->total_cap || (0 && system->N <= LOOSE_ZONE * system->total_cap) ) { Nflag = 1; system->total_cap = MAX( (int)(system->N * safezone), mincap ); @@ -466,7 +466,7 @@ void ReAllocate( reax_system *system, control_params *control, /* hydrogen bonds list */ if (control->hbond_cut > 0) { Hflag = 0; - if( system->numH >= DANGER_ZONE * system->Hcap || + if ( system->numH >= DANGER_ZONE * system->Hcap || (0 && system->numH <= LOOSE_ZONE * system->Hcap) ) { Hflag = 1; system->Hcap = int(MAX( system->numH * saferzone, mincap )); @@ -496,7 +496,7 @@ void ReAllocate( reax_system *system, control_params *control, realloc->num_3body = (int)(MAX(realloc->num_3body*safezone, MIN_3BODIES)); - if( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, + if ( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, (*lists)+THREE_BODIES ) ) { system->error_ptr->one(FLERR, "Problem in initializing angles list"); } diff --git a/src/USER-REAXC/reaxc_bond_orders.cpp b/src/USER-REAXC/reaxc_bond_orders.cpp index afa6c0ba5e..a9985d79f3 100644 --- a/src/USER-REAXC/reaxc_bond_orders.cpp +++ b/src/USER-REAXC/reaxc_bond_orders.cpp @@ -558,7 +558,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* } p_lp1 = system->reax_param.gp.l[15]; - for( j = 0; j < system->N; ++j ){ + for( j = 0; j < system->N; ++j ) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); diff --git a/src/USER-REAXC/reaxc_bonds.cpp b/src/USER-REAXC/reaxc_bonds.cpp index dd5b8ad89e..91dc38d56d 100644 --- a/src/USER-REAXC/reaxc_bonds.cpp +++ b/src/USER-REAXC/reaxc_bonds.cpp @@ -104,7 +104,7 @@ void Bonds( reax_system *system, control_params * /*control*/, /* Stabilisation terminal triple bond */ if (bo_ij->BO >= 1.00) { - if( gp37 == 2 || + if ( gp37 == 2 || (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990) ) { exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); diff --git a/src/USER-REAXC/reaxc_control.cpp b/src/USER-REAXC/reaxc_control.cpp index b805e46bf9..ab183bdaa4 100644 --- a/src/USER-REAXC/reaxc_control.cpp +++ b/src/USER-REAXC/reaxc_control.cpp @@ -134,7 +134,7 @@ char Read_Control_File( char *control_file, control_params* control, ival = atoi(tmp[1]); control->nsteps = ival; } - else if( strcmp(tmp[0], "dt") == 0) { + else if ( strcmp(tmp[0], "dt") == 0) { val = atof(tmp[1]); control->dt = val * 1.e-3; // convert dt from fs to ps! } diff --git a/src/USER-REAXC/reaxc_ffield.cpp b/src/USER-REAXC/reaxc_ffield.cpp index 5181415a9f..13e01c3a53 100644 --- a/src/USER-REAXC/reaxc_ffield.cpp +++ b/src/USER-REAXC/reaxc_ffield.cpp @@ -303,7 +303,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, /* Equate vval3 to valf for first-row elements (25/10/2004) */ for( i = 0; i < reax->num_atom_types; i++ ) - if( reax->sbp[i].mass < 21 && + if ( reax->sbp[i].mass < 21 && reax->sbp[i].valency_val != reax->sbp[i].valency_boc ) { if (me == 0) { char errmsg[256]; diff --git a/src/USER-REAXC/reaxc_forces.cpp b/src/USER-REAXC/reaxc_forces.cpp index 2ebffed25e..3cc66b7530 100644 --- a/src/USER-REAXC/reaxc_forces.cpp +++ b/src/USER-REAXC/reaxc_forces.cpp @@ -155,7 +155,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l (int)(MAX(Num_Entries(Hindex, hbonds)*saferzone, system->minhbonds)); //if( Num_Entries(i, hbonds) >= - //(Start_Index(i+1,hbonds)-Start_Index(i,hbonds))*0.90/*DANGER_ZONE*/){ + //(Start_Index(i+1,hbonds)-Start_Index(i,hbonds))*0.90/*DANGER_ZONE*/) { // workspace->realloc.hbonds = 1; if (Hindex < numH-1) @@ -367,7 +367,7 @@ void Estimate_Storages( reax_system *system, control_params *control, j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); - if(nbr_pj->d <= cutoff) { + if (nbr_pj->d <= cutoff) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; r_ij = nbr_pj->d; @@ -384,7 +384,7 @@ void Estimate_Storages( reax_system *system, control_params *control, jhb = sbp_j->p_hbond; if (ihb == 1 && jhb == 2) ++hb_top[i]; - else if( j < system->n && ihb == 2 && jhb == 1 ) + else if ( j < system->n && ihb == 2 && jhb == 1 ) ++hb_top[j]; } } diff --git a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp index 780b5f04a4..680f069bab 100644 --- a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp +++ b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp @@ -80,7 +80,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, if (type_i < 0) continue; bo_ij = &(pbond_ij->bo_data); - if( system->reax_param.sbp[type_i].p_hbond == 2 && + if ( system->reax_param.sbp[type_i].p_hbond == 2 && bo_ij->BO >= HB_THRESHOLD ) hblist[top++] = pi; } diff --git a/src/USER-REAXC/reaxc_init_md.cpp b/src/USER-REAXC/reaxc_init_md.cpp index e651f272ac..e7d46fa742 100644 --- a/src/USER-REAXC/reaxc_init_md.cpp +++ b/src/USER-REAXC/reaxc_init_md.cpp @@ -58,7 +58,7 @@ int Init_System(reax_system *system, control_params *control, char * /*msg*/) /* estimate numH and Hcap */ system->numH = 0; if (control->hbond_cut > 0) - for(i = 0; i < system->n; ++i) { + for (i = 0; i < system->n; ++i) { atom = &(system->my_atoms[i]); if (system->reax_param.sbp[ atom->type ].p_hbond == 1 && atom->type >= 0) atom->Hindex = system->numH++; @@ -101,7 +101,7 @@ void Init_Taper(control_params *control, storage *workspace) if (swb < 0) { error->all(FLERR,"Negative upper Taper-radius cutoff"); } - else if(swb < 5 && control->me == 0) { + else if (swb < 5 && control->me == 0) { char errmsg[256]; snprintf(errmsg, 256, "Very low Taper-radius cutoff: %f", swb); error->warning(FLERR, errmsg); @@ -178,13 +178,13 @@ int Init_Lists(reax_system *system, control_params *control, if (control->hbond_cut > 0) { /* init H indexes */ total_hbonds = 0; - for(i = 0; i < system->n; ++i) { + for (i = 0; i < system->n; ++i) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = (int)(MAX(total_hbonds*saferzone,mincap*system->minhbonds)); - if(!Make_List(system->Hcap, total_hbonds, TYP_HBOND, + if (!Make_List(system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS)) error->one(FLERR, "Not enough space for hbonds list."); @@ -192,13 +192,13 @@ int Init_Lists(reax_system *system, control_params *control, } total_bonds = 0; - for(i = 0; i < system->N; ++i) { + for (i = 0; i < system->N; ++i) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = (int)(MAX(total_bonds*safezone, mincap*MIN_BONDS)); - if(!Make_List(system->total_cap, bond_cap, TYP_BOND, + if (!Make_List(system->total_cap, bond_cap, TYP_BOND, *lists+BONDS)) error->one(FLERR, "Not enough space for bonds list."); @@ -206,7 +206,7 @@ int Init_Lists(reax_system *system, control_params *control, /* 3bodies list */ cap_3body = (int)(MAX(num_3body*safezone, MIN_3BODIES)); - if(!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, + if (!Make_List(bond_cap, cap_3body, TYP_THREE_BODY, *lists+THREE_BODIES)) error->one(FLERR,"Problem in initializing angles list."); diff --git a/src/USER-REAXC/reaxc_io_tools.cpp b/src/USER-REAXC/reaxc_io_tools.cpp index 3e1c00307d..6ac64a17bc 100644 --- a/src/USER-REAXC/reaxc_io_tools.cpp +++ b/src/USER-REAXC/reaxc_io_tools.cpp @@ -61,7 +61,7 @@ int Init_Output_Files( reax_system *system, control_params *control, } /* init pressure file */ - if( control->ensemble == NPT || + if ( control->ensemble == NPT || control->ensemble == iNPT || control->ensemble == sNPT ) { sprintf( temp, "%s.prs", control->sim_name ); @@ -109,15 +109,15 @@ void Output_Results( reax_system *system, control_params *control, output_controls *out_control, mpi_datatypes *mpi_data ) { - if((out_control->energy_update_freq > 0 && + if ((out_control->energy_update_freq > 0 && data->step%out_control->energy_update_freq == 0) || (out_control->write_steps > 0 && - data->step%out_control->write_steps == 0)){ + data->step%out_control->write_steps == 0)) { /* update system-wide energies */ Compute_System_Energy( system, data, mpi_data->world ); /* output energies */ - if( system->my_rank == MASTER_NODE && + if ( system->my_rank == MASTER_NODE && out_control->energy_update_freq > 0 && data->step % out_control->energy_update_freq == 0 ) { @@ -141,7 +141,7 @@ void Output_Results( reax_system *system, control_params *control, } /* write current frame */ - if( out_control->write_steps > 0 && + if ( out_control->write_steps > 0 && (data->step-data->prev_steps) % out_control->write_steps == 0 ) { Append_Frame( system, control, data, lists, out_control, mpi_data ); } diff --git a/src/USER-REAXC/reaxc_lookup.cpp b/src/USER-REAXC/reaxc_lookup.cpp index e39412ace6..980e6e0fb6 100644 --- a/src/USER-REAXC/reaxc_lookup.cpp +++ b/src/USER-REAXC/reaxc_lookup.cpp @@ -31,20 +31,20 @@ #include "reaxc_tool_box.h" void Tridiagonal_Solve( const double *a, const double *b, - double *c, double *d, double *x, unsigned int n){ + double *c, double *d, double *x, unsigned int n) { int i; double id; c[0] /= b[0]; /* Division by zero risk. */ d[0] /= b[0]; /* Division by zero would imply a singular matrix. */ - for(i = 1; i < (int)n; i++){ + for (i = 1; i < (int)n; i++) { id = (b[i] - c[i-1] * a[i]); /* Division by zero risk. */ c[i] /= id; /* Last value calculated is redundant. */ d[i] = (d[i] - d[i-1] * a[i])/id; } x[n - 1] = d[n - 1]; - for(i = n - 2; i >= 0; i--) + for (i = n - 2; i >= 0; i--) x[i] = d[i] - c[i] * x[i + 1]; } @@ -64,26 +64,26 @@ void Natural_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const d /* build the linear system */ a[0] = a[1] = a[n-1] = 0; - for( i = 2; i < (int)n-1; ++i ) + for ( i = 2; i < (int)n-1; ++i ) a[i] = h[i-1]; b[0] = b[n-1] = 0; - for( i = 1; i < (int)n-1; ++i ) + for ( i = 1; i < (int)n-1; ++i ) b[i] = 2 * (h[i-1] + h[i]); c[0] = c[n-2] = c[n-1] = 0; - for( i = 1; i < (int)n-2; ++i ) + for ( i = 1; i < (int)n-2; ++i ) c[i] = h[i]; d[0] = d[n-1] = 0; - for( i = 1; i < (int)n-1; ++i ) + for ( i = 1; i < (int)n-1; ++i ) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); v[0] = 0; v[n-1] = 0; Tridiagonal_Solve( &(a[1]), &(b[1]), &(c[1]), &(d[1]), &(v[1]), n-2 ); - for( i = 1; i < (int)n; ++i ){ + for ( i = 1; i < (int)n; ++i ) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -114,25 +114,25 @@ void Complete_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const /* build the linear system */ a[0] = 0; - for( i = 1; i < (int)n; ++i ) + for ( i = 1; i < (int)n; ++i ) a[i] = h[i-1]; b[0] = 2*h[0]; - for( i = 1; i < (int)n; ++i ) + for ( i = 1; i < (int)n; ++i ) b[i] = 2 * (h[i-1] + h[i]); c[n-1] = 0; - for( i = 0; i < (int)n-1; ++i ) + for ( i = 0; i < (int)n-1; ++i ) c[i] = h[i]; d[0] = 6 * (f[1]-f[0])/h[0] - 6 * v0; d[n-1] = 6 * vlast - 6 * (f[n-1]-f[n-2]/h[n-2]); - for( i = 1; i < (int)n-1; ++i ) + for ( i = 1; i < (int)n-1; ++i ) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); Tridiagonal_Solve( &(a[0]), &(b[0]), &(c[0]), &(d[0]), &(v[0]), n ); - for( i = 1; i < (int)n; ++i ){ + for ( i = 1; i < (int)n; ++i ) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -181,21 +181,21 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, LR = (LR_lookup_table**) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR"); - for( i = 0; i < num_atom_types; ++i ) + for ( i = 0; i < num_atom_types; ++i ) LR[i] = (LR_lookup_table*) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]"); - for( i = 0; i < REAX_MAX_ATOM_TYPES; ++i ) + for ( i = 0; i < REAX_MAX_ATOM_TYPES; ++i ) existing_types[i] = 0; - for( i = 0; i < system->n; ++i ) + for ( i = 0; i < system->n; ++i ) existing_types[ system->my_atoms[i].type ] = 1; MPI_Allreduce( existing_types, aggregated, REAX_MAX_ATOM_TYPES, MPI_INT, MPI_SUM, mpi_data->world ); - for( i = 0; i < num_atom_types; ++i ) { + for ( i = 0; i < num_atom_types; ++i ) { if (aggregated[i]) { - for( j = i; j < num_atom_types; ++j ) { + for ( j = i; j < num_atom_types; ++j ) { if (aggregated[j]) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; @@ -216,7 +216,7 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for( r = 1; r <= control->tabulate; ++r ) { + for ( r = 1; r <= control->tabulate; ++r ) { LR_vdW_Coulomb( system, workspace, control, i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -277,8 +277,8 @@ void Deallocate_Lookup_Tables( reax_system *system ) ntypes = system->reax_param.num_atom_types; - for( i = 0; i < ntypes; ++i ) { - for( j = i; j < ntypes; ++j ) + for ( i = 0; i < ntypes; ++i ) { + for ( j = i; j < ntypes; ++j ) if (LR[i][j].n) { sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y" ); sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H" ); diff --git a/src/USER-REAXC/reaxc_nonbonded.cpp b/src/USER-REAXC/reaxc_nonbonded.cpp index ccb8f0fed0..7c3350fd40 100644 --- a/src/USER-REAXC/reaxc_nonbonded.cpp +++ b/src/USER-REAXC/reaxc_nonbonded.cpp @@ -75,7 +75,7 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { + if (nbr_pj->d <= control->nonb_cut) { if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { @@ -110,7 +110,7 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, dTap += workspace->Tap[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -139,7 +139,7 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); data->my_en.e_vdW += Tap * e_core; @@ -243,7 +243,7 @@ void Tabulated_vdW_Coulomb_Energy( reax_system *system,control_params *control, orig_j = system->my_atoms[j].orig_id; flag = 0; - if(nbr_pj->d <= control->nonb_cut) { + if (nbr_pj->d <= control->nonb_cut) { if (j < natoms) flag = 1; else if (orig_i < orig_j) flag = 1; else if (orig_i == orig_j) { @@ -372,7 +372,7 @@ void LR_vdW_Coulomb( reax_system *system, storage *workspace, dTap += workspace->Tap[1]/r_ij; /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) { // shielding powr_vdW1 = pow(r_ij, p_vdW1); powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); @@ -397,7 +397,7 @@ void LR_vdW_Coulomb( reax_system *system, storage *workspace, Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; } - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + if (system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) { // inner wall e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); lr->e_vdW += Tap * e_core; diff --git a/src/USER-REAXC/reaxc_torsion_angles.cpp b/src/USER-REAXC/reaxc_torsion_angles.cpp index 380fbf4a02..c49b095b20 100644 --- a/src/USER-REAXC/reaxc_torsion_angles.cpp +++ b/src/USER-REAXC/reaxc_torsion_angles.cpp @@ -85,9 +85,9 @@ double Calculate_Omega( rvec dvec_ij, double r_ij, if (arg < -1.0) arg = -1.0; if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE; - else if( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) sin_ijk = -MIN_SINE; + else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) sin_ijk = -MIN_SINE; if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE; - else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) sin_jkl = -MIN_SINE; + else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) sin_jkl = -MIN_SINE; // dcos_omega_di rvec_ScaledSum( dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li ); @@ -230,7 +230,7 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; @@ -249,9 +249,9 @@ void Torsion_Angles( reax_system *system, control_params *control, fbp = &(system->reax_param.fbp[type_i][type_j] [type_k][type_l].prm[0]); - if( i != l && fbh->cnt && + if ( i != l && fbh->cnt && bo_kl->BO > control->thb_cut/*0*/ && - bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/ ){ + bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/ ) { ++num_frb_intrs; r_kl = pbond_kl->d; BOA_kl = bo_kl->BO - control->thb_cut; @@ -262,7 +262,7 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-REAXC/reaxc_traj.cpp b/src/USER-REAXC/reaxc_traj.cpp index b71d883c7d..2d56722aba 100644 --- a/src/USER-REAXC/reaxc_traj.cpp +++ b/src/USER-REAXC/reaxc_traj.cpp @@ -578,7 +578,7 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, for( i=0; i < system->n; ++i ) for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; - if( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && + if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && bonds->select.bond_list[pj].bo_data.BO >= control->bg_cut ) ++my_bonds; } @@ -605,7 +605,7 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, bo_ij = &( bonds->select.bond_list[pj] ); j = bo_ij->nbr; - if( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && + if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && bo_ij->bo_data.BO >= control->bg_cut ) { switch( out_control->bond_info ) { case OPT_BOND_BASIC: @@ -678,7 +678,7 @@ int Write_Angles( reax_system *system, control_params *control, k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); - if( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && + if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && bo_jk->bo_data.BO >= control->bg_cut ) // physical j&k bond ++my_angles; } @@ -711,7 +711,7 @@ int Write_Angles( reax_system *system, control_params *control, k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); - if( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && + if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && bo_jk->bo_data.BO >= control->bg_cut ) { // physical j&k bond sprintf( out_control->line, ANGLE_BASIC, system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, diff --git a/src/USER-REAXC/reaxc_valence_angles.cpp b/src/USER-REAXC/reaxc_valence_angles.cpp index 14c57773c7..b545fa93a9 100644 --- a/src/USER-REAXC/reaxc_valence_angles.cpp +++ b/src/USER-REAXC/reaxc_valence_angles.cpp @@ -176,7 +176,7 @@ void Valence_Angles( reax_system *system, control_params *control, BOA_ij = bo_ij->BO - control->thb_cut; - if( BOA_ij/*bo_ij->BO*/ > 0.0 && + if ( BOA_ij/*bo_ij->BO*/ > 0.0 && ( j < system->n || pbond_ij->nbr < system->n ) ) { i = pbond_ij->nbr; type_i = system->my_atoms[i].type; diff --git a/src/USER-SCAFACOS/scafacos.cpp b/src/USER-SCAFACOS/scafacos.cpp index 9cc7c408c1..ab28589f20 100644 --- a/src/USER-SCAFACOS/scafacos.cpp +++ b/src/USER-SCAFACOS/scafacos.cpp @@ -226,7 +226,7 @@ void Scafacos::compute(int eflag, int vflag) memcpy(xpbc,&x[0][0],3*nlocal*sizeof(double)); - if (domain->xperiodic || domain -> yperiodic || domain -> zperiodic){ + if (domain->xperiodic || domain -> yperiodic || domain -> zperiodic) { int j = 0; for (int i = 0; i < nlocal; i++) { domain->remap(&xpbc[j]); @@ -321,7 +321,7 @@ int Scafacos::modify_param(int narg, char **arg) else error->all(FLERR, "Illegal kspace_modify command (tolerance argument)"); // check if method is compatatible to chosen tolerance type - if( + if ( ( strcmp(method,"fmm") == 0 && ( diff --git a/src/USER-SMD/compute_smd_triangle_vertices.cpp b/src/USER-SMD/compute_smd_triangle_vertices.cpp index 9f2f11ebdf..f621029a47 100644 --- a/src/USER-SMD/compute_smd_triangle_vertices.cpp +++ b/src/USER-SMD/compute_smd_triangle_vertices.cpp @@ -95,7 +95,7 @@ void ComputeSMDTriangleVertices::compute_peratom() { int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && (mol[i] >= 65535) ){ + if ((mask[i] & groupbit) && (mol[i] >= 65535) ) { outputVector[i][0] = smd_data_9[i][0]; outputVector[i][1] = smd_data_9[i][1]; outputVector[i][2] = smd_data_9[i][2]; diff --git a/src/USER-SMD/pair_smd_tlsph.cpp b/src/USER-SMD/pair_smd_tlsph.cpp index 208be69acc..bf9fcdc1e7 100644 --- a/src/USER-SMD/pair_smd_tlsph.cpp +++ b/src/USER-SMD/pair_smd_tlsph.cpp @@ -679,7 +679,7 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { } // end loop over jj neighbors of i // avoid division by zero and overflow - if ((shepardWeight != 0.0) && (fabs(hourglass_error[i]) < 1.0e300)){ + if ((shepardWeight != 0.0) && (fabs(hourglass_error[i]) < 1.0e300)) { hourglass_error[i] /= shepardWeight; } diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index aedf90da07..5f416955cf 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -501,7 +501,7 @@ void PairSMTBQ::read_file(char *file) params[i].chi = atof(words[2]) ; params[i].dj = atof(words[3]) ; - if(strcmp(params[i].nom,"O")!=0){ + if (strcmp(params[i].nom,"O")!=0) { params[i].R = atof(words[4]) ; if (verbose) printf(" %s %f %f %f %f\n",words[0],params[i].ne,params[i].chi, params[i].dj,params[i].R); @@ -511,7 +511,7 @@ void PairSMTBQ::read_file(char *file) // Line 4bis - Coordinance et rayon pour Ox - if(strcmp(params[i].nom,"O")==0){ + if (strcmp(params[i].nom,"O")==0) { fgets( ptr, MAXLINE, fp); Tokenize ( ptr, &words ); @@ -543,7 +543,7 @@ void PairSMTBQ::read_file(char *file) ===================================================================== */ m = 0; maxintsm = 0; // - for (k=0 ; k<=maxintparam ; k++){intparams[k].intsm = 0;} + for (k=0 ; k<=maxintparam ; k++) {intparams[k].intsm = 0;} // --------------------------------- for (k = 0; k < maxintparam; k++) { // --------------------------------- @@ -597,7 +597,7 @@ void PairSMTBQ::read_file(char *file) intparams[m].intsm = maxintsm; if (strcmp(intparams[m].mode,"oxide") != 0 && - strcmp(intparams[m].mode,"metal") != 0){ + strcmp(intparams[m].mode,"metal") != 0) { error->all(FLERR,"needs mode to second moment interaction : oxide or metal"); } // if (strcmp(intparams[m].mode,"oxide") == 0) @@ -1400,8 +1400,8 @@ void PairSMTBQ::tabqeq() rcoupe = cutmax ; double cang ; - for (i = 0; i < n ; i++){ - for (j = i; j < n ; j++){ + for (i = 0; i < n ; i++) { + for (j = i; j < n ; j++) { rc = cutmax; if (verbose) printf ("cutmax %f\n",cutmax); m = coultype[i][j] ; @@ -1457,11 +1457,11 @@ void PairSMTBQ::tabqeq() // Make the table fafbOxOxSurf rc = cutmax; - if(strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0){ - if(strcmp(params[i].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0) { ra = ROxSurf; za = (2.0*params[i].ne + 1.0)/(4.0*ra);} - if(strcmp(params[j].nom,"O")==0) { + if (strcmp(params[j].nom,"O")==0) { rb = ROxSurf; zb = (2.0*params[j].ne + 1.0)/(4.0*rb); } @@ -1501,7 +1501,7 @@ void PairSMTBQ::tabqeq() if (r > (rc+nang)) {dij = 0.0 ; ddij = 0.0;} - if(strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0){ + if (strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0) { fafbOxOxSurf[k] = potqn[k] - dij ; if (k == 1) fafbOxOxSurf[0] = fafbOxOxSurf[k] ; @@ -1520,11 +1520,11 @@ void PairSMTBQ::tabqeq() // Makes the table fafbOxOxBB rc = cutmax; - if(strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0){ - if(strcmp(params[i].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0 || strcmp(params[j].nom,"O")==0) { + if (strcmp(params[i].nom,"O")==0) { ra = ROxBB; za = (2.0*params[i].ne + 1.0)/(4.0*ra);} - if(strcmp(params[j].nom,"O")==0) { + if (strcmp(params[j].nom,"O")==0) { rb = ROxBB; zb = (2.0*params[j].ne + 1.0)/(4.0*rb); } @@ -1565,7 +1565,7 @@ void PairSMTBQ::tabqeq() if (r > (rc+nang)) {dij = 0.0 ; ddij = 0.0;} - if(strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0){ + if (strcmp(params[i].nom,"O")==0 && strcmp(params[j].nom,"O")==0) { fafbOxOxBB[k] = potqn[k] - dij ; if (k == 1) fafbOxOxBB[0] = fafbOxOxBB[k] ; dfafbOxOxBB[k] = dpotqn[k] - ddij/r ; } @@ -1638,9 +1638,9 @@ void PairSMTBQ::potqeq(int i, int j, double qi, double qj, double rsq, fforce = - qi*qj*(t1 + (t2 - t1)*xi/2.0) ; - if(strcmp(params[itype].nom,"O")==0 || strcmp(params[jtype].nom,"O")==0){ + if (strcmp(params[itype].nom,"O")==0 || strcmp(params[jtype].nom,"O")==0) { - if(strcmp(params[itype].nom,"O")==0 && strcmp(params[jtype].nom,"O")==0){ + if (strcmp(params[itype].nom,"O")==0 && strcmp(params[jtype].nom,"O")==0) { // between two oxygens t1 = fafbOxOxSurf[l] + (fafbOxOxSurf[l+1] - fafbOxOxSurf[l])*xi; @@ -1680,7 +1680,7 @@ void PairSMTBQ::potqeq(int i, int j, double qi, double qj, double rsq, t2 = fafbTiOxBB[l+1] + (fafbTiOxBB[l+2] - fafbTiOxBB[l+1])*(xi-1.0); engBB = qi*qj*(t1 + (t2 - t1)*xi/2.0); - if(strcmp(params[jtype].nom,"O")==0) //the atom j is an oxygen + if (strcmp(params[jtype].nom,"O")==0) //the atom j is an oxygen { iIntfCoup2=jIntfCoup2; iCoord=jCoord; } @@ -1758,9 +1758,9 @@ void PairSMTBQ::pot_ES (int i, int j, double rsq, double &eng) engBulk=eng; - if(itype==0 || jtype==0){ + if (itype==0 || jtype==0) { - if(itype==0 && jtype==0){ // between two oxygens + if (itype==0 && jtype==0) { // between two oxygens t1 = fafbOxOxSurf[l] + (fafbOxOxSurf[l+1] - fafbOxOxSurf[l])*xi; t2 = fafbOxOxSurf[l+1] + (fafbOxOxSurf[l+2] - fafbOxOxSurf[l+1])*(xi-1.0); @@ -2062,7 +2062,7 @@ void PairSMTBQ::attractive(Intparam *intparam, double rsq, // if (i < 10) printf ("i %d, iq %f sbcov %f \n",i,iq,sbcov[i]); if (sqrt(r)(nQEqall[gp]); enegmax[gp] = enegmaxall[gp]; } @@ -2758,7 +2758,7 @@ void PairSMTBQ::Charge() // Statistique (ecart type) // ------------------------ for (i=0; i(nQEqcall[i]) ; TransfAll[i+2*cluster] /= static_cast(nQEqaall[i]) ;} sigmaa[i] = sigmac[i] = 0.0; @@ -2788,7 +2788,7 @@ void PairSMTBQ::Charge() - if (me == 0 && strcmp(Bavard,"false") != 0){ + if (me == 0 && strcmp(Bavard,"false") != 0) { for (gp = 0; gp < nteam+1; gp++) { printf (" -------------- Groupe %d -----------------\n",gp); printf (" qtotc %f(+- %f) qtota %f(+- %f)\n", @@ -3632,7 +3632,7 @@ void PairSMTBQ::CheckEnergyVSForce() drL=0.0001; iiiMax=int((cutmax-1.2)/drL); - for (iii=1; iii< iiiMax ; iii++){ + for (iii=1; iii< iiiMax ; iii++) { r=1.2+drL*iii; rsq=r*r; evdwlCoul = 0.0 ; fpairCoul = 0.0; @@ -3732,7 +3732,7 @@ void PairSMTBQ::CheckEnergyVSForce() drL=0.0001; iiiMax=int((cutmax-1.2)/drL); - for (iii=1; iii< iiiMax ; iii++){ + for (iii=1; iii< iiiMax ; iii++) { r=1.2+drL*iii; rsq=r*r; evdwlCoul = 0.0 ; fpairCoul = 0.0; diff --git a/src/USER-TALLY/compute_pe_mol_tally.cpp b/src/USER-TALLY/compute_pe_mol_tally.cpp index d4a7e80602..7cc0f95d80 100644 --- a/src/USER-TALLY/compute_pe_mol_tally.cpp +++ b/src/USER-TALLY/compute_pe_mol_tally.cpp @@ -100,7 +100,7 @@ void ComputePEMolTally::pair_tally_callback(int i, int j, int nlocal, int newton const tagint * const molid = atom->molecule; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ){ + || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { evdwl *= 0.5; ecoul *= 0.5; if (newton || i < nlocal) { diff --git a/src/USER-UEF/dump_cfg_uef.cpp b/src/USER-UEF/dump_cfg_uef.cpp index 4b1c8cc2c6..3f39bb5700 100644 --- a/src/USER-UEF/dump_cfg_uef.cpp +++ b/src/USER-UEF/dump_cfg_uef.cpp @@ -72,7 +72,7 @@ void DumpCFGUef::write_header(bigint n) // rot goes from "lab frame" to "upper triangular frame" // it's transpose takes the simulation box to the flow frame for (int i=0;i<3;i++) - for(int j=i+1;j<3;j++) + for (int j=i+1;j<3;j++) { double t=rot[i][j]; rot[i][j]=rot[j][i]; diff --git a/src/USER-UEF/uef_utils.cpp b/src/USER-UEF/uef_utils.cpp index 5fc92618b3..4febbbb577 100644 --- a/src/USER-UEF/uef_utils.cpp +++ b/src/USER-UEF/uef_utils.cpp @@ -277,9 +277,9 @@ void rotation_matrix(double q[3][3], double r[3][3], const double m[3][3]) // this makes r have positive diagonals // q*m = r <==> (-q)*m = (-r) will hold row-wise - if (r[0][0] < 0){ neg_row(q,0); neg_row(r,0); } - if (r[1][1] < 0){ neg_row(q,1); neg_row(r,1); } - if (r[2][2] < 0){ neg_row(q,2); neg_row(r,2); } + if (r[0][0] < 0) { neg_row(q,0); neg_row(r,0); } + if (r[1][1] < 0) { neg_row(q,1); neg_row(r,1); } + if (r[2][2] < 0) { neg_row(q,2); neg_row(r,2); } } /* ---------------------------------------------------------------------- diff --git a/src/USER-VTK/dump_vtk.cpp b/src/USER-VTK/dump_vtk.cpp index 98b8e0bb35..a2bf1fb4bf 100644 --- a/src/USER-VTK/dump_vtk.cpp +++ b/src/USER-VTK/dump_vtk.cpp @@ -1188,7 +1188,7 @@ void DumpVTK::write_domain_vtk() vtkSmartPointer gwriter = vtkSmartPointer::New(); - if(label) gwriter->SetHeader(label); + if (label) gwriter->SetHeader(label); else gwriter->SetHeader("Generated by LAMMPS"); if (binary) gwriter->SetFileTypeToBinary(); @@ -1212,7 +1212,7 @@ void DumpVTK::write_domain_vtk_triclinic() vtkSmartPointer gwriter = vtkSmartPointer::New(); - if(label) gwriter->SetHeader(label); + if (label) gwriter->SetHeader(label); else gwriter->SetHeader("Generated by LAMMPS"); if (binary) gwriter->SetFileTypeToBinary(); @@ -1305,7 +1305,7 @@ void DumpVTK::write_vtk(int n, double *mybuf) vtkSmartPointer writer = vtkSmartPointer::New(); #endif - if(label) writer->SetHeader(label); + if (label) writer->SetHeader(label); else writer->SetHeader("Generated by LAMMPS"); if (binary) writer->SetFileTypeToBinary(); @@ -1890,7 +1890,7 @@ void DumpVTK::identify_vectors() int num_vector3_starts = sizeof(vector3_starts) / sizeof(int); for (int v3s = 0; v3s < num_vector3_starts; v3s++) { - if(name.count(vector3_starts[v3s] ) && + if (name.count(vector3_starts[v3s] ) && name.count(vector3_starts[v3s]+1) && name.count(vector3_starts[v3s]+2) ) { @@ -1906,12 +1906,12 @@ void DumpVTK::identify_vectors() if (it->first < ATTRIBUTES) // neither fix nor compute continue; - if(argindex[it->first] == 0) // single value + if (argindex[it->first] == 0) // single value continue; // assume components are grouped together and in correct order - if(name.count(it->first + 1) && name.count(it->first + 2) ) { // more attributes? - if(it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? + if (name.count(it->first + 1) && name.count(it->first + 2) ) { // more attributes? + if (it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? it->second.compare(0,it->second.length()-3,name[it->first + 2],0,it->second.length()-3) == 0 ) { it->second.erase(it->second.length()-1); diff --git a/src/atom.cpp b/src/atom.cpp index 7b15b731c7..daead53a83 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1884,7 +1884,7 @@ void Atom::add_molecule(int narg, char **arg) int Atom::find_molecule(char *id) { - if(id == nullptr) return -1; + if (id == nullptr) return -1; int imol; for (imol = 0; imol < nmolecule; imol++) if (strcmp(id,molecules[imol]->id) == 0) return imol; @@ -2330,7 +2330,7 @@ void Atom::update_callback(int ifix) int Atom::find_custom(const char *name, int &flag) { - if(name == nullptr) return -1; + if (name == nullptr) return -1; for (int i = 0; i < nivector; i++) if (iname[i] && strcmp(iname[i],name) == 0) { diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index b4e03c6e57..6fa8ef7c37 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -201,7 +201,7 @@ void CommTiled::setup() cutghost[1] = cut * length1; length2 = h_inv[2]; cutghost[2] = cut * length2; - if (mode == Comm::MULTI){ + if (mode == Comm::MULTI) { for (i = 1; i <= ntypes; i++) { cutghostmulti[i][0] *= length0; cutghostmulti[i][1] *= length1; diff --git a/src/compute_hexorder_atom.cpp b/src/compute_hexorder_atom.cpp index b59d4d894d..aae935815c 100644 --- a/src/compute_hexorder_atom.cpp +++ b/src/compute_hexorder_atom.cpp @@ -260,8 +260,8 @@ inline void ComputeHexOrderAtom::calc_qn_complex(double delx, double dely, doubl inline void ComputeHexOrderAtom::calc_qn_trig(double delx, double dely, double &u, double &v) { double ntheta; - if(fabs(delx) <= MY_EPSILON) { - if(dely > 0.0) ntheta = ndegree * MY_PI / 2.0; + if (fabs(delx) <= MY_EPSILON) { + if (dely > 0.0) ntheta = ndegree * MY_PI / 2.0; else ntheta = ndegree * 3.0 * MY_PI / 2.0; } else ntheta = ndegree * atan(dely / delx); u = cos(ntheta); diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index b334654e82..b4f9662468 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -440,16 +440,16 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qnm_r[il][m] = 0.0; qnm_i[il][m] = 0.0; } } - for(int ineigh = 0; ineigh < ncount; ineigh++) { + for (int ineigh = 0; ineigh < ncount; ineigh++) { const double * const r = rlist[ineigh]; double rmag = dist(r); - if(rmag <= MY_EPSILON) { + if (rmag <= MY_EPSILON) { return; } @@ -457,7 +457,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, double expphi_r = r[0]; double expphi_i = r[1]; double rxymag = sqrt(expphi_r*expphi_r+expphi_i*expphi_i); - if(rxymag <= MY_EPSILON) { + if (rxymag <= MY_EPSILON) { expphi_r = 1.0; expphi_i = 0.0; } else { @@ -476,14 +476,14 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, qnm_r[il][l] += polar_prefactor(l, 0, costheta); double expphim_r = expphi_r; double expphim_i = expphi_i; - for(int m = 1; m <= +l; m++) { + for (int m = 1; m <= +l; m++) { double prefactor = polar_prefactor(l, m, costheta); double ylm_r = prefactor * expphim_r; double ylm_i = prefactor * expphim_i; qnm_r[il][m+l] += ylm_r; qnm_i[il][m+l] += ylm_i; - if(m & 1) { + if (m & 1) { qnm_r[il][-m+l] -= ylm_r; qnm_i[il][-m+l] += ylm_i; } else { @@ -504,7 +504,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, double facn = 1.0 / ncount; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qnm_r[il][m] *= facn; qnm_i[il][m] *= facn; } @@ -518,7 +518,7 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, int l = qlist[il]; double qnormfac = sqrt(MY_4PI/(2*l+1)); double qm_sum = 0.0; - for(int m = 0; m < 2*l+1; m++) + for (int m = 0; m < 2*l+1; m++) qm_sum += qnm_r[il][m]*qnm_r[il][m] + qnm_i[il][m]*qnm_i[il][m]; qn[jj++] = qnormfac * sqrt(qm_sum); } @@ -530,8 +530,8 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { int m = m1 + m2 - l; double qm1qm2_r = qnm_r[il][m1]*qnm_r[il][m2] - qnm_i[il][m1]*qnm_i[il][m2]; double qm1qm2_i = qnm_r[il][m1]*qnm_i[il][m2] + qnm_i[il][m1]*qnm_r[il][m2]; @@ -550,8 +550,8 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, for (int il = 0; il < nqlist; il++) { int l = qlist[il]; double wlsum = 0.0; - for(int m1 = 0; m1 < 2*l+1; m1++) { - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { int m = m1 + m2 - l; double qm1qm2_r = qnm_r[il][m1]*qnm_r[il][m2] - qnm_i[il][m1]*qnm_i[il][m2]; double qm1qm2_i = qnm_r[il][m1]*qnm_i[il][m2] + qnm_i[il][m1]*qnm_r[il][m2]; @@ -575,14 +575,14 @@ void ComputeOrientOrderAtom::calc_boop(double **rlist, int il = iqlcomp; int l = qlcomp; if (qn[il] < QEPSILON) - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qn[jj++] = 0.0; qn[jj++] = 0.0; } else { double qnormfac = sqrt(MY_4PI/(2*l+1)); double qnfac = qnormfac/qn[il]; - for(int m = 0; m < 2*l+1; m++) { + for (int m = 0; m < 2*l+1; m++) { qn[jj++] = qnm_r[il][m] * qnfac; qn[jj++] = qnm_i[il][m] * qnfac; } @@ -663,8 +663,8 @@ void ComputeOrientOrderAtom::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) + for (int m1 = 0; m1 < 2*l+1; m1++) + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) idxcg_count++; } idxcg_max = idxcg_count; @@ -673,9 +673,9 @@ void ComputeOrientOrderAtom::init_clebsch_gordan() idxcg_count = 0; for (int il = 0; il < nqlist; il++) { int l = qlist[il]; - for(int m1 = 0; m1 < 2*l+1; m1++) { + for (int m1 = 0; m1 < 2*l+1; m1++) { aa2 = m1 - l; - for(int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { + for (int m2 = MAX(0,l-m1); m2 < MIN(2*l+1,3*l-m1+1); m2++) { bb2 = m2 - l; m = aa2 + bb2 + l; diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 93a9e68a16..16e2ade2af 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -70,7 +70,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) if (iarg+3 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 3; - } else if (strcmp(arg[iarg],"bond") == 0 ){ + } else if (strcmp(arg[iarg],"bond") == 0 ) { if (iarg+5 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 5; @@ -110,7 +110,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) nadapt++; iarg += 6; - } else if (strcmp(arg[iarg],"bond") == 0 ){ + } else if (strcmp(arg[iarg],"bond") == 0 ) { if (iarg+5 > narg) error->all(FLERR, "Illegal fix adapt command"); adapt[nadapt].which = BOND; int n = strlen(arg[iarg+1]) + 1; @@ -395,7 +395,7 @@ void FixAdapt::init() } delete [] pstyle; - } else if (ad->which == BOND){ + } else if (ad->which == BOND) { ad->bond = nullptr; anybond = 1; @@ -463,10 +463,10 @@ void FixAdapt::init() for (i = ad->ilo; i <= ad->ihi; i++) for (j = MAX(ad->jlo,i); j <= ad->jhi; j++) ad->array_orig[i][j] = ad->array[i][j]; - } else if (ad->which == PAIR && ad->pdim == 0){ + } else if (ad->which == PAIR && ad->pdim == 0) { ad->scalar_orig = *ad->scalar; - } else if (ad->which == BOND && ad->bdim == 1){ + } else if (ad->which == BOND && ad->bdim == 1) { for (i = ad->ilo; i <= ad->ihi; ++i ) ad->vector_orig[i] = ad->vector[i]; } @@ -565,7 +565,7 @@ void FixAdapt::change_settings() // set bond type array values: } else if (ad->which == BOND) { - if (ad->bdim == 1){ + if (ad->bdim == 1) { if (scaleflag) for (i = ad->ilo; i <= ad->ihi; ++i ) ad->vector[i] = value*ad->vector_orig[i]; diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 1a638db742..61a36819b0 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -138,7 +138,7 @@ void FixAveHistoWeight::end_of_step() if (which[i] == X) { weights = &atom->x[0][j]; stride = 3; - } else if (which[i] == V){ + } else if (which[i] == V) { weights = &atom->v[0][j]; stride = 3; bin_atoms(&atom->v[0][j],3); diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp index d4edc0d7f2..4aec94fc32 100644 --- a/src/fix_deform.cpp +++ b/src/fix_deform.cpp @@ -362,7 +362,7 @@ rfix(nullptr), irregular(nullptr), set(nullptr) FixDeform::~FixDeform() { - if(set) { + if (set) { for (int i = 0; i < 6; i++) { delete [] set[i].hstr; delete [] set[i].hratestr; diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index b4f6bc987d..674cda4529 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -779,11 +779,11 @@ void FixNH::setup(int /*vflag*/) // if it was read in from a restart file, leave it be if (t0 == 0.0) { - if(p_temp_flag) { + if (p_temp_flag) { t0 = p_temp; } else { t0 = temperature->compute_scalar(); - if(t0 < EPSILON) + if (t0 < EPSILON) error->all(FLERR, "Current temperature too close to zero, consider using ptemp setting"); } } diff --git a/src/fix_nh_sphere.cpp b/src/fix_nh_sphere.cpp index bd599d6731..4e7fb24039 100644 --- a/src/fix_nh_sphere.cpp +++ b/src/fix_nh_sphere.cpp @@ -45,7 +45,7 @@ FixNHSphere::FixNHSphere(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { - if (strcmp(arg[iarg],"disc") == 0){ + if (strcmp(arg[iarg],"disc") == 0) { inertia = 0.5; if (domain->dimension != 2) error->all(FLERR, @@ -127,7 +127,7 @@ void FixNHSphere::nve_x() double **omega = atom->omega; int *mask = atom->mask; int nlocal = atom->nlocal; - if (dlm_flag == 0){ + if (dlm_flag == 0) { // d_mu/dt = omega cross mu // renormalize mu to dipole length double msq,scale,g[3]; @@ -174,7 +174,7 @@ void FixNHSphere::nve_x() // Q = I + vx + vx^2 * (1-c)/s^2 s2 = a[0]*a[0] + a[1]*a[1]; - if (s2 != 0.0){ // i.e. the vectors are not parallel + if (s2 != 0.0) { // i.e. the vectors are not parallel scale = (1.0 - a[2])/s2; Q[0][0] = 1.0 - scale*a[0]*a[0]; Q[0][1] = -scale*a[0]*a[1]; Q[0][2] = -a[0]; diff --git a/src/fix_nve_sphere.cpp b/src/fix_nve_sphere.cpp index 44a08638bf..cad821176b 100644 --- a/src/fix_nve_sphere.cpp +++ b/src/fix_nve_sphere.cpp @@ -187,7 +187,7 @@ void FixNVESphere::initial_integrate(int /*vflag*/) // Q = I + vx + vx^2 * (1-c)/s^2 s2 = a[0]*a[0] + a[1]*a[1]; - if (s2 != 0.0){ // i.e. the vectors are not parallel + if (s2 != 0.0) { // i.e. the vectors are not parallel scale = (1.0 - a[2])/s2; Q[0][0] = 1.0 - scale*a[0]*a[0]; diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index 674c436e9d..eedf24c387 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -105,7 +105,7 @@ double FixTempCSVR::sumnoises(int nn) { the system so it samples the canonical ensemble ---------------------------------------------------------------------- */ -double FixTempCSVR::resamplekin(double ekin_old, double ekin_new){ +double FixTempCSVR::resamplekin(double ekin_old, double ekin_new) { const double tdof = temperature->dof; const double c1 = exp(-update->dt/t_period); const double c2 = (1.0-c1)*ekin_new/ekin_old/tdof; diff --git a/src/hashlittle.cpp b/src/hashlittle.cpp index 5a8869bfea..a76e36050f 100644 --- a/src/hashlittle.cpp +++ b/src/hashlittle.cpp @@ -327,13 +327,13 @@ uint32_t LAMMPS_NS::hashlittle(const void *key, size_t length, uint32_t initval) h = 0; for (p = (uint32_t *)key, bytes=num_bytes; bytes >= (uint32_t) sizeof(uint32_t); - bytes-=sizeof(uint32_t), p++){ + bytes-=sizeof(uint32_t), p++) { h = (h^(*p))*MAXINT_DIV_PHI; } /* Then take care of the remaining bytes, if any */ rest = 0; - for (byteptr = (char *)p; bytes > 0; bytes--, byteptr++){ + for (byteptr = (char *)p; bytes > 0; bytes--, byteptr++) { rest = (rest<<8) | (*byteptr); } diff --git a/src/info.cpp b/src/info.cpp index 085e4e65ea..5202610f9a 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -654,20 +654,20 @@ void Info::available_styles(FILE * out, int flags) fputs("\nStyles information:\n",out); - if(flags & ATOM_STYLES) atom_styles(out); - if(flags & INTEGRATE_STYLES) integrate_styles(out); - if(flags & MINIMIZE_STYLES) minimize_styles(out); - if(flags & PAIR_STYLES) pair_styles(out); - if(flags & BOND_STYLES) bond_styles(out); - if(flags & ANGLE_STYLES) angle_styles(out); - if(flags & DIHEDRAL_STYLES) dihedral_styles(out); - if(flags & IMPROPER_STYLES) improper_styles(out); - if(flags & KSPACE_STYLES) kspace_styles(out); - if(flags & FIX_STYLES) fix_styles(out); - if(flags & COMPUTE_STYLES) compute_styles(out); - if(flags & REGION_STYLES) region_styles(out); - if(flags & DUMP_STYLES) dump_styles(out); - if(flags & COMMAND_STYLES) command_styles(out); + if (flags & ATOM_STYLES) atom_styles(out); + if (flags & INTEGRATE_STYLES) integrate_styles(out); + if (flags & MINIMIZE_STYLES) minimize_styles(out); + if (flags & PAIR_STYLES) pair_styles(out); + if (flags & BOND_STYLES) bond_styles(out); + if (flags & ANGLE_STYLES) angle_styles(out); + if (flags & DIHEDRAL_STYLES) dihedral_styles(out); + if (flags & IMPROPER_STYLES) improper_styles(out); + if (flags & KSPACE_STYLES) kspace_styles(out); + if (flags & FIX_STYLES) fix_styles(out); + if (flags & COMPUTE_STYLES) compute_styles(out); + if (flags & REGION_STYLES) region_styles(out); + if (flags & DUMP_STYLES) dump_styles(out); + if (flags & COMMAND_STYLES) command_styles(out); } void Info::atom_styles(FILE *out) @@ -935,31 +935,31 @@ bool Info::has_style(const std::string &category, const std::string &name) { if ( category == "atom" ) { return find_style(lmp, atom->avec_map, name, false); - } else if( category == "integrate" ) { + } else if ( category == "integrate" ) { return find_style(lmp, update->integrate_map, name, true); - } else if( category == "minimize" ) { + } else if ( category == "minimize" ) { return find_style(lmp, update->minimize_map, name, true); - } else if( category == "pair" ) { + } else if ( category == "pair" ) { return find_style(lmp, force->pair_map, name, true); - } else if( category == "bond" ) { + } else if ( category == "bond" ) { return find_style(lmp, force->bond_map, name, true); - } else if( category == "angle" ) { + } else if ( category == "angle" ) { return find_style(lmp, force->angle_map, name, true); - } else if( category == "dihedral" ) { + } else if ( category == "dihedral" ) { return find_style(lmp, force->dihedral_map, name, true); - } else if( category == "improper" ) { + } else if ( category == "improper" ) { return find_style(lmp, force->improper_map, name, true); - } else if( category == "kspace" ) { + } else if ( category == "kspace" ) { return find_style(lmp, force->kspace_map, name, true); - } else if( category == "fix" ) { + } else if ( category == "fix" ) { return find_style(lmp, modify->fix_map, name, true); - } else if( category == "compute" ) { + } else if ( category == "compute" ) { return find_style(lmp, modify->compute_map, name, true); - } else if( category == "region" ) { + } else if ( category == "region" ) { return find_style(lmp, domain->region_map, name, false); - } else if( category == "dump" ) { + } else if ( category == "dump" ) { return find_style(lmp, output->dump_map, name, false); - } else if( category == "command" ) { + } else if ( category == "command" ) { return find_style(lmp, input->command_map, name, false); } return false; @@ -969,31 +969,31 @@ std::vector Info::get_available_styles(const std::string &category) { if ( category == "atom" ) { return get_style_names(atom->avec_map); - } else if( category == "integrate" ) { + } else if ( category == "integrate" ) { return get_style_names(update->integrate_map); - } else if( category == "minimize" ) { + } else if ( category == "minimize" ) { return get_style_names(update->minimize_map); - } else if( category == "pair" ) { + } else if ( category == "pair" ) { return get_style_names(force->pair_map); - } else if( category == "bond" ) { + } else if ( category == "bond" ) { return get_style_names(force->bond_map); - } else if( category == "angle" ) { + } else if ( category == "angle" ) { return get_style_names(force->angle_map); - } else if( category == "dihedral" ) { + } else if ( category == "dihedral" ) { return get_style_names(force->dihedral_map); - } else if( category == "improper" ) { + } else if ( category == "improper" ) { return get_style_names(force->improper_map); - } else if( category == "kspace" ) { + } else if ( category == "kspace" ) { return get_style_names(force->kspace_map); - } else if( category == "fix" ) { + } else if ( category == "fix" ) { return get_style_names(modify->fix_map); - } else if( category == "compute" ) { + } else if ( category == "compute" ) { return get_style_names(modify->compute_map); - } else if( category == "region" ) { + } else if ( category == "region" ) { return get_style_names(domain->region_map); - } else if( category == "dump" ) { + } else if ( category == "dump" ) { return get_style_names(output->dump_map); - } else if( category == "command" ) { + } else if ( category == "command" ) { return get_style_names(input->command_map); } return std::vector(); @@ -1005,7 +1005,7 @@ static std::vector get_style_names(std::map std::vector names; names.reserve(styles->size()); - for(auto const& kv : *styles) { + for (auto const& kv : *styles) { // skip "secret" styles if (isupper(kv.first[0])) continue; names.push_back(kv.first); @@ -1049,7 +1049,7 @@ static void print_columns(FILE *fp, std::map *styles) // std::map keys are already sorted int pos = 80; - for(typename std::map::iterator it = styles->begin(); it != styles->end(); ++it) { + for (typename std::map::iterator it = styles->begin(); it != styles->end(); ++it) { const std::string &style_name = it->first; // skip "secret" styles @@ -1121,8 +1121,8 @@ bool Info::has_exceptions() { } bool Info::has_package(const char * package_name) { - for(int i = 0; LAMMPS::installed_packages[i] != nullptr; ++i) { - if(strcmp(package_name, LAMMPS::installed_packages[i]) == 0) { + for (int i = 0; LAMMPS::installed_packages[i] != nullptr; ++i) { + if (strcmp(package_name, LAMMPS::installed_packages[i]) == 0) { return true; } } diff --git a/src/library.cpp b/src/library.cpp index 17ca454b3c..00a922f98b 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -2444,7 +2444,7 @@ void lammps_scatter_atoms(void *handle, char *name, int type, int count, void *d int natoms = static_cast (lmp->atom->natoms); void *vptr = lmp->atom->extract(name); - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR, "lammps_scatter_atoms: unknown property name"); @@ -2561,7 +2561,7 @@ void lammps_scatter_atoms_subset(void *handle, char *name, int type, int count, } void *vptr = lmp->atom->extract(name); - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR, "lammps_scatter_atoms_subset: unknown property name"); @@ -2722,7 +2722,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -2751,7 +2751,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -2775,7 +2775,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) lmp->error->warning(FLERR,"lammps_gather: property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } @@ -2942,7 +2942,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -2971,7 +2971,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -2998,7 +2998,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d "property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } @@ -3183,7 +3183,7 @@ void lammps_gather_subset(void *handle, char *name, return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -3212,7 +3212,7 @@ void lammps_gather_subset(void *handle, char *name, if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -3239,7 +3239,7 @@ void lammps_gather_subset(void *handle, char *name, "property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } @@ -3414,7 +3414,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data) return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -3443,7 +3443,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data) if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; @@ -3467,12 +3467,12 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data) lmp->error->warning(FLERR,"lammps_scatter: property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR,"lammps_scatter: unknown property name"); return; @@ -3612,7 +3612,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count, return; } - if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom; else vptr = (void *) lmp->modify->fix[fcid]->array_atom; } @@ -3641,7 +3641,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count, if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep) lmp->modify->compute[fcid]->compute_peratom(); - if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; + if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom; else vptr = (void *) lmp->modify->compute[fcid]->array_atom; } @@ -3666,11 +3666,11 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count, "property/atom has count=1"); return; } - if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; + if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid]; else vptr = (void *) lmp->atom->dvector[fcid]; } - if(vptr == nullptr) { + if (vptr == nullptr) { if (lmp->comm->me == 0) lmp->error->warning(FLERR,"lammps_scatter_atoms_subset: " "unknown property name"); @@ -4025,7 +4025,7 @@ int lammps_neighlist_num_elements(void *handle, int idx) { LAMMPS * lmp = (LAMMPS *) handle; Neighbor * neighbor = lmp->neighbor; - if(idx < 0 || idx >= neighbor->nlist) { + if (idx < 0 || idx >= neighbor->nlist) { return -1; } @@ -4053,13 +4053,13 @@ void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int *numneigh = 0; *neighbors = nullptr; - if(idx < 0 || idx >= neighbor->nlist) { + if (idx < 0 || idx >= neighbor->nlist) { return; } NeighList * list = neighbor->lists[idx]; - if(element < 0 || element >= list->inum) { + if (element < 0 || element >= list->inum) { return; } @@ -4645,7 +4645,7 @@ void lammps_set_fix_external_callback(void *handle, char *id, FixExternalFnPtr c Fix *fix = lmp->modify->fix[ifix]; - if (strcmp("external",fix->style) != 0){ + if (strcmp("external",fix->style) != 0) { char str[128]; snprintf(str, 128, "Fix '%s' is not of style external!", id); lmp->error->all(FLERR,str); @@ -4819,7 +4819,7 @@ int lammps_get_last_error_message(void *handle, char *buffer, int buf_size) { Error *error = lmp->error; buffer[0] = buffer[buf_size-1] = '\0'; - if(!error->get_last_error().empty()) { + if (!error->get_last_error().empty()) { int error_type = error->get_last_error_type(); strncpy(buffer, error->get_last_error().c_str(), buf_size-1); error->set_last_error("", ERROR_NONE); diff --git a/src/modify.cpp b/src/modify.cpp index 2d0c23d125..f3ebb03c38 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1329,7 +1329,7 @@ void Modify::delete_compute(const std::string &id) int Modify::find_compute(const std::string &id) { - if(id.empty()) return -1; + if (id.empty()) return -1; for (int icompute = 0; icompute < ncompute; icompute++) if (id == compute[icompute]->id) return icompute; return -1; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 7761aae721..a76bf78c24 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -720,11 +720,11 @@ int Neighbor::init_pair() lists[i]->index = i; lists[i]->requestor = requests[i]->requestor; - if(requests[i]->pair) { + if (requests[i]->pair) { lists[i]->requestor_type = NeighList::PAIR; - } else if(requests[i]->fix) { + } else if (requests[i]->fix) { lists[i]->requestor_type = NeighList::FIX; - } else if(requests[i]->compute) { + } else if (requests[i]->compute) { lists[i]->requestor_type = NeighList::COMPUTE; } diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 7c4061d22d..01fc0adac3 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -113,10 +113,10 @@ void PairCoulStreitz::settings(int narg, char **arg) cut_coul = utils::numeric(FLERR,arg[0],false,lmp); - if (strcmp(arg[1],"wolf") == 0){ + if (strcmp(arg[1],"wolf") == 0) { kspacetype = 1; g_wolf = utils::numeric(FLERR,arg[2],false,lmp); - } else if (strcmp(arg[1],"ewald") == 0){ + } else if (strcmp(arg[1],"ewald") == 0) { ewaldflag = pppmflag = 1; kspacetype = 2; } else { @@ -297,7 +297,7 @@ void PairCoulStreitz::read_file(char *file) MPI_Bcast(&nparams, 1, MPI_INT, 0, world); MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - if(comm->me != 0) { + if (comm->me != 0) { params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); } diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index d41902c10d..2ad8bbb764 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -58,7 +58,7 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp, try { reader = open_potential(filename); - if(!reader) { + if (!reader) { error->one(FLERR, fmt::format("cannot open {} potential file {}", potential_name, filename)); } } catch (FileReaderException &e) { diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 9fe57198fd..a185f5ab3a 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -169,7 +169,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, labels[tokens.next()] = nwords++; } - if(nwords == 0) { + if (nwords == 0) { return 1; } diff --git a/src/region.cpp b/src/region.cpp index cd0464e10e..2fe2d88cef 100644 --- a/src/region.cpp +++ b/src/region.cpp @@ -496,7 +496,7 @@ void Region::set_velocity() prev[3] = theta; } - if (varshape){ + if (varshape) { set_velocity_shape(); } } @@ -514,12 +514,12 @@ void Region::velocity_contact(double *vwall, double *x, int ic) vwall[0] = vwall[1] = vwall[2] = 0.0; - if (moveflag){ + if (moveflag) { vwall[0] = v[0]; vwall[1] = v[1]; vwall[2] = v[2]; } - if (rotateflag){ + if (rotateflag) { xc[0] = x[0] - contact[ic].delx; xc[1] = x[1] - contact[ic].dely; xc[2] = x[2] - contact[ic].delz; diff --git a/src/region_block.cpp b/src/region_block.cpp index 385fcdd90a..4e433f424a 100644 --- a/src/region_block.cpp +++ b/src/region_block.cpp @@ -320,7 +320,7 @@ int RegBlock::surface_exterior(double *x, double cutoff) else zp = x[2]; } else { mindist = BIG; - for (int i = 0; i < 6; i++){ + for (int i = 0; i < 6; i++) { if (open_faces[i]) continue; dist = find_closest_point(i,x,xc,yc,zc); if (dist < mindist) { @@ -361,7 +361,7 @@ double RegBlock::find_closest_point(int i, double *x, // check if point projects inside of face - if (inside_face(xproj, i)){ + if (inside_face(xproj, i)) { d2 = d2min = dot*dot; xc = xproj[0] + corners[i][0][0]; yc = xproj[1] + corners[i][0][1]; diff --git a/src/region_cone.cpp b/src/region_cone.cpp index 72d315c16e..de3f8b254b 100644 --- a/src/region_cone.cpp +++ b/src/region_cone.cpp @@ -508,7 +508,7 @@ int RegCone::surface_exterior(double *x, double cutoff) distsq = BIG; - if (!open_faces[2]){ + if (!open_faces[2]) { point_on_line_segment(corner1,corner2,x,xp); distsq = closest(x,xp,nearest,distsq); crad = -2.0*(radiuslo + (nearest[1]-lo)*(radiushi-radiuslo)/(hi-lo)); @@ -573,7 +573,7 @@ int RegCone::surface_exterior(double *x, double cutoff) distsq = BIG; - if (!open_faces[2]){ + if (!open_faces[2]) { point_on_line_segment(corner1,corner2,x,xp); distsq = closest(x,xp,nearest,distsq); crad = -2.0*(radiuslo + (nearest[2]-lo)*(radiushi-radiuslo)/(hi-lo)); diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp index 306026cd7e..9e94a53046 100644 --- a/src/region_cylinder.cpp +++ b/src/region_cylinder.cpp @@ -520,7 +520,7 @@ int RegCylinder::surface_exterior(double *x, double cutoff) else d2 = dr2 + dx*dx; if (d2 < d2prev) { xp = hi; - if (r < radius){ + if (r < radius) { yp = x[1]; zp = x[2]; } @@ -572,7 +572,7 @@ int RegCylinder::surface_exterior(double *x, double cutoff) dr = r - radius; dr2 = dr*dr; - if (!open_faces[2]){ + if (!open_faces[2]) { xp = c1 + del1*radius/r; zp = c2 + del2*radius/r; if (x[1] < lo) { diff --git a/src/region_intersect.cpp b/src/region_intersect.cpp index beb8bb42b1..fb2b6239b1 100644 --- a/src/region_intersect.cpp +++ b/src/region_intersect.cpp @@ -313,7 +313,7 @@ void RegIntersect::write_restart(FILE *fp) fwrite(style, 1, sizestyle, fp); fwrite(&nregion,sizeof(int),1,fp); - for (int ilist = 0; ilist < nregion; ilist++){ + for (int ilist = 0; ilist < nregion; ilist++) { domain->regions[list[ilist]]->write_restart(fp); } } diff --git a/src/region_prism.cpp b/src/region_prism.cpp index 3ee45a4255..51c67c706c 100644 --- a/src/region_prism.cpp +++ b/src/region_prism.cpp @@ -393,7 +393,7 @@ void RegPrism::find_nearest(double *x, double &xp, double &yp, double &zp) xproj[0] = x[0] - dot*face[iface][0]; xproj[1] = x[1] - dot*face[iface][1]; xproj[2] = x[2] - dot*face[iface][2]; - if (inside_tri(xproj,corners[i],corners[j],corners[k],face[iface])){ + if (inside_tri(xproj,corners[i],corners[j],corners[k],face[iface])) { distsq = closest(x,xproj,nearest,distsq); } else { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index b254933531..37ebcd07fb 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -24,8 +24,8 @@ using namespace LAMMPS_NS; -TokenizerException::TokenizerException(const std::string &msg, const std::string &token){ - if(token.empty()) { +TokenizerException::TokenizerException(const std::string &msg, const std::string &token) { + if (token.empty()) { message = msg; } else { message = fmt::format("{}: '{}'", msg, token); @@ -83,12 +83,12 @@ bool Tokenizer::contains(const std::string &str) const { * * \param n number of tokens to skip over */ void Tokenizer::skip(int n) { - for(int i = 0; i < n; ++i) { - if(!has_next()) throw TokenizerException("No more tokens", ""); + for (int i = 0; i < n; ++i) { + if (!has_next()) throw TokenizerException("No more tokens", ""); size_t end = text.find_first_of(separators, start); - if(end == std::string::npos) { + if (end == std::string::npos) { start = end; } else { start = text.find_first_not_of(separators, end+1); @@ -107,11 +107,11 @@ bool Tokenizer::has_next() const { * * \return string with the next token */ std::string Tokenizer::next() { - if(!has_next()) throw TokenizerException("No more tokens", ""); + if (!has_next()) throw TokenizerException("No more tokens", ""); size_t end = text.find_first_of(separators, start); - if(end == std::string::npos) { + if (end == std::string::npos) { std::string token = text.substr(start); start = end; return token; @@ -210,7 +210,7 @@ std::string ValueTokenizer::next_string() { int ValueTokenizer::next_int() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_integer(current)) { + if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } int value = atoi(current.c_str()); @@ -225,7 +225,7 @@ int ValueTokenizer::next_int() { bigint ValueTokenizer::next_bigint() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_integer(current)) { + if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } bigint value = ATOBIGINT(current.c_str()); @@ -240,7 +240,7 @@ bigint ValueTokenizer::next_bigint() { tagint ValueTokenizer::next_tagint() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_integer(current)) { + if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } tagint value = ATOTAGINT(current.c_str()); @@ -255,7 +255,7 @@ tagint ValueTokenizer::next_tagint() { double ValueTokenizer::next_double() { if (has_next()) { std::string current = tokens.next(); - if(!utils::is_double(current)) { + if (!utils::is_double(current)) { throw InvalidFloatException(current); } double value = atof(current.c_str()); diff --git a/src/update.cpp b/src/update.cpp index a8a698a7f3..d52e5a742f 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -324,7 +324,7 @@ void Update::create_integrate(int narg, char **arg, int trysuffix) int sflag; - if(narg-1 > 0) { + if (narg-1 > 0) { new_integrate(arg[0],narg-1,&arg[1],trysuffix,sflag); } else { new_integrate(arg[0],0,nullptr,trysuffix,sflag); diff --git a/src/utils.cpp b/src/utils.cpp index 8bd36a8065..64283aa9c5 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -618,7 +618,7 @@ size_t utils::count_words(const std::string &text, const std::string &separators size_t end = text.find_first_of(separators, start); ++count; - if(end == std::string::npos) { + if (end == std::string::npos) { return count; } else { start = text.find_first_not_of(separators, end + 1); @@ -806,7 +806,7 @@ std::string utils::path_join(const std::string &a, const std::string &b) { bool utils::file_is_readable(const std::string &path) { FILE * fp = fopen(path.c_str(), "r"); - if(fp) { + if (fp) { fclose(fp); return true; } @@ -828,13 +828,13 @@ std::string utils::get_potential_file_path(const std::string &path) { std::string filepath = path; std::string filename = utils::path_basename(path); - if(utils::file_is_readable(filepath)) { + if (utils::file_is_readable(filepath)) { return filepath; } else { // try the environment variable directory const char *var = getenv("LAMMPS_POTENTIALS"); - if (var != nullptr){ + if (var != nullptr) { Tokenizer dirs(var,OS_PATH_VAR_SEP); while (dirs.has_next()) { @@ -935,12 +935,12 @@ FILE *utils::open_potential(const std::string &name, LAMMPS *lmp, std::string filepath = get_potential_file_path(name); - if(!filepath.empty()) { + if (!filepath.empty()) { std::string unit_style = lmp->update->unit_style; std::string date = get_potential_date(filepath, "potential"); std::string units = get_potential_units(filepath, "potential"); - if(!date.empty() && (me == 0)) { + if (!date.empty() && (me == 0)) { logmesg(lmp, fmt::format("Reading potential file {} " "with DATE: {}\n", name, date)); } diff --git a/src/variable.cpp b/src/variable.cpp index c339700787..bd5fc6cf8c 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -2755,7 +2755,7 @@ double Variable::collapse_tree(Tree *tree) ivalue3-ivalue1+1 < ivalue2 ) error->all(FLERR,"Invalid math function in variable formula"); if (update->ntimestep < ivalue1) tree->value = ivalue1; - //else if (update->ntimestep <= ivalue3){ + //else if (update->ntimestep <= ivalue3) { else { tree->value = ivalue1; double logsp = ivalue1; @@ -3664,7 +3664,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree, print_var_error(FLERR,"Invalid math function in variable formula",ivar); double value; if (update->ntimestep < ivalue1) value = ivalue1; - //else if (update->ntimestep <= ivalue3){ + //else if (update->ntimestep <= ivalue3) { else { value = ivalue1; double logsp = ivalue1; From 4f5192fa864c30938d1e12bc19b709e5f87d55bb Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:21:11 -0500 Subject: [PATCH 173/187] silence compiler warnings --- src/USER-BOCS/fix_bocs.cpp | 2 +- src/USER-DRUDE/fix_tgnh_drude.cpp | 2 -- src/USER-REACTION/fix_bond_react.cpp | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index 6a984edf60..438766e351 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -688,7 +688,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) int numBadVolumeIntervals = 0; // count these for message float f1, f2; int test_sscanf; - for (int i = 0; i < inputLines.size(); ++i) { + for (int i = 0; i < (int)inputLines.size(); ++i) { lineNum++; // count each line processed now so lineNum messages can be 1-based test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2); if (test_sscanf == 2) diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp index 167d8376db..d660f16c4a 100644 --- a/src/USER-DRUDE/fix_tgnh_drude.cpp +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -1101,8 +1101,6 @@ void FixTGNHDrude::remap() double oldlo,oldhi; double expfac; - double **x = atom->x; - int *mask = atom->mask; int nlocal = atom->nlocal; double *h = domain->h; diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index e5413c6af7..8d6b1b27ac 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -3385,25 +3385,25 @@ void FixBondReact::ReadConstraints(char *line, int myrxn) strcpy(constraintstr[myrxn],"("); // string for boolean constraint logic for (int i = 0; i < nconstraints[myrxn]; i++) { readline(line); - if (ptr = strrchr(line,'(')) { // reverse char search + if ((ptr = strrchr(line,'('))) { // reverse char search strncat(constraintstr[myrxn],line,ptr-line+1); line = ptr + 1; } // 'C' indicates where to sub in next constraint strcat(constraintstr[myrxn],"C"); - if (ptr = strchr(line,')')) { + if ((ptr = strchr(line,')'))) { strncat(constraintstr[myrxn],ptr,strrchr(line,')')-ptr+1); } - if (ptr = strstr(line,"&&")) { + if ((ptr = strstr(line,"&&"))) { strcat(constraintstr[myrxn],"&&"); *ptr = '\0'; - } else if (ptr = strstr(line,"||")) { + } else if ((ptr = strstr(line,"||"))) { strcat(constraintstr[myrxn],"||"); *ptr = '\0'; } else if (i+1 < nconstraints[myrxn]) { strcat(constraintstr[myrxn],"&&"); } - if (ptr = strchr(line,')')) + if ((ptr = strchr(line,')'))) *ptr = '\0'; sscanf(line,"%s",constraint_type); if (strcmp(constraint_type,"distance") == 0) { From 28de7e351a847257239282b69b6b8eacbc2a8918 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:23:47 -0500 Subject: [PATCH 174/187] fix off-by-one bug (arrhenius type constraint uses 5 parameters) --- src/USER-REACTION/fix_bond_react.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index a66f57c2bc..ad8d657e74 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -33,7 +33,7 @@ class FixBondReact : public Fix { enum {MAXLINE=256}; // max length of line read from files enum {MAXCONIDS=4}; // max # of IDs used by any constraint - enum {MAXCONPAR=4}; // max # of constraint parameters + enum {MAXCONPAR=5}; // max # of constraint parameters FixBondReact(class LAMMPS *, int, char **); ~FixBondReact(); From 51a20175c91b6dbf3306c0df78cb001048dace7f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:27:47 -0500 Subject: [PATCH 175/187] more code formatting consistency changes for loops and conditionals --- src/COLLOID/pair_lubricate_poly.cpp | 2 +- src/COMPRESS/zstd_file_writer.cpp | 6 +- src/KOKKOS/atom_vec_angle_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_kokkos.cpp | 6 +- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_sphere_kokkos.cpp | 4 +- .../compute_orientorder_atom_kokkos.cpp | 6 +- src/KOKKOS/fix_enforce2d_kokkos.cpp | 2 +- src/KOKKOS/fix_eos_table_rx_kokkos.cpp | 2 +- src/KOKKOS/fix_qeq_reax_kokkos.cpp | 16 ++--- src/KOKKOS/fix_rx_kokkos.cpp | 12 ++-- src/KOKKOS/nbin_kokkos.cpp | 2 +- src/KOKKOS/nbin_ssa_kokkos.cpp | 2 +- src/KOKKOS/npair_kokkos.cpp | 2 +- src/KOKKOS/npair_ssa_kokkos.cpp | 2 +- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 2 +- src/KOKKOS/pair_reaxc_kokkos.cpp | 38 +++++------ src/KOKKOS/pair_table_rx_kokkos.cpp | 4 +- src/KOKKOS/verlet_kokkos.cpp | 12 ++-- src/KSPACE/pair_lj_long_tip4p_long.cpp | 4 +- src/KSPACE/pppm_disp.cpp | 8 +-- src/MANYBODY/fix_qeq_comb.cpp | 2 +- src/MANYBODY/pair_comb.cpp | 6 +- src/MANYBODY/pair_comb3.cpp | 18 ++--- src/MANYBODY/pair_eam_cd.cpp | 4 +- src/MANYBODY/pair_eim.cpp | 4 +- src/MANYBODY/pair_gw.cpp | 2 +- src/MANYBODY/pair_gw_zbl.cpp | 2 +- src/MANYBODY/pair_lcbop.cpp | 52 +++++++------- src/MANYBODY/pair_nb3b_harmonic.cpp | 2 +- src/MANYBODY/pair_sw.cpp | 2 +- src/MANYBODY/pair_tersoff.cpp | 2 +- src/MANYBODY/pair_tersoff_mod.cpp | 2 +- src/MANYBODY/pair_tersoff_mod_c.cpp | 2 +- src/MANYBODY/pair_tersoff_zbl.cpp | 2 +- src/MANYBODY/pair_vashishta.cpp | 2 +- src/MC/fix_gcmc.cpp | 3 +- src/MC/fix_widom.cpp | 3 +- src/MISC/dump_xtc.cpp | 6 +- src/MPIIO/dump_cfg_mpiio.cpp | 2 +- src/MSCG/fix_mscg.cpp | 2 +- src/OPT/pair_eam_opt.cpp | 4 +- src/QEQ/fix_qeq.cpp | 38 +++++------ src/QEQ/fix_qeq_dynamic.cpp | 4 +- src/QEQ/fix_qeq_fire.cpp | 4 +- src/QEQ/fix_qeq_point.cpp | 6 +- src/QEQ/fix_qeq_shielded.cpp | 10 +-- src/QEQ/fix_qeq_slater.cpp | 8 +-- src/SHOCK/fix_append_atoms.cpp | 4 +- src/SHOCK/fix_msst.cpp | 58 ++++++++-------- src/SHOCK/fix_nphug.cpp | 6 +- src/SHOCK/fix_wall_piston.cpp | 4 +- src/USER-BOCS/compute_pressure_bocs.cpp | 4 +- src/USER-BOCS/fix_bocs.cpp | 12 ++-- src/USER-COLVARS/colvarproxy_lammps.cpp | 4 +- src/USER-COLVARS/fix_colvars.cpp | 2 +- src/USER-DIFFRACTION/compute_saed.cpp | 16 ++--- src/USER-DIFFRACTION/compute_xrd.cpp | 16 ++--- src/USER-DIFFRACTION/fix_saed_vtk.cpp | 26 +++---- src/USER-DPD/fix_rx.cpp | 6 +- src/USER-DPD/pair_table_rx.cpp | 4 +- src/USER-INTEL/fix_intel.cpp | 6 +- src/USER-INTEL/pair_buck_coul_cut_intel.cpp | 2 +- src/USER-INTEL/pair_buck_coul_long_intel.cpp | 2 +- src/USER-INTEL/pair_buck_intel.cpp | 2 +- .../pair_lj_charmm_coul_long_intel.cpp | 2 +- .../pair_lj_cut_coul_long_intel.cpp | 2 +- src/USER-INTEL/pair_tersoff_intel.cpp | 2 +- src/USER-MANIFOLD/fix_manifoldforce.cpp | 2 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp | 16 ++--- src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp | 21 +++--- src/USER-MANIFOLD/manifold_gaussian_bump.cpp | 6 +- src/USER-MANIFOLD/manifold_thylakoid.cpp | 10 +-- .../manifold_thylakoid_shared.cpp | 2 +- src/USER-MESODPD/pair_edpd.cpp | 2 +- src/USER-MESODPD/pair_mdpd.cpp | 2 +- src/USER-MESODPD/pair_tdpd.cpp | 2 +- src/USER-MGPT/mgpt_readpot.cpp | 6 +- src/USER-MGPT/pair_mgpt.cpp | 30 ++++---- src/USER-MISC/angle_fourier.cpp | 4 +- src/USER-MISC/angle_fourier_simple.cpp | 4 +- src/USER-MISC/angle_gaussian.cpp | 2 +- src/USER-MISC/bond_gaussian.cpp | 2 +- src/USER-MISC/compute_entropy_atom.cpp | 2 +- src/USER-MISC/compute_stress_mop.cpp | 8 +-- src/USER-MISC/compute_stress_mop_profile.cpp | 8 +-- src/USER-MISC/dihedral_fourier.cpp | 10 +-- src/USER-MISC/dihedral_nharmonic.cpp | 4 +- src/USER-MISC/dihedral_spherical.cpp | 20 +++--- src/USER-MISC/fix_flow_gauss.cpp | 8 +-- src/USER-MISC/fix_imd.cpp | 4 +- src/USER-MISC/fix_ipi.cpp | 2 +- src/USER-MISC/fix_propel_self.cpp | 6 +- src/USER-MISC/fix_rhok.cpp | 10 +-- src/USER-MISC/fix_ti_spring.cpp | 4 +- src/USER-MISC/improper_fourier.cpp | 6 +- src/USER-MISC/pair_e3b.cpp | 2 +- src/USER-MISC/pair_extep.cpp | 8 +-- src/USER-MISC/pair_list.cpp | 4 +- src/USER-MISC/pair_local_density.cpp | 14 ++-- src/USER-MISC/pair_meam_spline.cpp | 2 +- src/USER-MISC/pair_meam_sw_spline.cpp | 2 +- src/USER-MISC/pair_tersoff_table.cpp | 2 +- src/USER-MOLFILE/molfile_interface.cpp | 6 +- src/USER-MOLFILE/reader_molfile.cpp | 4 +- src/USER-OMP/angle_fourier_simple_omp.cpp | 4 +- src/USER-OMP/fix_qeq_comb_omp.cpp | 2 +- src/USER-OMP/improper_fourier_omp.cpp | 2 +- src/USER-OMP/pair_comb_omp.cpp | 2 +- src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp | 4 +- src/USER-OMP/pair_reaxc_omp.cpp | 12 ++-- src/USER-OMP/pair_tersoff_zbl_omp.cpp | 2 +- src/USER-OMP/reaxc_bond_orders_omp.cpp | 14 ++-- src/USER-OMP/reaxc_forces_omp.cpp | 10 +-- src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp | 10 +-- src/USER-OMP/reaxc_multi_body_omp.cpp | 6 +- src/USER-OMP/reaxc_nonbonded_omp.cpp | 4 +- src/USER-OMP/reaxc_torsion_angles_omp.cpp | 4 +- src/USER-PTM/ptm_voronoi_cell.cpp | 68 +++++++++---------- src/USER-QMMM/fix_qmmm.cpp | 2 +- src/USER-QTB/fix_qbmsst.cpp | 54 +++++++-------- src/USER-QUIP/pair_quip.cpp | 2 +- src/USER-REACTION/fix_bond_react.cpp | 6 +- src/USER-REAXC/fix_reaxc_bonds.cpp | 4 +- src/USER-REAXC/pair_reaxc.cpp | 20 +++--- src/USER-REAXC/reaxc_allocate.cpp | 26 +++---- src/USER-REAXC/reaxc_bond_orders.cpp | 18 ++--- src/USER-REAXC/reaxc_bonds.cpp | 6 +- src/USER-REAXC/reaxc_control.cpp | 6 +- src/USER-REAXC/reaxc_ffield.cpp | 50 +++++++------- src/USER-REAXC/reaxc_forces.cpp | 36 +++++----- src/USER-REAXC/reaxc_hydrogen_bonds.cpp | 8 +-- src/USER-REAXC/reaxc_io_tools.cpp | 6 +- src/USER-REAXC/reaxc_lookup.cpp | 36 +++++----- src/USER-REAXC/reaxc_multi_body.cpp | 14 ++-- src/USER-REAXC/reaxc_nonbonded.cpp | 10 +-- src/USER-REAXC/reaxc_reset_tools.cpp | 6 +- src/USER-REAXC/reaxc_tool_box.cpp | 2 +- src/USER-REAXC/reaxc_torsion_angles.cpp | 18 ++--- src/USER-REAXC/reaxc_traj.cpp | 44 ++++++------ src/USER-REAXC/reaxc_valence_angles.cpp | 24 +++---- src/USER-REAXC/reaxc_vector.cpp | 6 +- .../compute_smd_triangle_vertices.cpp | 2 +- src/USER-SMTBQ/pair_smtbq.cpp | 24 +++---- src/USER-TALLY/compute_force_tally.cpp | 2 +- src/USER-TALLY/compute_heat_flux_tally.cpp | 2 +- src/USER-TALLY/compute_pe_mol_tally.cpp | 2 +- src/USER-TALLY/compute_pe_tally.cpp | 2 +- src/USER-TALLY/compute_stress_tally.cpp | 2 +- src/USER-VTK/dump_vtk.cpp | 2 +- src/VORONOI/compute_voronoi_atom.cpp | 20 +++--- src/compute_orientorder_atom.cpp | 6 +- src/dump_cfg.cpp | 4 +- src/finish.cpp | 2 +- src/fix_adapt.cpp | 6 +- src/fix_halt.cpp | 2 +- src/info.cpp | 56 +++++++-------- src/library.cpp | 4 +- src/min_hftn.cpp | 4 +- src/min_linesearch.cpp | 2 +- src/molecule.cpp | 6 +- src/pair_coul_streitz.cpp | 4 +- src/pair_hybrid.cpp | 4 +- src/reader_native.cpp | 2 +- src/reader_xyz.cpp | 2 +- src/replicate.cpp | 12 ++-- src/text_file_reader.cpp | 4 +- src/tokenizer.cpp | 2 +- src/utils.cpp | 2 +- src/write_coeff.cpp | 2 +- 171 files changed, 744 insertions(+), 747 deletions(-) diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index a395f8c67e..b437bc2bfb 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -480,7 +480,7 @@ void PairLubricatePoly::init_style() if (strstr(modify->fix[i]->style,"wall") != nullptr) { flagwall = 1; // Walls exist - if (((FixWall *) modify->fix[i])->xflag ) { + if (((FixWall *) modify->fix[i])->xflag) { flagwall = 2; // Moving walls exist wallfix = (FixWall *) modify->fix[i]; } diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index 9f69f95395..f82ade605c 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -81,7 +81,7 @@ size_t ZstdFileWriter::write(const void * buffer, size_t length) ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); - } while(input.pos < input.size); + } while (input.pos < input.size); return length; } @@ -100,7 +100,7 @@ void ZstdFileWriter::flush() ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); - } while(remaining); + } while (remaining); fflush(fp); } @@ -119,7 +119,7 @@ void ZstdFileWriter::close() ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); - } while(remaining); + } while (remaining); ZSTD_freeCCtx(cctx); cctx = nullptr; diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 39897018ec..05f2661e64 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -491,7 +491,7 @@ struct AtomVecAngleKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecAngleKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 26fcda983b..5ab3691b16 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -526,7 +526,7 @@ struct AtomVecDPDKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecDPDKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 86c79141c0..4251a63b12 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -420,7 +420,7 @@ struct AtomVecKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); @@ -691,7 +691,7 @@ struct AtomVecKokkos_UnpackCommVel { /* ---------------------------------------------------------------------- */ void AtomVecKokkos::unpack_comm_vel_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { sync(Host,X_MASK|V_MASK); modified(Host,X_MASK|V_MASK); @@ -864,7 +864,7 @@ struct AtomVecKokkos_PackReverse { /* ---------------------------------------------------------------------- */ int AtomVecKokkos::pack_reverse_kokkos(const int &n, const int &first, - const DAT::tdual_ffloat_2d &buf ) { + const DAT::tdual_ffloat_2d &buf) { if (commKK->reverse_comm_on_host) { sync(Host,F_MASK); struct AtomVecKokkos_PackReverse f(atomKK->k_f,buf,first); diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index 2fb33e02b7..fb328584ff 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -563,7 +563,7 @@ struct AtomVecMolecularKokkos_UnpackComm { /* ---------------------------------------------------------------------- */ void AtomVecMolecularKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 451e9d737e..0b7a74966b 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -917,7 +917,7 @@ struct AtomVecSphereKokkos_UnpackComm { void AtomVecSphereKokkos::unpack_comm_kokkos( const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { // Fallback to AtomVecKokkos if radvary == 0 if (radvary == 0) { AtomVecKokkos::unpack_comm_kokkos(n,first,buf); @@ -994,7 +994,7 @@ struct AtomVecSphereKokkos_UnpackCommVel { void AtomVecSphereKokkos::unpack_comm_vel_kokkos( const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf ) { + const DAT::tdual_xfloat_2d &buf) { if (commKK->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); if (radvary == 0) { diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 8cac92240f..2325288c8c 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -341,17 +341,17 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder #define SWAP(view,i,j) do { \ tmp = view(i); view(i) = view(j); view(j) = tmp; \ - } while(0) + } while (0) #define ISWAP(view,i,j) do { \ itmp = view(i); view(i) = view(j); view(j) = itmp; \ - } while(0) + } while (0) #define SWAP3(view,i,j) do { \ tmp = view(i,0); view(i,0) = view(j,0); view(j,0) = tmp; \ tmp = view(i,1); view(i,1) = view(j,1); view(j,1) = tmp; \ tmp = view(i,2); view(i,2) = view(j,2); view(j,2) = tmp; \ - } while(0) + } while (0) /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 8608b90543..e4cf0e5309 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -77,7 +77,7 @@ void FixEnforce2DKokkos::post_force(int /*vflag*/) if (atomKK->torque_flag) flag_mask |= 4; copymode = 1; - switch( flag_mask ) { + switch (flag_mask) { case 0:{ FixEnforce2DKokkosPostForceFunctor functor(this); Kokkos::parallel_for(nlocal,functor); diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index a14e301bfa..4d181c2b41 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -303,7 +303,7 @@ void FixEOStableRXKokkos::energy_lookup(int id, double thetai, doubl nPG = 0; if (rx_flag) { - for (int ispecies = 0; ispecies < nspecies; ispecies++ ) { + for (int ispecies = 0; ispecies < nspecies; ispecies++) { nTotal += dvector(ispecies,id); if (fabs(d_moleculeCorrCoeff[ispecies]) > tolerance) { nPG++; diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index e81579061b..e607bea3e3 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -139,8 +139,8 @@ void FixQEqReaxKokkos::init_shielding_k() k_shield = DAT::tdual_ffloat_2d("qeq/kk:shield",ntypes+1,ntypes+1); d_shield = k_shield.template view(); - for ( i = 1; i <= ntypes; ++i ) - for ( j = 1; j <= ntypes; ++j ) + for (i = 1; i <= ntypes; ++i) + for (j = 1; j <= ntypes; ++j) k_shield.h_view(i,j) = pow( gamma[i] * gamma[j], -1.5 ); k_shield.template modify(); @@ -1371,11 +1371,11 @@ void FixQEqReaxKokkos::operator()(TagFixQEqReaxPackForwardComm, cons if (pack_flag == 1) d_buf[i] = d_d[j]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) d_buf[i] = d_s[j]; - else if ( pack_flag == 3 ) + else if (pack_flag == 3) d_buf[i] = d_t[j]; - else if ( pack_flag == 4 ) + else if (pack_flag == 4) d_buf[i] = q[j]; } @@ -1413,11 +1413,11 @@ int FixQEqReaxKokkos::pack_forward_comm(int n, int *list, double *bu if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = h_d[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = h_s[list[m]]; - else if ( pack_flag == 3 ) + else if (pack_flag == 3) for (m = 0; m < n; m++) buf[m] = h_t[list[m]]; - else if ( pack_flag == 4 ) + else if (pack_flag == 4) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; return n; diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 7a8bfbf9dd..036ecd1788 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -417,7 +417,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do // compute ydot at t=t0 k_rhs (t, y, ydot, userData); - while(1) + while (1) { // Estimate y'' with finite-difference ... @@ -455,11 +455,11 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do double hrat = hnew / hg; // Accept this value ... the bias factor should bring it within range. - if ( (hrat > 0.5) && (hrat < 2.0) ) + if ((hrat > 0.5) && (hrat < 2.0)) hnew_is_ok = true; // If y'' is still bad after a few iterations, just accept h and give up. - if ( (iter > 1) && hrat > 2.0 ) { + if ((iter > 1) && hrat > 2.0) { hnew = hg; hnew_is_ok = true; } @@ -736,7 +736,7 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl // compute ydot at t=t0 rhs (t, y, ydot, v_params); - while(1) + while (1) { // Estimate y'' with finite-difference ... @@ -774,11 +774,11 @@ int FixRxKokkos::rkf45_h0(const int neq, const double t, const doubl double hrat = hnew / hg; // Accept this value ... the bias factor should bring it within range. - if ( (hrat > 0.5) && (hrat < 2.0) ) + if ((hrat > 0.5) && (hrat < 2.0)) hnew_is_ok = true; // If y'' is still bad after a few iterations, just accept h and give up. - if ( (iter > 1) && hrat > 2.0 ) { + if ((iter > 1) && hrat > 2.0) { hnew = hg; hnew_is_ok = true; } diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 8234ceea6f..abe5b740f1 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -92,7 +92,7 @@ void NBinKokkos::bin_atoms() h_resize() = 1; - while(h_resize() > 0) { + while (h_resize() > 0) { h_resize() = 0; deep_copy(d_resize, h_resize); diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 276c3bee36..e38c7be8f2 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -293,7 +293,7 @@ void NBinSSAKokkos::sortBin( child = parent*2+1; /* Find the next child */ } gbins(ibin, parent) = t; /* We save t in the heap */ - } while(1); + } while (1); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index 564e1b0b98..20e819deaf 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -207,7 +207,7 @@ void NPairKokkos::build(NeighList *list_) data.special_flag[3] = special_flag[3]; data.h_resize()=1; - while(data.h_resize()) { + while (data.h_resize()) { data.h_new_maxneighs() = list->maxneighs; data.h_resize() = 0; diff --git a/src/KOKKOS/npair_ssa_kokkos.cpp b/src/KOKKOS/npair_ssa_kokkos.cpp index a3608fd35a..62be4a7d31 100644 --- a/src/KOKKOS/npair_ssa_kokkos.cpp +++ b/src/KOKKOS/npair_ssa_kokkos.cpp @@ -452,7 +452,7 @@ fprintf(stdout, "tota%03d total %3d could use %6d inums, expected %6d inums. inu bool firstTry = true; data.h_resize()=1; - while(data.h_resize()) { + while (data.h_resize()) { data.h_new_maxneighs() = list->maxneighs; data.h_resize() = 0; diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index 855d2b259a..4d89169c21 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -2227,7 +2227,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if ( nTotal[id] < MY_EPSILON || nTotalold[id] < MY_EPSILON ) + if (nTotal[id] < MY_EPSILON || nTotalold[id] < MY_EPSILON) errorFlag1 = 1; // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index 5d48b429cc..12eea720ba 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -375,7 +375,7 @@ void PairReaxCKokkos::init_md() k_tap.template sync(); - if ( control->tabulate ) { + if (control->tabulate) { int ntypes = atom->ntypes; Init_Lookup_Tables(); @@ -462,12 +462,12 @@ int PairReaxCKokkos::Init_Lookup_Tables() LR = (LR_lookup_table**) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table*), "lookup:LR"); - for ( i = 0; i < num_atom_types+1; ++i ) + for (i = 0; i < num_atom_types+1; ++i) LR[i] = (LR_lookup_table*) scalloc( control->error_ptr, num_atom_types+1, sizeof(LR_lookup_table), "lookup:LR[i]"); - for ( i = 1; i <= num_atom_types; ++i ) { - for ( j = i; j <= num_atom_types; ++j ) { + for (i = 1; i <= num_atom_types; ++i) { + for (j = i; j <= num_atom_types; ++j) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; LR[i][j].n = control->tabulate + 2; @@ -487,7 +487,7 @@ int PairReaxCKokkos::Init_Lookup_Tables() smalloc( control->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for ( r = 1; r <= control->tabulate; ++r ) { + for (r = 1; r <= control->tabulate; ++r) { LR_vdW_Coulomb(i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -546,9 +546,9 @@ void PairReaxCKokkos::Deallocate_Lookup_Tables() ntypes = atom->ntypes; - for ( i = 0; i <= ntypes; ++i ) { + for (i = 0; i <= ntypes; ++i) { if (map[i] == -1) continue; - for ( j = i; j <= ntypes; ++j ) { + for (j = i; j <= ntypes; ++j) { if (map[i] == -1) continue; if (LR[i][j].n) { sfree( control->error_ptr, LR[i][j].y, "LR[i,j].y" ); @@ -2301,8 +2301,8 @@ void PairReaxCKokkos::operator()(PairReaxComputeAngular::operator()(PairReaxComputeAngular::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) tan_ijk_i = cos_ijk / 1e-10; - else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) + else if (sin_ijk <= 0 && sin_ijk >= -1e-10) tan_ijk_i = -cos_ijk / 1e-10; else tan_ijk_i = cos_ijk / sin_ijk; @@ -2643,7 +2643,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion::operator()(PairReaxComputeTorsion= 0 && sin_jil <= 1e-10) tan_jil_i = cos_jil / 1e-10; - else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) + else if (sin_jil <= 0 && sin_jil >= -1e-10) tan_jil_i = -cos_jil / 1e-10; else tan_jil_i = cos_jil / sin_jil; @@ -2703,9 +2703,9 @@ void PairReaxCKokkos::operator()(PairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) sin_ijk_rnd = 1e-10; - else if ( sin_ijk <= 0 && sin_ijk >= -1e-10 ) sin_ijk_rnd = -1e-10; + else if (sin_ijk <= 0 && sin_ijk >= -1e-10) sin_ijk_rnd = -1e-10; if (sin_jil >= 0 && sin_jil <= 1e-10) sin_jil_rnd = 1e-10; - else if ( sin_jil <= 0 && sin_jil >= -1e-10 ) sin_jil_rnd = -1e-10; + else if (sin_jil <= 0 && sin_jil >= -1e-10) sin_jil_rnd = -1e-10; // dcos_omega_di for (int d = 0; d < 3; d++) dcos_omega_dk[d] = ((htra-arg*hnra)/rik) * delik[d] - dellk[d]; @@ -2944,7 +2944,7 @@ void PairReaxCKokkos::operator()(PairReaxComputeHydrogen::operator()(PairReaxComputeBond1= 1.00) { if (gp[37] == 2 || (imass == 12.0000 && jmass == 15.9990) || - (jmass == 12.0000 && imass == 15.9990) ) { + (jmass == 12.0000 && imass == 15.9990)) { const F_FLOAT exphu = exp(-gp[7] * SQR(BO_i - 2.50) ); const F_FLOAT exphua1 = exp(-gp[3] * (d_total_bo[i]-BO_i)); const F_FLOAT exphub1 = exp(-gp[3] * (d_total_bo[j]-BO_i)); @@ -3905,7 +3905,7 @@ void PairReaxCKokkos::operator()(PairReaxFindBondSpecies, const int double bo_tmp = d_BO(i,j_index); - if (bo_tmp >= 0.10 ) { // Why is this a hardcoded value? + if (bo_tmp >= 0.10) { // Why is this a hardcoded value? k_tmpid.view()(i,nj) = j; k_tmpbo.view()(i,nj) = bo_tmp; nj++; diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index 0c81090a39..162448416c 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -1117,7 +1117,7 @@ void PairTableRXKokkos::coeff(int narg, char **arg) ntables++; { - if ( strcmp(site1,"1fluid") == 0 ) + if (strcmp(site1,"1fluid") == 0) isite1 = OneFluidValue; else { isite1 = nspecies; @@ -1132,7 +1132,7 @@ void PairTableRXKokkos::coeff(int narg, char **arg) if (isite1 == nspecies) error->all(FLERR,"isite1 == nspecies"); } - if ( strcmp(site2,"1fluid") == 0 ) + if (strcmp(site2,"1fluid") == 0) isite2 = OneFluidValue; else { isite2 = nspecies; diff --git a/src/KOKKOS/verlet_kokkos.cpp b/src/KOKKOS/verlet_kokkos.cpp index 02cde691d2..3aa7a3575a 100644 --- a/src/KOKKOS/verlet_kokkos.cpp +++ b/src/KOKKOS/verlet_kokkos.cpp @@ -408,7 +408,7 @@ void VerletKokkos::run(int n) unsigned int datamask_modify_device = 0; unsigned int datamask_read_host = 0; - if ( pair_compute_flag ) { + if (pair_compute_flag) { if (force->pair->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->pair->datamask_read; @@ -418,7 +418,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->pair->datamask_modify; } } - if ( atomKK->molecular && force->bond ) { + if (atomKK->molecular && force->bond) { if (force->bond->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->bond->datamask_read; @@ -428,7 +428,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->bond->datamask_modify; } } - if ( atomKK->molecular && force->angle ) { + if (atomKK->molecular && force->angle) { if (force->angle->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->angle->datamask_read; @@ -438,7 +438,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->angle->datamask_modify; } } - if ( atomKK->molecular && force->dihedral ) { + if (atomKK->molecular && force->dihedral) { if (force->dihedral->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->dihedral->datamask_read; @@ -448,7 +448,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->dihedral->datamask_modify; } } - if ( atomKK->molecular && force->improper ) { + if (atomKK->molecular && force->improper) { if (force->improper->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->improper->datamask_read; @@ -458,7 +458,7 @@ void VerletKokkos::run(int n) datamask_modify_device |= force->improper->datamask_modify; } } - if ( kspace_compute_flag ) { + if (kspace_compute_flag) { if (force->kspace->execution_space==Host) { execute_on_host = true; datamask_read_host |= force->kspace->datamask_read; diff --git a/src/KSPACE/pair_lj_long_tip4p_long.cpp b/src/KSPACE/pair_lj_long_tip4p_long.cpp index 3421381d37..a6949fe085 100644 --- a/src/KSPACE/pair_lj_long_tip4p_long.cpp +++ b/src/KSPACE/pair_lj_long_tip4p_long.cpp @@ -566,7 +566,7 @@ void PairLJLongTIP4PLong::compute_inner() rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); @@ -819,7 +819,7 @@ void PairLJLongTIP4PLong::compute_middle() rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 2500336e8f..6621f5bdf3 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -1289,7 +1289,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs // allocate data for eigenvalue decomposition double **A=nullptr; double **Q=nullptr; - if ( n > 1 ) { + if (n > 1) { // get dispersion coefficients double **b = (double **) force->pair->extract("B",tmp); memory->create(A,n,n,"pppm/disp:A"); @@ -1364,7 +1364,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs // check if the function should preferably be [1] or [2] or [3] if (nsplit == 1) { - if ( B ) delete [] B; + if (B) delete [] B; function[3] = 0; function[2] = 0; function[1] = 1; @@ -1380,7 +1380,7 @@ void PPPMDisp::init_coeffs() // local pair coeffs } if (function[2] && (nsplit > 6)) { if (me == 0) utils::logmesg(lmp," Using 7 structure factors\n"); - if ( B ) delete [] B; + if (B) delete [] B; } if (function[3]) { if (me == 0) @@ -2130,7 +2130,7 @@ void PPPMDisp::allocate_peratom() } if (function[2]) { - if (differentiation_flag != 1 ) { + if (differentiation_flag != 1) { memory->create3d_offset(u_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); memory->create3d_offset(u_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 75abba2f09..1241d9905c 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -217,7 +217,7 @@ void FixQEQComb::post_force(int /*vflag*/) q1[i] = q2[i] = qf[i] = 0.0; } - for (iloop = 0; iloop < loopmax; iloop ++ ) { + for (iloop = 0; iloop < loopmax; iloop ++) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 5a724f7520..f6595f379c 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -283,7 +283,7 @@ void PairComb::compute(int eflag, int vflag) jtype = map[type[j]]; iparam_ij = elem2param[itype][jtype][jtype]; - if (params[iparam_ij].hfocor > 0.0 ) { + if (params[iparam_ij].hfocor > 0.0) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -595,7 +595,7 @@ void PairComb::read_file(char *file) PotentialFileReader reader(lmp, file, "comb"); char * line; - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); @@ -842,7 +842,7 @@ void PairComb::repulsive(Param *param, double rsq, double &fforce, Asi = param->biga1 * exp(param->lam11*Di); Asj = param->biga2 * exp(param->lam12*Dj); - if ( Asi > 0.0 && Asj > 0.0 ) + if (Asi > 0.0 && Asj > 0.0) bigA = sqrt(Asi*Asj)*param->romiga; else bigA = 0.0; diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index 30abb43dfc..f4434d9d76 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -531,7 +531,7 @@ void PairComb3::read_file(char *file) PotentialFileReader reader(lmp, file, "COMB3"); char * line; - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); @@ -1085,7 +1085,7 @@ void PairComb3::compute(int eflag, int vflag) sht_lnum = sht_num[j]; jtag = tag[j]; - if ( jtag <= itag ) continue ; + if (jtag <= itag) continue ; ycn = NCo[j]; jtype = map[type[j]]; @@ -1402,7 +1402,7 @@ void PairComb3::compute(int eflag, int vflag) // radical i-j-l-p: apply to all CC,CO,OC bonds if ( params[iparam_jil].rad_flag >= 1 && params[iparam_jil].ielementgp == 1 && - params[iparam_jil].kelementgp == 1 ) { + params[iparam_jil].kelementgp == 1) { iparam_lj = elem2param[ltype][jtype][jtype]; lcn=NCo[l]; double rjl=sqrt(rsq2); @@ -1667,7 +1667,7 @@ void PairComb3::force_zeta(Param *parami, Param *paramj, double rsq, // radical energy - if ( parami->rad_flag>0 ) { + if (parami->rad_flag>0) { rad_calc( r, parami, paramj, kconjug, lconjug, i, j, xcn, ycn); bij += brad[0]; pradx = brad[1]*att_eng; @@ -1701,7 +1701,7 @@ void PairComb3::force_zeta(Param *parami, Param *paramj, double rsq, prefac_ji5 = -0.5*att_eng*dbji5; // prefac_ji5 = -pfji4 // combines com6 & com7 below - if ( parami->rad_flag>0 || parami->tor_flag!=0 ) { + if (parami->rad_flag>0 || parami->tor_flag!=0) { prefac_ij2-=pradx; prefac_ji2-=prady; } @@ -1859,7 +1859,7 @@ void PairComb3::comb_fa(double r, Param *parami, Param *paramj, double iq, YYBn = (parami->aB-fabs(pow(parami->bB*(qi-parami->Qo),10))); YYBj = (paramj->aB-fabs(pow(paramj->bB*(qj-paramj->Qo),10))); - if (YYBn*YYBj > 0.0 ) { + if (YYBn*YYBj > 0.0) { AlfDiAlfDj = exp(0.5*(parami->alfi*Di+paramj->alfi*Dj)); Bsi = (pbij1*exp(-alfij1*r)+pbij2*exp(-alfij2*r)+pbij3*exp(-alfij3*r))* sqrt(YYBn*YYBj)*AlfDiAlfDj; // Bsi is cbj @@ -1894,7 +1894,7 @@ void PairComb3::comb_bij_d(double zet, Param *param, double r, int i, zeta = pow(zetang,pow_n)+pcorn; tmp_tbij=pow_n*pow(zetang,(pow_n-1.0)); - if ((1.0 + zeta) < 0.1 ) { + if ((1.0 + zeta) < 0.1) { zeta=0.1-1.0; tbij = pow(1.0 + zeta, -0.5/pow_n); tbij1=0.0; @@ -2933,7 +2933,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, vec3_scale(-1.0,delrl,delrl); rmul = sqrt(1.0-rmul*rmul); - if (rmul > 0.1 ) { + if (rmul > 0.1) { double fc1k, fc1l, TT1, TT2, rmut, btt, tork[3], torl[3]; fc1k = comb_fc(rik,paramk); @@ -3065,7 +3065,7 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, srmul = sqrt(1.0-rmul*rmul); if (acos(rmul) > MY_PI) srmul = -srmul; - if (srmul > 0.1 ) { + if (srmul > 0.1) { double fc1k, fcp1k, fc1l, fcp1l, srmul2, dt1dik, dt1djl; double TT1, TT2, rmut, btt, tork[3], torl[3]; double dt2dik[3], dt2djl[3], dt2dij[3], AA, AA2; diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index e028e53bb8..b56166424c 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -512,7 +512,7 @@ void PairEAMCD::read_h_coeff(char *filename) // h coefficients are stored at the end of the file. // Skip to last line of file. - while(fgets(nextline, MAXLINE, fptr) != nullptr) { + while (fgets(nextline, MAXLINE, fptr) != nullptr) { strcpy(line, nextline); } @@ -527,7 +527,7 @@ void PairEAMCD::read_h_coeff(char *filename) hcoeff = new double[nhcoeff]; int i = 0; - while(values.has_next()) { + while (values.has_next()) { hcoeff[i++] = values.next_double(); } diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index f95a43ed67..db673611e2 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -1108,7 +1108,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) { n = strlen(line); } - while(n == 0 || concat) { + while (n == 0 || concat) { char *ptr = fgets(&line[n], MAXLINE - n, fp); if (ptr == nullptr) { @@ -1143,7 +1143,7 @@ void EIMPotentialFileReader::parse(FILE * fp) char * line = nullptr; bool found_global = false; - while((line = next_line(fp))) { + while ((line = next_line(fp))) { ValueTokenizer values(line); std::string type = values.next_string(); diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 32ace05546..2f2b9922cb 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -385,7 +385,7 @@ void PairGW::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index bee8efb692..e166b1f1de 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -75,7 +75,7 @@ void PairGWZBL::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index 09ea20df52..070f23dbb9 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -535,12 +535,12 @@ void PairLCBOP::FLR(int eflag, int /*vflag*/) forces for Nij and Mij ------------------------------------------------------------------------- */ -void PairLCBOP::FNij( int i, int j, double factor, double **f, int vflag_atom ) { +void PairLCBOP::FNij( int i, int j, double factor, double **f, int vflag_atom) { int atomi = i; int atomj = j; int *SR_neighs = SR_firstneigh[i]; double **x = atom->x; - for( int k=0; kx; - for( int k=0; k( floor( N_ij ) ), 2 ); // 2 is the highest number of field size_t N_ji_int = MIN( static_cast( floor( N_ji ) ), 2 ); // cast to suppress warning double x = N_ij - N_ij_int; @@ -1096,9 +1096,9 @@ void PairLCBOP::read_file(char *filename) ------------------------------------------------------------------------- */ void PairLCBOP::spline_init() { - for( size_t N_conj_ij=0; N_conj_ij<2; N_conj_ij++ ) // N_conj_ij - for( size_t N_ij=0; N_ij<4-1; N_ij++ ) - for( size_t N_ji=0; N_ji<4-1; N_ji++ ) { + for (size_t N_conj_ij=0; N_conj_ij<2; N_conj_ij++) // N_conj_ij + for (size_t N_ij=0; N_ij<4-1; N_ij++) + for (size_t N_ji=0; N_ji<4-1; N_ji++) { TF_conj_field &field = F_conj_field[N_ij][N_ji][N_conj_ij]; field.f_00 = F_conj_data[N_ij ][N_ji ][N_conj_ij][0]; field.f_01 = F_conj_data[N_ij ][N_ji+1][N_conj_ij][0]; @@ -1126,7 +1126,7 @@ void PairLCBOP::spline_init() { // << gX[4] << " " // << gX[5] << std::endl; // file << "gC:\n"; -// for( int i=0; i<6; i++ ) +// for (int i=0; i<6; i++) // file << gC[i][0] << " " // << gC[i][1] << " " // << gC[i][2] << " " @@ -1170,7 +1170,7 @@ void PairLCBOP::spline_init() { // double x_1 = 1, x_0 = -1; // int n=1000; // double dx = (x_1-x_0)/n; -// for( double x=x_0; x<=x_1+0.0001; x+=dx ) { +// for (double x=x_0; x<=x_1+0.0001; x+=dx) { // double g, dg; // g = gSpline(x, &dg); // file << x << " " << g << " " << dg << std::endl; @@ -1181,7 +1181,7 @@ void PairLCBOP::spline_init() { // double x_1 = 1, x_0 = -1; // int n=1000; // double dx = (x_1-x_0)/n; -// for( double x=x_0; x<=x_1+0.0001; x+=dx ) { +// for (double x=x_0; x<=x_1+0.0001; x+=dx) { // double h, dh; // h = hSpline(x, &dh); // file << x << " " << h << " " << dh << std::endl; @@ -1193,7 +1193,7 @@ void PairLCBOP::spline_init() { // double x_1 = 4, x_0 = 0; // int n=1000; // double dx = (x_1-x_0)/n; -// for( double x=x_0; x<=x_1+0.0001; x+=dx ) { +// for (double x=x_0; x<=x_1+0.0001; x+=dx) { // double f, df; // f = f_c(x, r_1, r_2, &df); // file << x << " " << f << " " << df << std::endl; @@ -1217,23 +1217,23 @@ void PairLCBOP::spline_init() { // // file << "F_conj_0 "; // double dummy; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { +// for (double x=0; x<=3.0+0.0001; x+=0.1) { // file << x << " "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; // file << std::endl; // } // // file << "dF0_dx "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { +// for (double x=0; x<=3.0+0.0001; x+=0.1) { // file << x << " "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) { +// for (double y=0; y<=3.0+0.0001; y+=0.1) { // double dF_dx; // F_conj( x, y, 0, &dF_dx, &dummy, &dummy ); // file << dF_dx << " "; @@ -1244,12 +1244,12 @@ void PairLCBOP::spline_init() { // // // file << "F_conj_1 "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << y << " "; // file << std::endl; -// for( double x=0; x<=3.0+0.0001; x+=0.1 ) { +// for (double x=0; x<=3.0+0.0001; x+=0.1) { // file << x << " "; -// for( double y=0; y<=3.0+0.0001; y+=0.1 ) +// for (double y=0; y<=3.0+0.0001; y+=0.1) // file << F_conj( x, y, 0, &dummy, &dummy, &dummy ) << " "; // file << std::endl; // } diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 7e53dcc39c..a1dc903a43 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -301,7 +301,7 @@ void PairNb3bHarmonic::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index c94e75b4a2..e7a334d9a9 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -365,7 +365,7 @@ void PairSW::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index bcfcb149b4..3759932d9d 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -408,7 +408,7 @@ void PairTersoff::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index f5e4d21ffc..a25845196a 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -58,7 +58,7 @@ void PairTersoffMOD::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index c2cbcdd2d9..25bc735b9b 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -49,7 +49,7 @@ void PairTersoffMODC::read_file(char *file) int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index aee9eda71f..404868f969 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -77,7 +77,7 @@ void PairTersoffZBL::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 32f3212d75..94f211dd95 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -372,7 +372,7 @@ void PairVashishta::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 1587849ab7..79cfd09f96 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -485,8 +485,7 @@ void FixGCMC::init() (force->pair->single_enable == 0) || (force->pair_match("^hybrid",0)) || (force->pair_match("^eam",0)) || - (force->pair->tail_flag) - ) { + (force->pair->tail_flag)) { full_flag = true; if (comm->me == 0) error->warning(FLERR,"Fix gcmc using full_energy option"); diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index 202fd03dd1..c06573ab1a 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -287,8 +287,7 @@ void FixWidom::init() (force->pair->single_enable == 0) || (force->pair_match("hybrid",0)) || (force->pair_match("eam",0)) || - (force->pair->tail_flag) - ) { + (force->pair->tail_flag)) { full_flag = true; if (comm->me == 0) error->warning(FLERR,"Fix widom using full_energy option"); diff --git a/src/MISC/dump_xtc.cpp b/src/MISC/dump_xtc.cpp index 1f95220442..87eac61673 100644 --- a/src/MISC/dump_xtc.cpp +++ b/src/MISC/dump_xtc.cpp @@ -809,7 +809,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) /* when the number of coordinates is small, don't try to compress; just * write them as floats using xdr_vector */ - if (*size <= 9 ) { + if (*size <= 9) { return (xdr_vector(xdrs, (char *) fp, size3, sizeof(*fp), (xdrproc_t)xdr_float)); } @@ -851,7 +851,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) lip = ip; mindiff = INT_MAX; oldlint1 = oldlint2 = oldlint3 = 0; - while(lfp < fp + size3 ) { + while (lfp < fp + size3) { /* find nearest integer */ if (*lfp >= 0.0) lf = *lfp * *precision + 0.5; @@ -1131,7 +1131,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) run = 0; i = 0; lip = ip; - while ( i < lsize ) { + while (i < lsize) { thiscoord = (int *)(lip) + i * 3; if (bitsize == 0) { diff --git a/src/MPIIO/dump_cfg_mpiio.cpp b/src/MPIIO/dump_cfg_mpiio.cpp index eb9de685e3..07fb86d31c 100644 --- a/src/MPIIO/dump_cfg_mpiio.cpp +++ b/src/MPIIO/dump_cfg_mpiio.cpp @@ -416,7 +416,7 @@ int DumpCFGMPIIO::convert_string_omp(int n, double *mybuf) unwrap_coord = (mybuf[bufOffset[tid]+m] - 0.5)/UNWRAPEXPAND + 0.5; //offset += sprintf(&sbuf[offset],vformat[j],unwrap_coord); mpifhStringCountPerThread[tid] += sprintf(&(mpifh_buffer_line_per_thread[tid][mpifhStringCountPerThread[tid]]),vformat[j],unwrap_coord); - } else if (j >= 5 ) { + } else if (j >= 5) { if (vtype[j] == Dump::INT) //offset += // sprintf(&sbuf[offset],vformat[j],static_cast (mybuf[m])); diff --git a/src/MSCG/fix_mscg.cpp b/src/MSCG/fix_mscg.cpp index de17ae45be..38635b0891 100644 --- a/src/MSCG/fix_mscg.cpp +++ b/src/MSCG/fix_mscg.cpp @@ -73,7 +73,7 @@ FixMSCG::FixMSCG(LAMMPS *lmp, int narg, char **arg) : // parse remaining arguments int iarg = 4; - while(iarg < narg) { + while (iarg < narg) { if (strcmp(arg[iarg],"range") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix mscg command"); if (strcmp(arg[iarg+1],"on") == 0) diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp index c89afad705..c7d3541e67 100644 --- a/src/OPT/pair_eam_opt.cpp +++ b/src/OPT/pair_eam_opt.cpp @@ -202,7 +202,7 @@ void PairEAMOpt::eval() jtype = type[j] - 1; double p = sqrt(rsq)*tmp_rdr; - if ( (int)p <= nr2 ) { + if ((int)p <= nr2) { int m = (int)p + 1; p -= (double)((int)p); fast_alpha_t& a = tabeighti[jtype*nr+m]; @@ -289,7 +289,7 @@ void PairEAMOpt::eval() double r = sqrt(rsq); double rhoip,rhojp,z2,z2p; double p = r*tmp_rdr; - if ( (int)p <= nr2 ) { + if ((int)p <= nr2) { int m = (int) p + 1; m = MIN(m,nr-1); p -= (double)((int) p); diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 555b9d2770..733d566b7d 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -103,7 +103,7 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - for ( int i = 0; i < atom->nmax; i++ ) + for (int i = 0; i < atom->nmax; i++) for (int j = 0; j < nprev; ++j ) s_hist[i][j] = t_hist[i][j] = atom->q[i]; @@ -234,7 +234,7 @@ void FixQEq::allocate_matrix() numneigh = list->numneigh; m = 0; - for ( ii = 0; ii < inum; ii++ ) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; m += numneigh[i]; } @@ -306,7 +306,7 @@ void FixQEq::init_storage() nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for ( int i = 0; i < nall; i++ ) { + for (int i = 0; i < nall; i++) { Hdia_inv[i] = 1. / eta[atom->type[i]]; b_s[i] = -chi[atom->type[i]]; b_t[i] = -1.0; @@ -352,7 +352,7 @@ int FixQEq::CG( double *b, double *x ) vector_sum( r , 1., b, -1., q, inum ); - for ( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) d[i] = r[i] * Hdia_inv[i]; @@ -362,7 +362,7 @@ int FixQEq::CG( double *b, double *x ) b_norm = parallel_norm( b, inum ); sig_new = parallel_dot( r, d, inum); - for ( loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop ) { + for (loop = 1; loop < maxiter && sqrt(sig_new)/b_norm > tolerance; ++loop) { comm->forward_comm_fix(this); sparse_matvec( &H, d, q ); comm->reverse_comm_fix(this); @@ -373,7 +373,7 @@ int FixQEq::CG( double *b, double *x ) vector_add( x, alfa, d, inum ); vector_add( r, -alfa, q, inum ); - for ( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) p[i] = r[i] * Hdia_inv[i]; @@ -406,17 +406,17 @@ void FixQEq::sparse_matvec( sparse_matrix *A, double *x, double *b ) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - for ( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) b[i] = eta[ atom->type[i] ] * x[i]; } - for ( i = nlocal; i < nall; ++i ) { + for (i = nlocal; i < nall; ++i) { if (atom->mask[i] & groupbit) b[i] = 0; } - for ( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { for ( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; @@ -444,12 +444,12 @@ void FixQEq::calculate_Q() t_sum = parallel_vector_acc( t, inum); u = s_sum / t_sum; - for ( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { q[i] = s[i] - u * t[i]; - for ( k = 4; k > 0; --k ) { + for (k = 4; k > 0; --k) { s_hist[i][k] = s_hist[i][k-1]; t_hist[i][k] = t_hist[i][k-1]; } @@ -471,11 +471,11 @@ int FixQEq::pack_forward_comm(int n, int *list, double *buf, if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = d[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = s[list[m]]; - else if ( pack_flag == 3 ) + else if (pack_flag == 3) for (m = 0; m < n; m++) buf[m] = t[list[m]]; - else if ( pack_flag == 4 ) + else if (pack_flag == 4) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; else m = 0; @@ -591,7 +591,7 @@ double FixQEq::parallel_norm( double *v, int n ) my_sum = 0.0; norm_sqr = 0.0; - for ( ii = 0; ii < n; ++ii ) { + for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_sum += v[i]*v[i]; @@ -616,7 +616,7 @@ double FixQEq::parallel_dot( double *v1, double *v2, int n) my_dot = 0.0; res = 0.0; - for ( ii = 0; ii < n; ++ii ) { + for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_dot += v1[i] * v2[i]; @@ -641,7 +641,7 @@ double FixQEq::parallel_vector_acc( double *v, int n ) my_acc = 0.0; res = 0.0; - for ( ii = 0; ii < n; ++ii ) { + for (ii = 0; ii < n; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) my_acc += v[i]; @@ -662,7 +662,7 @@ void FixQEq::vector_sum( double* dest, double c, double* v, ilist = list->ilist; - for ( --k; k>=0; --k ) { + for (--k; k>=0; --k) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] = c * v[kk] + d * y[kk]; @@ -678,7 +678,7 @@ void FixQEq::vector_add( double* dest, double c, double* v, int k ) ilist = list->ilist; - for ( --k; k>=0; --k ) { + for (--k; k>=0; --k) { kk = ilist[k]; if (atom->mask[kk] & groupbit) dest[kk] += c * v[kk]; diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index 6fc98410eb..2bd63b718d 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -113,7 +113,7 @@ void FixQEqDynamic::pre_force(int /*vflag*/) q1[i] = q2[i] = qf[i] = 0.0; } - for (iloop = 0; iloop < maxiter; iloop ++ ) { + for (iloop = 0; iloop < maxiter; iloop ++) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { @@ -250,7 +250,7 @@ int FixQEqDynamic::pack_forward_comm(int n, int *list, double *buf, if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 613d6998aa..6e51c906bc 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -132,7 +132,7 @@ void FixQEqFire::pre_force(int /*vflag*/) dt = qstep; dtmax = TMAX * dt; - for (iloop = 0; iloop < maxiter; iloop ++ ) { + for (iloop = 0; iloop < maxiter; iloop ++) { pack_flag = 1; comm->forward_comm_fix(this); @@ -314,7 +314,7 @@ int FixQEqFire::pack_forward_comm(int n, int *list, double *buf, if (pack_flag == 1) for (m = 0; m < n; m++) buf[m] = atom->q[list[m]]; - else if ( pack_flag == 2 ) + else if (pack_flag == 2) for (m = 0; m < n; m++) buf[m] = qf[list[m]]; return m; diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index 0c9b918647..f112c4859f 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -95,7 +95,7 @@ void FixQEqPoint::init_matvec() inum = list->inum; ilist = list->ilist; - for( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { Hdia_inv[i] = 1. / eta[ atom->type[i] ]; @@ -131,14 +131,14 @@ void FixQEqPoint::compute_H() // fill in the H matrix m_fill = 0; - for( ii = 0; ii < inum; ii++ ) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { jlist = firstneigh[i]; jnum = numneigh[i]; H.firstnbr[i] = m_fill; - for( jj = 0; jj < jnum; jj++ ) { + for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 5cea54b4cb..decfe69ccc 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -97,8 +97,8 @@ void FixQEqShielded::init_shielding() double d7, swa2, swa3, swb2, swb3; int ntypes = atom->ntypes; - for( i = 1; i <= ntypes; ++i ) - for( j = 1; j <= ntypes; ++j ) + for (i = 1; i <= ntypes; ++i) + for (j = 1; j <= ntypes; ++j) shld[i][j] = pow( gamma[i] * gamma[j], -1.5 ); if (fabs(swa) > 0.01 && comm->me == 0) @@ -158,7 +158,7 @@ void FixQEqShielded::init_matvec() inum = list->inum; ilist = list->ilist; - for( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { Hdia_inv[i] = 1. / eta[ atom->type[i] ]; @@ -196,14 +196,14 @@ void FixQEqShielded::compute_H() // fill in the H matrix m_fill = 0; r_sqr = 0; - for( ii = 0; ii < inum; ii++ ) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { jlist = firstneigh[i]; jnum = numneigh[i]; H.firstnbr[i] = m_fill; - for( jj = 0; jj < jnum; jj++ ) { + for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 6860fab26b..5cab1f1979 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -136,7 +136,7 @@ void FixQEqSlater::init_matvec() inum = list->inum; ilist = list->ilist; - for( ii = 0; ii < inum; ++ii ) { + for (ii = 0; ii < inum; ++ii) { i = ilist[ii]; if (atom->mask[i] & groupbit) { Hdia_inv[i] = 1. / eta[ atom->type[i] ]; @@ -353,17 +353,17 @@ void FixQEqSlater::sparse_matvec( sparse_matrix *A, double *x, double *b ) double r = cutoff; double woself = 0.50*erfc(alpha*r)/r + alpha/MY_PIS; - for( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) b[i] = (eta[atom->type[i]] - 2.0*force->qqr2e*woself) * x[i]; } - for( i = nlocal; i < nall; ++i ) { + for (i = nlocal; i < nall; ++i) { if (atom->mask[i] & groupbit) b[i] = 0; } - for( i = 0; i < nlocal; ++i ) { + for (i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { for( itr_j=A->firstnbr[i]; itr_jfirstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; diff --git a/src/SHOCK/fix_append_atoms.cpp b/src/SHOCK/fix_append_atoms.cpp index f15831a498..cfff02d292 100644 --- a/src/SHOCK/fix_append_atoms.cpp +++ b/src/SHOCK/fix_append_atoms.cpp @@ -358,7 +358,7 @@ void FixAppendAtoms::post_force(int /*vflag*/) } for (int i = 0; i < nlocal; i++) { // SET TEMP AHEAD OF SHOCK - if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent ) { + if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent) { gamma1 = gfactor1[type[i]]; gamma2 = gfactor2[type[i]] * tsqrt; f[i][0] += gamma1*v[i][0] + gamma2*(randomt->uniform()-0.5); @@ -386,7 +386,7 @@ void FixAppendAtoms::post_force(int /*vflag*/) // set temp ahead of shock - if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent ) { + if (tempflag && x[i][2] >= domain->boxhi[2] - t_extent) { gamma1 = -rmass[i] / t_period / ftm2v; gamma2 = sqrt(rmass[i]) * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v; gamma2 *= tsqrt; diff --git a/src/SHOCK/fix_msst.cpp b/src/SHOCK/fix_msst.cpp index dabe4c425c..a73409e584 100644 --- a/src/SHOCK/fix_msst.cpp +++ b/src/SHOCK/fix_msst.cpp @@ -324,33 +324,33 @@ void FixMSST::setup(int /*vflag*/) couple(); velocity_sum = compute_vsum(); - if ( v0_set == 0 ) { + if (v0_set == 0) { v0 = compute_vol(); v0_set = 1; if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix MSST v0 = {:.8g}\n", v0)); } - if ( p0_set == 0 ) { + if (p0_set == 0) { p0 = p_current[direction]; p0_set = 1; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix MSST p0 = {:.8g}\n", p0)); } - if ( e0_set == 0 ) { + if (e0_set == 0) { e0 = compute_etotal(); e0_set = 1; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix MSST e0 = {:.8g}\n", e0)); } temperature->compute_vector(); double *ke_tensor = temperature->vector; double ke_temp = ke_tensor[0]+ke_tensor[1]+ke_tensor[2]; - if (ke_temp > 0.0 && tscale > 0.0 ) { + if (ke_temp > 0.0 && tscale > 0.0) { // transfer energy from atom velocities to cell volume motion // to bias initial compression @@ -371,7 +371,7 @@ void FixMSST::setup(int /*vflag*/) fac2,tscale)); for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - for (int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { v[i][k]*=sqrt_initial_temperature_scaling; } } @@ -453,7 +453,7 @@ void FixMSST::initial_integrate(int /*vflag*/) // use Taylor expansion to avoid singularity at B = 0 - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -469,7 +469,7 @@ void FixMSST::initial_integrate(int /*vflag*/) if (dftb) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; const double TS_term = TS_dot/(mass[type[i]]*velocity_sum); const double escale_term = force->ftm2v*beta*(e0-e_scale) / @@ -478,8 +478,8 @@ void FixMSST::initial_integrate(int /*vflag*/) (velocity_sum * mass[type[i]] * vol ); D += escale_term - TS_term; old_velocity[i][k] = v[i][k]; - if ( k == direction ) D -= 2.0 * omega[sd] / vol; - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (k == direction) D -= 2.0 * omega[sd] / vol; + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -492,15 +492,15 @@ void FixMSST::initial_integrate(int /*vflag*/) } else { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); old_velocity[i][k] = v[i][k]; - if ( k == direction ) { + if (k == direction) { D -= 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -529,7 +529,7 @@ void FixMSST::initial_integrate(int /*vflag*/) if (dftb) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; const double TS_term = TS_dot/(mass[type[i]]*velocity_sum); const double escale_term = force->ftm2v*beta*(e0-e_scale) / @@ -537,8 +537,8 @@ void FixMSST::initial_integrate(int /*vflag*/) double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); D += escale_term - TS_term; - if ( k == direction ) D -= 2.0 * omega[sd] / vol; - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (k == direction) D -= 2.0 * omega[sd] / vol; + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -551,14 +551,14 @@ void FixMSST::initial_integrate(int /*vflag*/) } else { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); - if ( k == direction ) { + if (k == direction) { D -= 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -647,7 +647,7 @@ void FixMSST::final_integrate() if (dftb) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; const double TS_term = TS_dot/(mass[type[i]]*velocity_sum); const double escale_term = force->ftm2v*beta*(e0-e_scale) / @@ -655,8 +655,8 @@ void FixMSST::final_integrate() double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); D += escale_term - TS_term; - if ( k == direction ) D -= 2.0 * omega[sd] / vol; - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (k == direction) D -= 2.0 * omega[sd] / vol; + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -669,14 +669,14 @@ void FixMSST::final_integrate() } else { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { const double C = f[i][k] * force->ftm2v / mass[type[i]]; double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ); - if ( k == direction ) { + if (k == direction) { D -= 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { const double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -707,11 +707,11 @@ void FixMSST::final_integrate() // prevent blow-up of the volume - if ( vol > v0 && A > 0.0 ) A = -A; + if (vol > v0 && A > 0.0) A = -A; // use taylor expansion to avoid singularity at B == 0. - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -766,7 +766,7 @@ void FixMSST::remap(int flag) // reset global and local box to new size/shape for (i = 0; i < 3; i++) { - if ( direction == i ) { + if (direction == i) { oldlo = domain->boxlo[i]; oldhi = domain->boxhi[i]; ctr = 0.5 * (oldlo + oldhi); diff --git a/src/SHOCK/fix_nphug.cpp b/src/SHOCK/fix_nphug.cpp index b8df9d7014..744f9d89cb 100644 --- a/src/SHOCK/fix_nphug.cpp +++ b/src/SHOCK/fix_nphug.cpp @@ -205,12 +205,12 @@ void FixNPHug::setup(int vflag) { FixNH::setup(vflag); - if ( v0_set == 0 ) { + if (v0_set == 0) { v0 = compute_vol(); v0_set = 1; } - if ( p0_set == 0 ) { + if (p0_set == 0) { p0_set = 1; if (uniaxial == 1) p0 = p_current[idir]; @@ -218,7 +218,7 @@ void FixNPHug::setup(int vflag) p0 = (p_current[0]+p_current[1]+p_current[2])/3.0; } - if ( e0_set == 0 ) { + if (e0_set == 0) { e0 = compute_etotal(); e0_set = 1; } diff --git a/src/SHOCK/fix_wall_piston.cpp b/src/SHOCK/fix_wall_piston.cpp index bddfcaa3cb..66c97bccda 100644 --- a/src/SHOCK/fix_wall_piston.cpp +++ b/src/SHOCK/fix_wall_piston.cpp @@ -307,7 +307,7 @@ void FixWallPiston::post_integrate() } for (int i = 0; i < nlocal; i++) { // SET TEMP AHEAD OF PISTON - if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent ) { + if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent) { gamma1 = gfactor1[type[i]]; gamma2 = gfactor2[type[i]] * tsqrt; f[i][0] += gamma1*v[i][0] + gamma2*(randomt->uniform()-0.5); @@ -324,7 +324,7 @@ void FixWallPiston::post_integrate() for (int i = 0; i < nlocal; i++) { // SET TEMP AHEAD OF PISTON - if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent ) { + if (tempflag && x[i][2] <= domain->boxlo[2] + t_extent) { gamma1 = -rmass[i] / t_period / ftm2v; gamma2 = sqrt(rmass[i]) * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v; gamma2 *= tsqrt; diff --git a/src/USER-BOCS/compute_pressure_bocs.cpp b/src/USER-BOCS/compute_pressure_bocs.cpp index 856dc3d6f5..f97edfeaa1 100644 --- a/src/USER-BOCS/compute_pressure_bocs.cpp +++ b/src/USER-BOCS/compute_pressure_bocs.cpp @@ -320,11 +320,11 @@ double ComputePressureBocs::compute_scalar() volume = (domain->xprd * domain->yprd * domain->zprd); /* MRD NJD if block */ - if ( p_basis_type == BASIS_ANALYTIC ) + if (p_basis_type == BASIS_ANALYTIC) { correction = get_cg_p_corr(N_basis,phi_coeff,N_mol,vavg,volume); } - else if ( p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) + else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) { correction = get_cg_p_corr(splines, p_basis_type, volume); } diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index 438766e351..81bf3538df 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -186,7 +186,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; - if ( strcmp(arg[iarg], "analytic") == 0 ) { + if (strcmp(arg[iarg], "analytic") == 0) { if (iarg + 4 > narg) { error->all(FLERR,"Illegal fix bocs command. Basis type analytic" " must be followed by: avg_vol n_mol n_pmatch_coeff"); @@ -202,13 +202,13 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : for (int pmatchi = 0; pmatchi < N_p_match; pmatchi++) p_match_coeffs[pmatchi] = utils::numeric(FLERR,arg[iarg+pmatchi],false,lmp); iarg += (N_p_match); - } else if (strcmp(arg[iarg], "linear_spline") == 0 ) { + } else if (strcmp(arg[iarg], "linear_spline") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command. " "Supply a file name after linear_spline."); p_basis_type = BASIS_LINEAR_SPLINE; spline_length = read_F_table( arg[iarg+1], p_basis_type ); iarg += 2; - } else if (strcmp(arg[iarg], "cubic_spline") == 0 ) { + } else if (strcmp(arg[iarg], "cubic_spline") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command. " "Supply a file name after cubic_spline."); p_basis_type = BASIS_CUBIC_SPLINE; @@ -551,7 +551,7 @@ void FixBocs::init() ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg); } - else if ( p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) + else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) { ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length); @@ -1592,12 +1592,12 @@ int FixBocs::modify_param(int narg, char **arg) if (p_match_flag) // NJD MRD { - if ( p_basis_type == BASIS_ANALYTIC ) + if (p_basis_type == BASIS_ANALYTIC) { ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg); } - else if ( p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) + else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE ) { ((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length ); } diff --git a/src/USER-COLVARS/colvarproxy_lammps.cpp b/src/USER-COLVARS/colvarproxy_lammps.cpp index 44b0b8b5ed..eb7d1820e5 100644 --- a/src/USER-COLVARS/colvarproxy_lammps.cpp +++ b/src/USER-COLVARS/colvarproxy_lammps.cpp @@ -207,7 +207,7 @@ double colvarproxy_lammps::compute() first_timestep = false; } else { // Use the time step number from LAMMPS Update object - if ( _lmp->update->ntimestep - previous_step == 1 ) { + if (_lmp->update->ntimestep - previous_step == 1) { colvars->it++; b_simulation_continuing = false; } else { @@ -412,7 +412,7 @@ int colvarproxy_lammps::check_atom_id(int atom_number) " for collective variables calculation.\n"); // TODO add upper boundary check? - if ( (aid < 0) ) { + if ((aid < 0)) { cvm::error("Error: invalid atom number specified, "+ cvm::to_str(atom_number)+"\n", INPUT_ERROR); return INPUT_ERROR; diff --git a/src/USER-COLVARS/fix_colvars.cpp b/src/USER-COLVARS/fix_colvars.cpp index 4d47f19ccc..841e2e0099 100644 --- a/src/USER-COLVARS/fix_colvars.cpp +++ b/src/USER-COLVARS/fix_colvars.cpp @@ -132,7 +132,7 @@ static void rebuild_table_int(inthash_t *tptr) { inthash_init(tptr, old_size<<1); for (i=0; inext; h=inthash(tptr, tmp->key); diff --git a/src/USER-DIFFRACTION/compute_saed.cpp b/src/USER-DIFFRACTION/compute_saed.cpp index a241d084be..c0be61dafe 100644 --- a/src/USER-DIFFRACTION/compute_saed.cpp +++ b/src/USER-DIFFRACTION/compute_saed.cpp @@ -88,7 +88,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : ztype[i] = j; } } - if ( ztype[i] == SAEDmaxType + 1 ) + if (ztype[i] == SAEDmaxType + 1) error->all(FLERR,"Compute SAED: Invalid ASF atom type"); iarg++; } @@ -148,7 +148,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : } // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { } else { R_Ewald = (1 / lambda); double Rnorm = R_Ewald/ sqrt(Zone[0] * Zone[0] + @@ -213,7 +213,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -239,7 +239,7 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) : r2 += pow(K[m] - Zone[m],2.0); EmdR2 = pow(R_Ewald - dR_Ewald,2); EpdR2 = pow(R_Ewald + dR_Ewald,2); - if ( (r2 > EmdR2 ) && (r2 < EpdR2 ) ) { + if ((r2 > EmdR2) && (r2 < EpdR2)) { n++; } } @@ -293,7 +293,7 @@ void ComputeSAED::init() int n = 0; // Zone 0 0 0 flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int k = -Knmax[2]; k <= Knmax[2]; k++) { for (int j = -Knmax[1]; j <= Knmax[1]; j++) { for (int i = -Knmax[0]; i <= Knmax[0]; i++) { @@ -324,7 +324,7 @@ void ComputeSAED::init() r2 += pow(K[m] - Zone[m],2.0); EmdR2 = pow(R_Ewald - dR_Ewald,2); EpdR2 = pow(R_Ewald + dR_Ewald,2); - if ( (r2 > EmdR2 ) && (r2 < EpdR2 ) ) { + if ((r2 > EmdR2) && (r2 < EpdR2)) { store_tmp[3*n] = i; store_tmp[3*n+1] = j; store_tmp[3*n+2] = k; @@ -473,13 +473,13 @@ void ComputeSAED::compute_vector() Fvec[2*n+1] = Fatom2; // reporting progress of calculation - if ( echo ) { + if (echo) { #if defined(_OPENMP) #pragma omp critical // TODO use VMD timer style incrementer #endif { - if ( m == round(frac * nRows) ) { + if (m == round(frac * nRows)) { if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100); frac += 0.1; } diff --git a/src/USER-DIFFRACTION/compute_xrd.cpp b/src/USER-DIFFRACTION/compute_xrd.cpp index 3d3bc17c74..0cb47fc2a2 100644 --- a/src/USER-DIFFRACTION/compute_xrd.cpp +++ b/src/USER-DIFFRACTION/compute_xrd.cpp @@ -89,7 +89,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : ztype[i] = j; } } - if ( ztype[i] == XRDmaxType + 1 ) + if (ztype[i] == XRDmaxType + 1) error->all(FLERR,"Compute XRD: Invalid ASF atom type"); iarg++; } @@ -109,7 +109,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal Compute XRD Command"); Min2Theta = atof(arg[iarg+1]) / 2; Max2Theta = atof(arg[iarg+2]) / 2; - if (Max2Theta > MY_PI ) { + if (Max2Theta > MY_PI) { Min2Theta = Min2Theta * MY_PI / 180; // converting to radians if necessary Max2Theta = Max2Theta * MY_PI / 180; radflag = 0; @@ -215,7 +215,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : K[1] = j * dK[1]; K[2] = k * dK[2]; dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]); - if (4 >= dinv2 * lambda * lambda ) { + if (4 >= dinv2 * lambda * lambda) { ang = asin(lambda * sqrt(dinv2) * 0.5); if ((ang <= Max2Theta) && (ang >= Min2Theta)) { nRows++; @@ -276,7 +276,7 @@ void ComputeXRD::init() K[1] = j * dK[1]; K[2] = k * dK[2]; dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]); - if (4 >= dinv2 * lambda * lambda ) { + if (4 >= dinv2 * lambda * lambda) { ang = asin(lambda * sqrt(dinv2) * 0.5); if ((ang <= Max2Theta) && (ang >= Min2Theta)) { store_tmp[3*n] = k; @@ -422,12 +422,12 @@ void ComputeXRD::compute_array() Fvec[2*n+1] = Fatom2 * sqrt_lp; // reporting progress of calculation - if ( echo ) { + if (echo) { #if defined(_OPENMP) #pragma omp critical #endif { - if ( m == round(frac * size_array_rows) ) { + if (m == round(frac * size_array_rows)) { if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100); frac += 0.1; } @@ -476,12 +476,12 @@ void ComputeXRD::compute_array() Fvec[2*n+1] = Fatom2; // reporting progress of calculation - if ( echo ) { + if (echo) { #if defined(_OPENMP) #pragma omp critical #endif { - if ( m == round(frac * size_array_rows) ) { + if (m == round(frac * size_array_rows)) { if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100 ); frac += 0.1; } diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.cpp b/src/USER-DIFFRACTION/fix_saed_vtk.cpp index 0791b25aaa..9c3666b426 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.cpp +++ b/src/USER-DIFFRACTION/fix_saed_vtk.cpp @@ -72,7 +72,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : iarg = 6; while (iarg < narg) { - if (strncmp(arg[iarg],"c_",2) == 0 ) { + if (strncmp(arg[iarg],"c_",2) == 0) { int n = strlen(arg[iarg]); char *suffix = new char[n]; @@ -153,7 +153,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // SAED specific paramaters needed int *periodicity = domain->periodicity; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { } else { R_Ewald = (1 / lambda); double Rnorm = R_Ewald/ sqrt(Zone[0] * Zone[0] + @@ -200,7 +200,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : } // Find integer dimensions of the reciprocal lattice box bounds - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int i=0; i<3; i++) { dK[i] = prd_inv[i]*c[i]; Knmax[i] = ceil(Kmax / dK[i]); @@ -233,15 +233,15 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) )) { - if ( i < Knmin[0] ) Knmin[0] = i; - if ( j < Knmin[1] ) Knmin[1] = j; - if ( k < Knmin[2] ) Knmin[2] = k; + if (i < Knmin[0]) Knmin[0] = i; + if (j < Knmin[1]) Knmin[1] = j; + if (k < Knmin[2]) Knmin[2] = k; - if ( i > Knmax[0] ) Knmax[0] = i; - if ( j > Knmax[1] ) Knmax[1] = j; - if ( k > Knmax[2] ) Knmax[2] = k; + if (i > Knmax[0]) Knmax[0] = i; + if (j > Knmax[1]) Knmax[1] = j; + if (k > Knmax[2]) Knmax[2] = k; } } } @@ -251,7 +251,7 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : // Finding dimensions for vtk files for (int i=0; i<3; i++) { - if ( ( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) ) ) { + if (( (Knmin[i] > 0) && (Knmax[i] > 0) ) || ( (Knmin[i] < 0) && (Knmax[i] < 0) )) { Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ); } else Dim[i] = abs( (int) Knmin[i] ) + abs( (int) Knmax[i] ) + 1; } @@ -452,7 +452,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) double K[3]; // Zone flag to capture entire recrocal space volume - if ( (Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0) ) { + if ((Zone[0] == 0) && (Zone[1] == 0) && (Zone[2] == 0)) { for (int k = Knmin[2]; k <= Knmax[2]; k++) { for (int j = Knmin[1]; j <= Knmax[1]; j++) { for (int i = Knmin[0]; i <= Knmax[0]; i++) { @@ -485,7 +485,7 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) r=0.0; for (int m=0; m<3; m++) r += pow(K[m] - Zone[m],2.0); r = sqrt(r); - if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) ) ) { + if ( (r > (R_Ewald - dR_Ewald) ) && (r < (R_Ewald + dR_Ewald) )) { fprintf(fp,"%g\n",vector_total[NROW1]/norm); fflush(fp); NROW2++; diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index ad3bf7c30c..c9d12506ab 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -1220,7 +1220,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, // compute ydot at t=t0 rhs (t, y, ydot, v_params); - while(1) + while (1) { // Estimate y'' with finite-difference ... @@ -1258,11 +1258,11 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, double hrat = hnew / hg; // Accept this value ... the bias factor should bring it within range. - if ( (hrat > 0.5) && (hrat < 2.0) ) + if ((hrat > 0.5) && (hrat < 2.0)) hnew_is_ok = true; // If y'' is still bad after a few iterations, just accept h and give up. - if ( (iter > 1) && hrat > 2.0 ) { + if ((iter > 1) && hrat > 2.0) { hnew = hg; hnew_is_ok = true; } diff --git a/src/USER-DPD/pair_table_rx.cpp b/src/USER-DPD/pair_table_rx.cpp index 6c975c97f3..cefbe5a73d 100644 --- a/src/USER-DPD/pair_table_rx.cpp +++ b/src/USER-DPD/pair_table_rx.cpp @@ -400,7 +400,7 @@ void PairTableRX::coeff(int narg, char **arg) ntables++; { - if ( strcmp(site1,"1fluid") == 0 ) + if (strcmp(site1,"1fluid") == 0) isite1 = OneFluidValue; else { isite1 = nspecies; @@ -415,7 +415,7 @@ void PairTableRX::coeff(int narg, char **arg) if (isite1 == nspecies) error->all(FLERR,"isite1 == nspecies"); } - if ( strcmp(site2,"1fluid") == 0 ) + if (strcmp(site2,"1fluid") == 0) isite2 = OneFluidValue; else { isite2 = nspecies; diff --git a/src/USER-INTEL/fix_intel.cpp b/src/USER-INTEL/fix_intel.cpp index ea65a91953..31bd63160f 100644 --- a/src/USER-INTEL/fix_intel.cpp +++ b/src/USER-INTEL/fix_intel.cpp @@ -1170,7 +1170,7 @@ int FixIntel::set_host_affinity(const int nomp) p = popen(cmd, "r"); if (p == nullptr) return -1; ncores = 0; - while(fgets(readbuf, 512, p)) { + while (fgets(readbuf, 512, p)) { proc_list[ncores] = atoi(readbuf); ncores++; } @@ -1224,7 +1224,7 @@ int FixIntel::set_host_affinity(const int nomp) p = popen(cmd, "r"); if (p == nullptr) return -1; - while(fgets(readbuf, 512, p)) { + while (fgets(readbuf, 512, p)) { lwp = atoi(readbuf); int first = coi_cores + node_rank * mpi_cores; CPU_ZERO(&cpuset); @@ -1260,7 +1260,7 @@ int FixIntel::set_host_affinity(const int nomp) p = popen(cmd, "r"); if (p == nullptr) return -1; - while(fgets(readbuf, 512, p)) { + while (fgets(readbuf, 512, p)) { lwp = atoi(readbuf); nlwp++; if (nlwp <= plwp) continue; diff --git a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp index 1aec1dcbf7..010237dcdf 100644 --- a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp @@ -493,7 +493,7 @@ void PairBuckCoulCutIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_buck_coul_long_intel.cpp b/src/USER-INTEL/pair_buck_coul_long_intel.cpp index d56b0dfd24..72d78fb6c7 100644 --- a/src/USER-INTEL/pair_buck_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_long_intel.cpp @@ -604,7 +604,7 @@ void PairBuckCoulLongIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_buck_intel.cpp b/src/USER-INTEL/pair_buck_intel.cpp index 77f6a1136c..df81b6852f 100644 --- a/src/USER-INTEL/pair_buck_intel.cpp +++ b/src/USER-INTEL/pair_buck_intel.cpp @@ -442,7 +442,7 @@ template void PairBuckIntel::ForceConst::set_ntypes(const int ntypes, Memory *memory, const int cop) { - if ( (ntypes != _ntypes ) ) { + if ((ntypes != _ntypes )) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp index ad15c045ab..b89deacc0b 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -640,7 +640,7 @@ void PairLJCharmmCoulLongIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp index d6d763677c..111f5610b6 100644 --- a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp @@ -599,7 +599,7 @@ void PairLJCutCoulLongIntel::ForceConst::set_ntypes(const int ntypes, const int ntable, Memory *memory, const int cop) { - if ( (ntypes != _ntypes || ntable != _ntable) ) { + if ((ntypes != _ntypes || ntable != _ntable)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD flt_t * ospecial_lj = special_lj; diff --git a/src/USER-INTEL/pair_tersoff_intel.cpp b/src/USER-INTEL/pair_tersoff_intel.cpp index bce2045f26..4284309b74 100644 --- a/src/USER-INTEL/pair_tersoff_intel.cpp +++ b/src/USER-INTEL/pair_tersoff_intel.cpp @@ -566,7 +566,7 @@ template void PairTersoffIntel::ForceConst::set_ntypes(const int ntypes, Memory *memory, const int cop) { - if ( (ntypes != _ntypes) ) { + if ((ntypes != _ntypes)) { if (_ntypes > 0) { #ifdef _LMP_INTEL_OFFLOAD c_first_loop_t * oc_first_loop = c_first_loop[0]; diff --git a/src/USER-MANIFOLD/fix_manifoldforce.cpp b/src/USER-MANIFOLD/fix_manifoldforce.cpp index bcb14ce1f9..d389b9787e 100644 --- a/src/USER-MANIFOLD/fix_manifoldforce.cpp +++ b/src/USER-MANIFOLD/fix_manifoldforce.cpp @@ -86,7 +86,7 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) : // equal style vars (so that they are not overwritten each time step). double *params = ptr_m->params; - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { if (was_var( arg[i+4] )) error->all(FLERR,"Equal-style variables not allowed with fix manifoldforce"); diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index bea7955d33..229dfd2433 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -117,7 +117,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, error->all(FLERR, msg); } // Loop over manifold args: - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { int len = 0, offset = 0; if (was_var( arg[i+6] )) { len = strlen(arg[i+6]) - 1; // -1 because -2 for v_, +1 for \0. @@ -135,7 +135,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, ptr_m->params = new double[nvars]; if (!ptr_m->params ) error->all(FLERR,"Failed to allocate params!"); - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { // If param i was variable type, it will be set later... ptr_m->params[i] = is_var[i] ? 0.0 : utils::numeric( FLERR, arg[i+6] ,false,lmp); } @@ -144,7 +144,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, // Loop over rest of args: int argi = 6 + nvars; - while( argi < narg ) { + while ( argi < narg) { if (strcmp(arg[argi], "every") == 0) { nevery = utils::inumeric(FLERR,arg[argi+1],false,lmp); next_output = update->ntimestep + nevery; @@ -170,7 +170,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, FixNVEManifoldRattle::~FixNVEManifoldRattle() { if (tstrs) { - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { delete [] tstrs[i]; } delete [] tstrs; @@ -277,7 +277,7 @@ void FixNVEManifoldRattle::update_var_params() double *ptr_params = ptr_m->params; - for( int i = 0; i < nvars; ++i ) { + for (int i = 0; i < nvars; ++i) { if (is_var[i]) { tvars[i] = input->variable->find(tstrs[i]); if (tvars[i] < 0) { @@ -306,7 +306,7 @@ int FixNVEManifoldRattle::dof(int /*igroup*/) int *mask = atom->mask; int nlocal = atom->nlocal; int natoms = 0; - for( int i = 0; i < nlocal; ++i ) { + for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) ++natoms; } @@ -508,7 +508,7 @@ void FixNVEManifoldRattle::rattle_manifold_x(double *x, double *v, const double c_inv = 1.0 / c; - while ( 1 ) { + while (1) { v[0] = vt[0] - l*no_dt[0]; v[1] = vt[1] - l*no_dt[1]; v[2] = vt[2] - l*no_dt[2]; @@ -643,7 +643,7 @@ void FixNVEManifoldRattle::rattle_manifold_v(double *v, double *f, res = infnorm<4>(R); ++iters; - }while( (res > tolerance) && (iters < max_iter) ); + } while ((res > tolerance) && (iters < max_iter)); if (iters >= max_iter && res >= tolerance) { char msg[2048]; diff --git a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp index d8a5360506..9ac81aafb0 100644 --- a/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nvt_manifold_rattle.cpp @@ -95,8 +95,7 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg, which = got_temp = 0; int argi = 6 + ptr_m->nparams(); - while( argi < narg ) - { + while (argi < narg) { if (strcmp( arg[argi], "temp") == 0) { if (argi+3 >= narg) error->all(FLERR,"Keyword 'temp' needs 3 arguments"); @@ -165,7 +164,7 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg, eta_dot[mtchain] = 0.0; eta_dot[mtchain] = 0.0; - for( int ich = 0; ich < mtchain; ++ich ) { + for (int ich = 0; ich < mtchain; ++ich) { eta[ich] = eta_dot[ich] = eta_dotdot[ich] = 0.0; } @@ -232,11 +231,11 @@ void FixNVTManifoldRattle::setup(int /*vflag*/) // Compute/set eta-masses: double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] - boltz * t_target ) / eta_mass[ich]; } @@ -268,7 +267,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() double expfac, kecurrent = tdof * boltz * t_current; double inv_t_freq2 = 1.0 / (t_freq*t_freq); eta_mass[0] = tdof * boltz * t_target * inv_t_freq2; - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta_mass[ich] = boltz * t_target * inv_t_freq2; } @@ -278,7 +277,7 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0; } - for( ich = mtchain-1; ich > 0; --ich ) { + for (ich = mtchain-1; ich > 0; --ich) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dot[ich] += eta_dotdot[ich] * dt4; @@ -311,14 +310,14 @@ void FixNVTManifoldRattle::nhc_temp_integrate() eta_dotdot[0] = 0.0; } - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { eta[ich] += dthalf*eta_dot[ich]; } eta_dot[0] *= expfac; eta_dot[0] += eta_dotdot[0]*dt4; eta_dot[0] *= expfac; - for( int ich = 1; ich < mtchain; ++ich ) { + for (int ich = 1; ich < mtchain; ++ich) { expfac = exp(-dt8*eta_dot[ich+1]); eta_dot[ich] *= expfac; eta_dotdot[ich] = (eta_mass[ich-1]*eta_dot[ich-1]*eta_dot[ich-1] @@ -340,7 +339,7 @@ void FixNVTManifoldRattle::nh_v_temp() if (which == NOBIAS) { - for( int i = 0; i < nlocal; ++i ) { + for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) { v[i][0] *= factor_eta; v[i][1] *= factor_eta; @@ -348,7 +347,7 @@ void FixNVTManifoldRattle::nh_v_temp() } } } else if (which == BIAS) { - for( int i = 0; i < nlocal; ++i ) { + for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) { temperature->remove_bias(i,v[i]); v[i][0] *= factor_eta; diff --git a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp index 0864e1e2f2..79d0185d1b 100644 --- a/src/USER-MANIFOLD/manifold_gaussian_bump.cpp +++ b/src/USER-MANIFOLD/manifold_gaussian_bump.cpp @@ -69,7 +69,7 @@ public: double ff = x(t) - xx; double ffp = xp(t); // double l = 1.0 / ( 1 + res*res ); - for( int i = 0; i < maxit; ++i ) { + for (int i = 0; i < maxit; ++i) { t -= ff / ffp; ff = x(t) - xx; ffp = xp(t); @@ -294,7 +294,7 @@ void manifold_gaussian_bump::make_lut() cubic_hermite pchip( lut_x0, lut_x1, f_at_rc, 0.0, fp_at_rc, 0.0, error ); double xx = lut_x0; - for( int i = 0; i <= lut_Nbins; ++i ) { + for (int i = 0; i <= lut_Nbins; ++i) { lut_z[i] = pchip.y_from_x( xx ); lut_zp[i] = pchip.yp_from_x( xx ); xx += lut_dx; @@ -355,7 +355,7 @@ void manifold_gaussian_bump::test_lut() FILE *fp = fopen( "test_lut_gaussian.dat", "w" ); double dx = 0.1; - for( double xx = 0; xx < 20; xx += dx ) { + for (double xx = 0; xx < 20; xx += dx) { x[0] = xx; x[1] = 0.0; x[2] = 0.0; diff --git a/src/USER-MANIFOLD/manifold_thylakoid.cpp b/src/USER-MANIFOLD/manifold_thylakoid.cpp index c4dfd33c30..b7eab17fe1 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid.cpp @@ -57,17 +57,17 @@ void manifold_thylakoid::post_param_init() void manifold_thylakoid::checkup() { - if (comm->me == 0 ) { + if (comm->me == 0) { fprintf(screen,"This is checkup of thylakoid %p\n", this); fprintf(screen,"I have %ld parts. They are:\n", parts.size()); - for ( int i = 0; i < (int)parts.size(); ++i ) { + for (int i = 0; i < (int)parts.size(); ++i) { fprintf(screen, "[%f, %f] x [%f, %f] x [%f, %f]\n", parts[i]->xlo, parts[i]->xhi, parts[i]->ylo, parts[i]->yhi, parts[i]->zlo, parts[i]->zhi ); } fprintf(screen,"My params are:\n"); - for ( int i = 0; i < NPARAMS; ++i ) { + for (int i = 0; i < NPARAMS; ++i) { fprintf(screen,"%f\n", params[i]); } } @@ -120,7 +120,7 @@ void manifold_thylakoid::n( const double *x, double *n ) thyla_part *manifold_thylakoid::get_thyla_part( const double *x, int * /*err_flag*/, std::size_t *idx ) { - for ( std::size_t i = 0; i < parts.size(); ++i ) { + for (std::size_t i = 0; i < parts.size(); ++i) { thyla_part *p = parts[i]; if (is_in_domain(p,x)) { if (idx != nullptr) *idx = i; @@ -604,7 +604,7 @@ thyla_part *manifold_thylakoid::make_cyl_to_plane_part(double X0, double R0, dou void manifold_thylakoid::print_part_data( FILE *fp_doms, FILE *fp_coms ) { - for ( std::size_t i = 0; i < parts.size(); ++i ) { + for (std::size_t i = 0; i < parts.size(); ++i) { thyla_part *p = parts[i]; fprintf(fp_doms, "%f %f\n", p->xlo, p->ylo); fprintf(fp_doms, "%f %f\n", p->xlo, p->yhi); diff --git a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp index c0b6871ea8..29e0ee82e9 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp +++ b/src/USER-MANIFOLD/manifold_thylakoid_shared.cpp @@ -40,7 +40,7 @@ thyla_part::thyla_part( int type, double *args, double xlo, double ylo, double z // The others should be 1. if ( (args[0] != 1.0) && (args[0] != 0.0) && (args[1] != 1.0) && (args[1] != 0.0) && - (args[2] != 1.0) && (args[2] != 0.0) ) { + (args[2] != 1.0) && (args[2] != 0.0)) { err_flag = -1; } break; diff --git a/src/USER-MESODPD/pair_edpd.cpp b/src/USER-MESODPD/pair_edpd.cpp index f7201052ff..04307429b4 100644 --- a/src/USER-MESODPD/pair_edpd.cpp +++ b/src/USER-MESODPD/pair_edpd.cpp @@ -275,7 +275,7 @@ void PairEDPD::settings(int narg, char **arg) // initialize Marsaglia RNG with processor-unique seed - if (seed <= 0 ) { + if (seed <= 0) { struct timespec time; clock_gettime( CLOCK_REALTIME, &time ); seed = time.tv_nsec; // if seed is non-positive, get the current time as the seed diff --git a/src/USER-MESODPD/pair_mdpd.cpp b/src/USER-MESODPD/pair_mdpd.cpp index 4dc42eb56a..30589e19bd 100644 --- a/src/USER-MESODPD/pair_mdpd.cpp +++ b/src/USER-MESODPD/pair_mdpd.cpp @@ -217,7 +217,7 @@ void PairMDPD::settings(int narg, char **arg) // initialize Marsaglia RNG with processor-unique seed - if (seed <= 0 ) { + if (seed <= 0) { struct timespec time; clock_gettime( CLOCK_REALTIME, &time ); seed = time.tv_nsec; // if seed is non-positive, get the current time as the seed diff --git a/src/USER-MESODPD/pair_tdpd.cpp b/src/USER-MESODPD/pair_tdpd.cpp index a416d94a00..a57b682c1c 100644 --- a/src/USER-MESODPD/pair_tdpd.cpp +++ b/src/USER-MESODPD/pair_tdpd.cpp @@ -239,7 +239,7 @@ void PairTDPD::settings(int narg, char **arg) // initialize Marsaglia RNG with processor-unique seed - if (seed <= 0 ) { + if (seed <= 0) { struct timespec time; clock_gettime( CLOCK_REALTIME, &time ); seed = time.tv_nsec; // if seed is non-positive, get the current time as the seed diff --git a/src/USER-MGPT/mgpt_readpot.cpp b/src/USER-MGPT/mgpt_readpot.cpp index 773c3d0fe9..9b89894f6f 100644 --- a/src/USER-MGPT/mgpt_readpot.cpp +++ b/src/USER-MGPT/mgpt_readpot.cpp @@ -75,7 +75,7 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub vsize = 10; volarr = (double *) malloc(sizeof(double) * vsize); n = 0; - while(fgets(line,sizeof(line),in) != nullptr) { + while (fgets(line,sizeof(line),in) != nullptr) { double zval,ivol,rws,mass; double r0x,r1x,drx; int nrx,i; @@ -185,7 +185,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl in = fopen(parmin_file,"r"); do { fgets(line,sizeof(line),in); - } while(line[strspn(line," \t")] == '#'); + } while (line[strspn(line," \t")] == '#'); /* Test to see whether this is a one-line or two-line version of parmin */ if (sscanf(line,"%lf %lf %lf %lf %d",&ddl[1],&ddl[2],&ddl[3],&ddl[4],&L) == 5) { @@ -244,7 +244,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl do { fgets(line,sizeof(line),in); - } while(line[strspn(line," \t")] == '#'); + } while (line[strspn(line," \t")] == '#'); metalx[0] = 0; diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index b358b12857..75f870e1b2 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -481,7 +481,7 @@ void PairMGPT::force_debug_4(double xx[][3], trd2 = transtrace(T12->H1H2##coord,T45->H1H2 ); \ trd3 = transtrace(T12->H1H2 ,T45->H1##coord##H2); \ trd4 = transtrace(T12->H1H2 ,T45->H1H2##coord ); \ - } while(0) + } while (0) */ #define trd_update_4(T12,T45) \ do { \ @@ -510,7 +510,7 @@ void PairMGPT::force_debug_4(double xx[][3], trd1y = utr1y.d; trd2y = utr2y.d; trd3y = utr3y.d; trd4y = utr4y.d; \ trd1z = utr1z.d; trd2z = utr2z.d; trd3z = utr3z.d; trd4z = utr4z.d; \ } \ - } while(0) + } while (0) #define dfix_update_4a(coord) \ do { \ @@ -518,7 +518,7 @@ void PairMGPT::force_debug_4(double xx[][3], dfj##coord = ( ( sij)*trd1##coord + (-sjk)*trd2##coord ) * (ve / anorm4); \ dfk##coord = ( ( sjk)*trd2##coord + (-skm)*trd4##coord ) * (ve / anorm4); \ dfm##coord = ( ( sim)*trd3##coord + ( skm)*trd4##coord ) * (ve / anorm4); \ - } while(0) + } while (0) #define dfix_update_4b(coord) \ @@ -527,7 +527,7 @@ void PairMGPT::force_debug_4(double xx[][3], dfj##coord = ( (-sjk)*trd2##coord + (-sjm)*trd4##coord ) * (ve / anorm4); \ dfk##coord = ( (-ski)*trd1##coord + ( sjk)*trd2##coord ) * (ve / anorm4); \ dfm##coord = ( ( sim)*trd3##coord + ( sjm)*trd4##coord ) * (ve / anorm4); \ - } while(0); + } while (0); #define dfix_update_4c(coord) \ do { \ @@ -535,7 +535,7 @@ void PairMGPT::force_debug_4(double xx[][3], dfj##coord = ( ( sij)*trd1##coord + (-sjm)*trd3##coord ) * (ve / anorm4); \ dfk##coord = ( (-ski)*trd2##coord + (-skm)*trd4##coord ) * (ve / anorm4); \ dfm##coord = ( ( sjm)*trd3##coord + ( skm)*trd4##coord ) * (ve / anorm4); \ - } while(0); + } while (0); #define accumulate_forces_2(w) \ do { \ @@ -546,7 +546,7 @@ void PairMGPT::force_debug_4(double xx[][3], fjx = fjx + dfjx*(w); \ fjy = fjy + dfjy*(w); \ fjz = fjz + dfjz*(w); \ - } while(0) + } while (0) #define accumulate_forces_3(w) \ do { \ @@ -554,7 +554,7 @@ void PairMGPT::force_debug_4(double xx[][3], fkx = fkx + dfkx*(w); \ fky = fky + dfky*(w); \ fkz = fkz + dfkz*(w); \ - } while(0) + } while (0) #define accumulate_forces_4(w) \ do { \ @@ -562,7 +562,7 @@ void PairMGPT::force_debug_4(double xx[][3], fmx = fmx + dfmx*(w); \ fmy = fmy + dfmy*(w); \ fmz = fmz + dfmz*(w); \ - } while(0) + } while (0) @@ -868,7 +868,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, */ p = first[i+1]-1; - while(p >= first[i] && nlist_short[p] > j) { + while (p >= first[i] && nlist_short[p] > j) { nlist_short[p+1] = nlist_short[p]; p = p - 1; } @@ -941,7 +941,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, Since i is in the j-list, and i > k and the list is sorted, the loop below terminates:-) */ - while(mj < first[j+1] && nlist_short[mj] < k) mj = mj + 1; + while (mj < first[j+1] && nlist_short[mj] < k) mj = mj + 1; if (mj < first[j+1] && nlist_short[mj] == k) { /* Closed triplet */ c_jk = 1; @@ -1265,7 +1265,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, i is in both the j-list and the k-list, and i > k, and lists are sorted, so the loop terminates. */ - while(nlist_short[mj] < i && nlist_short[mk] < i) { + while (nlist_short[mj] < i && nlist_short[mk] < i) { if (mj >= first[j+1] || mk >= first[k+1]) { printf("Illegal quad...\n" @@ -1291,7 +1291,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, /* Alrady know ij,jk,ki,jm,km bonds. Look for im bond. */ mi = first[i]; - while(mi < first[i+1] && nlist_short[mi] < m) mi = mi + 1; + while (mi < first[i+1] && nlist_short[mi] < m) mi = mi + 1; if (mi < first[i+1] && nlist_short[mi] == m) c_im = 1; else @@ -1613,7 +1613,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, { Hash::Iterator iter = bond_hash.begin(); int nitem = 0,nhit = 0; - while(iter != bond_hash.end()) { + while (iter != bond_hash.end()) { nitem++; nhit += iter.link()->hits; iter.next(); @@ -2149,7 +2149,7 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh Mx[j][i] = Mx[i][j] = fl_x*tmp + fl_ri*(tmpx - x*tmpsum); \ My[j][i] = My[i][j] = fl_y*tmp + fl_ri*(tmpy - y*tmpsum); \ Mz[j][i] = Mz[i][j] = fl_z*tmp + fl_ri*(tmpz - z*tmpsum); \ - } while(0) + } while (0) #define MAKE_ELEMENT_7(i,j) \ do { \ @@ -2168,7 +2168,7 @@ void PairMGPT::fl_deriv_new(double r,double ri,double xhat,double yhat,double zh Mx[j][i] = Mx[i][j] = fl_x*tmp + fl_ri*(tmpx - x*tmpsum); \ My[j][i] = My[i][j] = fl_y*tmp + fl_ri*(tmpy - y*tmpsum); \ Mz[j][i] = Mz[i][j] = fl_z*tmp + fl_ri*(tmpz - z*tmpsum); \ - } while(0) + } while (0) /* End of bond matrix macros */ diff --git a/src/USER-MISC/angle_fourier.cpp b/src/USER-MISC/angle_fourier.cpp index 0194626e81..47b74fad99 100644 --- a/src/USER-MISC/angle_fourier.cpp +++ b/src/USER-MISC/angle_fourier.cpp @@ -204,9 +204,9 @@ void AngleFourier::coeff(int narg, char **arg) double AngleFourier::equilibrium_angle(int i) { double ret=MY_PI; - if ( C2[i] != 0.0 ) { + if (C2[i] != 0.0) { ret = (C1[i]/4.0/C2[i]); - if ( fabs(ret) <= 1.0 ) ret = acos(-ret); + if (fabs(ret) <= 1.0) ret = acos(-ret); } return ret; } diff --git a/src/USER-MISC/angle_fourier_simple.cpp b/src/USER-MISC/angle_fourier_simple.cpp index 4a3e64c6a9..2b40c2f12f 100644 --- a/src/USER-MISC/angle_fourier_simple.cpp +++ b/src/USER-MISC/angle_fourier_simple.cpp @@ -118,10 +118,10 @@ void AngleFourierSimple::compute(int eflag, int vflag) // handle sin(n th)/sin(th) singulatiries - if ( fabs(c)-1.0 > 0.0001 ) { + if (fabs(c)-1.0 > 0.0001) { a = k[type]*C[type]*N[type]*sin(nth)/sin(th); } else { - if ( c >= 0.0 ) { + if (c >= 0.0) { term = 1.0 - c; sgn = 1.0; } else { diff --git a/src/USER-MISC/angle_gaussian.cpp b/src/USER-MISC/angle_gaussian.cpp index 66da9e792e..2150ef7a4b 100644 --- a/src/USER-MISC/angle_gaussian.cpp +++ b/src/USER-MISC/angle_gaussian.cpp @@ -217,7 +217,7 @@ void AngleGaussian::coeff(int narg, char **arg) alpha[i] = new double [n]; width[i] = new double [n]; theta0[i] = new double [n]; - for (int j = 0; j < n; j++ ) { + for (int j = 0; j < n; j++) { alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); theta0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp)* MY_PI / 180.0; diff --git a/src/USER-MISC/bond_gaussian.cpp b/src/USER-MISC/bond_gaussian.cpp index 42f76eda75..dcb8d7a4ad 100644 --- a/src/USER-MISC/bond_gaussian.cpp +++ b/src/USER-MISC/bond_gaussian.cpp @@ -171,7 +171,7 @@ void BondGaussian::coeff(int narg, char **arg) alpha[i] = new double [n]; width[i] = new double [n]; r0[i] = new double [n]; - for (int j = 0; j < n; j++ ) { + for (int j = 0; j < n; j++) { alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); r0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp); diff --git a/src/USER-MISC/compute_entropy_atom.cpp b/src/USER-MISC/compute_entropy_atom.cpp index 1362da447b..2fea708a71 100644 --- a/src/USER-MISC/compute_entropy_atom.cpp +++ b/src/USER-MISC/compute_entropy_atom.cpp @@ -122,7 +122,7 @@ void ComputeEntropyAtom::init() error->all(FLERR,"Compute entropy/atom requires a pair style be" " defined"); - if ( (cutoff+cutoff2) > (force->pair->cutforce + neighbor->skin) ) + if ((cutoff+cutoff2) > (force->pair->cutforce + neighbor->skin)) { error->all(FLERR,"Compute entropy/atom cutoff is longer than the" " pairwise cutoff. Increase the neighbor list skin" diff --git a/src/USER-MISC/compute_stress_mop.cpp b/src/USER-MISC/compute_stress_mop.cpp index a1f88aadaf..87de00cedd 100644 --- a/src/USER-MISC/compute_stress_mop.cpp +++ b/src/USER-MISC/compute_stress_mop.cpp @@ -67,7 +67,7 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : pos = 0.5*(domain->boxlo[dir]+domain->boxhi[dir]); } else pos = utils::numeric(FLERR,arg[4],false,lmp); - if ( pos < (domain->boxlo[dir]+domain->prd_half[dir]) ) { + if (pos < (domain->boxlo[dir]+domain->prd_half[dir])) { pos1 = pos + domain->prd[dir]; } else { pos1 = pos - domain->prd[dir]; @@ -319,7 +319,7 @@ void ComputeStressMop::compute_pairs() if (newton_pair || j < nlocal) { //check if ij pair is across plane, add contribution to pressure - if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -327,7 +327,7 @@ void ComputeStressMop::compute_pairs() values_local[m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; values_local[m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; } - else if ( ((xi[dir]pos)) || ((xi[dir]pos1)) ) { + else if (((xi[dir]pos)) || ((xi[dir]pos1))) { pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -338,7 +338,7 @@ void ComputeStressMop::compute_pairs() } else { - if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); diff --git a/src/USER-MISC/compute_stress_mop_profile.cpp b/src/USER-MISC/compute_stress_mop_profile.cpp index 3bd0139dea..4861e49e7e 100644 --- a/src/USER-MISC/compute_stress_mop_profile.cpp +++ b/src/USER-MISC/compute_stress_mop_profile.cpp @@ -336,7 +336,7 @@ void ComputeStressMopProfile::compute_pairs() //check if ij pair is across plane, add contribution to pressure if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -345,7 +345,7 @@ void ComputeStressMopProfile::compute_pairs() values_local[ibin][m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; } else if ( ((xi[dir]pos)) - || ((xi[dir]pos1)) ) { + || ((xi[dir]pos1))) { pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -363,7 +363,7 @@ void ComputeStressMopProfile::compute_pairs() //check if ij pair is across plane, add contribution to pressure if ( ((xi[dir]>pos) && (xj[dir]pos1) && (xj[dir]pos1) && (xj[dir]single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); @@ -499,7 +499,7 @@ void ComputeStressMopProfile::setup_bins() // set bin coordinates for (i = 0; i < nbins; i++) { coord[i][0] = offset + i*delta; - if ( coord[i][0] < (domain->boxlo[dir]+domain->prd_half[dir]) ) { + if (coord[i][0] < (domain->boxlo[dir]+domain->prd_half[dir])) { coordp[i][0] = coord[i][0] + domain->prd[dir]; } else { coordp[i][0] = coord[i][0] - domain->prd[dir]; diff --git a/src/USER-MISC/dihedral_fourier.cpp b/src/USER-MISC/dihedral_fourier.cpp index e4a61787a2..7ca8260bfe 100644 --- a/src/USER-MISC/dihedral_fourier.cpp +++ b/src/USER-MISC/dihedral_fourier.cpp @@ -50,11 +50,11 @@ DihedralFourier::~DihedralFourier() memory->destroy(nterms); for (int i=1; i<= atom->ndihedraltypes; i++) { - if ( k[i] ) delete [] k[i]; - if ( multiplicity[i] ) delete [] multiplicity[i]; - if ( shift[i] ) delete [] shift[i]; - if ( cos_shift[i] ) delete [] cos_shift[i]; - if ( sin_shift[i] ) delete [] sin_shift[i]; + if (k[i]) delete [] k[i]; + if (multiplicity[i]) delete [] multiplicity[i]; + if (shift[i]) delete [] shift[i]; + if (cos_shift[i]) delete [] cos_shift[i]; + if (sin_shift[i]) delete [] sin_shift[i]; } delete [] k; delete [] multiplicity; diff --git a/src/USER-MISC/dihedral_nharmonic.cpp b/src/USER-MISC/dihedral_nharmonic.cpp index 1041062530..03f235b166 100644 --- a/src/USER-MISC/dihedral_nharmonic.cpp +++ b/src/USER-MISC/dihedral_nharmonic.cpp @@ -47,7 +47,7 @@ DihedralNHarmonic::~DihedralNHarmonic() if (allocated) { memory->destroy(setflag); for (int i = 1; i <= atom->ndihedraltypes; i++) - if ( a[i] ) delete [] a[i]; + if (a[i]) delete [] a[i]; delete [] a; delete [] nterms; } @@ -290,7 +290,7 @@ void DihedralNHarmonic::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { a[i] = new double [n]; nterms[i] = n; - for (int j = 0; j < n; j++ ) { + for (int j = 0; j < n; j++) { a[i][j] = utils::numeric(FLERR,arg[2+j],false,lmp); setflag[i] = 1; } diff --git a/src/USER-MISC/dihedral_spherical.cpp b/src/USER-MISC/dihedral_spherical.cpp index 2f77887de9..4d753423f5 100644 --- a/src/USER-MISC/dihedral_spherical.cpp +++ b/src/USER-MISC/dihedral_spherical.cpp @@ -52,16 +52,16 @@ DihedralSpherical::~DihedralSpherical() memory->destroy(nterms); for (int i=1; i<= atom->ndihedraltypes; i++) { - if ( Ccoeff[i] ) delete [] Ccoeff[i]; - if ( phi_mult[i] ) delete [] phi_mult[i]; - if ( phi_shift[i] ) delete [] phi_shift[i]; - if ( phi_offset[i] ) delete [] phi_offset[i]; - if ( theta1_mult[i] ) delete [] theta1_mult[i]; - if ( theta1_shift[i] ) delete [] theta1_shift[i]; - if ( theta1_offset[i] ) delete [] theta1_offset[i]; - if ( theta2_mult[i] ) delete [] theta2_mult[i]; - if ( theta2_shift[i] ) delete [] theta2_shift[i]; - if ( theta2_offset[i] ) delete [] theta2_offset[i]; + if (Ccoeff[i]) delete [] Ccoeff[i]; + if (phi_mult[i]) delete [] phi_mult[i]; + if (phi_shift[i]) delete [] phi_shift[i]; + if (phi_offset[i]) delete [] phi_offset[i]; + if (theta1_mult[i]) delete [] theta1_mult[i]; + if (theta1_shift[i]) delete [] theta1_shift[i]; + if (theta1_offset[i]) delete [] theta1_offset[i]; + if (theta2_mult[i]) delete [] theta2_mult[i]; + if (theta2_shift[i]) delete [] theta2_shift[i]; + if (theta2_offset[i]) delete [] theta2_offset[i]; } delete [] Ccoeff; delete [] phi_mult; diff --git a/src/USER-MISC/fix_flow_gauss.cpp b/src/USER-MISC/fix_flow_gauss.cpp index 0dabf82436..b1b4174352 100644 --- a/src/USER-MISC/fix_flow_gauss.cpp +++ b/src/USER-MISC/fix_flow_gauss.cpp @@ -84,10 +84,10 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) : // process optional keyword int iarg = 6; while (iarg < narg) { - if ( strcmp(arg[iarg],"energy") == 0 ) { - if ( iarg+2 > narg ) error->all(FLERR,"Illegal energy keyword"); - if ( strcmp(arg[iarg+1],"yes") == 0 ) workflag = 1; - else if ( strcmp(arg[iarg+1],"no") != 0 ) + if (strcmp(arg[iarg],"energy") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword"); + if (strcmp(arg[iarg+1],"yes") == 0) workflag = 1; + else if (strcmp(arg[iarg+1],"no") != 0) error->all(FLERR,"Illegal energy keyword"); iarg += 2; } else error->all(FLERR,"Illegal fix flow/gauss command"); diff --git a/src/USER-MISC/fix_imd.cpp b/src/USER-MISC/fix_imd.cpp index 0f0f601584..0da5b29b62 100644 --- a/src/USER-MISC/fix_imd.cpp +++ b/src/USER-MISC/fix_imd.cpp @@ -146,7 +146,7 @@ static void rebuild_table_tagint(taginthash_t *tptr) { taginthash_init(tptr, old_size<<1); for (i=0; inext; h=taginthash(tptr, tmp->key); @@ -349,7 +349,7 @@ static void id_sort(tagint *idmap, tagint left, tagint right) #include -#if ( INT_MAX == 2147483647 ) +#if (INT_MAX == 2147483647) typedef int int32; #else typedef short int32; diff --git a/src/USER-MISC/fix_ipi.cpp b/src/USER-MISC/fix_ipi.cpp index 7fb696ce8c..1f1b527816 100644 --- a/src/USER-MISC/fix_ipi.cpp +++ b/src/USER-MISC/fix_ipi.cpp @@ -155,7 +155,7 @@ static void readbuffer(int sockfd, char *data, int len, Error* error) n = nr = read(sockfd,data,len); - while (nr>0 && n0 && nmask; int nlocal = atom->nlocal; - for( int i = 0; i < nlocal; i++ ) { // Iterate through all atoms on this CPU + for (int i = 0; i < nlocal; i++) { // Iterate through all atoms on this CPU if (mask[i] & groupbit) { // ...only those affected by this fix nThisLocal++; } @@ -156,7 +156,7 @@ FixRhok::post_force( int /*inVFlag*/ ) mRhoKLocal[0] = 0.0; mRhoKLocal[1] = 0.0; - for( int i = 0; i < nlocal; i++ ) { // Iterate through all atoms on this CPU + for (int i = 0; i < nlocal; i++) { // Iterate through all atoms on this CPU if (mask[i] & groupbit) { // ...only those affected by this fix // rho_k = sum_i exp( - i k.r_i ) @@ -179,7 +179,7 @@ FixRhok::post_force( int /*inVFlag*/ ) double rhoK = sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] + mRhoKGlobal[1]*mRhoKGlobal[1] ); - for( int i = 0; i < nlocal; i++ ) { // Iterate through all atoms on this CPU + for (int i = 0; i < nlocal; i++) { // Iterate through all atoms on this CPU if (mask[i] & groupbit) { // ...only those affected by this fix // Calculate forces @@ -235,9 +235,9 @@ FixRhok::compute_vector( int inI ) { if (inI == 0) return mRhoKGlobal[0]; // Real part - else if ( inI == 1 ) + else if (inI == 1) return mRhoKGlobal[1]; // Imagniary part - else if ( inI == 2 ) + else if (inI == 2) return sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] + mRhoKGlobal[1]*mRhoKGlobal[1] ); else diff --git a/src/USER-MISC/fix_ti_spring.cpp b/src/USER-MISC/fix_ti_spring.cpp index 3a87dfa96d..5aac36a47b 100644 --- a/src/USER-MISC/fix_ti_spring.cpp +++ b/src/USER-MISC/fix_ti_spring.cpp @@ -222,12 +222,12 @@ void FixTISpring::initial_integrate(int /*vflag*/) const bigint t = update->ntimestep - (t0+t_equil); const double r_switch = 1.0/t_switch; - if ( (t >= 0) && (t <= t_switch) ) { + if ((t >= 0) && (t <= t_switch)) { lambda = switch_func(t*r_switch); dlambda = dswitch_func(t*r_switch); } - if ( (t >= t_equil+t_switch) && (t <= (t_equil+2*t_switch)) ) { + if ((t >= t_equil+t_switch) && (t <= (t_equil+2*t_switch))) { lambda = switch_func(1.0 - (t - t_switch - t_equil)*r_switch); dlambda = - dswitch_func(1.0 - (t - t_switch - t_equil)*r_switch); } diff --git a/src/USER-MISC/improper_fourier.cpp b/src/USER-MISC/improper_fourier.cpp index 89b2333e1c..e03ef33cda 100644 --- a/src/USER-MISC/improper_fourier.cpp +++ b/src/USER-MISC/improper_fourier.cpp @@ -92,7 +92,7 @@ void ImproperFourier::compute(int eflag, int vflag) vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z); - if ( all[type] ) { + if (all[type]) { addone(i1,i4,i2,i3, type,evflag,eflag, vb3x, vb3y, vb3z, vb1x, vb1y, vb1z, @@ -274,7 +274,7 @@ void ImproperFourier::allocate() void ImproperFourier::coeff(int narg, char **arg) { - if ( narg != 5 && narg != 6 ) error->all(FLERR,"Incorrect args for improper coefficients"); + if (narg != 5 && narg != 6) error->all(FLERR,"Incorrect args for improper coefficients"); if (!allocated) allocate(); @@ -286,7 +286,7 @@ void ImproperFourier::coeff(int narg, char **arg) double C1_one = utils::numeric(FLERR,arg[3],false,lmp); double C2_one = utils::numeric(FLERR,arg[4],false,lmp); int all_one = 1; - if ( narg == 6 ) all_one = utils::inumeric(FLERR,arg[5],false,lmp); + if (narg == 6) all_one = utils::inumeric(FLERR,arg[5],false,lmp); // convert w0 from degrees to radians diff --git a/src/USER-MISC/pair_e3b.cpp b/src/USER-MISC/pair_e3b.cpp index dceed1fc57..ae65d68d89 100644 --- a/src/USER-MISC/pair_e3b.cpp +++ b/src/USER-MISC/pair_e3b.cpp @@ -418,7 +418,7 @@ void PairE3B::coeff(int narg, char **arg) rs=rc3=rc2=0.0; int iarg = 2; //beginning of keyword/value pairs - while(iarg < narg) { + while (iarg < narg) { char *keyword = arg[iarg++]; if (checkKeyword(keyword,"Ea",1,narg-iarg)) ea=utils::numeric(FLERR,arg[iarg++],false,lmp); diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index 2d0001c680..00ab46e697 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -362,7 +362,7 @@ void PairExTeP::compute(int eflag, int vflag) f[k][0] -= fc_prefac_ik * delr2[0]; f[k][1] -= fc_prefac_ik * delr2[1]; f[k][2] -= fc_prefac_ik * delr2[2]; - if ( itype != ktype ) { + if (itype != ktype) { fc_prefac_ik = dFc_dNdij * fc_prefac_ik_0; f[i][0] += fc_prefac_ik * delr2[0]; f[i][1] += fc_prefac_ik * delr2[1]; @@ -1094,8 +1094,8 @@ void PairExTeP::costheta_d(double *rij_hat, double rij, void PairExTeP::spline_init() { for ( int iel=0; ielcreate(style,num,"pair_list:style"); memory->create(params,num,"pair_list:params"); @@ -227,7 +227,7 @@ void PairList::settings(int narg, char **arg) tagint id1, id2; int nharm=0, nmorse=0, nlj126=0; - while(fgets(line,1024,fp)) { + while (fgets(line,1024,fp)) { ptr = strtok(line," \t\n\r\f"); // skip empty lines diff --git a/src/USER-MISC/pair_local_density.cpp b/src/USER-MISC/pair_local_density.cpp index 3da1fcbed2..dc4e694995 100644 --- a/src/USER-MISC/pair_local_density.cpp +++ b/src/USER-MISC/pair_local_density.cpp @@ -594,7 +594,7 @@ void PairLocalDensity::interpolate_cbspl(int n, double delta, fpa = 0.; fpb = 0.; - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { dl[i] = du[i] = delta; } @@ -602,32 +602,32 @@ void PairLocalDensity::interpolate_cbspl(int n, double delta, dd[n-1] = 2.0 * delta; coeff_c[0] = ( 3.0 / delta ) * ( f[1] - f[0] ) - 3.0 * fpa; coeff_c[n-1] = 3.0 * fpb - ( 3.0 / delta ) * ( f[n-1] - f[n-2] ); - for ( i = 0; i < n-2; i++ ) { + for (i = 0; i < n-2; i++) { dd[i+1] = 4.0 * delta; coeff_c[i+1] = ( 3.0 / delta ) * ( f[i+2] - f[i+1] ) - ( 3.0 / delta ) * ( f[i+1] - f[i] ); } // tridiagonal solver - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { du[i] /= dd[i]; dd[i+1] -= dl[i]*du[i]; } coeff_c[0] /= dd[0]; - for ( i = 1; i < n; i++ ) + for (i = 1; i < n; i++) coeff_c[i] = ( coeff_c[i] - dl[i-1] * coeff_c[i-1] ) / dd[i]; - for ( i = n-2; i >= 0; i-- ) + for (i = n-2; i >= 0; i--) coeff_c[i] -= coeff_c[i+1] * du[i]; - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { coeff_d[i] = ( coeff_c[i+1] - coeff_c[i] ) / ( 3.0 * delta ); coeff_b[i] = ( f[i+1] - f[i] ) / delta - delta * ( coeff_c[i+1] + 2.0*coeff_c[i] ) / 3.0; } // normalize - for ( i = 0; i < n-1; i++ ) { + for (i = 0; i < n-1; i++) { coeff_b[i] = coeff_b[i] * delta ; coeff_c[i] = coeff_c[i] * delta*delta ; coeff_d[i] = coeff_d[i] * delta*delta*delta; diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index 57981e8922..a6bf602c70 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -632,7 +632,7 @@ int PairMEAMSpline::pack_forward_comm(int n, int *list, double *buf, { int* list_iter = list; int* list_iter_end = list + n; - while(list_iter != list_iter_end) + while (list_iter != list_iter_end) *buf++ = Uprime_values[*list_iter++]; return n; } diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index 09f5fa436d..58c0f75546 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -562,7 +562,7 @@ int PairMEAMSWSpline::pack_forward_comm(int n, int *list, double *buf, { int* list_iter = list; int* list_iter_end = list + n; - while(list_iter != list_iter_end) + while (list_iter != list_iter_end) *buf++ = Uprime_values[*list_iter++]; return n; } diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 9eae918128..0d5bbc1147 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -860,7 +860,7 @@ void PairTersoffTable::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/USER-MOLFILE/molfile_interface.cpp b/src/USER-MOLFILE/molfile_interface.cpp index ecc2b7468f..1ced86da86 100644 --- a/src/USER-MOLFILE/molfile_interface.cpp +++ b/src/USER-MOLFILE/molfile_interface.cpp @@ -54,7 +54,7 @@ extern "C" { // make sure we have the proper plugin type (native reader) // for the desired file type (called "name" at this level) if ((strcmp(MOLFILE_PLUGIN_TYPE,p->type) == 0) - && (strcmp(r->name, p->name) == 0) ) { + && (strcmp(r->name, p->name) == 0)) { r->p = static_cast(p); } return 0; @@ -408,7 +408,7 @@ int MolfileInterface::find_plugin(const char *pluginpath) retval = (retval > E_DIR) ? retval : E_DIR; // search for suitable file names and try to inspect them - while(dir) { + while (dir) { char *fullname; int len; @@ -515,7 +515,7 @@ int MolfileInterface::load_plugin(const char *filename) // check if the new plugin is of a newer minor version } else if ( (p->majorv == plugin->majorv) && - (p->minorv >= plugin->minorv) ) { + (p->minorv >= plugin->minorv)) { retval = E_VERSION; } } diff --git a/src/USER-MOLFILE/reader_molfile.cpp b/src/USER-MOLFILE/reader_molfile.cpp index 458f9190f1..4820d9a861 100644 --- a/src/USER-MOLFILE/reader_molfile.cpp +++ b/src/USER-MOLFILE/reader_molfile.cpp @@ -302,11 +302,11 @@ bigint ReaderMolfile::read_header(double box[3][3], int &boxinfo, int &triclinic (fieldtype[i] == Y) || (fieldtype[i] == Z) || (fieldtype[i] == ID) || - (fieldtype[i] == TYPE) ) { + (fieldtype[i] == TYPE)) { fieldindex[i] = fieldtype[i]; } else if ( (fieldtype[i] == VX) || (fieldtype[i] == VY) || - (fieldtype[i] == VZ) ) { + (fieldtype[i] == VZ)) { fieldindex[i] = fieldtype[i]; needvels = 1; } else { diff --git a/src/USER-OMP/angle_fourier_simple_omp.cpp b/src/USER-OMP/angle_fourier_simple_omp.cpp index 9ccf078342..0be602f3b0 100644 --- a/src/USER-OMP/angle_fourier_simple_omp.cpp +++ b/src/USER-OMP/angle_fourier_simple_omp.cpp @@ -135,10 +135,10 @@ void AngleFourierSimpleOMP::eval(int nfrom, int nto, ThrData * const thr) // handle sin(n th)/sin(th) singulatiries - if ( fabs(c)-1.0 > 0.0001 ) { + if (fabs(c)-1.0 > 0.0001) { a = k[type]*C[type]*N[type]*sin(nth)/sin(th); } else { - if ( c >= 0.0 ) { + if (c >= 0.0) { term = 1.0 - c; sgn = 1.0; } else { diff --git a/src/USER-OMP/fix_qeq_comb_omp.cpp b/src/USER-OMP/fix_qeq_comb_omp.cpp index 957c49abe6..aceff62ebc 100644 --- a/src/USER-OMP/fix_qeq_comb_omp.cpp +++ b/src/USER-OMP/fix_qeq_comb_omp.cpp @@ -125,7 +125,7 @@ void FixQEQCombOMP::post_force(int /* vflag */) q1[i] = q2[i] = qf[i] = 0.0; } - for (iloop = 0; iloop < loopmax; iloop ++ ) { + for (iloop = 0; iloop < loopmax; iloop ++) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (mask[i] & groupbit) { diff --git a/src/USER-OMP/improper_fourier_omp.cpp b/src/USER-OMP/improper_fourier_omp.cpp index 5d2a03ccd3..b38b642dbc 100644 --- a/src/USER-OMP/improper_fourier_omp.cpp +++ b/src/USER-OMP/improper_fourier_omp.cpp @@ -120,7 +120,7 @@ void ImproperFourierOMP::eval(int nfrom, int nto, ThrData * const thr) vb1x,vb1y,vb1z, vb2x,vb2y,vb2z, vb3x,vb3y,vb3z,thr); - if ( all[type] ) { + if (all[type]) { add1_thr(i1,i4,i2,i3,type, vb3x,vb3y,vb3z, vb1x,vb1y,vb1z, diff --git a/src/USER-OMP/pair_comb_omp.cpp b/src/USER-OMP/pair_comb_omp.cpp index 045db5d402..2da9ca8d8f 100644 --- a/src/USER-OMP/pair_comb_omp.cpp +++ b/src/USER-OMP/pair_comb_omp.cpp @@ -242,7 +242,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) jtype = map[type[j]]; iparam_ij = elem2param[itype][jtype][jtype]; - if (params[iparam_ij].hfocor > 0.0 ) { + if (params[iparam_ij].hfocor > 0.0) { delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; diff --git a/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp b/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp index 0b8efe25ef..4dadd0a1ea 100644 --- a/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp @@ -1189,7 +1189,7 @@ void PairLJLongTIP4PLongOMP::eval_inner(int iifrom, int iito, ThrData * const th rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq < cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); @@ -1443,7 +1443,7 @@ void PairLJLongTIP4PLongOMP::eval_middle(int iifrom, int iito, ThrData * const t rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq ) { // lj + if (rsq < cut_ljsq[itype][jtype] && rsq >= cut_in_off_sq && rsq <= cut_out_off_sq) { // lj r2inv = 1.0/rsq; double rn = r2inv*r2inv*r2inv; if (ni == 0) forcelj = rn*(rn*lj1i[jtype]-lj2i[jtype]); diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index b717f87d0f..d10a4573f1 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -365,7 +365,7 @@ void PairReaxCOMP::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for ( int i = 0; i < LIST_N; ++i ) + for (int i = 0; i < LIST_N; ++i) lists[i].allocated = 0; if (fix_reax == nullptr) { @@ -433,7 +433,7 @@ void PairReaxCOMP::setup( ) InitializeOMP( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for ( int k = 0; k < system->N; ++k ) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -472,7 +472,7 @@ void PairReaxCOMP::write_reax_atoms() #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -596,7 +596,7 @@ void PairReaxCOMP::read_reax_forces(int /* vflag */) #if defined(_OPENMP) #pragma omp parallel for schedule(static) default(shared) #endif - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -622,14 +622,14 @@ void PairReaxCOMP::FindBond() bond_data *bo_ij; nj = 0; - for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for (pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; bo_tmp = bo_ij->bo_data.BO; - if (bo_tmp >= bo_cut ) { + if (bo_tmp >= bo_cut) { tmpid[i][nj] = j; tmpbo[i][nj] = bo_tmp; nj ++; diff --git a/src/USER-OMP/pair_tersoff_zbl_omp.cpp b/src/USER-OMP/pair_tersoff_zbl_omp.cpp index 44d7994c9e..5dd411760c 100644 --- a/src/USER-OMP/pair_tersoff_zbl_omp.cpp +++ b/src/USER-OMP/pair_tersoff_zbl_omp.cpp @@ -95,7 +95,7 @@ void PairTersoffZBLOMP::read_file(char *file) double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); diff --git a/src/USER-OMP/reaxc_bond_orders_omp.cpp b/src/USER-OMP/reaxc_bond_orders_omp.cpp index ec93d9478d..499c5f2933 100644 --- a/src/USER-OMP/reaxc_bond_orders_omp.cpp +++ b/src/USER-OMP/reaxc_bond_orders_omp.cpp @@ -46,7 +46,7 @@ using namespace LAMMPS_NS; void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, - storage *workspace, reax_list **lists ) { + storage *workspace, reax_list **lists) { reax_list *bonds = (*lists) + BONDS; bond_data *nbr_j, *nbr_k; bond_order_data *bo_ij, *bo_ji; @@ -164,7 +164,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: i neighbor - for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -194,7 +194,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, } // forces on k: j neighbor - for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -229,7 +229,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, simulation_data * /* data */, - storage *workspace, reax_list **lists ) { + storage *workspace, reax_list **lists) { reax_list *bonds = (*lists) + BONDS; bond_data *nbr_j, *nbr_k; bond_order_data *bo_ij, *bo_ji; @@ -274,7 +274,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, * forces related to atom i * * first neighbors of atom i * ************************************/ - for ( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -307,7 +307,7 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, /* force */ rvec_Add(workspace->forceReduction[reductionOffset+i],temp ); - for ( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -692,7 +692,7 @@ void BOOMP( reax_system *system, control_params * /* control */, simulation_data #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for (j = 0; j < system->N; ++j ) { + for (j = 0; j < system->N; ++j) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); diff --git a/src/USER-OMP/reaxc_forces_omp.cpp b/src/USER-OMP/reaxc_forces_omp.cpp index 68ab6f933d..7fe6a41e9d 100644 --- a/src/USER-OMP/reaxc_forces_omp.cpp +++ b/src/USER-OMP/reaxc_forces_omp.cpp @@ -92,7 +92,7 @@ void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control, #endif /* Implement all force calls as function pointers */ - for ( i = 0; i < NUM_INTRS; i++ ) { + for (i = 0; i < NUM_INTRS; i++) { (Interaction_Functions[i])( system, control, data, workspace, lists, out_control ); } @@ -284,7 +284,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for (int i = 0; i < N; ++i ) { + for (int i = 0; i < N; ++i) { system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); if (i < N-1) @@ -308,7 +308,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for (int i = 0; i < n; ++i ) { + for (int i = 0; i < n; ++i) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { system->my_atoms[i].num_hbonds = @@ -335,7 +335,7 @@ void Validate_ListsOMP(reax_system *system, storage * /*workspace*/, reax_list * void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, output_controls * /* out_control */, - MPI_Comm comm ) { + MPI_Comm comm) { #ifdef OMP_TIMING double startTimeBase, endTimeBase; startTimeBase = MPI_Wtime(); @@ -395,7 +395,7 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); - for ( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); if (nbr_pj->d <= cutoff) { int j = nbr_pj->nbr; diff --git a/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp b/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp index 0070fbc7c2..c0fe4e3792 100644 --- a/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp +++ b/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp @@ -111,8 +111,8 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, Hydrogen bond is between j and k. so in this function i->X, j->H, k->Z when we map variables onto the ones in the handout.*/ - // for( j = 0; j < system->n; ++j ) - for( j = ifrom; j < ito; ++j ) { + // for (j = 0; j < system->n; ++j) + for (j = ifrom; j < ito; ++j) { /* j has to be of type H */ if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { /*set j's variables */ @@ -124,7 +124,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, if (type_j < 0) continue; top = 0; - for( pi = start_j; pi < end_j; ++pi ) { + for (pi = start_j; pi < end_j; ++pi) { pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; @@ -136,7 +136,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, hblist[top++] = pi; } - for( pk = hb_start_j; pk < hb_end_j; ++pk ) { + for (pk = hb_start_j; pk < hb_end_j; ++pk) { /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; @@ -145,7 +145,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); - for( itr = 0; itr < top; ++itr ) { + for (itr = 0; itr < top; ++itr) { pi = hblist[itr]; pbond_ij = &( bonds->select.bond_list[pi] ); i = pbond_ij->nbr; diff --git a/src/USER-OMP/reaxc_multi_body_omp.cpp b/src/USER-OMP/reaxc_multi_body_omp.cpp index 52ef7048d6..e2af2d96ad 100644 --- a/src/USER-OMP/reaxc_multi_body_omp.cpp +++ b/src/USER-OMP/reaxc_multi_body_omp.cpp @@ -116,7 +116,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, numbonds = 0; e_lp = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; /* calculate the energy */ @@ -137,7 +137,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, /* correction for C2 */ if (p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C")) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -227,7 +227,7 @@ void Atom_EnergyOMP( reax_system *system, control_params * /* control */, numbonds = 0; e_un = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; if (numbonds > 0) total_Eun += e_un = diff --git a/src/USER-OMP/reaxc_nonbonded_omp.cpp b/src/USER-OMP/reaxc_nonbonded_omp.cpp index ce463c39ff..7abcb5b42a 100644 --- a/src/USER-OMP/reaxc_nonbonded_omp.cpp +++ b/src/USER-OMP/reaxc_nonbonded_omp.cpp @@ -96,13 +96,13 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, #if defined(_OPENMP) #pragma omp for schedule(guided) #endif - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { if (system->my_atoms[i].type < 0) continue; start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); orig_i = system->my_atoms[i].orig_id; - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; orig_j = system->my_atoms[j].orig_id; diff --git a/src/USER-OMP/reaxc_torsion_angles_omp.cpp b/src/USER-OMP/reaxc_torsion_angles_omp.cpp index 79fa9e0f47..cb92a9a68c 100644 --- a/src/USER-OMP/reaxc_torsion_angles_omp.cpp +++ b/src/USER-OMP/reaxc_torsion_angles_omp.cpp @@ -202,7 +202,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; @@ -241,7 +241,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-PTM/ptm_voronoi_cell.cpp b/src/USER-PTM/ptm_voronoi_cell.cpp index 5b29706b82..ab0b9172aa 100644 --- a/src/USER-PTM/ptm_voronoi_cell.cpp +++ b/src/USER-PTM/ptm_voronoi_cell.cpp @@ -103,9 +103,9 @@ voronoicell_base::~voronoicell_base() { * \param[in] vb a pointered to the class to be copied. */ template void voronoicell_base::check_memory_for_copy(vc_class &vc,voronoicell_base* vb) { - while(current_vertex_ordercurrent_vertex_order) add_memory_vorder(vc); - for (int i=0;imec[i]) add_memory(vc,i,ds2); - while(current_verticesp) add_memory_vertices(vc); + while (current_vertex_ordercurrent_vertex_order) add_memory_vorder(vc); + for (int i=0;imec[i]) add_memory(vc,i,ds2); + while (current_verticesp) add_memory_vertices(vc); } /** Increases the memory storage for a particular vertex order, by increasing @@ -139,7 +139,7 @@ void voronoicell_base::add_memory(vc_class &vc,int i,int *stackp2) { l=new int[s*mem[i]]; int m=0; vc.n_allocate_aux1(i); - while(j=0) { ed[k]=l+j; @@ -211,14 +211,14 @@ void voronoicell_base::add_memory_vorder(vc_class &vc) { #endif p1=new int[i]; for (j=0;j=p) throw true; u=l;up=lp; for (us=0;us=p) throw true; u=q;up=qp; @@ -410,7 +410,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq } if (us==qs) { us++; - while(us=current_vertex_order) add_memory_vorder(vc); + while (nu[p]>=current_vertex_order) add_memory_vorder(vc); if (mec[nu[p]]==mem[nu[p]]) add_memory(vc,nu[p],stackp2); // Copy the edges of the original vertex into the new @@ -651,7 +651,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq ed[p]=mep[nu[p]]+((nu[p]<<1)+1)*mec[nu[p]]++; ed[p][nu[p]<<1]=p; us=i++; - while(i=current_vertex_order) add_memory_vorder(vc); + while (k>=current_vertex_order) add_memory_vorder(vc); if (mec[k]==mem[k]) add_memory(vc,k,stackp2); // Now create a new vertex with order k, or augment @@ -903,7 +903,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq vc.n_set_aux1(k); edp=mep[k]+((k<<1)+1)*mec[k]++; i=0; - while(ids) { + while (stackp>ds) { --p; - while(ed[p][nu[p]]==-1) { + while (ed[p][nu[p]]==-1) { j=nu[p]; edp=ed[p];edd=(mep[j]+((j<<1)+1)*--mec[j]); - while(edp inline bool voronoicell_base::collapse_order2(vc_class &vc) { if (!collapse_order1(vc)) return false; int a,b,i,j,k,l; - while(mec[2]>0) { + while (mec[2]>0) { // Pick a order 2 vertex and read in its edges i=--mec[2]; @@ -1142,7 +1142,7 @@ inline bool voronoicell_base::collapse_order2(vc_class &vc) { template inline bool voronoicell_base::collapse_order1(vc_class &vc) { int i,j,k; - while(mec[1]>0) { + while (mec[1]>0) { up=0; #if VOROPP_VERBOSE >=1 fputs("Order one collapse\n",stderr); @@ -1187,7 +1187,7 @@ inline bool voronoicell_base::delete_connection(vc_class &vc,int j,int k,bool ha if (mec[i]==mem[i]) add_memory(vc,i,ds2); vc.n_set_aux1(i); for (l=0;l &v) { ed[i][j]=-1-k; l=cycle_up(ed[i][nu[i]+j],k); m=ed[k][l];ed[k][l]=-1-m; - while(m!=i) { + while (m!=i) { n=cycle_up(ed[k][nu[k]+l],m); ux=pts[3*k]-pts[3*i]; uy=pts[3*k+1]-pts[3*i+1]; diff --git a/src/USER-QMMM/fix_qmmm.cpp b/src/USER-QMMM/fix_qmmm.cpp index 32b77aaf80..f352cce827 100644 --- a/src/USER-QMMM/fix_qmmm.cpp +++ b/src/USER-QMMM/fix_qmmm.cpp @@ -108,7 +108,7 @@ static void rebuild_table_tagint(taginthash_t *tptr) { taginthash_init(tptr, old_size<<1); for (i=0; inext; h=taginthash(tptr, tmp->key); diff --git a/src/USER-QTB/fix_qbmsst.cpp b/src/USER-QTB/fix_qbmsst.cpp index 82dd76a1b5..2257c9992e 100644 --- a/src/USER-QTB/fix_qbmsst.cpp +++ b/src/USER-QTB/fix_qbmsst.cpp @@ -49,20 +49,20 @@ FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : { if (narg < 5) error->all(FLERR,"Illegal fix qbmsst command"); - if ( strcmp(arg[3],"x") == 0 ) { + if (strcmp(arg[3],"x") == 0) { direction = 0; box_change |= BOX_CHANGE_X; - } else if ( strcmp(arg[3],"y") == 0 ) { + } else if (strcmp(arg[3],"y") == 0) { direction = 1; box_change |= BOX_CHANGE_Y; - } else if ( strcmp(arg[3],"z") == 0 ) { + } else if (strcmp(arg[3],"z") == 0) { direction = 2; box_change |= BOX_CHANGE_Z; } else { error->all(FLERR,"Illegal fix qbmsst command"); } velocity = atof(arg[4]); - if ( velocity < 0 ) + if (velocity < 0) error->all(FLERR,"Illegal fix qbmsst command"); // default parameters @@ -431,34 +431,34 @@ void FixQBMSST::setup(int /*vflag*/) couple(); velocity_sum = compute_vsum(); - if ( v0_set == 0 ) { + if (v0_set == 0) { v0 = compute_vol(); v0_set = 1; if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix QBMSST v0 = {:12.5e}\n", v0)); } - if ( p0_set == 0 ) { + if (p0_set == 0) { p0 = p_current[direction]; p0_set = 1; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix QBMSST p0 = {:12.5e}\n", p0)); } - if ( e0_set == 0 ) { + if (e0_set == 0) { e0 = compute_etotal(); e0_set = 1; old_eavg = e0; - if ( comm->me == 0 ) + if (comm->me == 0) utils::logmesg(lmp,fmt::format("Fix QBMSST e0 = to be {:12.5e}\n",e0)); } temperature->compute_vector(); double *ke_tensor = temperature->vector; double ke_temp = ke_tensor[0]+ke_tensor[1]+ke_tensor[2]; - if (ke_temp > 0.0 && tscale > 0.0 ) { + if (ke_temp > 0.0 && tscale > 0.0) { // transfer energy from atom velocities to cell volume motion // to bias initial compression @@ -477,7 +477,7 @@ void FixQBMSST::setup(int /*vflag*/) "factor of {:12.5e}\n",fac2,tscale)); for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - for (int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { v[i][k]*=sqrt_initial_temperature_scaling; } } @@ -596,12 +596,12 @@ void FixQBMSST::initial_integrate(int /*vflag*/) double B = total_mass * mu / ( qmass * vol ); // prevent blow-up of the volume. - if ( vol > v0 && A > 0.0 ) { + if (vol > v0 && A > 0.0) { A = -A; } // use taylor expansion to avoid singularity at B == 0. - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -614,15 +614,15 @@ void FixQBMSST::initial_integrate(int /*vflag*/) velocity_sum = compute_vsum(); for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ) - fric_coef; old_velocity[i][k] = v[i][k]; - if ( k == direction ) { + if (k == direction) { D = D - 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -638,7 +638,7 @@ void FixQBMSST::initial_integrate(int /*vflag*/) // reset the velocities. for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { v[i][k] = old_velocity[i][k]; } } @@ -647,15 +647,15 @@ void FixQBMSST::initial_integrate(int /*vflag*/) // propagate velocities 1/2 step using the new velocity sum. for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( k = 0; k < 3; k++ ) { + for (k = 0; k < 3; k++) { double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ) - fric_coef; - if ( k == direction ) { + if (k == direction) { D = D - 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -715,15 +715,15 @@ void FixQBMSST::final_integrate() for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for ( int k = 0; k < 3; k++ ) { + for (int k = 0; k < 3; k++) { double C = (f[i][k] + fran[i][k]) * force->ftm2v / mass[type[i]];// this term now has a random force part double D = mu * omega[sd] * omega[sd] / (velocity_sum * mass[type[i]] * vol ) - fric_coef; - if ( k == direction ) { + if (k == direction) { D = D - 2.0 * omega[sd] / vol; } - if ( fabs(dthalf * D) > 1.0e-06 ) { + if (fabs(dthalf * D) > 1.0e-06) { double expd = exp(D * dthalf); v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; } else { @@ -753,13 +753,13 @@ void FixQBMSST::final_integrate() // prevent blow-up of the volume. - if ( vol > v0 && A > 0.0 ) { + if (vol > v0 && A > 0.0) { A = -A; } // use taylor expansion to avoid singularity at B == 0. - if ( B * dthalf > 1.0e-06 ) { + if (B * dthalf > 1.0e-06) { omega[sd] = ( omega[sd] + A * ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { @@ -814,7 +814,7 @@ void FixQBMSST::remap(int flag) // reset global and local box to new size/shape for (i = 0; i < 3; i++) { - if ( direction == i ) { + if (direction == i) { oldlo = domain->boxlo[i]; oldhi = domain->boxhi[i]; ctr = 0.5 * (oldlo + oldhi); @@ -1084,7 +1084,7 @@ double FixQBMSST::compute_vol() ------------------------------------------------------------------------- */ void FixQBMSST::check_alloc(int n) { - if ( atoms_allocated < n ) { + if (atoms_allocated < n) { memory->destroy(old_velocity); memory->create(old_velocity,n,3,"qbmsst:old_velocity"); atoms_allocated = n; diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 3ca19285f6..f850925764 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -162,7 +162,7 @@ void PairQUIP::compute(int eflag, int vflag) iquip = 0; for (ii = 0; ii < ntotal; ii++) { - for ( jj = 0; jj < 3; jj++ ) { + for (jj = 0; jj < 3; jj++) { f[ii][jj] += quip_force[iquip]; iquip++; } diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 8d6b1b27ac..483bd1c0f6 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -334,7 +334,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : strcpy(files[rxn],arg[iarg]); iarg++; - while (iarg < narg && strcmp(arg[iarg],"react") != 0 ) { + while (iarg < narg && strcmp(arg[iarg],"react") != 0) { if (strcmp(arg[iarg],"prob") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal fix bond/react command: " "'prob' keyword has too few arguments"); @@ -1293,7 +1293,7 @@ void FixBondReact::superimpose_algorithm() nxspecial[local_atom2][0] == nxspecial[local_atom1][0]) && (nxspecial[local_atom1][0] == 0 || xspecial[local_atom1][0] == atom->tag[local_atom2]) && - check_constraints() ) { + check_constraints()) { status = ACCEPT; glove_ghostcheck(); } else @@ -2772,7 +2772,7 @@ void FixBondReact::update_everything() for (int p = 0; p < twomol->natoms; p++) { int pp = equivalences[p][1][rxnID]-1; if (p!=j && special[atom->map(update_mega_glove[jj+1][i])][k] == update_mega_glove[pp+1][i] - && landlocked_atoms[p][rxnID] == 1 ) { + && landlocked_atoms[p][rxnID] == 1) { for (int n = k; n < nspecial[atom->map(update_mega_glove[jj+1][i])][2]-1; n++) { special[atom->map(update_mega_glove[jj+1][i])][n] = special[atom->map(update_mega_glove[jj+1][i])][n+1]; } diff --git a/src/USER-REAXC/fix_reaxc_bonds.cpp b/src/USER-REAXC/fix_reaxc_bonds.cpp index fa115e343e..6d90ef5fae 100644 --- a/src/USER-REAXC/fix_reaxc_bonds.cpp +++ b/src/USER-REAXC/fix_reaxc_bonds.cpp @@ -195,7 +195,7 @@ void FixReaxCBonds::FindBond(struct _reax_list * /*lists*/, int &numbonds) i = ilist[ii]; nj = 0; - for( pj = Start_Index(i, reaxc->lists); pj < End_Index(i, reaxc->lists); ++pj ) { + for (pj = Start_Index(i, reaxc->lists); pj < End_Index(i, reaxc->lists); ++pj) { bo_ij = &( reaxc->lists->select.bond_list[pj] ); j = bo_ij->nbr; jtag = tag[j]; @@ -262,7 +262,7 @@ void FixReaxCBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, double cutof3 = reaxc->control->bg_cut; MPI_Request irequest, irequest2; - if (me == 0 ) { + if (me == 0) { fprintf(fp,"# Timestep " BIGINT_FORMAT " \n",ntimestep); fprintf(fp,"# \n"); fprintf(fp,"# Number of particles %d \n",natoms); diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index 1fb6eb9005..bfe9330819 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -420,7 +420,7 @@ void PairReaxC::init_style( ) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " "increased neighbor list skin."); - for ( int i = 0; i < LIST_N; ++i ) + for (int i = 0; i < LIST_N; ++i) if (lists[i].allocated != 1) lists[i].allocated = 0; @@ -478,7 +478,7 @@ void PairReaxC::setup( ) write_reax_lists(); Initialize( system, control, data, workspace, &lists, out_control, mpi_data, world ); - for ( int k = 0; k < system->N; ++k ) { + for (int k = 0; k < system->N; ++k) { num_bonds[k] = system->my_atoms[k].num_bonds; num_hbonds[k] = system->my_atoms[k].num_hbonds; } @@ -645,7 +645,7 @@ void PairReaxC::write_reax_atoms() if (system->N > system->total_cap) error->all(FLERR,"Too many ghost atoms"); - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].orig_id = atom->tag[i]; system->my_atoms[i].type = map[atom->type[i]]; system->my_atoms[i].x[0] = atom->x[i][0]; @@ -703,13 +703,13 @@ int PairReaxC::estimate_reax_lists() int numall = list->inum + list->gnum; - for ( itr_i = 0; itr_i < numall; ++itr_i ) { + for (itr_i = 0; itr_i < numall; ++itr_i) { i = ilist[itr_i]; marked[i] = 1; ++num_marked; jlist = firstneigh[i]; - for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -751,7 +751,7 @@ int PairReaxC::write_reax_lists() int numall = list->inum + list->gnum; - for ( itr_i = 0; itr_i < numall; ++itr_i ) { + for (itr_i = 0; itr_i < numall; ++itr_i) { i = ilist[itr_i]; jlist = firstneigh[i]; Set_Start_Index( i, num_nbrs, far_nbrs ); @@ -761,7 +761,7 @@ int PairReaxC::write_reax_lists() else cutoff_sqr = control->bond_cut*control->bond_cut; - for ( itr_j = 0; itr_j < numneigh[i]; ++itr_j ) { + for (itr_j = 0; itr_j < numneigh[i]; ++itr_j) { j = jlist[itr_j]; j &= NEIGHMASK; get_distance( x[j], x[i], &d_sqr, &dvec ); @@ -784,7 +784,7 @@ int PairReaxC::write_reax_lists() void PairReaxC::read_reax_forces(int /*vflag*/) { - for ( int i = 0; i < system->N; ++i ) { + for (int i = 0; i < system->N; ++i) { system->my_atoms[i].f[0] = workspace->f[i][0]; system->my_atoms[i].f[1] = workspace->f[i][1]; system->my_atoms[i].f[2] = workspace->f[i][2]; @@ -864,14 +864,14 @@ void PairReaxC::FindBond() for (i = 0; i < system->n; i++) { nj = 0; - for ( pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj ) { + for (pj = Start_Index(i, lists); pj < End_Index(i, lists); ++pj) { bo_ij = &( lists->select.bond_list[pj] ); j = bo_ij->nbr; if (j < i) continue; bo_tmp = bo_ij->bo_data.BO; - if (bo_tmp >= bo_cut ) { + if (bo_tmp >= bo_cut) { tmpid[i][nj] = j; tmpbo[i][nj] = bo_tmp; nj ++; diff --git a/src/USER-REAXC/reaxc_allocate.cpp b/src/USER-REAXC/reaxc_allocate.cpp index f017eae41e..f043dc85d6 100644 --- a/src/USER-REAXC/reaxc_allocate.cpp +++ b/src/USER-REAXC/reaxc_allocate.cpp @@ -96,9 +96,9 @@ void DeAllocate_System( reax_system *system ) sfree(system->error_ptr, ff_params->gp.l, "ff:globals" ); - for( i = 0; i < ntypes; ++i ) { - for( j = 0; j < ntypes; ++j ) { - for( k = 0; k < ntypes; ++k ) { + for (i = 0; i < ntypes; ++i) { + for (j = 0; j < ntypes; ++j) { + for (k = 0; k < ntypes; ++k) { sfree(system->error_ptr, ff_params->fbp[i][j][k], "ff:fbp[i,j,k]" ); } sfree(system->error_ptr, ff_params->fbp[i][j], "ff:fbp[i,j]" ); @@ -129,7 +129,7 @@ void DeAllocate_Workspace( control_params * control, storage *workspace ) workspace->allocated = 0; /* communication storage */ - for( i = 0; i < MAX_NBRS; ++i ) { + for (i = 0; i < MAX_NBRS; ++i) { sfree(control->error_ptr, workspace->tmp_dbl[i], "tmp_dbl[i]" ); sfree(control->error_ptr, workspace->tmp_rvec[i], "tmp_rvec[i]" ); sfree(control->error_ptr, workspace->tmp_rvec2[i], "tmp_rvec2[i]" ); @@ -169,7 +169,7 @@ void DeAllocate_Workspace( control_params * control, storage *workspace ) sfree(control->error_ptr, workspace->x, "x" ); /* GMRES storage */ - for( i = 0; i < RESTART+1; ++i ) { + for (i = 0; i < RESTART+1; ++i) { sfree(control->error_ptr, workspace->h[i], "h[i]" ); sfree(control->error_ptr, workspace->v[i], "v[i]" ); } @@ -219,7 +219,7 @@ int Allocate_Workspace( reax_system * /*system*/, control_params * control, local_rvec = local_cap * sizeof(rvec); /* communication storage */ - for( i = 0; i < MAX_NBRS; ++i ) { + for (i = 0; i < MAX_NBRS; ++i) { workspace->tmp_dbl[i] = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "tmp_dbl"); workspace->tmp_rvec[i] = (rvec*) @@ -277,7 +277,7 @@ int Allocate_Workspace( reax_system * /*system*/, control_params * control, workspace->hc = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "hc"); workspace->v = (double**) scalloc(control->error_ptr, RESTART+1, sizeof(double*), "v"); - for( i = 0; i < RESTART+1; ++i ) { + for (i = 0; i < RESTART+1; ++i) { workspace->h[i] = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "h[i]"); workspace->v[i] = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "v[i]"); } @@ -336,7 +336,7 @@ static int Reallocate_HBonds_List( reax_system *system, reax_list *hbonds ) double saferzone = system->saferzone; total_hbonds = 0; - for( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) if ((system->my_atoms[i].Hindex) >= 0) { total_hbonds += system->my_atoms[i].num_hbonds; } @@ -361,7 +361,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, *total_bonds = 0; *est_3body = 0; - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { *est_3body += SQR(system->my_atoms[i].num_bonds); *total_bonds += system->my_atoms[i].num_bonds; } @@ -411,13 +411,13 @@ void ReAllocate( reax_system *system, control_params *control, realloc = &(workspace->realloc); if ( system->n >= DANGER_ZONE * system->local_cap || - (0 && system->n <= LOOSE_ZONE * system->local_cap) ) { + (0 && system->n <= LOOSE_ZONE * system->local_cap)) { system->local_cap = MAX( (int)(system->n * safezone), mincap ); } int Nflag = 0; if ( system->N >= DANGER_ZONE * system->total_cap || - (0 && system->N <= LOOSE_ZONE * system->total_cap) ) { + (0 && system->N <= LOOSE_ZONE * system->total_cap)) { Nflag = 1; system->total_cap = MAX( (int)(system->N * safezone), mincap ); } @@ -467,7 +467,7 @@ void ReAllocate( reax_system *system, control_params *control, if (control->hbond_cut > 0) { Hflag = 0; if ( system->numH >= DANGER_ZONE * system->Hcap || - (0 && system->numH <= LOOSE_ZONE * system->Hcap) ) { + (0 && system->numH <= LOOSE_ZONE * system->Hcap)) { Hflag = 1; system->Hcap = int(MAX( system->numH * saferzone, mincap )); } @@ -497,7 +497,7 @@ void ReAllocate( reax_system *system, control_params *control, realloc->num_3body = (int)(MAX(realloc->num_3body*safezone, MIN_3BODIES)); if ( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, - (*lists)+THREE_BODIES ) ) { + (*lists)+THREE_BODIES )) { system->error_ptr->one(FLERR, "Problem in initializing angles list"); } realloc->num_3body = -1; diff --git a/src/USER-REAXC/reaxc_bond_orders.cpp b/src/USER-REAXC/reaxc_bond_orders.cpp index a9985d79f3..6a854e1805 100644 --- a/src/USER-REAXC/reaxc_bond_orders.cpp +++ b/src/USER-REAXC/reaxc_bond_orders.cpp @@ -67,7 +67,7 @@ void Add_dBond_to_Forces_NPT( int i, int pj, simulation_data *data, coef.C2dDelta = bo_ij->C2dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); coef.C3dDelta = bo_ij->C3dbo * (workspace->CdDelta[i]+workspace->CdDelta[j]); - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -100,7 +100,7 @@ void Add_dBond_to_Forces_NPT( int i, int pj, simulation_data *data, /* force */ rvec_Add( workspace->f[i], temp ); - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -217,7 +217,7 @@ void Add_dBond_to_Forces( reax_system *system, int i, int pj, } // forces on k: i neighbor - for( pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk ) { + for (pk = Start_Index(i, bonds); pk < End_Index(i, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -237,7 +237,7 @@ void Add_dBond_to_Forces( reax_system *system, int i, int pj, } // forces on k: j neighbor - for( pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk ) { + for (pk = Start_Index(j, bonds); pk < End_Index(j, bonds); ++pk) { nbr_k = &(bonds->select.bond_list[pk]); k = nbr_k->nbr; @@ -262,7 +262,7 @@ void Add_dBond_to_Forces( reax_system *system, int i, int pj, int BOp( storage *workspace, reax_list *bonds, double bo_cut, int i, int btop_i, far_neighbor_data *nbr_pj, single_body_parameters *sbp_i, single_body_parameters *sbp_j, - two_body_parameters *twbp ) { + two_body_parameters *twbp) { int j, btop_j; double r2, C12, C34, C56; double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; @@ -383,7 +383,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* p_boc2 = system->reax_param.gp.l[1]; /* Calculate Deltaprime, Deltaprime_boc values */ - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); @@ -395,7 +395,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* } /* Corrected Bond Order calculations */ - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[type_i]); @@ -405,7 +405,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* start_i = Start_Index(i, bonds); end_i = End_Index(i, bonds); - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -558,7 +558,7 @@ void BO( reax_system *system, control_params * /*control*/, simulation_data * /* } p_lp1 = system->reax_param.gp.l[15]; - for( j = 0; j < system->N; ++j ) { + for (j = 0; j < system->N; ++j) { type_j = system->my_atoms[j].type; if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[ type_j ]); diff --git a/src/USER-REAXC/reaxc_bonds.cpp b/src/USER-REAXC/reaxc_bonds.cpp index 91dc38d56d..c706a2fd79 100644 --- a/src/USER-REAXC/reaxc_bonds.cpp +++ b/src/USER-REAXC/reaxc_bonds.cpp @@ -54,11 +54,11 @@ void Bonds( reax_system *system, control_params * /*control*/, gp37 = (int) system->reax_param.gp.l[37]; natoms = system->n; - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { start_i = Start_Index(i, bonds); end_i = End_Index(i, bonds); - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { j = bonds->select.bond_list[pj].nbr; if (system->my_atoms[i].orig_id > system->my_atoms[j].orig_id) @@ -106,7 +106,7 @@ void Bonds( reax_system *system, control_params * /*control*/, if (bo_ij->BO >= 1.00) { if ( gp37 == 2 || (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || - (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990) ) { + (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); diff --git a/src/USER-REAXC/reaxc_control.cpp b/src/USER-REAXC/reaxc_control.cpp index ab183bdaa4..b717b6b97f 100644 --- a/src/USER-REAXC/reaxc_control.cpp +++ b/src/USER-REAXC/reaxc_control.cpp @@ -41,7 +41,7 @@ char Read_Control_File( char *control_file, control_params* control, double val; /* open control file */ - if ( (fp = fopen( control_file, "r" ) ) == nullptr ) { + if ((fp = fopen( control_file, "r" ) ) == nullptr) { control->error_ptr->all(FLERR, "The control file cannot be opened"); } @@ -343,7 +343,7 @@ char Read_Control_File( char *control_file, control_params* control, } else if (strcmp(tmp[0], "ignore") == 0) { control->num_ignored = atoi(tmp[1]); - for( i = 0; i < control->num_ignored; ++i ) + for (i = 0; i < control->num_ignored; ++i) control->ignore[atoi(tmp[i+2])] = 1; } else if (strcmp(tmp[0], "dipole_anal") == 0) { @@ -379,7 +379,7 @@ char Read_Control_File( char *control_file, control_params* control, else control->T = control->T_init; /* free memory allocations at the top */ - for( i = 0; i < MAX_TOKENS; i++ ) + for (i = 0; i < MAX_TOKENS; i++) free( tmp[i] ); free( tmp ); free( s ); diff --git a/src/USER-REAXC/reaxc_ffield.cpp b/src/USER-REAXC/reaxc_ffield.cpp index 13e01c3a53..e54b3b75e0 100644 --- a/src/USER-REAXC/reaxc_ffield.cpp +++ b/src/USER-REAXC/reaxc_ffield.cpp @@ -109,7 +109,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, tor_flag = (char****) scalloc(control->error_ptr, reax->num_atom_types, sizeof(char***), "tor_flag"); - for( i = 0; i < reax->num_atom_types; i++ ) { + for (i = 0; i < reax->num_atom_types; i++) { reax->tbp[i] = (two_body_parameters*) scalloc(control->error_ptr, reax->num_atom_types, sizeof(two_body_parameters), "tbp[i]"); reax->thbp[i]= (three_body_header**) @@ -121,7 +121,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, tor_flag[i] = (char***) scalloc(control->error_ptr, reax->num_atom_types, sizeof(char**), "tor_flag[i]"); - for( j = 0; j < reax->num_atom_types; j++ ) { + for (j = 0; j < reax->num_atom_types; j++) { reax->thbp[i][j]= (three_body_header*) scalloc(control->error_ptr, reax->num_atom_types, sizeof(three_body_header), "thbp[i,j]"); reax->hbp[i][j] = (hbond_parameters*) @@ -144,7 +144,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, char errmsg[1024]; - for( i = 0; i < reax->num_atom_types; i++ ) { + for (i = 0; i < reax->num_atom_types; i++) { /* line one */ fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); @@ -158,7 +158,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, control->error_ptr->all(FLERR, errmsg); } - for( j = 0; j < (int)(strlen(tmp[0])); ++j ) + for (j = 0; j < (int)(strlen(tmp[0])); ++j) reax->sbp[i].name[j] = toupper( tmp[0][j] ); val = atof(tmp[1]); reax->sbp[i].r_s = val; @@ -302,9 +302,9 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } /* Equate vval3 to valf for first-row elements (25/10/2004) */ - for( i = 0; i < reax->num_atom_types; i++ ) + for (i = 0; i < reax->num_atom_types; i++) if ( reax->sbp[i].mass < 21 && - reax->sbp[i].valency_val != reax->sbp[i].valency_boc ) { + reax->sbp[i].valency_val != reax->sbp[i].valency_boc) { if (me == 0) { char errmsg[256]; snprintf(errmsg, 256, "Changed valency_val to valency_boc for %s", @@ -542,16 +542,16 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } } - for( i = 0; i < reax->num_atom_types; ++i ) - for( j = 0; j < reax->num_atom_types; ++j ) - for( k = 0; k < reax->num_atom_types; ++k ) + for (i = 0; i < reax->num_atom_types; ++i) + for (j = 0; j < reax->num_atom_types; ++j) + for (k = 0; k < reax->num_atom_types; ++k) reax->thbp[i][j][k].cnt = 0; fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); l = atoi( tmp[0] ); - for( i = 0; i < l; i++ ) { + for (i = 0; i < l; i++) { fgets(s,MAX_LINE,fp); c=Tokenize(s,&tmp); @@ -598,10 +598,10 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } /* clear all entries first */ - for( i = 0; i < reax->num_atom_types; ++i ) - for( j = 0; j < reax->num_atom_types; ++j ) - for( k = 0; k < reax->num_atom_types; ++k ) - for( m = 0; m < reax->num_atom_types; ++m ) { + for (i = 0; i < reax->num_atom_types; ++i) + for (j = 0; j < reax->num_atom_types; ++j) + for (k = 0; k < reax->num_atom_types; ++k) + for (m = 0; m < reax->num_atom_types; ++m) { reax->fbp[i][j][k][m].cnt = 0; tor_flag[i][j][k][m] = 0; } @@ -611,7 +611,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, c = Tokenize( s, &tmp ); l = atoi( tmp[0] ); - for( i = 0; i < l; i++ ) { + for (i = 0; i < l; i++) { fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); @@ -653,8 +653,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } } else { /* This means the entry is of the form 0-X-Y-0 */ if (k < reax->num_atom_types && m < reax->num_atom_types) - for( p = 0; p < reax->num_atom_types; p++ ) - for( o = 0; o < reax->num_atom_types; o++ ) { + for (p = 0; p < reax->num_atom_types; p++) + for (o = 0; o < reax->num_atom_types; o++) { reax->fbp[p][k][m][o].cnt = 1; reax->fbp[o][m][k][p].cnt = 1; @@ -682,12 +682,12 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, c = Tokenize( s, &tmp ); l = atoi( tmp[0] ); - for( i = 0; i < reax->num_atom_types; ++i ) - for( j = 0; j < reax->num_atom_types; ++j ) - for( k = 0; k < reax->num_atom_types; ++k ) + for (i = 0; i < reax->num_atom_types; ++i) + for (j = 0; j < reax->num_atom_types; ++j) + for (k = 0; k < reax->num_atom_types; ++k) reax->hbp[i][j][k].r0_hb = -1.0; - for( i = 0; i < l; i++ ) { + for (i = 0; i < l; i++) { fgets( s, MAX_LINE, fp ); c = Tokenize( s, &tmp ); @@ -713,16 +713,16 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax, } /* deallocate helper storage */ - for( i = 0; i < MAX_TOKENS; i++ ) + for (i = 0; i < MAX_TOKENS; i++) free( tmp[i] ); free( tmp ); free( s ); /* deallocate tor_flag */ - for( i = 0; i < reax->num_atom_types; i++ ) { - for( j = 0; j < reax->num_atom_types; j++ ) { - for( k = 0; k < reax->num_atom_types; k++ ) { + for (i = 0; i < reax->num_atom_types; i++) { + for (j = 0; j < reax->num_atom_types; j++) { + for (k = 0; k < reax->num_atom_types; k++) { free( tor_flag[i][j][k] ); } free( tor_flag[i][j] ); diff --git a/src/USER-REAXC/reaxc_forces.cpp b/src/USER-REAXC/reaxc_forces.cpp index 3cc66b7530..cde80e9866 100644 --- a/src/USER-REAXC/reaxc_forces.cpp +++ b/src/USER-REAXC/reaxc_forces.cpp @@ -74,7 +74,7 @@ void Compute_Bonded_Forces( reax_system *system, control_params *control, int i; /* Implement all force calls as function pointers */ - for( i = 0; i < NUM_INTRS; i++ ) { + for (i = 0; i < NUM_INTRS; i++) { (Interaction_Functions[i])( system, control, data, workspace, lists, out_control ); } @@ -104,8 +104,8 @@ void Compute_Total_Force( reax_system *system, control_params *control, int i, pj; reax_list *bonds = (*lists) + BONDS; - for( i = 0; i < system->N; ++i ) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (i = 0; i < system->N; ++i) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) if (i < bonds->select.bond_list[pj].nbr) { if (control->virial == 0) Add_dBond_to_Forces( system, i, pj, workspace, lists ); @@ -127,7 +127,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l if (N > 0) { bonds = *lists + BONDS; - for( i = 0; i < N; ++i ) { + for (i = 0; i < N; ++i) { system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); if (i < N-1) @@ -148,7 +148,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l if (numH > 0) { hbonds = *lists + HBONDS; - for( i = 0; i < N; ++i ) { + for (i = 0; i < N; ++i) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { system->my_atoms[i].num_hbonds = @@ -176,7 +176,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l void Init_Forces_noQEq( reax_system *system, control_params *control, simulation_data *data, storage *workspace, - reax_list **lists, output_controls * /*out_control*/ ) { + reax_list **lists, output_controls * /*out_control*/) { int i, j, pj; int start_i, end_i; int type_i, type_j; @@ -194,9 +194,9 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, bonds = *lists + BONDS; hbonds = *lists + HBONDS; - for( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) workspace->bond_mark[i] = 0; - for( i = system->n; i < system->N; ++i ) { + for (i = system->n; i < system->N; ++i) { workspace->bond_mark[i] = 1000; // put ghost atoms to an infinite distance } @@ -205,7 +205,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, btop_i = 0; renbr = (data->step-data->prev_steps) % control->reneighbor == 0; - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { atom_i = &(system->my_atoms[i]); type_i = atom_i->type; if (type_i < 0) continue; @@ -232,7 +232,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, } /* update i-j distance - check if j is within cutoff */ - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); @@ -263,7 +263,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, if (local) { /* hydrogen bond lists */ if (control->hbond_cut > 0 && (ihb==1 || ihb==2) && - nbr_pj->d <= control->hbond_cut ) { + nbr_pj->d <= control->hbond_cut) { // fprintf( stderr, "%d %d\n", atom1, atom2 ); jhb = sbp_j->p_hbond; if (ihb == 1 && jhb == 2) { @@ -287,7 +287,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, if (//(workspace->bond_mark[i] < 3 || workspace->bond_mark[j] < 3) && nbr_pj->d <= control->bond_cut && BOp( workspace, bonds, control->bo_cut, - i , btop_i, nbr_pj, sbp_i, sbp_j, twbp ) ) { + i , btop_i, nbr_pj, sbp_i, sbp_j, twbp )) { num_bonds += 2; ++btop_i; @@ -343,7 +343,7 @@ void Estimate_Storages( reax_system *system, control_params *control, memset( bond_top, 0, sizeof(int) * system->total_cap ); *num_3body = 0; - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { atom_i = &(system->my_atoms[i]); type_i = atom_i->type; if (type_i < 0) continue; @@ -362,7 +362,7 @@ void Estimate_Storages( reax_system *system, control_params *control, ihb = -1; } - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); j = nbr_pj->nbr; atom_j = &(system->my_atoms[j]); @@ -380,11 +380,11 @@ void Estimate_Storages( reax_system *system, control_params *control, /* hydrogen bond lists */ if (control->hbond_cut > 0.1 && (ihb==1 || ihb==2) && - nbr_pj->d <= control->hbond_cut ) { + nbr_pj->d <= control->hbond_cut) { jhb = sbp_j->p_hbond; if (ihb == 1 && jhb == 2) ++hb_top[i]; - else if ( j < system->n && ihb == 2 && jhb == 1 ) + else if (j < system->n && ihb == 2 && jhb == 1) ++hb_top[j]; } } @@ -422,10 +422,10 @@ void Estimate_Storages( reax_system *system, control_params *control, } *Htop = (int)(MAX( *Htop * safezone, mincap * MIN_HENTRIES )); - for( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) hb_top[i] = (int)(MAX(hb_top[i] * saferzone, system->minhbonds)); - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { *num_3body += SQR(bond_top[i]); bond_top[i] = MAX( bond_top[i] * 2, MIN_BONDS ); } diff --git a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp index 680f069bab..ac94d7b62c 100644 --- a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp +++ b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp @@ -63,7 +63,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, hbonds = (*lists) + HBONDS; hbond_list = hbonds->select.hbond_list; - for( j = 0; j < system->n; ++j ) + for (j = 0; j < system->n; ++j) if (system->reax_param.sbp[system->my_atoms[j].type].p_hbond == 1) { type_j = system->my_atoms[j].type; start_j = Start_Index(j, bonds); @@ -73,7 +73,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, if (type_j < 0) continue; top = 0; - for( pi = start_j; pi < end_j; ++pi ) { + for (pi = start_j; pi < end_j; ++pi) { pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; @@ -85,7 +85,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, hblist[top++] = pi; } - for( pk = hb_start_j; pk < hb_end_j; ++pk ) { + for (pk = hb_start_j; pk < hb_end_j; ++pk) { /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; @@ -94,7 +94,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); - for( itr = 0; itr < top; ++itr ) { + for (itr = 0; itr < top; ++itr) { pi = hblist[itr]; pbond_ij = &( bonds->select.bond_list[pi] ); i = pbond_ij->nbr; diff --git a/src/USER-REAXC/reaxc_io_tools.cpp b/src/USER-REAXC/reaxc_io_tools.cpp index 6ac64a17bc..5864ab6a15 100644 --- a/src/USER-REAXC/reaxc_io_tools.cpp +++ b/src/USER-REAXC/reaxc_io_tools.cpp @@ -63,7 +63,7 @@ int Init_Output_Files( reax_system *system, control_params *control, /* init pressure file */ if ( control->ensemble == NPT || control->ensemble == iNPT || - control->ensemble == sNPT ) { + control->ensemble == sNPT) { sprintf( temp, "%s.prs", control->sim_name ); if ((out_control->prs = fopen( temp, "w" )) != nullptr) { fprintf(out_control->prs,"%8s%13s%13s%13s%13s%13s%13s%13s\n", @@ -119,7 +119,7 @@ void Output_Results( reax_system *system, control_params *control, /* output energies */ if ( system->my_rank == MASTER_NODE && out_control->energy_update_freq > 0 && - data->step % out_control->energy_update_freq == 0 ) { + data->step % out_control->energy_update_freq == 0) { if (control->virial && out_control->prs) { fprintf( out_control->prs, @@ -142,7 +142,7 @@ void Output_Results( reax_system *system, control_params *control, /* write current frame */ if ( out_control->write_steps > 0 && - (data->step-data->prev_steps) % out_control->write_steps == 0 ) { + (data->step-data->prev_steps) % out_control->write_steps == 0) { Append_Frame( system, control, data, lists, out_control, mpi_data ); } } diff --git a/src/USER-REAXC/reaxc_lookup.cpp b/src/USER-REAXC/reaxc_lookup.cpp index 980e6e0fb6..b45a6da265 100644 --- a/src/USER-REAXC/reaxc_lookup.cpp +++ b/src/USER-REAXC/reaxc_lookup.cpp @@ -64,26 +64,26 @@ void Natural_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const d /* build the linear system */ a[0] = a[1] = a[n-1] = 0; - for ( i = 2; i < (int)n-1; ++i ) + for (i = 2; i < (int)n-1; ++i) a[i] = h[i-1]; b[0] = b[n-1] = 0; - for ( i = 1; i < (int)n-1; ++i ) + for (i = 1; i < (int)n-1; ++i) b[i] = 2 * (h[i-1] + h[i]); c[0] = c[n-2] = c[n-1] = 0; - for ( i = 1; i < (int)n-2; ++i ) + for (i = 1; i < (int)n-2; ++i) c[i] = h[i]; d[0] = d[n-1] = 0; - for ( i = 1; i < (int)n-1; ++i ) + for (i = 1; i < (int)n-1; ++i) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); v[0] = 0; v[n-1] = 0; Tridiagonal_Solve( &(a[1]), &(b[1]), &(c[1]), &(d[1]), &(v[1]), n-2 ); - for ( i = 1; i < (int)n; ++i ) { + for (i = 1; i < (int)n; ++i) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -114,25 +114,25 @@ void Complete_Cubic_Spline( LAMMPS_NS::Error* error_ptr, const double *h, const /* build the linear system */ a[0] = 0; - for ( i = 1; i < (int)n; ++i ) + for (i = 1; i < (int)n; ++i) a[i] = h[i-1]; b[0] = 2*h[0]; - for ( i = 1; i < (int)n; ++i ) + for (i = 1; i < (int)n; ++i) b[i] = 2 * (h[i-1] + h[i]); c[n-1] = 0; - for ( i = 0; i < (int)n-1; ++i ) + for (i = 0; i < (int)n-1; ++i) c[i] = h[i]; d[0] = 6 * (f[1]-f[0])/h[0] - 6 * v0; d[n-1] = 6 * vlast - 6 * (f[n-1]-f[n-2]/h[n-2]); - for ( i = 1; i < (int)n-1; ++i ) + for (i = 1; i < (int)n-1; ++i) d[i] = 6 * ((f[i+1]-f[i])/h[i] - (f[i]-f[i-1])/h[i-1]); Tridiagonal_Solve( &(a[0]), &(b[0]), &(c[0]), &(d[0]), &(v[0]), n ); - for ( i = 1; i < (int)n; ++i ) { + for (i = 1; i < (int)n; ++i) { coef[i-1].d = (v[i] - v[i-1]) / (6*h[i-1]); coef[i-1].c = v[i]/2; coef[i-1].b = (f[i]-f[i-1])/h[i-1] + h[i-1]*(2*v[i] + v[i-1])/6; @@ -181,21 +181,21 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, LR = (LR_lookup_table**) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR"); - for ( i = 0; i < num_atom_types; ++i ) + for (i = 0; i < num_atom_types; ++i) LR[i] = (LR_lookup_table*) scalloc(system->error_ptr, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]"); - for ( i = 0; i < REAX_MAX_ATOM_TYPES; ++i ) + for (i = 0; i < REAX_MAX_ATOM_TYPES; ++i) existing_types[i] = 0; - for ( i = 0; i < system->n; ++i ) + for (i = 0; i < system->n; ++i) existing_types[ system->my_atoms[i].type ] = 1; MPI_Allreduce( existing_types, aggregated, REAX_MAX_ATOM_TYPES, MPI_INT, MPI_SUM, mpi_data->world ); - for ( i = 0; i < num_atom_types; ++i ) { + for (i = 0; i < num_atom_types; ++i) { if (aggregated[i]) { - for ( j = i; j < num_atom_types; ++j ) { + for (j = i; j < num_atom_types; ++j) { if (aggregated[j]) { LR[i][j].xmin = 0; LR[i][j].xmax = control->nonb_cut; @@ -216,7 +216,7 @@ int Init_Lookup_Tables( reax_system *system, control_params *control, smalloc(system->error_ptr, LR[i][j].n*sizeof(cubic_spline_coef), "lookup:LR[i,j].CEclmb"); - for ( r = 1; r <= control->tabulate; ++r ) { + for (r = 1; r <= control->tabulate; ++r) { LR_vdW_Coulomb( system, workspace, control, i, j, r * dr, &(LR[i][j].y[r]) ); h[r] = LR[i][j].dx; fh[r] = LR[i][j].y[r].H; @@ -277,8 +277,8 @@ void Deallocate_Lookup_Tables( reax_system *system ) ntypes = system->reax_param.num_atom_types; - for ( i = 0; i < ntypes; ++i ) { - for ( j = i; j < ntypes; ++j ) + for (i = 0; i < ntypes; ++i) { + for (j = i; j < ntypes; ++j) if (LR[i][j].n) { sfree(system->error_ptr, LR[i][j].y, "LR[i,j].y" ); sfree(system->error_ptr, LR[i][j].H, "LR[i,j].H" ); diff --git a/src/USER-REAXC/reaxc_multi_body.cpp b/src/USER-REAXC/reaxc_multi_body.cpp index 00c8fbab2d..ab66e3352a 100644 --- a/src/USER-REAXC/reaxc_multi_body.cpp +++ b/src/USER-REAXC/reaxc_multi_body.cpp @@ -63,7 +63,7 @@ void Atom_Energy( reax_system *system, control_params *control, p_ovun7 = system->reax_param.gp.l[8]; p_ovun8 = system->reax_param.gp.l[9]; - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { /* set the parameter pointer */ type_i = system->my_atoms[i].type; if (type_i < 0) continue; @@ -76,7 +76,7 @@ void Atom_Energy( reax_system *system, control_params *control, numbonds = 0; e_lp = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; /* calculate the energy */ @@ -97,7 +97,7 @@ void Atom_Energy( reax_system *system, control_params *control, /* correction for C2 */ if (p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C")) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -127,7 +127,7 @@ void Atom_Energy( reax_system *system, control_params *control, } - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; sbp_i = &(system->reax_param.sbp[ type_i ]); @@ -139,7 +139,7 @@ void Atom_Energy( reax_system *system, control_params *control, p_ovun2 = sbp_i->p_ovun2; sum_ovun1 = sum_ovun2 = 0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; if (type_j < 0) continue; @@ -186,7 +186,7 @@ void Atom_Energy( reax_system *system, control_params *control, numbonds = 0; e_un = 0.0; - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) numbonds ++; if (numbonds > 0 || control->enobondsflag) @@ -214,7 +214,7 @@ void Atom_Energy( reax_system *system, control_params *control, if (numbonds > 0 || control->enobondsflag) workspace->CdDelta[i] += CEunder3; // UnCoor - 1st term - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { pbond = &(bonds->select.bond_list[pj]); j = pbond->nbr; bo_ij = &(pbond->bo_data); diff --git a/src/USER-REAXC/reaxc_nonbonded.cpp b/src/USER-REAXC/reaxc_nonbonded.cpp index 7c3350fd40..97790aa997 100644 --- a/src/USER-REAXC/reaxc_nonbonded.cpp +++ b/src/USER-REAXC/reaxc_nonbonded.cpp @@ -62,13 +62,13 @@ void vdW_Coulomb_Energy( reax_system *system, control_params *control, e_vdW = 0; e_lg = de_lg = 0.0; - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { if (system->my_atoms[i].type < 0) continue; start_i = Start_Index(i, far_nbrs); end_i = End_Index(i, far_nbrs); orig_i = system->my_atoms[i].orig_id; - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; if (system->my_atoms[j].type < 0) continue; @@ -228,14 +228,14 @@ void Tabulated_vdW_Coulomb_Energy( reax_system *system,control_params *control, e_ele = e_vdW = 0; - for( i = 0; i < natoms; ++i ) { + for (i = 0; i < natoms; ++i) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; start_i = Start_Index(i,far_nbrs); end_i = End_Index(i,far_nbrs); orig_i = system->my_atoms[i].orig_id; - for( pj = start_i; pj < end_i; ++pj ) { + for (pj = start_i; pj < end_i; ++pj) { nbr_pj = &(far_nbrs->select.far_nbr_list[pj]); j = nbr_pj->nbr; type_j = system->my_atoms[j].type; @@ -322,7 +322,7 @@ void Compute_Polarization_Energy( reax_system *system, simulation_data *data ) double q, en_tmp; data->my_en.e_pol = 0.0; - for( i = 0; i < system->n; i++ ) { + for (i = 0; i < system->n; i++) { type_i = system->my_atoms[i].type; if (type_i < 0) continue; q = system->my_atoms[i].q; diff --git a/src/USER-REAXC/reaxc_reset_tools.cpp b/src/USER-REAXC/reaxc_reset_tools.cpp index e400f38970..5caaf860e7 100644 --- a/src/USER-REAXC/reaxc_reset_tools.cpp +++ b/src/USER-REAXC/reaxc_reset_tools.cpp @@ -41,7 +41,7 @@ void Reset_Atoms( reax_system* system, control_params *control ) system->numH = 0; if (control->hbond_cut > 0) - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { atom = &(system->my_atoms[i]); if (atom->type < 0) continue; if (system->reax_param.sbp[ atom->type ].p_hbond == 1) @@ -135,7 +135,7 @@ void Reset_Neighbor_Lists( reax_system *system, control_params *control, total_bonds = 0; /* reset start-end indexes */ - for( i = 0; i < system->N; ++i ) { + for (i = 0; i < system->N; ++i) { Set_Start_Index( i, total_bonds, bonds ); Set_End_Index( i, total_bonds, bonds ); total_bonds += system->my_atoms[i].num_bonds; @@ -158,7 +158,7 @@ void Reset_Neighbor_Lists( reax_system *system, control_params *control, total_hbonds = 0; /* reset start-end indexes */ - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { Hindex = system->my_atoms[i].Hindex; if (Hindex > -1) { Set_Start_Index( Hindex, total_hbonds, hbonds ); diff --git a/src/USER-REAXC/reaxc_tool_box.cpp b/src/USER-REAXC/reaxc_tool_box.cpp index b27a1635fe..b559a362f4 100644 --- a/src/USER-REAXC/reaxc_tool_box.cpp +++ b/src/USER-REAXC/reaxc_tool_box.cpp @@ -62,7 +62,7 @@ int Tokenize( char* s, char*** tok ) strncpy( test, s, MAX_LINE-1); - for( word = strtok(test, sep); word; word = strtok(nullptr, sep) ) { + for (word = strtok(test, sep); word; word = strtok(nullptr, sep)) { strncpy( (*tok)[count], word, MAX_LINE ); count++; } diff --git a/src/USER-REAXC/reaxc_torsion_angles.cpp b/src/USER-REAXC/reaxc_torsion_angles.cpp index c49b095b20..305e83707d 100644 --- a/src/USER-REAXC/reaxc_torsion_angles.cpp +++ b/src/USER-REAXC/reaxc_torsion_angles.cpp @@ -85,9 +85,9 @@ double Calculate_Omega( rvec dvec_ij, double r_ij, if (arg < -1.0) arg = -1.0; if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE; - else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) sin_ijk = -MIN_SINE; + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) sin_ijk = -MIN_SINE; if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE; - else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) sin_jkl = -MIN_SINE; + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) sin_jkl = -MIN_SINE; // dcos_omega_di rvec_ScaledSum( dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li ); @@ -169,13 +169,13 @@ void Torsion_Angles( reax_system *system, control_params *control, natoms = system->n; - for( j = 0; j < natoms; ++j ) { + for (j = 0; j < natoms; ++j) { type_j = system->my_atoms[j].type; Delta_j = workspace->Delta_boc[j]; start_j = Start_Index(j, bonds); end_j = End_Index(j, bonds); - for( pk = start_j; pk < end_j; ++pk ) { + for (pk = start_j; pk < end_j; ++pk) { pbond_jk = &( bonds->select.bond_list[pk] ); k = pbond_jk->nbr; bo_jk = &( pbond_jk->bo_data ); @@ -212,7 +212,7 @@ void Torsion_Angles( reax_system *system, control_params *control, exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; - for( pi = start_pk; pi < end_pk; ++pi ) { + for (pi = start_pk; pi < end_pk; ++pi) { p_ijk = &( thb_intrs->select.three_body_list[pi] ); pij = p_ijk->pthb; // pij is pointer to i on j's bond_list pbond_ij = &( bonds->select.bond_list[pij] ); @@ -230,14 +230,14 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_ijk_i = 1. / tan( theta_ijk ); if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) tan_ijk_i = cos_ijk / MIN_SINE; - else if ( sin_ijk <= 0 && sin_ijk >= -MIN_SINE ) + else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) tan_ijk_i = cos_ijk / -MIN_SINE; else tan_ijk_i = cos_ijk / sin_ijk; exp_tor2_ij = exp( -p_tor2 * BOA_ij ); exp_cot2_ij = exp( -p_cot2 * SQR(BOA_ij -1.5) ); - for( pl = start_pj; pl < end_pj; ++pl ) { + for (pl = start_pj; pl < end_pj; ++pl) { p_jkl = &( thb_intrs->select.three_body_list[pl] ); l = p_jkl->thb; plk = p_jkl->pthb; //pointer to l on k's bond_list! @@ -251,7 +251,7 @@ void Torsion_Angles( reax_system *system, control_params *control, if ( i != l && fbh->cnt && bo_kl->BO > control->thb_cut/*0*/ && - bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/ ) { + bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { ++num_frb_intrs; r_kl = pbond_kl->d; BOA_kl = bo_kl->BO - control->thb_cut; @@ -262,7 +262,7 @@ void Torsion_Angles( reax_system *system, control_params *control, //tan_jkl_i = 1. / tan( theta_jkl ); if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) tan_jkl_i = cos_jkl / MIN_SINE; - else if ( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) + else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; diff --git a/src/USER-REAXC/reaxc_traj.cpp b/src/USER-REAXC/reaxc_traj.cpp index 2d56722aba..66a1c70b0e 100644 --- a/src/USER-REAXC/reaxc_traj.cpp +++ b/src/USER-REAXC/reaxc_traj.cpp @@ -285,7 +285,7 @@ int Write_Init_Desc( reax_system *system, control_params * /*control*/, out_control->line[0] = 0; out_control->buffer[0] = 0; - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { p_atom = &( system->my_atoms[i] ); sprintf( out_control->line, INIT_DESC, p_atom->orig_id, p_atom->type, p_atom->name, @@ -299,7 +299,7 @@ int Write_Init_Desc( reax_system *system, control_params * /*control*/, np * INIT_DESCS + me, mpi_data->world ); } else { buffer_len = system->n * INIT_DESC_LEN; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*INIT_DESCS+i, mpi_data->world, &status ); @@ -508,10 +508,10 @@ int Write_Atoms( reax_system *system, control_params * /*control*/, /* fill in buffer */ out_control->line[0] = 0; out_control->buffer[0] = 0; - for( i = 0; i < system->n; ++i ) { + for (i = 0; i < system->n; ++i) { p_atom = &( system->my_atoms[i] ); - switch( out_control->atom_info ) { + switch (out_control->atom_info) { case OPT_ATOM_BASIC: sprintf( out_control->line, ATOM_BASIC, p_atom->orig_id, p_atom->x[0], p_atom->x[1], p_atom->x[2], @@ -545,7 +545,7 @@ int Write_Atoms( reax_system *system, control_params * /*control*/, np*ATOM_LINES+me, mpi_data->world ); } else { buffer_len = system->n * line_len; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*ATOM_LINES+i, mpi_data->world, &status ); @@ -575,8 +575,8 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, /* count the number of bonds I will write */ my_bonds = 0; - for( i=0; i < system->n; ++i ) - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (i=0; i < system->n; ++i) + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { j = bonds->select.bond_list[pj].nbr; if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && bonds->select.bond_list[pj].bo_data.BO >= control->bg_cut ) @@ -600,14 +600,14 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, out_control->buffer[0] = 0; my_bonds = 0; - for( i=0; i < system->n; ++i ) { - for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { + for (i=0; i < system->n; ++i) { + for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) { bo_ij = &( bonds->select.bond_list[pj] ); j = bo_ij->nbr; if ( system->my_atoms[i].orig_id <= system->my_atoms[j].orig_id && - bo_ij->bo_data.BO >= control->bg_cut ) { - switch( out_control->bond_info ) { + bo_ij->bo_data.BO >= control->bg_cut) { + switch (out_control->bond_info) { case OPT_BOND_BASIC: sprintf( out_control->line, BOND_BASIC, system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, @@ -634,7 +634,7 @@ int Write_Bonds(reax_system *system, control_params *control, reax_list *bonds, np*BOND_LINES+me, mpi_data->world ); } else { buffer_len = my_bonds * line_len; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*BOND_LINES+i, mpi_data->world, &status ); @@ -666,14 +666,14 @@ int Write_Angles( reax_system *system, control_params *control, /* count the number of valence angles I will output */ my_angles = 0; - for( j = 0; j < system->n; ++j ) - for( pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi ) { + for (j = 0; j < system->n; ++j) + for (pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi) { bo_ij = &(bonds->select.bond_list[pi]); i = bo_ij->nbr; if (bo_ij->bo_data.BO >= control->bg_cut) // physical j&i bond - for( pk = Start_Index( pi, thb_intrs ); - pk < End_Index( pi, thb_intrs ); ++pk ) { + for (pk = Start_Index( pi, thb_intrs); + pk < End_Index( pi, thb_intrs ); ++pk) { angle_ijk = &(thb_intrs->select.three_body_list[pk]); k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); @@ -699,20 +699,20 @@ int Write_Angles( reax_system *system, control_params *control, my_angles = 0; out_control->line[0] = 0; out_control->buffer[0] = 0; - for( j = 0; j < system->n; ++j ) - for( pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi ) { + for (j = 0; j < system->n; ++j) + for (pi = Start_Index(j, bonds); pi < End_Index(j, bonds); ++pi) { bo_ij = &(bonds->select.bond_list[pi]); i = bo_ij->nbr; if (bo_ij->bo_data.BO >= control->bg_cut) // physical j&i bond - for( pk = Start_Index( pi, thb_intrs ); - pk < End_Index( pi, thb_intrs ); ++pk ) { + for (pk = Start_Index( pi, thb_intrs); + pk < End_Index( pi, thb_intrs ); ++pk) { angle_ijk = &(thb_intrs->select.three_body_list[pk]); k = angle_ijk->thb; bo_jk = &(bonds->select.bond_list[ angle_ijk->pthb ]); if ( system->my_atoms[i].orig_id < system->my_atoms[k].orig_id && - bo_jk->bo_data.BO >= control->bg_cut ) { // physical j&k bond + bo_jk->bo_data.BO >= control->bg_cut) { // physical j&k bond sprintf( out_control->line, ANGLE_BASIC, system->my_atoms[i].orig_id, system->my_atoms[j].orig_id, system->my_atoms[k].orig_id, RAD2DEG( angle_ijk->theta ) ); @@ -729,7 +729,7 @@ int Write_Angles( reax_system *system, control_params *control, np*ANGLE_LINES+me, mpi_data->world ); } else { buffer_len = my_angles * line_len; - for( i = 0; i < np; ++i ) + for (i = 0; i < np; ++i) if (i != MASTER_NODE) { MPI_Recv( out_control->buffer + buffer_len, buffer_req - buffer_len, MPI_CHAR, i, np*ANGLE_LINES+i, mpi_data->world, &status ); diff --git a/src/USER-REAXC/reaxc_valence_angles.cpp b/src/USER-REAXC/reaxc_valence_angles.cpp index b545fa93a9..9aec0a1f05 100644 --- a/src/USER-REAXC/reaxc_valence_angles.cpp +++ b/src/USER-REAXC/reaxc_valence_angles.cpp @@ -37,7 +37,7 @@ static double Dot( double* v1, double* v2, int k ) { double ret = 0.0; - for( int i=0; i < k; ++i ) + for (int i=0; i < k; ++i) ret += v1[i] * v2[i]; return ret; @@ -66,7 +66,7 @@ void Calculate_dCos_Theta( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, double dot_dvecs = Dot( dvec_ji, dvec_jk, 3 ); double Cdot_inv3 = dot_dvecs * inv_dists3; - for( t = 0; t < 3; ++t ) { + for (t = 0; t < 3; ++t) { (*dcos_theta_di)[t] = dvec_jk[t] * inv_dists - Cdot_inv3 * sqr_d_jk * dvec_ji[t]; (*dcos_theta_dj)[t] = -(dvec_jk[t] + dvec_ji[t]) * inv_dists + @@ -124,7 +124,7 @@ void Valence_Angles( reax_system *system, control_params *control, num_thb_intrs = 0; - for( j = 0; j < system->N; ++j ) { // Ray: the first one with system->N + for (j = 0; j < system->N; ++j) { // Ray: the first one with system->N type_j = system->my_atoms[j].type; if (type_j < 0) continue; start_j = Start_Index(j, bonds); @@ -134,7 +134,7 @@ void Valence_Angles( reax_system *system, control_params *control, p_val5 = system->reax_param.sbp[ type_j ].p_val5; SBOp = 0, prod_SBO = 1; - for( t = start_j; t < end_j; ++t ) { + for (t = start_j; t < end_j; ++t) { bo_jt = &(bonds->select.bond_list[t].bo_data); SBOp += (bo_jt->BO_pi + bo_jt->BO_pi2); temp = SQR( bo_jt->BO ); @@ -169,7 +169,7 @@ void Valence_Angles( reax_system *system, control_params *control, expval6 = exp( p_val6 * workspace->Delta_boc[j] ); - for( pi = start_j; pi < end_j; ++pi ) { + for (pi = start_j; pi < end_j; ++pi) { Set_Start_Index( pi, num_thb_intrs, thb_intrs ); pbond_ij = &(bonds->select.bond_list[pi]); bo_ij = &(pbond_ij->bo_data); @@ -177,15 +177,15 @@ void Valence_Angles( reax_system *system, control_params *control, if ( BOA_ij/*bo_ij->BO*/ > 0.0 && - ( j < system->n || pbond_ij->nbr < system->n ) ) { + ( j < system->n || pbond_ij->nbr < system->n )) { i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - for( pk = start_j; pk < pi; ++pk ) { + for (pk = start_j; pk < pi; ++pk) { start_pk = Start_Index( pk, thb_intrs ); end_pk = End_Index( pk, thb_intrs ); - for( t = start_pk; t < end_pk; ++t ) + for (t = start_pk; t < end_pk; ++t) if (thb_intrs->select.three_body_list[t].thb == i) { p_ijk = &(thb_intrs->select.three_body_list[num_thb_intrs] ); p_kji = &(thb_intrs->select.three_body_list[t]); @@ -202,7 +202,7 @@ void Valence_Angles( reax_system *system, control_params *control, } } - for( pk = pi+1; pk < end_j; ++pk ) { + for (pk = pi+1; pk < end_j; ++pk) { pbond_jk = &(bonds->select.bond_list[pk]); bo_jk = &(pbond_jk->bo_data); BOA_jk = bo_jk->BO - control->thb_cut; @@ -232,10 +232,10 @@ void Valence_Angles( reax_system *system, control_params *control, if ((j < system->n) && (BOA_jk > 0.0) && (bo_ij->BO > control->thb_cut) && (bo_jk->BO > control->thb_cut) && - (bo_ij->BO * bo_jk->BO > control->thb_cutsq) ) { + (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { thbh = &( system->reax_param.thbp[ type_i ][ type_j ][ type_k ] ); - for( cnt = 0; cnt < thbh->cnt; ++cnt ) { + for (cnt = 0; cnt < thbh->cnt; ++cnt) { if (fabs(thbh->prm[cnt].p_val1) > 0.001) { thbp = &( thbh->prm[cnt] ); @@ -345,7 +345,7 @@ void Valence_Angles( reax_system *system, control_params *control, workspace->CdDelta[i] += CEcoa4; workspace->CdDelta[k] += CEcoa5; - for( t = start_j; t < end_j; ++t ) { + for (t = start_j; t < end_j; ++t) { pbond_jt = &( bonds->select.bond_list[t] ); bo_jt = &(pbond_jt->bo_data); temp_bo_jt = bo_jt->BO; diff --git a/src/USER-REAXC/reaxc_vector.cpp b/src/USER-REAXC/reaxc_vector.cpp index edee65d637..e0e3a14782 100644 --- a/src/USER-REAXC/reaxc_vector.cpp +++ b/src/USER-REAXC/reaxc_vector.cpp @@ -107,15 +107,15 @@ void rtensor_MatVec( rvec ret, rtensor m, rvec v ) if (ret == v) { - for( i = 0; i < 3; ++i ) + for (i = 0; i < 3; ++i) temp[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; - for( i = 0; i < 3; ++i ) + for (i = 0; i < 3; ++i) ret[i] = temp[i]; } else { - for( i = 0; i < 3; ++i ) + for (i = 0; i < 3; ++i) ret[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; } } diff --git a/src/USER-SMD/compute_smd_triangle_vertices.cpp b/src/USER-SMD/compute_smd_triangle_vertices.cpp index f621029a47..c487e60872 100644 --- a/src/USER-SMD/compute_smd_triangle_vertices.cpp +++ b/src/USER-SMD/compute_smd_triangle_vertices.cpp @@ -95,7 +95,7 @@ void ComputeSMDTriangleVertices::compute_peratom() { int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && (mol[i] >= 65535) ) { + if ((mask[i] & groupbit) && (mol[i] >= 65535)) { outputVector[i][0] = smd_data_9[i][0]; outputVector[i][1] = smd_data_9[i][1]; outputVector[i][2] = smd_data_9[i][2]; diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index 5f416955cf..6989be8376 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -153,9 +153,9 @@ PairSMTBQ::~PairSMTBQ() if (elements) { for ( i = 0; i < nelements; i++) delete [] elements[i]; - for( i = 0; i < atom->ntypes ; i++ ) free( params[i].nom ); - for( i = 1; i <= maxintparam ; i++ ) free( intparams[i].typepot ); - for( i = 1; i <= maxintparam ; i++ ) free( intparams[i].mode ); + for (i = 0; i < atom->ntypes ; i++ ) free( params[i].nom); + for (i = 1; i <= maxintparam ; i++ ) free( intparams[i].typepot); + for (i = 1; i <= maxintparam ; i++ ) free( intparams[i].mode); } free(QEqMode); @@ -400,7 +400,7 @@ void PairSMTBQ::read_file(char *file) // open file on all processors FILE *fp; fp = utils::open_potential(file,lmp,nullptr); - if ( fp == nullptr ) { + if (fp == nullptr) { char str[128]; snprintf(str,128,"Cannot open SMTBQ potential file %s",file); error->one(FLERR,str); @@ -572,7 +572,7 @@ void PairSMTBQ::read_file(char *file) // if (test == 0) printf (" on a %s -> %d = %s\n",words[2],j,params[j].nom); - if ( test == 1 ) { + if (test == 1) { if (verbose) printf ("========== fin des interaction ==========\n"); break ; } @@ -766,7 +766,7 @@ void PairSMTBQ::read_file(char *file) } else if (strcmp(QEqMode,"QEqAll") != 0 && strcmp(QEqMode,"QEqAllParallel") != 0 && - strcmp(QEqMode,"Surface") != 0 ) { + strcmp(QEqMode,"Surface") != 0) { error->all(FLERR,"The QEq Mode is not known. QEq mode should be :\n" " Possible QEq modes | parameters\n" " QEqAll | no parameters\n" @@ -809,7 +809,7 @@ void PairSMTBQ::read_file(char *file) /* ======================================================== */ /* deallocate helper storage */ - for( i = 0; i < MAXTOKENS ; i++ ) free( words[i] ); + for (i = 0; i < MAXTOKENS ; i++ ) free( words[i]); free( words ); free( ptr ); fclose(fp); @@ -1055,7 +1055,7 @@ void PairSMTBQ::compute(int eflag, int vflag) // ---------------------------------------------- if ( strcmp(intparams[m].typepot,"buck") == 0 || - strcmp(intparams[m].typepot,"buckPlusAttr") ==0 ) { + strcmp(intparams[m].typepot,"buckPlusAttr") ==0) { // ---------------------------------------------- evdwl = 0.0; fpair =0.0; @@ -1079,7 +1079,7 @@ void PairSMTBQ::compute(int eflag, int vflag) } // ----------------------------------- Rep O-O - if (strcmp(intparams[m].typepot,"buckPlusAttr") == 0 ) { + if (strcmp(intparams[m].typepot,"buckPlusAttr") == 0) { // ---------------------------------------------- evdwl = 0.0; fpair =0.0; @@ -2577,7 +2577,7 @@ void PairSMTBQ::Charge() // Init_charge(nQEq,nQEqa,nQEqc); // --------------------------------- - if (update->ntimestep == 0 && (strcmp(QInitMode,"true") == 0) ) { + if (update->ntimestep == 0 && (strcmp(QInitMode,"true") == 0)) { //Carefull here it won't be fine if there are more than 2 species!!! QOxInit=max(QOxInit, -0.98* params[1].qform *nQEqcall[gp]/nQEqaall[gp]) ; @@ -2622,7 +2622,7 @@ void PairSMTBQ::Charge() // -------------------------------------------- - for (iloop = 0; iloop < loopmax; iloop ++ ) { + for (iloop = 0; iloop < loopmax; iloop ++) { // -------------------------------------------- qtot = qtotll = Transf[3*cluster] = 0.0 ; @@ -3556,7 +3556,7 @@ int PairSMTBQ::Tokenize( char* s, char*** tok ) strncpy( test, s, MAXLINE-1 ); - for( mot = strtok(test, sep); mot; mot = strtok(nullptr, sep) ) { + for (mot = strtok(test, sep); mot; mot = strtok(nullptr, sep)) { strncpy( (*tok)[count], mot, MAXLINE ); count++; } diff --git a/src/USER-TALLY/compute_force_tally.cpp b/src/USER-TALLY/compute_force_tally.cpp index e9b507ff11..21c518f3d7 100644 --- a/src/USER-TALLY/compute_force_tally.cpp +++ b/src/USER-TALLY/compute_force_tally.cpp @@ -122,7 +122,7 @@ void ComputeForceTally::pair_tally_callback(int i, int j, int nlocal, int newton const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { if (newton || i < nlocal) { if (mask[i] & groupbit) { diff --git a/src/USER-TALLY/compute_heat_flux_tally.cpp b/src/USER-TALLY/compute_heat_flux_tally.cpp index 18edae46ea..002d0e3238 100644 --- a/src/USER-TALLY/compute_heat_flux_tally.cpp +++ b/src/USER-TALLY/compute_heat_flux_tally.cpp @@ -131,7 +131,7 @@ void ComputeHeatFluxTally::pair_tally_callback(int i, int j, int nlocal, int new const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { const double epairhalf = 0.5 * (evdwl + ecoul); fpair *= 0.5; diff --git a/src/USER-TALLY/compute_pe_mol_tally.cpp b/src/USER-TALLY/compute_pe_mol_tally.cpp index 7cc0f95d80..97c1a7ffbe 100644 --- a/src/USER-TALLY/compute_pe_mol_tally.cpp +++ b/src/USER-TALLY/compute_pe_mol_tally.cpp @@ -100,7 +100,7 @@ void ComputePEMolTally::pair_tally_callback(int i, int j, int nlocal, int newton const tagint * const molid = atom->molecule; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { evdwl *= 0.5; ecoul *= 0.5; if (newton || i < nlocal) { diff --git a/src/USER-TALLY/compute_pe_tally.cpp b/src/USER-TALLY/compute_pe_tally.cpp index 3d589aed70..451c785b13 100644 --- a/src/USER-TALLY/compute_pe_tally.cpp +++ b/src/USER-TALLY/compute_pe_tally.cpp @@ -119,7 +119,7 @@ void ComputePETally::pair_tally_callback(int i, int j, int nlocal, int newton, const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { evdwl *= 0.5; ecoul *= 0.5; if (newton || i < nlocal) { diff --git a/src/USER-TALLY/compute_stress_tally.cpp b/src/USER-TALLY/compute_stress_tally.cpp index c2c474fb1c..e32a134ec3 100644 --- a/src/USER-TALLY/compute_stress_tally.cpp +++ b/src/USER-TALLY/compute_stress_tally.cpp @@ -124,7 +124,7 @@ void ComputeStressTally::pair_tally_callback(int i, int j, int nlocal, int newto const int * const mask = atom->mask; if ( ((mask[i] & groupbit) && (mask[j] & groupbit2)) - || ((mask[i] & groupbit2) && (mask[j] & groupbit)) ) { + || ((mask[i] & groupbit2) && (mask[j] & groupbit))) { fpair *= 0.5; const double v0 = dx*dx*fpair; diff --git a/src/USER-VTK/dump_vtk.cpp b/src/USER-VTK/dump_vtk.cpp index a2bf1fb4bf..518015d688 100644 --- a/src/USER-VTK/dump_vtk.cpp +++ b/src/USER-VTK/dump_vtk.cpp @@ -1910,7 +1910,7 @@ void DumpVTK::identify_vectors() continue; // assume components are grouped together and in correct order - if (name.count(it->first + 1) && name.count(it->first + 2) ) { // more attributes? + if (name.count(it->first + 1) && name.count(it->first + 2)) { // more attributes? if (it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? it->second.compare(0,it->second.length()-3,name[it->first + 2],0,it->second.length()-3) == 0 ) { diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index 50ebe8b7cf..2c3dac06f8 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -68,7 +68,7 @@ ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) : faces = nullptr; int iarg = 3; - while ( iarg 0 ) { + if (maxedge > 0) { vector_flag = 1; size_vector = maxedge+1; memory->create(edge,maxedge+1,"voronoi/atom:edge"); @@ -269,7 +269,7 @@ void ComputeVoronoi::buildCells() // cutghost is in lamda coordinates for triclinic boxes, use subxx_lamda double *h = domain->h; - for( i=0; i<3; ++i ) { + for (i=0; i<3; ++i) { sublo_bound[i] = sublo_lamda[i]-cut[i]-e; subhi_bound[i] = subhi_lamda[i]+cut[i]+e; if (domain->periodicity[i]==0) { @@ -290,7 +290,7 @@ void ComputeVoronoi::buildCells() } else { // orthogonal box - for( i=0; i<3; ++i ) { + for (i=0; i<3; ++i) { sublo_bound[i] = sublo[i]-cut[i]-e; subhi_bound[i] = subhi[i]+cut[i]+e; if (domain->periodicity[i]==0) { @@ -307,15 +307,15 @@ void ComputeVoronoi::buildCells() // n = # of voro++ spatial hash cells (with approximately cubic cells) int nall = nlocal + atom->nghost; double n[3], V; - for( i=0; i<3; ++i ) n[i] = subhi_bound[i] - sublo_bound[i]; + for (i=0; i<3; ++i) n[i] = subhi_bound[i] - sublo_bound[i]; V = n[0]*n[1]*n[2]; - for( i=0; i<3; ++i ) { + for (i=0; i<3; ++i) { n[i] = round( n[i]*pow( double(nall)/(V*8.0), 0.333333 ) ); n[i] = n[i]==0 ? 1 : n[i]; } // clear edge statistics - if ( maxedge > 0 ) + if (maxedge > 0) for (i = 0; i <= maxedge; ++i) edge[i]=0; // initialize voro++ container @@ -543,10 +543,10 @@ void ComputeVoronoi::processCell(voronoicell_neighbor &c, int i) c.vertices(vcell); c.face_vertices(vlist); // for each face: vertex count followed list of vertex indices (n_1,v1_1,v2_1,v3_1,..,vn_1,n_2,v2_1,...) double dx, dy, dz, r2, t2 = ethresh*ethresh; - for( j=0; j < (int)vlist.size(); j+=vlist[j]+1 ) { + for (j=0; j < (int)vlist.size(); j+=vlist[j]+1) { int a, b, nedge = 0; // vlist[j] contains number of vertex indices for the current face - for( k=0; k < vlist[j]; ++k ) { + for (k=0; k < vlist[j]; ++k) { a = vlist[j+1+k]; // first vertex in edge b = vlist[j+1+(k+1)%vlist[j]]; // second vertex in edge (possible wrap around to first vertex in list) dx = vcell[a*3] - vcell[b*3]; @@ -625,7 +625,7 @@ void ComputeVoronoi::compute_vector() invoked_vector = update->ntimestep; if (invoked_peratom < invoked_vector) compute_peratom(); - for( int i=0; i= 2 && j <= 4) { unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; offset += sprintf(&sbuf[offset],vformat[j],unwrap_coord); - } else if (j >= 5 ) { + } else if (j >= 5) { if (vtype[j] == Dump::INT) offset += sprintf(&sbuf[offset],vformat[j],static_cast (mybuf[m])); @@ -279,7 +279,7 @@ void DumpCFG::write_lines(int n, double *mybuf) } else if (j >= 2 && j <= 4) { unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; fprintf(fp,vformat[j],unwrap_coord); - } else if (j >= 5 ) { + } else if (j >= 5) { if (vtype[j] == Dump::INT) fprintf(fp,vformat[j],static_cast (mybuf[m])); else if (vtype[j] == Dump::DOUBLE) diff --git a/src/finish.cpp b/src/finish.cpp index c3d921f3c4..810155f1b0 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -134,7 +134,7 @@ void Finish::end(int flag) (strcmp(update->unit_style,"micro") == 0) || (strcmp(update->unit_style,"nano") == 0) || (strcmp(update->unit_style,"electron") == 0) || - (strcmp(update->unit_style,"real") == 0)) ) { + (strcmp(update->unit_style,"real") == 0))) { double one_fs = force->femtosecond; double t_step = ((double) time_loop) / ((double) update->nsteps); double step_t = 1.0/t_step; diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 16e2ade2af..657323802d 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -70,7 +70,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) if (iarg+3 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 3; - } else if (strcmp(arg[iarg],"bond") == 0 ) { + } else if (strcmp(arg[iarg],"bond") == 0) { if (iarg+5 > narg) error->all(FLERR,"Illegal fix adapt command"); nadapt++; iarg += 5; @@ -110,7 +110,7 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) nadapt++; iarg += 6; - } else if (strcmp(arg[iarg],"bond") == 0 ) { + } else if (strcmp(arg[iarg],"bond") == 0) { if (iarg+5 > narg) error->all(FLERR, "Illegal fix adapt command"); adapt[nadapt].which = BOND; int n = strlen(arg[iarg+1]) + 1; @@ -651,7 +651,7 @@ void FixAdapt::change_settings() } } if (anybond) { - for (int m = 0; m < nadapt; ++m ) { + for (int m = 0; m < nadapt; ++m) { Adapt *ad = &adapt[m]; if (ad->which == BOND) { ad->bond->reinit(); diff --git a/src/fix_halt.cpp b/src/fix_halt.cpp index f09a8c4464..76941dc176 100644 --- a/src/fix_halt.cpp +++ b/src/fix_halt.cpp @@ -107,7 +107,7 @@ FixHalt::FixHalt(LAMMPS *lmp, int narg, char **arg) : dlimit_path = new char[len]; // strip off quotes, if present if ( ((arg[iarg][0] == '"') || (arg[iarg][0] == '\'')) - && (arg[iarg][0] == arg[iarg][len-2]) ) { + && (arg[iarg][0] == arg[iarg][len-2])) { strcpy(dlimit_path,&arg[iarg][1]); dlimit_path[len-3] = '\0'; } else strcpy(dlimit_path,arg[iarg]); diff --git a/src/info.cpp b/src/info.cpp index 5202610f9a..bb3111cb69 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -933,33 +933,33 @@ bool Info::is_defined(const char *category, const char *name) bool Info::has_style(const std::string &category, const std::string &name) { - if ( category == "atom" ) { + if (category == "atom") { return find_style(lmp, atom->avec_map, name, false); - } else if ( category == "integrate" ) { + } else if (category == "integrate") { return find_style(lmp, update->integrate_map, name, true); - } else if ( category == "minimize" ) { + } else if (category == "minimize") { return find_style(lmp, update->minimize_map, name, true); - } else if ( category == "pair" ) { + } else if (category == "pair") { return find_style(lmp, force->pair_map, name, true); - } else if ( category == "bond" ) { + } else if (category == "bond") { return find_style(lmp, force->bond_map, name, true); - } else if ( category == "angle" ) { + } else if (category == "angle") { return find_style(lmp, force->angle_map, name, true); - } else if ( category == "dihedral" ) { + } else if (category == "dihedral") { return find_style(lmp, force->dihedral_map, name, true); - } else if ( category == "improper" ) { + } else if (category == "improper") { return find_style(lmp, force->improper_map, name, true); - } else if ( category == "kspace" ) { + } else if (category == "kspace") { return find_style(lmp, force->kspace_map, name, true); - } else if ( category == "fix" ) { + } else if (category == "fix") { return find_style(lmp, modify->fix_map, name, true); - } else if ( category == "compute" ) { + } else if (category == "compute") { return find_style(lmp, modify->compute_map, name, true); - } else if ( category == "region" ) { + } else if (category == "region") { return find_style(lmp, domain->region_map, name, false); - } else if ( category == "dump" ) { + } else if (category == "dump") { return find_style(lmp, output->dump_map, name, false); - } else if ( category == "command" ) { + } else if (category == "command") { return find_style(lmp, input->command_map, name, false); } return false; @@ -967,33 +967,33 @@ bool Info::has_style(const std::string &category, const std::string &name) std::vector Info::get_available_styles(const std::string &category) { - if ( category == "atom" ) { + if (category == "atom") { return get_style_names(atom->avec_map); - } else if ( category == "integrate" ) { + } else if (category == "integrate") { return get_style_names(update->integrate_map); - } else if ( category == "minimize" ) { + } else if (category == "minimize") { return get_style_names(update->minimize_map); - } else if ( category == "pair" ) { + } else if (category == "pair") { return get_style_names(force->pair_map); - } else if ( category == "bond" ) { + } else if (category == "bond") { return get_style_names(force->bond_map); - } else if ( category == "angle" ) { + } else if (category == "angle") { return get_style_names(force->angle_map); - } else if ( category == "dihedral" ) { + } else if (category == "dihedral") { return get_style_names(force->dihedral_map); - } else if ( category == "improper" ) { + } else if (category == "improper") { return get_style_names(force->improper_map); - } else if ( category == "kspace" ) { + } else if (category == "kspace") { return get_style_names(force->kspace_map); - } else if ( category == "fix" ) { + } else if (category == "fix") { return get_style_names(modify->fix_map); - } else if ( category == "compute" ) { + } else if (category == "compute") { return get_style_names(modify->compute_map); - } else if ( category == "region" ) { + } else if (category == "region") { return get_style_names(domain->region_map); - } else if ( category == "dump" ) { + } else if (category == "dump") { return get_style_names(output->dump_map); - } else if ( category == "command" ) { + } else if (category == "command") { return get_style_names(input->command_map); } return std::vector(); diff --git a/src/library.cpp b/src/library.cpp index 00a922f98b..7d3f2f8996 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -2758,7 +2758,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data) } // property / atom if ( (vptr == nullptr) && ((strstr(name,"d_") == name) - || (strstr(name,"i_") == name)) ) { + || (strstr(name,"i_") == name))) { fcid = lmp->atom->find_custom(&name[2], ltype); if (fcid < 0) { if (lmp->comm->me == 0) @@ -4269,7 +4269,7 @@ included in the LAMMPS library in use. */ int lammps_config_package_count() { int i = 0; - while(LAMMPS::installed_packages[i] != nullptr) { + while (LAMMPS::installed_packages[i] != nullptr) { ++i; } return i; diff --git a/src/min_hftn.cpp b/src/min_hftn.cpp index beca1a839a..c554981835 100644 --- a/src/min_hftn.cpp +++ b/src/min_hftn.cpp @@ -410,7 +410,7 @@ int MinHFTN::execute_hftn_(const bool bPrintProgress, double dMag = 0.5 * (fabs (dCurrentEnergy) + fabs (dNewEnergy)); dMag = MAX (dMag, MIN_ETOL_MAG); if ( (fabs (dAred) < (update->etol * dMag)) - || (dStepLengthInf == 0.0) ) { + || (dStepLengthInf == 0.0)) { if (bPrintProgress) hftn_print_line_ (true, niter+1, neval, dNewEnergy, dNewForce2, @@ -1267,7 +1267,7 @@ double MinHFTN::compute_to_tr_(const double dPP, //---- CHECK FOR ERRONEOUS DATA. if ( (dDD <= 0.0) || (dPP < 0.0) || (dTrustRadius < 0.0) - || (dTrustRadius * dTrustRadius < dPP) ) { + || (dTrustRadius * dTrustRadius < dPP)) { printf ("HFTN internal error - bad data given to compute_to_tr_()\n"); return( 0.0 ); } diff --git a/src/min_linesearch.cpp b/src/min_linesearch.cpp index 8856359bcb..0c6dd46408 100644 --- a/src/min_linesearch.cpp +++ b/src/min_linesearch.cpp @@ -545,7 +545,7 @@ pseudo code: bactrack = true // GRAD_TOL = 0.1 - if ( (not backtrack) && (fabs(fhCurr/fh0) <= GRAD_TOL) ): + if ((not backtrack) && (fabs(fhCurr/fh0) <= GRAD_TOL)): // forces sufficiently reduced without energy increase EXIT with success diff --git a/src/molecule.cpp b/src/molecule.cpp index d85cf47c71..819083e0b3 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -796,7 +796,7 @@ void Molecule::fragments(char *line) fragmentnames[i] = values.next_string(); - while(values.has_next()) { + while (values.has_next()) { int atomID = values.next_int(); if (atomID <= 0 || atomID > natoms) error->one(FLERR,"Invalid atom ID in Fragments section of molecule file"); @@ -1630,11 +1630,11 @@ void Molecule::body(int flag, int pflag, char *line) if (flag) { if (pflag == 0) { - while(values.has_next()) { + while (values.has_next()) { ibodyparams[nword++] = values.next_int(); } } else { - while(values.has_next()) { + while (values.has_next()) { dbodyparams[nword++] = values.next_double(); } } diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 01fc0adac3..de2f180d44 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -247,7 +247,7 @@ void PairCoulStreitz::read_file(char *file) PotentialFileReader reader(lmp, file, "coul/streitz"); char * line; - while((line = reader.next_line(NPARAMS_PER_LINE))) { + while ((line = reader.next_line(NPARAMS_PER_LINE))) { try { ValueTokenizer values(line); @@ -318,7 +318,7 @@ void PairCoulStreitz::setup_params() for (i = 0; i < nelements; i++) { n = -1; for (m = 0; m < nparams; m++) { - if (i == params[m].ielement ) { + if (i == params[m].ielement) { if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); n = m; } diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 7e4c1d2781..3026c9c741 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -775,14 +775,14 @@ void PairHybrid::read_restart(FILE *fp) special_lj[m] = special_coul[m] = nullptr; if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); MPI_Bcast(&n,1,MPI_INT,0,world); - if (n > 0 ) { + if (n > 0) { special_lj[m] = new double[4]; if (me == 0) utils::sfread(FLERR,special_lj[m],sizeof(double),4,fp,nullptr,error); MPI_Bcast(special_lj[m],4,MPI_DOUBLE,0,world); } if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); MPI_Bcast(&n,1,MPI_INT,0,world); - if (n > 0 ) { + if (n > 0) { special_coul[m] = new double[4]; if (me == 0) utils::sfread(FLERR,special_coul[m],sizeof(double),4,fp,nullptr,error); MPI_Bcast(special_coul[m],4,MPI_DOUBLE,0,world); diff --git a/src/reader_native.cpp b/src/reader_native.cpp index a185f5ab3a..7c8bd9c3a8 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -165,7 +165,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, Tokenizer tokens(labelline); nwords = 0; - while(tokens.has_next()) { + while (tokens.has_next()) { labels[tokens.next()] = nwords++; } diff --git a/src/reader_xyz.cpp b/src/reader_xyz.cpp index 6a51849a5e..b144857879 100644 --- a/src/reader_xyz.cpp +++ b/src/reader_xyz.cpp @@ -148,7 +148,7 @@ bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclin (fieldtype[i] == Y) || (fieldtype[i] == Z) || (fieldtype[i] == ID) || - (fieldtype[i] == TYPE) ) { + (fieldtype[i] == TYPE)) { fieldindex[i] = fieldtype[i]; } else { fieldflag = 1; diff --git a/src/replicate.cpp b/src/replicate.cpp index 296e099208..9e91c30612 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -510,12 +510,12 @@ void Replicate::command(int narg, char **arg) if (!xoverlap) { if (xboxlo < 0) { _xoverlap1 = 1; - if ( _lo[0] > (subhi[0] - EPSILON) ) _xoverlap1 = 0; + if (_lo[0] > (subhi[0] - EPSILON)) _xoverlap1 = 0; } if (xboxhi > 0) { _xoverlap2 = 1; - if ( _hi[0] < (sublo[0] + EPSILON) ) _xoverlap2 = 0; + if (_hi[0] < (sublo[0] + EPSILON)) _xoverlap2 = 0; } if (_xoverlap1 || _xoverlap2) xoverlap = 1; @@ -526,12 +526,12 @@ void Replicate::command(int narg, char **arg) if (!yoverlap) { if (yboxlo < 0) { _yoverlap1 = 1; - if ( _lo[1] > (subhi[1] - EPSILON) ) _yoverlap1 = 0; + if (_lo[1] > (subhi[1] - EPSILON)) _yoverlap1 = 0; } if (yboxhi > 0) { _yoverlap2 = 1; - if ( _hi[1] < (sublo[1] + EPSILON) ) _yoverlap2 = 0; + if (_hi[1] < (sublo[1] + EPSILON)) _yoverlap2 = 0; } if (_yoverlap1 || _yoverlap2) yoverlap = 1; @@ -543,12 +543,12 @@ void Replicate::command(int narg, char **arg) if (!zoverlap) { if (zboxlo < 0) { _zoverlap1 = 1; - if ( _lo[2] > (subhi[2] - EPSILON) ) _zoverlap1 = 0; + if (_lo[2] > (subhi[2] - EPSILON)) _zoverlap1 = 0; } if (zboxhi > 0) { _zoverlap2 = 1; - if ( _hi[2] < (sublo[2] + EPSILON) ) _zoverlap2 = 0; + if (_hi[2] < (sublo[2] + EPSILON)) _zoverlap2 = 0; } if (_zoverlap1 || _zoverlap2) zoverlap = 1; diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index 23ef4a5568..19f15d8522 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -101,7 +101,7 @@ char *TextFileReader::next_line(int nparams) { n = strlen(line); } - while(nwords == 0 || nwords < nparams) { + while (nwords == 0 || nwords < nparams) { char *ptr = fgets(&line[n], MAXLINE - n, fp); if (ptr == nullptr) { @@ -148,7 +148,7 @@ void TextFileReader::next_dvector(double * list, int n) { } ValueTokenizer values(line); - while(values.has_next()) { + while (values.has_next()) { list[i++] = values.next_double(); } } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 37ebcd07fb..a9d82ca913 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -145,7 +145,7 @@ std::vector Tokenizer::as_vector() { // generate vector std::vector tokens; - while(has_next()) { + while (has_next()) { tokens.emplace_back(next()); } diff --git a/src/utils.cpp b/src/utils.cpp index 64283aa9c5..a58b384225 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1091,7 +1091,7 @@ void utils::merge_sort(int *index, int num, void *ptr, // copy all indices not handled by the chunked merge sort loop - for ( ; i < num ; i++ ) dest[i] = hold[i]; + for (; i < num ; i++) dest[i] = hold[i]; chunk *= 2; } diff --git a/src/write_coeff.cpp b/src/write_coeff.cpp index f84e1a2e33..8f1f6140ed 100644 --- a/src/write_coeff.cpp +++ b/src/write_coeff.cpp @@ -97,7 +97,7 @@ void WriteCoeff::command(int narg, char **arg) fprintf(two,"# LAMMPS coeff file via write_coeff, version %s\n", lmp->version); - while(1) { + while (1) { int coeff_mode = REGULAR_MODE; if (fgets(str,256,one) == nullptr) break; From b08582de69e6965d084d754bec77f38fba38a2b2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Dec 2020 09:54:46 -0500 Subject: [PATCH 176/187] fix bond/react buffer overflow: must not use sprintf to write to char variable --- src/USER-REACTION/fix_bond_react.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 483bd1c0f6..b5244d62a3 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1966,12 +1966,11 @@ int FixBondReact::check_constraints() } if (nconstraints[rxnID] > 0) { - char evalstr[MAXLINE],*ptr,valstr; + char evalstr[MAXLINE],*ptr; strcpy(evalstr,constraintstr[rxnID]); for (int i = 0; i < nconstraints[rxnID]; i++) { - sprintf(&valstr,"%d", satisfied[i]); ptr = strchr(evalstr,'C'); - *ptr = valstr; + *ptr = satisfied[i] ? '1' : '0'; } double verdict = input->variable->evaluate_boolean(evalstr); if (verdict == 0.0) return 0; From 5b34d58e48540c5f3509f5a8ea96456da62864da Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Wed, 30 Dec 2020 15:01:56 -0500 Subject: [PATCH 177/187] Removed kokkos_type.h include from pair_snap_kokkos.h --- src/KOKKOS/pair_snap_kokkos.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index 352e6e30b1..c2a7e20384 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -13,8 +13,6 @@ #ifdef PAIR_CLASS -#include "kokkos_type.h" - PairStyle(snap/kk,PairSNAPKokkosDevice) PairStyle(snap/kk/device,PairSNAPKokkosDevice) #ifdef LMP_KOKKOS_GPU From f00ca10b1e4d6fa58b1359953a6214b0f74bc9cb Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Wed, 30 Dec 2020 15:35:37 -0500 Subject: [PATCH 178/187] PR-specific whitespace fixes. --- src/KOKKOS/sna_kokkos_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index dc5ab2bcb8..e88ae1f0b3 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -531,7 +531,7 @@ void SNAKokkos::compute_ui(const typename Kokko // grab the cached value const complex ulist_prev = ulist_wrapper.get(ma); - // ulist_accum += rootpq * a.conj() * ulist_prev; + // ulist_accum += rootpq * a.conj() * ulist_prev; real rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); @@ -943,7 +943,7 @@ void SNAKokkos::compute_fused_deidrj(const type const complex ulist_prev = ulist_wrapper.get(ma); const complex dulist_prev = dulist_wrapper.get(ma); - // ulist_accum += rootpq * a.conj() * ulist_prev; + // ulist_accum += rootpq * a.conj() * ulist_prev; real rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); From 4d96b068de3ba4d3ff86dd6a78694eca5cef6aec Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 4 Jan 2021 11:01:12 -0500 Subject: [PATCH 179/187] properly initialize pointers to be freed --- src/REPLICA/neb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 6f58d933a5..a6a70fde38 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -42,7 +42,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -NEB::NEB(LAMMPS *lmp) : Pointers(lmp) {} +NEB::NEB(LAMMPS *lmp) : Pointers(lmp), all(nullptr), rdist(nullptr) {} /* ---------------------------------------------------------------------- internal NEB constructor, called from TAD @@ -50,7 +50,7 @@ NEB::NEB(LAMMPS *lmp) : Pointers(lmp) {} NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2steps_in, int nevery_in, double *buf_init, double *buf_final) - : Pointers(lmp) + : Pointers(lmp), all(nullptr), rdist(nullptr) { double delx,dely,delz; From 80d992a5ac9242ce845452d1c8cdd322e93db00f Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Mon, 4 Jan 2021 19:06:03 -0500 Subject: [PATCH 180/187] Replies to PR review: comment and variable name clean-up. --- src/KOKKOS/kokkos_type.h | 6 +++--- src/KOKKOS/pair_snap_kokkos.h | 8 ++++++-- src/KOKKOS/pair_snap_kokkos_impl.h | 26 +++++++++++--------------- src/KOKKOS/sna_kokkos.h | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index aac87e9153..6ef7c7b4e4 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1090,10 +1090,10 @@ struct params_lj_coul { typedef double SNAreal; //typedef struct { SNAreal re, im; } SNAcomplex; -template -struct alignas(2*sizeof(real_)) SNAComplex +template +struct alignas(2*sizeof(real_type)) SNAComplex { - using real = real_; + using real = real_type; using complex = SNAComplex; real re,im; diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index c2a7e20384..84567c38ad 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -65,7 +65,7 @@ struct TagPairSNAPComputeYiCPU{}; struct TagPairSNAPComputeDuidrjCPU{}; struct TagPairSNAPComputeDeidrjCPU{}; -template +template class PairSNAPKokkos : public PairSNAP { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; @@ -75,9 +75,13 @@ public: typedef EV_FLOAT value_type; static constexpr int vector_length = vector_length_; - using real = real_; + using real = real_type; using complex = SNAComplex; + // type-dependent team sizes + static constexpr int team_size_compute_ui = sizeof(real) == 4 ? 8 : 4; + static constexpr int team_size_compute_fused_deidrj = sizeof(real) == 4 ? 4 : 2; + PairSNAPKokkos(class LAMMPS *); ~PairSNAPKokkos(); diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index 194738828c..c554f48710 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -324,7 +324,9 @@ void PairSNAPKokkos::compute(int eflag_in, int // ComputeUi w/vector parallelism, shared memory, direct atomicAdd into ulisttot { // new AoSoA form - constexpr int team_size = sizeof(real) == 4 ? 8 : 4; // shared memory reqs + + // team_size_compute_ui is defined in `pair_snap_kokkos.h` + constexpr int team_size = team_size_compute_ui; // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer const int tile_size = vector_length * (twojmax + 1); @@ -341,7 +343,7 @@ void PairSNAPKokkos::compute(int eflag_in, int int n_teams = chunk_size_div * max_neighs * (twojmax + 1); int n_teams_div = (n_teams + team_size - 1) / team_size; - typename Kokkos::TeamPolicy policy_ui(n_teams_div,team_size, vector_length); + typename Kokkos::TeamPolicy policy_ui(n_teams_div, team_size, vector_length); policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); Kokkos::parallel_for("ComputeUi",policy_ui,*this); @@ -389,7 +391,9 @@ void PairSNAPKokkos::compute(int eflag_in, int // Fused ComputeDuidrj, ComputeDeidrj { // new AoSoA form - constexpr int team_size = sizeof(real) == 4 ? 4 : 2; // shared memory reqs + + // team_size_compute_fused_deidrj is defined in `pair_snap_kokkos.h` + constexpr int team_size = team_size_compute_fused_deidrj; // scratch size: 32 atoms * (twojmax+1) cached values * 2 for u, du, no double buffer const int tile_size = vector_length * (twojmax + 1); @@ -731,20 +735,15 @@ KOKKOS_INLINE_FUNCTION void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { SNAKokkos my_sna = snaKK; - constexpr int team_size = sizeof(real) == 4 ? 8 : 4; - if (team.team_size() != team_size) return; // error - // extract flattened atom_div / neighbor number / bend location - int flattened_idx = team.team_rank() + team.league_rank() * team_size; + int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_ui; // extract neighbor index, iatom_div - const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); const int jbend = jj_jbend / max_neighs; const int jj = jj_jbend - jbend * max_neighs; - // check base atom numbers, hopefully this doesn't lead to blocking conditions? - // yep, we can't have a return in here Kokkos::parallel_for(Kokkos::ThreadVectorRange(team, vector_length), [&] (const int iatom_mod) { const int ii = iatom_mod + vector_length * iatom_div; @@ -857,14 +856,11 @@ KOKKOS_INLINE_FUNCTION void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { SNAKokkos my_sna = snaKK; - constexpr int team_size = sizeof(real) == 4 ? 4 : 2; - if (team.team_size() != team_size) return; // error - // extract flattened atom_div / neighbor number / bend location - int flattened_idx = team.team_rank() + team.league_rank() * team_size; + int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_fused_deidrj; // extract neighbor index, iatom_div - const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); // plug in int_fastdiv + const int iatom_div = flattened_idx / (max_neighs * (twojmax + 1)); const int jj_jbend = flattened_idx - iatom_div * (max_neighs * (twojmax + 1)); const int jbend = jj_jbend / max_neighs; const int jj = jj_jbend - jbend * max_neighs; diff --git a/src/KOKKOS/sna_kokkos.h b/src/KOKKOS/sna_kokkos.h index d34e9a9e17..7ee01776d0 100644 --- a/src/KOKKOS/sna_kokkos.h +++ b/src/KOKKOS/sna_kokkos.h @@ -25,9 +25,9 @@ namespace LAMMPS_NS { -template +template struct WignerWrapper { - using real = real_; + using real = real_type; using complex = SNAComplex; static constexpr int vector_length = vector_length_; @@ -56,11 +56,11 @@ struct alignas(8) FullHalfMapper { int flip_sign; // 0 -> isn't flipped, 1 -> conj, -1 -> -conj }; -template +template class SNAKokkos { public: - using real = real_; + using real = real_type; using complex = SNAComplex; static constexpr int vector_length = vector_length_; From e0f8d01176f901a40a1b3fa302cddc1fe808dc47 Mon Sep 17 00:00:00 2001 From: Evan Weinberg Date: Mon, 4 Jan 2021 19:33:31 -0500 Subject: [PATCH 181/187] Whitespace fix. --- src/KOKKOS/pair_snap_kokkos_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index c554f48710..e4df428881 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -391,7 +391,7 @@ void PairSNAPKokkos::compute(int eflag_in, int // Fused ComputeDuidrj, ComputeDeidrj { // new AoSoA form - + // team_size_compute_fused_deidrj is defined in `pair_snap_kokkos.h` constexpr int team_size = team_size_compute_fused_deidrj; From df01bbc0162901b43e2b27484a6c4025cb705351 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 4 Jan 2021 23:28:58 -0500 Subject: [PATCH 182/187] provide input script backward compatibility w/o documenting the old option --- src/KOKKOS/kokkos.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 34100ff16f..3e25ae061f 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -415,7 +415,8 @@ void KokkosLMP::accelerator(int narg, char **arg) } else error->all(FLERR,"Illegal package kokkos command"); reverse_comm_changed = 0; iarg += 2; - } else if (strcmp(arg[iarg],"gpu/aware") == 0) { + } else if ((strcmp(arg[iarg],"gpu/aware") == 0) + || (strcmp(arg[iarg],"cuda/aware") == 0)) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"off") == 0) gpu_aware_flag = 0; else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; From 973c23018568de26b025bd37fcdd7581344cb74d Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 5 Jan 2021 08:29:47 -0700 Subject: [PATCH 183/187] Update chunksize --- doc/src/compute_orientorder_atom.rst | 6 +++--- doc/src/pair_snap.rst | 6 +++--- src/SNAP/pair_snap.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/src/compute_orientorder_atom.rst b/doc/src/compute_orientorder_atom.rst index 2a36fb4cc0..af4e6a21e8 100644 --- a/doc/src/compute_orientorder_atom.rst +++ b/doc/src/compute_orientorder_atom.rst @@ -115,8 +115,8 @@ The optional keyword *chunksize* is only applicable when using the the KOKKOS package and is ignored otherwise. This keyword controls the number of atoms in each pass used to compute the bond-orientational order parameters and is used to avoid running out of memory. For example -if there are 4000 atoms in the simulation and the *chunksize* -is set to 2000, the parameter calculation will be broken up +if there are 32768 atoms in the simulation and the *chunksize* +is set to 16384, the parameter calculation will be broken up into two passes. The value of :math:`Q_l` is set to zero for atoms not in the @@ -193,7 +193,7 @@ Default The option defaults are *cutoff* = pair style cutoff, *nnn* = 12, *degrees* = 5 4 6 8 10 12 i.e. :math:`Q_4`, :math:`Q_6`, :math:`Q_8`, :math:`Q_{10}`, and :math:`Q_{12}`, -*wl* = no, *wl/hat* = no, *components* off, and *chunksize* = 2000 +*wl* = no, *wl/hat* = no, *components* off, and *chunksize* = 16384 ---------- diff --git a/doc/src/pair_snap.rst b/doc/src/pair_snap.rst index 8aa10f5986..a99331345e 100644 --- a/doc/src/pair_snap.rst +++ b/doc/src/pair_snap.rst @@ -152,7 +152,7 @@ The default values for these keywords are * *chemflag* = 0 * *bnormflag* = 0 * *wselfallflag* = 0 -* *chunksize* = 2000 +* *chunksize* = 4096 If *quadraticflag* is set to 1, then the SNAP energy expression includes additional quadratic terms that have been shown to increase the overall accuracy of the potential without much increase @@ -189,8 +189,8 @@ pair style *snap* with the KOKKOS package and is ignored otherwise. This keyword controls the number of atoms in each pass used to compute the bispectrum components and is used to avoid running out of memory. For example -if there are 4000 atoms in the simulation and the *chunksize* -is set to 2000, the bispectrum calculation will be broken up +if there are 8192 atoms in the simulation and the *chunksize* +is set to 4096, the bispectrum calculation will be broken up into two passes. Detailed definitions for all the other keywords diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index a7ea6de591..741c237ca8 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -657,7 +657,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) chemflag = 0; bnormflag = 0; wselfallflag = 0; - chunksize = 2000; + chunksize = 4096; // open SNAP parameter file on proc 0 From 12ccc00ac9d2551af208781e4741f3d094dff2de Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 5 Jan 2021 08:34:08 -0700 Subject: [PATCH 184/187] Formatting tweak --- src/KOKKOS/pair_snap_kokkos_impl.h | 24 ++++++++++++------------ src/KOKKOS/sna_kokkos_impl.h | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index e4df428881..26ecd0dd36 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -299,10 +299,10 @@ void PairSNAPKokkos::compute(int eflag_in, int Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( team_size * max_neighs ); + int scratch_size = ScratchViewType::shmem_size(team_size * max_neighs); typename Kokkos::TeamPolicy policy_neigh(chunk_size,team_size,vector_length); - policy_neigh = policy_neigh.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + policy_neigh = policy_neigh.set_scratch_size(0, Kokkos::PerTeam(scratch_size)); Kokkos::parallel_for("ComputeNeigh",policy_neigh,*this); } @@ -334,7 +334,7 @@ void PairSNAPKokkos::compute(int eflag_in, int Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( team_size * tile_size ); + int scratch_size = ScratchViewType::shmem_size(team_size * tile_size); // total number of teams needed int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; @@ -344,7 +344,7 @@ void PairSNAPKokkos::compute(int eflag_in, int int n_teams_div = (n_teams + team_size - 1) / team_size; typename Kokkos::TeamPolicy policy_ui(n_teams_div, team_size, vector_length); - policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + policy_ui = policy_ui.set_scratch_size(0, Kokkos::PerTeam(scratch_size)); Kokkos::parallel_for("ComputeUi",policy_ui,*this); @@ -401,7 +401,7 @@ void PairSNAPKokkos::compute(int eflag_in, int Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits > ScratchViewType; - int scratch_size = ScratchViewType::shmem_size( 2 * team_size * tile_size ); + int scratch_size = ScratchViewType::shmem_size(2 * team_size * tile_size); // total number of teams needed int chunk_size_div = (chunk_size + vector_length - 1) / vector_length; @@ -411,7 +411,7 @@ void PairSNAPKokkos::compute(int eflag_in, int int n_teams_div = (n_teams + team_size - 1) / team_size; typename Kokkos::TeamPolicy policy_fused_deidrj(n_teams_div,team_size,vector_length); - policy_fused_deidrj = policy_fused_deidrj.set_scratch_size(0, Kokkos::PerTeam( scratch_size )); + policy_fused_deidrj = policy_fused_deidrj.set_scratch_size(0, Kokkos::PerTeam(scratch_size)); for (int k = 0; k < 3; k++) { snaKK.set_dir(k); @@ -631,7 +631,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const int tile_size = max_neighs; // number of elements per thread const int team_rank = team.team_rank(); const int scratch_shift = team_rank * tile_size; // offset into pointer for entire team - int* type_cache = (int*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(int), 0) + scratch_shift; + int* type_cache = (int*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(int), 0) + scratch_shift; // Load various info about myself up front const int i = d_ilist[ii + chunk_offset]; @@ -668,7 +668,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom type_cache[jj] = jtype; - if ( jtype >= 0 ) + if (jtype >= 0) count++; }, ninside); @@ -679,7 +679,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const int jtype = type_cache[jj]; - if ( jtype >= 0 ) { + if (jtype >= 0) { if (final) { T_INT j = d_neighbors(i,jj); const F_FLOAT dx = x(j,0) - xtmp; @@ -778,7 +778,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra if (mapper.flip_sign == 1) { utot_im = -utot_im; - } else if (mapper.flip_sign == -1 ) { + } else if (mapper.flip_sign == -1) { utot_re = -utot_re; } @@ -957,7 +957,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const int jtype = type(j); const F_FLOAT rsq = dx*dx + dy*dy + dz*dz; - if ( rsq < rnd_cutsq(itype,jtype) ) + if (rsq < rnd_cutsq(itype,jtype)) count++; }); },ninside); @@ -977,7 +977,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const F_FLOAT rsq = dx*dx + dy*dy + dz*dz; const int elem_j = d_map[jtype]; - if ( rsq < rnd_cutsq(itype,jtype) ) { + if (rsq < rnd_cutsq(itype,jtype)) { if (final) { my_sna.rij(ii,offset,0) = static_cast(dx); my_sna.rij(ii,offset,1) = static_cast(dy); diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index e88ae1f0b3..ed80647083 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -496,7 +496,7 @@ void SNAKokkos::compute_ui(const typename Kokko const int scratch_shift = team_rank * tile_size; // extract and wrap - WignerWrapper ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters @@ -900,8 +900,8 @@ void SNAKokkos::compute_fused_deidrj(const type const int scratch_shift = team_rank * tile_size; // extract, wrap shared memory buffer - WignerWrapper ulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - WignerWrapper dulist_wrapper((complex*)team.team_shmem( ).get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper dulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters const auto a = a_pack(iatom_mod, jnbor, iatom_div); @@ -1335,7 +1335,7 @@ void SNAKokkos::compute_yi_cpu(int iter, int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; - int icgb = mb1min * (j2 +1 ) + mb2max; + int icgb = mb1min * (j2 +1) + mb2max; for (int ib = 0; ib < nb; ib++) { From fffbb8ac7fb524e464a09ad799d23bbd075d40fc Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 5 Jan 2021 09:08:57 -0700 Subject: [PATCH 185/187] Switch 'real' to 'real_type' --- src/KOKKOS/kokkos_type.h | 28 +-- src/KOKKOS/pair_snap_kokkos.h | 24 +- src/KOKKOS/pair_snap_kokkos_impl.h | 220 ++++++++--------- src/KOKKOS/sna_kokkos.h | 66 ++--- src/KOKKOS/sna_kokkos_impl.h | 370 ++++++++++++++--------------- 5 files changed, 354 insertions(+), 354 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 6ef7c7b4e4..fbe9799bee 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1090,20 +1090,20 @@ struct params_lj_coul { typedef double SNAreal; //typedef struct { SNAreal re, im; } SNAcomplex; -template -struct alignas(2*sizeof(real_type)) SNAComplex +template +struct alignas(2*sizeof(real_type_)) SNAComplex { - using real = real_type; - using complex = SNAComplex; - real re,im; + using real_type = real_type_; + using complex = SNAComplex; + real_type re,im; KOKKOS_FORCEINLINE_FUNCTION SNAComplex() - : re(static_cast(0.)), im(static_cast(0.)) { ; } + : re(static_cast(0.)), im(static_cast(0.)) { ; } - KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real re) - : re(re), im(static_cast(0.)) { ; } + KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real_type re) + : re(re), im(static_cast(0.)) { ; } - KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real re, real im) + KOKKOS_FORCEINLINE_FUNCTION SNAComplex(real_type re, real_type im) : re(re), im(im) { ; } KOKKOS_FORCEINLINE_FUNCTION SNAComplex(const SNAComplex& other) @@ -1132,19 +1132,19 @@ struct alignas(2*sizeof(real_type)) SNAComplex } KOKKOS_INLINE_FUNCTION - static constexpr complex zero() { return complex(static_cast(0.), static_cast(0.)); } + static constexpr complex zero() { return complex(static_cast(0.), static_cast(0.)); } KOKKOS_INLINE_FUNCTION - static constexpr complex one() { return complex(static_cast(1.), static_cast(0.)); } + static constexpr complex one() { return complex(static_cast(1.), static_cast(0.)); } KOKKOS_INLINE_FUNCTION const complex conj() { return complex(re, -im); } }; -template -KOKKOS_FORCEINLINE_FUNCTION SNAComplex operator*(const real& r, const SNAComplex& self) { - return SNAComplex(r*self.re, r*self.im); +template +KOKKOS_FORCEINLINE_FUNCTION SNAComplex operator*(const real_type& r, const SNAComplex& self) { + return SNAComplex(r*self.re, r*self.im); } typedef SNAComplex SNAcomplex; diff --git a/src/KOKKOS/pair_snap_kokkos.h b/src/KOKKOS/pair_snap_kokkos.h index 84567c38ad..416cc1b888 100644 --- a/src/KOKKOS/pair_snap_kokkos.h +++ b/src/KOKKOS/pair_snap_kokkos.h @@ -65,7 +65,7 @@ struct TagPairSNAPComputeYiCPU{}; struct TagPairSNAPComputeDuidrjCPU{}; struct TagPairSNAPComputeDeidrjCPU{}; -template +template class PairSNAPKokkos : public PairSNAP { public: enum {EnabledNeighFlags=FULL|HALF|HALFTHREAD}; @@ -75,12 +75,12 @@ public: typedef EV_FLOAT value_type; static constexpr int vector_length = vector_length_; - using real = real_type; - using complex = SNAComplex; + using real_type = real_type_; + using complex = SNAComplex; // type-dependent team sizes - static constexpr int team_size_compute_ui = sizeof(real) == 4 ? 8 : 4; - static constexpr int team_size_compute_fused_deidrj = sizeof(real) == 4 ? 4 : 2; + static constexpr int team_size_compute_ui = sizeof(real_type) == 4 ? 8 : 4; + static constexpr int team_size_compute_fused_deidrj = sizeof(real_type) == 4 ? 4 : 2; PairSNAPKokkos(class LAMMPS *); ~PairSNAPKokkos(); @@ -190,7 +190,7 @@ protected: t_bvec bvec; typedef Kokkos::View t_dbvec; t_dbvec dbvec; - SNAKokkos snaKK; + SNAKokkos snaKK; int inum,max_neighs,chunk_size,chunk_offset; int host_flag; @@ -225,14 +225,14 @@ inline double dist2(double* x,double* y); Kokkos::View i_uarraytot_r, i_uarraytot_i; Kokkos::View i_zarray_r, i_zarray_i; - Kokkos::View d_radelem; // element radii - Kokkos::View d_wjelem; // elements weights - Kokkos::View d_coeffelem; // element bispectrum coefficients + Kokkos::View d_radelem; // element radii + Kokkos::View d_wjelem; // elements weights + Kokkos::View d_coeffelem; // element bispectrum coefficients Kokkos::View d_map; // mapping from atom types to elements Kokkos::View d_ninside; // ninside for all atoms in list - Kokkos::View d_beta; // betas for all atoms in list - Kokkos::View d_beta_pack; // betas for all atoms in list, GPU - Kokkos::View d_bispectrum; // bispectrum components for all atoms in list + Kokkos::View d_beta; // betas for all atoms in list + Kokkos::View d_beta_pack; // betas for all atoms in list, GPU + Kokkos::View d_bispectrum; // bispectrum components for all atoms in list typedef Kokkos::DualView tdual_fparams; tdual_fparams k_cutsq; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index 26ecd0dd36..1349232136 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -48,8 +48,8 @@ namespace LAMMPS_NS { //static double t7 = 0.0; /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) +template +PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp) { respa_enable = 0; @@ -67,8 +67,8 @@ PairSNAPKokkos::PairSNAPKokkos(LAMMPS *lmp) : P /* ---------------------------------------------------------------------- */ -template -PairSNAPKokkos::~PairSNAPKokkos() +template +PairSNAPKokkos::~PairSNAPKokkos() { if (copymode) return; @@ -81,8 +81,8 @@ PairSNAPKokkos::~PairSNAPKokkos() init specific to this pair style ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::init_style() +template +void PairSNAPKokkos::init_style() { if (force->newton_pair == 0) error->all(FLERR,"Pair style SNAP requires newton pair on"); @@ -128,8 +128,8 @@ struct FindMaxNumNeighs { This version is a straightforward implementation ---------------------------------------------------------------------- */ -template -void PairSNAPKokkos::compute(int eflag_in, int vflag_in) +template +void PairSNAPKokkos::compute(int eflag_in, int vflag_in) { eflag = eflag_in; vflag = vflag_in; @@ -192,9 +192,9 @@ void PairSNAPKokkos::compute(int eflag_in, int if (beta_max < inum) { beta_max = inum; - d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); + d_beta = Kokkos::View("PairSNAPKokkos:beta",ncoeff,inum); if (!host_flag) - d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",vector_length,ncoeff,(inum + vector_length - 1) / vector_length); + d_beta_pack = Kokkos::View("PairSNAPKokkos:beta_pack",vector_length,ncoeff,(inum + vector_length - 1) / vector_length); d_ninside = Kokkos::View("PairSNAPKokkos:ninside",inum); } @@ -501,8 +501,8 @@ void PairSNAPKokkos::compute(int eflag_in, int allocate all arrays ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::allocate() +template +void PairSNAPKokkos::allocate() { PairSNAP::allocate(); @@ -515,8 +515,8 @@ void PairSNAPKokkos::allocate() init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::init_one(int i, int j) +template +double PairSNAPKokkos::init_one(int i, int j) { double cutone = PairSNAP::init_one(i,j); k_cutsq.h_view(i,j) = k_cutsq.h_view(j,i) = cutone*cutone; @@ -529,16 +529,16 @@ double PairSNAPKokkos::init_one(int i, int j) set coeffs for one or more type pairs ------------------------------------------------------------------------- */ -template -void PairSNAPKokkos::coeff(int narg, char **arg) +template +void PairSNAPKokkos::coeff(int narg, char **arg) { PairSNAP::coeff(narg,arg); // Set up element lists - d_radelem = Kokkos::View("pair:radelem",nelements); - d_wjelem = Kokkos::View("pair:wjelem",nelements); - d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); + d_radelem = Kokkos::View("pair:radelem",nelements); + d_wjelem = Kokkos::View("pair:wjelem",nelements); + d_coeffelem = Kokkos::View("pair:coeffelem",nelements,ncoeffall); auto h_radelem = Kokkos::create_mirror_view(d_radelem); auto h_wjelem = Kokkos::create_mirror_view(d_wjelem); @@ -562,7 +562,7 @@ void PairSNAPKokkos::coeff(int narg, char **arg Kokkos::deep_copy(d_coeffelem,h_coeffelem); Kokkos::deep_copy(d_map,h_map); - snaKK = SNAKokkos(rfac0,twojmax, + snaKK = SNAKokkos(rfac0,twojmax, rmin0,switchflag,bzeroflag,chemflag,bnormflag,wselfallflag,nelements); snaKK.grow_rij(0,0); snaKK.init(); @@ -573,9 +573,9 @@ void PairSNAPKokkos::coeff(int narg, char **arg of AoSoA data layouts and scratch memory for recursive polynomials ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { +void PairSNAPKokkos::operator() (TagPairSNAPBeta,const int& ii) const { if (ii >= chunk_size) return; @@ -585,7 +585,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet const int i = d_ilist[ii + chunk_offset]; const int itype = type[i]; const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); @@ -605,7 +605,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { const auto jdxb = jcoeff % idxb_max; const auto jdx_chem = jcoeff / idxb_max; - real bvecj = my_sna.blist(jdxb, jdx_chem, ii); + real_type bvecj = my_sna.blist(jdxb, jdx_chem, ii); d_beta_pack(iatom_mod,icoeff,iatom_div) += d_coeffi[k]*bvecj; d_beta_pack(iatom_mod,jcoeff,iatom_div) += d_coeffi[k]*bveci; k++; @@ -614,11 +614,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeigh,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; // extract atom number int ii = team.team_rank() + team.league_rank() * team.team_size(); @@ -686,11 +686,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom const F_FLOAT dy = x(j,1) - ytmp; const F_FLOAT dz = x(j,2) - ztmp; const int elem_j = d_map[jtype]; - my_sna.rij(ii,offset,0) = static_cast(dx); - my_sna.rij(ii,offset,1) = static_cast(dy); - my_sna.rij(ii,offset,2) = static_cast(dz); - my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); - my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); my_sna.inside(ii,offset) = j; if (chemflag) my_sna.element(ii,offset) = elem_j; @@ -702,10 +702,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom }); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeCayleyKlein,const int iatom_mod, const int jnbor, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeCayleyKlein,const int iatom_mod, const int jnbor, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int ii = iatom_mod + iatom_div * vector_length; if (ii >= chunk_size) return; @@ -716,10 +716,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_cayley_klein(iatom_mod,jnbor,iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUi, const int iatom_mod, const int j, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPPreUi, const int iatom_mod, const int j, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int ii = iatom_mod + iatom_div * vector_length; if (ii >= chunk_size) return; @@ -730,10 +730,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPPre my_sna.pre_ui(iatom_mod, j, ielem, iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeUi,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // extract flattened atom_div / neighbor number / bend location int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_ui; @@ -757,10 +757,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int idxu, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformUi,const int iatom_mod, const int idxu, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -791,10 +791,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeYi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -804,10 +804,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_yi(iatom_mod,jjz,iatom_div,d_beta_pack); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeZi,const int iatom_mod, const int jjz, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -817,10 +817,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_zi(iatom_mod,jjz,iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeBi,const int iatom_mod, const int jjb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -830,10 +830,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_bi(iatom_mod,jjb,iatom_div); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformBi,const int iatom_mod, const int idxb, const int iatom_div) const { + SNAKokkos my_sna = snaKK; const int iatom = iatom_mod + iatom_div * vector_length; if (iatom >= chunk_size) return; @@ -851,10 +851,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeFusedDeidrj,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // extract flattened atom_div / neighbor number / bend location int flattened_idx = team.team_rank() + team.league_rank() * team_size_compute_fused_deidrj; @@ -887,14 +887,14 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom different arithmetic intensity requirements for the CPU vs GPU. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { +void PairSNAPKokkos::operator() (TagPairSNAPBetaCPU,const int& ii) const { const int i = d_ilist[ii + chunk_offset]; const int itype = type[i]; const int ielem = d_map[itype]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; auto d_coeffi = Kokkos::subview(d_coeffelem, ielem, Kokkos::ALL); @@ -922,14 +922,14 @@ void PairSNAPKokkos::operator() (TagPairSNAPBet } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeNeighCPU,const typename Kokkos::TeamPolicy::member_type& team) const { int ii = team.league_rank(); const int i = d_ilist[ii + chunk_offset]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; const double xtmp = x(i,0); const double ytmp = x(i,1); const double ztmp = x(i,2); @@ -979,11 +979,11 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom if (rsq < rnd_cutsq(itype,jtype)) { if (final) { - my_sna.rij(ii,offset,0) = static_cast(dx); - my_sna.rij(ii,offset,1) = static_cast(dy); - my_sna.rij(ii,offset,2) = static_cast(dz); - my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); - my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); + my_sna.rij(ii,offset,0) = static_cast(dx); + my_sna.rij(ii,offset,1) = static_cast(dy); + my_sna.rij(ii,offset,2) = static_cast(dz); + my_sna.wj(ii,offset) = static_cast(d_wjelem[elem_j]); + my_sna.rcutij(ii,offset) = static_cast((radi + d_radelem[elem_j])*rcutfac); my_sna.inside(ii,offset) = j; if (chemflag) my_sna.element(ii,offset) = elem_j; @@ -996,10 +996,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPPreUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number const int ii = team.team_rank() + team.team_size() * team.league_rank(); @@ -1012,10 +1012,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPPre -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeUiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1029,10 +1029,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_ui_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPTransformUiCPU, const int j, const int iatom) const { + SNAKokkos my_sna = snaKK; if (iatom >= chunk_size) return; @@ -1079,32 +1079,32 @@ void PairSNAPKokkos::operator() (TagPairSNAPTra } } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeYiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_yi_cpu(ii,d_beta); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeZiCPU,const int& ii) const { + SNAKokkos my_sna = snaKK; my_sna.compute_zi_cpu(ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeBiCPU,const typename Kokkos::TeamPolicy::member_type& team) const { int ii = team.league_rank(); - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; my_sna.compute_bi_cpu(team,ii); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDuidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1118,10 +1118,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom my_sna.compute_duidrj_cpu(team,ii,jj); } -template +template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { - SNAKokkos my_sna = snaKK; +void PairSNAPKokkos::operator() (TagPairSNAPComputeDeidrjCPU,const typename Kokkos::TeamPolicy::member_type& team) const { + SNAKokkos my_sna = snaKK; // Extract the atom number int ii = team.team_rank() + team.team_size() * (team.league_rank() % ((chunk_size+team.team_size()-1)/team.team_size())); @@ -1141,10 +1141,10 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom likely not worth it. ------------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team, EV_FLOAT& ev) const { // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial @@ -1153,7 +1153,7 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom int ii = team.league_rank(); const int i = d_ilist[ii + chunk_offset]; - SNAKokkos my_sna = snaKK; + SNAKokkos my_sna = snaKK; const int ninside = d_ninside(ii); Kokkos::parallel_for (Kokkos::TeamThreadRange(team,ninside), @@ -1242,20 +1242,20 @@ void PairSNAPKokkos::operator() (TagPairSNAPCom } } -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { +void PairSNAPKokkos::operator() (TagPairSNAPComputeForce,const typename Kokkos::TeamPolicy >::member_type& team) const { EV_FLOAT ev; this->template operator()(TagPairSNAPComputeForce(), team, ev); } /* ---------------------------------------------------------------------- */ -template +template template KOKKOS_INLINE_FUNCTION -void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, +void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const int &j, const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { @@ -1300,24 +1300,24 @@ void PairSNAPKokkos::v_tally_xyz(EV_FLOAT &ev, memory usage ------------------------------------------------------------------------- */ -template -double PairSNAPKokkos::memory_usage() +template +double PairSNAPKokkos::memory_usage() { double bytes = Pair::memory_usage(); int n = atom->ntypes+1; bytes += n*n*sizeof(int); - bytes += n*n*sizeof(real); - bytes += (2*ncoeffall)*sizeof(real); - bytes += (ncoeff*3)*sizeof(real); + bytes += n*n*sizeof(real_type); + bytes += (2*ncoeffall)*sizeof(real_type); + bytes += (ncoeff*3)*sizeof(real_type); bytes += snaKK.memory_usage(); return bytes; } /* ---------------------------------------------------------------------- */ -template +template template -void PairSNAPKokkos::check_team_size_for(int inum, int &team_size) { +void PairSNAPKokkos::check_team_size_for(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); @@ -1326,9 +1326,9 @@ void PairSNAPKokkos::check_team_size_for(int in team_size = team_size_max/vector_length; } -template +template template -void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size) { +void PairSNAPKokkos::check_team_size_reduce(int inum, int &team_size) { int team_size_max; team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelReduceTag()); diff --git a/src/KOKKOS/sna_kokkos.h b/src/KOKKOS/sna_kokkos.h index 7ee01776d0..f183acdb57 100644 --- a/src/KOKKOS/sna_kokkos.h +++ b/src/KOKKOS/sna_kokkos.h @@ -25,18 +25,18 @@ namespace LAMMPS_NS { -template +template struct WignerWrapper { - using real = real_type; - using complex = SNAComplex; + using real_type = real_type_; + using complex = SNAComplex; static constexpr int vector_length = vector_length_; const int offset; // my offset into the vector (0, ..., vector_length - 1) - real* buffer; // buffer of real numbers + real_type* buffer; // buffer of real numbers KOKKOS_INLINE_FUNCTION WignerWrapper(complex* buffer_, const int offset_) - : offset(offset_), buffer(reinterpret_cast(buffer_)) + : offset(offset_), buffer(reinterpret_cast(buffer_)) { ; } KOKKOS_INLINE_FUNCTION @@ -56,26 +56,26 @@ struct alignas(8) FullHalfMapper { int flip_sign; // 0 -> isn't flipped, 1 -> conj, -1 -> -conj }; -template +template class SNAKokkos { public: - using real = real_type; - using complex = SNAComplex; + using real_type = real_type_; + using complex = SNAComplex; static constexpr int vector_length = vector_length_; typedef Kokkos::View t_sna_1i; - typedef Kokkos::View t_sna_1d; - typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; + typedef Kokkos::View t_sna_1d; + typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1d_atomic; typedef Kokkos::View t_sna_2i; - typedef Kokkos::View t_sna_2d; - typedef Kokkos::View t_sna_2d_ll; - typedef Kokkos::View t_sna_3d; - typedef Kokkos::View t_sna_3d_ll; - typedef Kokkos::View t_sna_4d; - typedef Kokkos::View t_sna_4d_ll; - typedef Kokkos::View t_sna_3d3; - typedef Kokkos::View t_sna_5d; + typedef Kokkos::View t_sna_2d; + typedef Kokkos::View t_sna_2d_ll; + typedef Kokkos::View t_sna_3d; + typedef Kokkos::View t_sna_3d_ll; + typedef Kokkos::View t_sna_4d; + typedef Kokkos::View t_sna_4d_ll; + typedef Kokkos::View t_sna_3d3; + typedef Kokkos::View t_sna_5d; typedef Kokkos::View t_sna_1c; typedef Kokkos::View::value, Kokkos::MemoryTraits > t_sna_1c_atomic; @@ -93,10 +93,10 @@ public: inline SNAKokkos() {}; KOKKOS_INLINE_FUNCTION - SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); + SNAKokkos(const SNAKokkos& sna, const typename Kokkos::TeamPolicy::member_type& team); inline - SNAKokkos(real, int, real, int, int, int, int, int, int); + SNAKokkos(real_type, int, real_type, int, int, int, int, int, int); KOKKOS_INLINE_FUNCTION ~SNAKokkos(); @@ -123,7 +123,7 @@ inline void compute_zi(const int&, const int&, const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi(int,int,int, - const Kokkos::View &beta_pack); // ForceSNAP + const Kokkos::View &beta_pack); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi(const int&, const int&, const int&); // ForceSNAP @@ -136,7 +136,7 @@ inline void compute_zi_cpu(const int&); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_yi_cpu(int, - const Kokkos::View &beta); // ForceSNAP + const Kokkos::View &beta); // ForceSNAP KOKKOS_INLINE_FUNCTION void compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int); // ForceSNAP @@ -151,13 +151,13 @@ inline void compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int); // ForceSNAP KOKKOS_INLINE_FUNCTION - real compute_sfac(real, real); // add_uarraytot, compute_duarray + real_type compute_sfac(real_type, real_type); // add_uarraytot, compute_duarray KOKKOS_INLINE_FUNCTION - real compute_dsfac(real, real); // compute_duarray + real_type compute_dsfac(real_type, real_type); // compute_duarray KOKKOS_INLINE_FUNCTION - void compute_s_dsfac(const real, const real, real&, real&); // compute_cayley_klein + void compute_s_dsfac(const real_type, const real_type, real_type&, real_type&); // compute_cayley_klein static KOKKOS_FORCEINLINE_FUNCTION void sincos_wrapper(double x, double* sin_, double *cos_) { sincos(x, sin_, cos_); } @@ -224,7 +224,7 @@ inline int ntriples; private: - real rmin0, rfac0; + real_type rmin0, rfac0; //use indexlist instead of loops, constructor generates these // Same across all SNAKokkos @@ -265,12 +265,12 @@ inline void init_rootpqarray(); // init() KOKKOS_INLINE_FUNCTION - void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, const real&, const real&, const real&, int); // compute_ui + void add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int, int, const real_type&, const real_type&, const real_type&, int); // compute_ui KOKKOS_INLINE_FUNCTION void compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - const real&, const real&, const real&, - const real&, const real&); // compute_ui_cpu + const real_type&, const real_type&, const real_type&, + const real_type&, const real_type&); // compute_ui_cpu inline @@ -280,8 +280,8 @@ inline int compute_ncoeff(); // SNAKokkos() KOKKOS_INLINE_FUNCTION void compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int, int, - const real&, const real&, const real&, // compute_duidrj_cpu - const real&, const real&, const real&, const real&, const real&); + const real_type&, const real_type&, const real_type&, // compute_duidrj_cpu + const real_type&, const real_type&, const real_type&, const real_type&, const real_type&); // Sets the style for the switching function // 0 = none @@ -293,11 +293,11 @@ inline int bnorm_flag; // Self-weight - real wself; + real_type wself; int wselfall_flag; int bzero_flag; // 1 if bzero subtracted from barray - Kokkos::View bzero; // array of B values for isolated atoms + Kokkos::View bzero; // array of B values for isolated atoms // for per-direction dulist calculation, specify the direction. int dir; diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index ed80647083..23c1670bd8 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -25,16 +25,16 @@ namespace LAMMPS_NS { static const double MY_PI = 3.14159265358979323846; // pi -template +template inline -SNAKokkos::SNAKokkos(real rfac0_in, - int twojmax_in, real rmin0_in, int switch_flag_in, int bzero_flag_in, +SNAKokkos::SNAKokkos(real_type rfac0_in, + int twojmax_in, real_type rmin0_in, int switch_flag_in, int bzero_flag_in, int chem_flag_in, int bnorm_flag_in, int wselfall_flag_in, int nelements_in) { LAMMPS_NS::ExecutionSpace execution_space = ExecutionSpaceFromDevice::space; host_flag = (execution_space == LAMMPS_NS::Host); - wself = static_cast(1.0); + wself = static_cast(1.0); rfac0 = rfac0_in; rmin0 = rmin0_in; @@ -63,7 +63,7 @@ SNAKokkos::SNAKokkos(real rfac0_in, cglist = t_sna_1d("SNAKokkos::cglist",idxcg_max); if (bzero_flag) { - bzero = Kokkos::View("sna:bzero",twojmax+1); + bzero = Kokkos::View("sna:bzero",twojmax+1); auto h_bzero = Kokkos::create_mirror_view(bzero); double www = wself*wself*wself; @@ -78,15 +78,15 @@ SNAKokkos::SNAKokkos(real rfac0_in, /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -SNAKokkos::~SNAKokkos() +SNAKokkos::~SNAKokkos() { } -template +template inline -void SNAKokkos::build_indexlist() +void SNAKokkos::build_indexlist() { // index list for cglist @@ -274,17 +274,17 @@ void SNAKokkos::build_indexlist() /* ---------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init() +void SNAKokkos::init() { init_clebsch_gordan(); init_rootpqarray(); } -template +template inline -void SNAKokkos::grow_rij(int newnatom, int newnmax) +void SNAKokkos::grow_rij(int newnatom, int newnmax) { if(newnatom <= natom && newnmax <= nmax) return; natom = newnatom; @@ -358,9 +358,9 @@ void SNAKokkos::grow_rij(int newnatom, int newn ComputeFusedDeidrj, which are one warp per atom-neighbor pair. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_cayley_klein(const int& iatom_mod, const int& jnbor, const int& iatom_div) +void SNAKokkos::compute_cayley_klein(const int& iatom_mod, const int& jnbor, const int& iatom_div) { const int iatom = iatom_mod + vector_length * iatom_div; const auto x = rij(iatom,jnbor,0); @@ -369,25 +369,25 @@ void SNAKokkos::compute_cayley_klein(const int& const auto rsq = x * x + y * y + z * z; const auto r = sqrt(rsq); const auto rcut = rcutij(iatom, jnbor); - const auto rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); + const auto rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); const auto theta0 = (r - rmin0) * rscale0; - real sn, cs; + real_type sn, cs; sincos_wrapper(theta0, &sn, &cs); - const real z0 = r * cs / sn; - const real dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; + const real_type z0 = r * cs / sn; + const real_type dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; const auto wj_local = wj(iatom, jnbor); - real sfac, dsfac; + real_type sfac, dsfac; compute_s_dsfac(r, rcut, sfac, dsfac); sfac *= wj_local; dsfac *= wj_local; - const auto rinv = static_cast(1.0) / r; + const auto rinv = static_cast(1.0) / r; const auto ux = x * rinv; const auto uy = y * rinv; const auto uz = z * rinv; - const auto r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + const auto r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); const complex a = { z0 * r0inv, -z * r0inv }; const complex b = { r0inv * y, -r0inv * x }; @@ -433,9 +433,9 @@ void SNAKokkos::compute_cayley_klein(const int& // we need to explicitly zero `dedr` somewhere before hitting // ComputeFusedDeidrj --- this is just a convenient place to do it. - dedr(iatom_mod + vector_length * iatom_div, jnbor, 0) = static_cast(0.); - dedr(iatom_mod + vector_length * iatom_div, jnbor, 1) = static_cast(0.); - dedr(iatom_mod + vector_length * iatom_div, jnbor, 2) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 0) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 1) = static_cast(0.); + dedr(iatom_mod + vector_length * iatom_div, jnbor, 2) = static_cast(0.); } @@ -445,9 +445,9 @@ void SNAKokkos::compute_cayley_klein(const int& advantage of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui(const int& iatom_mod, const int& j, const int& ielem, const int& iatom_div) +void SNAKokkos::pre_ui(const int& iatom_mod, const int& j, const int& ielem, const int& iatom_div) { for (int jelem = 0; jelem < nelements; jelem++) { @@ -459,11 +459,11 @@ void SNAKokkos::pre_ui(const int& iatom_mod, co for (int mb = 0; 2*mb <= j; mb++) { for (int ma = 0; ma <= j; ma++) { - real re_part = static_cast(0.); + real_type re_part = static_cast(0.); if (ma == mb && (!chem_flag || ielem == jelem || wselfall_flag)) { re_part = wself; } ulisttot_re_pack(iatom_mod, jju_half, jelem, iatom_div) = re_part; - ulisttot_im_pack(iatom_mod, jju_half, jelem, iatom_div) = static_cast(0.); + ulisttot_im_pack(iatom_mod, jju_half, jelem, iatom_div) = static_cast(0.); jju_half++; } @@ -477,9 +477,9 @@ void SNAKokkos::pre_ui(const int& iatom_mod, co accumulating to the total. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) +void SNAKokkos::compute_ui(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // utot(j,ma,mb) = 0 for all j,ma,ma @@ -496,7 +496,7 @@ void SNAKokkos::compute_ui(const typename Kokko const int scratch_shift = team_rank * tile_size; // extract and wrap - WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters @@ -532,7 +532,7 @@ void SNAKokkos::compute_ui(const typename Kokko const complex ulist_prev = ulist_wrapper.get(ma); // ulist_accum += rootpq * a.conj() * ulist_prev; - real rootpq = rootpqarray(j - ma, j - mb); + real_type rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); @@ -572,7 +572,7 @@ void SNAKokkos::compute_ui(const typename Kokko Kokkos::atomic_add(&(ulisttot_im_pack(iatom_mod, jjup + ma, jelem, iatom_div)), ulist_prev.im * sfac); // ulist_accum += rootpq * b * ulist_prev; - real rootpq = rootpqarray(j - ma, mb); + real_type rootpq = rootpqarray(j - ma, mb); ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); @@ -614,9 +614,9 @@ void SNAKokkos::compute_ui(const typename Kokko divergence. GPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) +void SNAKokkos::compute_zi(const int& iatom_mod, const int& jjz, const int& iatom_div) { const int j1 = idxz(jjz, 0); @@ -629,7 +629,7 @@ void SNAKokkos::compute_zi(const int& iatom_mod const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const real* cgblock = cglist.data() + idxcg_block(j1, j2, j); + const real_type* cgblock = cglist.data() + idxcg_block(j1, j2, j); int idouble = 0; @@ -688,9 +688,9 @@ void SNAKokkos::compute_zi(const int& iatom_mod divergence. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) +void SNAKokkos::compute_bi(const int& iatom_mod, const int& jjb, const int& iatom_div) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -751,10 +751,10 @@ void SNAKokkos::compute_bi(const int& iatom_mod const auto utot = ulisttot_pack(iatom_mod, jju_index, elem3, iatom_div); const auto zloc = zlist_pack(iatom_mod, jjz_index, idouble, iatom_div); - sumzu += static_cast(0.5) * (utot.re * zloc.re + utot.im * zloc.im); + sumzu += static_cast(0.5) * (utot.re * zloc.re + utot.im * zloc.im); } // end if jeven - sumzu *= static_cast(2.0); + sumzu *= static_cast(2.0); if (bzero_flag) { if (!wselfall_flag) { if (elem1 == elem2 && elem1 == elem3) { @@ -781,12 +781,12 @@ void SNAKokkos::compute_bi(const int& iatom_mod divergence. GPU version. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, - const Kokkos::View &beta_pack) +void SNAKokkos::compute_yi(int iatom_mod, int jjz, int iatom_div, + const Kokkos::View &beta_pack) { - real betaj; + real_type betaj; const int j1 = idxz(jjz, 0); const int j2 = idxz(jjz, 1); @@ -799,15 +799,15 @@ void SNAKokkos::compute_yi(int iatom_mod, int j const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real_type *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - real ztmp_r = 0.0; - real ztmp_i = 0.0; + real_type ztmp_r = 0.0; + real_type ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -888,9 +888,9 @@ void SNAKokkos::compute_yi(int iatom_mod, int j and accumulation into dEidRj. GPU only. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) +void SNAKokkos::compute_fused_deidrj(const typename Kokkos::TeamPolicy::member_type& team, const int iatom_mod, const int j_bend, const int jnbor, const int iatom_div) { // get shared memory offset // scratch size: 32 atoms * (twojmax+1) cached values, no double buffer @@ -900,8 +900,8 @@ void SNAKokkos::compute_fused_deidrj(const type const int scratch_shift = team_rank * tile_size; // extract, wrap shared memory buffer - WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); - WignerWrapper dulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper ulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); + WignerWrapper dulist_wrapper((complex*)team.team_shmem().get_shmem(team.team_size() * tile_size * sizeof(complex), 0) + scratch_shift, iatom_mod); // load parameters const auto a = a_pack(iatom_mod, jnbor, iatom_div); @@ -913,7 +913,7 @@ void SNAKokkos::compute_fused_deidrj(const type const int jelem = element(iatom_mod + vector_length * iatom_div, jnbor); - auto dedr_full_sum = static_cast(0.); + auto dedr_full_sum = static_cast(0.); // we need to "choose" when to bend // this for loop is here for context --- we expose additional @@ -944,7 +944,7 @@ void SNAKokkos::compute_fused_deidrj(const type const complex dulist_prev = dulist_wrapper.get(ma); // ulist_accum += rootpq * a.conj() * ulist_prev; - real rootpq = rootpqarray(j - ma, j - mb); + real_type rootpq = rootpqarray(j - ma, j - mb); ulist_accum.re += rootpq * (a.re * ulist_prev.re + a.im * ulist_prev.im); ulist_accum.im += rootpq * (a.re * ulist_prev.im - a.im * ulist_prev.re); @@ -996,7 +996,7 @@ void SNAKokkos::compute_fused_deidrj(const type const complex dulist_prev = dulist_wrapper.get(ma); // ulist_accum += rootpq * b * ulist_prev; - real rootpq = rootpqarray(j - ma, mb); + real_type rootpq = rootpqarray(j - ma, mb); ulist_accum.re += rootpq * (b.re * ulist_prev.re - b.im * ulist_prev.im); ulist_accum.im += rootpq * (b.re * ulist_prev.im + b.im * ulist_prev.re); @@ -1037,8 +1037,8 @@ void SNAKokkos::compute_fused_deidrj(const type // grab y_local early auto y_local = complex(ylist_pack_re(iatom_mod, jjup + ma, jelem, iatom_div), ylist_pack_im(iatom_mod, jjup+ma, jelem, iatom_div)); if (j % 2 == 1 && 2*(mb-1) == j-1) { // double check me... - if (ma == (mb-1)) { y_local = static_cast(0.5)*y_local; } - else if (ma > (mb-1)) { y_local.re = static_cast(0.); y_local.im = static_cast(0.); } // can probably avoid this outright + if (ma == (mb-1)) { y_local = static_cast(0.5)*y_local; } + else if (ma > (mb-1)) { y_local.re = static_cast(0.); y_local.im = static_cast(0.); } // can probably avoid this outright // else the ma < mb gets "double counted", cancelling the 0.5. } @@ -1053,7 +1053,7 @@ void SNAKokkos::compute_fused_deidrj(const type //} // end reference loop over j_bend // dedr gets zeroed out at the start of each iteration in compute_cayley_klein - Kokkos::atomic_add(&(dedr(iatom_mod + vector_length * iatom_div, jnbor, dir)), static_cast(2.0) * dedr_full_sum); + Kokkos::atomic_add(&(dedr(iatom_mod + vector_length * iatom_div, jnbor, dir)), static_cast(2.0) * dedr_full_sum); } @@ -1068,9 +1068,9 @@ void SNAKokkos::compute_fused_deidrj(const type advantage of the symmetry of the Wigner U matrices. * ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) +void SNAKokkos::pre_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, const int& iatom, const int& ielem) { for (int jelem = 0; jelem < nelements; jelem++) { for (int j = 0; j <= twojmax; j++) { @@ -1085,7 +1085,7 @@ void SNAKokkos::pre_ui_cpu(const typename Kokko // if m is on the "diagonal", initialize it with the self energy. // Otherwise zero it out - complex init(static_cast(0.),static_cast(0.)); + complex init(static_cast(0.),static_cast(0.)); if (m % (j+2) == 0 && (!chem_flag || ielem == jelem || wselfall_flag)) { init.re = wself; } //need to map iatom to element ulisttot(jjup, jelem, iatom) = init; @@ -1102,11 +1102,11 @@ void SNAKokkos::pre_ui_cpu(const typename Kokko data layout comments. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_ui_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - real rsq, r, x, y, z, z0, theta0; + real_type rsq, r, x, y, z, z0, theta0; // utot(j,ma,mb) = 0 for all j,ma,ma // utot(j,ma,ma) = 1 for all j,ma @@ -1132,9 +1132,9 @@ void SNAKokkos::compute_ui_cpu(const typename K compute Zi by summing over products of Ui, CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_zi_cpu(const int& iter) +void SNAKokkos::compute_zi_cpu(const int& iter) { const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1149,22 +1149,22 @@ void SNAKokkos::compute_zi_cpu(const int& iter) const int na = idxz(jjz, 7); const int nb = idxz(jjz, 8); - const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real_type *cgblock = cglist.data() + idxcg_block(j1,j2,j); int idouble = 0; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - zlist(jjz, idouble, iatom).re = static_cast(0.0); - zlist(jjz, idouble, iatom).im = static_cast(0.0); + zlist(jjz, idouble, iatom).re = static_cast(0.0); + zlist(jjz, idouble, iatom).im = static_cast(0.0); int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; int icgb = mb1min*(j2+1) + mb2max; for(int ib = 0; ib < nb; ib++) { - real suma1_r = static_cast(0.0); - real suma1_i = static_cast(0.0); + real_type suma1_r = static_cast(0.0); + real_type suma1_i = static_cast(0.0); int ma1 = ma1min; int ma2 = ma2max; @@ -1201,9 +1201,9 @@ void SNAKokkos::compute_zi_cpu(const int& iter) compute Bi by summing conj(Ui)*Zi, CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) +void SNAKokkos::compute_bi_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom) { // for j1 = 0,...,twojmax // for j2 = 0,twojmax @@ -1229,11 +1229,11 @@ void SNAKokkos::compute_bi_cpu(const typename K int jjz = idxz_block(j1, j2, j); int jju = idxu_block[j]; - real sumzu = static_cast(0.0); - real sumzu_temp = static_cast(0.0); + real_type sumzu = static_cast(0.0); + real_type sumzu_temp = static_cast(0.0); const int bound = (j+2)/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,(j+1)*bound), - [&] (const int mbma, real& sum) { + [&] (const int mbma, real_type& sum) { //for(int mb = 0; 2*mb < j; mb++) //for(int ma = 0; ma <= j; ma++) { const int ma = mbma % (j + 1); @@ -1252,7 +1252,7 @@ void SNAKokkos::compute_bi_cpu(const typename K if (j%2 == 0) { const int mb = j/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, mb), - [&] (const int ma, real& sum) { + [&] (const int ma, real_type& sum) { //for(int ma = 0; ma < mb; ma++) { const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; @@ -1265,13 +1265,13 @@ void SNAKokkos::compute_bi_cpu(const typename K const int ma = mb; const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; - sumzu += static_cast(0.5)* + sumzu += static_cast(0.5)* (ulisttot_full(jju_index, elem3, iatom).re * zlist(jjz_index, jalloy, iatom).re + ulisttot_full(jju_index, elem3, iatom).im * zlist(jjz_index, jalloy, iatom).im); } // end if jeven Kokkos::single(Kokkos::PerThread(team), [&] () { - sumzu *= static_cast(2.0); + sumzu *= static_cast(2.0); // apply bzero shift @@ -1303,12 +1303,12 @@ void SNAKokkos::compute_bi_cpu(const typename K CPU version ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_yi_cpu(int iter, - const Kokkos::View &beta) +void SNAKokkos::compute_yi_cpu(int iter, + const Kokkos::View &beta) { - real betaj; + real_type betaj; const int iatom = iter / idxz_max; const int jjz = iter % idxz_max; @@ -1323,15 +1323,15 @@ void SNAKokkos::compute_yi_cpu(int iter, const int nb = idxz(jjz, 8); const int jju_half = idxz(jjz, 9); - const real *cgblock = cglist.data() + idxcg_block(j1,j2,j); + const real_type *cgblock = cglist.data() + idxcg_block(j1,j2,j); //int mb = (2 * (mb1min+mb2max) - j1 - j2 + j) / 2; //int ma = (2 * (ma1min+ma2max) - j1 - j2 + j) / 2; for (int elem1 = 0; elem1 < nelements; elem1++) { for (int elem2 = 0; elem2 < nelements; elem2++) { - real ztmp_r = 0.0; - real ztmp_i = 0.0; + real_type ztmp_r = 0.0; + real_type ztmp_i = 0.0; int jju1 = idxu_block[j1] + (j1 + 1) * mb1min; int jju2 = idxu_block[j2] + (j2 + 1) * mb2max; @@ -1339,8 +1339,8 @@ void SNAKokkos::compute_yi_cpu(int iter, for (int ib = 0; ib < nb; ib++) { - real suma1_r = 0.0; - real suma1_i = 0.0; + real_type suma1_r = 0.0; + real_type suma1_i = 0.0; int ma1 = ma1min; int ma2 = ma2max; @@ -1411,19 +1411,19 @@ void SNAKokkos::compute_yi_cpu(int iter, data layout ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_duidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - real rsq, r, x, y, z, z0, theta0, cs, sn; - real dz0dr; + real_type rsq, r, x, y, z, z0, theta0, cs, sn; + real_type dz0dr; x = rij(iatom,jnbor,0); y = rij(iatom,jnbor,1); z = rij(iatom,jnbor,2); rsq = x * x + y * y + z * z; r = sqrt(rsq); - auto rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); + auto rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); theta0 = (r - rmin0) * rscale0; sincos_wrapper(theta0, &sn, &cs); z0 = r * cs / sn; @@ -1442,16 +1442,16 @@ void SNAKokkos::compute_duidrj_cpu(const typena ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) +void SNAKokkos::compute_deidrj_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor) { - t_scalar3 final_sum; + t_scalar3 final_sum; const int jelem = element(iatom, jnbor); //for(int j = 0; j <= twojmax; j++) { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,twojmax+1), - [&] (const int& j, t_scalar3& sum_tmp) { + [&] (const int& j, t_scalar3& sum_tmp) { int jju_half = idxu_half_block[j]; int jju_cache = idxu_cache_block[j]; @@ -1509,10 +1509,10 @@ void SNAKokkos::compute_deidrj_cpu(const typena of the symmetry of the Wigner U matrices. ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - const real& r, const real& wj, const real& rcut, int jelem) +void SNAKokkos::add_uarraytot(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real_type& r, const real_type& wj, const real_type& rcut, int jelem) { const auto sfac = compute_sfac(r, rcut) * wj; @@ -1539,18 +1539,18 @@ void SNAKokkos::add_uarraytot(const typename Ko information stored between layers via scratch memory on the GPU path ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - const real& x, const real& y, const real& z, const real& z0, const real& r) +void SNAKokkos::compute_uarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real_type& x, const real_type& y, const real_type& z, const real_type& z0, const real_type& r) { - real r0inv; - real a_r, b_r, a_i, b_i; - real rootpq; + real_type r0inv; + real_type a_r, b_r, a_i, b_i; + real_type rootpq; // compute Cayley-Klein parameters for unit quaternion - r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); a_r = r0inv * z0; a_i = -r0inv * z; b_r = r0inv * y; @@ -1630,23 +1630,23 @@ void SNAKokkos::compute_uarray_cpu(const typena Uses same cached data layout of ulist ------------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, - const real& x, const real& y, const real& z, - const real& z0, const real& r, const real& dz0dr, - const real& wj, const real& rcut) +void SNAKokkos::compute_duarray_cpu(const typename Kokkos::TeamPolicy::member_type& team, int iatom, int jnbor, + const real_type& x, const real_type& y, const real_type& z, + const real_type& z0, const real_type& r, const real_type& dz0dr, + const real_type& wj, const real_type& rcut) { - real r0inv; - real a_r, a_i, b_r, b_i; - real da_r[3], da_i[3], db_r[3], db_i[3]; - real dz0[3], dr0inv[3], dr0invdr; - real rootpq; + real_type r0inv; + real_type a_r, a_i, b_r, b_i; + real_type da_r[3], da_i[3], db_r[3], db_i[3]; + real_type dz0[3], dr0inv[3], dr0invdr; + real_type rootpq; - real rinv = 1.0 / r; - real ux = x * rinv; - real uy = y * rinv; - real uz = z * rinv; + real_type rinv = 1.0 / r; + real_type ux = x * rinv; + real_type uy = y * rinv; + real_type uz = z * rinv; r0inv = 1.0 / sqrt(r * r + z0 * z0); a_r = z0 * r0inv; @@ -1761,8 +1761,8 @@ void SNAKokkos::compute_duarray_cpu(const typen }); } - real sfac = compute_sfac(r, rcut); - real dsfac = compute_dsfac(r, rcut); + real_type sfac = compute_sfac(r, rcut); + real_type dsfac = compute_dsfac(r, rcut); sfac *= wj; dsfac *= wj; @@ -1796,9 +1796,9 @@ void SNAKokkos::compute_duarray_cpu(const typen factorial n, wrapper for precomputed table ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::factorial(int n) +double SNAKokkos::factorial(int n) { //if (n < 0 || n > nmaxfactorial) { // char str[128]; @@ -1813,8 +1813,8 @@ double SNAKokkos::factorial(int n) factorial n table, size SNA::nmaxfactorial+1 ------------------------------------------------------------------------- */ -template -const double SNAKokkos::nfac_table[] = { +template +const double SNAKokkos::nfac_table[] = { 1, 1, 2, @@ -1989,9 +1989,9 @@ const double SNAKokkos::nfac_table[] = { the function delta given by VMK Eq. 8.2(1) ------------------------------------------------------------------------- */ -template +template inline -double SNAKokkos::deltacg(int j1, int j2, int j) +double SNAKokkos::deltacg(int j1, int j2, int j) { double sfaccg = factorial((j1 + j2 + j) / 2 + 1); return sqrt(factorial((j1 + j2 - j) / 2) * @@ -2004,9 +2004,9 @@ double SNAKokkos::deltacg(int j1, int j2, int j the quasi-binomial formula VMK 8.2.1(3) ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_clebsch_gordan() +void SNAKokkos::init_clebsch_gordan() { auto h_cglist = Kokkos::create_mirror_view(cglist); @@ -2074,23 +2074,23 @@ void SNAKokkos::init_clebsch_gordan() the p = 0, q = 0 entries are allocated and skipped for convenience. ------------------------------------------------------------------------- */ -template +template inline -void SNAKokkos::init_rootpqarray() +void SNAKokkos::init_rootpqarray() { auto h_rootpqarray = Kokkos::create_mirror_view(rootpqarray); for (int p = 1; p <= twojmax; p++) for (int q = 1; q <= twojmax; q++) - h_rootpqarray(p,q) = static_cast(sqrt(static_cast(p)/q)); + h_rootpqarray(p,q) = static_cast(sqrt(static_cast(p)/q)); Kokkos::deep_copy(rootpqarray,h_rootpqarray); } /* ---------------------------------------------------------------------- */ -template +template inline -int SNAKokkos::compute_ncoeff() +int SNAKokkos::compute_ncoeff() { int ncount; @@ -2111,19 +2111,19 @@ int SNAKokkos::compute_ncoeff() /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -real SNAKokkos::compute_sfac(real r, real rcut) +real_type SNAKokkos::compute_sfac(real_type r, real_type rcut) { - constexpr real one = static_cast(1.0); - constexpr real zero = static_cast(0.0); - constexpr real onehalf = static_cast(0.5); + constexpr real_type one = static_cast(1.0); + constexpr real_type zero = static_cast(0.0); + constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return one; if (switch_flag == 1) { if(r <= rmin0) return one; else if(r > rcut) return zero; else { - auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return onehalf * (cos((r - rmin0) * rcutfac) + one); } } @@ -2132,37 +2132,37 @@ real SNAKokkos::compute_sfac(real r, real rcut) /* ---------------------------------------------------------------------- */ -template +template KOKKOS_INLINE_FUNCTION -real SNAKokkos::compute_dsfac(real r, real rcut) +real_type SNAKokkos::compute_dsfac(real_type r, real_type rcut) { - constexpr real zero = static_cast(0.0); - constexpr real onehalf = static_cast(0.5); + constexpr real_type zero = static_cast(0.0); + constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return zero; if (switch_flag == 1) { if(r <= rmin0) return zero; else if(r > rcut) return zero; else { - auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return -onehalf * sin((r - rmin0) * rcutfac) * rcutfac; } } return zero; } -template +template KOKKOS_INLINE_FUNCTION -void SNAKokkos::compute_s_dsfac(const real r, const real rcut, real& sfac, real& dsfac) { - constexpr real one = static_cast(1.0); - constexpr real zero = static_cast(0.0); - constexpr real onehalf = static_cast(0.5); +void SNAKokkos::compute_s_dsfac(const real_type r, const real_type rcut, real_type& sfac, real_type& dsfac) { + constexpr real_type one = static_cast(1.0); + constexpr real_type zero = static_cast(0.0); + constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) { sfac = zero; dsfac = zero; } else if (switch_flag == 1) { if (r <= rmin0) { sfac = one; dsfac = zero; } else if (r > rcut) { sfac = zero; dsfac = zero; } else { - const auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); - real sn, cs; + const auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); + real_type sn, cs; sincos_wrapper((r - rmin0) * rcutfac, &sn, &cs); // need to create a wrapper sfac = onehalf * (cs + one); dsfac = -onehalf * sn * rcutfac; @@ -2174,9 +2174,9 @@ void SNAKokkos::compute_s_dsfac(const real r, c /* ---------------------------------------------------------------------- */ // set direction of batched Duidrj -template +template KOKKOS_FORCEINLINE_FUNCTION -void SNAKokkos::set_dir(int dir_) { +void SNAKokkos::set_dir(int dir_) { dir = dir_; } @@ -2184,8 +2184,8 @@ void SNAKokkos::set_dir(int dir_) { memory usage of arrays ------------------------------------------------------------------------- */ -template -double SNAKokkos::memory_usage() +template +double SNAKokkos::memory_usage() { int jdimpq = twojmax + 2; int jdim = twojmax + 1; @@ -2193,48 +2193,48 @@ double SNAKokkos::memory_usage() bytes = 0; - bytes += jdimpq*jdimpq * sizeof(real); // pqarray - bytes += idxcg_max * sizeof(real); // cglist + bytes += jdimpq*jdimpq * sizeof(real_type); // pqarray + bytes += idxcg_max * sizeof(real_type); // cglist #ifdef LMP_KOKKOS_GPU if (!host_flag) { auto natom_pad = (natom+vector_length-1)/vector_length; - bytes += natom_pad * nmax * sizeof(real) * 2; // a_pack - bytes += natom_pad * nmax * sizeof(real) * 2; // b_pack - bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // da_pack - bytes += natom_pad * nmax * 3 * sizeof(real) * 2; // db_pack - bytes += natom_pad * nmax * 4 * sizeof(real); // sfac_pack + bytes += natom_pad * nmax * sizeof(real_type) * 2; // a_pack + bytes += natom_pad * nmax * sizeof(real_type) * 2; // b_pack + bytes += natom_pad * nmax * 3 * sizeof(real_type) * 2; // da_pack + bytes += natom_pad * nmax * 3 * sizeof(real_type) * 2; // db_pack + bytes += natom_pad * nmax * 4 * sizeof(real_type); // sfac_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_re_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ulisttot_im_pack - bytes += natom_pad * idxu_max * nelements * sizeof(real) * 2; // ulisttot_pack + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ulisttot_re_pack + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ulisttot_im_pack + bytes += natom_pad * idxu_max * nelements * sizeof(real_type) * 2; // ulisttot_pack - bytes += natom_pad * idxz_max * ndoubles * sizeof(real) * 2; // zlist_pack - bytes += natom_pad * idxb_max * ntriples * sizeof(real); // blist_pack + bytes += natom_pad * idxz_max * ndoubles * sizeof(real_type) * 2; // zlist_pack + bytes += natom_pad * idxb_max * ntriples * sizeof(real_type); // blist_pack - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_re - bytes += natom_pad * idxu_half_max * nelements * sizeof(real); // ylist_pack_im + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ylist_pack_re + bytes += natom_pad * idxu_half_max * nelements * sizeof(real_type); // ylist_pack_im } else { #endif - bytes += natom * nmax * idxu_cache_max * sizeof(real) * 2; // ulist - bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ulisttot - bytes += natom * idxu_max * nelements * sizeof(real) * 2; // ulisttot_full + bytes += natom * nmax * idxu_cache_max * sizeof(real_type) * 2; // ulist + bytes += natom * idxu_half_max * nelements * sizeof(real_type) * 2; // ulisttot + bytes += natom * idxu_max * nelements * sizeof(real_type) * 2; // ulisttot_full - bytes += natom * idxz_max * ndoubles * sizeof(real) * 2; // zlist - bytes += natom * idxb_max * ntriples * sizeof(real); // blist + bytes += natom * idxz_max * ndoubles * sizeof(real_type) * 2; // zlist + bytes += natom * idxb_max * ntriples * sizeof(real_type); // blist - bytes += natom * idxu_half_max * nelements * sizeof(real) * 2; // ylist + bytes += natom * idxu_half_max * nelements * sizeof(real_type) * 2; // ylist - bytes += natom * nmax * idxu_cache_max * 3 * sizeof(real) * 2; // dulist + bytes += natom * nmax * idxu_cache_max * 3 * sizeof(real_type) * 2; // dulist #ifdef LMP_KOKKOS_GPU } #endif - bytes += natom * nmax * 3 * sizeof(real); // dedr + bytes += natom * nmax * 3 * sizeof(real_type); // dedr bytes += jdim * jdim * jdim * sizeof(int); // idxcg_block bytes += jdim * sizeof(int); // idxu_block @@ -2247,12 +2247,12 @@ double SNAKokkos::memory_usage() bytes += idxz_max * 10 * sizeof(int); // idxz bytes += idxb_max * 3 * sizeof(int); // idxb - bytes += jdim * sizeof(real); // bzero + bytes += jdim * sizeof(real_type); // bzero - bytes += natom * nmax * 3 * sizeof(real); // rij - bytes += natom * nmax * sizeof(real); // inside - bytes += natom * nmax * sizeof(real); // wj - bytes += natom * nmax * sizeof(real); // rcutij + bytes += natom * nmax * 3 * sizeof(real_type); // rij + bytes += natom * nmax * sizeof(real_type); // inside + bytes += natom * nmax * sizeof(real_type); // wj + bytes += natom * nmax * sizeof(real_type); // rcutij return bytes; } From e42845799d045a3b788702f4eee4ee2dfbe048c2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 5 Jan 2021 15:42:35 -0500 Subject: [PATCH 186/187] more consistent formatting for conditionals and loops --- src/KOKKOS/atom_kokkos.h | 12 +-- src/KOKKOS/atom_vec_kokkos.h | 4 +- src/KOKKOS/memory_kokkos.h | 12 +-- src/KOKKOS/nbin_ssa_kokkos.h | 24 ++--- src/KOKKOS/pair_kokkos.h | 38 ++++---- src/KOKKOS/pair_snap_kokkos_impl.h | 4 +- src/KOKKOS/sna_kokkos_impl.h | 103 ++++++++++---------- src/MANYBODY/pair_eam_cd.h | 4 +- src/USER-CGDNA/mf_oxdna.h | 18 ++-- src/USER-DPD/random_external_state.h | 4 +- src/USER-MANIFOLD/manifold.h | 6 +- src/USER-MANIFOLD/manifold_factory.h | 4 +- src/USER-MISC/pair_ilp_graphene_hbn.h | 4 +- src/USER-MISC/pair_kolmogorov_crespi_full.h | 4 +- src/USER-MISC/pair_meam_spline.h | 12 +-- src/USER-MISC/pair_meam_sw_spline.h | 12 +-- src/USER-PTM/ptm_voronoi_cell.h | 6 +- src/math_eigen_impl.h | 60 ++++++------ 18 files changed, 163 insertions(+), 168 deletions(-) diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index 6eebbad661..b554442b37 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -100,18 +100,18 @@ struct SortFunctor { dest(i) = source(index(i)); } void operator()(const typename std::enable_if::type& i) { - for(int j=0; j < (int)source.extent(1); j++) + for (int j=0; j < (int)source.extent(1); j++) dest(i,j) = source(index(i),j); } void operator()(const typename std::enable_if::type& i) { - for(int j=0; j < (int)source.extent(1); j++) - for(int k=0; k < (int)source.extent(2); k++) + for (int j=0; j < (int)source.extent(1); j++) + for (int k=0; k < (int)source.extent(2); k++) dest(i,j,k) = source(index(i),j,k); } void operator()(const typename std::enable_if::type& i) { - for(int j=0; j < (int)source.extent(1); j++) - for(int k=0; k < (int)source.extent(2); k++) - for(int l=0; l < (int)source.extent(3); l++) + for (int j=0; j < (int)source.extent(1); j++) + for (int k=0; k < (int)source.extent(2); k++) + for (int l=0; l < (int)source.extent(3); l++) dest(i,j,k,l) = source(index(i),j,k,l); } }; diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 9fbf172535..f81b7715ad 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -178,7 +178,7 @@ class AtomVecKokkos : public AtomVec { } mirror_type tmp_view((typename ViewType::value_type*)buffer, src.d_view.layout()); - if(space == Device) { + if (space == Device) { Kokkos::deep_copy(LMPHostType(),tmp_view,src.h_view), Kokkos::deep_copy(LMPHostType(),src.d_view,tmp_view); src.clear_sync_state(); @@ -191,7 +191,7 @@ class AtomVecKokkos : public AtomVec { #else template void perform_async_copy(ViewType& src, unsigned int space) { - if(space == Device) + if (space == Device) src.template sync(); else src.template sync(); diff --git a/src/KOKKOS/memory_kokkos.h b/src/KOKKOS/memory_kokkos.h index 2f9e0cc375..445ecd87f2 100644 --- a/src/KOKKOS/memory_kokkos.h +++ b/src/KOKKOS/memory_kokkos.h @@ -92,7 +92,7 @@ void destroy_kokkos(TYPE data, typename TYPE::value_type* &array) template TYPE destroy_kokkos(TYPE &data) { - /*if(data.data()!=nullptr) + /*if (data.data()!=nullptr) free(data.data());*/ data = TYPE(); return data; @@ -173,7 +173,7 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, bigint n = 0; for (int i = 0; i < n1; i++) { - if(n2==0) + if (n2==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); @@ -194,7 +194,7 @@ template bigint n = 0; for (int i = 0; i < n1; i++) { - if(n2==0) + if (n2==0) array[i] = nullptr; else array[i] = &h_data(i,0); @@ -218,7 +218,7 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type**) srealloc(array,nbytes,name); for (int i = 0; i < n1; i++) - if(n2==0) + if (n2==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); @@ -235,7 +235,7 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - if(data.h_view.extent(1)==0) + if (data.h_view.extent(1)==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); @@ -255,7 +255,7 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - if(data.h_view.extent(1)==0) + if (data.h_view.extent(1)==0) array[i] = nullptr; else array[i] = &data.h_view(i,0); diff --git a/src/KOKKOS/nbin_ssa_kokkos.h b/src/KOKKOS/nbin_ssa_kokkos.h index cc98859913..a99e0d448c 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.h +++ b/src/KOKKOS/nbin_ssa_kokkos.h @@ -108,20 +108,20 @@ class NBinSSAKokkos : public NBinStandard { if (y >= subhi_[1]) iy = 1; if (x < sublo_[0]) ix = -1; if (x >= subhi_[0]) ix = 1; - if(iz < 0){ + if (iz < 0){ return -1; - } else if(iz == 0){ - if( iy<0 ) return -1; // bottom left/middle/right - if( (iy==0) && (ix<0) ) return -1; // left atoms - if( (iy==0) && (ix==0) ) return 0; // Locally owned atoms - if( (iy==0) && (ix>0) ) return 2; // Right atoms - if( (iy>0) && (ix==0) ) return 1; // Top-middle atoms - if( (iy>0) && (ix!=0) ) return 3; // Top-right and top-left atoms + } else if (iz == 0){ + if (iy<0) return -1; // bottom left/middle/right + if ((iy==0) && (ix<0) ) return -1; // left atoms + if ((iy==0) && (ix==0)) return 0; // Locally owned atoms + if ((iy==0) && (ix>0) ) return 2; // Right atoms + if ((iy>0) && (ix==0)) return 1; // Top-middle atoms + if ((iy>0) && (ix!=0)) return 3; // Top-right and top-left atoms } else { // iz > 0 - if((ix==0) && (iy==0)) return 4; // Back atoms - if((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms - if((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms - if((ix!=0) && (iy!=0)) return 7; // Back corner atoms + if ((ix==0) && (iy==0)) return 4; // Back atoms + if ((ix==0) && (iy!=0)) return 5; // Top-back and bottom-back atoms + if ((ix!=0) && (iy==0)) return 6; // Left-back and right-back atoms + if ((ix!=0) && (iy!=0)) return 7; // Back corner atoms } return -2; } diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index cb55dd3141..7dc3e33f74 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -144,7 +144,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const F_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -213,13 +213,13 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { F_FLOAT fpair = F_FLOAT(); - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) fpair+=factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); fxtmp += delx*fpair; @@ -236,11 +236,11 @@ struct PairComputeFunctor { F_FLOAT evdwl = 0.0; F_FLOAT ecoul = 0.0; if (c.eflag) { - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { evdwl = factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(rsq,i,j,itype,jtype,factor_coul,qtmp); ev.ecoul += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(rsq,i,j,itype,jtype); @@ -351,13 +351,13 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { F_FLOAT fpair = F_FLOAT(); - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) fpair+=factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); ftmp.x += delx*fpair; @@ -413,7 +413,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const F_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -510,13 +510,13 @@ struct PairComputeFunctor { const int jtype = c.type(j); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { F_FLOAT fpair = F_FLOAT(); - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) fpair+=factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); fev_tmp.f[0] += delx*fpair; @@ -526,11 +526,11 @@ struct PairComputeFunctor { F_FLOAT evdwl = 0.0; F_FLOAT ecoul = 0.0; if (c.eflag) { - if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { evdwl = factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); fev_tmp.evdwl += 0.5*evdwl; } - if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) { + if (rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) { ecoul = c.template compute_ecoul(rsq,i,j,itype,jtype,factor_coul,qtmp); fev_tmp.ecoul += 0.5*ecoul; } @@ -722,7 +722,7 @@ int GetTeamSize(FunctorStyle& KOKKOS_GPU_ARG(functor), int KOKKOS_GPU_ARG(inum), else team_size_max = Kokkos::TeamPolicy<>(inum,Kokkos::AUTO).team_size_max(functor,Kokkos::ParallelForTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; #else team_size = 1; @@ -743,7 +743,7 @@ EV_FLOAT pair_compute_neighlist (PairStyle* fpair, typename std::enable_if<(NEIG int vector_length = 8; int atoms_per_team = 32; - if(fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { PairComputeFunctor ff(fpair,list); atoms_per_team = GetTeamSize(ff, list->inum, (fpair->eflag || fpair->vflag), atoms_per_team, vector_length); Kokkos::TeamPolicy > policy(list->inum,atoms_per_team,vector_length); @@ -757,7 +757,7 @@ EV_FLOAT pair_compute_neighlist (PairStyle* fpair, typename std::enable_if<(NEIG else Kokkos::parallel_for(policy,ff); } } else { - if(fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { + if (fpair->atom->ntypes > MAX_TYPES_STACKPARAMS) { PairComputeFunctor ff(fpair,list); if (fpair->eflag || fpair->vflag) Kokkos::parallel_reduce(list->inum,ff,ev); else Kokkos::parallel_for(list->inum,ff); diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index da99cbd52a..cf4d5851b6 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -1323,7 +1323,7 @@ void PairSNAPKokkos::check_team_size_for(i team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelForTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; } @@ -1334,7 +1334,7 @@ void PairSNAPKokkos::check_team_size_reduc team_size_max = Kokkos::TeamPolicy(inum,Kokkos::AUTO).team_size_max(*this,Kokkos::ParallelReduceTag()); - if(team_size*vector_length > team_size_max) + if (team_size*vector_length > team_size_max) team_size = team_size_max/vector_length; } diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index 23c1670bd8..d7aabb22c8 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -67,7 +67,7 @@ SNAKokkos::SNAKokkos(real_type rfac0_in, auto h_bzero = Kokkos::create_mirror_view(bzero); double www = wself*wself*wself; - for(int j = 0; j <= twojmax; j++) + for (int j = 0; j <= twojmax; j++) if (bnorm_flag) h_bzero[j] = www; else @@ -95,9 +95,9 @@ void SNAKokkos::build_indexlist() auto h_idxcg_block = Kokkos::create_mirror_view(idxcg_block); int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { h_idxcg_block(j1,j2,j) = idxcg_count; for (int m1 = 0; m1 <= j1; m1++) for (int m2 = 0; m2 <= j2; m2++) @@ -114,10 +114,10 @@ void SNAKokkos::build_indexlist() int idxu_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { h_idxu_block[j] = idxu_count; - for(int mb = 0; mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) + for (int mb = 0; mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) idxu_count++; } idxu_max = idxu_count; @@ -128,10 +128,10 @@ void SNAKokkos::build_indexlist() auto h_idxu_half_block = Kokkos::create_mirror_view(idxu_half_block); int idxu_half_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { h_idxu_half_block[j] = idxu_half_count; - for(int mb = 0; 2*mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) + for (int mb = 0; 2*mb <= j; mb++) + for (int ma = 0; ma <= j; ma++) idxu_half_count++; } idxu_half_max = idxu_half_count; @@ -142,10 +142,10 @@ void SNAKokkos::build_indexlist() auto h_idxu_full_half = Kokkos::create_mirror_view(idxu_full_half); idxu_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { int jju_half = h_idxu_half_block[j]; - for(int mb = 0; mb <= j; mb++) { - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; mb <= j; mb++) { + for (int ma = 0; ma <= j; ma++) { FullHalfMapper mapper; if (2*mb <= j) { mapper.idxu_half = jju_half + mb * (j + 1) + ma; @@ -169,9 +169,9 @@ void SNAKokkos::build_indexlist() auto h_idxu_cache_block = Kokkos::create_mirror_view(idxu_cache_block); int idxu_cache_count = 0; - for(int j = 0; j <= twojmax; j++) { + for (int j = 0; j <= twojmax; j++) { h_idxu_cache_block[j] = idxu_cache_count; - for(int mb = 0; mb < ((j+3)/2); mb++) + for (int mb = 0; mb < ((j+3)/2); mb++) for (int ma = 0; ma <= j; ma++) idxu_cache_count++; } @@ -181,9 +181,9 @@ void SNAKokkos::build_indexlist() // index list for beta and B int idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) idxb_count++; idxb_max = idxb_count; @@ -191,9 +191,9 @@ void SNAKokkos::build_indexlist() auto h_idxb = Kokkos::create_mirror_view(idxb); idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) if (j >= j1) { h_idxb(idxb_count,0) = j1; h_idxb(idxb_count,1) = j2; @@ -208,9 +208,9 @@ void SNAKokkos::build_indexlist() auto h_idxb_block = Kokkos::create_mirror_view(idxb_block); idxb_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { if (j >= j1) { h_idxb_block(j1,j2,j) = idxb_count; idxb_count++; @@ -222,9 +222,9 @@ void SNAKokkos::build_indexlist() int idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) for (int mb = 0; 2*mb <= j; mb++) for (int ma = 0; ma <= j; ma++) idxz_count++; @@ -237,9 +237,9 @@ void SNAKokkos::build_indexlist() auto h_idxz_block = Kokkos::create_mirror_view(idxz_block); idxz_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { h_idxz_block(j1,j2,j) = idxz_count; // find right beta(ii,jjb) entry @@ -286,7 +286,7 @@ template inline void SNAKokkos::grow_rij(int newnatom, int newnmax) { - if(newnatom <= natom && newnmax <= nmax) return; + if (newnatom <= natom && newnmax <= nmax) return; natom = newnatom; nmax = newnmax; @@ -644,7 +644,7 @@ void SNAKokkos::compute_zi(const int& iato #ifdef LMP_KK_DEVICE_COMPILE #pragma unroll #endif - for(int ib = 0; ib < nb; ib++) { + for (int ib = 0; ib < nb; ib++) { int ma1 = ma1min; int ma2 = ma2max; @@ -653,7 +653,7 @@ void SNAKokkos::compute_zi(const int& iato #ifdef LMP_KK_DEVICE_COMPILE #pragma unroll #endif - for(int ia = 0; ia < na; ia++) { + for (int ia = 0; ia < na; ia++) { const auto utot1 = ulisttot_pack(iatom_mod, jju1+ma1, elem1, iatom_div); const auto utot2 = ulisttot_pack(iatom_mod, jju2+ma2, elem2, iatom_div); const auto cgcoeff_a = cgblock[icga]; @@ -717,8 +717,8 @@ void SNAKokkos::compute_bi(const int& iato double sumzu = 0.0; double sumzu_temp = 0.0; - for(int mb = 0; 2*mb < j; mb++) { - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb < j; mb++) { + for (int ma = 0; ma <= j; ma++) { const int jju_index = jju+mb*(j+1)+ma; const int jjz_index = jjz+mb*(j+1)+ma; if (2*mb == j) return; // I think we can remove this? @@ -734,7 +734,7 @@ void SNAKokkos::compute_bi(const int& iato sumzu_temp = 0.; const int mb = j/2; - for(int ma = 0; ma < mb; ma++) { + for (int ma = 0; ma < mb; ma++) { const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; @@ -1161,7 +1161,7 @@ void SNAKokkos::compute_zi_cpu(const int& int jju1 = idxu_block[j1] + (j1+1)*mb1min; int jju2 = idxu_block[j2] + (j2+1)*mb2max; int icgb = mb1min*(j2+1) + mb2max; - for(int ib = 0; ib < nb; ib++) { + for (int ib = 0; ib < nb; ib++) { real_type suma1_r = static_cast(0.0); real_type suma1_i = static_cast(0.0); @@ -1169,7 +1169,7 @@ void SNAKokkos::compute_zi_cpu(const int& int ma1 = ma1min; int ma2 = ma2max; int icga = ma1min * (j2 + 1) + ma2max; - for(int ia = 0; ia < na; ia++) { + for (int ia = 0; ia < na; ia++) { suma1_r += cgblock[icga] * (ulisttot_full(jju1+ma1, elem1, iatom).re * ulisttot_full(jju2+ma2, elem2, iatom).re - ulisttot_full(jju1+ma1, elem1, iatom).im * ulisttot_full(jju2+ma2, elem2, iatom).im); suma1_i += cgblock[icga] * (ulisttot_full(jju1+ma1, elem1, iatom).re * ulisttot_full(jju2+ma2, elem2, iatom).im + @@ -1222,7 +1222,6 @@ void SNAKokkos::compute_bi_cpu(const typen for (int elem3 = 0; elem3 < nelements; elem3++) { Kokkos::parallel_for(Kokkos::TeamThreadRange(team,idxb_max), [&] (const int& jjb) { - //for(int jjb = 0; jjb < idxb_max; jjb++) { const int j1 = idxb(jjb, 0); const int j2 = idxb(jjb, 1); const int j = idxb(jjb, 2); @@ -1234,8 +1233,6 @@ void SNAKokkos::compute_bi_cpu(const typen const int bound = (j+2)/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,(j+1)*bound), [&] (const int mbma, real_type& sum) { - //for(int mb = 0; 2*mb < j; mb++) - //for(int ma = 0; ma <= j; ma++) { const int ma = mbma % (j + 1); const int mb = mbma / (j + 1); const int jju_index = jju + mb * (j + 1) + ma; @@ -1253,7 +1250,6 @@ void SNAKokkos::compute_bi_cpu(const typen const int mb = j/2; Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, mb), [&] (const int ma, real_type& sum) { - //for(int ma = 0; ma < mb; ma++) { const int jju_index = jju+(mb-1)*(j+1)+(j+1)+ma; const int jjz_index = jjz+(mb-1)*(j+1)+(j+1)+ma; sum += @@ -1449,14 +1445,13 @@ void SNAKokkos::compute_deidrj_cpu(const t t_scalar3 final_sum; const int jelem = element(iatom, jnbor); - //for(int j = 0; j <= twojmax; j++) { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,twojmax+1), [&] (const int& j, t_scalar3& sum_tmp) { int jju_half = idxu_half_block[j]; int jju_cache = idxu_cache_block[j]; - for(int mb = 0; 2*mb < j; mb++) - for(int ma = 0; ma <= j; ma++) { + for (int mb = 0; 2*mb < j; mb++) + for (int ma = 0; ma <= j; ma++) { sum_tmp.x += dulist(jju_cache,iatom,jnbor,0).re * ylist(jju_half,jelem,iatom).re + dulist(jju_cache,iatom,jnbor,0).im * ylist(jju_half,jelem,iatom).im; sum_tmp.y += dulist(jju_cache,iatom,jnbor,1).re * ylist(jju_half,jelem,iatom).re + @@ -1471,7 +1466,7 @@ void SNAKokkos::compute_deidrj_cpu(const t if (j%2 == 0) { int mb = j/2; - for(int ma = 0; ma < mb; ma++) { + for (int ma = 0; ma < mb; ma++) { sum_tmp.x += dulist(jju_cache,iatom,jnbor,0).re * ylist(jju_half,jelem,iatom).re + dulist(jju_cache,iatom,jnbor,0).im * ylist(jju_half,jelem,iatom).im; sum_tmp.y += dulist(jju_cache,iatom,jnbor,1).re * ylist(jju_half,jelem,iatom).re + @@ -2015,9 +2010,9 @@ void SNAKokkos::init_clebsch_gordan() int ifac; int idxcg_count = 0; - for(int j1 = 0; j1 <= twojmax; j1++) - for(int j2 = 0; j2 <= j1; j2++) - for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { + for (int j1 = 0; j1 <= twojmax; j1++) + for (int j2 = 0; j2 <= j1; j2++) + for (int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { for (int m1 = 0; m1 <= j1; m1++) { aa2 = 2 * m1 - j1; @@ -2028,7 +2023,7 @@ void SNAKokkos::init_clebsch_gordan() bb2 = 2 * m2 - j2; m = (aa2 + bb2 + j) / 2; - if(m < 0 || m > j) { + if (m < 0 || m > j) { h_cglist[idxcg_count] = 0.0; idxcg_count++; continue; @@ -2120,8 +2115,8 @@ real_type SNAKokkos::compute_sfac(real_typ constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return one; if (switch_flag == 1) { - if(r <= rmin0) return one; - else if(r > rcut) return zero; + if (r <= rmin0) return one; + else if (r > rcut) return zero; else { auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return onehalf * (cos((r - rmin0) * rcutfac) + one); @@ -2140,8 +2135,8 @@ real_type SNAKokkos::compute_dsfac(real_ty constexpr real_type onehalf = static_cast(0.5); if (switch_flag == 0) return zero; if (switch_flag == 1) { - if(r <= rmin0) return zero; - else if(r > rcut) return zero; + if (r <= rmin0) return zero; + else if (r > rcut) return zero; else { auto rcutfac = static_cast(MY_PI) / (rcut - rmin0); return -onehalf * sin((r - rmin0) * rcutfac) * rcutfac; diff --git a/src/MANYBODY/pair_eam_cd.h b/src/MANYBODY/pair_eam_cd.h index 8f306d1019..4d938aad10 100644 --- a/src/MANYBODY/pair_eam_cd.h +++ b/src/MANYBODY/pair_eam_cd.h @@ -60,7 +60,7 @@ public: // Evaluates the h(x) polynomial for a given local concentration x. inline double evalH(double x) const { double v = 0.0; - for(int i = nhcoeff-1; i >= 1; i--) { + for (int i = nhcoeff-1; i >= 1; i--) { v = (v + hcoeff[i]) * x; } return v + hcoeff[0]; @@ -69,7 +69,7 @@ public: // Calculates the derivative of the h(x) polynomial. inline double evalHprime(double x) const { double v = 0.0; - for(int i = nhcoeff-1; i >= 2; i--) { + for (int i = nhcoeff-1; i >= 2; i--) { v = (v + (double)i * hcoeff[i]) * x; } return v + hcoeff[1]; diff --git a/src/USER-CGDNA/mf_oxdna.h b/src/USER-CGDNA/mf_oxdna.h index e4ed1bbd03..00df53234d 100644 --- a/src/USER-CGDNA/mf_oxdna.h +++ b/src/USER-CGDNA/mf_oxdna.h @@ -96,13 +96,13 @@ inline double MFOxdna::F2(double r, double k, double cut_0, double cut_lc, double b_lo, double b_hi, double cut_c) { - if(r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc){ return 0; } - else if(r < cut_lo){ + else if (r < cut_lo){ return k * b_lo * (cut_lc - r)*(cut_lc-r); } - else if(r < cut_hi){ + else if (r < cut_hi){ return k * 0.5 * ((r - cut_0)*(r-cut_0) - (cut_0 - cut_c)*(cut_0 - cut_c)); } else{ @@ -118,13 +118,13 @@ inline double MFOxdna::DF2(double r, double k, double cut_0, double cut_lc, double cut_hc, double cut_lo, double cut_hi, double b_lo, double b_hi) { - if(r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc){ return 0; } - else if(r < cut_lo){ + else if (r < cut_lo){ return 2*k * b_lo * (r - cut_lc); } - else if(r < cut_hi){ + else if (r < cut_hi){ return k * (r - cut_0); } else{ @@ -171,7 +171,7 @@ inline double MFOxdna::F4(double theta, double a, double theta_0, else if (dtheta > dtheta_ast) { return b * (dtheta-dtheta_c)*(dtheta-dtheta_c); } - else if(dtheta > -dtheta_ast) { + else if (dtheta > -dtheta_ast) { return 1 - a * dtheta*dtheta; } else { @@ -235,13 +235,13 @@ inline double MFOxdna::F5(double x, double a, double x_ast, inline double MFOxdna::DF5(double x, double a, double x_ast, double b, double x_c) { - if(x >= 0) { + if (x >= 0) { return 0.0; } else if (x > x_ast) { return -2 * a * x; } - else if(x > x_c) { + else if (x > x_c) { return 2 * b * (x-x_c); } else { diff --git a/src/USER-DPD/random_external_state.h b/src/USER-DPD/random_external_state.h index de017ee8bd..e7d11a5926 100644 --- a/src/USER-DPD/random_external_state.h +++ b/src/USER-DPD/random_external_state.h @@ -141,9 +141,9 @@ namespace random_external_state { // RNGs with k calls to genNextParallelState() LAMMPS_INLINE void es_init(es_RNG_t &serial_state, uint64_t seed) { - if(seed==0) seed = uint64_t(1318319); + if (seed==0) seed = uint64_t(1318319); serial_state = seed; - for(int i = 0; i < 17; i++) es_rand(serial_state); + for (int i = 0; i < 17; i++) es_rand(serial_state); } // Call genNextParallelState() once for each RNG to generate diff --git a/src/USER-MANIFOLD/manifold.h b/src/USER-MANIFOLD/manifold.h index 9adf7055c7..7c3197e161 100644 --- a/src/USER-MANIFOLD/manifold.h +++ b/src/USER-MANIFOLD/manifold.h @@ -77,17 +77,17 @@ namespace user_manifold { // Some utility functions that are templated, so I implement them // here in the header. template< unsigned int size > inline - double infnorm( double *vect ) + double infnorm(double *vect) { double largest = fabs( vect[0] ); - for( unsigned int i = 1; i < size; ++i ){ + for (unsigned int i = 1; i < size; ++i){ double c = fabs( vect[i] ); largest = ( c > largest ) ? c : largest; } return largest; } - inline double dot( double *a, double *b ){ + inline double dot(double *a, double *b){ return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; } diff --git a/src/USER-MANIFOLD/manifold_factory.h b/src/USER-MANIFOLD/manifold_factory.h index 1eac8bf644..cc23874eba 100644 --- a/src/USER-MANIFOLD/manifold_factory.h +++ b/src/USER-MANIFOLD/manifold_factory.h @@ -93,8 +93,8 @@ class manifold; void make_manifold_if( manifold **man_ptr, const char *name, LAMMPS *lmp, int narg, char **arg ) { - if( strcmp( m_type::type(), name ) == 0 ){ - if( *man_ptr == nullptr ){ + if ( strcmp( m_type::type(), name ) == 0 ){ + if ( *man_ptr == nullptr ){ *man_ptr = new m_type(lmp, narg, arg); } } diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.h b/src/USER-MISC/pair_ilp_graphene_hbn.h index 5ca8eb64a7..aadb792cad 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.h +++ b/src/USER-MISC/pair_ilp_graphene_hbn.h @@ -82,7 +82,7 @@ class PairILPGrapheneHBN : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {Tap = 0.0;} + if (r >= 1.0) {Tap = 0.0;} else { Tap = Tap_coeff[7] * r + Tap_coeff[6]; Tap = Tap * r + Tap_coeff[5]; @@ -101,7 +101,7 @@ class PairILPGrapheneHBN : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {dTap = 0.0;} + if (r >= 1.0) {dTap = 0.0;} else { dTap = 7.0*Tap_coeff[7] * r + 6.0*Tap_coeff[6]; dTap = dTap * r + 5.0*Tap_coeff[5]; diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.h b/src/USER-MISC/pair_kolmogorov_crespi_full.h index c579788110..f7d9237be4 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.h +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.h @@ -84,7 +84,7 @@ class PairKolmogorovCrespiFull : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {Tap = 0.0;} + if (r >= 1.0) {Tap = 0.0;} else{ Tap = Tap_coeff[7] * r + Tap_coeff[6]; Tap = Tap * r + Tap_coeff[5]; @@ -104,7 +104,7 @@ class PairKolmogorovCrespiFull : public Pair { double Tap_coeff[8] = {1.0,0.0,0.0,0.0,-35.0,84.0,-70.0,20.0}; r = r_ij/Rcut; - if(r >= 1.0) {dTap = 0.0;} + if (r >= 1.0) {dTap = 0.0;} else { dTap = 7.0*Tap_coeff[7] * r + 6.0*Tap_coeff[6]; dTap = dTap * r + 5.0*Tap_coeff[5]; diff --git a/src/USER-MISC/pair_meam_spline.h b/src/USER-MISC/pair_meam_spline.h index 31be826d0d..d1dc5064f5 100644 --- a/src/USER-MISC/pair_meam_spline.h +++ b/src/USER-MISC/pair_meam_spline.h @@ -118,10 +118,10 @@ protected: inline double eval(double x) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. return Y[N-1] + derivN * (x - xmax_shifted); } else { @@ -131,7 +131,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; @@ -156,11 +156,11 @@ protected: inline double eval(double x, double& deriv) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. deriv = deriv0; return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. deriv = derivN; return Y[N-1] + derivN * (x - xmax_shifted); } @@ -171,7 +171,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; diff --git a/src/USER-MISC/pair_meam_sw_spline.h b/src/USER-MISC/pair_meam_sw_spline.h index 1fd59b34a5..7b40d123ed 100644 --- a/src/USER-MISC/pair_meam_sw_spline.h +++ b/src/USER-MISC/pair_meam_sw_spline.h @@ -106,10 +106,10 @@ protected: inline double eval(double x) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. return Y[N-1] + derivN * (x - xmax_shifted); } else { @@ -119,7 +119,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; @@ -144,11 +144,11 @@ protected: inline double eval(double x, double& deriv) const { x -= xmin; - if(x <= 0.0) { // Left extrapolation. + if (x <= 0.0) { // Left extrapolation. deriv = deriv0; return Y[0] + deriv0 * x; } - else if(x >= xmax_shifted) { // Right extrapolation. + else if (x >= xmax_shifted) { // Right extrapolation. deriv = derivN; return Y[N-1] + derivN * (x - xmax_shifted); } @@ -159,7 +159,7 @@ protected: int khi = N-1; while(khi - klo > 1) { int k = (khi + klo) / 2; - if(Xs[k] > x) khi = k; + if (Xs[k] > x) khi = k; else klo = k; } double h = Xs[khi] - Xs[klo]; diff --git a/src/USER-PTM/ptm_voronoi_cell.h b/src/USER-PTM/ptm_voronoi_cell.h index 69e3b5bdc4..138f290c42 100644 --- a/src/USER-PTM/ptm_voronoi_cell.h +++ b/src/USER-PTM/ptm_voronoi_cell.h @@ -328,12 +328,12 @@ class voronoicell_neighbor : public voronoicell_base { inline void n_allocate(int i,int m) {mne[i]=new int[m*i];} inline void n_add_memory_vertices(int i) { int **pp=new int*[i]; - for(int j=0;j l2_norm(const std::vector& vec) { template inline void scalar_mul(T1 a, std::vector& vec) { int n = vec.size(); - for(int i = 0;i < n;i++) + for (int i = 0;i < n;i++) vec[i] *= a; } @@ -465,7 +465,7 @@ inline void normalize(std::vector& vec) { template inline real_t l1_norm(const std::vector& vec) { real_t norm = real_t(); // Zero initialization - for(const T& element : vec) + for (const T& element : vec) norm += std::abs(element); return norm; } @@ -746,7 +746,7 @@ template int Jacobi:: MaxEntryRow(Scalar const *const *M, int i) const { int j_max = i+1; - for(int j = i+2; j < n; j++) + for (int j = i+2; j < n; j++) if (std::abs(M[i][j]) > std::abs(M[i][j_max])) j_max = j; return j_max; @@ -963,9 +963,9 @@ run(real_t& eigvalue, std::vector& eigvec) const pev = std::numeric_limits>::max(); int itern = this->max_iteration; - for(int k = 1;k <= this->max_iteration;k++) { + for (int k = 1;k <= this->max_iteration;k++) { // vk = (A + offset*E)uk, here E is the identity matrix - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { vk[i] = uk[i]*this->eigenvalue_offset; } this->mv_mul(uk, vk); @@ -984,7 +984,7 @@ run(real_t& eigvalue, std::vector& eigvec) const alpha.push_back(alphak); - for(int i = 0;i < n; i++) { + for (int i = 0;i < n; i++) { uk[i] = vk[i] - betak*u[k-1][i] - alphak*u[k][i]; } @@ -993,14 +993,14 @@ run(real_t& eigvalue, std::vector& eigvec) const betak = l2_norm(uk); beta.push_back(betak); - if(this->find_maximum) { + if (this->find_maximum) { ev = find_maximum_eigenvalue(alpha, beta); } else { ev = find_minimum_eigenvalue(alpha, beta); } const real_t zero_threshold = minimum_effective_decimal>()*1e-1; - if(betak < zero_threshold) { + if (betak < zero_threshold) { u.push_back(uk); // This element will never be accessed, // but this "push" guarantees u to always have one more element than @@ -1012,7 +1012,7 @@ run(real_t& eigvalue, std::vector& eigvec) const normalize(uk); u.push_back(uk); - if(abs(ev-pev) < std::min(abs(ev), abs(pev))*this->eps) { + if (abs(ev-pev) < std::min(abs(ev), abs(pev))*this->eps) { itern = k; break; } else { @@ -1030,18 +1030,18 @@ run(real_t& eigvalue, std::vector& eigvec) const beta[m-1] = 0.0; - if(eigvec.size() < n) { + if (eigvec.size() < n) { eigvec.resize(n); } - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { eigvec[i] = cv[m-1]*u[m-1][i]; } - for(int k = m-2;k >= 1;k--) { + for (int k = m-2;k >= 1;k--) { cv[k] = ((ev - alpha[k+1])*cv[k+1] - beta[k+1]*cv[k+2])/beta[k]; - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { eigvec[i] += cv[k]*u[k][i]; } } @@ -1062,9 +1062,9 @@ schmidt_orth(std::vector& uorth, const std::vector>& u) int n = uorth.size(); - for(int k = 0;k < u.size();k++) { + for (int k = 0;k < u.size();k++) { T innprod = inner_prod(uorth, u[k]); - for(int i = 0;i < n;i++) + for (int i = 0;i < n;i++) uorth[i] -= innprod * u[k][i]; } } @@ -1083,16 +1083,16 @@ find_minimum_eigenvalue(const std::vector>& alpha, real_t mid; int nmid; // Number of eigenvalues smaller than the "mid" - while(upper-lower > std::min(abs(lower), abs(upper))*eps) { + while (upper-lower > std::min(abs(lower), abs(upper))*eps) { mid = (lower+upper)/2.0; nmid = num_of_eigs_smaller_than(mid, alpha, beta); - if(nmid >= 1) { + if (nmid >= 1) { upper = mid; } else { lower = mid; } - if(mid == pmid) { + if (mid == pmid) { break; // This avoids an infinite loop due to zero matrix } pmid = mid; @@ -1119,17 +1119,17 @@ find_maximum_eigenvalue(const std::vector>& alpha, // triangular matrix, which equals the rank of it - while(upper-lower > std::min(abs(lower), abs(upper))*eps) { + while (upper-lower > std::min(abs(lower), abs(upper))*eps) { mid = (lower+upper)/2.0; nmid = num_of_eigs_smaller_than(mid, alpha, beta); - if(nmid < m) { + if (nmid < m) { lower = mid; } else { upper = mid; } - if(mid == pmid) { + if (mid == pmid) { break; // This avoids an infinite loop due to zero matrix } pmid = mid; @@ -1173,12 +1173,12 @@ num_of_eigs_smaller_than(real_t c, int count = 0; int m = alpha.size(); - for(int i = 1;i < m;i++){ + for (int i = 1;i < m;i++){ q_i = alpha[i] - c - beta[i-1]*beta[i-1]/q_i; - if(q_i < 0){ + if (q_i < 0){ count++; } - if(q_i == 0){ + if (q_i == 0){ q_i = minimum_effective_decimal>(); } } @@ -1271,7 +1271,7 @@ init(std::vector& v) std::uniform_real_distribution rand((T)(-1.0), (T)(1.0)); int n = v.size(); - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { v[i] = rand(mt); } @@ -1288,7 +1288,7 @@ init(std::vector>& v) std::uniform_real_distribution rand((T)(-1.0), (T)(1.0)); int n = v.size(); - for(int i = 0;i < n;i++) { + for (int i = 0;i < n;i++) { v[i] = std::complex(rand(mt), rand(mt)); } @@ -1319,14 +1319,14 @@ PrincipalEigen(ConstMatrix matrix, { //assert(n > 0); auto matmul = [&](const std::vector& in, std::vector& out) { - for(int i = 0; i < n; i++) { - for(int j = 0; j < n; j++) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { out[i] += matrix[i][j]*in[j]; } } }; auto init_vec = [&](std::vector& vec) { - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) vec[i] = 0.0; vec[0] = 1.0; }; From cf841e99c4eada564dc18adfd3c634201b09b694 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 5 Jan 2021 15:45:52 -0500 Subject: [PATCH 187/187] change '){' tp ') {' --- src/KOKKOS/atom_kokkos.h | 8 ++++---- src/KOKKOS/compute_temp_kokkos.h | 2 +- src/KOKKOS/fix_langevin_kokkos.h | 4 ++-- src/KOKKOS/fix_qeq_reax_kokkos.h | 4 ++-- src/KOKKOS/fix_setforce_kokkos.h | 2 +- src/KOKKOS/fix_shardlow_kokkos.h | 4 ++-- src/KOKKOS/kokkos_type.h | 4 ++-- src/KOKKOS/min_linesearch_kokkos.h | 2 +- src/KOKKOS/nbin_ssa_kokkos.h | 4 ++-- src/KOKKOS/pair_buck_coul_cut_kokkos.h | 4 ++-- src/KOKKOS/pair_buck_coul_long_kokkos.h | 4 ++-- src/KOKKOS/pair_buck_kokkos.h | 4 ++-- src/KOKKOS/pair_coul_cut_kokkos.h | 4 ++-- src/KOKKOS/pair_coul_debye_kokkos.h | 4 ++-- src/KOKKOS/pair_coul_long_kokkos.h | 4 ++-- src/KOKKOS/pair_dpd_fdt_energy_kokkos.h | 4 ++-- src/KOKKOS/pair_kokkos.h | 8 ++++---- src/KOKKOS/pair_lj_class2_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_cut_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_expand_kokkos.h | 4 ++-- .../pair_lj_gromacs_coul_gromacs_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_gromacs_kokkos.h | 4 ++-- src/KOKKOS/pair_lj_sdk_kokkos.h | 4 ++-- src/KOKKOS/pair_morse_kokkos.h | 4 ++-- src/KOKKOS/pair_reaxc_kokkos.h | 20 +++++++++---------- src/KOKKOS/pair_snap_kokkos_impl.h | 4 ++-- src/KOKKOS/pair_tersoff_kokkos.h | 4 ++-- src/KOKKOS/pair_tersoff_mod_kokkos.h | 4 ++-- src/KOKKOS/pair_tersoff_zbl_kokkos.h | 4 ++-- src/KOKKOS/pair_yukawa_kokkos.h | 4 ++-- src/KOKKOS/sna_kokkos_impl.h | 2 +- src/KSPACE/pair_coul_msm.h | 2 +- src/USER-CGDNA/mf_oxdna.h | 12 +++++------ src/USER-EFF/pair_eff_inline.h | 2 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.h | 2 +- src/USER-MANIFOLD/manifold.h | 16 +++++++-------- src/USER-MANIFOLD/manifold_cylinder.h | 10 +++++----- src/USER-MANIFOLD/manifold_cylinder_dent.h | 10 +++++----- src/USER-MANIFOLD/manifold_dumbbell.h | 10 +++++----- src/USER-MANIFOLD/manifold_ellipsoid.h | 10 +++++----- src/USER-MANIFOLD/manifold_factory.h | 6 +++--- src/USER-MANIFOLD/manifold_gaussian_bump.h | 4 ++-- src/USER-MANIFOLD/manifold_plane.h | 10 +++++----- src/USER-MANIFOLD/manifold_plane_wiggle.h | 10 +++++----- src/USER-MANIFOLD/manifold_sphere.h | 12 +++++------ src/USER-MANIFOLD/manifold_spine.h | 14 ++++++------- src/USER-MANIFOLD/manifold_supersphere.h | 12 +++++------ src/USER-MANIFOLD/manifold_thylakoid.h | 8 ++++---- src/USER-MANIFOLD/manifold_thylakoid_shared.h | 4 ++-- src/USER-MANIFOLD/manifold_torus.h | 10 +++++----- src/USER-UEF/compute_pressure_uef.h | 2 +- src/USER-UEF/compute_temp_uef.h | 2 +- src/USER-UEF/dump_cfg_uef.h | 2 +- src/USER-UEF/fix_nvt_uef.h | 2 +- 54 files changed, 156 insertions(+), 156 deletions(-) diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index b554442b37..c875817a70 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -83,16 +83,16 @@ struct SortFunctor { ViewType source; Kokkos::View dest; IndexView index; - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0)); } - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0),src.extent(1)); } - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0),src.extent(1),src.extent(2)); } - SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind){ + SortFunctor(ViewType src, typename std::enable_if::type ind):source(src),index(ind) { dest = Kokkos::View("",src.extent(0),src.extent(1),src.extent(2),src.extent(3)); } KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/compute_temp_kokkos.h b/src/KOKKOS/compute_temp_kokkos.h index 7f116f7120..555881869d 100644 --- a/src/KOKKOS/compute_temp_kokkos.h +++ b/src/KOKKOS/compute_temp_kokkos.h @@ -34,7 +34,7 @@ namespace LAMMPS_NS { t0 = t1 = t2 = t3 = t4 = t5 = 0.0; } KOKKOS_INLINE_FUNCTION - s_CTEMP& operator+=(const s_CTEMP &rhs){ + s_CTEMP& operator+=(const s_CTEMP &rhs) { t0 += rhs.t0; t1 += rhs.t1; t2 += rhs.t2; diff --git a/src/KOKKOS/fix_langevin_kokkos.h b/src/KOKKOS/fix_langevin_kokkos.h index 034e4eaa8f..411adc2219 100644 --- a/src/KOKKOS/fix_langevin_kokkos.h +++ b/src/KOKKOS/fix_langevin_kokkos.h @@ -36,7 +36,7 @@ namespace LAMMPS_NS { fx = fy = fz = 0.0; } KOKKOS_INLINE_FUNCTION - s_FSUM& operator+=(const s_FSUM &rhs){ + s_FSUM& operator+=(const s_FSUM &rhs) { fx += rhs.fx; fy += rhs.fy; fz += rhs.fz; @@ -175,7 +175,7 @@ namespace LAMMPS_NS { FixLangevinKokkosPostForceFunctor(FixLangevinKokkos* c_ptr): c(*c_ptr) {} - ~FixLangevinKokkosPostForceFunctor(){c.cleanup_copy();} + ~FixLangevinKokkosPostForceFunctor() {c.cleanup_copy();} KOKKOS_INLINE_FUNCTION void operator()(const int i) const { diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.h b/src/KOKKOS/fix_qeq_reax_kokkos.h index cc9bff3652..bbfeb00266 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.h +++ b/src/KOKKOS/fix_qeq_reax_kokkos.h @@ -147,9 +147,9 @@ class FixQEqReaxKokkos : public FixQEqReax, public KokkosBase { struct params_qeq{ KOKKOS_INLINE_FUNCTION - params_qeq(){chi=0;eta=0;gamma=0;}; + params_qeq() {chi=0;eta=0;gamma=0;}; KOKKOS_INLINE_FUNCTION - params_qeq(int /*i*/){chi=0;eta=0;gamma=0;}; + params_qeq(int /*i*/) {chi=0;eta=0;gamma=0;}; F_FLOAT chi, eta, gamma; }; diff --git a/src/KOKKOS/fix_setforce_kokkos.h b/src/KOKKOS/fix_setforce_kokkos.h index ecbfd71e36..709d31279b 100644 --- a/src/KOKKOS/fix_setforce_kokkos.h +++ b/src/KOKKOS/fix_setforce_kokkos.h @@ -34,7 +34,7 @@ struct s_double_3 { d0 = d1 = d2 = 0.0; } KOKKOS_INLINE_FUNCTION - s_double_3& operator+=(const s_double_3 &rhs){ + s_double_3& operator+=(const s_double_3 &rhs) { d0 += rhs.d0; d1 += rhs.d1; d2 += rhs.d2; diff --git a/src/KOKKOS/fix_shardlow_kokkos.h b/src/KOKKOS/fix_shardlow_kokkos.h index d5541ac5b7..1d11de0fcb 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.h +++ b/src/KOKKOS/fix_shardlow_kokkos.h @@ -62,9 +62,9 @@ class FixShardlowKokkos : public FixShardlow { struct params_ssa { KOKKOS_INLINE_FUNCTION - params_ssa(){cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; + params_ssa() {cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; KOKKOS_INLINE_FUNCTION - params_ssa(int /*i*/){cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; + params_ssa(int /*i*/) {cutinv=FLT_MAX;halfsigma=0;kappa=0;alpha=0;}; F_FLOAT cutinv,halfsigma,kappa,alpha; }; diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index fbe9799bee..7050af80fc 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1068,9 +1068,9 @@ void memset_kokkos (ViewType &view) { struct params_lj_coul { KOKKOS_INLINE_FUNCTION - params_lj_coul(){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj_coul() {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_lj_coul(int /*i*/){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj_coul(int /*i*/) {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; F_FLOAT cut_ljsq,cut_coulsq,lj1,lj2,lj3,lj4,offset; }; diff --git a/src/KOKKOS/min_linesearch_kokkos.h b/src/KOKKOS/min_linesearch_kokkos.h index 43336335b1..5439a93932 100644 --- a/src/KOKKOS/min_linesearch_kokkos.h +++ b/src/KOKKOS/min_linesearch_kokkos.h @@ -25,7 +25,7 @@ namespace LAMMPS_NS { d0 = d1 = 0.0; } KOKKOS_INLINE_FUNCTION - s_double2& operator+=(const s_double2 &rhs){ + s_double2& operator+=(const s_double2 &rhs) { d0 += rhs.d0; d1 += rhs.d1; return *this; diff --git a/src/KOKKOS/nbin_ssa_kokkos.h b/src/KOKKOS/nbin_ssa_kokkos.h index a99e0d448c..c9a389bed4 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.h +++ b/src/KOKKOS/nbin_ssa_kokkos.h @@ -108,9 +108,9 @@ class NBinSSAKokkos : public NBinStandard { if (y >= subhi_[1]) iy = 1; if (x < sublo_[0]) ix = -1; if (x >= subhi_[0]) ix = 1; - if (iz < 0){ + if (iz < 0) { return -1; - } else if (iz == 0){ + } else if (iz == 0) { if (iy<0) return -1; // bottom left/middle/right if ((iy==0) && (ix<0) ) return -1; // left atoms if ((iy==0) && (ix==0)) return 0; // Locally owned atoms diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.h b/src/KOKKOS/pair_buck_coul_cut_kokkos.h index ca843df2d4..683cb37310 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.h +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.h @@ -46,9 +46,9 @@ class PairBuckCoulCutKokkos : public PairBuckCoulCut { struct params_buck_coul{ KOKKOS_INLINE_FUNCTION - params_buck_coul(){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul() {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_buck_coul(int /*i*/){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul(int /*i*/) {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; F_FLOAT cut_ljsq,cut_coulsq,a,c,rhoinv,buck1,buck2,offset; }; diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.h b/src/KOKKOS/pair_buck_coul_long_kokkos.h index 1cb407776c..c383a64081 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.h +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.h @@ -47,9 +47,9 @@ class PairBuckCoulLongKokkos : public PairBuckCoulLong { struct params_buck_coul{ KOKKOS_INLINE_FUNCTION - params_buck_coul(){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul() {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_buck_coul(int /*i*/){cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck_coul(int /*i*/) {cut_ljsq=0;cut_coulsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; F_FLOAT cut_ljsq,cut_coulsq,a,c,rhoinv,buck1,buck2,offset; }; diff --git a/src/KOKKOS/pair_buck_kokkos.h b/src/KOKKOS/pair_buck_kokkos.h index ed23bf6a5b..8bd8fc9ffe 100644 --- a/src/KOKKOS/pair_buck_kokkos.h +++ b/src/KOKKOS/pair_buck_kokkos.h @@ -45,9 +45,9 @@ class PairBuckKokkos : public PairBuck { struct params_buck{ KOKKOS_INLINE_FUNCTION - params_buck(){cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck() {cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_buck(int /*i*/){cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; + params_buck(int /*i*/) {cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; F_FLOAT cutsq,a,c,rhoinv,buck1,buck2,offset; }; diff --git a/src/KOKKOS/pair_coul_cut_kokkos.h b/src/KOKKOS/pair_coul_cut_kokkos.h index d525422d2f..6fb5334cb4 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.h +++ b/src/KOKKOS/pair_coul_cut_kokkos.h @@ -46,9 +46,9 @@ class PairCoulCutKokkos : public PairCoulCut { struct params_coul{ KOKKOS_INLINE_FUNCTION - params_coul(){cutsq=0,scale=0;}; + params_coul() {cutsq=0,scale=0;}; KOKKOS_INLINE_FUNCTION - params_coul(int /*i*/){cutsq=0,scale=0;}; + params_coul(int /*i*/) {cutsq=0,scale=0;}; F_FLOAT cutsq, scale; }; diff --git a/src/KOKKOS/pair_coul_debye_kokkos.h b/src/KOKKOS/pair_coul_debye_kokkos.h index 900613aaa0..b5dc2eaed4 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.h +++ b/src/KOKKOS/pair_coul_debye_kokkos.h @@ -46,9 +46,9 @@ class PairCoulDebyeKokkos : public PairCoulDebye { struct params_coul{ KOKKOS_INLINE_FUNCTION - params_coul(){cutsq=0,scale=0;}; + params_coul() {cutsq=0,scale=0;}; KOKKOS_INLINE_FUNCTION - params_coul(int /*i*/){cutsq=0,scale=0;}; + params_coul(int /*i*/) {cutsq=0,scale=0;}; F_FLOAT cutsq, scale; }; diff --git a/src/KOKKOS/pair_coul_long_kokkos.h b/src/KOKKOS/pair_coul_long_kokkos.h index 590ab191a4..11847bc25c 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.h +++ b/src/KOKKOS/pair_coul_long_kokkos.h @@ -47,9 +47,9 @@ class PairCoulLongKokkos : public PairCoulLong { struct params_coul{ KOKKOS_INLINE_FUNCTION - params_coul(){cut_coulsq=0;}; + params_coul() {cut_coulsq=0;}; KOKKOS_INLINE_FUNCTION - params_coul(int /*i*/){cut_coulsq=0;}; + params_coul(int /*i*/) {cut_coulsq=0;}; F_FLOAT cut_coulsq; }; diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h index b6cf65976d..250a318568 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.h @@ -88,9 +88,9 @@ class PairDPDfdtEnergyKokkos : public PairDPDfdtEnergy { struct params_dpd { KOKKOS_INLINE_FUNCTION - params_dpd(){cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; + params_dpd() {cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; KOKKOS_INLINE_FUNCTION - params_dpd(int /*i*/){cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; + params_dpd(int /*i*/) {cut=0;a0=0;sigma=0;kappa=0;alpha=0;}; F_FLOAT cut,a0,sigma,kappa,alpha; }; diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index 7dc3e33f74..a3b31f54cc 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -305,7 +305,7 @@ struct PairComputeFunctor { },fsum); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fsum.x; f(i,1) += fsum.y; f(i,2) += fsum.z; @@ -366,7 +366,7 @@ struct PairComputeFunctor { } },fsum); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fsum.x; f(i,1) += fsum.y; f(i,2) += fsum.z; @@ -437,7 +437,7 @@ struct PairComputeFunctor { } },fev); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fev.f[0]; f(i,1) += fev.f[1]; f(i,2) += fev.f[2]; @@ -546,7 +546,7 @@ struct PairComputeFunctor { } },fev); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { f(i,0) += fev.f[0]; f(i,1) += fev.f[1]; f(i,2) += fev.f[2]; diff --git a/src/KOKKOS/pair_lj_class2_kokkos.h b/src/KOKKOS/pair_lj_class2_kokkos.h index 8c40599f95..4be6c40667 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.h +++ b/src/KOKKOS/pair_lj_class2_kokkos.h @@ -46,9 +46,9 @@ class PairLJClass2Kokkos : public PairLJClass2 { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset; }; diff --git a/src/KOKKOS/pair_lj_cut_kokkos.h b/src/KOKKOS/pair_lj_cut_kokkos.h index 1bb0421b4a..557a28b698 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.h +++ b/src/KOKKOS/pair_lj_cut_kokkos.h @@ -46,9 +46,9 @@ class PairLJCutKokkos : public PairLJCut { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset; }; diff --git a/src/KOKKOS/pair_lj_expand_kokkos.h b/src/KOKKOS/pair_lj_expand_kokkos.h index d6a860690a..ef288dcfe3 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.h +++ b/src/KOKKOS/pair_lj_expand_kokkos.h @@ -46,9 +46,9 @@ class PairLJExpandKokkos : public PairLJExpand { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;shift=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset,shift; }; diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h index fd4511c519..88dbf28699 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.h @@ -47,9 +47,9 @@ class PairLJGromacsCoulGromacsKokkos : public PairLJGromacsCoulGromacs { struct params_lj_coul_gromacs{ KOKKOS_INLINE_FUNCTION - params_lj_coul_gromacs(){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj_coul_gromacs() {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; KOKKOS_INLINE_FUNCTION - params_lj_coul_gromacs(int /*i*/){cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj_coul_gromacs(int /*i*/) {cut_ljsq=0;cut_coulsq=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; F_FLOAT cut_ljsq,cut_coulsq,lj1,lj2,lj3,lj4,offset,ljsw1,ljsw2,ljsw3,ljsw4,ljsw5; }; diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.h b/src/KOKKOS/pair_lj_gromacs_kokkos.h index 956c5df47d..47804ffe0a 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.h +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.h @@ -46,9 +46,9 @@ class PairLJGromacsKokkos : public PairLJGromacs { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj() {cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; + params_lj(int /*i*/) {cut_inner_sq=0;cut_inner=0;lj1=0;lj2=0;lj3=0;lj4=0;offset=0;ljsw1=0;ljsw2=0;ljsw3=0;ljsw4=0;ljsw5=0;}; F_FLOAT cut_inner_sq,cut_inner,lj1,lj2,lj3,lj4,offset,ljsw1,ljsw2,ljsw3,ljsw4,ljsw5; }; diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.h b/src/KOKKOS/pair_lj_sdk_kokkos.h index 0a183051ba..470bda1f9f 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.h +++ b/src/KOKKOS/pair_lj_sdk_kokkos.h @@ -46,9 +46,9 @@ class PairLJSDKKokkos : public PairLJSDK { struct params_lj{ KOKKOS_INLINE_FUNCTION - params_lj(){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; + params_lj() {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; KOKKOS_INLINE_FUNCTION - params_lj(int /*i*/){cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; + params_lj(int /*i*/) {cutsq=0,lj1=0;lj2=0;lj3=0;lj4=0;offset=0;lj_type=0;}; F_FLOAT cutsq,lj1,lj2,lj3,lj4,offset; int lj_type; }; diff --git a/src/KOKKOS/pair_morse_kokkos.h b/src/KOKKOS/pair_morse_kokkos.h index 41de06a560..d747cc9e1e 100644 --- a/src/KOKKOS/pair_morse_kokkos.h +++ b/src/KOKKOS/pair_morse_kokkos.h @@ -45,9 +45,9 @@ class PairMorseKokkos : public PairMorse { struct params_morse{ KOKKOS_INLINE_FUNCTION - params_morse(){cutsq=0,d0=0;alpha=0;r0=0;offset=0;} + params_morse() {cutsq=0,d0=0;alpha=0;r0=0;offset=0;} KOKKOS_INLINE_FUNCTION - params_morse(int /*i*/){cutsq=0,d0=0;alpha=0;r0=0;offset=0;} + params_morse(int /*i*/) {cutsq=0,d0=0;alpha=0;r0=0;offset=0;} F_FLOAT cutsq,d0,alpha,r0,offset; }; diff --git a/src/KOKKOS/pair_reaxc_kokkos.h b/src/KOKKOS/pair_reaxc_kokkos.h index 3e5c07cc4d..d54f275d6f 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.h +++ b/src/KOKKOS/pair_reaxc_kokkos.h @@ -249,10 +249,10 @@ class PairReaxCKokkos : public PairReaxC { struct params_sing{ KOKKOS_INLINE_FUNCTION - params_sing(){mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; + params_sing() {mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; p_lp2=0;p_ovun2=0;p_ovun5=0;p_val3=0;p_val5=0;p_hbond=0;}; KOKKOS_INLINE_FUNCTION - params_sing(int /*i*/){mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; + params_sing(int /*i*/) {mass=0;chi=0;eta=0;r_s=0;r_pi=0;r_pi2=0;valency=0;valency_val=0;valency_e=0;valency_boc=0;nlp_opt=0; p_lp2=0;p_ovun2=0;p_ovun5=0;p_val3=0;p_val5=0;p_hbond=0;}; F_FLOAT mass,chi,eta,r_s,r_pi,r_pi2,valency,valency_val,valency_e,valency_boc,nlp_opt, p_lp2,p_ovun2,p_ovun5, p_val3, p_val5, p_hbond; @@ -260,12 +260,12 @@ class PairReaxCKokkos : public PairReaxC { struct params_twbp{ KOKKOS_INLINE_FUNCTION - params_twbp(){gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; + params_twbp() {gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; r_s=0;r_pi=0;r_pi2=0;p_bo1=0;p_bo2=0;p_bo3=0;p_bo4=0;p_bo5=0;p_bo6=0;ovc=0;v13cor=0; p_boc3=0;p_boc4=0;p_boc5=0;p_be1=0,p_be2=0,De_s=0,De_p=0;De_pp=0; p_ovun1=0;}; KOKKOS_INLINE_FUNCTION - params_twbp(int /*i*/){gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; + params_twbp(int /*i*/) {gamma=0;gamma_w=0;alpha=0;r_vdw=0;epsilon=0;acore=0;ecore=0;rcore=0;lgre=0;lgcij=0; r_s=0;r_pi=0;r_pi2=0;p_bo1=0;p_bo2=0;p_bo3=0;p_bo4=0;p_bo5=0;p_bo6=0;ovc=0;v13cor=0; p_boc3=0;p_boc4=0;p_boc5=0;p_be1=0,p_be2=0,De_s=0,De_p=0;De_pp=0; p_ovun1=0;}; @@ -277,25 +277,25 @@ class PairReaxCKokkos : public PairReaxC { struct params_thbp{ KOKKOS_INLINE_FUNCTION - params_thbp(){cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; + params_thbp() {cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; KOKKOS_INLINE_FUNCTION - params_thbp(int /*i*/){cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; + params_thbp(int /*i*/) {cnt=0;theta_00=0;p_val1=0;p_val2=0;p_val4=0;p_val7=0;p_pen1=0;p_coa1=0;}; F_FLOAT cnt, theta_00, p_val1, p_val2, p_val4, p_val7, p_pen1, p_coa1; }; struct params_fbp{ KOKKOS_INLINE_FUNCTION - params_fbp(){p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; + params_fbp() {p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; KOKKOS_INLINE_FUNCTION - params_fbp(int /*i*/){p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; + params_fbp(int /*i*/) {p_tor1=0;p_cot1=0;V1=0;V2=0;V3=0;}; F_FLOAT p_tor1, p_cot1, V1, V2, V3; }; struct params_hbp{ KOKKOS_INLINE_FUNCTION - params_hbp(){p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; + params_hbp() {p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; KOKKOS_INLINE_FUNCTION - params_hbp(int /*i*/){p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; + params_hbp(int /*i*/) {p_hb1=0;p_hb2=0;p_hb3=0;r0_hb=0;}; F_FLOAT p_hb1, p_hb2, p_hb3, r0_hb; }; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index cf4d5851b6..359ac652ef 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -949,7 +949,7 @@ void PairSNAPKokkos::operator() (TagPairSN int ninside = 0; Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,num_neighs), [&] (const int jj, int& count) { - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { T_INT j = d_neighbors(i,jj); const F_FLOAT dx = x(j,0) - xtmp; const F_FLOAT dy = x(j,1) - ytmp; @@ -1166,7 +1166,7 @@ void PairSNAPKokkos::operator() (TagPairSN fij[1] = my_sna.dedr(ii,jj,1); fij[2] = my_sna.dedr(ii,jj,2); - Kokkos::single(Kokkos::PerThread(team), [&] (){ + Kokkos::single(Kokkos::PerThread(team), [&] () { a_f(i,0) += fij[0]; a_f(i,1) += fij[1]; a_f(i,2) += fij[2]; diff --git a/src/KOKKOS/pair_tersoff_kokkos.h b/src/KOKKOS/pair_tersoff_kokkos.h index 9bae8df91f..dbc6dc7901 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.h +++ b/src/KOKKOS/pair_tersoff_kokkos.h @@ -153,10 +153,10 @@ class PairTersoffKokkos : public PairTersoff { struct params_ters{ KOKKOS_INLINE_FUNCTION - params_ters(){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters() {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; KOKKOS_INLINE_FUNCTION - params_ters(int /*i*/){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters(int /*i*/) {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; F_FLOAT powerm, gamma, lam3, c, d, h, powern, beta, lam2, bigb, bigr, bigd, lam1, biga, cutsq, c1, c2, c3, c4; diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.h b/src/KOKKOS/pair_tersoff_mod_kokkos.h index 4d541c0446..f6a03e1908 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.h +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.h @@ -153,10 +153,10 @@ class PairTersoffMODKokkos : public PairTersoffMOD { struct params_ters{ KOKKOS_INLINE_FUNCTION - params_ters(){powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; + params_ters() {powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; lam1=0;biga=0;powern_del=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;c5=0;ca1=0;ca4=0;}; KOKKOS_INLINE_FUNCTION - params_ters(int /*i*/){powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; + params_ters(int /*i*/) {powerm=0;lam3=0;h=0;powern=0;beta=0;lam2=0;bigb=0;bigr=0;bigd=0; lam1=0;biga=0;powern_del=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;c5=0;ca1=0;ca4=0;}; F_FLOAT powerm, lam3, h, powern, beta, lam2, bigb, bigr, bigd, lam1, biga, powern_del, cutsq, c1, c2, c3, c4, c5, ca1, ca4; diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.h b/src/KOKKOS/pair_tersoff_zbl_kokkos.h index fccbca7f46..f82a69cc29 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.h +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.h @@ -152,10 +152,10 @@ class PairTersoffZBLKokkos : public PairTersoffZBL { struct params_ters{ KOKKOS_INLINE_FUNCTION - params_ters(){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters() {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;Z_i=0;Z_j=0;ZBLcut=0;ZBLexpscale=0;}; KOKKOS_INLINE_FUNCTION - params_ters(int /*i*/){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; + params_ters(int /*i*/) {powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;Z_i=0;Z_j=0;ZBLcut=0;ZBLexpscale=0;}; F_FLOAT powerm, gamma, lam3, c, d, h, powern, beta, lam2, bigb, bigr, bigd, lam1, biga, cutsq, c1, c2, c3, c4, Z_i, Z_j, ZBLcut, ZBLexpscale; diff --git a/src/KOKKOS/pair_yukawa_kokkos.h b/src/KOKKOS/pair_yukawa_kokkos.h index 5e2a1e53e8..a78f9d5f7c 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.h +++ b/src/KOKKOS/pair_yukawa_kokkos.h @@ -45,9 +45,9 @@ class PairYukawaKokkos : public PairYukawa { struct params_yukawa { KOKKOS_INLINE_FUNCTION - params_yukawa(){ cutsq=0, a = 0; offset = 0; } + params_yukawa() { cutsq=0, a = 0; offset = 0; } KOKKOS_INLINE_FUNCTION - params_yukawa(int /*i*/){ cutsq=0, a = 0; offset = 0; } + params_yukawa(int /*i*/) { cutsq=0, a = 0; offset = 0; } F_FLOAT cutsq, a, offset; }; diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index d7aabb22c8..f20c677d1d 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -1271,7 +1271,7 @@ void SNAKokkos::compute_bi_cpu(const typen // apply bzero shift - if (bzero_flag){ + if (bzero_flag) { if (!wselfall_flag) { if (elem1 == elem2 && elem1 == elem3) { sumzu -= bzero[j]; diff --git a/src/KSPACE/pair_coul_msm.h b/src/KSPACE/pair_coul_msm.h index e4b4bc4750..ed7b6864fd 100644 --- a/src/KSPACE/pair_coul_msm.h +++ b/src/KSPACE/pair_coul_msm.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class PairCoulMSM : public PairCoulLong { public: PairCoulMSM(class LAMMPS *); - virtual ~PairCoulMSM(){}; + virtual ~PairCoulMSM() {}; virtual void compute(int, int); virtual double single(int, int, int, int, double, double, double, double &); virtual void *extract(const char *, int &); diff --git a/src/USER-CGDNA/mf_oxdna.h b/src/USER-CGDNA/mf_oxdna.h index 00df53234d..3c4e714f6b 100644 --- a/src/USER-CGDNA/mf_oxdna.h +++ b/src/USER-CGDNA/mf_oxdna.h @@ -96,13 +96,13 @@ inline double MFOxdna::F2(double r, double k, double cut_0, double cut_lc, double b_lo, double b_hi, double cut_c) { - if (r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc) { return 0; } - else if (r < cut_lo){ + else if (r < cut_lo) { return k * b_lo * (cut_lc - r)*(cut_lc-r); } - else if (r < cut_hi){ + else if (r < cut_hi) { return k * 0.5 * ((r - cut_0)*(r-cut_0) - (cut_0 - cut_c)*(cut_0 - cut_c)); } else{ @@ -118,13 +118,13 @@ inline double MFOxdna::DF2(double r, double k, double cut_0, double cut_lc, double cut_hc, double cut_lo, double cut_hi, double b_lo, double b_hi) { - if (r < cut_lc || r > cut_hc){ + if (r < cut_lc || r > cut_hc) { return 0; } - else if (r < cut_lo){ + else if (r < cut_lo) { return 2*k * b_lo * (r - cut_lc); } - else if (r < cut_hi){ + else if (r < cut_hi) { return k * (r - cut_0); } else{ diff --git a/src/USER-EFF/pair_eff_inline.h b/src/USER-EFF/pair_eff_inline.h index c93a3803f9..f30a122265 100644 --- a/src/USER-EFF/pair_eff_inline.h +++ b/src/USER-EFF/pair_eff_inline.h @@ -543,7 +543,7 @@ inline void SmallRForce(double dx, double dy, double dz, { /* Handles case where rc is small to avoid division by zero */ - if (rc > 0.000001){ + if (rc > 0.000001) { force /= rc; *fx = force * dx; *fy = force * dy; *fz = force * dz; } else { diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.h b/src/USER-MANIFOLD/fix_nve_manifold_rattle.h index 7ed1f75fa8..9ec2b3c78c 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.h +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.h @@ -74,7 +74,7 @@ namespace user_manifold { class manifold; } virtual void reset_dt(); virtual void end_of_step(); virtual int dof(int); - virtual void setup(int){} // Not needed for fixNVE but is for fixNVT + virtual void setup(int) {} // Not needed for fixNVE but is for fixNVT virtual double memory_usage(); protected: diff --git a/src/USER-MANIFOLD/manifold.h b/src/USER-MANIFOLD/manifold.h index 7c3197e161..be9f2c9f65 100644 --- a/src/USER-MANIFOLD/manifold.h +++ b/src/USER-MANIFOLD/manifold.h @@ -46,8 +46,8 @@ namespace user_manifold { // Abstract base class. class manifold : protected Pointers { public: - manifold(class LAMMPS* lmp) : Pointers(lmp), params(nullptr){ } - virtual ~manifold(){ delete[] params; } + manifold(class LAMMPS* lmp) : Pointers(lmp), params(nullptr) { } + virtual ~manifold() { delete[] params; } virtual double g( const double * ) = 0; virtual void n( const double *, double * ) = 0; @@ -61,13 +61,13 @@ namespace user_manifold { virtual const char *id() = 0; - virtual void set_atom_id( tagint /*a_id*/ ){} + virtual void set_atom_id( tagint /*a_id*/ ) {} virtual int nparams() = 0; - // double *get_params(){ return params; }; + // double *get_params() { return params; }; // Overload if any initialization depends on params: - virtual void post_param_init(){} - virtual void checkup(){} // Some diagnostics... + virtual void post_param_init() {} + virtual void checkup() {} // Some diagnostics... double *params; }; @@ -80,14 +80,14 @@ namespace user_manifold { double infnorm(double *vect) { double largest = fabs( vect[0] ); - for (unsigned int i = 1; i < size; ++i){ + for (unsigned int i = 1; i < size; ++i) { double c = fabs( vect[i] ); largest = ( c > largest ) ? c : largest; } return largest; } - inline double dot(double *a, double *b){ + inline double dot(double *a, double *b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; } diff --git a/src/USER-MANIFOLD/manifold_cylinder.h b/src/USER-MANIFOLD/manifold_cylinder.h index f8cddadf66..78a1725e5e 100644 --- a/src/USER-MANIFOLD/manifold_cylinder.h +++ b/src/USER-MANIFOLD/manifold_cylinder.h @@ -14,13 +14,13 @@ namespace user_manifold { public: enum { NPARAMS = 1 }; // Number of parameters. manifold_cylinder( LAMMPS *lmp, int, char ** ); - virtual ~manifold_cylinder(){} + virtual ~manifold_cylinder() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "cylinder"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "cylinder"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_cylinder_dent.h b/src/USER-MANIFOLD/manifold_cylinder_dent.h index 33167d670b..04c23d959d 100644 --- a/src/USER-MANIFOLD/manifold_cylinder_dent.h +++ b/src/USER-MANIFOLD/manifold_cylinder_dent.h @@ -12,13 +12,13 @@ namespace user_manifold { public: manifold_cylinder_dent( LAMMPS *lmp, int, char ** ); enum { NPARAMS = 3 }; // Number of parameters. - virtual ~manifold_cylinder_dent(){} + virtual ~manifold_cylinder_dent() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "cylinder/dent"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "cylinder/dent"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_dumbbell.h b/src/USER-MANIFOLD/manifold_dumbbell.h index fea718b487..cb2a1f0d0e 100644 --- a/src/USER-MANIFOLD/manifold_dumbbell.h +++ b/src/USER-MANIFOLD/manifold_dumbbell.h @@ -14,15 +14,15 @@ namespace user_manifold { public: enum { NPARAMS = 4 }; // Number of parameters. manifold_dumbbell( LAMMPS *lmp, int, char ** ); - virtual ~manifold_dumbbell(){} + virtual ~manifold_dumbbell() {} virtual double g ( const double *x ); virtual void n ( const double *x, double *nn ); - static const char* type(){ return "dumbbell"; } - virtual const char *id(){ return type(); } + static const char* type() { return "dumbbell"; } + virtual const char *id() { return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_ellipsoid.h b/src/USER-MANIFOLD/manifold_ellipsoid.h index e23dbec72a..373bdc8e91 100644 --- a/src/USER-MANIFOLD/manifold_ellipsoid.h +++ b/src/USER-MANIFOLD/manifold_ellipsoid.h @@ -12,14 +12,14 @@ namespace user_manifold { public: enum { NPARAMS = 3 }; manifold_ellipsoid( LAMMPS *lmp, int, char ** ); - virtual ~manifold_ellipsoid(){} + virtual ~manifold_ellipsoid() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char* type(){ return "ellipsoid"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "ellipsoid"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_factory.h b/src/USER-MANIFOLD/manifold_factory.h index cc23874eba..c6533855ad 100644 --- a/src/USER-MANIFOLD/manifold_factory.h +++ b/src/USER-MANIFOLD/manifold_factory.h @@ -68,7 +68,7 @@ struct LAMMPS { }; struct Pointers { - Pointers(LAMMPS *) : error( &e ){} + Pointers(LAMMPS *) : error( &e ) {} Error e; Error *error; }; @@ -93,8 +93,8 @@ class manifold; void make_manifold_if( manifold **man_ptr, const char *name, LAMMPS *lmp, int narg, char **arg ) { - if ( strcmp( m_type::type(), name ) == 0 ){ - if ( *man_ptr == nullptr ){ + if ( strcmp( m_type::type(), name ) == 0 ) { + if ( *man_ptr == nullptr ) { *man_ptr = new m_type(lmp, narg, arg); } } diff --git a/src/USER-MANIFOLD/manifold_gaussian_bump.h b/src/USER-MANIFOLD/manifold_gaussian_bump.h index 4fef84e3a5..d65979416b 100644 --- a/src/USER-MANIFOLD/manifold_gaussian_bump.h +++ b/src/USER-MANIFOLD/manifold_gaussian_bump.h @@ -59,10 +59,10 @@ namespace user_manifold { // Variant of g that computes n at the same time. virtual double g_and_n( const double *x, double *nn ); - static const char* type(){ return "gaussian_bump"; } + static const char* type() { return "gaussian_bump"; } virtual const char *id() { return type(); } - virtual int nparams(){ return NPARAMS; } + virtual int nparams() { return NPARAMS; } virtual void post_param_init(); private: // Some private constants: diff --git a/src/USER-MANIFOLD/manifold_plane.h b/src/USER-MANIFOLD/manifold_plane.h index 738c632b17..2fa7d6829e 100644 --- a/src/USER-MANIFOLD/manifold_plane.h +++ b/src/USER-MANIFOLD/manifold_plane.h @@ -14,13 +14,13 @@ namespace user_manifold { public: enum { NPARAMS = 6 }; // Number of parameters. manifold_plane( LAMMPS *lmp, int, char ** ); - virtual ~manifold_plane(){} + virtual ~manifold_plane() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "plane"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "plane"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_plane_wiggle.h b/src/USER-MANIFOLD/manifold_plane_wiggle.h index fe84713d7d..c1408d8900 100644 --- a/src/USER-MANIFOLD/manifold_plane_wiggle.h +++ b/src/USER-MANIFOLD/manifold_plane_wiggle.h @@ -13,13 +13,13 @@ namespace user_manifold { public: enum { NPARAMS = 2 }; // Number of parameters. manifold_plane_wiggle( LAMMPS *lmp, int, char ** ); - virtual ~manifold_plane_wiggle(){} + virtual ~manifold_plane_wiggle() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "plane/wiggle"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "plane/wiggle"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_sphere.h b/src/USER-MANIFOLD/manifold_sphere.h index d9cd46c9c3..a0f7f48c5f 100644 --- a/src/USER-MANIFOLD/manifold_sphere.h +++ b/src/USER-MANIFOLD/manifold_sphere.h @@ -12,9 +12,9 @@ namespace user_manifold { class manifold_sphere : public manifold { public: enum { NPARAMS = 1 }; - manifold_sphere( LAMMPS *lmp, int, char ** ) : manifold(lmp){} + manifold_sphere( LAMMPS *lmp, int, char ** ) : manifold(lmp) {} - virtual ~manifold_sphere(){} + virtual ~manifold_sphere() {} virtual double g( const double *x ) { double R = params[0]; @@ -46,10 +46,10 @@ namespace user_manifold { h[0][0] = h[1][1] = h[2][2] = 2.0; } - static const char* type(){ return "sphere"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "sphere"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_spine.h b/src/USER-MANIFOLD/manifold_spine.h index ba5e82a6bb..09b61b8300 100644 --- a/src/USER-MANIFOLD/manifold_spine.h +++ b/src/USER-MANIFOLD/manifold_spine.h @@ -13,16 +13,16 @@ namespace user_manifold { public: enum { NPARAMS = 5 }; // Number of parameters. manifold_spine( LAMMPS *lmp, int, char ** ); - virtual ~manifold_spine(){} + virtual ~manifold_spine() {} virtual double g ( const double *x ); virtual void n ( const double *x, double *nn ); virtual double g_and_n( const double *x, double *nn ); - static const char* type(){ return "spine"; } - virtual const char *id(){ return type(); } + static const char* type() { return "spine"; } + virtual const char *id() { return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } protected: int power; }; @@ -31,8 +31,8 @@ namespace user_manifold { public: manifold_spine_two( LAMMPS *lmp, int, char **); - static const char* type(){ return "spine/two"; } - virtual const char *id(){ return type(); } + static const char* type() { return "spine/two"; } + virtual const char *id() { return type(); } }; } diff --git a/src/USER-MANIFOLD/manifold_supersphere.h b/src/USER-MANIFOLD/manifold_supersphere.h index 1d9c62d7a2..031ec71932 100644 --- a/src/USER-MANIFOLD/manifold_supersphere.h +++ b/src/USER-MANIFOLD/manifold_supersphere.h @@ -12,9 +12,9 @@ namespace user_manifold { class manifold_supersphere : public manifold { public: enum { NPARAMS = 2 }; - manifold_supersphere( LAMMPS *lmp, int, char ** ) : manifold(lmp){} + manifold_supersphere( LAMMPS *lmp, int, char ** ) : manifold(lmp) {} - virtual ~manifold_supersphere(){} + virtual ~manifold_supersphere() {} double my_sign( double a ) { @@ -46,10 +46,10 @@ namespace user_manifold { nn[2] = q * my_sign(x[2])*pow(zz,q-1); } - static const char* type(){ return "supersphere"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "supersphere"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-MANIFOLD/manifold_thylakoid.h b/src/USER-MANIFOLD/manifold_thylakoid.h index d3ffa67765..8044d13813 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid.h +++ b/src/USER-MANIFOLD/manifold_thylakoid.h @@ -18,10 +18,10 @@ namespace user_manifold { virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char* type(){ return "thylakoid"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char* type() { return "thylakoid"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } virtual void post_param_init(); diff --git a/src/USER-MANIFOLD/manifold_thylakoid_shared.h b/src/USER-MANIFOLD/manifold_thylakoid_shared.h index 756f392bbb..1af32cc206 100644 --- a/src/USER-MANIFOLD/manifold_thylakoid_shared.h +++ b/src/USER-MANIFOLD/manifold_thylakoid_shared.h @@ -21,7 +21,7 @@ namespace user_manifold { thyla_part( int type, double *args, double xlo, double ylo, double zlo, double xhi, double yhi, double zhi ); - thyla_part() : type(-1), x0(-1337), y0(-1337), z0(-1337){} + thyla_part() : type(-1), x0(-1337), y0(-1337), z0(-1337) {} ~thyla_part(); double g( const double *x ); @@ -43,7 +43,7 @@ namespace user_manifold { struct thyla_part_geom { - thyla_part_geom() : pt(3), lo(3), hi(3){} + thyla_part_geom() : pt(3), lo(3), hi(3) {} std::vector pt, lo, hi; // Function for mirroring thyla_geoms: diff --git a/src/USER-MANIFOLD/manifold_torus.h b/src/USER-MANIFOLD/manifold_torus.h index 0c3bd6e2eb..d7fbc7958b 100644 --- a/src/USER-MANIFOLD/manifold_torus.h +++ b/src/USER-MANIFOLD/manifold_torus.h @@ -13,14 +13,14 @@ namespace user_manifold { public: enum {NPARAMS=2}; manifold_torus( LAMMPS *, int, char ** ); - ~manifold_torus(){} + ~manifold_torus() {} virtual double g( const double *x ); virtual void n( const double *x, double *n ); - static const char *type(){ return "torus"; } - virtual const char *id(){ return type(); } - static int expected_argc(){ return NPARAMS; } - virtual int nparams(){ return NPARAMS; } + static const char *type() { return "torus"; } + virtual const char *id() { return type(); } + static int expected_argc() { return NPARAMS; } + virtual int nparams() { return NPARAMS; } }; } diff --git a/src/USER-UEF/compute_pressure_uef.h b/src/USER-UEF/compute_pressure_uef.h index d3a4d3195c..f5ce642a0e 100644 --- a/src/USER-UEF/compute_pressure_uef.h +++ b/src/USER-UEF/compute_pressure_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class ComputePressureUef : public ComputePressure { public: ComputePressureUef(class LAMMPS *, int, char **); - virtual ~ComputePressureUef(){} + virtual ~ComputePressureUef() {} virtual void init(); virtual void compute_vector(); virtual double compute_scalar(); diff --git a/src/USER-UEF/compute_temp_uef.h b/src/USER-UEF/compute_temp_uef.h index 460e2b18c0..837e9c1c3e 100644 --- a/src/USER-UEF/compute_temp_uef.h +++ b/src/USER-UEF/compute_temp_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class ComputeTempUef : public ComputeTemp { public: ComputeTempUef(class LAMMPS *, int, char **); - virtual ~ComputeTempUef(){} + virtual ~ComputeTempUef() {} virtual void init(); virtual void compute_vector(); void yes_rot(); diff --git a/src/USER-UEF/dump_cfg_uef.h b/src/USER-UEF/dump_cfg_uef.h index d2881136ad..d8e7b15bcc 100644 --- a/src/USER-UEF/dump_cfg_uef.h +++ b/src/USER-UEF/dump_cfg_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class DumpCFGUef : public DumpCFG { public: DumpCFGUef(LAMMPS *lmp, int narg, char **arg) : - DumpCFG(lmp, narg, arg){} + DumpCFG(lmp, narg, arg) {} void init_style(); void write_header(bigint); diff --git a/src/USER-UEF/fix_nvt_uef.h b/src/USER-UEF/fix_nvt_uef.h index 718e36e756..b98da7963f 100644 --- a/src/USER-UEF/fix_nvt_uef.h +++ b/src/USER-UEF/fix_nvt_uef.h @@ -29,7 +29,7 @@ namespace LAMMPS_NS { class FixNVTUef : public FixNHUef { public: FixNVTUef(class LAMMPS *, int, char **); - ~FixNVTUef(){} + ~FixNVTUef() {} }; }