Loading...
Searching...
No Matches
forcefields::ZhuPhilpott< P > Class Template Reference

Forcefield for water and platinum interactions. More...

#include <zhu_philpott.hpp>

Inheritance diagram for forcefields::ZhuPhilpott< P >:

Public Member Functions

 ZhuPhilpott ()
 ZhuPhilpott (double cutoff, double switchingWidth)
 ZhuPhilpott (ZhuPhilpott const &)
void operator= (ZhuPhilpott const &)
 ~ZhuPhilpott ()
void computeHH_O_Pt_ (const int nWater, const int nPt, const double r[], double f[], double &energy, double const b[], bool const fixed[])
 Compute water-platinum forcefield.
void computeHH_O_ (const int nWater, const double r[], double f[], double &energy, double const b[], bool const fixed[])
 Compute water-platinum interactions, call with water's positions only.
int nPlatinum () const
 Number of platinum atoms.
void setPlatinum (int nPlatinum, double const positions[])
 Initialises the positions of the atoms of platinum.
template<int H, int O, int H3, int O3>
void computeTemplate (const int nWater, const double(*const rh1)[H3], const double(*const rh2)[H3], const double(*const ro)[O3], double(*const fh1)[H3], double(*const fh2)[H3], double(*const fo)[O3], const int nPt, const double rPt[][3], double fPt[][3], double &energy, double const b[], bool const (*const xh1)[H], bool const (*const xh2)[H], bool const (*const xo)[O], bool const xPt[])
Public Member Functions inherited from forcefields::SpceCcl
 SpceCcl ()
 SpceCcl (double cutoff, double switchingWidth)
void computeHH_O_ (const int nAtoms, const double R[], double F[], double &U, const double b[])
 Compute the forces and the energy.
void computeHH_O_ (const int nAtoms, const double R[], double F[], double &U, const double b[], const bool fixed[])
 Compute the forces and the energy (with fixed atom optimisation).
char const * getName () const
 Name of the potential.
Public Member Functions inherited from forcefields::Ccl
 Ccl ()
void computeHH_O_ (const int nAtoms, const double R[], double F[], double &U, const double b[])
 Compute the forces and the energy.
void computeHH_O_ (const int nAtoms, const double R[], double F[], double &U, const double b[], const bool fixed[])
 Compute the forces and the energy (with fixed atom optimisation).
char const * getName () const
 Name of the potential.
Public Member Functions inherited from forcefields::PotentialBase
 PotentialBase ()
 Non bond interaction cutoff.
 PotentialBase (double cutoff, double switchingWidth)
virtual ~PotentialBase ()
double getCutoff () const
void setCutoff (double cutoff)
double getSwitchingWidth () const
 Width of the switching zone.
void setSwitchingWidth (double width)

Static Public Member Functions

static char const * getName ()
 Name of the potential.
static double applyPeriodicity0 (double r, double const period)
 Minimum image representation.
static void applyPeriodicity0 (double r[], double const periods[])
 Minimum image representation.

Private Member Functions

template<int H, int O, int H3, int O3>
void computeTemplate (const int nWater, const double(*const rh1)[H3], const double(*const rh2)[H3], const double(*const ro)[O3], double(*const fh1)[H3], double(*const fh2)[H3], double(*const fo)[O3], const int nPt, const double rPt[][3], double fPt[][3], double &energy, double const b[], bool const (*const xh1)[H]=0, bool const (*const xh2)[H]=0, bool const (*const xo)[O]=0, bool const *xPt=0)
void interactWithCorePt (Water &water, int const nPt, double const rPt[][3], double fPt[][3], double &energy)
 Interaction of one molecule of water with the whole platinum.
void interactionPtO (double const R1[], double const R2[], double F1[], double F2[], double &energy)
void interactionPtH (double const R1[], double const R2[], double F1[], double F2[], double &energy)
void anisotropic (const double distance[], double force[], double &energy, double const epsilon, double const sigma, double const alpha)
 Anisotropic interaction between water and platinum.
void isotropic10 (double const distance, double &force, double &energy, double const epsilon, double const sigma, double const C10)
 Isotropic interaction between water and platinum.
void interactWithImage (Water &w1, Water &w2, double &U)
 Interactions of a molecule with an image.
void coulombWithCutoff (Water &w1, Water &w2, double &u, double const relativePermittivity)
 Coulomb interaction between two molecules within the swithcing zone.
void coulombFull (Water &w1, Water &w2, double &U, double const relativePermittivity)
 Coulomb interaction between two molecules with cutoff.

Private Attributes

int nPlatinum_ {0}
std::vector< double > positions_
std::vector< double > forces_

Additional Inherited Members

Protected Member Functions inherited from forcefields::SpceCcl
void intramolecular (Water &water, double &U)
 Interactions within a molecules.
void lennardJonesWithCutoff (Water &w1, Water &w2, double &U)
 Interactions between two molecules.
void coulombWithCutoff (Water &w1, Water &w2, double &U)
 Interactions between two molecules.
void coulombFull (Water &w1, Water &w2, double &U)
 Interactions between two molecules.
