Functions and tools commonly used by potentials. More...
#include <potential_base.hpp>
Classes | |
| struct | ChargeGroup |
| struct | Vector3 |
Public Member Functions | |
| PotentialBase () | |
| Non bond interaction cutoff. | |
| PotentialBase (double cutoff, double switchingWidth) | |
| virtual | ~PotentialBase () |
| double | getCutoff () const |
| void | setCutoff (double cutoff) |
Protected Member Functions | |
Angle | |
| 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. | |
Static Protected Member Functions | |
| 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|} \). | |
Protected Attributes | |
| double | cutoff_ |
| double | periods_ [3] |
| double | switchingWidth_ |
Coulomb | |
| static const double | ONE_OVER_4_PI_EPSILON0 |
| 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) |
| static const double | EPSILON_PT = 0.68165797577788501 |
| Platinum Lennard-Jones. | |
| static const double | SIGMA_PT = 2.54 |
| double | getSwitchingWidth () const |
| Width of the switching zone. | |
| void | setSwitchingWidth (double width) |
| static double | applyPeriodicity0 (double r, double const period) |
| Minimum image representation. | |
| static void | applyPeriodicity0 (double r[], double const periods[]) |
| Minimum image representation. | |
| void | computePt (int const nAtoms, double positions[], double forces[], double &energy, double const periods[], bool const fixed[]) |
| Potential for Platinum. | |
Bond Interactions | |
| static double | isoscelesBase (double length, double angle) |
| Calculate the base of an isosceles triangle. | |
| 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. | |
Lennard-Jones | |
| 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. | |
| 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. | |
Periodic Boundaries, Distance... | |
3-D vector. | |
| 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. | |
| 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. | |
Functions and tools commonly used by potentials.
Contains functions for quadratic retrainst, Lennard-Jones, Coulomb, to manage the periodic boundaries and interface for cutoff. The system of units used is (eV, Angstrom, fs, e). Rules to combine different Lennard-Jones parameters were taken from:
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 24 of file potential_base.hpp.
| PotentialBase::PotentialBase | ( | ) |
Non bond interaction cutoff.
When the distance between two molecules is over getCutoff(), van der Waals and Coulomb interactions between the two molecules are ignored.
Definition at line 40 of file potential_base.cpp.
| PotentialBase::PotentialBase | ( | double | cutoff, |
| double | switchingWidth ) |
Definition at line 48 of file potential_base.cpp.
|
inlinevirtual |
Definition at line 28 of file potential_base.hpp.
|
protected |
Increment forces.
Increment forces in g2 by forces in g1.
Definition at line 157 of file potential_base.hpp.
|
static |
Minimum image representation.
| [in] | r | Cyclic coordinate. |
| [in] | period | Period of the coordinates. |
Definition at line 85 of file potential_base.cpp.
|
static |
Minimum image representation.
| [in] | r | Three-dimension vector. |
| [in] | periods | Three-dimension vector containing periods along each of the axes. |
Definition at line 104 of file potential_base.cpp.
|
protected |
Minimum image representation.
| [in] | r | Cyclic coordinate. |
| [in] | axis | Either 0, 1 or 2. |
Definition at line 545 of file potential_base.cpp.
|
protected |
Minimum image representation.
| [in] | r | Three-dimension vector. |
Definition at line 534 of file potential_base.cpp.
|
protected |
Calculate centre of three points.
Definition at line 196 of file potential_base.cpp.
|
protected |
Calculate centre of two points.
Calculate the centre of r1 and r2 and store the result in rc.
Definition at line 188 of file potential_base.cpp.
|
protected |
Calculate barycentre.
The inverse of this functions the forces is spreadWeightedForce()
Definition at line 208 of file potential_base.cpp.
|
protected |
Potential for Platinum.
Simple 12-6 Lennard-Jones potential for Platinum.
Parameters from: C. Kittel, Introduction to Solid State Physics, (Wiley, New York, 1986).
| [in] | nAtoms | Number of atoms. |
| [in] | positions | Positions of atoms. |
| [out] | forces | Forces on atoms. |
| [out] | energy | Potential energy. |
| [in] | periods | Periods for periodic boundary conditions. |
| [in] | fixed | Array of boolean of length equal to nAtoms. The array shall contain true is the atom is fixed, false is movable. |
Definition at line 658 of file potential_base.cpp.
|
protected |
Compute Coulomb interaction between two charges.
\( U = \frac{q_1q_2}{|\mathbf r_1- \mathbf r_2|} \)
| [in] | r1 | Positions of atom 1. |
| [in] | r2 | Positions of atom 2. |
| [in,out] | f1 | Incremented by force on atom 1. |
| [in,out] | f2 | Incremented by force on atom 2. |
| [in,out] | energy | Incremented by energy. |
| [in] | Product of the charges. |
Definition at line 256 of file potential_base.cpp.
|
protected |
Compute Coulomb interaction between two charges.
\( U = \frac{q_1q_2}{|\mathbf r_1- \mathbf r_2|} \)
| [in] | distance | between two charges |
| [out] | force | Force Resulting from the coulom interaction. |
| [out] | energy | Potential energy. |
| [in] | Product of the charges. |
Definition at line 275 of file potential_base.cpp.
|
protected |
Coulomb interaction with single charge based cutoff.
\( U = \frac{q_1q_2}{|\mathbf r_1- \mathbf r_2|} \)
| [in] | r1 | Positions of atom 1. |
| [in] | r2 | Positions of atom 2. |
| [in,out] | f1 | Incremented by force on atom 1. |
| [in,out] | f2 | Incremented by force on atom 2. |
| [in,out] | energy | Incremented by energy. |
| [in] | Product of the charges. |
Definition at line 229 of file potential_base.cpp.
|
protected |
|
protected |
Distance vector, norm.
Definition at line 581 of file potential_base.cpp.
|
protected |
Distance.
| [in] | x, y | Two three dimension vector. |
| [out] | z[] | |
| [out] | z1 | \(| \mathbf x -\mathbf y | \) with pbc applied. |
Definition at line 572 of file potential_base.cpp.
|
protected |
Distance vector, norm and norm square.
| [in] | x, y | Two three dimension vector. |
| [out] | z | \( \mathbf x -\mathbf y \) with pbc applied. |
| [out] | z1 | \( |\mathbf z | \) |
| [out] | z2 | \( |\mathbf z |^2 \) |
Definition at line 555 of file potential_base.cpp.
|
protected |
Distance vector, norm and norm square.
| [in] | x, y | Two three dimension vector. |
| [out] | z | Return x-y, |x-y| and |x-y|^2. |
Definition at line 595 of file potential_base.cpp.
|
staticprotected |
Conversion for Lennard-Jones.
The Lennard-Jones is sometimes expressed as:
\[ \frac{A}{r^{12}}-\frac{B}{r^6} \]
whereas the functions lennardJones() use the expression:
\[ 4\epsilon\left[\left(\frac{\sigma}{r}\right)^{12}-\left(\frac{\sigma}{r}\right)^6\right] \]
The function calculates the parameter epsilon.
Definition at line 333 of file potential_base.cpp.
| double PotentialBase::getCutoff | ( | ) | const |
Definition at line 60 of file potential_base.cpp.
| double PotentialBase::getSwitchingWidth | ( | ) | const |
Width of the switching zone.
In the switching zone the potential is replaced by \( V=U\times S(x) \) where U is the real potential V the switching potential and S the switching function. Variable x=0 at the beginning of the switching zone and x=1 at the end the function S is \( S=2x^3-3x^2+1 \) which has the following properties: S(0)=1, S(1)=0, S'(0)=0 and S'(1)=0. The switching when the distance between the two molecules is getCutoff()-getSwitchingWidth() and ends when the distance is getCutoff();
Definition at line 74 of file potential_base.cpp.
|
staticprotected |
Calculate the base of an isosceles triangle.
An isosceles triangle is a triangle with two sides of equal length. If you know the length of the two equal sides and the angle between the two, the function can calculate the length of the third side.
| [in] | length | Length of the two equal sides of the triangle. |
| [in] | angle | Angle between the two equal side in radiant. |
Definition at line 116 of file potential_base.cpp.
|
protected |
Lennard-Jones 12-6 between two atoms.
| [in] | R1, R2 | Positions of atom 1 and 2. |
| [in,out] | F1, F2 | Force on atom 1 and 2. |
| [in,out] | E | Energy. |
| [in] | epsilon, sigma | Parameters of the Lennard-Jones potential. |
Definition at line 363 of file potential_base.cpp.
|
protected |
Lennard-Jones 12-6 between two atoms.
Return the energy and scalar force resulting from a Lennard-Jones potential. \( E=4*\epsilon*(x^{12}-x^6) \) with \( x=\frac{\sigma}{r} \) and \(F=-\frac{dE}{dr} \) .
| [in] | distance | Distance between two atoms. |
| [out] | force | Force. |
| [out] | energy | Potential energy. |
| [in] | epsilon, sigma | Lennard-Jones parameters. |
Definition at line 347 of file potential_base.cpp.
|
protected |
Lennard Jones 12-6 Potential with cutoff.
Interaction between two atoms. Cutoff and switching width should be set with setCutoff() and setSwitchingWidth().
| [in] | r1, r2 | Positions of the two atoms. |
| [in,out] | f1, f2 | Forces on the two atoms. |
| [in,out] | energy | Potential energy. |
| [in] | epsilon, sigma | See lennardJones() for definition of sigma and esplion. |
Definition at line 397 of file potential_base.cpp.
|
protected |
Angular quadratic restraints.
\( U=k(a-a_0)^2 \)
| [in] | r1[], r2[], r3[] | Positions of atoms. |
| [in,out] | f1[], f2[], f3[] | Force on atoms. The forces are incremeneted by the function. |
| [in,out] | u | Incremented by energy. |
| [in] | k | Potential curvature |
| [in] | aeq | Angle made by the three atoms 1,2,3 at equilibrium. |
Definition at line 160 of file potential_base.cpp.
|
protected |
Compute quadratic restraints between two atoms.
\( U=k(r-r_0)^2 \)
| [in] | R1[] | Positions of atom 1. |
| [in] | R2[] | Positions of atom 2. |
| [in,out] | F1[] | Incremented by force on atom 1. |
| [in,out] | F2[] | Incremented by force on atom 2. |
| [in,out] | u | Incremented by energy. |
| [in] | k | Potential curvature |
| [in] | req | Distance of the two atoms at equilibrium. |
Definition at line 130 of file potential_base.cpp.
| void PotentialBase::setCutoff | ( | double | cutoff | ) |
Definition at line 62 of file potential_base.cpp.
|
protected |
Set periodicity.
Must be used before calling certain functions: distance(), applyPeriodicity(), etc...
Definition at line 603 of file potential_base.cpp.
| void PotentialBase::setSwitchingWidth | ( | double | width | ) |
Definition at line 76 of file potential_base.cpp.
|
staticprotected |
Conversion for Lennard-Jones.
The Lennard-Jones is sometimes expressed as:
\[ \frac{A}{r^{12}}-\frac{B}{r^6} \]
whereas the functions lennardJones() use the expression:
\[ 4\epsilon\left[\left(\frac{\sigma}{r}\right)^{12}-\left(\frac{\sigma}{r}\right)^6\right] \]
The function calculates the parameter sigma.
Definition at line 423 of file potential_base.cpp.
|
staticprotected |
Smith and Kong combination rules.
\[ \epsilon^{SK}_{12}= \frac{2^{13}\epsilon_1\sigma_1^6\epsilon_2\sigma_2^6}{\left[(\epsilon_1\sigma_1^{12})^\frac{1}{13}+(\epsilon_1\sigma_1^{12})^\frac{1}{13}\right]^{13}} \]
Definition at line 433 of file potential_base.cpp.
|
staticprotected |
Smith and Kong combination rules.
Combination of unlike Lennard-Jones parameters
\[ \sigma^{SK}= \left[ \frac{(\epsilon_1\sigma_1^{12})^{\frac{1}{13}}+(\epsilon_2\sigma_2^{12})^{\frac{1}{13}}} {2^{13}\sqrt{\epsilon_1\sigma_1^6\epsilon_2\sigma_2^6}} \right]^\frac{1}{6} \]
Definition at line 455 of file potential_base.cpp.
|
protected |
Spread force on centre to other points.
Spread force fc to f1, f2. Each receives a half of the force.
Definition at line 284 of file potential_base.cpp.
|
protected |
Spread force on centre to other points.
Spread force fc to f1, f2, f3. Each receives 1/3 of the force.
Definition at line 295 of file potential_base.cpp.
|
protected |
Spread force on barycentre to atoms.
This is the inverse functions calculateWeightedCentre()
| [in] | w1, w2, w3 | weights. |
| [in,out] | f1, f2, f3 | vector to spread fc to. |
| [in,out] | fc | force to spread. |
Definition at line 312 of file potential_base.cpp.
|
protected |
Definition at line 163 of file potential_base.hpp.
|
protected |
Smooth cutoff switch off.
Should be called when the distance between the two atoms is in the switching zone (see getSwitchinWidth() for more explanation).
| [in] | distance | Distance between two atoms. |
| [in,out] | force | On atoms. The input values should be the full force for the interaction between the two atoms. The function returns the corrected force. |
| [in,out] | energy | Potential energy. The input should be the full energy for the interaction between the two atoms. The functions returns the corrected energy. |
Definition at line 481 of file potential_base.cpp.
|
protected |
Smooth cutoff switch off.
Should be called when the distance between the two atoms is in the switching zone (see getSwitchinWidth() for more explanation).
| [in] | r1, r2 | Positions of atoms. |
| [in,out] | f1, f2 | Forces on atoms. The input values should be the full forces for the interaction between the two atoms. The function returns the corrected forces. |
| [in,out] | energy | Potential energy. The input should be the full energy for the interaction between the two atoms. The functions returns the corrected energy. |
Definition at line 511 of file potential_base.cpp.
|
staticprotected |
Undo the separation of two atoms created by the periodic boundaries.
Example: two atoms H and O are at respectively x = -9.5 and x = 9.5 and the period along x is 20. The real distance between the two atoms is 1. We use unBreak() on the coordinates of these two atoms:
The coordinates rh of H is now 10.5 thus making O and H appears at a distance of 1 of each other.
Apply periodic boundaries condition to vector \(r - r_{ef} \).
| [in] | r | Returns \( \textrm{applyPeriodicity}(r - r_{ef}) +r_{ef} \) |
| [in] | ref | |
| [in] | period |
Definition at line 623 of file potential_base.cpp.
|
staticprotected |
Undo the separation of two atoms created by the periodic boundaries.
Definition at line 629 of file potential_base.cpp.
|
protected |
Undo the separation of two atoms created by the periodic boundaries.
Definition at line 641 of file potential_base.cpp.
|
protected |
Undo the separation of two atoms created by the periodic boundaries.
Definition at line 636 of file potential_base.cpp.
|
protected |
Definition at line 147 of file potential_base.hpp.
|
staticprotected |
Platinum Lennard-Jones.
Lennard-Jones parameters for platinum.
Definition at line 132 of file potential_base.hpp.
|
staticprotected |
Definition at line 54 of file potential_base.hpp.
|
protected |
Definition at line 148 of file potential_base.hpp.
|
staticprotected |
Definition at line 133 of file potential_base.hpp.
|
protected |
Definition at line 149 of file potential_base.hpp.