Template Class PMEInstance¶
Defined in File helpme.h
Class Documentation¶
-
template<typename Real, typename std::enable_if<std::is_floating_point<Real>::value, int>::type = 0>
class PMEInstance¶ A class to encapsulate information related to a particle mesh Ewald calculation.
By storing information related to a single PME calculation in this way, we allow multiple instances to be created in calculations requiring multiple PMEs, e.g. for computing both electrostatic and attractive dispersion terms using PME to handle long-range interactions.
- Template Parameters:
Real – the floating point type to use for arithmetic.
Public Functions
-
inline Real *spreadParameters(int parameterAngMom, const RealMat ¶meters)¶
Spread the parameters onto the charge grid. Generally this shouldn’t be called; use the various computeE() methods instead. This the more efficient version that filters the atom list and uses pre-computed splines. Therefore, the splineCache_ member must have been updated via a call to filterAtomsAndBuildSplineCache() first.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
- Returns:
realGrid the array of discretized parameters (stored in CBA order).
-
inline void filterAtomsAndBuildSplineCache(int splineDerivativeLevel, const RealMat &coords)¶
filterAtomsAndBuildSplineCache builds a list of BSplines for only the atoms to be handled by this node.
- Parameters:
splineDerivativeLevel – the derivative level (parameter angular momentum + energy derivative level) of the BSplines.
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
-
inline Real cellVolume()¶
cellVolume Compute the volume of the unit cell.
- Returns:
volume in units consistent with those used to define the lattice vectors.
-
inline helpme::Matrix<Real> minimumImageDeltaR(const typename helpme::Matrix<Real>::sliceIterator &positionI, const typename helpme::Matrix<Real>::sliceIterator &positionJ)¶
minimumImageDeltaR Computes deltaR = positionJ - positionI, applying the minimum image convention to the result
param positionJ
- Parameters:
positionI –
- Returns:
minimum image deltaR
-
inline void setLatticeVectors(Real A, Real B, Real C, Real alpha, Real beta, Real gamma, LatticeType latticeType)¶
Sets the unit cell lattice vectors, with units consistent with those used to specify coordinates.
- Parameters:
A – the A lattice parameter in units consistent with the coordinates.
B – the B lattice parameter in units consistent with the coordinates.
C – the C lattice parameter in units consistent with the coordinates.
alpha – the alpha lattice parameter in degrees.
beta – the beta lattice parameter in degrees.
gamma – the gamma lattice parameter in degrees.
latticeType – how to arrange the lattice vectors. Options are ShapeMatrix: enforce a symmetric representation of the lattice vectors [c.f. S. Nos${‘e}$ and M. L. Klein, Mol. Phys. 50 1055 (1983)] particularly appendix C. XAligned: make the A vector coincide with the X axis, the B vector fall in the XY plane, and the C vector take the appropriate alignment to completely define the system.
-
inline Real *compressedForwardTransform(Real *realGrid)¶
Performs the forward 3D FFT of the discretized parameter grid using the compressed PME algorithm.
- Parameters:
realGrid – the array of discretized parameters (stored in CBA order, with A being the fast running index) to be transformed.
- Returns:
Pointer to the transformed grid, which is stored in one of the buffers in BAC order.
-
inline Complex *forwardTransform(Real *realGrid)¶
Performs the forward 3D FFT of the discretized parameter grid.
- Parameters:
realGrid – the array of discretized parameters (stored in CBA order, with A being the fast running index) to be transformed.
- Returns:
Pointer to the transformed grid, which is stored in one of the buffers in BAC order.
-
inline Real *inverseTransform(Complex *convolvedGrid)¶
Performs the inverse 3D FFT.
- Parameters:
convolvedGrid – the complex array of discretized parameters convolved with the influence function (stored in BAC order, with C being the fast running index) to be transformed.
- Returns:
Pointer to the potential grid, which is stored in one of the buffers in CBA order.
-
inline Real *compressedInverseTransform(Real *reciprocalGrid)¶
Performs the backward 3D FFT of the discretized parameter grid using the compressed PME algorithm.
- Parameters:
reciprocalGrid – the reciprocal space potential grid (stored in BAC order, with C being the fast running index) to be transformed.
- Returns:
Pointer to the transformed grid, which is stored in one of the buffers in CBA order.
-
inline Real convolveE(Real *transformedGrid)¶
convolveE performs the convolution on a compressed PME transformed Grid
- Parameters:
transformedGrid – the pointer to the complex array holding the transformed grid in YXZ ordering.
- Returns:
the reciprocal space energy.
-
inline Real convolveE(Complex *transformedGrid)¶
convolveE performs the convolution of a standard PME transformed grid
- Parameters:
transformedGrid – the pointer to the complex array holding the transformed grid in YXZ ordering.
- Returns:
the reciprocal space energy.
-
inline Real convolveEV(const Real *transformedGrid, Real *&convolvedGrid, RealMat &virial)¶
convolveEV A wrapper to determine the correct convolution function to call, including virial, for the compressed PME algorithm.
- Parameters:
transformedGrid – the pointer to the Fourier space array holding the transformed grid in YXZ ordering.
convolvedGrid – the (output) pointer to the Fourier space array holding the convolved grid in YXZ ordering.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the reciprocal space energy.
-
inline Real convolveEV(Complex *transformedGrid, RealMat &virial)¶
convolveEV A wrapper to determine the correct convolution function to call, including virial, for the conventional PME algorithm.
- Parameters:
transformedGrid – the pointer to the complex array holding the transformed grid in YXZ ordering.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the reciprocal space energy.
-
inline void probeGrid(const Real *potentialGrid, int parameterAngMom, const RealMat ¶meters, RealMat &forces, Real *virial = nullptr)¶
Probes the potential grid to get the forces. Generally this shouldn’t be called; use the various computeE() methods instead. This is the faster version that uses the filtered atom list and uses pre-computed splines. Therefore, the splineCache_ member must have been updated via a call to filterAtomsAndBuildSplineCache() first.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
potentialGrid – pointer to the array containing the potential, in ZYX order.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}.
virial – pointer to the virial vector if needed
-
inline Real computeESlf(int parameterAngMom, const RealMat ¶meters)¶
computeESlf computes the Ewald self interaction energy.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
- Returns:
the self energy.
-
inline Real computeEDir(const PairList &pairList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates)¶
computeEDir computes the direct space energy. This is provided mostly for debugging and testing purposes; generally the host program should provide the pairwise interactions.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
pairList – dense list of atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
- Returns:
the direct space energy.
-
inline Real computeEFDir(const PairList &pairList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces)¶
computeEFDir computes the direct space energy and force. This is provided mostly for debugging and testing purposes; generally the host program should provide the pairwise interactions.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
pairList – dense list of atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
- Returns:
the direct space energy.
-
inline Real computeEFVDir(const PairList &pairList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces, RealMat &virial)¶
computeEFVDir computes the direct space energy, force and virial. This is provided mostly for debugging and testing purposes; generally the host program should provide the pairwise interactions.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
pairList – dense list of atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the direct space energy.
-
inline Real computeEAdj(const PairList &pairList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates)¶
computeEAdj computes the adjusted real space energy which extracts the energy for excluded pairs that is present in reciprocal space. This is provided mostly for debugging and testing purposes; generally the host program should provide the pairwise interactions.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
pairList – dense list of atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
- Returns:
the adjusted energy.
-
inline Real computeEFAdj(const PairList &pairList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces)¶
computeEFAdj computes the adjusted energy and force. This is provided mostly for debugging and testing purposes; generally the host program should provide the pairwise interactions.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
pairList – dense list of atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
- Returns:
the adjusted energy.
-
inline Real computeEFVAdj(const PairList &pairList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces, RealMat &virial)¶
computeEFVAdj computes the adjusted energy, forces and virial. This is provided mostly for debugging and testing purposes; generally the host program should provide the pairwise interactions.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
pairList – dense list of atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the adjusted energy.
-
inline void computePAtAtomicSites(const RealMat &charges, const RealMat &coordinates, RealMat &potential, Real sphericalCutoff)¶
Computes the full electrostatic potential at atomic sites due to point charges located at those same sites. The site located at each probe location is neglected, to avoid the resulting singularity.
- Parameters:
charges – * the list of point charges (in e) associated with each particle.
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
potential – the array holding the potential. This is * a matrix of dimensions nAtoms x 1.
sphericalCutoff – the cutoff (in A) applied to the real space summations, which must be no more than half of the box dimensions.
-
inline void computePAdj(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, const RealMat &gridPoints, RealMat &potential, bool &minimumImage)¶
Computes the adjusted real space potential from the atoms at the grid points provided.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.). A negative value indicates that only the shell with |parameterAngMom| is to be considered, e.g. a value of -2 specifies that only quadrupoles (and not dipoles or charges) will be provided; the input matrix should have dimensions corresponding only to the number of terms in this shell.
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
gridPoints – the list of grid points at which the potential is needed; can be the same as the coordinates.
potential – the array holding the potential. This is a matrix of dimensions nAtoms x 1. N.B. this array is incremented with the potential, not assigned, so take care to zero it first if only the current results are desired.
minimumImage – whether or not to use the minimum image convection when calculated the potential.
-
inline void computePDPAdj(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, const RealMat &gridPoints, RealMat &potential, bool &minimumImage)¶
Computes the adjusted real space potential and its first derivative from the atoms at the grid points provided.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.). A negative value indicates that only the shell with |parameterAngMom| is to be considered, e.g. a value of -2 specifies that only quadrupoles (and not dipoles or charges) will be provided; the input matrix should have dimensions corresponding only to the number of terms in this shell.
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
gridPoints – the list of grid points at which the potential is needed; can be the same as the coordinates.
potential – the array holding the potential. This is a matrix of dimensions nAtoms x nD, where nD is the derivative level requested. See the details for the parameters argument for information about ordering of derivative components. N.B. this array is incremented with the potential, not assigned, so take care to zero it first if only the current results are desired.
minimumImage – whether or not to use the minimum image convection when calculated the potential.
-
inline void computePVRec(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, const RealMat &gridPoints, int derivativeLevel, RealMat &potential, RealMat &virial)¶
-
inline void computePRec(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, const RealMat &gridPoints, int derivativeLevel, RealMat &potential)¶
Runs a PME reciprocal space calculation, computing the potential and, optionally, its derivatives.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.). A negative value indicates that only the shell with |parameterAngMom| is to be considered, e.g. a value of -2 specifies that only quadrupoles (and not dipoles or charges) will be provided; the input matrix should have dimensions corresponding only to the number of terms in this shell.
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
gridPoints – the list of grid points at which the potential is needed; can be the same as the coordinates.
derivativeLevel – the order of the potential derivatives required; 0 is the potential, 1 is (minus) the field, etc. A negative value indicates that only the derivative with order |derivativeLevel| is to be generated, e.g. -2 specifies that only the second derivative (not the potential or its gradient) will be returned as output. The output matrix should have space for only these terms, accordingly.
potential – the array holding the potential. This is a matrix of dimensions nAtoms x nD, where nD is the derivative level requested. See the details for the parameters argument for information about ordering of derivative components. N.B. this array is incremented with the potential, not assigned, so take care to zero it first if only the current results are desired.
-
inline Real computeERec(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates)¶
Runs a PME reciprocal space calculation, computing energies.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
- Returns:
the reciprocal space energy.
-
inline Real computeEFRec(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces)¶
Runs a PME reciprocal space calculation, computing energies and forces.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
- Returns:
the reciprocal space energy.
-
inline Real computeEFVRec(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces, RealMat &virial)¶
Runs a PME reciprocal space calculation, computing energies, forces and the virial.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the reciprocal space energy.
-
inline Real computeEFVRecIsotropicInducedDipoles(int parameterAngMom, const RealMat ¶meters, const RealMat &inducedDipoles, PolarizationType polarizationType, const RealMat &coordinates, RealMat &forces, RealMat &virial)¶
Runs a PME reciprocal space calculation, computing energies, forces and the virial.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
inducedDipoles – the induced dipoles in the order {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
polarizationType – the method used to converged the induced dipoles.
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the reciprocal space energy.
-
inline Real computeEAll(const PairList &includedList, const PairList &excludedList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates)¶
Runs a full (direct and reciprocal space) PME calculation, computing the energy. The direct space implementation here is not totally optimal, so this routine should primarily be used for testing and debugging.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
includedList – dense list of included atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN,jN.
excludedList – dense list of excluded atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
- Returns:
the full PME energy.
-
inline Real computeEFAll(const PairList &includedList, const PairList &excludedList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces)¶
Runs a full (direct and reciprocal space) PME calculation, computing energies and forces. The direct space implementation here is not totally optimal, so this routine should primarily be used for testing and debugging.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
includedList – dense list of included atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
excludedList – dense list of excluded atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
- Returns:
the full PME energy.
-
inline Real computeEFVAll(const PairList &includedList, const PairList &excludedList, int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, RealMat &forces, RealMat &virial)¶
Runs a full (direct and reciprocal space) PME calculation, computing energies, forces and virials. The direct space implementation here is not totally optimal, so this routine should primarily be used for testing and debugging.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
includedList – dense list of included atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
excludedList – dense list of excluded atom pairs, ordered like i1, j1, i2, j2, i3, j3, … iN, jN.
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}. This matrix is incremented, not assigned.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
- Returns:
the full PME energy.
-
inline void setup(int rPower, Real kappa, int splineOrder, int dimA, int dimB, int dimC, Real scaleFactor, int nThreads)¶
setup initializes this object for a PME calculation using only threading. This may be called repeatedly without compromising performance.
- Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
splineOrder – the order of B-spline; must be at least (2 + max. multipole order + deriv. level needed).
dimA – the dimension of the FFT grid along the A axis.
dimB – the dimension of the FFT grid along the B axis.
dimC – the dimension of the FFT grid along the C axis.
scaleFactor – a scale factor to be applied to all computed energies and derivatives thereof (e.g. the 1 / [4 pi epslion0] for Coulomb calculations).
nThreads – the maximum number of threads to use for each MPI instance; if set to 0 all available threads are used.
-
inline void setupCompressed(int rPower, Real kappa, int splineOrder, int dimA, int dimB, int dimC, int maxKA, int maxKB, int maxKC, Real scaleFactor, int nThreads)¶
setupCompressed initializes this object for a compressed PME calculation using only threading. This may be called repeatedly without compromising performance.
- Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
splineOrder – the order of B-spline; must be at least (2 + max. multipole order + deriv. level needed).
dimA – the dimension of the FFT grid along the A axis.
dimB – the dimension of the FFT grid along the B axis.
dimC – the dimension of the FFT grid along the C axis.
maxKA – the maximum K value in the reciprocal sum along the A axis.
maxKB – the maximum K value in the reciprocal sum along the B axis.
maxKC – the maximum K value in the reciprocal sum along the C axis.
scaleFactor – a scale factor to be applied to all computed energies and derivatives thereof (e.g. the 1 / [4 pi epslion0] for Coulomb calculations).
nThreads – the maximum number of threads to use for each MPI instance; if set to 0 all available threads are used.
Protected Functions
-
inline GridIterator makeGridIterator(int dimension, int first, int last, int paddingSize) const¶
makeGridIterator makes an iterator over the spline values that contribute to this node’s grid in a given Cartesian dimension. The iterator is of the form (grid point, spline index) and is sorted by increasing grid point, for cache efficiency.
- Parameters:
dimension – the dimension of the grid in the Cartesian dimension of interest.
first – the first grid point in the Cartesian dimension to be handled by this node.
last – the element past the last grid point in the Cartesian dimension to be handled by this node.
paddingSize – the size of the “halo” region around this grid onto which the charge can be spread that really belongs to neighboring nodes. For compressed PME we assume that each node handles only its own atoms and spreads onto an expanded grid to account for this. In regular PME there is no padding because we assume that all halo atoms are present on this node before spreading.
- Returns:
the vector of spline iterators for each starting grid point.
-
inline void updateAngMomIterator(int parameterAngMom)¶
Make sure that the iterator over AM components is up to date.
- Parameters:
angMom – the angular momentum required for the iterator over multipole components.
-
inline void updateInfluenceFunction()¶
updateInfluenceFunction builds the gF array cache, if the lattice vector has changed since the last build of it. If the cell is unchanged, this does nothing. This is handled separately from other initializations because we may skip the cacheing of the influence function when the virial is requested; we assume it’s an NPT calculation in this case and therefore the influence function changes every time.
-
inline void computePRecHelper(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, const RealMat &gridPoints, int derivativeLevel, RealMat &potential, RealMat &virial)¶
Runs a PME reciprocal space calculation, computing the potential and, optionally, its derivatives as well as the volume dependent part of the virial that comes from the structure factor.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.). A negative value indicates that only the shell with |parameterAngMom| is to be considered, e.g. a value of -2 specifies that only quadrupoles (and not dipoles or charges) will be provided; the input matrix should have dimensions corresponding only to the number of terms in this shell.
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
coordinates – the cartesian coordinates, ordered in memory as {x1,y1,z1,x2,y2,z2,….xN,yN,zN}.
gridPoints – the list of grid points at which the potential is needed; can be the same as the coordinates.
derivativeLevel – the order of the potential derivatives required; 0 is the potential, 1 is (minus) the field, etc. A negative value indicates that only the derivative with order |derivativeLevel| is to be generated, e.g. -2 specifies that only the second derivative (not the potential or its gradient) will be returned as output. The output matrix should have space for only these terms, accordingly.
potential – the array holding the potential. This is a matrix of dimensions nAtoms x nD, where nD is the derivative level requested. See the details for the parameters argument for information about ordering of derivative components. N.B. this array is incremented with the potential, not assigned, so take care to zero it first if only the current results are desired.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
-
inline void spreadParametersImpl(const int &atom, Real *realGrid, const int &nComponents, const Spline &splineA, const Spline &splineB, const Spline &splineC, const RealMat ¶meters, int thread)¶
Spreads parameters onto the grid for a single atom.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
atom – the absolute atom number.
realGrid – pointer to the array containing the grid in CBA order
nComponents – the number of angular momentum components in the parameters.
nForceComponents – the number of angular momentum components in the parameters with one extra level of angular momentum to permit evaluation of forces.
splineA – the BSpline object for the A direction.
splineB – the BSpline object for the B direction.
splineC – the BSpline object for the C direction.
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
thread – the ID of the thread handling this term.
-
inline void probeGridImpl(const Real *potentialGrid, const Spline &splineA, const Spline &splineB, const Spline &splineC, const Real ¶meter, Real *forces) const¶
Probes the grid and computes the force for a single atom, specialized for zero parameter angular momentum.
- Parameters:
potentialGrid – pointer to the array containing the potential, in ZYX order.
splineA – the BSpline object for the A direction.
splineB – the BSpline object for the B direction.
splineC – the BSpline object for the C direction.
parameter – the list of parameter associated with the given atom.
forces – a 3 vector of the forces for this atom, ordered in memory as {Fx, Fy, Fz}.
-
inline void probeGridImpl(const Real *potentialGrid, const int &nPotentialComponents, const Spline &splineA, const Spline &splineB, const Spline &splineC, Real *phiPtr)¶
Probes the grid and computes the force for a single atom, for arbitrary parameter angular momentum.
- Parameters:
potentialGrid – pointer to the array containing the potential, in ZYX order.
nPotentialComponents – the number of components in the potential and its derivatives with one extra level of angular momentum to permit evaluation of forces.
splineA – the BSpline object for the A direction.
splineB – the BSpline object for the B direction.
splineC – the BSpline object for the C direction.
phiPtr – a scratch array of length nPotentialComponents, to store the fractional potential. N.B. Make sure that updateAngMomIterator() has been called first with the appropriate derivative level for the requested potential derivatives.
-
inline void probeGridImpl(const int &atom, const Real *potentialGrid, const int &nComponents, const int &nForceComponents, const Spline &splineA, const Spline &splineB, const Spline &splineC, Real *phiPtr, const Real *fracParameters, Real *forces)¶
Probes the grid and computes the force for a single atom, for arbitrary parameter angular momentum.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Parameters:
atom – the absolute atom number.
potentialGrid – pointer to the array containing the potential, in ZYX order.
nComponents – the number of angular momentum components in the parameters.
nForceComponents – the number of angular momentum components in the parameters with one extra level of angular momentum to permit evaluation of forces.
splineA – the BSpline object for the A direction.
splineB – the BSpline object for the B direction.
splineC – the BSpline object for the C direction.
phiPtr – a scratch array of length nForceComponents, to store the fractional potential.
fracParameters – the list of parameters associated with the current atom, in the scaled fraction coordinate basis (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
forces – a Nx3 matrix of the forces, ordered in memory as {Fx1,Fy1,Fz1,Fx2,Fy2,Fz2,….FxN,FyN,FzN}.
-
inline void assertInitialized() const¶
assertInitialized makes sure that setup() has been called before running any calculations.
-
inline std::tuple<Spline, Spline, Spline> makeBSplines(const Real *atomCoords, short derivativeLevel) const¶
makeBSplines construct the {x,y,z} B-Splines.
- Parameters:
atomCoords – a 3-vector containing the atom’s coordinates.
derivativeLevel – level of derivative needed for the splines.
- Returns:
a 3-tuple containing the {x,y,z} B-splines.
-
inline void checkMinimumImageCutoff(int sphericalCutoff)¶
checkMinimumImageCutoff ensure that the box dimensions satisfy the condition sphericalCutoff < MIN(W_A, W_B, W_C)/2
where
W_A = |A.(B x C)| / |B x C| W_B = |B.(C x A)| / |C x A| W_C = |C.(A x B)| / |A x B|
- Parameters:
sphericalCutoff – the spherical nonbonded cutoff in Angstrom
-
inline void sanityChecks(int parameterAngMom, const RealMat ¶meters, const RealMat &coordinates, int cartesianOffset = 0)¶
sanityChecks just makes sure that inputs have consistent dimensions, and that prerequisites are initialized.
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the input parameters.
coordinates – the input coordinates.
cartesianOffset – an offset to the start of the angular momentum shell for the parameters, in cases where only a single angular momentum shell is to be processed (rather than all shells up to a given angular momentum).
-
inline void setupCalculationMetadata(int rPower, Real kappa, int splineOrder, int dimA, int dimB, int dimC, int maxKA, int maxKB, int maxKC, Real scaleFactor, int nThreads, void *commPtrIn, NodeOrder nodeOrder, int numNodesA, int numNodesB, int numNodesC)¶
common_init sets up information that is common to serial and parallel runs.
Protected Attributes
-
int gridDimensionA_ = 0¶
The FFT grid dimensions in the {A,B,C} grid dimensions.
-
int gridDimensionB_ = 0¶
-
int gridDimensionC_ = 0¶
-
int numKSumTermsA_ = 0¶
The number of K vectors in the {A,B,C} dimensions. Equal to dim{A,B,C} for PME, lower for cPME.
-
int numKSumTermsB_ = 0¶
-
int numKSumTermsC_ = 0¶
-
int myNumKSumTermsA_ = 0¶
The number of K vectors in the {A,B,C} dimensions to be handled by this node in a parallel setup.
-
int myNumKSumTermsB_ = 0¶
-
int myNumKSumTermsC_ = 0¶
-
int complexGridDimensionA_ = 0¶
The full A dimension after real->complex transformation.
-
int myComplexGridDimensionA_ = 0¶
The locally owned A dimension after real->complex transformation.
-
int splineOrder_ = 0¶
The order of the cardinal B-Spline used for interpolation.
-
int nThreads_ = -1¶
The actual number of threads per MPI instance, and the number requested previously.
-
int requestedNumberOfThreads_ = -1¶
-
int rPower_ = 0¶
The exponent of the (inverse) interatomic distance used in this kernel.
-
Real kappa_ = 0¶
The attenuation parameter, whose units should be the inverse of those used to specify coordinates.
-
RealMat boxVecs_ = RealMat(3, 3)¶
The lattice vectors.
-
RealMat recVecs_ = RealMat(3, 3)¶
The reciprocal lattice vectors.
-
RealMat scaledRecVecs_ = RealMat(3, 3)¶
The scaled reciprocal lattice vectors, for transforming forces from scaled fractional coordinates.
-
std::vector<size_t> numAtomsPerThread_¶
A list of the number of splines handle by each thread on this node.
-
std::vector<std::array<short, 3>> angMomIterator_¶
An iterator over angular momentum components.
-
GridIterator gridIteratorA_¶
From a given starting point on the {A,B,C} edge of the grid, lists all points to be handled, correctly wrapping around the end.
-
GridIterator gridIteratorB_¶
-
GridIterator gridIteratorC_¶
-
std::vector<GridIterator> threadedGridIteratorC_¶
The grid iterator for the C dimension, divided up by threads to avoid race conditions in parameter spreading.
-
RealVec splineModA_¶
The (inverse) bspline moduli to normalize the spreading / probing steps; these are folded into the convolution.
-
RealVec splineModB_¶
-
RealVec splineModC_¶
-
RealVec cachedInfluenceFunction_¶
The cached influence function involved in the convolution.
-
std::function<Real(bool, int, int, int, int, int, int, int, Real, Complex*, const RealMat&, Real, Real, const Real*, const Real*, const Real*, const int*, const int*, const int*, RealMat&, int)> convolveEVFxn_¶
A function pointer to call the approprate function to implement convolution with virial for conventional PME, templated to the rPower value.
-
std::function<Real(int, int, int, int, int, int, Real, const Real*, Real*, const RealMat&, Real, Real, const Real*, const Real*, const Real*, const int*, const int*, const int*, RealMat&, int)> convolveEVCompressedFxn_¶
A function pointer to call the approprate function to implement convolution with virial for comporessed PME, templated to the rPower value.
-
std::function<void(int, int, int, int, int, int, Real, RealVec&, const RealMat&, Real, Real, const Real*, const Real*, const Real*, const int*, const int*, const int*, int)> cacheInfluenceFunctionFxn_¶
A function pointer to call the approprate function to implement cacheing of the influence function that appears.
-
std::function<Real(int, Real, Real)> slfEFxn_¶
A function pointer to call the approprate function to compute self energy, templated to the rPower value.
-
std::function<Real(Real, Real)> dirEFxn_¶
A function pointer to call the approprate function to compute the direct energy, templated to the rPower value.
-
std::function<Real(Real, Real)> adjEFxn_¶
A function pointer to call the approprate function to compute the adjusted energy, templated to the rPower value.
-
std::function<std::tuple<Real, Real>(Real, Real, Real)> dirEFFxn_¶
A function pointer to call the approprate function to compute the direct energy and force, templated to the rPower value.
-
std::function<std::tuple<Real, Real>(Real, Real, Real)> adjEFFxn_¶
A function pointer to call the approprate function to compute the adjusted energy and force, templated to the rPower value.
-
int numNodesA_ = 1¶
The number of nodes in the {A,B,C} dimensions.
-
int numNodesB_ = 1¶
-
int numNodesC_ = 1¶
-
int myNodeRankA_ = 0¶
The rank of this node along the {A,B,C} dimensions.
-
int myNodeRankB_ = 0¶
-
int myNodeRankC_ = 0¶
-
int myFirstGridPointA_ = 0¶
The first grid point that this node is responsible for in the {A,B,C} dimensions.
-
int myFirstGridPointB_ = 0¶
-
int myFirstGridPointC_ = 0¶
-
int firstKSumTermA_ = 0¶
The first K sum term that this node is responsible for.
-
int firstKSumTermB_ = 0¶
-
int firstKSumTermC_ = 0¶
-
int myGridDimensionA_ = 0¶
The {X,Y,Z} dimensions of the locally owned chunk of the grid.
-
int myGridDimensionB_ = 0¶
-
int myGridDimensionC_ = 0¶
-
int subsetOfCAlongA_ = 0¶
The subsets of a given dimension to be processed when doing a transform along another dimension.
-
int subsetOfCAlongB_ = 0¶
-
int subsetOfBAlongC_ = 0¶
-
Real cacheLineSizeInReals_ = 0¶
The size of a cache line, in units of the size of the Real type, to allow better memory allocation policies.
-
bool unitCellHasChanged_ = true¶
Whether the unit cell parameters have been changed, invalidating cached gF quantities.
-
bool kappaHasChanged_ = true¶
Whether the kappa has been changed, invalidating kappa-dependent quantities.
-
bool gridDimensionHasChanged_ = true¶
Whether any of the grid dimensions have changed.
-
bool reciprocalSumDimensionHasChanged_ = true¶
Whether any of the reciprocal sum dimensions have changed.
-
bool algorithmHasChanged_ = true¶
Whether the algorithm to be used has changed.
-
bool splineOrderHasChanged_ = true¶
Whether the spline order has changed.
-
bool scaleFactorHasChanged_ = true¶
Whether the scale factor has changed.
-
bool rPowerHasChanged_ = true¶
Whether the power of R has changed.
-
bool numNodesHasChanged_ = true¶
Whether the parallel node setup has changed in any way.
-
AlgorithmType algorithmType_ = AlgorithmType::Undefined¶
The algorithm being used to solve for reciprocal space quantities.
-
LatticeType latticeType_ = LatticeType::Undefined¶
The type of alignment scheme used for the lattice vectors.
-
FFTWWrapper<Real> fftHelperA_¶
FFTW wrappers to help with transformations in the {A,B,C} dimensions.
-
FFTWWrapper<Real> fftHelperB_¶
-
FFTWWrapper<Real> fftHelperC_¶
-
std::vector<SplineCacheEntry<Real>> splineCache_¶
The cached list of splines.
-
RealMat fractionalPhis_¶
A scratch array for each threads to use as storage when probing the grid.
-
std::vector<std::list<size_t>> splinesPerThread_¶
A list of the splines that each thread should handle.
-
RealMat compressionCoefficientsA_¶
The transformation matrices for the compressed PME algorithms, in the {A,B,C} dimensions.
-
RealMat compressionCoefficientsB_¶
-
RealMat compressionCoefficientsC_¶
-
std::vector<int> mValsA_¶
Iterators that define the reciprocal lattice sums over each index, correctly defining -1/2 <= m{A,B,C} < 1/2.
-
std::vector<int> mValsB_¶
-
std::vector<int> mValsC_¶
-
std::vector<std::set<std::pair<uint32_t, uint32_t>>> gridAtomList_¶
A temporary list used in the assigning of atoms to threads and resorting by starting grid point.
Protected Static Functions
-
template<int rPower>
static inline Real convolveEVImpl(bool useConjugateSymmetry, int fullNx, int myNx, int myNy, int myNz, int startX, int startY, int startZ, Real scaleFactor, Complex *gridPtr, const RealMat &boxInv, Real volume, Real kappa, const Real *xMods, const Real *yMods, const Real *zMods, const int *xMVals, const int *yMVals, const int *zMVals, RealMat &virial, int nThreads)¶ convolveEVImpl performs the reciprocal space convolution, returning the energy, for conventional PME. We opt to not cache this the same way as the non-virial version because it’s safe to assume that if the virial is requested the box is likely to change, which renders the cache useless.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
useConjugateSymmetry – whether to use the complex conjugate symmetry in the convolution or not.
fullNx – full (complex) dimension of the reciprocal sum in the X direction.
myNx – the subset of the reciprocal sum in the x direction to be handled by this node.
myNy – the subset of the reciprocal sum in the y direction to be handled by this node.
myNz – the subset of the reciprocal sum in the z direction to be handled by this node.
startX – the starting reciprocal sum term handled by this node in the X direction.
startY – the starting reciprocal sum term handled by this node in the Y direction.
startZ – the starting reciprocal sum term handled by this node in the Z direction.
scaleFactor – a scale factor to be applied to all computed energies and derivatives thereof (e.g. the 1 / [4 pi epslion0] for Coulomb calculations).
gridPtr – the Fourier space grid, with ordering YXZ.
boxInv – the reciprocal lattice vectors.
volume – the volume of the unit cell.
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
xMods – the Fourier space norms of the x B-Splines.
yMods – the Fourier space norms of the y B-Splines.
zMods – the Fourier space norms of the z B-Splines.
xMVals – the integer prefactors to iterate over reciprocal vectors in the x dimension.
yMVals – the integer prefactors to iterate over reciprocal vectors in the y dimension.
zMVals – the integer prefactors to iterate over reciprocal vectors in the z dimension.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
nThreads – the number of OpenMP threads to use.
- Returns:
the reciprocal space energy.
- template<int rPower> static inline Real convolveEVCompressedImpl (int myNx, int myNy, int myNz, int startX, int startY, int startZ, Real scaleFactor, const Real *__restrict__ gridPtrIn, Real *__restrict__ gridPtrOut, const RealMat &boxInv, Real volume, Real kappa, const Real *xMods, const Real *yMods, const Real *zMods, const int *xMVals, const int *yMVals, const int *zMVals, RealMat &virial, int nThreads)
convolveEVCompressedImpl performs the reciprocal space convolution, returning the energy, for compressed PME. We opt to not cache this the same way as the non-virial version because it’s safe to assume that if the virial is requested the box is likely to change, which renders the cache useless.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
myNx – the subset of the reciprocal sum in the x direction to be handled by this node.
myNy – the subset of the reciprocal sum in the y direction to be handled by this node.
myNz – the subset of the reciprocal sum in the z direction to be handled by this node.
startX – the starting reciprocal sum term handled by this node in the X direction.
startY – the starting reciprocal sum term handled by this node in the Y direction.
startZ – the starting reciprocal sum term handled by this node in the Z direction.
scaleFactor – a scale factor to be applied to all computed energies and derivatives thereof (e.g. thee 1 / [4 pi epslion0] for Coulomb calculations).
gridPtrIn – the Fourier space grid, with ordering YXZ.
gridPtrOut – the convolved Fourier space grid, with ordering YXZ.
boxInv – the reciprocal lattice vectors.
volume – the volume of the unit cell.
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
xMods – the Fourier space norms of the x B-Splines.
yMods – the Fourier space norms of the y B-Splines.
zMods – the Fourier space norms of the z B-Splines.
xMVals – the integer prefactors to iterate over reciprocal vectors in the x dimension.
yMVals – the integer prefactors to iterate over reciprocal vectors in the y dimension.
zMVals – the integer prefactors to iterate over reciprocal vectors in the z dimension.
virial – a vector of length 6 containing the unique virial elements, in the order XX XY YY XZ YZ ZZ. This vector is incremented, not assigned.
nThreads – the number of OpenMP threads to use.
- Returns:
the reciprocal space energy.
-
template<int rPower>
static inline void cacheInfluenceFunctionImpl(int myNx, int myNy, int myNz, int startX, int startY, int startZ, Real scaleFactor, RealVec &influenceFunction, const RealMat &boxInv, Real volume, Real kappa, const Real *xMods, const Real *yMods, const Real *zMods, const int *xMVals, const int *yMVals, const int *zMVals, int nThreads)¶ cacheInfluenceFunctionImpl computes the influence function used in convolution, for later use.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
myNx – the subset of the grid in the x direction to be handled by this node.
myNy – the subset of the grid in the y direction to be handled by this node.
myNz – the subset of the grid in the z direction to be handled by this node.
startX – the starting reciprocal space sum term handled by this node in the X direction.
startY – the starting reciprocal space sum term handled by this node in the Y direction.
startZ – the starting reciprocal space sum term handled by this node in the Z direction.
scaleFactor – a scale factor to be applied to all computed energies and derivatives thereof (e.g. the 1 / [4 pi epslion0] for Coulomb calculations).
gridPtr – the Fourier space grid, with ordering YXZ.
boxInv – the reciprocal lattice vectors.
volume – the volume of the unit cell.
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
xMods – the Fourier space norms of the x B-Splines.
yMods – the Fourier space norms of the y B-Splines.
zMods – the Fourier space norms of the z B-Splines.
xMVals – the integer prefactors to iterate over reciprocal vectors in the x dimension.
yMVals – the integer prefactors to iterate over reciprocal vectors in the y dimension.
zMVals – the integer prefactors to iterate over reciprocal vectors in the z dimension. This vector is incremented, not assigned.
nThreads – the number of OpenMP threads to use.
- Returns:
the energy for the m=0 term.
-
template<int rPower>
static inline Real dirEImpl(Real rSquared, Real kappaSquared)¶ dirEImpl computes the kernel for the direct energy for a pair.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
rSquared – the square of the internuclear distance
kappaSquared – the square of attenuation parameter in units inverse of those used to specify coordinates.
- Returns:
the energy kernel.
-
template<int rPower>
static inline std::tuple<Real, Real> dirEFImpl(Real rSquared, Real kappa, Real kappaSquared)¶ dirEFImpl computes the kernels for the direct energy and force for a pair.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
rSquared – the square of the internuclear distance
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
kappaSquared – the square of attenuation parameter in units inverse of those used to specify coordinates.
- Returns:
a tuple containing the energy and force kernels, respectively.
-
template<int rPower>
static inline Real adjEImpl(Real rSquared, Real kappaSquared)¶ adjEImpl computes the kernel for the adjusted energy for a pair.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
rSquared – the square of the internuclear distance
kappaSquared – the square of attenuation parameter in units inverse of those used to specify coordinates.
- Returns:
the energy kernel.
-
template<int rPower>
static inline std::tuple<Real, Real> adjEFImpl(Real rSquared, Real kappa, Real kappaSquared)¶ adjEFImpl computes the kernels for the adjusted energy and force for a pair.
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
rSquared – the square of the internuclear distance
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
kappaSquared – the square of attenuation parameter in units inverse of those used to specify coordinates.
- Returns:
a tuple containing the energy and force kernels, respectively.
-
template<int rPower>
static inline Real slfEImpl(int parameterAngMom, Real kappa, Real scaleFactor)¶ slfEImpl computes the coefficient to be applied to the sum of squared parameters for the self energy due to particles feeling their own potential.
0 X Y Z XX XY YY XZ YZ ZZ XXX XXY XYY YYY XXZ XYZ YYZ XZZ YZZ ZZZ …
i.e. generated by the python loops
for L in range(maxAM+1): for Lz in range(0,L+1): for Ly in range(0, L - Lz + 1): Lx = L - Ly - Lz
- Template Parameters:
rPower – the exponent of the (inverse) distance kernel (e.g. 1 for Coulomb, 6 for attractive dispersion).
- Parameters:
parameterAngMom – the angular momentum of the parameters (0 for charges, C6 coefficients, 2 for quadrupoles, etc.).
parameters – the list of parameters associated with each atom (charges, C6 coefficients, multipoles, etc…). For a parameter with angular momentum L, a matrix of dimension nAtoms x nL is expected, where nL = (L+1)*(L+2)*(L+3)/6 and the fast running index nL has the ordering
kappa – the attenuation parameter in units inverse of those used to specify coordinates.
scaleFactor – a scale factor to be applied to all computed energies and derivatives thereof (e.g. the 1 / [4 pi epslion0] for Coulomb calculations).
- Returns:
the coefficient for the sum of squared parameters in the self energy. N.B. there is no self force associated with this term.