Protected Member Functions inherited from forcefields::Ccl
 Ccl (double cutoff, double switchingWidth)
 Constructor with cutoff for derived classes.
void intramolecular (double const rh1[], double const rh2[], double const ro[], double fh1[], double fh2[], double fo[], double &energy)
 Interactions inside one molecules.
void initialiseRho (Vector3 const &v, Rho &r)
 Initialise Rho.
void initialiseDtheta (Vector3 const &v1, Vector3 const &v2, Dtheta &dth, double const thetaEquilibrium)
 Initialise Dtheta.
void intramolecular (Rho const &ro1, Rho const &ro2, Dtheta const &dth, double &energy, double fh1[], double fh2[], double fo[])
 Compute intramolecular energy and forces.
Protected Member Functions inherited from forcefields::PotentialBase
void restrainAngle (double const r1[], double const r2[], double const r3[], double f1[], double f2[], double f3[], double &u, const double k, const double aeq)
 Angular quadratic restraints.
void calculateCentre (double const r1[], double const r2[], double rc[])
 Calculate centre of two points.
void calculateCentre (double const r1[], double const r2[], double const r3[], double rc[])
 Calculate centre of three points.
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 coulombWithCutoff (const double r1[], const double r2[], double f1[], double f2[], double &u, double const qq)
 Coulomb interaction with single charge based cutoff.
void coulomb (const double r1[], const double r2[], double f1[], double f2[], double &u, double const qq)
 Compute Coulomb interaction between two charges.
void coulomb (double distance, double &force, double &energy, double const qq)
 Compute Coulomb interaction between two charges.
void spreadForce (double f1[], double f2[], double const fc[])
 Spread force on centre to other points.
void spreadForce (double f1[], double f2[], double f3[], double const fc[])
 Spread force on centre to other 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.
template<int N, class R, class F>
void addForces (ChargeGroup< N, R, F > const &g1, ChargeGroup< N, R, F > &g2)
 Increment forces.
template<int N, class R, class F>
void switching (ChargeGroup< N, R, F > &g1, ChargeGroup< N, R, F > &g2, double &energy, double cutoff, double switchingWidth)
void computePt (int const nAtoms, double positions[], double forces[], double &energy, double const periods[], bool const fixed[])
 Potential for Platinum.
void restrainLength (const double R1[], const double R2[], double F1[], double F2[], double &u, const double k, const double r0)
 Compute quadratic restraints between two atoms.
void lennardJones (double const distance, double &force, double &energy, double const epsilon, double const sigma)
 Lennard-Jones 12-6 between two atoms.
void lennardJones (const double R1[], const double R2[], double F1[], double F2[], double &E, double const epsilon, double const sigma)
 Lennard-Jones 12-6 between two atoms.
void lennardJonesWithCutoff (double const r1[], double const r2[], double f1[], double f2[], double &energy, double const epsilon, double const sigma)
 Lennard Jones 12-6 Potential with cutoff.
void switching (double const distance, double &force, double &energy)
 Smooth cutoff switch off.
void switching (double const r1[], double const r2[], double f1[], double f2[], double &energy)
 Smooth cutoff switch off.
double applyPeriodicity1 (double r, int const axis)
 Minimum image representation.
void applyPeriodicity1 (double r[])
 Minimum image representation.
void distance (const double x[], const double y[], double z[], double &z1, double &z2)
 Distance vector, norm and norm square.
void distance (const double x[], const double y[], double z[], double &z1)
 Distance.
void distance (const double x[], const double y[], double z[])
 Distance vector, norm.
void distance (const double x[], const double y[], double &z1)
 Distance.
void distance (const double x[], const double y[], Vector3 &z)
 Distance vector, norm and norm square.
void setPeriodicity (const double periods[])
 Set periodicity.
double unBreak1 (double const r, double const ref, int const axis)
 Undo the separation of two atoms created by the periodic boundaries.
void unBreak1 (double r[], double const ref[])
 Undo the separation of two atoms created by the periodic boundaries.
Static Protected Member Functions inherited from forcefields::PotentialBase
static void divide (double v[], double const divisor)
 Divide vector.
static double * crossProduct (const double v[], const double w[], double e[])
 Cross product.
static double dotProduct (double const v[], double const w[])
 Dot product.
static void multiply (double v[], double const factor)
 Multiply vector.
static double norm (double const v[])
 Norm of 3D vector.
static void normalise (double v[])
 Normalise 3D vector \( \frac{\mathbf v}{ |\mathbf v|} \).
static double isoscelesBase (double length, double angle)
 Calculate the base of an isosceles triangle.
static double epsilon (double const A, double const B)
 Conversion for Lennard-Jones.
static double sigma (double const A, double const B)
 Conversion for Lennard-Jones.
static double smithKongEpsilon (double sigma1, double epsilon1, double sigma2, double epsilon2)
 Smith and Kong combination rules.
static double smithKongSigma (double sigma1, double epsilon1, double sigma2, double epsilon2)
 Smith and Kong combination rules.
static double unBreak0 (double const r, double const ref, double const period)
 Undo the separation of two atoms created by the periodic boundaries.
