Debian Codegraph @

include/BALL/MOLMEC/COMMON/snapShot.h

raw symbols SCIP
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4
5 // This file contains the definitions of the classes
6 // SnapshotManager and Snapshot.
7 // They can be used to obtain snapshots from an MD simulation or an energy
8 // minimisation.
9 // A snapshot contains atom positions, velocities, forces and potential energy.
10
11
12 #ifndef BALL_MOLMEC_COMMON_SNAPSHOT_H
13 #define BALL_MOLMEC_COMMON_SNAPSHOT_H
14
15 #ifndef BALL_MATHS_VECTOR3_H
16 # include <BALL/MATHS/vector3.h>
17 #endif
18
19 namespace BALL
20 {
21 class System;
22
23 /** SnapShot class, containing the actual data of one single snapshot.
24 It consists of the posistions, velocities and forces for each atom
25 along with kinetic and potential energy of selected atoms. It is used
26 by the \link SnapShotManager SnapShotManager \endlink . \par
27 \ingroup MolmecCommon
28 */
29 class BALL_EXPORT SnapShot
30 {
31
32 public:
33
34 BALL_CREATE(SnapShot)
35
36 /// @name Constructors and Destructors
37 //@{
38
39 /** The default constructor. It creates an empty SnapShot object.
40 */
41 SnapShot();
42
43 /// Copy constructor.
44 SnapShot(const SnapShot& snapshot);
45
46 /// The destructor
47 virtual ~SnapShot();
48
49 //@}
50 /// @name Assignment
51 //@{
52
53 /// Assignment operator.
54 const SnapShot& operator = (const SnapShot& snapshot);
55
56 /// Clear method.
57 virtual void clear();
58
59 //@}
60 /// @name Predicates
61 //@{
62
63 /// Equality operator
64 bool operator == (const SnapShot& snapshot) const;
65
66 /** Indicates validity of the SnapShot
67 @return true if this instance is valid
68 */
69 bool isValid() const;
70
71 //@}
72 /// @name Accessors
73 //@{
74
75 /// Set the index attribute.
76 void setIndex(Size index);
77
78 /// Get the index of this instance.
79 Size getIndex() const;
80
81 /// Set the number of atoms that are covered by this snapshot.
82 void setNumberOfAtoms(Size number_of_atoms);
83
84 /// Get the number of atoms that are covered by this snapshot.
85 Size getNumberOfAtoms() const;
86
87 /// Set the value for the potential energy of this snapshot's system
88 void setPotentialEnergy(DoubleReal potential_energy);
89
90 /// Get the value for the potential energy of this snapshot's system
91 DoubleReal getPotentialEnergy() const;
92
93 /// Set the value for the kinetic energy of this snapshot's system
94 void setKineticEnergy(DoubleReal kinetic_energy);
95
96 /// Get the value for the kinetic energy of this snapshot's system
97 DoubleReal getKineticEnergy() const;
98
99 /// Specify all atom positions
100 void setAtomPositions(const ::std::vector<Vector3>& atom_postions);
101
102 /// Get the vector containing the atom postions
103 const ::std::vector<Vector3>& getAtomPositions() const;
104
105 /// Specify all atom velocities
106 void setAtomVelocities(const ::std::vector<Vector3>& atom_velocities);
107
108 /// Get the vector containing the atom velocitites
109 const ::std::vector<Vector3>& getAtomVelocities() const;
110
111 /// Specify all atom forces
112 void setAtomForces(const ::std::vector<Vector3>& atom_forces);
113
114 /// Get all atom forces
115 const ::std::vector<Vector3>& getAtomForces() const;
116
117 //@}
118 /// @name System interaction
119 //@{
120
121 /** Take a SnapShot from a system. Copy all positions, velocities and
122 forces from the System <tt>system</tt> to this instance of SnapShot.
123 @param system the System from which to take the data
124 @throws BALL::Exception::OutOfMemory
125 */
126 void takeSnapShot(const System& system);
127
128 /** Apply the data contained in a SnapShot to a System. Copy all
129 available data to the system. <b>Note</b> that some trajectory file
130 formats do not contain all this information and vectors might be
131 zero or even worse undefined when read SnapShots are read from such
132 a file.
133 @param system the System which will be manipulated
134 */
135 void applySnapShot(System& system) const;
136
137 /** Read all atom positions from a System and store them in this
138 instance of SnapShot.
139 @param system the System from which data will be read
140 @throws BALL::Exception::OutOfMemory
141 */
142 void getAtomPositions(const System& system);
143
144 /** Set all Atom positions of a System to the values stored in this
145 instance of SnapShot.
146 @param system the system which will be manipulated
147 */
148 void setAtomPositions(System& system) const;
149
150 /** Read all atom velocities from a System and store them in this
151 instance of SnapShot.
152 @param system the System from which data will be read
153 @throws BALL::Exception::OutOfMemory
154 */
155 void getAtomVelocities(const System& system);
156
157 /** Set all Atom velocities of a System to the values stored in this
158 instance of SnapShot.
159 @param system the system which will be manipulated
160 */
161 void setAtomVelocitites(System& system) const;
162
163 /** Read all atom forces from a System and store them in this
164 instance of SnapShot.
165 @param system the System from which data will be read
166 @throws BALL::Exception::OutOfMemory
167 */
168 void getAtomForces(const System& system);
169
170 /** Set all Atom forces of a System to the values stored in this
171 instance of SnapShot.
172 @param system the system which will be manipulated
173 */
174 void setAtomForces(System& system) const;
175
176 //@}
177
178 protected:
179
180 //_ @name Protected Attributes
181 //@{
182
183 //_ The index of the current snapshot object. Valid indices start at 1.
184 Size index_;
185
186 /*_ The number of atoms of the underlying system. The system being
187 snapshot must always be the same, especially with respect to
188 the number of atoms.
189 */
190 Size number_of_atoms_;
191
192 /*_ The potential energy in the system when the snapshot is taken.
193 Only contributions from selected atoms are considered.
194 */
195 double potential_energy_;
196
197 /*_ The kinetic energy due to electrostatic interactions.
198 Only contributions from selected atoms are considered.
199 */
200 double kinetic_energy_;
201
202 //_ An STL vector with the positions of all atoms
203 vector<Vector3> atom_positions_;
204
205 //_ An STL vector with the velocities of all atoms
206 vector<Vector3> atom_velocities_;
207
208 //_ An STL vector with the forces of all atoms
209 vector<Vector3> atom_forces_;
210
211 //@}
212
213 }; // Snapshot
214
215 /// Output stream operator for SnapShots
216 ::std::ostream& operator << (::std::ostream& os, const SnapShot& ss);
217
218 /// Input stream operator for SnapShots
219 ::std::istream& operator >> (::std::istream& is, SnapShot& ss);
220
221 } // end of namespace BALL
222
223 #endif // BALL_MOLMEC_COMMON_SNAPSHOT_H