IMP logo
IMP Reference Guide  develop.b3a5ae88fa,2024/05/02
The Integrative Modeling Platform
SlabWithPore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/npc/SlabWithPore.h
3  * \brief A decorator for a particle that's a slab with a pore.
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPNPC_SLAB_WITH_PORE_H
10 #define IMPNPC_SLAB_WITH_PORE_H
11 
12 #include "npc_config.h"
13 #include <IMP/Decorator.h>
14 #include <IMP/decorator_macros.h>
15 
16 IMPNPC_BEGIN_NAMESPACE
17 
18 //! A decorator for a particle that represents a slab containing
19 //! a cylindrical pore
20 /** \ingroup helper
21  \ingroup decorators
22  */
23 class IMPNPCEXPORT SlabWithPore
24 : public IMP::Decorator
25 {
26  /** Decorate a particle that represents a slab (e.g. nuclear
27  envelope) with specified thickness and a cylindrical pore of
28  specified radius. Note that the radius is controlled by set_radius()
29  as any other XYZR particle, but the XYZ coordinates are ignored for now
30  (assumed to be 0,0,0).
31 
32  The slab is parallel to the x,y plane from z=-0.5*thickness to
33  z=0.5*thickness, and the central axis of the pore lies on the
34  origin.
35 
36  @param m the model
37  @param pi the particle index
38  @param thickness slab thickness
39  @param pore_radius pore radius
40 
41  @note the pore radius is initially not optimizable
42  */
43  static void do_setup_particle(IMP::Model* m,
44  ParticleIndex pi,
45  double thickness,
46  double pore_radius);
47 
48 
49  public:
51 
52 
53  /** Decorate a particle that represents a slab (e.g. nuclear
54  envelope) with specified thickness and a cylindrical pore of
55  specified pore_radius.
56 
57  The slab is parallel to the x,y plane from z=-0.5*thickness to
58  z=0.5*thickness, and the central axis of the pore lies on the
59  origin.
60 
61  @param m the model
62  @param pi the particle index
63  @param thickness slab thickness
64  @param pore_radius pore radius
65 
66  @note the pore radius is initially not optimizable
67  */
69  double, thickness,
70  double, pore_radius);
71 
72  //! Return true if the particle is an instance of SlabWithPore
73  static bool get_is_setup(Model *m, ParticleIndex pi) {
74  return m->get_has_attribute(get_pore_radius_key(), pi) &&
75  m->get_has_attribute(get_thickness_key(), pi);
76  }
77 
78  //! sets slab thickness
79  void set_thickness(double thickness) {
80  get_particle()->set_value(get_thickness_key(),
81  thickness);
82  }
83 
84  //! returns whether the particle last entered the transport moiety from its
85  //!top
86  Float get_thickness() const {
87  return get_particle()->get_value(get_thickness_key());
88  }
89 
90  //! get cylindrical pore radius
92  return get_particle()->get_value(get_pore_radius_key());
93  }
94 
95  //! set cylindrical pore radius
96  void set_pore_radius(double r) const {
97  get_particle()->set_value(get_pore_radius_key(), r);
98  }
99 
100  //! add v to the derivative of the cylindrical pore radius,
101  //! using derivative accumulator d
103  get_particle()->add_to_derivative(get_pore_radius_key(), v, d);
104  }
105 
106  bool get_pore_radius_is_optimized() const {
107  return get_particle()->get_is_optimized(get_pore_radius_key());
108  }
109  //! Set whether the pore radius is optimized
110  void set_pore_radius_is_optimized(bool tf) const {
111  get_particle()->set_is_optimized(get_pore_radius_key(), tf);
112  }
113 
114  //! Get the key for the pore thickness.
115  static FloatKey get_thickness_key();
116 
117  //! Get the key for the pore radius.
118  static FloatKey get_pore_radius_key();
119 };
120 
121 
122 
123 IMP_DECORATORS(SlabWithPore, SlabsWithPores, IMP::Decorators);
124 
125 IMPNPC_END_NAMESPACE
126 
127 #endif /* IMPNPC_SLAB_WITH_PORE_H */
The base class for decorators.
void add_to_pore_radius_derivative(double v, DerivativeAccumulator &d)
Definition: SlabWithPore.h:102
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
void set_pore_radius(double r) const
set cylindrical pore radius
Definition: SlabWithPore.h:96
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of SlabWithPore.
Definition: SlabWithPore.h:73
Helper macros for implementing Decorators.
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:194
void set_thickness(double thickness)
sets slab thickness
Definition: SlabWithPore.h:79
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:119
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
#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
Float get_pore_radius() const
get cylindrical pore radius
Definition: SlabWithPore.h:91
void set_pore_radius_is_optimized(bool tf) const
Set whether the pore radius is optimized.
Definition: SlabWithPore.h:110
Float get_thickness() const
Definition: SlabWithPore.h:86
Class for adding derivatives from restraints to the model.