IMP  2.1.1
The Integrative Modeling Platform
LennardJonesPairScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/LennardJonesPairScore.h
3  * \brief Lennard-Jones score between a pair of particles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_LENNARD_JONES_PAIR_SCORE_H
9 #define IMPATOM_LENNARD_JONES_PAIR_SCORE_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include <IMP/generic.h>
13 #include <IMP/PairScore.h>
14 #include <IMP/base/Pointer.h>
15 #include <IMP/atom/LennardJones.h>
17 
18 IMPATOM_BEGIN_NAMESPACE
19 
20 //! Lennard-Jones score between a pair of particles.
21 /** The two particles in the pair must be LennardJones particles.
22  The form of the potential is \f[
23  -\epsilon \left[ w_{rep} \left(\frac{r_{min}}{r}\right)^{12}
24  - 2 w_{att} \left(\frac{r_{min}}{r}\right)^{6}\right]
25  \f] where \f$\epsilon\f$ is the depth of the well between the
26  two particles, \f$r_{min}\f$ the sum of the particles' radii, \f$r\f$
27  the interparticle distance, and \f$w_{rep}\f$ and \f$w_{att}\f$ the
28  weights on the repulsive and attractive parts of the potential respectively;
29  both weights are 1.0 by default.
30 
31  The well depth is the geometric mean of the individual particles' well
32  depths (as extracted by LennardJones::get_well_depth).
33 
34  Note that because this score uses radii and well depths set in the particles
35  themselves, the strength of the interaction cannot be changed for a
36  particular pair of atoms (as is done in the CHARMM forcefield with the
37  rarely-used NBFIX directive, for example). If the well depth or radius of
38  a single particle is modifed, that will affect its interaction with all
39  particles.
40  */
41 class IMPATOMEXPORT LennardJonesPairScore : public PairScore {
43  double repulsive_weight_, attractive_weight_;
44 
45  // Calculate A, B factors from particle well depths and radii
46  // It may be appropriate to cache these for speed since the particle
47  // attributes rarely change and square roots are expensive
48  inline void get_factors(const LennardJones &lj0, const LennardJones &lj1,
49  double &A, double &B) const {
50  double well_depth = std::sqrt(lj0.get_well_depth() * lj1.get_well_depth());
51  double rmin = lj0.get_radius() + lj1.get_radius();
52  // probably faster than pow(rmin, 6) on systems that don't
53  // have pow(double, int)
54  double rmin6 = rmin * rmin * rmin * rmin * rmin * rmin;
55  double rmin12 = rmin6 * rmin6;
56 
57  A = well_depth * rmin12 * repulsive_weight_;
58  B = 2.0 * well_depth * rmin6 * attractive_weight_;
59  }
60 
61  public:
63  : smoothing_function_(f),
64  repulsive_weight_(1.0),
65  attractive_weight_(1.0) {}
66 
67  void set_repulsive_weight(double repulsive_weight) {
68  repulsive_weight_ = repulsive_weight;
69  }
70 
71  double get_repulsive_weight() const { return repulsive_weight_; }
72 
73  void set_attractive_weight(double attractive_weight) {
74  attractive_weight_ = attractive_weight;
75  }
76 
77  double get_attractive_weight() const { return attractive_weight_; }
78 
79  virtual double evaluate_index(kernel::Model *m,
81  DerivativeAccumulator *da) const IMP_OVERRIDE;
83  kernel::Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE;
86  ;
87 };
88 
90 
91 IMPATOM_END_NAMESPACE
92 
93 #endif /* IMPATOM_LENNARD_JONES_PAIR_SCORE_H */
Class for adding derivatives from restraints to the model.
A nullptr-initialized pointer to an IMP Object.
virtual double evaluate_index(kernel::Model *m, const ParticleIndexPair &vt, DerivativeAccumulator *da) const
Compute the score and the derivative if needed.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
#define IMP_PAIR_SCORE_METHODS(Name)
A decorator for a particle that has a Lennard-Jones potential well.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Abstract score function.
Lennard-Jones score between a pair of particles.
virtual ModelObjectsTemp do_get_inputs(kernel::Model *m, const ParticleIndexes &pis) const
Import IMP/kernel/PairScore.h in the namespace.
#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.
Definition: LennardJones.h:26
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Classes to smooth nonbonded interactions.
Base class for smoothing nonbonded interactions as a function of distance.
Class for storing model, its restraints, constraints, and particles.
Import IMP/kernel/generic.h in the namespace.