IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
Charged.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Charged.h
3  * \brief A decorator for a point particle that has an electrostatic charge.
4  *
5  * Copyright 2007-2017 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_CHARGED_H
10 #define IMPATOM_CHARGED_H
11 
12 #include <IMP/atom/atom_config.h>
13 
14 #include <IMP/core/XYZ.h>
15 #include <IMP/algebra/Vector3D.h>
16 #include <IMP/internal/constants.h>
17 
18 #include <vector>
19 #include <limits>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 //! A decorator for a point particle that has an electrostatic charge.
24 /** The charge itself should be given in atomic units; i.e. the charge on
25  a proton is +1 and on an electron, -1.
26 
27  \ingroup helper
28  \ingroup decorators
29  \see CoulombPairScore
30  */
31 class IMPATOMEXPORT Charged : public IMP::core::XYZ {
32  static void do_setup_particle(Model *m, ParticleIndex pi,
33  const algebra::Vector3D &v, Float charge) {
34  XYZ::setup_particle(m, pi, v);
35  do_setup_particle(m, pi, charge);
36  }
37  static void do_setup_particle(Model *m, ParticleIndex pi,
38  Float charge = 0) {
39  IMP_USAGE_CHECK(XYZ::get_is_setup(m, pi),
40  "Particle must already be an XYZ particle");
41  m->add_attribute(get_charge_key(), pi, charge);
42  }
43 
44  public:
48 
49  IMP_DECORATOR_GET_SET(charge, get_charge_key(), Float, Float);
50 
51  //! Return true if the particle is an instance of a Charged
52  static bool get_is_setup(Model *m, ParticleIndex pi) {
53  return XYZ::get_is_setup(m, pi) &&
54  m->get_has_attribute(get_charge_key(), pi);
55  }
56 
57  static FloatKey get_charge_key();
58 };
59 
60 IMP_DECORATORS(Charged, Chargeds, core::XYZs);
61 
62 IMPATOM_END_NAMESPACE
63 
64 #endif /* IMPATOM_CHARGED_H */
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
Define methods for getting and setting a particular simple field.
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of a Charged.
Definition: Charged.h:52
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Simple XYZ decorator.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
A decorator for a point particle that has an electrostatic charge.
Definition: Charged.h:31
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle atribute with the specied key and initial value
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
#define IMP_DECORATOR_METHODS(Name, Parent)
VectorD< 3 > Vector3D
Definition: VectorD.h:395
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Simple 3D vector class.
#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