static void unBreak0 (double r[], double const ref[], double const periods[])
 Undo the separation of two atoms created by the periodic boundaries.
Protected Attributes inherited from forcefields::PotentialBase
double cutoff_
double periods_ [3]
double switchingWidth_
Static Protected Attributes inherited from forcefields::SpceCcl
static const double roh_ = 1.0
 Distance OH.
static const double theta_ = 1.91063
 Angle HOH.
static const double rhh_ = 1.63299
 Distance HH.
static const double charge_ = 0.4238
 Charge on one hydrogen.
static const double charge2_ = 0.179606
 Square of # charge_.
static const double A_ = 27291.6
 Lennard-Jones.
static const double B_ = 27.1223
 Lennard-Jones.
static const double sigma_ = 3.16556
 Lennard-Jones. See PotentialBase::lennardJones() for definition.
static const double epsilon_ = 0.00673853
 Lennard-Jones. See PotentialBase::lennardJones() for definition.
static double const polarisationEnergy_ = 0.0541015
 Polarisation correction.
Static Protected Attributes inherited from forcefields::Ccl
static double const re_ = ::re_
 Distance OH at equilibrium.
static double const thetae_ = ::thetae_
 Distance OH at equilibrium.
static const double ONE_OVER_4_PI_EPSILON0
static const double EPSILON_PT = 0.68165797577788501
 Platinum Lennard-Jones.
static const double SIGMA_PT = 2.54
Static Private Attributes inherited from forcefields::zhu_philpott_parameters::Standard
static double const sigmaO_ = 2.86
static double const epsilonO_ = 0.0023734176137013181
static double const sigmaH_ = 2.56
static double const epsilonH_ = 0.00087578073518673099
static double const C10_O_ = 1.28
static double const C10_H_ = 1.2
static double const alpha_ = 0.8
static double const sigmaHPt_ = 2.730249677569295
static double const sigmaOPt_ = 2.7735458150747108
static double const epsilonHPt_ = 0.016217645873043762
static double const epsilonOPt_ = 0.03387330127291549

Detailed Description

template<class P = zhu_philpott_parameters::Standard>
class forcefields::ZhuPhilpott< P >

Forcefield for water and platinum interactions.

This forcefield is the A2 water-platinum potential invented by Zhuand Philpott. It includes the SPC/E+CCL potential for interaction between the molecules of water. The SPC/E is a potential for constrained water. This implementation includes restraints so it may be used without constraint (see class SpceCcl).
The potential uses Kong's rules to combine the Lennard-Jones parameters of platinum with oxygen and hydrogen. A review of combination rules including Kong's rule can be find on the web.
The system of unit used by the class is (eV, Angstrom, fs, e).

References

Interaction of water with metal surfaces, S.-B. Zhu and M.R. Philpott J. Chem. Phys. (1994) vol. 100, No 9, p. 6961.
A Molecular Dynamics Simulation of Water Droplet in Contact with a Platinum Surface, T. Kimura and S. Maruyama, University of Tokyo.
Unlike Lennard-Jones Parameters for Vapor-Liquid Equilibria, Thorsten Schnabel, Jadran Vrabec , Hans Hasse, Institut fur Technische Thermodynamik und Thermische Verfahrenstechnik, Universitat Stuttgart, D-70550 Stuttgart, Germany, http://www.itt.uni-stuttgart.de/~schnabel/CR.pdf.

Definition at line 25 of file zhu_philpott.hpp.

Constructor & Destructor Documentation

◆ ZhuPhilpott() [1/3]

template<class P>
ZhuPhilpott::ZhuPhilpott ( )

Definition at line 66 of file zhu_philpott.cpp.

67 : SpceCcl() {
68 nPlatinum_ = 0;
69 positions_ = 0;
70 forces_ = 0;
71}
std::vector< double > positions_
std::vector< double > forces_

◆ ZhuPhilpott() [2/3]

template<class P>
ZhuPhilpott::ZhuPhilpott ( double cutoff,
double switchingWidth )

Definition at line 74 of file zhu_philpott.cpp.

76 nPlatinum_ = 0;
77 positions_ = 0;
78 forces_ = 0;
79}
Forcefield for water and platinum interactions.

◆ ZhuPhilpott() [3/3]

template<class P>
ZhuPhilpott::ZhuPhilpott ( ZhuPhilpott< P > const & zhuPhilpott)

Definition at line 81 of file zhu_philpott.cpp.

81 {
83}
void operator=(ZhuPhilpott const &)

◆ ~ZhuPhilpott()

template<class P>
ZhuPhilpott::~ZhuPhilpott ( )
default

Member Function Documentation

◆ anisotropic()

template<class P>
void ZhuPhilpott::anisotropic ( const double distance[],
double force[],
double & energy,
double const epsilon,
double const sigma,
double const alpha )
private

Anisotropic interaction between water and platinum.

The isotropic iteraction between a atom Pt and an atom O or H of a molecule of water has the function form:

\[ E=4\epsilon\left[ \left(\frac{\sigma^2}{\alpha^2\rho^2+z^2}\right)^6-\left(\frac{\sigma^2}{\rho^2/\alpha^2+z^2}\right)^3 \right] \]

