IMP  2.2.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-2014 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  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
28  Float well_depth = 0) {
29  IMP_USAGE_CHECK(XYZR::get_is_setup(m, pi),
30  "Particle must already be an XYZR particle");
31  m->add_attribute(get_well_depth_key(), pi, well_depth);
32  }
33 
34  public:
38 
39  Float get_well_depth() const {
40  return static_cast<Float>(get_particle()->get_value(get_well_depth_key()));
41  }
42 
43  void set_well_depth(Float well_depth) {
44  IMP_USAGE_CHECK(well_depth >= 0, "well depth cannot be negative");
45  get_particle()->set_value(get_well_depth_key(), well_depth);
46  }
47 
48  //! Return true if the particle is an instance of a LennardJones
50  return XYZR::get_is_setup(m, pi) &&
51  m->get_has_attribute(get_well_depth_key(), pi);
52  }
53 
54  static FloatKey get_well_depth_key();
55 };
56 
57 IMP_DECORATORS(LennardJones, LennardJonesList, core::XYZRs);
58 
59 IMPATOM_END_NAMESPACE
60 
61 #endif /* IMPATOM_LENNARD_JONES_H */
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
Return true if the particle is an instance of a LennardJones.
Definition: LennardJones.h:49
Particle * get_particle() const
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_DECORATOR_SETUP_0(Name)
A decorator for a particle that has a Lennard-Jones potential well.
Definition: LennardJones.h:26
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Decorator for a sphere-like particle.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27