IMP logo
IMP Reference Guide  2.23.0
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-2022 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/Pointer.h>
15 #include <IMP/atom/LennardJones.h>
17 
18 IMPATOM_DEPRECATED_HEADER(2.23, "Use LennardJonesTypedPairScore.h instead");
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 //! Lennard-Jones score between a pair of particles.
23 /** The two particles in the pair must be LennardJones particles.
24  The form of the potential is \f[
25  -\epsilon \left[ w_{rep} \left(\frac{r_{min}}{r}\right)^{12}
26  - 2 w_{att} \left(\frac{r_{min}}{r}\right)^{6}\right]
27  \f] where \f$\epsilon\f$ is the depth of the well between the
28  two particles, \f$r_{min}\f$ the sum of the particles' radii, \f$r\f$
29  the inter-particle distance, and \f$w_{rep}\f$ and \f$w_{att}\f$ the
30  weights on the repulsive and attractive parts of the potential respectively;
31  both weights are 1.0 by default.
32 
33  The well depth is the geometric mean of the individual particles' well
34  depths (as extracted by LennardJones::get_well_depth).
35 
36  Note that because this score uses radii and well depths set in the particles
37  themselves, the strength of the interaction cannot be changed for a
38  particular pair of atoms (as is done in the CHARMM forcefield with the
39  rarely-used NBFIX directive, for example). If the well depth or radius of
40  a single particle is modified, that will affect its interaction with all
41  particles.
42 
43  It is recommended that new code instead uses LennardJonesTypedPairScore,
44  which is about twice as fast and can support NBFIX.
45  */
46 class IMPATOMEXPORT LennardJonesPairScore : public PairScore {
47  IMP::PointerMember<SmoothingFunction> smoothing_function_;
48  double repulsive_weight_, attractive_weight_;
49 
50  // Calculate A, B factors from particle well depths and radii
51  // It may be appropriate to cache these for speed since the particle
52  // attributes rarely change and square roots are expensive
53  inline void get_factors(const LennardJones &lj0, const LennardJones &lj1,
54  double &A, double &B) const {
55  double well_depth = std::sqrt(lj0.get_well_depth() * lj1.get_well_depth());
56  double rmin = lj0.get_radius() + lj1.get_radius();
57  // probably faster than pow(rmin, 6) on systems that don't
58  // have pow(double, int)
59  double rmin6 = rmin * rmin * rmin * rmin * rmin * rmin;
60  double rmin12 = rmin6 * rmin6;
61 
62  A = well_depth * rmin12 * repulsive_weight_;
63  B = 2.0 * well_depth * rmin6 * attractive_weight_;
64  }
65 
66  public:
67  IMPATOM_DEPRECATED_OBJECT_DECL(2.23)
69  : smoothing_function_(f),
70  repulsive_weight_(1.0),
71  attractive_weight_(1.0) {
72  IMPATOM_DEPRECATED_OBJECT_DEF(
73  2.23, "Use LennardJonesTypedPairScore instead");
74  }
75 
76  void set_repulsive_weight(double repulsive_weight) {
77  repulsive_weight_ = repulsive_weight;
78  }
79 
80  double get_repulsive_weight() const { return repulsive_weight_; }
81 
82  void set_attractive_weight(double attractive_weight) {
83  attractive_weight_ = attractive_weight;
84  }
85 
86  double get_attractive_weight() const { return attractive_weight_; }
87 
88  virtual double evaluate_index(Model *m,
89  const ParticleIndexPair &p,
90  DerivativeAccumulator *da) const override;
92  Model *m, const ParticleIndexes &pis) const override;
95  ;
96 };
97 
99 
100 IMPATOM_END_NAMESPACE
101 
102 #endif /* IMPATOM_LENNARD_JONES_PAIR_SCORE_H */
Abstract class for scoring object(s) of type ParticleIndexPair.
Definition: PairScore.h:44
#define IMP_PAIR_SCORE_METHODS(Name)
Definition: pair_macros.h:25
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A more IMP-like version of the std::vector.
Definition: Vector.h:50
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A decorator for a particle that has a Lennard-Jones potential well.
Lennard-Jones score between a pair of particles.
Define PairScore.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
A decorator for a particle that has a Lennard-Jones potential well.
Definition: LennardJones.h:29
Classes to smooth nonbonded interactions.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A nullptr-initialized pointer to an IMP Object.
Base class for smoothing nonbonded interactions as a function of distance.
virtual double evaluate_index(Model *m, const ParticleIndexPair &vt, DerivativeAccumulator *da) const =0
Compute the score and the derivative if needed.
Class for adding derivatives from restraints to the model.
Compile-time generic restraint and constraint support.