From c6d09437ae150b5da84e9263c1070b66c76160c3 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 7 Apr 2020 18:41:15 +0200 Subject: [PATCH 01/12] pair_style lj/class2/coul/long/cs The files for the core-shell version of the pair_style lj/class2/coul/long --- src/USER-MISC/pair_lj_class2_coul_long_cs.cpp | 573 ++++++++++++++++++ src/USER-MISC/pair_lj_class2_coul_long_cs.h | 67 ++ 2 files changed, 640 insertions(+) create mode 100644 src/USER-MISC/pair_lj_class2_coul_long_cs.cpp create mode 100644 src/USER-MISC/pair_lj_class2_coul_long_cs.h diff --git a/src/USER-MISC/pair_lj_class2_coul_long_cs.cpp b/src/USER-MISC/pair_lj_class2_coul_long_cs.cpp new file mode 100644 index 0000000000..bf103612ab --- /dev/null +++ b/src/USER-MISC/pair_lj_class2_coul_long_cs.cpp @@ -0,0 +1,573 @@ +/* ---------------------------------------------------------------------- + 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 "pair_lj_class2_coul_long_cs.h" +#include +#include +#include +#include "atom.h" +#include "comm.h" +#include "force.h" +#include "kspace.h" +#include "update.h" +#include "respa.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" +#include "utils.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +#define EWALD_F 1.12837917 +#define EWALD_P 0.3275911 +#define A1 0.254829592 +#define A2 -0.284496736 +#define A3 1.421413741 +#define A4 -1.453152027 +#define A5 1.061405429 + +#define EPSILON 1.0e-20 +#define EPS_EWALD 1.0e-6 +#define EPS_EWALD_SQR 1.0e-12 + +/* ---------------------------------------------------------------------- */ + +PairLJClass2CoulLongCS::PairLJClass2CoulLongCS(LAMMPS *lmp) : PairLJClass2CoulLong(lmp) +{ + ewaldflag = pppmflag = 1; + respa_enable = 1; + writedata = 1; + ftable = NULL; +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itable,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; + double fraction,table; + double rsq,r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj; + double grij,expm2,prefactor,t,erfc; + double factor_coul,factor_lj; + int *ilist,*jlist,*numneigh,**firstneigh; + + evdwl = ecoul = 0.0; + ev_init(eflag,vflag); + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + 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]; + + if (rsq < cutsq[itype][jtype]) { + rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; + r2inv = 1.0/rsq; + + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + r = sqrt(rsq); + prefactor = qqrd2e * qtmp*q[j]; + if (factor_coul < 1.0) { + // When bonded parts are being calculated a minimal distance (EPS_EWALD) + // has to be added to the prefactor and erfc in order to make the + // used approximation functions for the Ewald correction valid + grij = g_ewald * (r+EPS_EWALD); + expm2 = exp(-grij*grij); + t = 1.0 / (1.0 + EWALD_P*grij); + erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor /= (r+EPS_EWALD); + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - (1.0-factor_coul)); + // Additionally r2inv needs to be accordingly modified since the later + // scaling of the overall force shall be consistent + r2inv = 1.0/(rsq + EPS_EWALD_SQR); + } else { + grij = g_ewald * r; + expm2 = exp(-grij*grij); + t = 1.0 / (1.0 + EWALD_P*grij); + erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor /= r; + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); + } + } else { + union_int_float_t rsq_lookup; + rsq_lookup.f = rsq; + itable = rsq_lookup.i & ncoulmask; + itable >>= ncoulshiftbits; + fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable]; + table = ftable[itable] + fraction*dftable[itable]; + forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ctable[itable] + fraction*dctable[itable]; + prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else forcecoul = 0.0; + + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) + ecoul = prefactor*erfc; + else { + table = etable[itable] + fraction*detable[itable]; + ecoul = qtmp*q[j] * table; + } + if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + } else ecoul = 0.0; + if (rsq < cut_ljsq[itype][jtype]) { + evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } else evdwl = 0.0; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,ecoul,fpair,delx,dely,delz); + } + } + } + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute_inner() +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair; + double rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; + double rsw; + int *ilist,*jlist,*numneigh,**firstneigh; + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum_inner; + ilist = list->ilist_inner; + numneigh = list->numneigh_inner; + firstneigh = list->firstneigh_inner; + + double cut_out_on = cut_respa[0]; + double cut_out_off = cut_respa[1]; + + double cut_out_diff = cut_out_off - cut_out_on; + double cut_out_on_sq = cut_out_on*cut_out_on; + double cut_out_off_sq = cut_out_off*cut_out_off; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq < cut_out_off_sq) { + rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; + r2inv = 1.0/rsq; + forcecoul = qqrd2e * qtmp*q[j]*sqrt(r2inv); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*forcecoul; + + jtype = type[j]; + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + if (rsq > cut_out_on_sq) { + rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff; + fpair *= 1.0 + rsw*rsw*(2.0*rsw-3.0); + } + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute_middle() +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair; + double rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; + double rsw; + int *ilist,*jlist,*numneigh,**firstneigh; + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum_middle; + ilist = list->ilist_middle; + numneigh = list->numneigh_middle; + firstneigh = list->firstneigh_middle; + + double cut_in_off = cut_respa[0]; + double cut_in_on = cut_respa[1]; + double cut_out_on = cut_respa[2]; + double cut_out_off = cut_respa[3]; + + double cut_in_diff = cut_in_on - cut_in_off; + double cut_out_diff = cut_out_off - cut_out_on; + double cut_in_off_sq = cut_in_off*cut_in_off; + double cut_in_on_sq = cut_in_on*cut_in_on; + double cut_out_on_sq = cut_out_on*cut_out_on; + double cut_out_off_sq = cut_out_off*cut_out_off; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq < cut_out_off_sq && rsq > cut_in_off_sq) { + r2inv = 1.0/rsq; + forcecoul = qqrd2e * qtmp*q[j]*sqrt(r2inv); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*forcecoul; + + jtype = type[j]; + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + if (rsq < cut_in_on_sq) { + rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; + fpair *= rsw*rsw*(3.0 - 2.0*rsw); + } + if (rsq > cut_out_on_sq) { + rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff; + fpair *= 1.0 + rsw*rsw*(2.0*rsw - 3.0); + } + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype,itable; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; + double fraction,table; + double r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; + double grij,expm2,prefactor,t,erfc; + double rsw; + int *ilist,*jlist,*numneigh,**firstneigh; + double rsq; + + evdwl = ecoul = 0.0; + ev_init(eflag,vflag); + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + double cut_in_off = cut_respa[2]; + double cut_in_on = cut_respa[3]; + + double cut_in_diff = cut_in_on - cut_in_off; + double cut_in_off_sq = cut_in_off*cut_in_off; + double cut_in_on_sq = cut_in_on*cut_in_on; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + 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]; + + if (rsq < cutsq[itype][jtype]) { + rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; + r2inv = 1.0/rsq; + + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + r = sqrt(rsq); + grij = g_ewald * r; + expm2 = exp(-grij*grij); + t = 1.0 / (1.0 + EWALD_P*grij); + erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor = qqrd2e * qtmp*q[j]/r; + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - 1.0); + if (rsq > cut_in_off_sq) { + if (rsq < cut_in_on_sq) { + rsw = (r - cut_in_off)/cut_in_diff; + forcecoul += prefactor*rsw*rsw*(3.0 - 2.0*rsw); + if (factor_coul < 1.0) + forcecoul -= + (1.0-factor_coul)*prefactor*rsw*rsw*(3.0 - 2.0*rsw); + } else { + forcecoul += prefactor; + if (factor_coul < 1.0) + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else { + union_int_float_t rsq_lookup; + rsq_lookup.f = rsq; + itable = rsq_lookup.i & ncoulmask; + itable >>= ncoulshiftbits; + fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable]; + table = ftable[itable] + fraction*dftable[itable]; + forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ctable[itable] + fraction*dctable[itable]; + prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else forcecoul = 0.0; + + if (rsq < cut_ljsq[itype][jtype] && rsq > cut_in_off_sq) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + if (rsq < cut_in_on_sq) { + rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; + forcelj *= rsw*rsw*(3.0 - 2.0*rsw); + } + } else forcelj = 0.0; + + fpair = (forcecoul + forcelj) * r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + ecoul = prefactor*erfc; + if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + } else { + table = etable[itable] + fraction*detable[itable]; + ecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ptable[itable] + fraction*dptable[itable]; + prefactor = qtmp*q[j] * table; + ecoul -= (1.0-factor_coul)*prefactor; + } + } + } else ecoul = 0.0; + + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } else evdwl = 0.0; + } + + if (vflag) { + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + } else { + table = vtable[itable] + fraction*dvtable[itable]; + forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ptable[itable] + fraction*dptable[itable]; + prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else forcecoul = 0.0; + + if (rsq <= cut_in_off_sq) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else if (rsq <= cut_in_on_sq) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,ecoul,fpair,delx,dely,delz); + } + } + } +} + + diff --git a/src/USER-MISC/pair_lj_class2_coul_long_cs.h b/src/USER-MISC/pair_lj_class2_coul_long_cs.h new file mode 100644 index 0000000000..3e2e6972d8 --- /dev/null +++ b/src/USER-MISC/pair_lj_class2_coul_long_cs.h @@ -0,0 +1,67 @@ +/* -*- 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(lj/class2/coul/long/cs,PairLJClass2CoulLongCS) + +#else + +#ifndef LMP_PAIR_LJ_CLASS2_COUL_LONG_CS_H +#define LMP_PAIR_LJ_CLASS2_COUL_LONG_CS_H + +#include "pair_lj_class2_coul_long.h" + +namespace LAMMPS_NS { + +class PairLJClass2CoulLongCS : public PairLJClass2CoulLong { + + public: + PairLJClass2CoulLongCS(class LAMMPS *); + virtual void compute(int, int); + void compute_inner(); + void compute_middle(); + void compute_outer(int, int); +}; + +} + +#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 style lj/class2/coul/long requires atom attribute q + +The atom style defined does not have this attribute. + +E: Pair style requires a KSpace style + +No kspace style is defined. + +E: Pair cutoff < Respa interior cutoff + +One or more pairwise cutoffs are too short to use with the specified +rRESPA cutoffs. + +*/ From 4ef0e17900281afc72ed73817bb9d1fdaeb936ac Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 7 Apr 2020 18:44:06 +0200 Subject: [PATCH 02/12] Update README --- src/USER-MISC/README | 1 + 1 file changed, 1 insertion(+) diff --git a/src/USER-MISC/README b/src/USER-MISC/README index 91d630e560..f9c99ffcff 100644 --- a/src/USER-MISC/README +++ b/src/USER-MISC/README @@ -88,6 +88,7 @@ pair_style ilp/graphene/hbn, Wengen Ouyang (Tel Aviv University), w.g.ouyang at pair_style lebedeva/z, Zbigniew Koziol (National Center for Nuclear Research), softquake at gmail dot com, 4 Jan 19 pair_style lennard/mdf, Paolo Raiteri, p.raiteri at curtin.edu.au, 2 Dec 15 pair_style list, Axel Kohlmeyer (Temple U), akohlmey at gmail.com, 1 Jun 13 +pair_style lj/class2/coul/long/cs, Evangelos Voyiatzis, evoyiatzis at gmail.com, 7 April 2020 pair_style lj/mdf, Paolo Raiteri, p.raiteri at curtin.edu.au, 2 Dec 15 pair_style local/density, Tanmoy Sanyal (tanmoy dot 7989 at gmail.com) and M. Scott Shell (UCSB), and David Rosenberger (TU Darmstadt), 9 Sept 19 pair_style kolmogorov/crespi/full, Wengen Ouyang (Tel Aviv University), w.g.ouyang at gmail dot com, 30 Mar 18 From 9da2d34f9da7d53465a7a2bae984394f14e3941d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 7 Apr 2020 18:50:53 +0200 Subject: [PATCH 03/12] Update pair_cs.rst --- doc/src/pair_cs.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/src/pair_cs.rst b/doc/src/pair_cs.rst index 72332a87b2..9790c2defd 100644 --- a/doc/src/pair_cs.rst +++ b/doc/src/pair_cs.rst @@ -30,6 +30,9 @@ pair_style coul/wolf/cs command pair_style lj/cut/coul/long/cs command ======================================= +pair_style lj/class2/coul/long/cs command +========================================== + Syntax """""" @@ -37,7 +40,7 @@ Syntax pair_style style args -* style = *born/coul/dsf/cs* or *born/coul/long/cs* or *born/coul/wolf/cs* or *buck/coul/long/cs* or *coul/long/cs* or *coul/wolf/cs* or *lj/cut/coul/long/cs* +* style = *born/coul/dsf/cs* or *born/coul/long/cs* or *born/coul/wolf/cs* or *buck/coul/long/cs* or *coul/long/cs* or *coul/wolf/cs* or *lj/cut/coul/long/cs* or *lj/class2/coul/long/cs* * args = list of arguments for a particular style .. parsed-literal:: @@ -64,6 +67,9 @@ Syntax *lj/cut/coul/long/cs* args = cutoff (cutoff2) cutoff = global cutoff for LJ (and Coulombic if only 1 arg) (distance units) cutoff2 = global cutoff for Coulombic (optional) (distance units) + *lj/class2/coul/long/cs* args = cutoff (cutoff2) + cutoff = global cutoff for LJ (and Coulombic if only 1 arg) (distance units) + cutoff2 = global cutoff for Coulombic (optional) (distance units) Examples """""""" @@ -115,6 +121,7 @@ the "/cs" in the name: * :doc:`pair_style coul/long ` * :doc:`pair_style coul/wolf ` * :doc:`pair_style lj/cut/coul/long ` +* :doc:`pair_style lj/class2/coul/long ` except that they correctly treat the special case where the distance between two charged core and shell atoms in the same core/shell pair From dab9cc617aee6e23077814a91569015b6c2ee08e Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 9 Apr 2020 19:38:12 +0200 Subject: [PATCH 04/12] delete entry at README --- src/USER-MISC/README | 1 - 1 file changed, 1 deletion(-) diff --git a/src/USER-MISC/README b/src/USER-MISC/README index f9c99ffcff..91d630e560 100644 --- a/src/USER-MISC/README +++ b/src/USER-MISC/README @@ -88,7 +88,6 @@ pair_style ilp/graphene/hbn, Wengen Ouyang (Tel Aviv University), w.g.ouyang at pair_style lebedeva/z, Zbigniew Koziol (National Center for Nuclear Research), softquake at gmail dot com, 4 Jan 19 pair_style lennard/mdf, Paolo Raiteri, p.raiteri at curtin.edu.au, 2 Dec 15 pair_style list, Axel Kohlmeyer (Temple U), akohlmey at gmail.com, 1 Jun 13 -pair_style lj/class2/coul/long/cs, Evangelos Voyiatzis, evoyiatzis at gmail.com, 7 April 2020 pair_style lj/mdf, Paolo Raiteri, p.raiteri at curtin.edu.au, 2 Dec 15 pair_style local/density, Tanmoy Sanyal (tanmoy dot 7989 at gmail.com) and M. Scott Shell (UCSB), and David Rosenberger (TU Darmstadt), 9 Sept 19 pair_style kolmogorov/crespi/full, Wengen Ouyang (Tel Aviv University), w.g.ouyang at gmail dot com, 30 Mar 18 From d4757e53305b6093136f060f9e3bbe73c6d4f4af Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 9 Apr 2020 19:41:27 +0200 Subject: [PATCH 05/12] move cpp file to CORESHELL folder --- src/{USER-MISC => CORESHELL}/pair_lj_class2_coul_long_cs.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{USER-MISC => CORESHELL}/pair_lj_class2_coul_long_cs.cpp (100%) diff --git a/src/USER-MISC/pair_lj_class2_coul_long_cs.cpp b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp similarity index 100% rename from src/USER-MISC/pair_lj_class2_coul_long_cs.cpp rename to src/CORESHELL/pair_lj_class2_coul_long_cs.cpp From 52bc8c398df28fdd6f2b5ff3da3e524e3d6b7936 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 9 Apr 2020 19:42:32 +0200 Subject: [PATCH 06/12] move header file to CORESHELL folder --- src/{USER-MISC => CORESHELL}/pair_lj_class2_coul_long_cs.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{USER-MISC => CORESHELL}/pair_lj_class2_coul_long_cs.h (100%) diff --git a/src/USER-MISC/pair_lj_class2_coul_long_cs.h b/src/CORESHELL/pair_lj_class2_coul_long_cs.h similarity index 100% rename from src/USER-MISC/pair_lj_class2_coul_long_cs.h rename to src/CORESHELL/pair_lj_class2_coul_long_cs.h From 4534096ad12a191aaf6bd9e52c04987874ff93eb Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 9 Apr 2020 19:44:48 +0200 Subject: [PATCH 07/12] Update Install.sh --- src/CORESHELL/Install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CORESHELL/Install.sh b/src/CORESHELL/Install.sh index 93c8fe8132..f8b75d1f25 100755 --- a/src/CORESHELL/Install.sh +++ b/src/CORESHELL/Install.sh @@ -41,6 +41,8 @@ action pair_coul_long_cs.cpp pair_coul_long.cpp action pair_coul_long_cs.h pair_coul_long.h action pair_lj_cut_coul_long_cs.cpp pair_lj_cut_coul_long.cpp action pair_lj_cut_coul_long_cs.h pair_lj_cut_coul_long.h +action pair_lj_class2_coul_long_cs.cpp pair_lj_class2_coul_long.cpp +action pair_lj_class2_coul_long_cs.h pair_lj_class2_coul_long.h action pair_born_coul_wolf_cs.cpp pair_born_coul_wolf.cpp action pair_born_coul_wolf_cs.h pair_born_coul_wolf.h From 35bb5977470f1edbc3f118d67be0e12463fad218 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 11 Apr 2020 16:11:27 -0400 Subject: [PATCH 08/12] fix some whitespace issues: replace tabs with spaces, remove DOS/Windows style CR-LF --- src/CORESHELL/pair_lj_class2_coul_long_cs.cpp | 1146 ++++++++--------- src/CORESHELL/pair_lj_class2_coul_long_cs.h | 134 +- 2 files changed, 640 insertions(+), 640 deletions(-) diff --git a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp index bf103612ab..9fb7ad118e 100644 --- a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp @@ -1,573 +1,573 @@ -/* ---------------------------------------------------------------------- - 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 "pair_lj_class2_coul_long_cs.h" -#include -#include -#include -#include "atom.h" -#include "comm.h" -#include "force.h" -#include "kspace.h" -#include "update.h" -#include "respa.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "math_const.h" -#include "memory.h" -#include "error.h" -#include "utils.h" - -using namespace LAMMPS_NS; -using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 - -/* ---------------------------------------------------------------------- */ - -PairLJClass2CoulLongCS::PairLJClass2CoulLongCS(LAMMPS *lmp) : PairLJClass2CoulLong(lmp) -{ - ewaldflag = pppmflag = 1; - respa_enable = 1; - writedata = 1; - ftable = NULL; -} - -/* ---------------------------------------------------------------------- */ - -void PairLJClass2CoulLongCS::compute(int eflag, int vflag) -{ - int i,j,ii,jj,inum,jnum,itable,itype,jtype; - double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; - double fraction,table; - double rsq,r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj; - double grij,expm2,prefactor,t,erfc; - double factor_coul,factor_lj; - int *ilist,*jlist,*numneigh,**firstneigh; - - evdwl = ecoul = 0.0; - ev_init(eflag,vflag); - - double **x = atom->x; - double **f = atom->f; - double *q = atom->q; - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_coul = force->special_coul; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; - double qqrd2e = force->qqrd2e; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - // loop over neighbors of my atoms - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - qtmp = q[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; - factor_coul = special_coul[sbmask(j)]; - 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]; - - if (rsq < cutsq[itype][jtype]) { - rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; - r2inv = 1.0/rsq; - - if (rsq < cut_coulsq) { - if (!ncoultablebits || rsq <= tabinnersq) { - r = sqrt(rsq); - prefactor = qqrd2e * qtmp*q[j]; - if (factor_coul < 1.0) { - // When bonded parts are being calculated a minimal distance (EPS_EWALD) - // has to be added to the prefactor and erfc in order to make the - // used approximation functions for the Ewald correction valid - grij = g_ewald * (r+EPS_EWALD); - expm2 = exp(-grij*grij); - t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; - prefactor /= (r+EPS_EWALD); - forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - (1.0-factor_coul)); - // Additionally r2inv needs to be accordingly modified since the later - // scaling of the overall force shall be consistent - r2inv = 1.0/(rsq + EPS_EWALD_SQR); - } else { - grij = g_ewald * r; - expm2 = exp(-grij*grij); - t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; - prefactor /= r; - forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - } - } else { - union_int_float_t rsq_lookup; - rsq_lookup.f = rsq; - itable = rsq_lookup.i & ncoulmask; - itable >>= ncoulshiftbits; - fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable]; - table = ftable[itable] + fraction*dftable[itable]; - forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { - table = ctable[itable] + fraction*dctable[itable]; - prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; - } - } - } else forcecoul = 0.0; - - if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); - } else forcelj = 0.0; - - fpair = (forcecoul + factor_lj*forcelj) * r2inv; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (eflag) { - if (rsq < cut_coulsq) { - if (!ncoultablebits || rsq <= tabinnersq) - ecoul = prefactor*erfc; - else { - table = etable[itable] + fraction*detable[itable]; - ecoul = qtmp*q[j] * table; - } - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; - } else ecoul = 0.0; - if (rsq < cut_ljsq[itype][jtype]) { - evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - - offset[itype][jtype]; - evdwl *= factor_lj; - } else evdwl = 0.0; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); - } - } - } - - if (vflag_fdotr) virial_fdotr_compute(); -} - -/* ---------------------------------------------------------------------- */ - -void PairLJClass2CoulLongCS::compute_inner() -{ - int i,j,ii,jj,inum,jnum,itype,jtype; - double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair; - double rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; - double rsw; - int *ilist,*jlist,*numneigh,**firstneigh; - - double **x = atom->x; - double **f = atom->f; - double *q = atom->q; - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_coul = force->special_coul; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; - double qqrd2e = force->qqrd2e; - - inum = list->inum_inner; - ilist = list->ilist_inner; - numneigh = list->numneigh_inner; - firstneigh = list->firstneigh_inner; - - double cut_out_on = cut_respa[0]; - double cut_out_off = cut_respa[1]; - - double cut_out_diff = cut_out_off - cut_out_on; - double cut_out_on_sq = cut_out_on*cut_out_on; - double cut_out_off_sq = cut_out_off*cut_out_off; - - // loop over neighbors of my atoms - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - qtmp = q[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; - factor_coul = special_coul[sbmask(j)]; - j &= NEIGHMASK; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; - - if (rsq < cut_out_off_sq) { - rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; - r2inv = 1.0/rsq; - forcecoul = qqrd2e * qtmp*q[j]*sqrt(r2inv); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*forcecoul; - - jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); - } else forcelj = 0.0; - - fpair = (forcecoul + factor_lj*forcelj) * r2inv; - if (rsq > cut_out_on_sq) { - rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff; - fpair *= 1.0 + rsw*rsw*(2.0*rsw-3.0); - } - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - } - } - } -} - -/* ---------------------------------------------------------------------- */ - -void PairLJClass2CoulLongCS::compute_middle() -{ - int i,j,ii,jj,inum,jnum,itype,jtype; - double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair; - double rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; - double rsw; - int *ilist,*jlist,*numneigh,**firstneigh; - - double **x = atom->x; - double **f = atom->f; - double *q = atom->q; - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_coul = force->special_coul; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; - double qqrd2e = force->qqrd2e; - - inum = list->inum_middle; - ilist = list->ilist_middle; - numneigh = list->numneigh_middle; - firstneigh = list->firstneigh_middle; - - double cut_in_off = cut_respa[0]; - double cut_in_on = cut_respa[1]; - double cut_out_on = cut_respa[2]; - double cut_out_off = cut_respa[3]; - - double cut_in_diff = cut_in_on - cut_in_off; - double cut_out_diff = cut_out_off - cut_out_on; - double cut_in_off_sq = cut_in_off*cut_in_off; - double cut_in_on_sq = cut_in_on*cut_in_on; - double cut_out_on_sq = cut_out_on*cut_out_on; - double cut_out_off_sq = cut_out_off*cut_out_off; - - // loop over neighbors of my atoms - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - qtmp = q[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; - factor_coul = special_coul[sbmask(j)]; - j &= NEIGHMASK; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; - - if (rsq < cut_out_off_sq && rsq > cut_in_off_sq) { - r2inv = 1.0/rsq; - forcecoul = qqrd2e * qtmp*q[j]*sqrt(r2inv); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*forcecoul; - - jtype = type[j]; - if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); - } else forcelj = 0.0; - - fpair = (forcecoul + factor_lj*forcelj) * r2inv; - if (rsq < cut_in_on_sq) { - rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; - fpair *= rsw*rsw*(3.0 - 2.0*rsw); - } - if (rsq > cut_out_on_sq) { - rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff; - fpair *= 1.0 + rsw*rsw*(2.0*rsw - 3.0); - } - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - } - } - } -} - -/* ---------------------------------------------------------------------- */ - -void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) -{ - int i,j,ii,jj,inum,jnum,itype,jtype,itable; - double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; - double fraction,table; - double r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; - double grij,expm2,prefactor,t,erfc; - double rsw; - int *ilist,*jlist,*numneigh,**firstneigh; - double rsq; - - evdwl = ecoul = 0.0; - ev_init(eflag,vflag); - - double **x = atom->x; - double **f = atom->f; - double *q = atom->q; - int *type = atom->type; - int nlocal = atom->nlocal; - double *special_coul = force->special_coul; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; - double qqrd2e = force->qqrd2e; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - double cut_in_off = cut_respa[2]; - double cut_in_on = cut_respa[3]; - - double cut_in_diff = cut_in_on - cut_in_off; - double cut_in_off_sq = cut_in_off*cut_in_off; - double cut_in_on_sq = cut_in_on*cut_in_on; - - // loop over neighbors of my atoms - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - qtmp = q[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; - factor_coul = special_coul[sbmask(j)]; - 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]; - - if (rsq < cutsq[itype][jtype]) { - rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; - r2inv = 1.0/rsq; - - if (rsq < cut_coulsq) { - if (!ncoultablebits || rsq <= tabinnersq) { - r = sqrt(rsq); - grij = g_ewald * r; - expm2 = exp(-grij*grij); - t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; - prefactor = qqrd2e * qtmp*q[j]/r; - forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - 1.0); - if (rsq > cut_in_off_sq) { - if (rsq < cut_in_on_sq) { - rsw = (r - cut_in_off)/cut_in_diff; - forcecoul += prefactor*rsw*rsw*(3.0 - 2.0*rsw); - if (factor_coul < 1.0) - forcecoul -= - (1.0-factor_coul)*prefactor*rsw*rsw*(3.0 - 2.0*rsw); - } else { - forcecoul += prefactor; - if (factor_coul < 1.0) - forcecoul -= (1.0-factor_coul)*prefactor; - } - } - } else { - union_int_float_t rsq_lookup; - rsq_lookup.f = rsq; - itable = rsq_lookup.i & ncoulmask; - itable >>= ncoulshiftbits; - fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable]; - table = ftable[itable] + fraction*dftable[itable]; - forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { - table = ctable[itable] + fraction*dctable[itable]; - prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; - } - } - } else forcecoul = 0.0; - - if (rsq < cut_ljsq[itype][jtype] && rsq > cut_in_off_sq) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); - if (rsq < cut_in_on_sq) { - rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; - forcelj *= rsw*rsw*(3.0 - 2.0*rsw); - } - } else forcelj = 0.0; - - fpair = (forcecoul + forcelj) * r2inv; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (eflag) { - if (rsq < cut_coulsq) { - if (!ncoultablebits || rsq <= tabinnersq) { - ecoul = prefactor*erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; - } else { - table = etable[itable] + fraction*detable[itable]; - ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { - table = ptable[itable] + fraction*dptable[itable]; - prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; - } - } - } else ecoul = 0.0; - - if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - - offset[itype][jtype]; - evdwl *= factor_lj; - } else evdwl = 0.0; - } - - if (vflag) { - if (rsq < cut_coulsq) { - if (!ncoultablebits || rsq <= tabinnersq) { - forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; - } else { - table = vtable[itable] + fraction*dvtable[itable]; - forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { - table = ptable[itable] + fraction*dptable[itable]; - prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; - } - } - } else forcecoul = 0.0; - - if (rsq <= cut_in_off_sq) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); - } else if (rsq <= cut_in_on_sq) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; - forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); - } - fpair = (forcecoul + factor_lj*forcelj) * r2inv; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); - } - } - } -} - - +/* ---------------------------------------------------------------------- + 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 "pair_lj_class2_coul_long_cs.h" +#include +#include +#include +#include "atom.h" +#include "comm.h" +#include "force.h" +#include "kspace.h" +#include "update.h" +#include "respa.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "math_const.h" +#include "memory.h" +#include "error.h" +#include "utils.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +#define EWALD_F 1.12837917 +#define EWALD_P 0.3275911 +#define A1 0.254829592 +#define A2 -0.284496736 +#define A3 1.421413741 +#define A4 -1.453152027 +#define A5 1.061405429 + +#define EPSILON 1.0e-20 +#define EPS_EWALD 1.0e-6 +#define EPS_EWALD_SQR 1.0e-12 + +/* ---------------------------------------------------------------------- */ + +PairLJClass2CoulLongCS::PairLJClass2CoulLongCS(LAMMPS *lmp) : PairLJClass2CoulLong(lmp) +{ + ewaldflag = pppmflag = 1; + respa_enable = 1; + writedata = 1; + ftable = NULL; +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itable,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; + double fraction,table; + double rsq,r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj; + double grij,expm2,prefactor,t,erfc; + double factor_coul,factor_lj; + int *ilist,*jlist,*numneigh,**firstneigh; + + evdwl = ecoul = 0.0; + ev_init(eflag,vflag); + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + 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]; + + if (rsq < cutsq[itype][jtype]) { + rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; + r2inv = 1.0/rsq; + + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + r = sqrt(rsq); + prefactor = qqrd2e * qtmp*q[j]; + if (factor_coul < 1.0) { + // When bonded parts are being calculated a minimal distance (EPS_EWALD) + // has to be added to the prefactor and erfc in order to make the + // used approximation functions for the Ewald correction valid + grij = g_ewald * (r+EPS_EWALD); + expm2 = exp(-grij*grij); + t = 1.0 / (1.0 + EWALD_P*grij); + erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor /= (r+EPS_EWALD); + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - (1.0-factor_coul)); + // Additionally r2inv needs to be accordingly modified since the later + // scaling of the overall force shall be consistent + r2inv = 1.0/(rsq + EPS_EWALD_SQR); + } else { + grij = g_ewald * r; + expm2 = exp(-grij*grij); + t = 1.0 / (1.0 + EWALD_P*grij); + erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor /= r; + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); + } + } else { + union_int_float_t rsq_lookup; + rsq_lookup.f = rsq; + itable = rsq_lookup.i & ncoulmask; + itable >>= ncoulshiftbits; + fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable]; + table = ftable[itable] + fraction*dftable[itable]; + forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ctable[itable] + fraction*dctable[itable]; + prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else forcecoul = 0.0; + + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) + ecoul = prefactor*erfc; + else { + table = etable[itable] + fraction*detable[itable]; + ecoul = qtmp*q[j] * table; + } + if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + } else ecoul = 0.0; + if (rsq < cut_ljsq[itype][jtype]) { + evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } else evdwl = 0.0; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,ecoul,fpair,delx,dely,delz); + } + } + } + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute_inner() +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair; + double rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; + double rsw; + int *ilist,*jlist,*numneigh,**firstneigh; + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum_inner; + ilist = list->ilist_inner; + numneigh = list->numneigh_inner; + firstneigh = list->firstneigh_inner; + + double cut_out_on = cut_respa[0]; + double cut_out_off = cut_respa[1]; + + double cut_out_diff = cut_out_off - cut_out_on; + double cut_out_on_sq = cut_out_on*cut_out_on; + double cut_out_off_sq = cut_out_off*cut_out_off; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq < cut_out_off_sq) { + rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; + r2inv = 1.0/rsq; + forcecoul = qqrd2e * qtmp*q[j]*sqrt(r2inv); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*forcecoul; + + jtype = type[j]; + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + if (rsq > cut_out_on_sq) { + rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff; + fpair *= 1.0 + rsw*rsw*(2.0*rsw-3.0); + } + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute_middle() +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair; + double rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; + double rsw; + int *ilist,*jlist,*numneigh,**firstneigh; + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum_middle; + ilist = list->ilist_middle; + numneigh = list->numneigh_middle; + firstneigh = list->firstneigh_middle; + + double cut_in_off = cut_respa[0]; + double cut_in_on = cut_respa[1]; + double cut_out_on = cut_respa[2]; + double cut_out_off = cut_respa[3]; + + double cut_in_diff = cut_in_on - cut_in_off; + double cut_out_diff = cut_out_off - cut_out_on; + double cut_in_off_sq = cut_in_off*cut_in_off; + double cut_in_on_sq = cut_in_on*cut_in_on; + double cut_out_on_sq = cut_out_on*cut_out_on; + double cut_out_off_sq = cut_out_off*cut_out_off; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq < cut_out_off_sq && rsq > cut_in_off_sq) { + r2inv = 1.0/rsq; + forcecoul = qqrd2e * qtmp*q[j]*sqrt(r2inv); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*forcecoul; + + jtype = type[j]; + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else forcelj = 0.0; + + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + if (rsq < cut_in_on_sq) { + rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; + fpair *= rsw*rsw*(3.0 - 2.0*rsw); + } + if (rsq > cut_out_on_sq) { + rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff; + fpair *= 1.0 + rsw*rsw*(2.0*rsw - 3.0); + } + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype,itable; + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; + double fraction,table; + double r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; + double grij,expm2,prefactor,t,erfc; + double rsw; + int *ilist,*jlist,*numneigh,**firstneigh; + double rsq; + + evdwl = ecoul = 0.0; + ev_init(eflag,vflag); + + double **x = atom->x; + double **f = atom->f; + double *q = atom->q; + int *type = atom->type; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + double qqrd2e = force->qqrd2e; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + double cut_in_off = cut_respa[2]; + double cut_in_on = cut_respa[3]; + + double cut_in_diff = cut_in_on - cut_in_off; + double cut_in_off_sq = cut_in_off*cut_in_off; + double cut_in_on_sq = cut_in_on*cut_in_on; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + qtmp = q[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + 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]; + + if (rsq < cutsq[itype][jtype]) { + rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; + r2inv = 1.0/rsq; + + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + r = sqrt(rsq); + grij = g_ewald * r; + expm2 = exp(-grij*grij); + t = 1.0 / (1.0 + EWALD_P*grij); + erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + prefactor = qqrd2e * qtmp*q[j]/r; + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - 1.0); + if (rsq > cut_in_off_sq) { + if (rsq < cut_in_on_sq) { + rsw = (r - cut_in_off)/cut_in_diff; + forcecoul += prefactor*rsw*rsw*(3.0 - 2.0*rsw); + if (factor_coul < 1.0) + forcecoul -= + (1.0-factor_coul)*prefactor*rsw*rsw*(3.0 - 2.0*rsw); + } else { + forcecoul += prefactor; + if (factor_coul < 1.0) + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else { + union_int_float_t rsq_lookup; + rsq_lookup.f = rsq; + itable = rsq_lookup.i & ncoulmask; + itable >>= ncoulshiftbits; + fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable]; + table = ftable[itable] + fraction*dftable[itable]; + forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ctable[itable] + fraction*dctable[itable]; + prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else forcecoul = 0.0; + + if (rsq < cut_ljsq[itype][jtype] && rsq > cut_in_off_sq) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + if (rsq < cut_in_on_sq) { + rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; + forcelj *= rsw*rsw*(3.0 - 2.0*rsw); + } + } else forcelj = 0.0; + + fpair = (forcecoul + forcelj) * r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + ecoul = prefactor*erfc; + if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + } else { + table = etable[itable] + fraction*detable[itable]; + ecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ptable[itable] + fraction*dptable[itable]; + prefactor = qtmp*q[j] * table; + ecoul -= (1.0-factor_coul)*prefactor; + } + } + } else ecoul = 0.0; + + if (rsq < cut_ljsq[itype][jtype]) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - + offset[itype][jtype]; + evdwl *= factor_lj; + } else evdwl = 0.0; + } + + if (vflag) { + if (rsq < cut_coulsq) { + if (!ncoultablebits || rsq <= tabinnersq) { + forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + } else { + table = vtable[itable] + fraction*dvtable[itable]; + forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + table = ptable[itable] + fraction*dptable[itable]; + prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + } + } else forcecoul = 0.0; + + if (rsq <= cut_in_off_sq) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } else if (rsq <= cut_in_on_sq) { + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; + forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); + } + fpair = (forcecoul + factor_lj*forcelj) * r2inv; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,ecoul,fpair,delx,dely,delz); + } + } + } +} + + diff --git a/src/CORESHELL/pair_lj_class2_coul_long_cs.h b/src/CORESHELL/pair_lj_class2_coul_long_cs.h index 3e2e6972d8..b37685bda1 100644 --- a/src/CORESHELL/pair_lj_class2_coul_long_cs.h +++ b/src/CORESHELL/pair_lj_class2_coul_long_cs.h @@ -1,67 +1,67 @@ -/* -*- 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(lj/class2/coul/long/cs,PairLJClass2CoulLongCS) - -#else - -#ifndef LMP_PAIR_LJ_CLASS2_COUL_LONG_CS_H -#define LMP_PAIR_LJ_CLASS2_COUL_LONG_CS_H - -#include "pair_lj_class2_coul_long.h" - -namespace LAMMPS_NS { - -class PairLJClass2CoulLongCS : public PairLJClass2CoulLong { - - public: - PairLJClass2CoulLongCS(class LAMMPS *); - virtual void compute(int, int); - void compute_inner(); - void compute_middle(); - void compute_outer(int, int); -}; - -} - -#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 style lj/class2/coul/long requires atom attribute q - -The atom style defined does not have this attribute. - -E: Pair style requires a KSpace style - -No kspace style is defined. - -E: Pair cutoff < Respa interior cutoff - -One or more pairwise cutoffs are too short to use with the specified -rRESPA cutoffs. - -*/ +/* -*- 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(lj/class2/coul/long/cs,PairLJClass2CoulLongCS) + +#else + +#ifndef LMP_PAIR_LJ_CLASS2_COUL_LONG_CS_H +#define LMP_PAIR_LJ_CLASS2_COUL_LONG_CS_H + +#include "pair_lj_class2_coul_long.h" + +namespace LAMMPS_NS { + +class PairLJClass2CoulLongCS : public PairLJClass2CoulLong { + + public: + PairLJClass2CoulLongCS(class LAMMPS *); + virtual void compute(int, int); + void compute_inner(); + void compute_middle(); + void compute_outer(int, int); +}; + +} + +#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 style lj/class2/coul/long requires atom attribute q + +The atom style defined does not have this attribute. + +E: Pair style requires a KSpace style + +No kspace style is defined. + +E: Pair cutoff < Respa interior cutoff + +One or more pairwise cutoffs are too short to use with the specified +rRESPA cutoffs. + +*/ From 03634b12df7bc1fb022392a57061dd09d2179885 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 13 Apr 2020 10:38:09 -0400 Subject: [PATCH 09/12] add missing pair style. Coulombic/Coulombics -> Coulomb for consistency --- doc/src/Commands_pair.rst | 1 + doc/src/pair_style.rst | 87 ++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index 34b04969f9..b176e22a85 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -131,6 +131,7 @@ OPT. * :doc:`lj/class2/coul/cut (ko) ` * :doc:`lj/class2/coul/cut/soft ` * :doc:`lj/class2/coul/long (gko) ` + * :doc:`lj/class2/coul/long/cs ` * :doc:`lj/class2/coul/long/soft ` * :doc:`lj/class2/soft ` * :doc:`lj/cubic (go) ` diff --git a/doc/src/pair_style.rst b/doc/src/pair_style.rst index 5b5e6e6fe8..48dd2dde0f 100644 --- a/doc/src/pair_style.rst +++ b/doc/src/pair_style.rst @@ -111,41 +111,41 @@ accelerated styles exist. * :doc:`born ` - Born-Mayer-Huggins potential * :doc:`born/coul/dsf ` - Born with damped-shifted-force model * :doc:`born/coul/dsf/cs ` - Born with damped-shifted-force and core/shell model -* :doc:`born/coul/long ` - Born with long-range Coulombics -* :doc:`born/coul/long/cs ` - Born with long-range Coulombics and core/shell -* :doc:`born/coul/msm ` - Born with long-range MSM Coulombics -* :doc:`born/coul/wolf ` - Born with Wolf potential for Coulombics -* :doc:`born/coul/wolf/cs ` - Born with Wolf potential for Coulombics and core/shell model +* :doc:`born/coul/long ` - Born with long-range Coulomb +* :doc:`born/coul/long/cs ` - Born with long-range Coulomb and core/shell +* :doc:`born/coul/msm ` - Born with long-range MSM Coulomb +* :doc:`born/coul/wolf ` - Born with Wolf potential for Coulomb +* :doc:`born/coul/wolf/cs ` - Born with Wolf potential for Coulomb and core/shell model * :doc:`brownian ` - Brownian potential for Fast Lubrication Dynamics * :doc:`brownian/poly ` - Brownian potential for Fast Lubrication Dynamics with polydispersity * :doc:`buck ` - Buckingham potential * :doc:`buck/coul/cut ` - Buckingham with cutoff Coulomb -* :doc:`buck/coul/long ` - Buckingham with long-range Coulombics -* :doc:`buck/coul/long/cs ` - Buckingham with long-range Coulombics and core/shell -* :doc:`buck/coul/msm ` - Buckingham with long-range MSM Coulombics -* :doc:`buck/long/coul/long ` - long-range Buckingham with long-range Coulombics +* :doc:`buck/coul/long ` - Buckingham with long-range Coulomb +* :doc:`buck/coul/long/cs ` - Buckingham with long-range Coulomb and core/shell +* :doc:`buck/coul/msm ` - Buckingham with long-range MSM Coulomb +* :doc:`buck/long/coul/long ` - long-range Buckingham with long-range Coulomb * :doc:`buck/mdf ` - Buckingham with a taper function * :doc:`buck6d/coul/gauss/dsf ` - dispersion-damped Buckingham with damped-shift-force model -* :doc:`buck6d/coul/gauss/long ` - dispersion-damped Buckingham with long-range Coulombics +* :doc:`buck6d/coul/gauss/long ` - dispersion-damped Buckingham with long-range Coulomb * :doc:`colloid ` - integrated colloidal potential * :doc:`comb ` - charge-optimized many-body (COMB) potential * :doc:`comb3 ` - charge-optimized many-body (COMB3) potential * :doc:`cosine/squared ` - Cooke-Kremer-Deserno membrane model potential -* :doc:`coul/cut ` - cutoff Coulombic potential -* :doc:`coul/cut/soft ` - Coulombic potential with a soft core -* :doc:`coul/debye ` - cutoff Coulombic potential with Debye screening +* :doc:`coul/cut ` - cutoff Coulomb potential +* :doc:`coul/cut/soft ` - Coulomb potential with a soft core +* :doc:`coul/debye ` - cutoff Coulomb potential with Debye screening * :doc:`coul/diel ` - Coulomb potential with dielectric permittivity -* :doc:`coul/dsf ` - Coulombics with damped-shifted-force model -* :doc:`coul/long ` - long-range Coulombic potential -* :doc:`coul/long/cs ` - long-range Coulombic potential and core/shell -* :doc:`coul/long/soft ` - long-range Coulombic potential with a soft core -* :doc:`coul/msm ` - long-range MSM Coulombics -* :doc:`coul/slater/cut ` - smeared out Coulombics -* :doc:`coul/slater/long ` - long-range smeared out Coulombics -* :doc:`coul/shield ` - Coulombics for boron nitride for use with :doc:`ilp/graphene/hbn ` potential -* :doc:`coul/streitz ` - Coulombics via Streitz/Mintmire Slater orbitals -* :doc:`coul/wolf ` - Coulombics via Wolf potential -* :doc:`coul/wolf/cs ` - ditto with core/shell adjustments +* :doc:`coul/dsf ` - Coulomb with damped-shifted-force model +* :doc:`coul/long ` - long-range Coulomb potential +* :doc:`coul/long/cs ` - long-range Coulomb potential and core/shell +* :doc:`coul/long/soft ` - long-range Coulomb potential with a soft core +* :doc:`coul/msm ` - long-range MSM Coulomb +* :doc:`coul/slater/cut ` - smeared out Coulomb +* :doc:`coul/slater/long ` - long-range smeared out Coulomb +* :doc:`coul/shield ` - Coulomb for boron nitride for use with :doc:`ilp/graphene/hbn ` potential +* :doc:`coul/streitz ` - Coulomb via Streitz/Mintmire Slater orbitals +* :doc:`coul/wolf ` - Coulomb via Wolf potential +* :doc:`coul/wolf/cs ` - Coulomb via Wolf potential with core/shell adjustments * :doc:`dpd ` - dissipative particle dynamics (DPD) * :doc:`dpd/fdt ` - DPD for constant temperature and pressure * :doc:`dpd/fdt/energy ` - DPD for constant energy and enthalpy @@ -189,44 +189,45 @@ accelerated styles exist. * :doc:`lj/charmm/coul/charmm/implicit ` - CHARMM for implicit solvent * :doc:`lj/charmm/coul/long ` - CHARMM with long-range Coulomb * :doc:`lj/charmm/coul/long/soft ` - CHARMM with long-range Coulomb and a soft core -* :doc:`lj/charmm/coul/msm ` - CHARMM with long-range MSM Coulombics +* :doc:`lj/charmm/coul/msm ` - CHARMM with long-range MSM Coulomb * :doc:`lj/charmmfsw/coul/charmmfsh ` - CHARMM with force switching and shifting -* :doc:`lj/charmmfsw/coul/long ` - CHARMM with force switching and long-rnage Coulombics -* :doc:`lj/class2 ` - COMPASS (class 2) force field with no Coulomb +* :doc:`lj/charmmfsw/coul/long ` - CHARMM with force switching and long-rnage Coulomb +* :doc:`lj/class2 ` - COMPASS (class 2) force field without Coulomb * :doc:`lj/class2/coul/cut ` - COMPASS with cutoff Coulomb * :doc:`lj/class2/coul/cut/soft ` - COMPASS with cutoff Coulomb with a soft core * :doc:`lj/class2/coul/long ` - COMPASS with long-range Coulomb +* :doc:`lj/class2/coul/long/cs ` - COMPASS with long-range Coulomb with core/shell adjustments * :doc:`lj/class2/coul/long/soft ` - COMPASS with long-range Coulomb with a soft core * :doc:`lj/class2/soft ` - COMPASS (class 2) force field with no Coulomb with a soft core * :doc:`lj/cubic ` - LJ with cubic after inflection point -* :doc:`lj/cut ` - cutoff Lennard-Jones potential with no Coulomb +* :doc:`lj/cut ` - cutoff Lennard-Jones potential without Coulomb * :doc:`lj/cut/coul/cut ` - LJ with cutoff Coulomb * :doc:`lj/cut/coul/cut/soft ` - LJ with cutoff Coulomb with a soft core * :doc:`lj/cut/coul/debye ` - LJ with Debye screening added to Coulomb -* :doc:`lj/cut/coul/dsf ` - LJ with Coulombics via damped shifted forces -* :doc:`lj/cut/coul/long ` - LJ with long-range Coulombics -* :doc:`lj/cut/coul/long/cs ` - ditto with core/shell adjustments -* :doc:`lj/cut/coul/long/soft ` - LJ with long-range Coulombics with a soft core -* :doc:`lj/cut/coul/msm ` - LJ with long-range MSM Coulombics -* :doc:`lj/cut/coul/wolf ` - LJ with Coulombics via Wolf potential +* :doc:`lj/cut/coul/dsf ` - LJ with Coulomb via damped shifted forces +* :doc:`lj/cut/coul/long ` - LJ with long-range Coulomb +* :doc:`lj/cut/coul/long/cs ` - LJ with long-range Coulomb with core/shell adjustments +* :doc:`lj/cut/coul/long/soft ` - LJ with long-range Coulomb with a soft core +* :doc:`lj/cut/coul/msm ` - LJ with long-range MSM Coulomb +* :doc:`lj/cut/coul/wolf ` - LJ with Coulomb via Wolf potential * :doc:`lj/cut/dipole/cut ` - point dipoles with cutoff * :doc:`lj/cut/dipole/long ` - point dipoles with long-range Ewald * :doc:`lj/cut/soft ` - LJ with a soft core -* :doc:`lj/cut/thole/long ` - LJ with Coulombics with thole damping +* :doc:`lj/cut/thole/long ` - LJ with Coulomb with thole damping * :doc:`lj/cut/tip4p/cut ` - LJ with cutoff Coulomb for TIP4P water * :doc:`lj/cut/tip4p/long ` - LJ with long-range Coulomb for TIP4P water * :doc:`lj/cut/tip4p/long/soft ` - LJ with cutoff Coulomb for TIP4P water with a soft core * :doc:`lj/expand ` - Lennard-Jones for variable size particles -* :doc:`lj/expand/coul/long ` - Lennard-Jones for variable size particles with long-range Coulombics +* :doc:`lj/expand/coul/long ` - Lennard-Jones for variable size particles with long-range Coulomb * :doc:`lj/gromacs ` - GROMACS-style Lennard-Jones potential -* :doc:`lj/gromacs/coul/gromacs ` - GROMACS-style LJ and Coulombic potential -* :doc:`lj/long/coul/long ` - long-range LJ and long-range Coulombics +* :doc:`lj/gromacs/coul/gromacs ` - GROMACS-style LJ and Coulomb potential +* :doc:`lj/long/coul/long ` - long-range LJ and long-range Coulomb * :doc:`lj/long/dipole/long ` - long-range LJ and long-range point dipoles -* :doc:`lj/long/tip4p/long ` - long-range LJ and long-range Coulombics for TIP4P water +* :doc:`lj/long/tip4p/long ` - long-range LJ and long-range Coulomb for TIP4P water * :doc:`lj/mdf ` - LJ potential with a taper function * :doc:`lj/sdk ` - LJ for SDK coarse-graining -* :doc:`lj/sdk/coul/long ` - LJ for SDK coarse-graining with long-range Coulombics -* :doc:`lj/sdk/coul/msm ` - LJ for SDK coarse-graining with long-range Coulombics via MSM +* :doc:`lj/sdk/coul/long ` - LJ for SDK coarse-graining with long-range Coulomb +* :doc:`lj/sdk/coul/msm ` - LJ for SDK coarse-graining with long-range Coulomb via MSM * :doc:`lj/sf/dipole/sf ` - LJ with dipole interaction with shifted forces * :doc:`lj/smooth ` - smoothed Lennard-Jones potential * :doc:`lj/smooth/linear ` - linear smoothed LJ potential @@ -255,7 +256,7 @@ accelerated styles exist. * :doc:`nb3b/harmonic ` - non-bonded 3-body harmonic potential * :doc:`nm/cut ` - N-M potential * :doc:`nm/cut/coul/cut ` - N-M potential with cutoff Coulomb -* :doc:`nm/cut/coul/long ` - N-M potential with long-range Coulombics +* :doc:`nm/cut/coul/long ` - N-M potential with long-range Coulomb * :doc:`oxdna/coaxstk ` - * :doc:`oxdna/excv ` - * :doc:`oxdna/hbond ` - @@ -315,7 +316,7 @@ accelerated styles exist. * :doc:`tersoff/zbl ` - Tersoff/ZBL 3-body potential * :doc:`thole ` - Coulomb interactions with thole damping * :doc:`tip4p/cut ` - Coulomb for TIP4P water w/out LJ -* :doc:`tip4p/long ` - long-range Coulombics for TIP4P water w/out LJ +* :doc:`tip4p/long ` - long-range Coulomb for TIP4P water w/out LJ * :doc:`tip4p/long/soft ` - * :doc:`tri/lj ` - LJ potential between triangles * :doc:`ufm ` - From 8a6664eb4c130505c0cd7505f64d4bf5a9326fb7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 14 Apr 2020 21:55:24 -0400 Subject: [PATCH 10/12] make coulomb part of lj/class2/coul/long/cs consistent with lj/cut/coul/long --- src/CORESHELL/pair_lj_class2_coul_long_cs.cpp | 74 ++++++++----------- src/CORESHELL/pair_lj_cut_coul_long_cs.cpp | 8 +- 2 files changed, 33 insertions(+), 49 deletions(-) diff --git a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp index 9fb7ad118e..b99d03799a 100644 --- a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp @@ -12,33 +12,21 @@ ------------------------------------------------------------------------- */ #include "pair_lj_class2_coul_long_cs.h" -#include #include -#include #include "atom.h" -#include "comm.h" #include "force.h" -#include "kspace.h" -#include "update.h" -#include "respa.h" -#include "neighbor.h" #include "neigh_list.h" -#include "neigh_request.h" -#include "math_const.h" -#include "memory.h" -#include "error.h" -#include "utils.h" using namespace LAMMPS_NS; -using namespace MathConst; #define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +#define EWALD_P 9.95473818e-1 +#define B0 -0.1335096380159268 +#define B1 -2.57839507e-1 +#define B2 -1.37203639e-1 +#define B3 -8.88822059e-3 +#define B4 -5.80844129e-3 +#define B5 1.14652755e-1 #define EPSILON 1.0e-20 #define EPS_EWALD 1.0e-6 @@ -49,7 +37,7 @@ using namespace MathConst; PairLJClass2CoulLongCS::PairLJClass2CoulLongCS(LAMMPS *lmp) : PairLJClass2CoulLong(lmp) { ewaldflag = pppmflag = 1; - respa_enable = 1; + respa_enable = 0; // TODO: r-RESPA handling is inconsistent and thus disabled until fixed writedata = 1; ftable = NULL; } @@ -62,7 +50,7 @@ void PairLJClass2CoulLongCS::compute(int eflag, int vflag) double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; double fraction,table; double rsq,r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj; - double grij,expm2,prefactor,t,erfc; + double grij,expm2,prefactor,t,erfc,u; double factor_coul,factor_lj; int *ilist,*jlist,*numneigh,**firstneigh; @@ -111,7 +99,6 @@ void PairLJClass2CoulLongCS::compute(int eflag, int vflag) if (rsq < cutsq[itype][jtype]) { rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; r2inv = 1.0/rsq; - if (rsq < cut_coulsq) { if (!ncoultablebits || rsq <= tabinnersq) { r = sqrt(rsq); @@ -123,7 +110,8 @@ void PairLJClass2CoulLongCS::compute(int eflag, int vflag) grij = g_ewald * (r+EPS_EWALD); expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + u = 1.0 - t; + erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2; prefactor /= (r+EPS_EWALD); forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - (1.0-factor_coul)); // Additionally r2inv needs to be accordingly modified since the later @@ -133,7 +121,8 @@ void PairLJClass2CoulLongCS::compute(int eflag, int vflag) grij = g_ewald * r; expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + u = 1.0 - t; + erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2; prefactor /= r; forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); } @@ -260,8 +249,8 @@ void PairLJClass2CoulLongCS::compute_inner() jtype = type[j]; if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; r6inv = r3inv*r3inv; forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); } else forcelj = 0.0; @@ -352,8 +341,8 @@ void PairLJClass2CoulLongCS::compute_middle() jtype = type[j]; if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; r6inv = r3inv*r3inv; forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); } else forcelj = 0.0; @@ -389,7 +378,7 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair; double fraction,table; double r,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj; - double grij,expm2,prefactor,t,erfc; + double grij,expm2,prefactor,t,erfc,u; double rsw; int *ilist,*jlist,*numneigh,**firstneigh; double rsq; @@ -444,7 +433,6 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) jtype = type[j]; if (rsq < cutsq[itype][jtype]) { - rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; r2inv = 1.0/rsq; if (rsq < cut_coulsq) { @@ -453,7 +441,8 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) grij = g_ewald * r; expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + u = 1. - t; + erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2; prefactor = qqrd2e * qtmp*q[j]/r; forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - 1.0); if (rsq > cut_in_off_sq) { @@ -486,9 +475,9 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) } else forcecoul = 0.0; if (rsq < cut_ljsq[itype][jtype] && rsq > cut_in_off_sq) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); if (rsq < cut_in_on_sq) { rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff; @@ -524,9 +513,9 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) } else ecoul = 0.0; if (rsq < cut_ljsq[itype][jtype]) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - offset[itype][jtype]; evdwl *= factor_lj; @@ -551,13 +540,13 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) if (rsq <= cut_in_off_sq) { rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); } else if (rsq <= cut_in_on_sq) { - rinv = sqrt(r2inv); - r3inv = r2inv*rinv; - r6inv = r3inv*r3inv; + rinv = sqrt(r2inv); + r3inv = r2inv*rinv; + r6inv = r3inv*r3inv; forcelj = r6inv * (lj1[itype][jtype]*r3inv - lj2[itype][jtype]); } fpair = (forcecoul + factor_lj*forcelj) * r2inv; @@ -570,4 +559,3 @@ void PairLJClass2CoulLongCS::compute_outer(int eflag, int vflag) } } - diff --git a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp index 7ad544051a..12d9088f26 100644 --- a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp @@ -41,7 +41,7 @@ using namespace LAMMPS_NS; PairLJCutCoulLongCS::PairLJCutCoulLongCS(LAMMPS *lmp) : PairLJCutCoulLong(lmp) { ewaldflag = pppmflag = 1; - respa_enable = 1; + respa_enable = 0; // TODO: r-RESPA handling is inconsistent and thus disabled until fixed writedata = 1; ftable = NULL; qdist = 0.0; @@ -173,7 +173,6 @@ void PairLJCutCoulLongCS::compute(int eflag, int vflag) } if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; } else ecoul = 0.0; - if (rsq < cut_ljsq[itype][jtype]) { evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype]; @@ -433,7 +432,6 @@ void PairLJCutCoulLongCS::compute_outer(int eflag, int vflag) jtype = type[j]; if (rsq < cutsq[itype][jtype]) { - rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond; r2inv = 1.0/rsq; if (rsq < cut_coulsq) { @@ -442,9 +440,8 @@ void PairLJCutCoulLongCS::compute_outer(int eflag, int vflag) grij = g_ewald * r; expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - u = 1. - t; + u = 1. - t; erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2; - //erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; prefactor = qqrd2e * qtmp*q[j]/r; forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - 1.0); if (rsq > cut_in_off_sq) { @@ -543,7 +540,6 @@ void PairLJCutCoulLongCS::compute_outer(int eflag, int vflag) r6inv = r2inv*r2inv*r2inv; forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); } - fpair = (forcecoul + factor_lj*forcelj) * r2inv; } From e5842e9236af790a1dbde4497dd0d1ef8b2e3c1a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 14 Apr 2020 22:34:07 -0400 Subject: [PATCH 11/12] must handle CORESHELL as ACCEL_PACKAGE because of the dependency tracking --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 36bed2d649..7d2bb586f5 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -121,7 +121,7 @@ set(LAMMPS_LINK_LIBS) set(LAMMPS_DEPS) set(LAMMPS_API_DEFINES) -set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE +set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC 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 @@ -130,7 +130,7 @@ set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) -set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU) +set(ACCEL_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU) foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) option(PKG_${PKG} "Build ${PKG} Package" OFF) endforeach() From 567147cf784d53a4b59f4ed65ae10efd674f487d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 14 Apr 2020 22:37:39 -0400 Subject: [PATCH 12/12] rename DEFAULT_PACKAGES to STANDARD_PACKAGES and ACCEL_PACKAGES to SUFFIX_PACKAGES for clarity --- cmake/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7d2bb586f5..14c18c431b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -121,7 +121,7 @@ set(LAMMPS_LINK_LIBS) set(LAMMPS_DEPS) set(LAMMPS_API_DEFINES) -set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE +set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC 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 @@ -130,8 +130,8 @@ set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) -set(ACCEL_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU) -foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) +set(SUFFIX_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU) +foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) option(PKG_${PKG} "Build ${PKG} Package" OFF) endforeach() @@ -386,7 +386,7 @@ RegisterStyles(${LAMMPS_SOURCE_DIR}) ############################################## # add sources of enabled packages ############################################ -foreach(PKG ${DEFAULT_PACKAGES}) +foreach(PKG ${STANDARD_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp) @@ -414,7 +414,7 @@ foreach(PKG MPIIO) endforeach() # dedicated check for entire contents of accelerator packages -foreach(PKG ${ACCEL_PACKAGES}) +foreach(PKG ${SUFFIX_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp) @@ -507,7 +507,7 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ###################################### set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n") set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n") -set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) +set(temp_PKG_LIST ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) list(SORT temp_PKG_LIST) foreach(PKG ${temp_PKG_LIST}) if(PKG_${PKG}) @@ -698,7 +698,7 @@ include(CodeCoverage) ############################################################################### # Print package summary ############################################################################### -foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) +foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) if(PKG_${PKG}) message(STATUS "Building package: ${PKG}") endif()