Parameters
[in]distanceVector distance between to atom.
[in,out]forceVector force created by the interaction between the two atoms.
[in,out]energyEnergy created by the interaction.
[in]epsilonSee equation.
[in]sigmaSee equation.
[in]alphaSee equation.

Definition at line 388 of file zhu_philpott.cpp.

390 {
391 double z2, z, a, b, A, B, dE_da, dE_db, rho, rho2, alpha2;
392 // WARNING: F1 and F2 are incremented.
393 alpha2 = alpha * alpha;
394 double f;
395 rho2 = distance[0] * distance[0] + distance[1] * distance[1];
396 rho = std::sqrt(rho2);
397 z = distance[2];
398 z2 = z * z;
399 double sigma2 = sigma * sigma;
400 a = sigma2 / (rho2 * alpha2 + z2);
401 b = sigma2 / (rho2 / alpha2 + z2);
402 double a2 = a * a, a3 = a2 * a;
403 double b2 = b * b;
404 A = a3 * a3; // a^6
405 B = b * b2; // b^3
406 energy += 4.0 * epsilon * (A - B);
407 dE_da = 24.0 * epsilon * a2 * a3; // a^5
408 dE_db = -12.0 * epsilon * b2; // b^2
409 double invSigma2 = 1.0 / sigma2;
410 f = 2.0 * (dE_da * a2 * alpha2 + dE_db * b2 / alpha2) * invSigma2;
411 force[0] += f * distance[0];
412 force[1] += f * distance[1];
413 f = 2.0 * (dE_da * a2 + dE_db * b2) * invSigma2;
414 force[2] += f * distance[2];
415}
static double sigma(double const A, double const B)
Conversion for Lennard-Jones.
void distance(const double x[], const double y[], double z[], double &z1, double &z2)
Distance vector, norm and norm square.
static double epsilon(double const A, double const B)
Conversion for Lennard-Jones.

◆ computeHH_O_()

template<class P>
void ZhuPhilpott::computeHH_O_ ( const int nWater,
const double r[],
double f[],
double & energy,
double const b[],
bool const fixed[] )

Compute water-platinum interactions, call with water's positions only.

This function is called with the coordinates of the atoms of water only. The positions of the platinum atoms must have been previously provided through function setPlatinum().

Parameters
[in]nWaterNumber of molecules of water.
[in]rPositions of atoms in water.
[out]fForces on the atoms in water.
[out]energyPotential energy.
[in]bPeriodic boundaries. Length: 3
[in]fixedTrue for fixed atoms, false otherwise. The length of arrays r and f is \( 9\times nWater \). The length of array fixed is \( 3 \times nWater \).
Note
The function does not return the forces on platinum atoms as they as assumed to be fixed.
See also
setPlatinum() and computeHH_O_Pt_().

Definition at line 161 of file zhu_philpott.cpp.

163 {
164 const double (*const rh1)[6] = reinterpret_cast<const double (*)[6]>(r);
165 const double (*const rh2)[6] = reinterpret_cast<const double (*)[6]>(&r[3]);
166 const double (*const ro)[3] =
167 reinterpret_cast<const double (*)[3]>(&r[nWater * 6]);
168 const double (*const rPt)[3] =
169 reinterpret_cast<const double (*)[3]>(positions_.data());
170
171 double (*const fh1)[6] = reinterpret_cast<double (*)[6]>(f);
172 double (*const fh2)[6] = reinterpret_cast<double (*)[6]>(&f[3]);
173 double (*const fo)[3] = reinterpret_cast<double (*)[3]>(&f[nWater * 6]);
174 double (*const fPt)[3] = reinterpret_cast<double (*)[3]>(forces_.data());
175
176 if (fixed) {
177 bool const(*const xh1)[2] = reinterpret_cast<bool const(*)[2]>(fixed);
178 bool const(*const xh2)[2] = reinterpret_cast<bool const(*)[2]>(&fixed[1]);
179 bool const(*const xo)[1] =
180 reinterpret_cast<bool const(*)[1]>(&fixed[nWater * 2]);
182 energy, b, xh1, xh2, xo, 0);
183 } else {
184 bool const(*const xh1)[2] = 0;
185 bool const(*const xh2)[2] = 0;
186 bool const(*const xo)[1] = 0;
188 energy, b, xh1, xh2, xo, 0);
189 };
190}
void computeTemplate(const int nWater, const double(*const rh1)[H3], const double(*const rh2)[H3], const double(*const ro)[O3], double(*const fh1)[H3], double(*const fh2)[H3], double(*const fo)[O3], const int nPt, const double rPt[][3], double fPt[][3], double &energy, double const b[], bool const (*const xh1)[H]=0, bool const (*const xh2)[H]=0, bool const (*const xo)[O]=0, bool const *xPt=0)

◆ computeHH_O_Pt_()

template<class P>
void ZhuPhilpott::computeHH_O_Pt_ ( const int nWater,
const int nPt,
const double r[],
double f[],
double & energy,
double const b[],
bool const fixed[] )

