reformat
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -20,22 +19,24 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "pair_coul_shield.h"
|
#include "pair_coul_shield.h"
|
||||||
#include <cmath>
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "force.h"
|
|
||||||
#include "neighbor.h"
|
|
||||||
#include "neigh_list.h"
|
|
||||||
#include "memory.h"
|
|
||||||
#include "math_special.h"
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "force.h"
|
||||||
|
#include "math_special.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "neigh_list.h"
|
||||||
|
#include "neighbor.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
PairCoulShield::PairCoulShield(LAMMPS *lmp) : Pair(lmp) {
|
PairCoulShield::PairCoulShield(LAMMPS *lmp) : Pair(lmp)
|
||||||
|
{
|
||||||
tap_flag = 1;
|
tap_flag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ void PairCoulShield::compute(int eflag, int vflag)
|
|||||||
r3 = rsq * r;
|
r3 = rsq * r;
|
||||||
rarg = 1.0 / sigmae[itype][jtype];
|
rarg = 1.0 / sigmae[itype][jtype];
|
||||||
th = r3 + MathSpecial::cube(rarg);
|
th = r3 + MathSpecial::cube(rarg);
|
||||||
epsr = 1.0/pow(th,0.333333333333333333333333);
|
epsr = 1.0 / pow(th, 1.0 / 3.0);
|
||||||
depsdr = MathSpecial::square(epsr);
|
depsdr = MathSpecial::square(epsr);
|
||||||
depsdr *= depsdr;
|
depsdr *= depsdr;
|
||||||
Vc = qqrd2e * qtmp * q[j] * epsr;
|
Vc = qqrd2e * qtmp * q[j] * epsr;
|
||||||
@ -118,7 +119,10 @@ void PairCoulShield::compute(int eflag, int vflag)
|
|||||||
if (tap_flag) {
|
if (tap_flag) {
|
||||||
Tap = calc_Tap(r, cut[itype][jtype]);
|
Tap = calc_Tap(r, cut[itype][jtype]);
|
||||||
dTap = calc_dTap(r, cut[itype][jtype]);
|
dTap = calc_dTap(r, cut[itype][jtype]);
|
||||||
} else {Tap = 1.0; dTap = 0.0;}
|
} else {
|
||||||
|
Tap = 1.0;
|
||||||
|
dTap = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
forcecoul = qqrd2e * qtmp * q[j] * r * depsdr;
|
forcecoul = qqrd2e * qtmp * q[j] * r * depsdr;
|
||||||
fvc = forcecoul * Tap - Vc * dTap / r;
|
fvc = forcecoul * Tap - Vc * dTap / r;
|
||||||
@ -134,13 +138,14 @@ void PairCoulShield::compute(int eflag, int vflag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (eflag) {
|
if (eflag) {
|
||||||
if (tap_flag) ecoul = Vc*Tap;
|
if (tap_flag)
|
||||||
else ecoul = Vc - offset[itype][jtype];
|
ecoul = Vc * Tap;
|
||||||
|
else
|
||||||
|
ecoul = Vc - offset[itype][jtype];
|
||||||
ecoul *= factor_coul;
|
ecoul *= factor_coul;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evflag) ev_tally(i,j,nlocal,newton_pair,0.0,
|
if (evflag) ev_tally(i, j, nlocal, newton_pair, 0.0, ecoul, fpair, delx, dely, delz);
|
||||||
ecoul,fpair,delx,dely,delz);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,8 +164,7 @@ void PairCoulShield::allocate()
|
|||||||
|
|
||||||
memory->create(setflag, n + 1, n + 1, "pair:setflag");
|
memory->create(setflag, n + 1, n + 1, "pair:setflag");
|
||||||
for (int i = 1; i <= n; i++)
|
for (int i = 1; i <= n; i++)
|
||||||
for (int j = i; j <= n; j++)
|
for (int j = i; j <= n; j++) setflag[i][j] = 0;
|
||||||
setflag[i][j] = 0;
|
|
||||||
|
|
||||||
memory->create(cutsq, n + 1, n + 1, "pair:cutsq");
|
memory->create(cutsq, n + 1, n + 1, "pair:cutsq");
|
||||||
memory->create(cut, n + 1, n + 1, "pair:cut");
|
memory->create(cut, n + 1, n + 1, "pair:cut");
|
||||||
@ -220,15 +224,13 @@ void PairCoulShield::coeff(int narg, char **arg)
|
|||||||
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
|
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
init specific to this pair style
|
init specific to this pair style
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void PairCoulShield::init_style()
|
void PairCoulShield::init_style()
|
||||||
{
|
{
|
||||||
if (!atom->q_flag)
|
if (!atom->q_flag) error->all(FLERR, "Pair style coul/shield requires atom attribute q");
|
||||||
error->all(FLERR,"Pair style coul/shield requires atom attribute q");
|
|
||||||
if (!atom->molecule_flag)
|
if (!atom->molecule_flag)
|
||||||
error->all(FLERR, "Pair style coul/shield requires atom attribute molecule");
|
error->all(FLERR, "Pair style coul/shield requires atom attribute molecule");
|
||||||
|
|
||||||
@ -242,7 +244,8 @@ void PairCoulShield::init_style()
|
|||||||
double PairCoulShield::init_one(int i, int j)
|
double PairCoulShield::init_one(int i, int j)
|
||||||
{
|
{
|
||||||
if (setflag[i][j] == 0) {
|
if (setflag[i][j] == 0) {
|
||||||
error->all(FLERR,"for pair style coul/shield, parameters need to be set explicitly for all pairs.");
|
error->all(FLERR,
|
||||||
|
"for pair style coul/shield, parameters need to be set explicitly for all pairs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
double *q = atom->q;
|
double *q = atom->q;
|
||||||
@ -254,10 +257,10 @@ double PairCoulShield::init_one(int i, int j)
|
|||||||
r3 = r * r * r;
|
r3 = r * r * r;
|
||||||
rarg = 1.0 / sigmae[i][j];
|
rarg = 1.0 / sigmae[i][j];
|
||||||
th = r3 + MathSpecial::cube(rarg);
|
th = r3 + MathSpecial::cube(rarg);
|
||||||
epsr = 1.0/pow(th,0.333333333333333333);
|
epsr = 1.0 / pow(th, 1.0/3.0);
|
||||||
offset[i][j] = qqrd2e * q[i] * q[j] * epsr;
|
offset[i][j] = qqrd2e * q[i] * q[j] * epsr;
|
||||||
} else offset[i][j] = 0.0;
|
} else
|
||||||
|
offset[i][j] = 0.0;
|
||||||
|
|
||||||
sigmae[j][i] = sigmae[i][j];
|
sigmae[j][i] = sigmae[i][j];
|
||||||
offset[j][i] = offset[i][j];
|
offset[j][i] = offset[i][j];
|
||||||
@ -340,9 +343,8 @@ void PairCoulShield::read_restart_settings(FILE *fp)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
double PairCoulShield::single(int i, int j, int itype, int jtype,
|
double PairCoulShield::single(int i, int j, int itype, int jtype, double rsq, double factor_coul,
|
||||||
double rsq, double factor_coul, double /*factor_lj*/,
|
double /*factor_lj*/, double &fforce)
|
||||||
double &fforce)
|
|
||||||
{
|
{
|
||||||
double r, rarg, Vc, fvc, forcecoul, phishieldec;
|
double r, rarg, Vc, fvc, forcecoul, phishieldec;
|
||||||
double r3, th, epsr, depsdr, Tap, dTap;
|
double r3, th, epsr, depsdr, Tap, dTap;
|
||||||
@ -360,7 +362,7 @@ double PairCoulShield::single(int i, int j, int itype, int jtype,
|
|||||||
r3 = rsq * r;
|
r3 = rsq * r;
|
||||||
rarg = 1.0 / sigmae[itype][jtype];
|
rarg = 1.0 / sigmae[itype][jtype];
|
||||||
th = r3 + MathSpecial::cube(rarg);
|
th = r3 + MathSpecial::cube(rarg);
|
||||||
epsr = 1.0/pow(th,0.333333333333333333);
|
epsr = 1.0 / pow(th, 1.0/3.0);
|
||||||
depsdr = epsr * epsr;
|
depsdr = epsr * epsr;
|
||||||
depsdr *= depsdr;
|
depsdr *= depsdr;
|
||||||
Vc = qqrd2e * q[i] * q[j] * epsr;
|
Vc = qqrd2e * q[i] * q[j] * epsr;
|
||||||
@ -369,13 +371,18 @@ double PairCoulShield::single(int i, int j, int itype, int jtype,
|
|||||||
if (tap_flag) {
|
if (tap_flag) {
|
||||||
Tap = calc_Tap(r, cut[itype][jtype]);
|
Tap = calc_Tap(r, cut[itype][jtype]);
|
||||||
dTap = calc_dTap(r, cut[itype][jtype]);
|
dTap = calc_dTap(r, cut[itype][jtype]);
|
||||||
} else {Tap = 1.0; dTap = 0.0;}
|
} else {
|
||||||
|
Tap = 1.0;
|
||||||
|
dTap = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
forcecoul = qqrd2e * q[i] * q[j] * r * depsdr;
|
forcecoul = qqrd2e * q[i] * q[j] * r * depsdr;
|
||||||
fvc = forcecoul * Tap - Vc * dTap / r;
|
fvc = forcecoul * Tap - Vc * dTap / r;
|
||||||
fforce = factor_coul * fvc;
|
fforce = factor_coul * fvc;
|
||||||
|
|
||||||
if (tap_flag) phishieldec = Vc*Tap;
|
if (tap_flag)
|
||||||
else phishieldec = Vc - offset[itype][jtype];
|
phishieldec = Vc * Tap;
|
||||||
|
else
|
||||||
|
phishieldec = Vc - offset[itype][jtype];
|
||||||
return factor_coul * phishieldec;
|
return factor_coul * phishieldec;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user