IMP  2.0.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-2013 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 {
33 public:
35 
36  /** Create a decorator with the passed coordinates and charge.
37  */
39  Float charge) {
40  XYZ::setup_particle(p, v);
41  p->add_attribute(get_charge_key(), charge);
42  return Charged(p);
43  }
44 
45  /** Create a decorator with the passed charge.
46  The particle is assumed to already have x,y,z attributes.
47  */
48  static Charged setup_particle(Particle *p, Float charge=0) {
49  IMP_USAGE_CHECK(XYZ::particle_is_instance(p),
50  "Particle must already be an XYZ particle");
51  p->add_attribute(get_charge_key(), charge);
52  return Charged(p);
53  }
54 
55  IMP_DECORATOR_GET_SET(charge, get_charge_key(), Float, Float);
56 
57  //! Return true if the particle is an instance of a Charged
58  static bool particle_is_instance(Particle *p) {
59  return XYZ::particle_is_instance(p)
60  && p->has_attribute(get_charge_key());
61  }
62 
63  static FloatKey get_charge_key();
64 };
65 
66 IMP_DECORATORS(Charged, Chargeds, core::XYZs);
67 
68 IMPATOM_END_NAMESPACE
69 
70 #endif /* IMPATOM_CHARGED_H */