26#if defined(FORCEFIELDS_UNIT_SYSTEM_HPP) && \
27 (FORCEFIELDS_UNIT_SYSTEM_HPP != \
28 FORCEFIELDS_UNIT_SYSTEM_ELECTRONVOLT_ANGSTROM_FEMTOSECOND_ECHARGE)
32 std::acos(-1.0 / 3.0);
60 :
Ccl(cutoff, switchingWidth) {}
63 double &U,
const double b[]) {
68 double &U,
const double b[],
const bool fixed[]) {
69 int const nMolecules = nAtoms / 3;
70 const double (*
const rh1)[6] =
reinterpret_cast<const double (*)[6]
>(R);
71 const double (*
const rh2)[6] =
reinterpret_cast<const double (*)[6]
>(&R[3]);
72 const double (*
const ro)[3] =
73 reinterpret_cast<const double (*)[3]
>(&R[nMolecules * 6]);
74 double (*
const fh1)[6] =
reinterpret_cast<double (*)[6]
>(F);
75 double (*
const fh2)[6] =
reinterpret_cast<double (*)[6]
>(&F[3]);
76 double (*
const fo)[3] =
reinterpret_cast<double (*)[3]
>(&F[nMolecules * 6]);
77 bool const(*
const xh1)[2] =
reinterpret_cast<bool const(*)[2]
>(fixed);
78 bool const(*
const xh2)[2] =
reinterpret_cast<bool const(*)[2]
>(&fixed[1]);
79 bool const(*
const xo)[1] =
80 reinterpret_cast<bool const(*)[1]
>(&fixed[nMolecules * 2]);
81 computeTemplate(nMolecules, rh1, rh2, ro, fh1, fh2, fo, U, b, xh1, xh2, xo);
92 double f1[3] = {0}, f2[3] = {0};
97 for (
int i = 0; i < 3; i++) {
111 double f1[3][3] = {{0}}, f2[3][3] = {{0}};
122 for (
int i = 0; i < 3; ++i) {
154 double const d =
re_ / a / a / v.
_1;
155 for (
int i = 0; i < 3; ++i)
156 ro.
n[i] = v.
v[i] * d;
174template <
int H,
int O>
176 const int nMolecules,
const double (*
const rh1)[H * 3],
177 const double (*
const rh2)[H * 3],
const double (*
const ro)[O * 3],
178 double (*
const fh1)[H * 3],
double (*
const fh2)[H * 3],
179 double (*
const fo)[O * 3],
double &energy,
double const b[],
180 bool const (*
const xh1)[H],
bool const (*
const xh2)[H],
181 bool const (*
const xo)[O]) {
182 for (
int i = 0; i < nMolecules; ++i) {
183 for (
int a = 0; a < 3; a++) {
192 for (
int i = nMolecules - 1; i >= 0; --i) {
195 Water w1(rh1[i], rh2[i], ro[i], rc1, fh1[i], fh2[i], fo[i]);
198 for (
int j = i - 1; j >= 0; --j) {
199 bool areFixed =
false;
200 if (xh1 and xh2 and xo) {
201 areFixed = xh1[i][0] and xh2[i][0] and xo[i][0];
203 areFixed &= xh1[j][0] and xh2[j][0] and xo[j][0];
209 Water w2(rh1[j], rh2[j], ro[j], rc2, fh1[j], fh2[j], fo[j]);
215 assert(not std::isnan(energy) and not std::isinf(energy));
static double const re_
Distance OH at equilibrium.
void initialiseDtheta(Vector3 const &v1, Vector3 const &v2, Dtheta &dth, double const thetaEquilibrium)
Initialise Dtheta.
void intramolecular(double const rh1[], double const rh2[], double const ro[], double fh1[], double fh2[], double fo[], double &energy)
Interactions inside one molecules.
void switching(ChargeGroup< N, R, F > &g1, ChargeGroup< N, R, F > &g2, double &energy, double cutoff, double switchingWidth)
void coulomb(const double r1[], const double r2[], double f1[], double f2[], double &u, double const qq)
Compute Coulomb interaction between two charges.
void lennardJones(double const distance, double &force, double &energy, double const epsilon, double const sigma)
Lennard-Jones 12-6 between two atoms.
void calculateCentre(double const r1[], double const r2[], double rc[])
Calculate centre of two points.
void setPeriodicity(const double periods[])
Set periodicity.
void distance(const double x[], const double y[], double z[], double &z1, double &z2)
Distance vector, norm and norm square.
static const double A_
Lennard-Jones.
void initialiseRho(Vector3 const &v, Rho &r)
Initialise Rho.
static const double roh_
Distance OH.
void coulombWithCutoff(Water &w1, Water &w2, double &U)
Interactions between two molecules.
void intramolecular(Water &water, double &U)
Interactions within a molecules.
static const double charge_
Charge on one hydrogen.
void lennardJonesWithCutoff(Water &w1, Water &w2, double &U)
Interactions between two molecules.
char const * getName() const
Name of the potential.
static const double theta_
Angle HOH.
static const double rhh_
Distance HH.
static const double charge2_
Square of # charge_.
static const double sigma_
Lennard-Jones. See PotentialBase::lennardJones() for definition.
void coulombFull(Water &w1, Water &w2, double &U)
Interactions between two molecules.
void computeTemplate(const int nMolecules, const double(*const rh1)[H *3], const double(*const rh2)[H *3], const double(*const ro)[O *3], double(*const fh1)[H *3], double(*const fh2)[H *3], double(*const fo)[O *3], double &energy, double const b[], bool const (*const xh1)[H]=0, bool const (*const xh2)[H]=0, bool const (*const xo)[O]=0)
Compute forces and energy.
static double const polarisationEnergy_
Polarisation correction.
static const double epsilon_
Lennard-Jones. See PotentialBase::lennardJones() for definition.
void computeHH_O_(const int nAtoms, const double R[], double F[], double &U, const double b[])
Compute the forces and the energy.
static const double B_
Lennard-Jones.
Physical constants and unit conversion.
SPC/E potential for water.
double n[3]
Convert derivative to force.
Pointers to molecule of water.