Compute water-platinum forcefield.

Parameters
[in]nWaterNumber of molecules of water.
[in]nPtNumber of platinum atoms.
[in]rPositions of the atoms.
[out]fForces on the atoms.
[out]energyPotential energy.
[in]bPeriodic boundaries. Length: 3
[in]fixedTrue for fixed atoms, false otherwise. The order of the atoms is all hydrogens (hydrogens belonging to the same molecule are next to each others), all oxygen, all platinum. The length of arrays r and f is \( 3\times(3 \times nWater+nPt) \). The length of array fixed is \( 3 \times nWater+nPt \). When fixed is provided the interaction between two fixed atoms may be skipped to speed up the calculation. The parameter is optional.
Warning
The conductivity is simulated by interaction a mirror images of charges. The mirror surface is set at z=0, which should correspond to the location of the highest layer of platinum atoms.

Definition at line 111 of file zhu_philpott.cpp.

114 {
115 const double (*const rh1)[6] = reinterpret_cast<const double (*)[6]>(r);
116 const double (*const rh2)[6] = reinterpret_cast<const double (*)[6]>(&r[3]);
117 const double (*const ro)[3] =
118 reinterpret_cast<const double (*)[3]>(&r[nWater * 6]);
119 const double (*const rPt)[3] =
120 reinterpret_cast<const double (*)[3]>(&r[nWater * 9]);
121
122 double (*const fh1)[6] = reinterpret_cast<double (*)[6]>(f);
123 double (*const fh2)[6] = reinterpret_cast<double (*)[6]>(&f[3]);
124 double (*const fo)[3] = reinterpret_cast<double (*)[3]>(&f[nWater * 6]);
125 double (*const fPt)[3] = reinterpret_cast<double (*)[3]>(&f[nWater * 9]);
126
127 if (fixed) {
128 bool const(*const xh1)[2] = reinterpret_cast<bool const(*)[2]>(fixed);
129 bool const(*const xh2)[2] = reinterpret_cast<bool const(*)[2]>(&fixed[1]);
130 bool const(*const xo)[1] =
131 reinterpret_cast<bool const(*)[1]>(&fixed[nWater * 2]);
132 bool const *const xPt = &fixed[nWater * 3];
134 b, xh1, xh2, xo, xPt);
135 } else {
136 bool const(*const xh1)[2] = 0;
137 bool const(*const xh2)[2] = 0;
138 bool const(*const xo)[1] = 0;
140 b, xh1, xh2, xo, 0);
141 };
142}

◆ computeTemplate() [1/2]

template<class P = zhu_philpott_parameters::Standard>
template<int H, int O, int H3, int O3>
void forcefields::ZhuPhilpott< P >::computeTemplate ( const int nWater,
const double(*) rh1[H3],
const double(*) rh2[H3],
const double(*) ro[O3],
double(*) fh1[H3],
double(*) fh2[H3],
double(*) fo[O3],
const int nPt,
const double rPt[][3],
double fPt[][3],
double & energy,
double const b[],
bool const (*) xh1[H],
bool const (*) xh2[H],
bool const (*) xo[O],
bool const xPt[] )

Definition at line 215 of file zhu_philpott.cpp.

221 {
222 for (int i = 0; i < nWater; ++i) {
223 for (int a = 0; a < 3; ++a) {
224 fh1[i][a] = 0.0;
225 fh2[i][a] = 0.0;
226 fo[i][a] = 0.0;
227 };
228 };
229 for (int i = 0; i < nPt; ++i) {
230 for (int a = 0; a < 3; ++a)
231 fPt[i][a] = 0.0;
232 };
233 energy = 0.0;
235 for (int i = nWater - 1; i >= 0; --i) {
236 double centre1[3] = {0};
238 Water w1(rh1[i], rh2[i], ro[i], centre1, fh1[i], fh2[i], fo[i]);
242 // Two next lines for interaction with platinum
244 energy); // called Vw-core in Zhu and Philpott
247 interactWithImage(w1, w1, energy); // called Vw-cond in Zhu and Philpott
250 for (int j = i - 1; j >= 0; --j) {
251 bool areFixed = false;
252 if (xh1 and xh2 and xo) {
253 areFixed = xh1[i][0] and xh2[i][0] and xo[i][0];
254 // check if all the atoms of molecule j are fixed.
255 areFixed &= xh1[j][0] and xh2[j][0] and xo[j][0];
256 };
257 // if both molecules are fixed skip force calculation
258 if (not areFixed) {
259 double centre2[3] = {0};
261 Water w2(rh1[j], rh2[j], ro[j], centre2, fh1[j], fh2[j], fo[j]);
266 // Two next lines for interaction with platinum
267 // called Vw-cond in Zhu and Philpott
268 interactWithImage(w1, w2, energy); // w1 interacts with image of w2
269 interactWithImage(w2, w1, energy); // w2 interacts with image of w1
271 };
272 };
273#ifndef NDEBUG
274 for (int a = 0; a < 3; a++) {
278 };
279#endif
280 };
282}
void calculateCentre(double const r1[], double const r2[], double rc[])
Calculate centre of two points.
void setPeriodicity(const double periods[])
Set periodicity.
void intramolecular(Water &water, double &U)
Interactions within a molecules.
Definition spce_ccl.cpp:159
void lennardJonesWithCutoff(Water &w1, Water &w2, double &U)
Interactions between two molecules.
Definition spce_ccl.cpp:86
void interactWithCorePt(Water &water, int const nPt, double const rPt[][3], double fPt[][3], double &energy)
Interaction of one molecule of water with the whole platinum.
void interactWithImage(Water &w1, Water &w2, double &U)
Interactions of a molecule with an image.
void coulombWithCutoff(Water &w1, Water &w2, double &u, double const relativePermittivity)
Coulomb interaction between two molecules within the swithcing zone.
Pointers to molecule of water.
Definition spce_ccl.hpp:78
#define DEBUG_LEVEL_RETURN(x)

