00001
00002
00003
00004
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
00351 std::ostream& error() throw(Exception::TooManyErrors);
00352
00354
00357
00360 Options options;
00361
00364 PeriodicBoundary periodic_boundary;
00365
00367
00368 protected:
00369
00370
00371 void collectAtoms_(const System& system);
00372
00373
00374
00375 void sortSelectedAtomVector_();
00376
00377
00378
00379
00380
00381
00382
00383 System* system_;
00384
00385
00386
00387 AtomVector atoms_;
00388
00389
00390
00391 ForceFieldParameters parameters_;
00392
00393
00394
00395 bool valid_;
00396
00397
00398
00399 String name_;
00400
00401
00402
00403 double energy_;
00404
00405
00406
00407 vector<ForceFieldComponent*> components_;
00408
00409
00410
00411 Size number_of_movable_atoms_;
00412
00413
00414
00415 bool use_selection_;
00416
00417
00418
00419 bool selection_enabled_;
00420
00421
00422
00423 TimeStamp update_time_stamp_;
00424
00425
00426
00427 TimeStamp setup_time_stamp_;
00428
00429
00430 HashSet<const Atom*> unassigned_atoms_;
00431
00432
00433 Size max_number_of_errors_;
00434
00435 Size number_of_errors_;
00436
00437
00438 };
00439
00440 # ifndef BALL_NO_INLINE_FUNCTIONS
00441 # include <BALL/MOLMEC/COMMON/forceField.iC>
00442 # endif
00443
00444 }
00445
00446 #endif // BALL_MOLMEC_COMMON_FORCEFIELD_H