IMP  2.0.1
The Integrative Modeling Platform
LennardJones.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/LennardJones.h
3  * \brief A decorator for a particle that has a Lennard-Jones potential well.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_LENNARD_JONES_H
10 #define IMPATOM_LENNARD_JONES_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include <IMP/core/XYZR.h>
14 
15 IMPATOM_BEGIN_NAMESPACE
16 
17 //! A decorator for a particle that has a Lennard-Jones potential well.
18 /** Such particles must be XYZR particles (they must have a position and
19  a radius) but need not be true atoms.
20 
21  The well depth should be a non-negative value.
22  \ingroup helper
23  \ingroup decorators
24  \see LennardJonesPairScore
25  */
26 class IMPATOMEXPORT LennardJones: public IMP::core::XYZR
27 {
28 public:
30 
31  /** Create a decorator with the passed well depth.
32  The particle is assumed to already have x,y,z,r attributes.
33  */
34  static LennardJones setup_particle(Particle *p, Float well_depth=0) {
35  IMP_USAGE_CHECK(XYZR::particle_is_instance(p),
36  "Particle must already be an XYZR particle");
37  p->add_attribute(get_well_depth_key(), well_depth);
38  return LennardJones(p);
39  }
40 
41  Float get_well_depth() const {
42  return static_cast<Float>(get_particle()->get_value(get_well_depth_key()));
43  }
44 
45  void set_well_depth(Float well_depth) {
46  IMP_USAGE_CHECK(well_depth >= 0, "well depth cannot be negative");
47  get_particle()->set_value(get_well_depth_key(), well_depth);
48  }
49 
50  //! Return true if the particle is an instance of a LennardJones
51  static bool particle_is_instance(Particle *p) {
53  && p->has_attribute(get_well_depth_key());
54  }
55 
56  static FloatKey get_well_depth_key();
57 };
58 
59 IMP_DECORATORS(LennardJones, LennardJonesList, core::XYZRs);
60 
61 IMPATOM_END_NAMESPACE
62 
63 #endif /* IMPATOM_LENNARD_JONES_H */