IMP logo
IMP Reference Guide  2.11.1
The Integrative Modeling Platform
ExcludedVolumeRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/ExcludedVolumeRestraint.h
3  * \brief Prevent spheres from inter-penetrating
4  *
5  * Copyright 2007-2019 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_EXCLUDED_VOLUME_RESTRAINT_H
9 #define IMPCORE_EXCLUDED_VOLUME_RESTRAINT_H
10 
11 #include <IMP/core/core_config.h>
12 
13 #include "internal/remove_pointers.h"
14 #include "rigid_bodies.h"
15 #include <IMP/PairContainer.h>
16 #include <IMP/SingletonContainer.h>
17 #include <IMP/Restraint.h>
18 #include <IMP/UnaryFunction.h>
19 #include <IMP/Refiner.h>
20 #include "RigidClosePairsFinder.h"
22 #include <boost/unordered_map.hpp>
23 
24 IMPCORE_BEGIN_NAMESPACE
25 
26 //! Prevent a set of particles and rigid bodies from inter-penetrating
27 /** Given an arbitrary collection of particles and rigid bodies, this
28  restraint prevents the particles from interpenetrating. Such restraints
29  are also known as steric clash restraints.
30 
31  \note Pairs of particles within a single rigid body are not restrained
32  (and are ignored in the returned score).
33 
34  \note See IMP::container::ClosePairContainer for more information about
35  close pair based scoring functions and \imp.
36 
37  \note Changing the set of particles in the SingletonContainer is not
38  currently supported after the first evaluate call.
39  */
40 class IMPCOREEXPORT ExcludedVolumeRestraint : public Restraint {
42  mutable ParticleIndexPairs cur_list_;
43  mutable bool was_bad_;
44  mutable bool initialized_;
45  ObjectKey key_;
47  // moved stuff
48  mutable ParticleIndexes rbs_;
49  mutable ParticleIndexes xyzrs_;
50  mutable boost::unordered_map<ParticleIndex, ParticleIndexes>
51  constituents_;
52  double slack_;
53  mutable algebra::Sphere3Ds rbs_backup_sphere_;
54  mutable algebra::Rotation3Ds rbs_backup_rot_;
55  mutable algebra::Sphere3Ds xyzrs_backup_;
56 
57  void reset_moved() const;
58  void initialize() const;
59  bool get_if_moved() const;
60  void fill_list() const;
61  double fill_list_if_good(double max) const;
64  double slack = 10);
65 
66  public:
67  //! Construct an excluded volume restraint over a container of particles
68  /** Construct an excluded volume restraint over a container of XYZR
69  and/or RigidMember particles with a lower-harmonic score on
70  overlapping spheres. Formally, every two overlapping spheres
71  contrinute k*D^2/2 to the restraint score (repulsion force of
72  k*D), where D is the depth of the overlap between the two
73  spheres. Non-overlapping spheres do not contribute to the score.
74 
75  @param sc a SingletonContainer contains a set of XYZR particles and RigidMembers.
76  @param slack how far in A the particles must move before the
77  internal list of close pairs is computed (this list is used to
78  efficiently detect clashing particles). It does not matter for
79  correctness, just running time. You may want to fiddle with it
80  or use the IMP::container::get_slack_estimate() function.
81  @param k the spring constant used for the lower-harmonic score, in kcal/mol/A^2.
82  @param name the object name
83 */
85  double slack = 10,
86  std::string name = "ExcludedVolumeRestraint%1%");
87 
88  void clear_caches();
89 
90 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
91  double unprotected_evaluate_if_good(DerivativeAccumulator *da,
92  double max) const;
93 #endif
94  public:
95  double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const
99  ;
102 #ifndef IMP_DOXYGEN
103  const ParticleIndexPairs &get_indexes() const { return cur_list_; }
104 #endif
105  IMP_LIST_ACTION(public, PairFilter, PairFilters, pair_filter, pair_filters,
106  PairPredicate *, PairPredicates, , , );
107 };
108 
109 IMPCORE_END_NAMESPACE
110 
111 #endif /* IMPCORE_EXCLUDED_VOLUME_RESTRAINT_H */
A container for Singletons.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Single variable function.
virtual Restraints do_create_decomposition() const
Definition: Restraint.h:225
virtual void clear_caches()
Definition: Object.h:227
A container for Pairs.
virtual Restraints do_create_current_decomposition() const
Definition: Restraint.h:235
Refine a particle into a list of particles.
functionality for defining rigid bodies
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
A score on the distance between the surfaces of two spheres.
Abstract predicate function.
Definition: PairPredicate.h:31
Handle rigid bodies by looking at their members.
Prevent a set of particles and rigid bodies from inter-penetrating.
Abstract base class for all restraints.
ParticleIndexes get_indexes(const ParticlesTemp &ps)
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:54