29 #ifndef CDPL_FORCEFIELD_ELASTICPOTENTIALFUNCTIONS_HPP
30 #define CDPL_FORCEFIELD_ELASTICPOTENTIALFUNCTIONS_HPP
47 template <
typename ValueType,
typename Iter,
typename CoordsArray>
53 template <
typename ValueType,
typename CoordsArray>
73 template <
typename ValueType,
typename CoordsVec>
75 const ValueType& force_const,
const ValueType& ref_length);
80 template <
typename ValueType,
typename Iter,
typename CoordsArray,
typename GradVector>
86 template <
typename ValueType,
typename CoordsArray,
typename GradVector>
121 template <
typename ValueType,
typename CoordsVec,
typename GradVec>
123 const ValueType& force_const,
const ValueType& ref_length);
131 template <
typename ValueType,
typename Iter,
typename CoordsArray>
134 return Detail::accumInteractionEnergies<ValueType>(beg, end, coords,
135 static_cast<ValueType (*)(
const ElasticPotential&,
const CoordsArray&)
>(
136 &calcElasticPotentialEnergy<ValueType, CoordsArray>));
139 template <
typename ValueType,
typename CoordsArray>
142 return calcElasticPotentialEnergy<ValueType>(coords[pot.getAtom1Index()], coords[pot.getAtom2Index()],
143 pot.getForceConstant(), pot.getReferenceLength());
146 template <
typename ValueType,
typename CoordsVec>
148 const ValueType& force_const,
const ValueType& ref_length)
150 ValueType dr_ij = calcDistance<ValueType>(atom1_pos, atom2_pos) - ref_length;
151 ValueType e = force_const * dr_ij * dr_ij;
157 template <
typename ValueType,
typename Iter,
typename CoordsArray,
typename GradVector>
160 return Detail::calcInteractionGradient<ValueType>(beg, end, coords, grad,
161 static_cast<ValueType (*)(
const ElasticPotential&,
const CoordsArray&, GradVector&)
>(
162 &calcElasticPotentialGradient<ValueType, CoordsArray, GradVector>));
165 template <
typename ValueType,
typename CoordsArray,
typename GradVector>
168 return calcElasticPotentialGradient<ValueType>(coords[pot.getAtom1Index()], coords[pot.getAtom2Index()], grad[pot.getAtom1Index()],
169 grad[pot.getAtom2Index()], pot.getForceConstant(), pot.getReferenceLength());
172 template <
typename ValueType,
typename CoordsVec,
typename GradVec>
174 const ValueType& force_const,
const ValueType& ref_length)
176 ValueType dist_atom1_grad[3];
177 ValueType dist_atom2_grad[3];
179 ValueType dr_ij = calcDistanceDerivatives<ValueType>(atom1_pos, atom2_pos, dist_atom1_grad, dist_atom2_grad) - ref_length;
180 ValueType grad_fact = ValueType(2) * force_const * dr_ij;
182 Detail::scaleAddVector(dist_atom1_grad, grad_fact, atom1_grad);
183 Detail::scaleAddVector(dist_atom2_grad, grad_fact, atom2_grad);
185 ValueType e = force_const * dr_ij * dr_ij;
192 #endif // CDPL_FORCEFIELD_ELASTICPOTENTIALENERGYFUNCTIONS_HPP