IMP  2.3.0
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-2014 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/kernel/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 kernel::Restraint {
42  mutable kernel::ParticleIndexPairs cur_list_;
43  mutable bool was_bad_;
44  mutable bool initialized_;
45  ObjectKey key_;
47  // moved stuff
48  mutable kernel::ParticleIndexes rbs_;
49  mutable kernel::ParticleIndexes xyzrs_;
50  mutable boost::unordered_map<kernel::ParticleIndex, kernel::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;
62  ExcludedVolumeRestraint(SingletonContainerAdaptor sc,
64  double slack = 10);
65 
66  public:
67  /** The SingletonContainer contains a set of XYZR particles and RigidMembers.
68 
69  The slack is how far the particles must move before the list of close
70  pairs is computed. It does not matter for correctness, just running
71  time. You may want to fiddle with it or use the
72  IMP::container::get_slack_estimate() function.
73 
74  The spring constant used is k.*/
75  ExcludedVolumeRestraint(SingletonContainerAdaptor sc, double k = 1,
76  double slack = 10,
77  std::string name = "ExcludedVolumeRestraint%1%");
78 
79  void clear_caches();
80 
81 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
82  double unprotected_evaluate_if_good(DerivativeAccumulator *da,
83  double max) const;
84 #endif
85  public:
86  double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const
90  ;
93 #ifndef IMP_DOXYGEN
94  const kernel::ParticleIndexPairs &get_indexes() const { return cur_list_; }
95 #endif
96  IMP_LIST_ACTION(public, PairFilter, PairFilters, pair_filter, pair_filters,
97  PairPredicate *, PairPredicates, , , );
98 };
99 
100 IMPCORE_END_NAMESPACE
101 
102 #endif /* IMPCORE_EXCLUDED_VOLUME_RESTRAINT_H */
ParticleIndexes get_indexes(const ParticlesTemp &ps)
A base class for Keys.
Definition: kernel/Key.h:46
Class for adding derivatives from restraints to the model.
Import IMP/kernel/SingletonContainer.h in the namespace.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:147
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Import IMP/kernel/UnaryFunction.h in the namespace.
virtual void clear_caches()
Definition: Object.h:227
Import IMP/kernel/PairContainer.h in the namespace.
Abstract base class for all restraints.
Import IMP/kernel/Refiner.h in the namespace.
functionality for defining rigid bodies
A restraint is a term in an IMP ScoringFunction.
Abstract predicate function.
IMP::base::Vector< IMP::base::Pointer< PairPredicate > > PairPredicates
virtual Restraints do_create_current_decomposition() const
A score on the distance between the surfaces of two spheres.
Handle rigid bodies by looking at their members.
virtual ModelObjectsTemp do_get_inputs() const =0
Prevent a set of particles and rigid bodies from inter-penetrating.
virtual Restraints do_create_decomposition() const
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.