29 #ifndef CDPL_FORCEFIELD_ELASTICPOTENTIALFUNCTIONS_HPP
30 #define CDPL_FORCEFIELD_ELASTICPOTENTIALFUNCTIONS_HPP
56 template <
typename ValueType,
typename Iter,
typename CoordsArray>
68 template <
typename ValueType,
typename CoordsArray>
88 template <
typename ValueType,
typename CoordsVec>
90 const ValueType& force_const,
const ValueType& ref_length);
107 template <
typename ValueType,
typename Iter,
typename CoordsArray,
typename GradVector>
122 template <
typename ValueType,
typename CoordsArray,
typename GradVector>
157 template <
typename ValueType,
typename CoordsVec,
typename GradVec>
159 const ValueType& force_const,
const ValueType& ref_length);
167 template <
typename ValueType,
typename Iter,
typename CoordsArray>
170 return Detail::accumInteractionEnergies<ValueType>(beg, end, coords,
171 static_cast<ValueType (*)(
const ElasticPotential&,
const CoordsArray&)
>(
172 &calcElasticPotentialEnergy<ValueType, CoordsArray>));
175 template <
typename ValueType,
typename CoordsArray>
178 return calcElasticPotentialEnergy<ValueType>(coords[pot.getAtom1Index()], coords[pot.getAtom2Index()],
179 pot.getForceConstant(), pot.getReferenceLength());
182 template <
typename ValueType,
typename CoordsVec>
184 const ValueType& force_const,
const ValueType& ref_length)
186 ValueType dr_ij = calcDistance<ValueType>(atom1_pos, atom2_pos) - ref_length;
187 ValueType e = force_const * dr_ij * dr_ij;
193 template <
typename ValueType,
typename Iter,
typename CoordsArray,
typename GradVector>
196 return Detail::calcInteractionGradient<ValueType>(beg, end, coords, grad,
197 static_cast<ValueType (*)(
const ElasticPotential&,
const CoordsArray&, GradVector&)
>(
198 &calcElasticPotentialGradient<ValueType, CoordsArray, GradVector>));
201 template <
typename ValueType,
typename CoordsArray,
typename GradVector>
204 return calcElasticPotentialGradient<ValueType>(coords[pot.getAtom1Index()], coords[pot.getAtom2Index()], grad[pot.getAtom1Index()],
205 grad[pot.getAtom2Index()], pot.getForceConstant(), pot.getReferenceLength());
208 template <
typename ValueType,
typename CoordsVec,
typename GradVec>
210 const ValueType& force_const,
const ValueType& ref_length)
212 ValueType dist_atom1_grad[3];
213 ValueType dist_atom2_grad[3];
215 ValueType dr_ij = calcDistanceDerivatives<ValueType>(atom1_pos, atom2_pos, dist_atom1_grad, dist_atom2_grad) - ref_length;
216 ValueType grad_fact = ValueType(2) * force_const * dr_ij;
218 Detail::scaleAddVector(dist_atom1_grad, grad_fact, atom1_grad);
219 Detail::scaleAddVector(dist_atom2_grad, grad_fact, atom2_grad);
221 ValueType e = force_const * dr_ij * dr_ij;
Declaration of type CDPL::Util::BitSet.
Definition of class CDPL::ForceField::ElasticPotential.
Definition of the preprocessor macro CDPL_FORCEFIELD_API.
Utility functions used in the calculation of force field energies and gradients.
Stores parameters for an elastic potential (harmonic distance restraint) between a pair of atoms.
Definition: ElasticPotential.hpp:47
ValueType calcElasticPotentialEnergy(Iter beg, const Iter &end, const CoordsArray &coords)
Accumulates the energies calculated for the elastic potentials specified by the iterators in the give...
ValueType calcElasticPotentialGradient(Iter beg, const Iter &end, const CoordsArray &coords, GradVector &grad)
Accumulates the energies and gradient contributions calculated for the elastic potentials specified b...
The namespace of the Chemical Data Processing Library.