BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: forceField.h,v 1.33 2005/12/23 17:01:51 amoll Exp $ 00005 // 00006 00007 #ifndef BALL_MOLMEC_COMMON_FORCEFIELD_H 00008 #define BALL_MOLMEC_COMMON_FORCEFIELD_H 00009 00010 #ifndef BALL_COMMON_H 00011 # include <BALL/common.h> 00012 #endif 00013 00014 #ifndef BALL_KERNEL_SYSTEM_H 00015 # include <BALL/KERNEL/system.h> 00016 #endif 00017 00018 #ifndef BALL_DATATYPE_OPTIONS_H 00019 # include <BALL/DATATYPE/options.h> 00020 #endif 00021 00022 #ifndef BALL_CONCEPT_TIMESTAMP_H 00023 # include <BALL/CONCEPT/timeStamp.h> 00024 #endif 00025 00026 #ifndef BALL_MOLMEC_PARAMETER_FORCEFIELDPARAMETERS_H 00027 # include <BALL/MOLMEC/PARAMETER/forceFieldParameters.h> 00028 #endif 00029 00030 #ifndef BALL_MOLMEC_PARAMETER_ATOMTYPES_H 00031 # include <BALL/MOLMEC/PARAMETER/atomTypes.h> 00032 #endif 00033 00034 #ifndef BALL_MOLMEC_COMMON_PERIODIC_BOUNDARY_H 00035 # include <BALL/MOLMEC/COMMON/periodicBoundary.h> 00036 #endif 00037 00038 #ifndef BALL_MOLMEC_COMMON_ATOMVECTOR_H 00039 # include <BALL/MOLMEC/COMMON/atomVector.h> 00040 #endif 00041 00042 #include <vector> 00043 00044 namespace BALL 00045 { 00046 class ForceFieldComponent; 00047 00085 class BALL_EXPORT ForceField 00086 { 00087 public: 00088 00089 friend class ForceFieldComponent; 00090 00094 00099 typedef std::vector<std::pair<Atom*, Atom*> > PairVector; 00100 00102 00105 00106 BALL_CREATE(ForceField) 00107 00108 00112 ForceField(); 00113 00118 ForceField(System& system); 00119 00124 ForceField(System& system, const Options& options); 00125 00128 ForceField(const ForceField& force_field); 00129 00132 virtual ~ForceField(); 00133 00136 virtual void clear() 00137 ; 00138 00140 00143 00146 ForceField& operator = (const ForceField& force_field); 00147 00149 00152 00157 bool isValid() const 00158 ; 00159 00161 00164 00167 bool setup(System& system); 00168 00171 bool setup(System& system, const Options& options); 00172 00176 virtual bool specificSetup() 00177 throw(Exception::TooManyErrors); 00178 00183 void setMaximumNumberOfErrors(Size nr); 00184 00188 Size getMaximumNumberOfErrors() const; 00189 00191 HashSet<const Atom*>& getUnassignedAtoms(); 00192 00194 00197 00200 void setName(const String& name); 00201 00204 String getName() const; 00205 00208 Size getNumberOfAtoms() const; 00209 00217 Size getNumberOfMovableAtoms() const; 00218 00221 BALL_INLINE 00222 const AtomVector& getAtoms() const ; 00223 00226 BALL_INLINE 00227 System* getSystem() ; 00228 00231 BALL_INLINE 00232 const System* getSystem() const ; 00233 00236 BALL_INLINE 00237 bool getUseSelection() const ; 00238 00241 BALL_INLINE 00242 void disableSelection() ; 00243 00246 BALL_INLINE 00247 void enableSelection() ; 00248 00250 BALL_INLINE 00251 bool isSelectionEnabled() const ; 00252 00255 ForceFieldParameters& getParameters(); 00256 00259 Size countComponents() const; 00260 00268 const TimeStamp& getUpdateTime() const 00269 ; 00270 00278 const TimeStamp& getSetupTime() const 00279 ; 00280 00285 void insertComponent(ForceFieldComponent* force_field_component); 00286 00290 void removeComponent(const ForceFieldComponent* force_field_component); 00291 00294 void removeComponent(const String& name); 00295 00301 ForceFieldComponent* getComponent(const Size index) const; 00302 00306 ForceFieldComponent* getComponent(const String& name) const; 00307 00313 double getEnergy() const; 00314 00317 double updateEnergy(); 00318 00321 void updateForces(); 00322 00325 double getRMSGradient() const; 00326 00331 virtual Size getUpdateFrequency() const; 00332 00341 virtual void update() 00342 throw(Exception::TooManyErrors); 00343 00347 virtual String getResults() const 00348 { return "undefined";} 00349 00350 //_ Report an error and increase the error counter 00351 std::ostream& error() throw(Exception::TooManyErrors); 00352 00354 00357 00360 Options options; 00361 00364 PeriodicBoundary periodic_boundary; 00365 00367 00368 protected: 00369 /*_ Collect all atoms into the atoms_ vector. 00370 */ 00371 void collectAtoms_(const System& system); 00372 00373 /*_ Sort the atom vector wrt selection. 00374 */ 00375 void sortSelectedAtomVector_(); 00376 00380 virtual void performRequiredUpdates_(); 00381 00382 /*_ @name Protected Attributes 00383 */ 00384 //_@{ 00385 00386 /*_ The system the force field is bound to 00387 */ 00388 System* system_; 00389 00390 /*_ The atoms in the simulated system 00391 */ 00392 AtomVector atoms_; 00393 00394 /*_ An object containing the force field parameters read from a file 00395 */ 00396 ForceFieldParameters parameters_; 00397 00398 /*_ The boolean variable indicates if the setup of the force field was successful 00399 */ 00400 bool valid_; 00401 00402 /*_ The force field name 00403 */ 00404 String name_; 00405 00406 /*_ The total energy 00407 */ 00408 double energy_; 00409 00410 /*_ The components of the force field 00411 */ 00412 vector<ForceFieldComponent*> components_; 00413 00414 /*_ The number of movable atoms in the force field 00415 */ 00416 Size number_of_movable_atoms_; 00417 00418 /*_ Do we have to check whether atoms are selected? 00419 */ 00420 bool use_selection_; 00421 00422 /*_ This flag can temporarily disable the selection. 00423 */ 00424 bool selection_enabled_; 00425 00426 /*_ The time of the last call to update. 00427 */ 00428 TimeStamp update_time_stamp_; 00429 00430 /*_ The time of the last call to setup. 00431 */ 00432 TimeStamp setup_time_stamp_; 00433 00434 //_ Atoms, for which the setup of the force field fails 00435 HashSet<const Atom*> unassigned_atoms_; 00436 00437 //_ max number of unassigned atoms 00438 Size max_number_of_errors_; 00439 00440 Size number_of_errors_; 00441 00442 //_@} 00443 }; 00444 00445 # ifndef BALL_NO_INLINE_FUNCTIONS 00446 # include <BALL/MOLMEC/COMMON/forceField.iC> 00447 # endif 00448 00449 } // namespace BALL 00450 00451 #endif // BALL_MOLMEC_COMMON_FORCEFIELD_H