88 for (
int_t d : {0, 1, 2})
142 real_t dv = std::numeric_limits<real_t>::max();
143 real_t dva = std::numeric_limits<real_t>::max();
162 for (
int_t i : {-im, im})
163 for (
int_t j = -jm; j < jm + 1; ++j)
164 for (
int_t k = -km; k < km + 1; ++k)
175 for (
int_t j : {-jm, jm})
176 for (
int_t k = -km; k < km + 1; ++k)
177 for (
int_t i = -im; i < im + 1; ++i)
188 for (
int_t k : {-km, km})
189 for (
int_t i = -im; i < im + 1; ++i)
190 for (
int_t j = -jm; j < jm + 1; ++j)
244 real_t kfactor = 4 * M_PI / volume;
304 real_t kfactor = 4 * M_PI / volume;
318 real_t es = cval + rval + kval;
343 const size_t N = R.size();
353 for (
size_t i = 0; i <
N; ++i)
354 qqmax = std::max(
std::abs(Q[i] * Q[i]), qqmax);
360 for (
size_t i = 0; i <
N; ++i)
361 ve += Q[i] * Q[i] * vm / 2;
368 #pragma omp parallel for reduction(+ : ve) 369 for (
size_t i = 1; i <
N / 2 + 1; ++i)
371 for (
size_t j = 0; j < i; ++j)
375 for (
size_t dim = 0; dim <
DIM; dim++)
378 ve += qq *
ewaldSum(rr, a, tol / qq);
381 const size_t i_reverse =
N - i;
385 for (
size_t j = 0; j < i_reverse; ++j)
387 real_t qq = Q[i_reverse] * Q[j];
389 for (
size_t dim = 0; dim <
DIM; dim++)
392 ve += qq *
ewaldSum(rr, a, tol / qq);
Functor for term within the real-space sum in Drummond 2008 formula 7.
helper functions for EinsplineSetBuilder
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Functor for term within the real-space sum in Drummond 2008 formula 6.
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
RspaceMadelungTerm(const RealMat &a_in, real_t rconst_in)
std::vector< real_t > ChargeArray
Type for lists of particle charges.
Computes Ewald sums of the potential energy to a given tolerance for arbitrary collections of charges...
real_t operator()(const IntVec &i) const
real_t ewaldEnergy(const RealMat &a, const PosArray &R, const ChargeArray &Q, real_t tol)
Compute the total Ewald potential energy for a collection of charges.
real_t gridSum(T &function, bool zero=true, real_t tol=1e-11)
Perform a sum over successively larger cubic integer grids in DIM dimensional space for arbitrary fun...
real_t operator()(const IntVec &i) const
int int_t
Type for integers.
std::vector< RealVec > PosArray
Type for lists of particle positions.
const RealMat a
The real-space cell axes.
RspaceEwaldTerm(const RealVec &r_in, const RealMat &a_in, real_t rconst_in)
KspaceMadelungTerm(const RealMat &b_in, real_t kconst_in, real_t kfactor_in)
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
const RealMat a
The real-space cell axes.
real_t getKappaMadelung(real_t volume)
Find the optimal kappa for Madelung sums.
Functor for term within the k-space sum in Drummond 2008 formula 7.
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
const real_t rconst
The constant in Drummond 2008 formula 7.
Tensor<T,D> class for D by D tensor.
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
const real_t kfactor
The constant 4/ in Drummond 2008 formula 7.
const RealVec r
The inter-particle separation vector.
real_t getKappaEwald(real_t volume)
Find the optimal kappa for Ewald pair sums.
Functor for term within the k-space sum in Drummond 2008 formula 6.
const RealMat b
The k-space cell axes.
real_t ewaldSum(const RealVec &r, const RealMat &a, real_t tol=1e-10)
Compute the Ewald interaction of a particle pair to a given tolerance.
const RealMat b
The k-space cell axes.
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
real_t operator()(const IntVec &i) const
AntiSymTensor< T, D > transpose(const AntiSymTensor< T, D > &rhs)
const real_t kconst
The constant -^2/2 in Drummond 2008 formula 6.
const real_t rconst
The constant 1/({2}) in Drummond 2008 formula 6.
KspaceEwaldTerm(const RealVec &r_in, const RealMat &b_in, real_t kconst_in, real_t kfactor_in)
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
Tensor< T, D > inverse(const Tensor< T, D > &a)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
double real_t
Type for floating point numbers.
real_t operator()(const IntVec &i) const
const RealVec r
The inter-particle separation vector.
real_t madelungSum(const RealMat &a, real_t tol=1e-10)
Compute the Madelung constant to a given tolerance.
const real_t kfactor
The constant 4/ in Drummond 2008 formula 6.
const real_t kconst
The constant 1/(4^2) in Drummond 2008 formula 7.
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)