IMP logo
IMP Reference Guide  2.20.2
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-2022 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(Model *m, 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
49  static bool get_is_setup(Model *m, ParticleIndex pi) {
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 */
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of a LennardJones.
Definition: LennardJones.h:49
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle attribute with the specified key and initial value
#define IMP_DECORATOR_SETUP_0(Name)
A decorator for a particle that has a Lennard-Jones potential well.
Definition: LennardJones.h:26
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:194
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
Decorator for a sphere-like particle.
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27