1185 lines
44 KiB
C++
1185 lines
44 KiB
C++
// clang-format off
|
|
/* ----------------------------------------------------------------------
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
|
https://www.lammps.org/, 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_buck_long_coul_long_omp.h"
|
|
|
|
#include "atom.h"
|
|
#include "comm.h"
|
|
#include "force.h"
|
|
#include "math_extra.h"
|
|
#include "neigh_list.h"
|
|
#include "suffix.h"
|
|
|
|
#include <cmath>
|
|
#include <cstring>
|
|
|
|
#include "omp_compat.h"
|
|
using namespace LAMMPS_NS;
|
|
using namespace MathExtra;
|
|
|
|
#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
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
PairBuckLongCoulLongOMP::PairBuckLongCoulLongOMP(LAMMPS *lmp) :
|
|
PairBuckLongCoulLong(lmp), ThrOMP(lmp, THR_PAIR)
|
|
{
|
|
suffix_flag |= Suffix::OMP;
|
|
respa_enable = 1;
|
|
cut_respa = nullptr;
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
void PairBuckLongCoulLongOMP::compute(int eflag, int vflag)
|
|
{
|
|
ev_init(eflag,vflag);
|
|
|
|
const int order1 = ewald_order&(1<<1);
|
|
const int order6 = ewald_order&(1<<6);
|
|
|
|
const int nall = atom->nlocal + atom->nghost;
|
|
const int nthreads = comm->nthreads;
|
|
const int inum = list->inum;
|
|
|
|
#if defined(_OPENMP)
|
|
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag)
|
|
#endif
|
|
{
|
|
int ifrom, ito, tid;
|
|
|
|
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
|
|
ThrData *thr = fix->get_thr(tid);
|
|
thr->timer(Timer::START);
|
|
ev_setup_thr(eflag, vflag, nall, eatom, vatom, nullptr, thr);
|
|
|
|
if (order6) {
|
|
if (order1) {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,0,1,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,0,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,0,1,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,0,1,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,0,1,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,0,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,0,1,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,0,1,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,1,1,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,1,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,1,1,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,1,1,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,1,1,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,1,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,1,1,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,1,1,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,0,0,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,0,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,0,0,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,0,0,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,0,0,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,0,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,0,0,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,0,0,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,1,0,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,1,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,1,0,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,1,0,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,1,0,1>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,1,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,1,0,1>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,1,0,1>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (order1) {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,0,1,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,0,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,0,1,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,0,1,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,0,1,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,0,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,0,1,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,0,1,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,1,1,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,1,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,1,1,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,1,1,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,1,1,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,1,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,1,1,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,1,1,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,0,0,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,0,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,0,0,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,0,0,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,0,0,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,0,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,0,0,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,0,0,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,0,1,0,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,0,1,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,0,1,0,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,0,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,0,1,0,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,0,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval<1,1,1,1,1,0,0>(ifrom, ito, thr);
|
|
else eval<1,1,0,1,1,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval<1,0,1,1,1,0,0>(ifrom, ito, thr);
|
|
else eval<1,0,0,1,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval<0,0,1,1,1,0,0>(ifrom, ito, thr);
|
|
else eval<0,0,0,1,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
thr->timer(Timer::PAIR);
|
|
reduce_thr(this, eflag, vflag, thr);
|
|
} // end of omp parallel region
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
void PairBuckLongCoulLongOMP::compute_inner()
|
|
{
|
|
|
|
const int nall = atom->nlocal + atom->nghost;
|
|
const int nthreads = comm->nthreads;
|
|
const int inum = list->inum_inner;
|
|
#if defined(_OPENMP)
|
|
#pragma omp parallel LMP_DEFAULT_NONE
|
|
#endif
|
|
{
|
|
int ifrom, ito, tid;
|
|
|
|
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
|
|
ThrData *thr = fix->get_thr(tid);
|
|
thr->timer(Timer::START);
|
|
ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr);
|
|
eval_inner(ifrom, ito, thr);
|
|
thr->timer(Timer::PAIR);
|
|
|
|
} // end of omp parallel region
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
void PairBuckLongCoulLongOMP::compute_middle()
|
|
{
|
|
|
|
const int nall = atom->nlocal + atom->nghost;
|
|
const int nthreads = comm->nthreads;
|
|
const int inum = list->inum_middle;
|
|
|
|
#if defined(_OPENMP)
|
|
#pragma omp parallel LMP_DEFAULT_NONE
|
|
#endif
|
|
{
|
|
int ifrom, ito, tid;
|
|
|
|
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
|
|
ThrData *thr = fix->get_thr(tid);
|
|
thr->timer(Timer::START);
|
|
ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr);
|
|
eval_middle(ifrom, ito, thr);
|
|
thr->timer(Timer::PAIR);
|
|
|
|
} // end of omp parallel region
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
void PairBuckLongCoulLongOMP::compute_outer(int eflag, int vflag)
|
|
{
|
|
ev_init(eflag,vflag);
|
|
const int order1 = ewald_order&(1<<1);
|
|
const int order6 = ewald_order&(1<<6);
|
|
|
|
const int nall = atom->nlocal + atom->nghost;
|
|
const int nthreads = comm->nthreads;
|
|
const int inum = list->inum;
|
|
|
|
#if defined(_OPENMP)
|
|
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag)
|
|
#endif
|
|
{
|
|
int ifrom, ito, tid;
|
|
|
|
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
|
|
ThrData *thr = fix->get_thr(tid);
|
|
thr->timer(Timer::START);
|
|
ev_setup_thr(eflag, vflag, nall, eatom, vatom, nullptr, thr);
|
|
|
|
if (order6) {
|
|
if (order1) {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,0,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,0,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,0,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,0,1,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,0,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,0,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,0,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,0,1,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,0,1,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,1,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,1,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,1,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,1,1,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,1,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,1,1,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,1,1,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,1,1,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,1,1,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,0,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,0,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,0,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,0,0,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,0,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,0,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,0,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,0,0,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,0,0,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,1,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,1,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,1,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,1,0,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,1,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,1,0,1>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,1,0,1>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,1,0,1>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,1,0,1>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (order1) {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,0,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,0,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,0,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,0,1,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,0,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,0,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,0,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,0,1,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,0,1,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,1,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,1,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,1,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,1,1,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,1,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,1,1,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,1,1,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,1,1,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,1,1,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (!ndisptablebits) {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,0,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,0,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,0,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,0,0,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,0,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,0,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,0,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,0,0,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,0,0,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
} else {
|
|
if (!ncoultablebits) {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,0,1,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,0,1,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,0,1,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,0,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,0,1,0,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,0,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (evflag) {
|
|
if (eflag) {
|
|
if (force->newton_pair) eval_outer<1,1,1,1,1,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,1,0,1,1,0,0>(ifrom, ito, thr);
|
|
} else {
|
|
if (force->newton_pair) eval_outer<1,0,1,1,1,0,0>(ifrom, ito, thr);
|
|
else eval_outer<1,0,0,1,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
} else {
|
|
if (force->newton_pair) eval_outer<0,0,1,1,1,0,0>(ifrom, ito, thr);
|
|
else eval_outer<0,0,0,1,1,0,0>(ifrom, ito, thr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
thr->timer(Timer::PAIR);
|
|
reduce_thr(this, eflag, vflag, thr);
|
|
} // end of omp parallel region
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
template < const int EVFLAG, const int EFLAG,
|
|
const int NEWTON_PAIR, const int CTABLE, const int DISPTABLE, const int ORDER1, const int ORDER6 >
|
|
void PairBuckLongCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr)
|
|
{
|
|
|
|
double evdwl,ecoul,fpair;
|
|
evdwl = ecoul = 0.0;
|
|
|
|
const double * const * const x = atom->x;
|
|
double * const * const f = thr->get_f();
|
|
const double * const q = atom->q;
|
|
const int * const type = atom->type;
|
|
const int nlocal = atom->nlocal;
|
|
const double * const special_coul = force->special_coul;
|
|
const double * const special_lj = force->special_lj;
|
|
const double qqrd2e = force->qqrd2e;
|
|
|
|
const double *x0 = x[0];
|
|
double *f0 = f[0], *fi = f0;
|
|
|
|
int *ilist = list->ilist;
|
|
|
|
// loop over neighbors of my atoms
|
|
|
|
int i, ii, j;
|
|
int *jneigh, *jneighn, typei, typej, ni;
|
|
double qi = 0.0, qri = 0.0, *cutsqi, *cut_bucksqi,
|
|
*buck1i, *buck2i, *buckai, *buckci, *rhoinvi, *offseti;
|
|
double r, rsq, r2inv, force_coul, force_buck;
|
|
double g2 = g_ewald_6*g_ewald_6, g6 = g2*g2*g2, g8 = g6*g2;
|
|
double xi[3], d[3];
|
|
|
|
for (ii = iifrom; ii < iito; ++ii) { // loop over my atoms
|
|
i = ilist[ii]; fi=f0+3*i;
|
|
if (ORDER1) qri = (qi = q[i])*qqrd2e; // initialize constants
|
|
offseti = offset[typei = type[i]];
|
|
buck1i = buck1[typei]; buck2i = buck2[typei];
|
|
buckai = buck_a[typei]; buckci = buck_c[typei], rhoinvi = rhoinv[typei];
|
|
cutsqi = cutsq[typei]; cut_bucksqi = cut_bucksq[typei];
|
|
memcpy(xi, x0+(i+(i<<1)), 3*sizeof(double));
|
|
jneighn = (jneigh = list->firstneigh[i])+list->numneigh[i];
|
|
|
|
for (; jneigh<jneighn; ++jneigh) { // loop over neighbors
|
|
j = *jneigh;
|
|
ni = sbmask(j);
|
|
j &= NEIGHMASK;
|
|
|
|
{ const double *xj = x0+(j+(j<<1));
|
|
d[0] = xi[0] - xj[0]; // pair vector
|
|
d[1] = xi[1] - xj[1];
|
|
d[2] = xi[2] - xj[2]; }
|
|
|
|
if ((rsq = dot3(d, d)) >= cutsqi[typej = type[j]]) continue;
|
|
r2inv = 1.0/rsq;
|
|
r = sqrt(rsq);
|
|
|
|
if (ORDER1 && (rsq < cut_coulsq)) { // coulombic
|
|
if (!CTABLE || rsq <= tabinnersq) { // series real space
|
|
double x = g_ewald*r;
|
|
double s = qri*q[j], t = 1.0/(1.0+EWALD_P*x);
|
|
if (ni == 0) {
|
|
s *= g_ewald*exp(-x*x);
|
|
force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s;
|
|
if (EFLAG) ecoul = t;
|
|
}
|
|
else { // special case
|
|
double f = s*(1.0-special_coul[ni])/r;
|
|
s *= g_ewald*exp(-x*x);
|
|
force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s-f;
|
|
if (EFLAG) ecoul = t-f;
|
|
}
|
|
} // table real space
|
|
else {
|
|
union_int_float_t t;
|
|
t.f = rsq;
|
|
const int k = (t.i & ncoulmask) >> ncoulshiftbits;
|
|
double f = (rsq-rtable[k])*drtable[k], qiqj = qi*q[j];
|
|
if (ni == 0) {
|
|
force_coul = qiqj*(ftable[k]+f*dftable[k]);
|
|
if (EFLAG) ecoul = qiqj*(etable[k]+f*detable[k]);
|
|
}
|
|
else { // special case
|
|
t.f = (1.0-special_coul[ni])*(ctable[k]+f*dctable[k]);
|
|
force_coul = qiqj*(ftable[k]+f*dftable[k]-t.f);
|
|
if (EFLAG) ecoul = qiqj*(etable[k]+f*detable[k]-t.f);
|
|
}
|
|
}
|
|
}
|
|
else force_coul = ecoul = 0.0;
|
|
|
|
if (rsq < cut_bucksqi[typej]) { // buckingham
|
|
double rn = r2inv*r2inv*r2inv,
|
|
expr = exp(-r*rhoinvi[typej]);
|
|
if (ORDER6) { // long-range
|
|
if (!DISPTABLE || rsq <= tabinnerdispsq) {
|
|
double x2 = g2*rsq, a2 = 1.0/x2;
|
|
x2 = a2*exp(-x2)*buckci[typej];
|
|
if (ni == 0) {
|
|
force_buck =
|
|
r*expr*buck1i[typej]-g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq;
|
|
if (EFLAG) evdwl = expr*buckai[typej]-g6*((a2+1.0)*a2+0.5)*x2;
|
|
}
|
|
else { // special case
|
|
double f = special_lj[ni], t = rn*(1.0-f);
|
|
force_buck = f*r*expr*buck1i[typej]-
|
|
g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq+t*buck2i[typej];
|
|
if (EFLAG) evdwl = f*expr*buckai[typej] -
|
|
g6*((a2+1.0)*a2+0.5)*x2+t*buckci[typej];
|
|
}
|
|
}
|
|
else { //table real space
|
|
union_int_float_t disp_t;
|
|
disp_t.f = rsq;
|
|
const int disp_k = (disp_t.i & ndispmask)>>ndispshiftbits;
|
|
double f_disp = (rsq-rdisptable[disp_k])*drdisptable[disp_k];
|
|
if (ni == 0) {
|
|
force_buck = r*expr*buck1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*buckci[typej];
|
|
if (EFLAG) evdwl = expr*buckai[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*buckci[typej];
|
|
}
|
|
else { //speial case
|
|
double f = special_lj[ni], t = rn*(1.0-f);
|
|
force_buck = f*r*expr*buck1i[typej] -(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*buckci[typej] +t*buck2i[typej];
|
|
if (EFLAG) evdwl = f*expr*buckai[typej] -(edisptable[disp_k]+f_disp*dedisptable[disp_k])*buckci[typej]+t*buckci[typej];
|
|
}
|
|
}
|
|
}
|
|
else { // cut
|
|
if (ni == 0) {
|
|
force_buck = r*expr*buck1i[typej]-rn*buck2i[typej];
|
|
if (EFLAG) evdwl = expr*buckai[typej] -
|
|
rn*buckci[typej]-offseti[typej];
|
|
}
|
|
else { // special case
|
|
double f = special_lj[ni];
|
|
force_buck = f*(r*expr*buck1i[typej]-rn*buck2i[typej]);
|
|
if (EFLAG)
|
|
evdwl = f*(expr*buckai[typej]-rn*buckci[typej]-offseti[typej]);
|
|
}
|
|
}
|
|
}
|
|
else force_buck = evdwl = 0.0;
|
|
|
|
fpair = (force_coul+force_buck)*r2inv;
|
|
|
|
if (NEWTON_PAIR || j < nlocal) {
|
|
double *fj = f0+(j+(j<<1)), f;
|
|
fi[0] += f = d[0]*fpair; fj[0] -= f;
|
|
fi[1] += f = d[1]*fpair; fj[1] -= f;
|
|
fi[2] += f = d[2]*fpair; fj[2] -= f;
|
|
}
|
|
else {
|
|
fi[0] += d[0]*fpair;
|
|
fi[1] += d[1]*fpair;
|
|
fi[2] += d[2]*fpair;
|
|
}
|
|
|
|
if (EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,
|
|
evdwl,ecoul,fpair,d[0],d[1],d[2],thr);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
void PairBuckLongCoulLongOMP::eval_inner(int iifrom, int iito, ThrData * const thr)
|
|
{
|
|
double r, rsq, r2inv, force_coul = 0.0, force_buck, fpair;
|
|
|
|
const double * const * const x = atom->x;
|
|
double * const * const f = thr->get_f();
|
|
const double * const q = atom->q;
|
|
const int * const type = atom->type;
|
|
const int nlocal = atom->nlocal;
|
|
const double * const special_coul = force->special_coul;
|
|
const double * const special_lj = force->special_lj;
|
|
const double qqrd2e = force->qqrd2e;
|
|
|
|
const double *x0 = x[0];
|
|
double *f0 = f[0], *fi = nullptr;
|
|
|
|
int *ilist = list->ilist_inner;
|
|
|
|
const int newton_pair = force->newton_pair;
|
|
|
|
const double cut_out_on = cut_respa[0];
|
|
const double cut_out_off = cut_respa[1];
|
|
|
|
const double cut_out_diff = cut_out_off - cut_out_on;
|
|
const double cut_out_on_sq = cut_out_on*cut_out_on;
|
|
const double cut_out_off_sq = cut_out_off*cut_out_off;
|
|
|
|
|
|
int *jneigh, *jneighn, typei, typej, ni;
|
|
const int order1 = (ewald_order|(ewald_off^-1))&(1<<1);
|
|
int i, j, ii;
|
|
double qri, *cut_bucksqi, *buck1i, *buck2i, *rhoinvi;
|
|
double xi[3], d[3];
|
|
|
|
for (ii = iifrom; ii < iito; ++ii) { // loop over my atoms
|
|
i = ilist[ii]; fi = f0+3*i;
|
|
if (order1) qri = qqrd2e*q[i];
|
|
memcpy(xi, x0+(i+(i<<1)), 3*sizeof(double));
|
|
cut_bucksqi = cut_bucksq[typei = type[i]];
|
|
buck1i = buck1[typei]; buck2i = buck2[typei]; rhoinvi = rhoinv[typei];
|
|
jneighn = (jneigh = list->firstneigh_inner[i])+list->numneigh_inner[i];
|
|
|
|
for (; jneigh<jneighn; ++jneigh) { // loop over neighbors
|
|
j = *jneigh;
|
|
ni = sbmask(j);
|
|
j &= NEIGHMASK;
|
|
|
|
{ const double *xj = x0+(j+(j<<1));
|
|
d[0] = xi[0] - xj[0]; // pair vector
|
|
d[1] = xi[1] - xj[1];
|
|
d[2] = xi[2] - xj[2]; }
|
|
|
|
if ((rsq = dot3(d, d)) >= cut_out_off_sq) continue;
|
|
r2inv = 1.0/rsq;
|
|
r = sqrt(rsq);
|
|
|
|
if (order1 && (rsq < cut_coulsq)) // coulombic
|
|
force_coul = ni == 0 ?
|
|
qri*q[j]/r : qri*q[j]/r*special_coul[ni];
|
|
|
|
if (rsq < cut_bucksqi[typej = type[j]]) { // buckingham
|
|
double rn = r2inv*r2inv*r2inv,
|
|
expr = exp(-r*rhoinvi[typej]);
|
|
force_buck = ni == 0 ?
|
|
(r*expr*buck1i[typej]-rn*buck2i[typej]) :
|
|
(r*expr*buck1i[typej]-rn*buck2i[typej])*special_lj[ni];
|
|
}
|
|
else force_buck = 0.0;
|
|
|
|
fpair = (force_coul + force_buck) * r2inv;
|
|
|
|
if (rsq > cut_out_on_sq) { // switching
|
|
double rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff;
|
|
fpair *= 1.0 + rsw*rsw*(2.0*rsw-3.0);
|
|
}
|
|
|
|
if (newton_pair || j < nlocal) { // force update
|
|
double *fj = f0+(j+(j<<1)), f;
|
|
fi[0] += f = d[0]*fpair; fj[0] -= f;
|
|
fi[1] += f = d[1]*fpair; fj[1] -= f;
|
|
fi[2] += f = d[2]*fpair; fj[2] -= f;
|
|
}
|
|
else {
|
|
fi[0] += d[0]*fpair;
|
|
fi[1] += d[1]*fpair;
|
|
fi[2] += d[2]*fpair;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
void PairBuckLongCoulLongOMP::eval_middle(int iifrom, int iito, ThrData * const thr)
|
|
{
|
|
double r, rsq, r2inv, force_coul = 0.0, force_buck, fpair;
|
|
|
|
const double * const * const x = atom->x;
|
|
double * const * const f = thr->get_f();
|
|
const double * const q = atom->q;
|
|
const int * const type = atom->type;
|
|
const int nlocal = atom->nlocal;
|
|
const double * const special_coul = force->special_coul;
|
|
const double * const special_lj = force->special_lj;
|
|
const double qqrd2e = force->qqrd2e;
|
|
|
|
const double *x0 = x[0];
|
|
double *f0 = f[0], *fi = nullptr;
|
|
|
|
int *ilist = list->ilist_middle;
|
|
|
|
const int newton_pair = force->newton_pair;
|
|
|
|
const double cut_in_off = cut_respa[0];
|
|
const double cut_in_on = cut_respa[1];
|
|
const double cut_out_on = cut_respa[2];
|
|
const double cut_out_off = cut_respa[3];
|
|
|
|
const double cut_in_diff = cut_in_on - cut_in_off;
|
|
const double cut_out_diff = cut_out_off - cut_out_on;
|
|
const double cut_in_off_sq = cut_in_off*cut_in_off;
|
|
const double cut_in_on_sq = cut_in_on*cut_in_on;
|
|
const double cut_out_on_sq = cut_out_on*cut_out_on;
|
|
const double cut_out_off_sq = cut_out_off*cut_out_off;
|
|
|
|
int *jneigh, *jneighn, typei, typej, ni;
|
|
const int order1 = (ewald_order|(ewald_off^-1))&(1<<1);
|
|
int i, j, ii;
|
|
double qri, *cut_bucksqi, *buck1i, *buck2i, *rhoinvi;
|
|
double xi[3], d[3];
|
|
|
|
for (ii = iifrom; ii < iito; ++ii) { // loop over my atoms
|
|
i = ilist[ii]; fi = f0+3*i;
|
|
if (order1) qri = qqrd2e*q[i];
|
|
memcpy(xi, x0+(i+(i<<1)), 3*sizeof(double));
|
|
cut_bucksqi = cut_bucksq[typei = type[i]];
|
|
buck1i = buck1[typei]; buck2i = buck2[typei]; rhoinvi = rhoinv[typei];
|
|
jneighn = (jneigh = list->firstneigh_middle[i])+list->numneigh_middle[i];
|
|
|
|
for (; jneigh<jneighn; ++jneigh) { // loop over neighbors
|
|
j = *jneigh;
|
|
ni = sbmask(j);
|
|
j &= NEIGHMASK;
|
|
|
|
{ const double *xj = x0+(j+(j<<1));
|
|
d[0] = xi[0] - xj[0]; // pair vector
|
|
d[1] = xi[1] - xj[1];
|
|
d[2] = xi[2] - xj[2]; }
|
|
|
|
if ((rsq = dot3(d, d)) >= cut_out_off_sq) continue;
|
|
if (rsq <= cut_in_off_sq) continue;
|
|
r2inv = 1.0/rsq;
|
|
r = sqrt(rsq);
|
|
|
|
if (order1 && (rsq < cut_coulsq)) // coulombic
|
|
force_coul = ni == 0 ?
|
|
qri*q[j]/r : qri*q[j]/r*special_coul[ni];
|
|
|
|
if (rsq < cut_bucksqi[typej = type[j]]) { // buckingham
|
|
double rn = r2inv*r2inv*r2inv,
|
|
expr = exp(-r*rhoinvi[typej]);
|
|
force_buck = ni == 0 ?
|
|
(r*expr*buck1i[typej]-rn*buck2i[typej]) :
|
|
(r*expr*buck1i[typej]-rn*buck2i[typej])*special_lj[ni];
|
|
}
|
|
else force_buck = 0.0;
|
|
|
|
fpair = (force_coul + force_buck) * r2inv;
|
|
|
|
if (rsq < cut_in_on_sq) { // switching
|
|
double rsw = (sqrt(rsq) - cut_in_off)/cut_in_diff;
|
|
fpair *= rsw*rsw*(3.0 - 2.0*rsw);
|
|
}
|
|
if (rsq > cut_out_on_sq) {
|
|
double rsw = (sqrt(rsq) - cut_out_on)/cut_out_diff;
|
|
fpair *= 1.0 + rsw*rsw*(2.0*rsw-3.0);
|
|
}
|
|
|
|
if (newton_pair || j < nlocal) { // force update
|
|
double *fj = f0+(j+(j<<1)), f;
|
|
fi[0] += f = d[0]*fpair; fj[0] -= f;
|
|
fi[1] += f = d[1]*fpair; fj[1] -= f;
|
|
fi[2] += f = d[2]*fpair; fj[2] -= f;
|
|
}
|
|
else {
|
|
fi[0] += d[0]*fpair;
|
|
fi[1] += d[1]*fpair;
|
|
fi[2] += d[2]*fpair;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
template < const int EVFLAG, const int EFLAG,
|
|
const int NEWTON_PAIR, const int CTABLE, const int DISPTABLE, const int ORDER1, const int ORDER6 >
|
|
void PairBuckLongCoulLongOMP::eval_outer(int iiform, int iito, ThrData * const thr)
|
|
{
|
|
double evdwl,ecoul,fpair,fvirial;
|
|
evdwl = ecoul = 0.0;
|
|
|
|
const double * const * const x = atom->x;
|
|
double * const * const f = thr->get_f();
|
|
const double * const q = atom->q;
|
|
const int * const type = atom->type;
|
|
const int nlocal = atom->nlocal;
|
|
const double * const special_coul = force->special_coul;
|
|
const double * const special_lj = force->special_lj;
|
|
const double qqrd2e = force->qqrd2e;
|
|
|
|
const double *x0 = x[0];
|
|
double *f0 = f[0], *fi = f0;
|
|
|
|
int *ilist = list->ilist;
|
|
|
|
int i, j, ii;
|
|
int *jneigh, *jneighn, typei, typej, ni, respa_flag;
|
|
double qi = 0.0, qri = 0.0;
|
|
double *cutsqi, *cut_bucksqi, *buck1i, *buck2i, *buckai, *buckci, *rhoinvi, *offseti;
|
|
double r, rsq, r2inv, force_coul, force_buck;
|
|
double g2 = g_ewald_6*g_ewald_6, g6 = g2*g2*g2, g8 = g6*g2;
|
|
double respa_buck = 0.0, respa_coul = 0.0, frespa = 0.0;
|
|
double xi[3], d[3];
|
|
|
|
const double cut_in_off = cut_respa[2];
|
|
const double cut_in_on = cut_respa[3];
|
|
|
|
const double cut_in_diff = cut_in_on - cut_in_off;
|
|
const double cut_in_off_sq = cut_in_off*cut_in_off;
|
|
const double cut_in_on_sq = cut_in_on*cut_in_on;
|
|
|
|
for (ii = iiform; ii < iito; ++ii) { // loop over my atoms
|
|
i = ilist[ii]; fi = f0+3*i;
|
|
if (ORDER1) qri = (qi = q[i])*qqrd2e; // initialize constants
|
|
offseti = offset[typei = type[i]];
|
|
buck1i = buck1[typei]; buck2i = buck2[typei];
|
|
buckai = buck_a[typei]; buckci = buck_c[typei]; rhoinvi = rhoinv[typei];
|
|
cutsqi = cutsq[typei]; cut_bucksqi = cut_bucksq[typei];
|
|
memcpy(xi, x0+(i+(i<<1)), 3*sizeof(double));
|
|
jneighn = (jneigh = list->firstneigh[i])+list->numneigh[i];
|
|
|
|
for (; jneigh<jneighn; ++jneigh) { // loop over neighbors
|
|
j = *jneigh;
|
|
ni = sbmask(j);
|
|
j &= NEIGHMASK;
|
|
|
|
{ const double *xj = x0+(j+(j<<1));
|
|
d[0] = xi[0] - xj[0]; // pair vector
|
|
d[1] = xi[1] - xj[1];
|
|
d[2] = xi[2] - xj[2]; }
|
|
|
|
if ((rsq = dot3(d, d)) >= cutsqi[typej = type[j]]) continue;
|
|
r2inv = 1.0/rsq;
|
|
r = sqrt(rsq);
|
|
|
|
frespa = 1.0; //check whether and how to compute respa corrections
|
|
respa_coul = 0.0;
|
|
respa_buck = 0.0;
|
|
respa_flag = rsq < cut_in_on_sq ? 1 : 0;
|
|
if (respa_flag && (rsq > cut_in_off_sq)) {
|
|
double rsw = (r-cut_in_off)/cut_in_diff;
|
|
frespa = 1-rsw*rsw*(3.0-2.0*rsw);
|
|
}
|
|
|
|
if (ORDER1 && (rsq < cut_coulsq)) { // coulombic
|
|
if (!CTABLE || rsq <= tabinnersq) { // series real space
|
|
double s = qri*q[j];
|
|
if (respa_flag) // correct for respa
|
|
respa_coul = ni == 0 ? frespa*s/r : frespa*s/r*special_coul[ni];
|
|
double x = g_ewald*r, t = 1.0/(1.0+EWALD_P*x);
|
|
if (ni == 0) {
|
|
s *= g_ewald*exp(-x*x);
|
|
force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s-respa_coul;
|
|
if (EFLAG) ecoul = t;
|
|
}
|
|
else { // correct for special
|
|
double ri = s*(1.0-special_coul[ni])/r; s *= g_ewald*exp(-x*x);
|
|
force_coul = (t *= ((((t*A5+A4)*t+A3)*t+A2)*t+A1)*s/x)+EWALD_F*s-ri-respa_coul;
|
|
if (EFLAG) ecoul = t-ri;
|
|
}
|
|
} // table real space
|
|
else {
|
|
if (respa_flag) {
|
|
double s = qri*q[j];
|
|
respa_coul = ni == 0 ? frespa*s/r : frespa*s/r*special_coul[ni];
|
|
}
|
|
union_int_float_t t;
|
|
t.f = rsq;
|
|
const int k = (t.i & ncoulmask) >> ncoulshiftbits;
|
|
double f = (rsq-rtable[k])*drtable[k], qiqj = qi*q[j];
|
|
if (ni == 0) {
|
|
force_coul = qiqj*(ftable[k]+f*dftable[k]);
|
|
if (EFLAG) ecoul = qiqj*(etable[k]+f*detable[k]);
|
|
}
|
|
else { // correct for special
|
|
t.f = (1.0-special_coul[ni])*(ctable[k]+f*dctable[k]);
|
|
force_coul = qiqj*(ftable[k]+f*dftable[k]-t.f);
|
|
if (EFLAG) {
|
|
t.f = (1.0-special_coul[ni])*(ptable[k]+f*dptable[k]);
|
|
ecoul = qiqj*(etable[k]+f*detable[k]-t.f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else force_coul = respa_coul = ecoul = 0.0;
|
|
|
|
if (rsq < cut_bucksqi[typej]) { // buckingham
|
|
double rn = r2inv*r2inv*r2inv,
|
|
expr = exp(-r*rhoinvi[typej]);
|
|
if (respa_flag) respa_buck = ni == 0 ? // correct for respa
|
|
frespa*(r*expr*buck1i[typej]-rn*buck2i[typej]) :
|
|
frespa*(r*expr*buck1i[typej]-rn*buck2i[typej])*special_lj[ni];
|
|
if (ORDER6) { // long-range form
|
|
if (!DISPTABLE || rsq <= tabinnerdispsq) {
|
|
double x2 = g2*rsq, a2 = 1.0/x2;
|
|
x2 = a2*exp(-x2)*buckci[typej];
|
|
if (ni == 0) {
|
|
force_buck =
|
|
r*expr*buck1i[typej]-g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq-respa_buck;
|
|
if (EFLAG) evdwl = expr*buckai[typej]-g6*((a2+1.0)*a2+0.5)*x2;
|
|
}
|
|
else { // correct for special
|
|
double f = special_lj[ni], t = rn*(1.0-f);
|
|
force_buck = f*r*expr*buck1i[typej]-
|
|
g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq+t*buck2i[typej]-respa_buck;
|
|
if (EFLAG) evdwl = f*expr*buckai[typej] -
|
|
g6*((a2+1.0)*a2+0.5)*x2+t*buckci[typej];
|
|
}
|
|
}
|
|
else { // table real space
|
|
union_int_float_t disp_t;
|
|
disp_t.f = rsq;
|
|
const int disp_k = (disp_t.i & ndispmask)>>ndispshiftbits;
|
|
double f_disp = (rsq-rdisptable[disp_k])*drdisptable[disp_k];
|
|
double rn = r2inv*r2inv*r2inv;
|
|
if (ni == 0) {
|
|
force_buck = r*expr*buck1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*buckci[typej]-respa_buck;
|
|
if (EFLAG) evdwl = expr*buckai[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*buckci[typej];
|
|
}
|
|
else { //special case
|
|
double f = special_lj[ni], t = rn*(1.0-f);
|
|
force_buck = f*r*expr*buck1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*buckci[typej]+t*buck2i[typej]-respa_buck;
|
|
if (EFLAG) evdwl = f*expr*buckai[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*buckci[typej]+t*buckci[typej];
|
|
}
|
|
}
|
|
}
|
|
else { // cut form
|
|
if (ni == 0) {
|
|
force_buck = r*expr*buck1i[typej]-rn*buck2i[typej]-respa_buck;
|
|
if (EFLAG)
|
|
evdwl = expr*buckai[typej]-rn*buckci[typej]-offseti[typej];
|
|
}
|
|
else { // correct for special
|
|
double f = special_lj[ni];
|
|
force_buck = f*(r*expr*buck1i[typej]-rn*buck2i[typej])-respa_buck;
|
|
if (EFLAG)
|
|
evdwl = f*(expr*buckai[typej]-rn*buckci[typej]-offseti[typej]);
|
|
}
|
|
}
|
|
}
|
|
else force_buck = respa_buck = evdwl = 0.0;
|
|
|
|
fpair = (force_coul+force_buck)*r2inv;
|
|
|
|
if (NEWTON_PAIR || j < nlocal) {
|
|
double *fj = f0+(j+(j<<1)), f;
|
|
fi[0] += f = d[0]*fpair; fj[0] -= f;
|
|
fi[1] += f = d[1]*fpair; fj[1] -= f;
|
|
fi[2] += f = d[2]*fpair; fj[2] -= f;
|
|
}
|
|
else {
|
|
fi[0] += d[0]*fpair;
|
|
fi[1] += d[1]*fpair;
|
|
fi[2] += d[2]*fpair;
|
|
}
|
|
|
|
if (EVFLAG) {
|
|
fvirial = (force_coul + force_buck + respa_coul + respa_buck)*r2inv;
|
|
ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,
|
|
evdwl,ecoul,fvirial,d[0],d[1],d[2],thr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|