◆ computeTemplate() [2/2]

template<class P = zhu_philpott_parameters::Standard>
template<int H, int O, int H3, int O3>
void forcefields::ZhuPhilpott< P >::computeTemplate ( const int nWater,
const double(*) rh1[H3],
const double(*) rh2[H3],
const double(*) ro[O3],
double(*) fh1[H3],
double(*) fh2[H3],
double(*) fo[O3],
const int nPt,
const double rPt[][3],
double fPt[][3],
double & energy,
double const b[],
bool const (*) xh1[H] = 0,
bool const (*) xh2[H] = 0,
bool const (*) xo[O] = 0,
bool const * xPt = 0 )
private

◆ coulombFull()

template<class P>
void ZhuPhilpott::coulombFull ( Water & w1,
Water & w2,
double & U,
double const relativePermittivity )
private

Coulomb interaction between two molecules with cutoff.

Coulomb interaction between two molecules of water.

Parameters
[in,out]w1, w2Water molecules.
[in,out]UAdd the potential energy to U.
[in]relativePermittivity
See also
getCutOff() and getSwitchingWidth().

Definition at line 525 of file zhu_philpott.cpp.

526 {
527 // q^2/relativePermittivity;
528 const double qq2overEr = charge2_ / relativePermittivity;
529 // Coulomb interactions between hydrogens
530 coulomb(w1.rh1_, w2.rh1_, w1.fh1_, w2.fh1_, U, qq2overEr);
531 coulomb(w1.rh1_, w2.rh2_, w1.fh1_, w2.fh2_, U, qq2overEr);
532 coulomb(w1.rh2_, w2.rh1_, w1.fh2_, w2.fh1_, U, qq2overEr);
533 coulomb(w1.rh2_, w2.rh2_, w1.fh2_, w2.fh2_, U, qq2overEr);
534 // interactions between H and O.
535 coulomb(w1.ro_, w2.rh1_, w1.fo_, w2.fh1_, U, -2.0 * qq2overEr);
536 coulomb(w1.ro_, w2.rh2_, w1.fo_, w2.fh2_, U, -2.0 * qq2overEr);
537 coulomb(w1.rh1_, w2.ro_, w1.fh1_, w2.fo_, U, -2.0 * qq2overEr);
538 coulomb(w1.rh2_, w2.ro_, w1.fh2_, w2.fo_, U, -2.0 * qq2overEr);
539 // interactions between O1, O2
540 coulomb(w1.ro_, w2.ro_, w1.fo_, w2.fo_, U, 4.0 * qq2overEr);
541}
void coulomb(const double r1[], const double r2[], double f1[], double f2[], double &u, double const qq)
Compute Coulomb interaction between two charges.
static const double charge2_
Square of # charge_.
Definition spce_ccl.hpp:157

◆ coulombWithCutoff()

template<class P>
void ZhuPhilpott::coulombWithCutoff ( Water & w1,
Water & w2,
double & U,
double const relativePermittivity )
private

Coulomb interaction between two molecules within the swithcing zone.

The precondition for using the function is that the distance between w1 and w2 defined as \( |\mathbf r_{n1}-\mathbf r_{n2}| \) verifies the equation:

\[ C_{utoff}-S_{witchingWidth} < |\mathbf r_{n1}-\mathbf r_{n2}| < C_{utoff} \]

Parameters
[in,out]w1Molecule 1.
[in,out]w2Molecule 2.
[in,out]UAdd the potential energy to U.
[in]relativePermittivityRelative permittivity.
See also
getCutOff() and getSwitchingWidth().

Definition at line 496 of file zhu_philpott.cpp.

497 {
498 double z[3], z1, z2;
499 distance(w1.rc_, w2.rc_, z, z1, z2);
500 if (z1 <= cutoff_ - switchingWidth_) {
502 } else if (z1 < cutoff_) {
503 double f1[3][3] = {{0}}, f2[3][3] = {{0}};
504 Water v1(w1, f1[0], f1[1], f1[2]);
505 Water v2(w2, f2[0], f2[1], f2[2]);
506 double energy = 0.0;
508 ChargeGroup<3> g1 = {v1.rc_, 0, f1};
509 ChargeGroup<3> g2 = {v2.rc_, 0, f2};
511 U += energy;
512 w1.addForces(v1);
513 w2.addForces(v2);
514 };
515}
void switching(ChargeGroup< N, R, F > &g1, ChargeGroup< N, R, F > &g2, double &energy, double cutoff, double switchingWidth)
void addForces(ChargeGroup< N, R, F > const &g1, ChargeGroup< N, R, F > &g2)
Increment forces.
void coulombFull(Water &w1, Water &w2, double &U, double const relativePermittivity)
Coulomb interaction between two molecules with cutoff.

