reformat and use std::numeric_limits<double>::min() instead of DBL_MIN (Posix-only)
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -19,22 +18,22 @@
|
||||
#include "comm.h"
|
||||
#include "neigh_list.h"
|
||||
#include "suffix.h"
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "omp_compat.h"
|
||||
#define GRIDDENSITY 8000
|
||||
#define GRIDSTART 0.1
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
// max number of interaction per atom for f(Z) environment potential
|
||||
|
||||
static constexpr int leadDimInteractionList = 64;
|
||||
|
||||
#define GRIDDENSITY 8000
|
||||
#define GRIDSTART 0.1
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairEDIPOMP::PairEDIPOMP(LAMMPS *lmp) :
|
||||
PairEDIP(lmp), ThrOMP(lmp, THR_PAIR)
|
||||
PairEDIPOMP::PairEDIPOMP(LAMMPS *lmp) : PairEDIP(lmp), ThrOMP(lmp, THR_PAIR)
|
||||
{
|
||||
suffix_flag |= Suffix::OMP;
|
||||
respa_enable = 0;
|
||||
@ -63,13 +62,18 @@ void PairEDIPOMP::compute(int eflag, int vflag)
|
||||
|
||||
if (evflag) {
|
||||
if (eflag) {
|
||||
if (vflag_atom) eval<1,1,1>(ifrom, ito, thr);
|
||||
else eval<1,1,0>(ifrom, ito, thr);
|
||||
if (vflag_atom)
|
||||
eval<1, 1, 1>(ifrom, ito, thr);
|
||||
else
|
||||
eval<1, 1, 0>(ifrom, ito, thr);
|
||||
} else {
|
||||
if (vflag_atom) eval<1,0,1>(ifrom, ito, thr);
|
||||
else eval<1,0,0>(ifrom, ito, thr);
|
||||
if (vflag_atom)
|
||||
eval<1, 0, 1>(ifrom, ito, thr);
|
||||
else
|
||||
eval<1, 0, 0>(ifrom, ito, thr);
|
||||
}
|
||||
} else eval<0,0,0>(ifrom, ito, thr);
|
||||
} else
|
||||
eval<0, 0, 0>(ifrom, ito, thr);
|
||||
|
||||
thr->timer(Timer::PAIR);
|
||||
reduce_thr(this, eflag, vflag, thr);
|
||||
@ -203,8 +207,7 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
|
||||
interpolY1 = exp3B[interpolIDX];
|
||||
interpolY2 = exp3B[interpolIDX + 1];
|
||||
exp3B_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
exp3B_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
exp3BDerived_ij = -exp3B_ij * gammInvRMinusCutoffA * invRMinusCutoffA;
|
||||
|
||||
@ -213,8 +216,7 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
|
||||
interpolY1 = exp2B[interpolIDX];
|
||||
interpolY2 = exp2B[interpolIDX + 1];
|
||||
exp2B_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
exp2B_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
exp2BDerived_ij = -exp2B_ij * sigmaInvRMinusCutoffA * invRMinusCutoffA;
|
||||
|
||||
@ -223,26 +225,24 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
|
||||
interpolY1 = pow2B[interpolIDX];
|
||||
interpolY2 = pow2B[interpolIDX + 1];
|
||||
pow2B_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
pow2B_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
pre_thrPow2B_ij[neighbor_j] = pow2B_ij;
|
||||
|
||||
// zeta and its derivative
|
||||
|
||||
if (r_ij < cutoffC) zeta_i += 1.0;
|
||||
if (r_ij < cutoffC)
|
||||
zeta_i += 1.0;
|
||||
else {
|
||||
interpolY1 = cutoffFunction[interpolIDX];
|
||||
interpolY2 = cutoffFunction[interpolIDX + 1];
|
||||
cutoffFunction_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
cutoffFunction_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
zeta_i += cutoffFunction_ij;
|
||||
|
||||
interpolY1 = cutoffFunctionDerived[interpolIDX];
|
||||
interpolY2 = cutoffFunctionDerived[interpolIDX + 1];
|
||||
zeta_iDerived = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
zeta_iDerived = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
zeta_iDerivedInvR_ij = zeta_iDerived * invR_ij;
|
||||
|
||||
@ -264,23 +264,19 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
|
||||
interpolY1 = expMinusBetaZeta_iZeta_iGrid[interpolIDX];
|
||||
interpolY2 = expMinusBetaZeta_iZeta_iGrid[interpolIDX + 1];
|
||||
expMinusBetaZeta_iZeta_i = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
expMinusBetaZeta_iZeta_i = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
interpolY1 = qFunctionGrid[interpolIDX];
|
||||
interpolY2 = qFunctionGrid[interpolIDX + 1];
|
||||
qFunction = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
qFunction = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
interpolY1 = tauFunctionGrid[interpolIDX];
|
||||
interpolY2 = tauFunctionGrid[interpolIDX + 1];
|
||||
tauFunction = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
tauFunction = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
interpolY1 = tauFunctionDerivedGrid[interpolIDX];
|
||||
interpolY2 = tauFunctionDerivedGrid[interpolIDX + 1];
|
||||
tauFunctionDerived = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
tauFunctionDerived = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
forceModCoord_factor = 2.0 * beta * zeta_i * expMinusBetaZeta_iZeta_i;
|
||||
|
||||
@ -317,8 +313,7 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
forceModCoord += (forceModCoord_factor * exp2B_ij);
|
||||
|
||||
exp2BDerived_ij = pre_thrExp2BDerived_ij[neighbor_j];
|
||||
forceMod2B = exp2BDerived_ij * potential2B_factor +
|
||||
exp2B_ij * pow2BDerived_ij;
|
||||
forceMod2B = exp2BDerived_ij * potential2B_factor + exp2B_ij * pow2BDerived_ij;
|
||||
|
||||
directorCos_ij_x = invR_ij * dr_ij[0];
|
||||
directorCos_ij_y = invR_ij * dr_ij[1];
|
||||
@ -343,8 +338,9 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
|
||||
evdwl = (exp2B_ij * potential2B_factor);
|
||||
|
||||
if (EVFLAG) ev_tally_thr(this,i, j, nlocal, /* newton_pair */ 1, evdwl, 0.0,
|
||||
-forceMod2B*invR_ij, dr_ij[0], dr_ij[1], dr_ij[2],thr);
|
||||
if (EVFLAG)
|
||||
ev_tally_thr(this, i, j, nlocal, /* newton_pair */ 1, evdwl, 0.0, -forceMod2B * invR_ij,
|
||||
dr_ij[0], dr_ij[1], dr_ij[2], thr);
|
||||
|
||||
// three-body Forces
|
||||
|
||||
@ -371,15 +367,13 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
directorCos_ik_y = invR_ik * dr_ik[1];
|
||||
directorCos_ik_z = invR_ik * dr_ik[2];
|
||||
|
||||
cosTeta = directorCos_ij_x * directorCos_ik_x +
|
||||
directorCos_ij_y * directorCos_ik_y +
|
||||
cosTeta = directorCos_ij_x * directorCos_ik_x + directorCos_ij_y * directorCos_ik_y +
|
||||
directorCos_ij_z * directorCos_ik_z;
|
||||
|
||||
cosTetaDiff = cosTeta + tauFunction;
|
||||
cosTetaDiffCosTetaDiff = cosTetaDiff * cosTetaDiff;
|
||||
qFunctionCosTetaDiffCosTetaDiff = cosTetaDiffCosTetaDiff * qFunction;
|
||||
expMinusQFunctionCosTetaDiffCosTetaDiff =
|
||||
exp(-qFunctionCosTetaDiffCosTetaDiff);
|
||||
expMinusQFunctionCosTetaDiffCosTetaDiff = exp(-qFunctionCosTetaDiffCosTetaDiff);
|
||||
|
||||
potentia3B_factor = lambda *
|
||||
((1.0 - expMinusQFunctionCosTetaDiffCosTetaDiff) +
|
||||
@ -388,39 +382,29 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
exp3B_ik = pre_thrExp3B_ij[neighbor_k];
|
||||
exp3BDerived_ik = pre_thrExp3BDerived_ij[neighbor_k];
|
||||
|
||||
forceMod3B_factor1_ij = - exp3BDerived_ij * exp3B_ik *
|
||||
potentia3B_factor;
|
||||
forceMod3B_factor2 = 2.0 * lambda * exp3B_ij * exp3B_ik *
|
||||
qFunction * cosTetaDiff *
|
||||
forceMod3B_factor1_ij = -exp3BDerived_ij * exp3B_ik * potentia3B_factor;
|
||||
forceMod3B_factor2 = 2.0 * lambda * exp3B_ij * exp3B_ik * qFunction * cosTetaDiff *
|
||||
(eta + expMinusQFunctionCosTetaDiffCosTetaDiff);
|
||||
forceMod3B_factor2_ij = forceMod3B_factor2 * invR_ij;
|
||||
|
||||
f_ij[0] = forceMod3B_factor1_ij * directorCos_ij_x +
|
||||
forceMod3B_factor2_ij *
|
||||
(cosTeta * directorCos_ij_x - directorCos_ik_x);
|
||||
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_x - directorCos_ik_x);
|
||||
f_ij[1] = forceMod3B_factor1_ij * directorCos_ij_y +
|
||||
forceMod3B_factor2_ij *
|
||||
(cosTeta * directorCos_ij_y - directorCos_ik_y);
|
||||
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_y - directorCos_ik_y);
|
||||
f_ij[2] = forceMod3B_factor1_ij * directorCos_ij_z +
|
||||
forceMod3B_factor2_ij *
|
||||
(cosTeta * directorCos_ij_z - directorCos_ik_z);
|
||||
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_z - directorCos_ik_z);
|
||||
|
||||
forceMod3B_factor1_ik = - exp3BDerived_ik * exp3B_ij *
|
||||
potentia3B_factor;
|
||||
forceMod3B_factor1_ik = -exp3BDerived_ik * exp3B_ij * potentia3B_factor;
|
||||
forceMod3B_factor2_ik = forceMod3B_factor2 * invR_ik;
|
||||
|
||||
f_ik[0] = forceMod3B_factor1_ik * directorCos_ik_x +
|
||||
forceMod3B_factor2_ik *
|
||||
(cosTeta * directorCos_ik_x - directorCos_ij_x);
|
||||
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_x - directorCos_ij_x);
|
||||
f_ik[1] = forceMod3B_factor1_ik * directorCos_ik_y +
|
||||
forceMod3B_factor2_ik *
|
||||
(cosTeta * directorCos_ik_y - directorCos_ij_y);
|
||||
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_y - directorCos_ij_y);
|
||||
f_ik[2] = forceMod3B_factor1_ik * directorCos_ik_z +
|
||||
forceMod3B_factor2_ik *
|
||||
(cosTeta * directorCos_ik_z - directorCos_ij_z);
|
||||
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_z - directorCos_ij_z);
|
||||
|
||||
forceModCoord += (forceMod3B_factor2 *
|
||||
(tauFunctionDerived - 0.5 * mu * cosTetaDiff));
|
||||
forceModCoord += (forceMod3B_factor2 * (tauFunctionDerived - 0.5 * mu * cosTetaDiff));
|
||||
|
||||
f[j].x += f_ij[0];
|
||||
f[j].y += f_ij[1];
|
||||
@ -468,8 +452,9 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
f[j].y += f_ij[1];
|
||||
f[j].z += f_ij[2];
|
||||
|
||||
if (EVFLAG) ev_tally_thr(this, i, j, nlocal, /* newton_pair */ 1, 0.0, 0.0,
|
||||
-forceModCoord_ij, dr_ij[0], dr_ij[1], dr_ij[2],thr);
|
||||
if (EVFLAG)
|
||||
ev_tally_thr(this, i, j, nlocal, /* newton_pair */ 1, 0.0, 0.0, -forceModCoord_ij, dr_ij[0],
|
||||
dr_ij[1], dr_ij[2], thr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -34,8 +33,8 @@
|
||||
#include "neighbor.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -53,11 +52,10 @@ static constexpr int leadDimInteractionList = 64;
|
||||
|
||||
PairEDIP::PairEDIP(LAMMPS *lmp) :
|
||||
Pair(lmp), preInvR_ij(nullptr), preExp3B_ij(nullptr), preExp3BDerived_ij(nullptr),
|
||||
preExp2B_ij(nullptr), preExp2BDerived_ij(nullptr), prePow2B_ij(nullptr),
|
||||
preForceCoord(nullptr), cutoffFunction(nullptr), cutoffFunctionDerived(nullptr),
|
||||
pow2B(nullptr), exp2B(nullptr), exp3B(nullptr), qFunctionGrid(nullptr),
|
||||
expMinusBetaZeta_iZeta_iGrid(nullptr), tauFunctionGrid(nullptr),
|
||||
tauFunctionDerivedGrid(nullptr)
|
||||
preExp2B_ij(nullptr), preExp2BDerived_ij(nullptr), prePow2B_ij(nullptr), preForceCoord(nullptr),
|
||||
cutoffFunction(nullptr), cutoffFunctionDerived(nullptr), pow2B(nullptr), exp2B(nullptr),
|
||||
exp3B(nullptr), qFunctionGrid(nullptr), expMinusBetaZeta_iZeta_iGrid(nullptr),
|
||||
tauFunctionGrid(nullptr), tauFunctionDerivedGrid(nullptr)
|
||||
{
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
@ -209,8 +207,7 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
|
||||
interpolY1 = exp3B[interpolIDX];
|
||||
interpolY2 = exp3B[interpolIDX + 1];
|
||||
exp3B_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
exp3B_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
exp3BDerived_ij = -exp3B_ij * gammInvRMinusCutoffA * invRMinusCutoffA;
|
||||
|
||||
@ -219,8 +216,7 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
|
||||
interpolY1 = exp2B[interpolIDX];
|
||||
interpolY2 = exp2B[interpolIDX + 1];
|
||||
exp2B_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
exp2B_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
exp2BDerived_ij = -exp2B_ij * sigmaInvRMinusCutoffA * invRMinusCutoffA;
|
||||
|
||||
@ -229,26 +225,24 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
|
||||
interpolY1 = pow2B[interpolIDX];
|
||||
interpolY2 = pow2B[interpolIDX + 1];
|
||||
pow2B_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
pow2B_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
prePow2B_ij[neighbor_j] = pow2B_ij;
|
||||
|
||||
// zeta and its derivative
|
||||
|
||||
if (r_ij < cutoffC) zeta_i += 1.0;
|
||||
if (r_ij < cutoffC)
|
||||
zeta_i += 1.0;
|
||||
else {
|
||||
interpolY1 = cutoffFunction[interpolIDX];
|
||||
interpolY2 = cutoffFunction[interpolIDX + 1];
|
||||
cutoffFunction_ij = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
cutoffFunction_ij = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
zeta_i += cutoffFunction_ij;
|
||||
|
||||
interpolY1 = cutoffFunctionDerived[interpolIDX];
|
||||
interpolY2 = cutoffFunctionDerived[interpolIDX + 1];
|
||||
zeta_iDerived = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
zeta_iDerived = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
zeta_iDerivedInvR_ij = zeta_iDerived * invR_ij;
|
||||
|
||||
@ -270,23 +264,19 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
|
||||
interpolY1 = expMinusBetaZeta_iZeta_iGrid[interpolIDX];
|
||||
interpolY2 = expMinusBetaZeta_iZeta_iGrid[interpolIDX + 1];
|
||||
expMinusBetaZeta_iZeta_i = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
expMinusBetaZeta_iZeta_i = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
interpolY1 = qFunctionGrid[interpolIDX];
|
||||
interpolY2 = qFunctionGrid[interpolIDX + 1];
|
||||
qFunction = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
qFunction = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
interpolY1 = tauFunctionGrid[interpolIDX];
|
||||
interpolY2 = tauFunctionGrid[interpolIDX + 1];
|
||||
tauFunction = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
tauFunction = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
interpolY1 = tauFunctionDerivedGrid[interpolIDX];
|
||||
interpolY2 = tauFunctionDerivedGrid[interpolIDX + 1];
|
||||
tauFunctionDerived = interpolY1 + (interpolY2 - interpolY1) *
|
||||
(interpolTMP-interpolIDX);
|
||||
tauFunctionDerived = interpolY1 + (interpolY2 - interpolY1) * (interpolTMP - interpolIDX);
|
||||
|
||||
forceModCoord_factor = 2.0 * beta * zeta_i * expMinusBetaZeta_iZeta_i;
|
||||
|
||||
@ -323,8 +313,7 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
forceModCoord += (forceModCoord_factor * exp2B_ij);
|
||||
|
||||
exp2BDerived_ij = preExp2BDerived_ij[neighbor_j];
|
||||
forceMod2B = exp2BDerived_ij * potential2B_factor +
|
||||
exp2B_ij * pow2BDerived_ij;
|
||||
forceMod2B = exp2BDerived_ij * potential2B_factor + exp2B_ij * pow2BDerived_ij;
|
||||
|
||||
directorCos_ij_x = invR_ij * dr_ij[0];
|
||||
directorCos_ij_y = invR_ij * dr_ij[1];
|
||||
@ -349,8 +338,9 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
|
||||
evdwl = (exp2B_ij * potential2B_factor);
|
||||
|
||||
if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0,
|
||||
-forceMod2B*invR_ij, dr_ij[0], dr_ij[1], dr_ij[2]);
|
||||
if (evflag)
|
||||
ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, -forceMod2B * invR_ij, dr_ij[0], dr_ij[1],
|
||||
dr_ij[2]);
|
||||
|
||||
// three-body Forces
|
||||
|
||||
@ -377,15 +367,13 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
directorCos_ik_y = invR_ik * dr_ik[1];
|
||||
directorCos_ik_z = invR_ik * dr_ik[2];
|
||||
|
||||
cosTeta = directorCos_ij_x * directorCos_ik_x +
|
||||
directorCos_ij_y * directorCos_ik_y +
|
||||
cosTeta = directorCos_ij_x * directorCos_ik_x + directorCos_ij_y * directorCos_ik_y +
|
||||
directorCos_ij_z * directorCos_ik_z;
|
||||
|
||||
cosTetaDiff = cosTeta + tauFunction;
|
||||
cosTetaDiffCosTetaDiff = cosTetaDiff * cosTetaDiff;
|
||||
qFunctionCosTetaDiffCosTetaDiff = cosTetaDiffCosTetaDiff * qFunction;
|
||||
expMinusQFunctionCosTetaDiffCosTetaDiff =
|
||||
exp(-qFunctionCosTetaDiffCosTetaDiff);
|
||||
expMinusQFunctionCosTetaDiffCosTetaDiff = exp(-qFunctionCosTetaDiffCosTetaDiff);
|
||||
|
||||
potentia3B_factor = lambda *
|
||||
((1.0 - expMinusQFunctionCosTetaDiffCosTetaDiff) +
|
||||
@ -394,39 +382,29 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
exp3B_ik = preExp3B_ij[neighbor_k];
|
||||
exp3BDerived_ik = preExp3BDerived_ij[neighbor_k];
|
||||
|
||||
forceMod3B_factor1_ij = - exp3BDerived_ij * exp3B_ik *
|
||||
potentia3B_factor;
|
||||
forceMod3B_factor2 = 2.0 * lambda * exp3B_ij * exp3B_ik *
|
||||
qFunction * cosTetaDiff *
|
||||
forceMod3B_factor1_ij = -exp3BDerived_ij * exp3B_ik * potentia3B_factor;
|
||||
forceMod3B_factor2 = 2.0 * lambda * exp3B_ij * exp3B_ik * qFunction * cosTetaDiff *
|
||||
(eta + expMinusQFunctionCosTetaDiffCosTetaDiff);
|
||||
forceMod3B_factor2_ij = forceMod3B_factor2 * invR_ij;
|
||||
|
||||
f_ij[0] = forceMod3B_factor1_ij * directorCos_ij_x +
|
||||
forceMod3B_factor2_ij *
|
||||
(cosTeta * directorCos_ij_x - directorCos_ik_x);
|
||||
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_x - directorCos_ik_x);
|
||||
f_ij[1] = forceMod3B_factor1_ij * directorCos_ij_y +
|
||||
forceMod3B_factor2_ij *
|
||||
(cosTeta * directorCos_ij_y - directorCos_ik_y);
|
||||
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_y - directorCos_ik_y);
|
||||
f_ij[2] = forceMod3B_factor1_ij * directorCos_ij_z +
|
||||
forceMod3B_factor2_ij *
|
||||
(cosTeta * directorCos_ij_z - directorCos_ik_z);
|
||||
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_z - directorCos_ik_z);
|
||||
|
||||
forceMod3B_factor1_ik = - exp3BDerived_ik * exp3B_ij *
|
||||
potentia3B_factor;
|
||||
forceMod3B_factor1_ik = -exp3BDerived_ik * exp3B_ij * potentia3B_factor;
|
||||
forceMod3B_factor2_ik = forceMod3B_factor2 * invR_ik;
|
||||
|
||||
f_ik[0] = forceMod3B_factor1_ik * directorCos_ik_x +
|
||||
forceMod3B_factor2_ik *
|
||||
(cosTeta * directorCos_ik_x - directorCos_ij_x);
|
||||
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_x - directorCos_ij_x);
|
||||
f_ik[1] = forceMod3B_factor1_ik * directorCos_ik_y +
|
||||
forceMod3B_factor2_ik *
|
||||
(cosTeta * directorCos_ik_y - directorCos_ij_y);
|
||||
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_y - directorCos_ij_y);
|
||||
f_ik[2] = forceMod3B_factor1_ik * directorCos_ik_z +
|
||||
forceMod3B_factor2_ik *
|
||||
(cosTeta * directorCos_ik_z - directorCos_ij_z);
|
||||
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_z - directorCos_ij_z);
|
||||
|
||||
forceModCoord += (forceMod3B_factor2 *
|
||||
(tauFunctionDerived - 0.5 * mu * cosTetaDiff));
|
||||
forceModCoord += (forceMod3B_factor2 * (tauFunctionDerived - 0.5 * mu * cosTetaDiff));
|
||||
|
||||
f[j][0] += f_ij[0];
|
||||
f[j][1] += f_ij[1];
|
||||
@ -474,11 +452,9 @@ void PairEDIP::compute(int eflag, int vflag)
|
||||
f[j][1] += f_ij[1];
|
||||
f[j][2] += f_ij[2];
|
||||
|
||||
// potential energy
|
||||
|
||||
evdwl = 0.0;
|
||||
if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0,
|
||||
-forceModCoord_ij, dr_ij[0], dr_ij[1], dr_ij[2]);
|
||||
if (evflag)
|
||||
ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, -forceModCoord_ij, dr_ij[0], dr_ij[1],
|
||||
dr_ij[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,53 +476,46 @@ void PairEDIP::allocateGrids(void)
|
||||
double maxArgumentTauFunctionGrid;
|
||||
double maxArgumentQFunctionGrid;
|
||||
double maxArgumentExpMinusBetaZeta_iZeta_i;
|
||||
double const leftLimitToZero = -DBL_MIN * 1000.0;
|
||||
double const leftLimitToZero = -std::numeric_limits<double>::min() * 1000.0;
|
||||
|
||||
deallocateGrids();
|
||||
|
||||
// tauFunctionGrid
|
||||
|
||||
maxArgumentTauFunctionGrid = leadDimInteractionList;
|
||||
numGridPointsTauFunctionGrid = (int)
|
||||
((maxArgumentTauFunctionGrid) * GRIDDENSITY) + 2;
|
||||
numGridPointsTauFunctionGrid = (int) ((maxArgumentTauFunctionGrid) *GRIDDENSITY) + 2;
|
||||
|
||||
memory->create(tauFunctionGrid,numGridPointsTauFunctionGrid,
|
||||
"edip:tauFunctionGrid");
|
||||
memory->create(tauFunctionGrid, numGridPointsTauFunctionGrid, "edip:tauFunctionGrid");
|
||||
memory->create(tauFunctionDerivedGrid, numGridPointsTauFunctionGrid,
|
||||
"edip:tauFunctionDerivedGrid");
|
||||
|
||||
// expMinusBetaZeta_iZeta_iGrid
|
||||
|
||||
maxArgumentExpMinusBetaZeta_iZeta_i = leadDimInteractionList;
|
||||
numGridPointsExpMinusBetaZeta_iZeta_i = (int)
|
||||
((maxArgumentExpMinusBetaZeta_iZeta_i) * GRIDDENSITY) + 2;
|
||||
memory->create(expMinusBetaZeta_iZeta_iGrid,
|
||||
numGridPointsExpMinusBetaZeta_iZeta_i,
|
||||
numGridPointsExpMinusBetaZeta_iZeta_i =
|
||||
(int) ((maxArgumentExpMinusBetaZeta_iZeta_i) *GRIDDENSITY) + 2;
|
||||
memory->create(expMinusBetaZeta_iZeta_iGrid, numGridPointsExpMinusBetaZeta_iZeta_i,
|
||||
"edip:expMinusBetaZeta_iZeta_iGrid");
|
||||
|
||||
// qFunctionGrid
|
||||
|
||||
maxArgumentQFunctionGrid = leadDimInteractionList;
|
||||
numGridPointsQFunctionGrid = (int)
|
||||
((maxArgumentQFunctionGrid) * GRIDDENSITY) + 2;
|
||||
numGridPointsQFunctionGrid = (int) ((maxArgumentQFunctionGrid) *GRIDDENSITY) + 2;
|
||||
memory->create(qFunctionGrid, numGridPointsQFunctionGrid, "edip:qFunctionGrid");
|
||||
|
||||
// cutoffFunction
|
||||
|
||||
numGridPointsOneCutoffFunction = (int) ((cutoffC - GRIDSTART) * GRIDDENSITY);
|
||||
numGridPointsNotOneCutoffFunction = (int) ((cutoffA - cutoffC) * GRIDDENSITY);
|
||||
numGridPointsCutoffFunction = numGridPointsOneCutoffFunction +
|
||||
numGridPointsNotOneCutoffFunction+2;
|
||||
numGridPointsCutoffFunction =
|
||||
numGridPointsOneCutoffFunction + numGridPointsNotOneCutoffFunction + 2;
|
||||
|
||||
memory->create(cutoffFunction,numGridPointsCutoffFunction,
|
||||
"edip:cutoffFunction");
|
||||
memory->create(cutoffFunctionDerived,numGridPointsCutoffFunction,
|
||||
"edip:cutoffFunctionDerived");
|
||||
memory->create(cutoffFunction, numGridPointsCutoffFunction, "edip:cutoffFunction");
|
||||
memory->create(cutoffFunctionDerived, numGridPointsCutoffFunction, "edip:cutoffFunctionDerived");
|
||||
|
||||
// pow2B
|
||||
|
||||
numGridPointsR = (int)
|
||||
((cutoffA + leftLimitToZero - GRIDSTART) * GRIDDENSITY);
|
||||
numGridPointsR = (int) ((cutoffA + leftLimitToZero - GRIDSTART) * GRIDDENSITY);
|
||||
numGridPointsRTotal = numGridPointsR + 2;
|
||||
|
||||
memory->create(pow2B, numGridPointsRTotal, "edip:pow2B");
|
||||
@ -565,11 +534,9 @@ void PairEDIP::allocatePreLoops(void)
|
||||
deallocatePreLoops();
|
||||
memory->create(preInvR_ij, nthreads * leadDimInteractionList, "edip:preInvR_ij");
|
||||
memory->create(preExp3B_ij, nthreads * leadDimInteractionList, "edip:preExp3B_ij");
|
||||
memory->create(preExp3BDerived_ij,nthreads*leadDimInteractionList,
|
||||
"edip:preExp3BDerived_ij");
|
||||
memory->create(preExp3BDerived_ij, nthreads * leadDimInteractionList, "edip:preExp3BDerived_ij");
|
||||
memory->create(preExp2B_ij, nthreads * leadDimInteractionList, "edip:preExp2B_ij");
|
||||
memory->create(preExp2BDerived_ij,nthreads*leadDimInteractionList,
|
||||
"edip:preExp2BDerived_ij");
|
||||
memory->create(preExp2BDerived_ij, nthreads * leadDimInteractionList, "edip:preExp2BDerived_ij");
|
||||
memory->create(prePow2B_ij, nthreads * leadDimInteractionList, "edip:prePow2B_ij");
|
||||
memory->create(preForceCoord, 5 * nthreads * leadDimInteractionList, "edip:preForceCoord");
|
||||
}
|
||||
@ -652,23 +619,20 @@ void PairEDIP::initGrids(void)
|
||||
double deltaArgumentQFunctionGrid;
|
||||
double deltaArgumentTauFunctionGrid;
|
||||
double deltaArgumentExpMinusBetaZeta_iZeta_i;
|
||||
double const leftLimitToZero = -DBL_MIN * 1000.0;
|
||||
double const leftLimitToZero = -std::numeric_limits<double>::min() * 1000.0;
|
||||
|
||||
// tauFunctionGrid
|
||||
|
||||
maxArgumentTauFunctionGrid = leadDimInteractionList;
|
||||
|
||||
numGridPointsTauFunctionGrid = (int)
|
||||
((maxArgumentTauFunctionGrid) * GRIDDENSITY) + 2;
|
||||
numGridPointsTauFunctionGrid = (int) ((maxArgumentTauFunctionGrid) *GRIDDENSITY) + 2;
|
||||
|
||||
r = 0.0;
|
||||
deltaArgumentTauFunctionGrid = 1.0 / GRIDDENSITY;
|
||||
|
||||
for (l = 0; l < numGridPointsTauFunctionGrid; l++) {
|
||||
tauFunctionGrid[l] = u1 + u2 * u3 * exp(-u4 * r) -
|
||||
u2 * exp(-2.0 * u4 * r);
|
||||
tauFunctionDerivedGrid[l] = - u2 * u3 * u4 * exp(-u4 * r) +
|
||||
2.0 * u2 * u4 * exp(-2.0 * u4 * r);
|
||||
tauFunctionGrid[l] = u1 + u2 * u3 * exp(-u4 * r) - u2 * exp(-2.0 * u4 * r);
|
||||
tauFunctionDerivedGrid[l] = -u2 * u3 * u4 * exp(-u4 * r) + 2.0 * u2 * u4 * exp(-2.0 * u4 * r);
|
||||
r += deltaArgumentTauFunctionGrid;
|
||||
}
|
||||
|
||||
@ -676,8 +640,8 @@ void PairEDIP::initGrids(void)
|
||||
|
||||
maxArgumentExpMinusBetaZeta_iZeta_i = leadDimInteractionList;
|
||||
|
||||
numGridPointsExpMinusBetaZeta_iZeta_i = (int)
|
||||
((maxArgumentExpMinusBetaZeta_iZeta_i) * GRIDDENSITY) + 2;
|
||||
numGridPointsExpMinusBetaZeta_iZeta_i =
|
||||
(int) ((maxArgumentExpMinusBetaZeta_iZeta_i) *GRIDDENSITY) + 2;
|
||||
|
||||
r = 0.0;
|
||||
deltaArgumentExpMinusBetaZeta_iZeta_i = 1.0 / GRIDDENSITY;
|
||||
@ -690,8 +654,7 @@ void PairEDIP::initGrids(void)
|
||||
// qFunctionGrid
|
||||
|
||||
maxArgumentQFunctionGrid = leadDimInteractionList;
|
||||
numGridPointsQFunctionGrid =
|
||||
(int) ((maxArgumentQFunctionGrid) * GRIDDENSITY) + 2;
|
||||
numGridPointsQFunctionGrid = (int) ((maxArgumentQFunctionGrid) *GRIDDENSITY) + 2;
|
||||
|
||||
r = 0.0;
|
||||
deltaArgumentQFunctionGrid = 1.0 / GRIDDENSITY;
|
||||
@ -703,10 +666,8 @@ void PairEDIP::initGrids(void)
|
||||
|
||||
// cutoffFunction
|
||||
|
||||
numGridPointsOneCutoffFunction =
|
||||
(int) ((cutoffC - GRIDSTART) * GRIDDENSITY);
|
||||
numGridPointsNotOneCutoffFunction =
|
||||
(int) ((cutoffA-cutoffC) * GRIDDENSITY);
|
||||
numGridPointsOneCutoffFunction = (int) ((cutoffC - GRIDSTART) * GRIDDENSITY);
|
||||
numGridPointsNotOneCutoffFunction = (int) ((cutoffA - cutoffC) * GRIDDENSITY);
|
||||
numGridPointsCutoffFunction =
|
||||
numGridPointsOneCutoffFunction + numGridPointsNotOneCutoffFunction + 2;
|
||||
|
||||
@ -719,8 +680,7 @@ void PairEDIP::initGrids(void)
|
||||
r += deltaArgumentCutoffFunction;
|
||||
}
|
||||
|
||||
for (l = numGridPointsOneCutoffFunction;
|
||||
l < numGridPointsCutoffFunction; l++) {
|
||||
for (l = numGridPointsOneCutoffFunction; l < numGridPointsCutoffFunction; l++) {
|
||||
temp = (cutoffA - cutoffC) / (r - cutoffC);
|
||||
temp3 = temp * temp * temp;
|
||||
temp4 = temp3 * temp;
|
||||
@ -732,8 +692,7 @@ void PairEDIP::initGrids(void)
|
||||
|
||||
// pow2B
|
||||
|
||||
numGridPointsR = (int)
|
||||
((cutoffA + leftLimitToZero - GRIDSTART) * GRIDDENSITY);
|
||||
numGridPointsR = (int) ((cutoffA + leftLimitToZero - GRIDSTART) * GRIDDENSITY);
|
||||
|
||||
r = GRIDSTART;
|
||||
deltaArgumentR = 1.0 / GRIDDENSITY;
|
||||
@ -762,8 +721,7 @@ void PairEDIP::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
map_element2type(narg - 3, arg + 3);
|
||||
if (nelements != 1)
|
||||
error->all(FLERR,"Pair style edip only supports single element potentials");
|
||||
if (nelements != 1) error->all(FLERR, "Pair style edip only supports single element potentials");
|
||||
|
||||
// read potential file and initialize potential parameters
|
||||
|
||||
@ -783,8 +741,7 @@ void PairEDIP::coeff(int narg, char **arg)
|
||||
|
||||
void PairEDIP::init_style()
|
||||
{
|
||||
if (force->newton_pair == 0)
|
||||
error->all(FLERR,"Pair style edip requires newton pair on");
|
||||
if (force->newton_pair == 0) error->all(FLERR, "Pair style edip requires newton pair on");
|
||||
|
||||
// need a full neighbor list
|
||||
|
||||
@ -841,7 +798,8 @@ void PairEDIP::read_file(char *file)
|
||||
if (ptr == nullptr) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
} else
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof, 1, MPI_INT, 0, world);
|
||||
if (eof) break;
|
||||
@ -863,7 +821,8 @@ void PairEDIP::read_file(char *file)
|
||||
if (ptr == nullptr) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
} else
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof, 1, MPI_INT, 0, world);
|
||||
if (eof) break;
|
||||
@ -873,8 +832,7 @@ void PairEDIP::read_file(char *file)
|
||||
nwords = utils::count_words(line);
|
||||
}
|
||||
|
||||
if (nwords != params_per_line)
|
||||
error->all(FLERR,"Incorrect format in EDIP potential file");
|
||||
if (nwords != params_per_line) error->all(FLERR, "Incorrect format in EDIP potential file");
|
||||
|
||||
// words = ptrs to all words in line
|
||||
|
||||
@ -900,8 +858,7 @@ void PairEDIP::read_file(char *file)
|
||||
|
||||
if (nparams == maxparam) {
|
||||
maxparam += DELTA;
|
||||
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param),
|
||||
"pair:params");
|
||||
params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params");
|
||||
|
||||
// make certain all addional allocated storage is initialized
|
||||
// to avoid false positives when checking with valgrind
|
||||
@ -930,12 +887,11 @@ void PairEDIP::read_file(char *file)
|
||||
params[nparams].u3 = atof(words[18]);
|
||||
params[nparams].u4 = atof(words[19]);
|
||||
|
||||
if (params[nparams].A < 0.0 || params[nparams].B < 0.0 ||
|
||||
params[nparams].cutoffA < 0.0 || params[nparams].cutoffC < 0.0 ||
|
||||
params[nparams].alpha < 0.0 || params[nparams].beta < 0.0 ||
|
||||
params[nparams].eta < 0.0 || params[nparams].gamm < 0.0 ||
|
||||
params[nparams].lambda < 0.0 || params[nparams].mu < 0.0 ||
|
||||
params[nparams].rho < 0.0 || params[nparams].sigma < 0.0)
|
||||
if (params[nparams].A < 0.0 || params[nparams].B < 0.0 || params[nparams].cutoffA < 0.0 ||
|
||||
params[nparams].cutoffC < 0.0 || params[nparams].alpha < 0.0 ||
|
||||
params[nparams].beta < 0.0 || params[nparams].eta < 0.0 || params[nparams].gamm < 0.0 ||
|
||||
params[nparams].lambda < 0.0 || params[nparams].mu < 0.0 || params[nparams].rho < 0.0 ||
|
||||
params[nparams].sigma < 0.0)
|
||||
error->all(FLERR, "Illegal EDIP parameter");
|
||||
|
||||
nparams++;
|
||||
@ -963,8 +919,7 @@ void PairEDIP::setup_params()
|
||||
for (k = 0; k < nelements; k++) {
|
||||
n = -1;
|
||||
for (m = 0; m < nparams; m++) {
|
||||
if (i == params[m].ielement && j == params[m].jelement &&
|
||||
k == params[m].kelement) {
|
||||
if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) {
|
||||
if (n >= 0) error->all(FLERR, "Potential file has duplicate entry");
|
||||
n = m;
|
||||
}
|
||||
@ -975,9 +930,7 @@ void PairEDIP::setup_params()
|
||||
|
||||
// set cutoff square
|
||||
|
||||
for (m = 0; m < nparams; m++) {
|
||||
params[m].cutsq = params[m].cutoffA*params[m].cutoffA;
|
||||
}
|
||||
for (m = 0; m < nparams; m++) { params[m].cutsq = params[m].cutoffA * params[m].cutoffA; }
|
||||
|
||||
// set cutmax to max of all params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user