34double const charge2_ = charge_ * charge_;
38double const epsilon_ =
43 re_ * std::cos(thetae_ / 2.0);
45double const wh_ = ron_ / rok_ * 0.5;
46double const wo_ = (1.0 - wh_ * 2.0);
70 :
Ccl(cutoff, switchingWidth) {}
85 double &U,
const double b[]) {
103 double &U,
const double b[],
const bool fixed[]) {
104 int const nMolecules = nAtoms / 3;
105 const double (*
const rh1)[6] =
reinterpret_cast<const double (*)[6]
>(R);
106 const double (*
const rh2)[6] =
reinterpret_cast<const double (*)[6]
>(&R[3]);
107 const double (*
const ro)[3] =
108 reinterpret_cast<const double (*)[3]
>(&R[nMolecules * 6]);
109 double (*
const fh1)[6] =
reinterpret_cast<double (*)[6]
>(F);
110 double (*
const fh2)[6] =
reinterpret_cast<double (*)[6]
>(&F[3]);
111 double (*
const fo)[3] =
reinterpret_cast<double (*)[3]
>(&F[nMolecules * 6]);
112 bool const(*
const xh1)[2] =
reinterpret_cast<bool const(*)[2]
>(fixed);
113 bool const(*
const xh2)[2] =
reinterpret_cast<bool const(*)[2]
>(&fixed[1]);
114 bool const(*
const xo)[1] =
115 reinterpret_cast<bool const(*)[1]
>(&fixed[nMolecules * 2]);
116 computeTemplate(nMolecules, rh1, rh2, ro, fh1, fh2, fo, U, b, xh1, xh2, xo);
155template <
int H,
int O>
157 const int nMolecules,
const double (*
const rh1)[H * 3],
158 const double (*
const rh2)[H * 3],
const double (*
const ro)[O * 3],
159 double (*
const fh1)[H * 3],
double (*
const fh2)[H * 3],
160 double (*
const fo)[O * 3],
double &energy,
double const b[],
161 bool const (*
const xh1)[H],
bool const (*
const xh2)[H],
162 bool const (*
const xo)[O]) {
163 for (
int i = 0; i < nMolecules; ++i) {
164 for (
int a = 0; a < 3; a++) {
172 for (
int i = nMolecules - 1; i >= 0; --i) {
173 double rc1[3], rn1[3], fn1[3] = {0};
177 Water w1 = {rh1[i], rh2[i], ro[i], rn1, rc1, fh1[i], fh2[i], fo[i], fn1};
178 intramolecular(rh1[i], rh2[i], ro[i], fh1[i], fh2[i], fo[i], energy);
179 for (
int j = i - 1; j >= 0; --j) {
180 bool areFixed =
false;
181 if (xh1 and xh2 and xo) {
182 areFixed = xh1[i][0] and xh2[i][0] and xo[i][0];
184 areFixed &= xh1[j][0] and xh2[j][0] and xo[j][0];
188 double rc2[3], rn2[3], fn2[3] = {0};
191 Water w2 = {rh1[j], rh2[j], ro[j], rn2, rc2,
192 fh1[j], fh2[j], fo[j], fn2};
200 assert(not std::isnan(energy) and not std::isinf(energy));
215 double f1[3][3] = {{0}}, f2[3][3] = {{0}};
219 f1[0], f1[1], 0, f1[2]};
221 f2[0], f2[1], 0, f2[2]};
230 for (
int i = 0; i < 3; ++i) {
279 double f1[3] = {0}, f2[3] = {0};
284 for (
int i = 0; i < 3; i++) {
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 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.
void coulomb(const double r1[], const double r2[], double f1[], double f2[], double &u, double const qq)
Compute Coulomb interaction between two charges.
void calculateWeightedCentre(double const w1, double const w2, double const w3, double const r1[], double const r2[], double const r3[], double rc[])
Calculate barycentre.
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 spreadWeightedForce(double const w1, double const w2, double const w3, double f1[], double f2[], double f3[], double const fc[])
Spread force on barycentre to atoms.
static char const * getName()
Name of the potential.
void coulombWithCutoff(Water &w1, Water &w2, double &U)
Interactions between two molecules.
void computeHH_O_(const int nAtoms, const double R[], double F[], double &U, const double b[])
Compute the forces and the energy.
void lennardJonesWithCutoff(Water &w1, Water &w2, double &U)
Interactions between two molecules.
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.
Pointers for one molecule of water.
TIP4P potential for water.
Physical constants, unit conversion.