8 #ifndef IMPATOM_LENNARD_JONES_TYPED_PAIR_SCORE_H
9 #define IMPATOM_LENNARD_JONES_TYPED_PAIR_SCORE_H
11 #include <IMP/atom/atom_config.h>
19 IMPATOM_BEGIN_NAMESPACE
38 template <
class SmoothingFuncT>
41 double repulsive_weight_, attractive_weight_;
44 double evaluate_index_fast(
Model *m,
47 const int *type_array)
const;
51 : smoothing_function_(f),
52 repulsive_weight_(1.0),
53 attractive_weight_(1.0) {
54 params_ = internal::get_lj_params();
57 void set_repulsive_weight(
double repulsive_weight) {
58 repulsive_weight_ = repulsive_weight;
61 double get_repulsive_weight()
const {
return repulsive_weight_; }
63 void set_attractive_weight(
double attractive_weight) {
64 attractive_weight_ = attractive_weight;
67 double get_attractive_weight()
const {
return attractive_weight_; }
79 SmoothingFuncT *get_smoothing_function()
const {
80 return smoothing_function_;
83 virtual double evaluate_index(
Model *m,
88 virtual bool check_indexes(
Model *m,
91 const int *type_array = LennardJonesTyped::get_type_array(m),
92 evaluate_index_fast(m, p[i], da, type_array) );
97 template <
class SmoothingFuncT>
104 double distsqr = delta.get_squared_magnitude();
105 double dist = std::sqrt(distsqr);
106 double dist6 = distsqr * distsqr * distsqr;
107 double dist12 = dist6 * dist6;
109 int index = params_->get_parameter_index(lj0.get_index(), lj1.get_index());
110 double A = params_->aij_[index] * repulsive_weight_;
111 double B = params_->bij_[index] * attractive_weight_;
112 double repulsive = A / dist12;
113 double attractive = B / dist6;
114 double score = repulsive - attractive;
118 score, (6.0 * attractive - 12.0 * repulsive) / dist, dist);
124 return (*smoothing_function_)(score, dist);
128 template <
class SmoothingFuncT>
137 total += lj0.get_index();
142 template <
class SmoothingFuncT>
145 const int *type_array)
const {
148 int type0 = type_array[lj0.get_particle_index().get_index()];
149 int type1 = type_array[lj1.get_particle_index().get_index()];
152 double distsqr = delta.get_squared_magnitude();
153 double dist = std::sqrt(distsqr);
154 double dist6 = distsqr * distsqr * distsqr;
155 double dist12 = dist6 * dist6;
157 int index = params_->get_parameter_index(type0, type1);
158 double A = params_->aij_[index] * repulsive_weight_;
159 double B = params_->bij_[index] * attractive_weight_;
160 double repulsive = A / dist12;
161 double attractive = B / dist6;
162 double score = repulsive - attractive;
166 score, (6.0 * attractive - 12.0 * repulsive) / dist, dist);
168 lj0.add_to_derivatives(deriv, *da);
169 lj1.add_to_derivatives(-deriv, *da);
172 return (*smoothing_function_)(score, dist);
176 template <
class SmoothingFuncT>
182 IMPATOM_END_NAMESPACE
void add_to_derivatives(const algebra::Vector3D &v, DerivativeAccumulator &d)
Add the vector v to the derivative vector of the x,y,z coordinates.
Abstract class for scoring object(s) of type ParticleIndexPair.
Macros for various classes.
Floats get_repulsive_type_factors() const
Return the precalculated repulsive factors for each pair of LJ types.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A decorator for a particle that has a Lennard-Jones potential well.
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
Class for storing model, its restraints, constraints, and particles.
Lennard-Jones score between a pair of particles.
A decorator for a particle with x,y,z coordinates.
const algebra::Vector3D & get_coordinates() const
Convert it to a vector.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Classes to smooth nonbonded interactions.
A nullptr-initialized pointer to an IMP Object.
double Float
Basic floating-point value (could be float, double...)
Floats get_attractive_type_factors() const
Return the precalculated attractive factors for each pair of LJ types.
#define IMP_PAIR_SCORE_METHODS_UNCHECKED(Name, Setup, Evaluate)
Parameters for a Lennard-Jones interaction.
Class for adding derivatives from restraints to the model.
Compile-time generic restraint and constraint support.