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_; }
69 virtual double evaluate_index(
Model *m,
74 virtual bool check_indexes(
Model *m,
77 const int *type_array = LennardJonesTyped::get_type_array(m),
78 evaluate_index_fast(m, p[i], da, type_array) );
83 template <
class SmoothingFuncT>
90 double distsqr = delta.get_squared_magnitude();
91 double dist = std::sqrt(distsqr);
92 double dist6 = distsqr * distsqr * distsqr;
93 double dist12 = dist6 * dist6;
95 int index = params_->get_parameter_index(lj0.get_index(), lj1.get_index());
96 double A = params_->aij_[index] * repulsive_weight_;
97 double B = params_->bij_[index] * attractive_weight_;
98 double repulsive = A / dist12;
99 double attractive = B / dist6;
100 double score = repulsive - attractive;
104 score, (6.0 * attractive - 12.0 * repulsive) / dist, dist);
110 return (*smoothing_function_)(score, dist);
114 template <
class SmoothingFuncT>
123 total += lj0.get_index();
128 template <
class SmoothingFuncT>
131 const int *type_array)
const {
134 int type0 = type_array[lj0.get_particle_index().get_index()];
135 int type1 = type_array[lj1.get_particle_index().get_index()];
138 double distsqr = delta.get_squared_magnitude();
139 double dist = std::sqrt(distsqr);
140 double dist6 = distsqr * distsqr * distsqr;
141 double dist12 = dist6 * dist6;
143 int index = params_->get_parameter_index(type0, type1);
144 double A = params_->aij_[index] * repulsive_weight_;
145 double B = params_->bij_[index] * attractive_weight_;
146 double repulsive = A / dist12;
147 double attractive = B / dist6;
148 double score = repulsive - attractive;
152 score, (6.0 * attractive - 12.0 * repulsive) / dist, dist);
154 lj0.add_to_derivatives(deriv, *da);
155 lj1.add_to_derivatives(-deriv, *da);
158 return (*smoothing_function_)(score, dist);
162 template <
class SmoothingFuncT>
168 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.
#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.
A more IMP-like version of the std::vector.
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...)
#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.