BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
forceField.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: forceField.h,v 1.33 2005/12/23 17:01:51 amoll Exp $
5 //
6 
7 #ifndef BALL_MOLMEC_COMMON_FORCEFIELD_H
8 #define BALL_MOLMEC_COMMON_FORCEFIELD_H
9 
10 #ifndef BALL_COMMON_H
11 # include <BALL/common.h>
12 #endif
13 
14 #ifndef BALL_KERNEL_SYSTEM_H
15 # include <BALL/KERNEL/system.h>
16 #endif
17 
18 #ifndef BALL_DATATYPE_OPTIONS_H
19 # include <BALL/DATATYPE/options.h>
20 #endif
21 
22 #ifndef BALL_CONCEPT_TIMESTAMP_H
23 # include <BALL/CONCEPT/timeStamp.h>
24 #endif
25 
26 #ifndef BALL_MOLMEC_PARAMETER_FORCEFIELDPARAMETERS_H
28 #endif
29 
30 #ifndef BALL_MOLMEC_PARAMETER_ATOMTYPES_H
32 #endif
33 
34 #ifndef BALL_MOLMEC_COMMON_PERIODIC_BOUNDARY_H
36 #endif
37 
38 #ifndef BALL_MOLMEC_COMMON_ATOMVECTOR_H
40 #endif
41 
42 #include <vector>
43 
44 namespace BALL
45 {
46  class ForceFieldComponent;
47 
86  {
87  public:
88 
89  friend class ForceFieldComponent;
90 
94 
99  typedef std::vector<std::pair<Atom*, Atom*> > PairVector;
100 
102 
105 
107 
108 
112  ForceField();
113 
118  ForceField(System& system);
119 
124  ForceField(System& system, const Options& options);
125 
128  ForceField(const ForceField& force_field);
129 
132  virtual ~ForceField();
133 
136  virtual void clear()
137  ;
138 
140 
143 
146  ForceField& operator = (const ForceField& force_field);
147 
149 
152 
157  bool isValid() const
158  ;
159 
161 
164 
167  bool setup(System& system);
168 
171  bool setup(System& system, const Options& options);
172 
176  virtual bool specificSetup()
177  throw(Exception::TooManyErrors);
178 
183  void setMaximumNumberOfErrors(Size nr);
184 
188  Size getMaximumNumberOfErrors() const;
189 
191  HashSet<const Atom*>& getUnassignedAtoms();
192 
194 
197 
200  void setName(const String& name);
201 
204  String getName() const;
205 
208  Size getNumberOfAtoms() const;
209 
217  Size getNumberOfMovableAtoms() const;
218 
222  const AtomVector& getAtoms() const ;
223 
227  System* getSystem() ;
228 
232  const System* getSystem() const ;
233 
237  bool getUseSelection() const ;
238 
242  void disableSelection() ;
243 
247  void enableSelection() ;
248 
251  bool isSelectionEnabled() const ;
252 
255  ForceFieldParameters& getParameters();
256 
259  Size countComponents() const;
260 
268  const TimeStamp& getUpdateTime() const
269  ;
270 
278  const TimeStamp& getSetupTime() const
279  ;
280 
285  void insertComponent(ForceFieldComponent* force_field_component);
286 
290  void removeComponent(const ForceFieldComponent* force_field_component);
291 
294  void removeComponent(const String& name);
295 
301  ForceFieldComponent* getComponent(const Size index) const;
302 
306  ForceFieldComponent* getComponent(const String& name) const;
307 
313  double getEnergy() const;
314 
317  double updateEnergy();
318 
321  void updateForces();
322 
325  double getRMSGradient() const;
326 
331  virtual Size getUpdateFrequency() const;
332 
341  virtual void update()
342  throw(Exception::TooManyErrors);
343 
347  virtual String getResults() const
348  { return "undefined";}
349 
350  //_ Report an error and increase the error counter
351  std::ostream& error() throw(Exception::TooManyErrors);
352 
354 
357 
360  Options options;
361 
364  PeriodicBoundary periodic_boundary;
365 
367 
368  protected:
369  /*_ Collect all atoms into the atoms_ vector.
370  */
371  void collectAtoms_(const System& system);
372 
373  /*_ Sort the atom vector wrt selection.
374  */
375  void sortSelectedAtomVector_();
376 
380  virtual void performRequiredUpdates_();
381 
382  /*_ @name Protected Attributes
383  */
384  //_@{
385 
386  /*_ The system the force field is bound to
387  */
388  System* system_;
389 
390  /*_ The atoms in the simulated system
391  */
392  AtomVector atoms_;
393 
394  /*_ An object containing the force field parameters read from a file
395  */
396  ForceFieldParameters parameters_;
397 
398  /*_ The boolean variable indicates if the setup of the force field was successful
399  */
400  bool valid_;
401 
402  /*_ The force field name
403  */
404  String name_;
405 
406  /*_ The total energy
407  */
408  double energy_;
409 
410  /*_ The components of the force field
411  */
412  vector<ForceFieldComponent*> components_;
413 
414  /*_ The number of movable atoms in the force field
415  */
416  Size number_of_movable_atoms_;
417 
418  /*_ Do we have to check whether atoms are selected?
419  */
420  bool use_selection_;
421 
422  /*_ This flag can temporarily disable the selection.
423  */
424  bool selection_enabled_;
425 
426  /*_ The time of the last call to update.
427  */
428  TimeStamp update_time_stamp_;
429 
430  /*_ The time of the last call to setup.
431  */
432  TimeStamp setup_time_stamp_;
433 
434  //_ Atoms, for which the setup of the force field fails
435  HashSet<const Atom*> unassigned_atoms_;
436 
437  //_ max number of unassigned atoms
438  Size max_number_of_errors_;
439 
440  Size number_of_errors_;
441 
442  //_@}
443  };
444 
445 # ifndef BALL_NO_INLINE_FUNCTIONS
446 # include <BALL/MOLMEC/COMMON/forceField.iC>
447 # endif
448 
449 } // namespace BALL
450 
451 #endif // BALL_MOLMEC_COMMON_FORCEFIELD_H