◆ getName()

template<class P>
char const * ZhuPhilpott::getName ( )
static

Name of the potential.

Definition at line 209 of file zhu_philpott.cpp.

209 {
210 return "ZhuPhilpott";
211}

◆ interactionPtH()

template<class P>
void ZhuPhilpott::interactionPtH ( double const R1[],
double const R2[],
double F1[],
double F2[],
double & energy )
private

Definition at line 359 of file zhu_philpott.cpp.

360 {
361 double R12[3], F12[3] = {0}, r1, f1 = 0;
362 distance(R1, R2, R12, r1);
365 for (int j = 0; j < 3; j++) {
366 F1[j] += F12[j] + f1 * R12[j] / r1;
367 F2[j] -= F12[j] + f1 * R12[j] / r1;
368 };
369}
void anisotropic(const double distance[], double force[], double &energy, double const epsilon, double const sigma, double const alpha)
Anisotropic interaction between water and platinum.
void isotropic10(double const distance, double &force, double &energy, double const epsilon, double const sigma, double const C10)
Isotropic interaction between water and platinum.

◆ interactionPtO()

template<class P>
void ZhuPhilpott::interactionPtO ( double const R1[],
double const R2[],
double F1[],
double F2[],
double & energy )
private

Definition at line 346 of file zhu_philpott.cpp.

347 {
348 double R12[3], F12[3] = {0}, r1, f1 = 0;
349 distance(R1, R2, R12, r1);
352 for (int j = 0; j < 3; j++) {
353 F1[j] += F12[j] + f1 * R12[j] / r1;
354 F2[j] -= F12[j] + f1 * R12[j] / r1;
355 };
356}

◆ interactWithCorePt()

template<class P>
void ZhuPhilpott::interactWithCorePt ( Water & water,
int const nPt,
double const rPt[][3],
double fPt[][3],
double & energy )
private

Interaction of one molecule of water with the whole platinum.

Parameters
[in,out]waterMolecule of water. The forces are incremented.
[in]nPtNumber of Platinum atom.
[in]rPtPositions of the platinum.
[in,out]fPtForces on the platinum. The forces are incremented
[in,out]energyAdd the energy.

Definition at line 292 of file zhu_philpott.cpp.

294 {
295 for (int i = 0; i < nPt; ++i) {
296 double r[3], r1; // for distance between two atoms
297 // Pt - O
298 distance(water.ro_, rPt[i], r, r1);
299 if (r1 <= cutoff_ - switchingWidth_) {
300 interactionPtO(water.ro_, rPt[i], water.fo_, fPt[i], energy);
301 } else if (r1 < cutoff_) {
302 double en = 0;
303 double fo[3] = {0}, fPtTmp[3] = {0};
304 interactionPtO(water.ro_, rPt[i], fo, fPtTmp, en);
305 switching(water.ro_, rPt[i], fo, fPtTmp, en);
306 energy += en;
307 for (int j = 0; j < 3; j++) {
308 water.fo_[j] += fo[j];
309 fPt[i][j] += fPtTmp[j];
310 };
311 };
312 // Pt - H1
313 distance(water.rh1_, rPt[i], r, r1);
314 if (r1 <= cutoff_ - switchingWidth_) {
315 interactionPtH(water.rh1_, rPt[i], water.fh1_, fPt[i], energy);
316 } else if (r1 < cutoff_) {
317 double en = 0;
318 double fh[3] = {0}, fPtTmp[3] = {0};
319 interactionPtH(water.rh1_, rPt[i], fh, fPtTmp, en);
320 switching(water.rh1_, rPt[i], fh, fPtTmp, en);
321 energy += en;
322 for (int j = 0; j < 3; j++) {
323 water.fh1_[j] += fh[j];
324 fPt[i][j] += fPtTmp[j];
325 };
326 };
327 // Pt - H2
328 distance(water.rh2_, rPt[i], r, r1);
329 if (r1 <= cutoff_ - switchingWidth_) {
330 interactionPtH(water.rh2_, rPt[i], water.fh2_, fPt[i], energy);
331 } else if (r1 < cutoff_) {
332 double en = 0;
333 double fh[3] = {0}, fPtTmp[3] = {0};
334 interactionPtH(water.rh2_, rPt[i], fh, fPtTmp, en);
335 switching(water.rh2_, rPt[i], fh, fPtTmp, en);
336 energy += en;
337 for (int j = 0; j < 3; j++) {
338 water.fh2_[j] += fh[j];
339 fPt[i][j] += fPtTmp[j];
340 };
341 };
342 };
343}
void interactionPtH(double const R1[], double const R2[], double F1[], double F2[], double &energy)
void interactionPtO(double const R1[], double const R2[], double F1[], double F2[], double &energy)

