| 1 | // -*- Mode: C++; tab-width: 2; -*- |
| 2 | // vi: set ts=2: |
| 3 | // |
| 4 | // $Id: forceFieldComponent.h,v 1.20.18.1 2007/03/25 21:23:49 oliver Exp $ |
| 5 | // |
| 6 | |
| 7 | // Molecular Mechanics: general force field component class |
| 8 | |
| 9 | #ifndef BALL_MOLMEC_FORCEFIELDCOMPONENT_H |
| 10 | #define BALL_MOLMEC_FORCEFIELDCOMPONENT_H |
| 11 | |
| 12 | #ifndef BALL_COMMON_H |
| 13 | # include <BALL/common.h> |
| 14 | #endif |
| 15 | |
| 16 | #ifndef BALL_DATATYPE_STRING_H |
| 17 | # include <BALL/DATATYPE/string.h> |
| 18 | #endif |
| 19 | |
| 20 | #ifndef BALL_KERNEL_ATOM_H |
| 21 | # include <BALL/KERNEL/atom.h> |
| 22 | #endif |
| 23 | |
| 24 | #include <BALL/SCORING/COMMON/scoringComponent.h> |
| 25 | |
| 26 | namespace BALL |
| 27 | { |
| 28 | class ForceField; |
| 29 | |
| 30 | /** Generic force field component class. |
| 31 | |
| 32 | \ingroup MolmecCommon |
| 33 | */ |
| 34 | class BALL_EXPORT ForceFieldComponent : public ScoringComponent |
| 35 | { |
| 36 | |
| 37 | friend class ForceField; |
| 38 | |
| 39 | public: |
| 40 | |
| 41 | /** @name Constructors and Destructors |
| 42 | */ |
| 43 | //@{ |
| 44 | |
| 45 | public: |
| 46 | |
| 47 | BALL_CREATE(ForceFieldComponent) |
| 48 | |
| 49 | /** Default constructor. |
| 50 | */ |
| 51 | ForceFieldComponent(); |
| 52 | |
| 53 | /** Constructor. |
| 54 | */ |
| 55 | ForceFieldComponent(ForceField& force_field); |
| 56 | |
| 57 | /** Copy constructor. |
| 58 | Creates a new instance of the given ForceFieldComponent. |
| 59 | The created object will not be assigned to an existing force field. |
| 60 | */ |
| 61 | ForceFieldComponent(const ForceFieldComponent& force_field_component); |
| 62 | |
| 63 | /** Destructor. |
| 64 | */ |
| 65 | virtual ~ForceFieldComponent(); |
| 66 | |
| 67 | //@} |
| 68 | |
| 69 | /** @name Setup method |
| 70 | */ |
| 71 | //@{ |
| 72 | |
| 73 | /** Setup method. |
| 74 | */ |
| 75 | virtual bool setup(); |
| 76 | |
| 77 | //@} |
| 78 | /** @name Accessors |
| 79 | */ |
| 80 | //@{ |
| 81 | |
| 82 | /** Returns the parent force field. |
| 83 | 0 is returned, if no force field is assigned. |
| 84 | */ |
| 85 | ForceField* getForceField() const; |
| 86 | |
| 87 | /** Sets the force field. |
| 88 | */ |
| 89 | void setForceField(ForceField& force_field); |
| 90 | |
| 91 | /** Sets the component's name. |
| 92 | */ |
| 93 | void setName(const String& name); |
| 94 | |
| 95 | /** Returns the component's name |
| 96 | */ |
| 97 | String getName() const; |
| 98 | |
| 99 | /// |
| 100 | bool isEnabled() const { return enabled_;} |
| 101 | |
| 102 | /// |
| 103 | void setEnabled(bool state) { enabled_ = state;} |
| 104 | |
| 105 | //@} |
| 106 | /** @name Force field calculations |
| 107 | */ |
| 108 | //@{ |
| 109 | |
| 110 | /** Returns the energy of the force field component |
| 111 | */ |
| 112 | virtual double getEnergy() const; |
| 113 | |
| 114 | /** Returns the energy of the force field component. |
| 115 | The current energy for this force field component is being |
| 116 | calculated and returned in units of kJ/mol. \par |
| 117 | If the component isn't assigned to a ForceField object, |
| 118 | zero is returned. |
| 119 | */ |
| 120 | virtual double updateEnergy(); |
| 121 | |
| 122 | /** Updates the atomic forces in the force field. |
| 123 | The forces created by this ForceFieldComponent are |
| 124 | calculated for each atom and updated in the corresponding |
| 125 | array (forces) of the ForceField instance this component |
| 126 | is assigned to. |
| 127 | */ |
| 128 | virtual void updateForces(); |
| 129 | |
| 130 | /** Regular update of the pair list and the like. |
| 131 | Each component that contains updatable data structures |
| 132 | (like nonbonded pair lists) should implement |
| 133 | this method. It is called for each component of a force field |
| 134 | each time \link ForceField::update ForceField::update \endlink is called. |
| 135 | The default implementation does exactly nothing. |
| 136 | @throws BALL::Exception::TooManyErrors |
| 137 | */ |
| 138 | virtual void update(); |
| 139 | |
| 140 | /** interface to ScoringComponent */ |
| 141 | double updateScore(); |
| 142 | |
| 143 | protected: |
| 144 | |
| 145 | //@} |
| 146 | /*_ @name Protected Attributes |
| 147 | */ |
| 148 | //_@{ |
| 149 | |
| 150 | /*_ The force field this component is registered in |
| 151 | */ |
| 152 | ForceField* force_field_; |
| 153 | |
| 154 | /*_ The energy of the component |
| 155 | */ |
| 156 | double energy_; |
| 157 | |
| 158 | private: |
| 159 | |
| 160 | //_@} |
| 161 | /*_ @name Private Attributes |
| 162 | */ |
| 163 | //_@{ |
| 164 | |
| 165 | /*_ The force field component name |
| 166 | */ |
| 167 | String name_; |
| 168 | |
| 169 | bool enabled_; |
| 170 | |
| 171 | //_@} |
| 172 | |
| 173 | }; |
| 174 | } // namespace BALL |
| 175 | |
| 176 | #endif // BALL_MOLMEC_FORCEFIELDCOMPONENT_H |