◆ interactWithImage()

template<class P>
void ZhuPhilpott::interactWithImage ( Water & w1,
Water & w2,
double & U )
private

Interactions of a molecule with an image.

Coulomb interaction between w1 and the image of w2. Includes cutoff.

Parameters
[in,out]w1Molecule 1.
[in,out]w2Molecule 2.
[in,out]UAdd the potential energy to U.
Note
Does not include the interaction of w2 with the image of w1. For this you must explicitely call interactWithImage(w2, w1, U).

Definition at line 449 of file zhu_philpott.cpp.

449 {
450 // f is used to store the force on the atoms' images. These forces have no use
451 // and are at the end discarded. we use the same vector to store of the forces
452 // even when they are on different atoms' images.
453 double r[4][3], f[3][3] = {{0}};
454 for (int k = 0; k < 2; k++) {
455 r[0][k] = w2.rh1_[k];
456 r[1][k] = w2.rh2_[k];
457 r[2][k] = w2.ro_[k];
458 r[3][k] = w2.rc_[k];
459 };
460 // mirror about plane at z=0.
461 r[0][2] = -w2.rh1_[2];
462 r[1][2] = -w2.rh2_[2];
463 r[2][2] = -w2.ro_[2];
464 r[3][2] = -w2.rc_[2];
465 Water w2m(r[0], r[1], r[2], r[3], f[0], f[1], f[2]);
466 // -2 is given as the relative permittivity. This value is not the
467 // permittivity of the metal which is infinite in the case of a perfect metal.
468 // It is the value (1+epsilon_r)/(1-epsilon_r) which is equal to -1 for a
469 // perfect metal. This value is the 'effective' permittivity for the
470 // interaction of a charge with a mirror image.
471 coulombWithCutoff(w1, w2m, U, -2.0);
472 for (int k = 0; k < 2; k++) {
473 w2.fh1_[k] += f[0][k];
474 w2.fh2_[k] += f[1][k];
475 w2.fo_[k] += f[2][k];
476 };
477 // mirror about plane
478 w2.fh1_[2] -= f[0][2];
479 w2.fh2_[2] -= f[1][2];
480 w2.fo_[2] -= f[2][2];
481}

◆ isotropic10()

template<class P>
void ZhuPhilpott::isotropic10 ( double const distance,
double & force,
double & energy,
double const epsilon,
double const sigma,
double const C10 )
private

Isotropic interaction between water and platinum.

The isotropic iteraction between a atom Pt and an atom O or H of a molecule of water has the functional form:

\[ E=-4\epsilon\ C_{10}\left(\frac{\sigma}{r}\right)^{10} \]

Parameters
[in]distanceDistance between two atoms.
[in,out]forceForce create by the interaction between the two atoms.
[in,out]energyEnergy created by the interaction.
[in]epsilonSee equation.
[in]sigmaSee equation.
[in]C10See equation.

Definition at line 430 of file zhu_philpott.cpp.

432 {
433 double const s = sigma / distance;
434 double s10 = s * s * s * s * s;
435 s10 *= s10;
436 energy += -4.0 * epsilon * C10 * s10;
437 force -= 40.0 * epsilon * C10 * s10 / distance;
438}

◆ nPlatinum()

template<class P>
int ZhuPhilpott::nPlatinum ( ) const

Number of platinum atoms.

See also
setPlatinum().

Definition at line 194 of file zhu_philpott.cpp.

194{ return nPlatinum_; }

◆ operator=()

template<class P>
void ZhuPhilpott::operator= ( ZhuPhilpott< P > const & zhuPhilpott)

Definition at line 86 of file zhu_philpott.cpp.

86 {
88}
void setPlatinum(int nPlatinum, double const positions[])
Initialises the positions of the atoms of platinum.

◆ setPlatinum()

template<class P>
void ZhuPhilpott::setPlatinum ( int nPlatinum,
double const positions[] )

Initialises the positions of the atoms of platinum.

Use before calling computeHH_O_().

Definition at line 200 of file zhu_philpott.cpp.

200 {
201 assert(nPlatinum >= 0);
203 int const n = nPlatinum * 3;
204 positions_.assign(positions, positions + n);
205 forces_.assign(n, 0.0);
206}
int nPlatinum() const
Number of platinum atoms.

Member Data Documentation

◆ forces_

template<class P = zhu_philpott_parameters::Standard>
std::vector<double> forcefields::ZhuPhilpott< P >::forces_
private

Definition at line 70 of file zhu_philpott.hpp.

◆ nPlatinum_

template<class P = zhu_philpott_parameters::Standard>
int forcefields::ZhuPhilpott< P >::nPlatinum_ {0}
private

Definition at line 68 of file zhu_philpott.hpp.

68{0};

◆ positions_

template<class P = zhu_philpott_parameters::Standard>
std::vector<double> forcefields::ZhuPhilpott< P >::positions_
private

Definition at line 69 of file zhu_philpott.hpp.


The documentation for this class was generated from the following files: