ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/brains/Stats.cpp
(Generate patch)

Comparing trunk/src/brains/Stats.cpp (file contents):
Revision 541 by tim, Sun May 22 21:05:15 2005 UTC vs.
Revision 2022 by gezelter, Fri Sep 26 22:22:28 2014 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
2 > * Copyright (c) 2005, 2009 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
5   * non-exclusive, royalty free, license to use, modify and
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42    
43   /**
# Line 48 | Line 49
49   */
50  
51   #include "brains/Stats.hpp"
52 + #include "brains/Thermo.hpp"
53  
54 < namespace oopse {
54 > namespace OpenMD {
55  
56 <  bool Stats::isInit_ = false;
55 <  std::string Stats::title_[Stats::ENDINDEX - Stats::BEGININDEX];
56 <  std::string Stats::units_[Stats::ENDINDEX - Stats::BEGININDEX];
56 >  Stats::Stats(SimInfo* info) : isInit_(false), info_(info) {  
57  
58  Stats::Stats() {
59
58      if (!isInit_) {
59        init();
60        isInit_ = true;
61      }
64
62    }
63  
64    void Stats::init() {
65 +  
66 +    data_.resize(Stats::ENDINDEX);
67  
68 <    Stats::title_[TIME] = "Time";
69 <    Stats::title_[TOTAL_ENERGY] = "Total Energy";
70 <    Stats::title_[POTENTIAL_ENERGY] = "Potential Energy";
71 <    Stats::title_[KINETIC_ENERGY] = "Kinetic Energy";
72 <    Stats::title_[TEMPERATURE] = "Temperature";
73 <    Stats::title_[PRESSURE] = "Pressure";
74 <    Stats::title_[VOLUME] = "Volume";
75 <    Stats::title_[CONSERVED_QUANTITY] = "Conserved Quantity";            
76 <    Stats::title_[TRANSLATIONAL_KINETIC] = "Translational Kinetic";
77 <    Stats::title_[ROTATIONAL_KINETIC] = "Rotational Kinetic";
78 <    Stats::title_[LONG_RANGE_POTENTIAL] = "Long Range Potential";
79 <    Stats::title_[SHORT_RANGE_POTENTIAL] = "Short Range Potential";
80 <    Stats::title_[VANDERWAALS_POTENTIAL] = "van der waals Potential";
81 <    Stats::title_[BOND_POTENTIAL] = "Bond Potential";
82 <    Stats::title_[BEND_POTENTIAL] = "Bend Potential";
83 <    Stats::title_[DIHEDRAL_POTENTIAL] = "Dihedral Potential";
84 <    Stats::title_[IMPROPER_POTENTIAL] = "Improper Potential";
85 <    Stats::title_[VRAW] = "Raw Potential";
86 <    Stats::title_[VHARM] = "Harmonic Potential";
87 <    Stats::title_[PRESSURE_TENSOR_X] = "presure tensor x";
88 <    Stats::title_[PRESSURE_TENSOR_Y] = "presure tensor y";
89 <    Stats::title_[PRESSURE_TENSOR_Z] = "presure tensor z";
68 >    StatsData time;
69 >    time.units =  "fs";
70 >    time.title =  "Time";
71 >    time.dataType = "RealType";
72 >    time.accumulator = new Accumulator();
73 >    data_[TIME] = time;
74 >    statsMap_["TIME"] = TIME;
75 >
76 >    StatsData total_energy;
77 >    total_energy.units =  "kcal/mol";
78 >    total_energy.title =  "Total Energy";
79 >    total_energy.dataType = "RealType";
80 >    total_energy.accumulator = new Accumulator();
81 >    data_[TOTAL_ENERGY] = total_energy;
82 >    statsMap_["TOTAL_ENERGY"] =  TOTAL_ENERGY;
83 >  
84 >    StatsData potential_energy;
85 >    potential_energy.units =  "kcal/mol";
86 >    potential_energy.title =  "Potential Energy";
87 >    potential_energy.dataType = "RealType";
88 >    potential_energy.accumulator = new Accumulator();
89 >    data_[POTENTIAL_ENERGY] = potential_energy;
90 >    statsMap_["POTENTIAL_ENERGY"] =  POTENTIAL_ENERGY;
91 >
92 >    StatsData kinetic_energy;
93 >    kinetic_energy.units =  "kcal/mol";
94 >    kinetic_energy.title =  "Kinetic Energy";
95 >    kinetic_energy.dataType = "RealType";
96 >    kinetic_energy.accumulator = new Accumulator();
97 >    data_[KINETIC_ENERGY] = kinetic_energy;
98 >    statsMap_["KINETIC_ENERGY"] =  KINETIC_ENERGY;
99 >
100 >    StatsData temperature;
101 >    temperature.units =  "K";
102 >    temperature.title =  "Temperature";
103 >    temperature.dataType = "RealType";
104 >    temperature.accumulator = new Accumulator();
105 >    data_[TEMPERATURE] = temperature;
106 >    statsMap_["TEMPERATURE"] =  TEMPERATURE;
107 >
108 >    StatsData pressure;
109 >    pressure.units =  "atm";
110 >    pressure.title =  "Pressure";
111 >    pressure.dataType = "RealType";
112 >    pressure.accumulator = new Accumulator();
113 >    data_[PRESSURE] = pressure;
114 >    statsMap_["PRESSURE"] =  PRESSURE;
115 >
116 >    StatsData volume;
117 >    volume.units =  "A^3";
118 >    volume.title =  "Volume";
119 >    volume.dataType = "RealType";
120 >    volume.accumulator = new Accumulator();
121 >    data_[VOLUME] = volume;
122 >    statsMap_["VOLUME"] =  VOLUME;
123 >
124 >    StatsData hullvolume;
125 >    hullvolume.units =  "A^3";
126 >    hullvolume.title =  "Hull Volume";
127 >    hullvolume.dataType = "RealType";
128 >    hullvolume.accumulator = new Accumulator();
129 >    data_[HULLVOLUME] = hullvolume;
130 >    statsMap_["HULLVOLUME"] =  HULLVOLUME;
131 >
132 >    StatsData gyrvolume;
133 >    gyrvolume.units =  "A^3";
134 >    gyrvolume.title =  "Gyrational Volume";
135 >    gyrvolume.dataType = "RealType";
136 >    gyrvolume.accumulator = new Accumulator();
137 >    data_[GYRVOLUME] = gyrvolume;
138 >    statsMap_["GYRVOLUME"] =  GYRVOLUME;
139 >
140 >    StatsData conserved_quantity;
141 >    conserved_quantity.units =  "kcal/mol";            
142 >    conserved_quantity.title =  "Conserved Quantity";            
143 >    conserved_quantity.dataType = "RealType";
144 >    conserved_quantity.accumulator = new Accumulator();
145 >    data_[CONSERVED_QUANTITY] = conserved_quantity;
146 >    statsMap_["CONSERVED_QUANTITY"] =  CONSERVED_QUANTITY;
147 >
148 >    StatsData translational_kinetic;
149 >    translational_kinetic.units =  "kcal/mol";
150 >    translational_kinetic.title =  "Translational Kinetic";
151 >    translational_kinetic.dataType = "RealType";
152 >    translational_kinetic.accumulator = new Accumulator();
153 >    data_[TRANSLATIONAL_KINETIC] = translational_kinetic;
154 >    statsMap_["TRANSLATIONAL_KINETIC"] =  TRANSLATIONAL_KINETIC;
155 >
156 >    StatsData rotational_kinetic;
157 >    rotational_kinetic.units =  "kcal/mol";
158 >    rotational_kinetic.title =  "Rotational Kinetic";
159 >    rotational_kinetic.dataType = "RealType";
160 >    rotational_kinetic.accumulator = new Accumulator();
161 >    data_[ROTATIONAL_KINETIC] = rotational_kinetic;
162 >    statsMap_["ROTATIONAL_KINETIC"] =  ROTATIONAL_KINETIC;
163 >
164 >    StatsData long_range_potential;
165 >    long_range_potential.units =  "kcal/mol";
166 >    long_range_potential.title =  "Long Range Potential";
167 >    long_range_potential.dataType = "RealType";
168 >    long_range_potential.accumulator = new Accumulator();
169 >    data_[LONG_RANGE_POTENTIAL] = long_range_potential;
170 >    statsMap_["LONG_RANGE_POTENTIAL"] =  LONG_RANGE_POTENTIAL;
171 >
172 >    StatsData vanderwaals_potential;
173 >    vanderwaals_potential.units =  "kcal/mol";
174 >    vanderwaals_potential.title =  "van der waals Potential";
175 >    vanderwaals_potential.dataType = "RealType";
176 >    vanderwaals_potential.accumulator = new Accumulator();
177 >    data_[VANDERWAALS_POTENTIAL] = vanderwaals_potential;
178 >    statsMap_["VANDERWAALS_POTENTIAL"] =  VANDERWAALS_POTENTIAL;
179 >
180 >    StatsData electrostatic_potential;
181 >    electrostatic_potential.units =  "kcal/mol";
182 >    electrostatic_potential.title =  "Electrostatic Potential";    
183 >    electrostatic_potential.dataType = "RealType";
184 >    electrostatic_potential.accumulator = new Accumulator();
185 >    data_[ELECTROSTATIC_POTENTIAL] = electrostatic_potential;
186 >    statsMap_["ELECTROSTATIC_POTENTIAL"] =  ELECTROSTATIC_POTENTIAL;
187 >
188 >    StatsData metallic_potential;
189 >    metallic_potential.units =  "kcal/mol";
190 >    metallic_potential.title =  "Metallic Potential";    
191 >    metallic_potential.dataType = "RealType";
192 >    metallic_potential.accumulator = new Accumulator();
193 >    data_[METALLIC_POTENTIAL] = metallic_potential;
194 >    statsMap_["METALLIC_POTENTIAL"] =  METALLIC_POTENTIAL;
195 >
196 >    StatsData hydrogenbonding_potential;
197 >    hydrogenbonding_potential.units =  "kcal/mol";
198 >    hydrogenbonding_potential.title =  "Hydrogen Bonding Potential";    
199 >    hydrogenbonding_potential.dataType = "RealType";
200 >    hydrogenbonding_potential.accumulator = new Accumulator();
201 >    data_[HYDROGENBONDING_POTENTIAL] = hydrogenbonding_potential;
202 >    statsMap_["HYDROGENBONDING_POTENTIAL"] =  HYDROGENBONDING_POTENTIAL;
203 >
204 >    StatsData reciprocal_potential;
205 >    reciprocal_potential.units =  "kcal/mol";
206 >    reciprocal_potential.title =  "Reciprocal Space Potential";    
207 >    reciprocal_potential.dataType = "RealType";
208 >    reciprocal_potential.accumulator = new Accumulator();
209 >    data_[RECIPROCAL_POTENTIAL] = reciprocal_potential;
210 >    statsMap_["RECIPROCAL_POTENTIAL"] =  RECIPROCAL_POTENTIAL;
211 >
212 >    StatsData short_range_potential;
213 >    short_range_potential.units =  "kcal/mol";
214 >    short_range_potential.title =  "Short Range Potential";
215 >    short_range_potential.dataType = "RealType";
216 >    short_range_potential.accumulator = new Accumulator();
217 >    data_[SHORT_RANGE_POTENTIAL] = short_range_potential;
218 >    statsMap_["SHORT_RANGE_POTENTIAL"] =  SHORT_RANGE_POTENTIAL;
219 >
220 >    StatsData bond_potential;
221 >    bond_potential.units =  "kcal/mol";
222 >    bond_potential.title =  "Bond Potential";
223 >    bond_potential.dataType = "RealType";
224 >    bond_potential.accumulator = new Accumulator();
225 >    data_[BOND_POTENTIAL] = bond_potential;
226 >    statsMap_["BOND_POTENTIAL"] =  BOND_POTENTIAL;
227 >
228 >    StatsData bend_potential;
229 >    bend_potential.units =  "kcal/mol";
230 >    bend_potential.title =  "Bend Potential";
231 >    bend_potential.dataType = "RealType";
232 >    bend_potential.accumulator = new Accumulator();
233 >    data_[BEND_POTENTIAL] = bend_potential;
234 >    statsMap_["BEND_POTENTIAL"] =  BEND_POTENTIAL;
235      
236 +    StatsData dihedral_potential;
237 +    dihedral_potential.units =  "kcal/mol";
238 +    dihedral_potential.title =  "Dihedral Potential";
239 +    dihedral_potential.dataType = "RealType";
240 +    dihedral_potential.accumulator = new Accumulator();
241 +    data_[DIHEDRAL_POTENTIAL] = dihedral_potential;
242 +    statsMap_["DIHEDRAL_POTENTIAL"] =  DIHEDRAL_POTENTIAL;
243  
244 <    Stats::units_[TIME] = "fs";
245 <    Stats::units_[TOTAL_ENERGY] = "kcal/mol";
246 <    Stats::units_[POTENTIAL_ENERGY] = "kcal/mol";
247 <    Stats::units_[KINETIC_ENERGY] = "kcal/mol";
248 <    Stats::units_[TEMPERATURE] = "K";
249 <    Stats::units_[PRESSURE] = "atm";
250 <    Stats::units_[VOLUME] = "A^3";
100 <    Stats::units_[CONSERVED_QUANTITY] = "kcal/mol";            
101 <    Stats::units_[TRANSLATIONAL_KINETIC] = "kcal/mol";
102 <    Stats::units_[ROTATIONAL_KINETIC] = "kcal/mol";
103 <    Stats::units_[LONG_RANGE_POTENTIAL] = "kcal/mol";
104 <    Stats::units_[SHORT_RANGE_POTENTIAL] = "kcal/mol";
105 <    Stats::units_[VANDERWAALS_POTENTIAL] = "kcal/mol";
106 <    Stats::units_[BOND_POTENTIAL] = "kcal/mol";
107 <    Stats::units_[BEND_POTENTIAL] = "kcal/mol";
108 <    Stats::units_[DIHEDRAL_POTENTIAL] = "kcal/mol";
109 <    Stats::units_[IMPROPER_POTENTIAL] = "kcal/mol";
110 <    Stats::units_[VRAW] = "kcal/mol";
111 <    Stats::units_[VHARM] = "kcal/mol";
112 <    Stats::units_[PRESSURE_TENSOR_X] = "amu*fs^-2*Ang^-1";
113 <    Stats::units_[PRESSURE_TENSOR_Y] = "amu*fs^-2*Ang^-1";
114 <    Stats::units_[PRESSURE_TENSOR_Z] = "amu*fs^-2*Ang^-1";
244 >    StatsData inversion_potential;
245 >    inversion_potential.units =  "kcal/mol";
246 >    inversion_potential.title =  "Inversion Potential";
247 >    inversion_potential.dataType = "RealType";
248 >    inversion_potential.accumulator = new Accumulator();
249 >    data_[INVERSION_POTENTIAL] = inversion_potential;
250 >    statsMap_["INVERSION_POTENTIAL"] =  INVERSION_POTENTIAL;
251  
252 +    StatsData vraw;
253 +    vraw.units =  "kcal/mol";
254 +    vraw.title =  "Raw Potential";
255 +    vraw.dataType = "RealType";
256 +    vraw.accumulator = new Accumulator();
257 +    data_[RAW_POTENTIAL] = vraw;
258 +    statsMap_["RAW_POTENTIAL"] =  RAW_POTENTIAL;
259 +
260 +    StatsData vrestraint;
261 +    vrestraint.units =  "kcal/mol";
262 +    vrestraint.title =  "Restraint Potential";
263 +    vrestraint.dataType = "RealType";
264 +    vrestraint.accumulator = new Accumulator();
265 +    data_[RESTRAINT_POTENTIAL] = vrestraint;
266 +    statsMap_["RESTRAINT_POTENTIAL"] =  RESTRAINT_POTENTIAL;
267 +
268 +    StatsData pressure_tensor;
269 +    pressure_tensor.units =  "amu*fs^-2*Ang^-1";
270 +    pressure_tensor.title =  "Ptensor";
271 +    pressure_tensor.dataType = "Mat3x3d";
272 +    pressure_tensor.accumulator = new MatrixAccumulator();
273 +    data_[PRESSURE_TENSOR] = pressure_tensor;
274 +    statsMap_["PRESSURE_TENSOR"] =  PRESSURE_TENSOR;
275 +
276 +    StatsData system_dipole;
277 +    system_dipole.units =  "C*m";
278 +    system_dipole.title =  "System Dipole";
279 +    system_dipole.dataType = "Vector3d";
280 +    system_dipole.accumulator = new VectorAccumulator();
281 +    data_[SYSTEM_DIPOLE] = system_dipole;
282 +    statsMap_["SYSTEM_DIPOLE"] =  SYSTEM_DIPOLE;
283 +
284 +    StatsData system_quadrupole;
285 +    system_quadrupole.units =  "C*m*m";
286 +    system_quadrupole.title =  "System Quadrupole";
287 +    system_quadrupole.dataType = "Mat3x3d";
288 +    system_quadrupole.accumulator = new MatrixAccumulator();
289 +    data_[SYSTEM_QUADRUPOLE] = system_quadrupole;
290 +    statsMap_["SYSTEM_QUADRUPOLE"] =  SYSTEM_QUADRUPOLE;
291 +
292 +    StatsData tagged_pair_distance;
293 +    tagged_pair_distance.units =  "Ang";
294 +    tagged_pair_distance.title =  "Tagged_Pair_Distance";
295 +    tagged_pair_distance.dataType = "RealType";
296 +    tagged_pair_distance.accumulator = new Accumulator();
297 +    data_[TAGGED_PAIR_DISTANCE] = tagged_pair_distance;
298 +    statsMap_["TAGGED_PAIR_DISTANCE"] =  TAGGED_PAIR_DISTANCE;
299 +
300 +    StatsData shadowh;
301 +    shadowh.units =  "kcal/mol";
302 +    shadowh.title =  "Shadow Hamiltonian";
303 +    shadowh.dataType = "RealType";
304 +    shadowh.accumulator = new Accumulator();
305 +    data_[SHADOWH] = shadowh;
306 +    statsMap_["SHADOWH"] =  SHADOWH;
307 +
308 +    StatsData helfandmoment;
309 +    helfandmoment.units =  "Ang*kcal/mol";
310 +    helfandmoment.title =  "Thermal Helfand Moment";
311 +    helfandmoment.dataType = "Vector3d";
312 +    helfandmoment.accumulator = new VectorAccumulator();
313 +    data_[HELFANDMOMENT] = helfandmoment;
314 +    statsMap_["HELFANDMOMENT"] = HELFANDMOMENT;
315 +
316 +    StatsData heatflux;
317 +    heatflux.units = "amu/fs^3";
318 +    heatflux.title =  "Heat Flux";  
319 +    heatflux.dataType = "Vector3d";
320 +    heatflux.accumulator = new VectorAccumulator();
321 +    data_[HEATFLUX] = heatflux;
322 +    statsMap_["HEATFLUX"] = HEATFLUX;
323 +
324 +    StatsData electronic_temperature;
325 +    electronic_temperature.units = "K";
326 +    electronic_temperature.title =  "Electronic Temperature";  
327 +    electronic_temperature.dataType = "RealType";
328 +    electronic_temperature.accumulator = new Accumulator();
329 +    data_[ELECTRONIC_TEMPERATURE] = electronic_temperature;
330 +    statsMap_["ELECTRONIC_TEMPERATURE"] = ELECTRONIC_TEMPERATURE;
331 +
332 +    StatsData com;
333 +    com.units =  "A";
334 +    com.title =  "Center of Mass";
335 +    com.dataType = "Vector3d";
336 +    com.accumulator = new VectorAccumulator();
337 +    data_[COM] = com;
338 +    statsMap_["COM"] =  COM;
339 +
340 +    StatsData comVel;
341 +    comVel.units =  "A/fs";
342 +    comVel.title =  "Center of Mass Velocity";
343 +    comVel.dataType = "Vector3d";
344 +    comVel.accumulator = new VectorAccumulator();
345 +    data_[COM_VELOCITY] = comVel;
346 +    statsMap_["COM_VELOCITY"] =  COM_VELOCITY;
347 +
348 +    StatsData angMom;
349 +    angMom.units =  "amu A^2/fs";
350 +    angMom.title =  "Angular Momentum";
351 +    angMom.dataType = "Vector3d";
352 +    angMom.accumulator = new VectorAccumulator();
353 +    data_[ANGULAR_MOMENTUM] = angMom;
354 +    statsMap_["ANGULAR_MOMENTUM"] =  ANGULAR_MOMENTUM;
355 +
356 +    // Now, set some defaults in the mask:
357 +
358 +    Globals* simParams = info_->getSimParams();
359 +    std::string statFileFormatString = simParams->getStatFileFormat();
360 +    parseStatFileFormat(statFileFormatString);
361 +
362 +    // if we're doing a thermodynamic integration, we'll want the raw
363 +    // potential as well as the full potential:
364 +    
365 +    if (simParams->getUseThermodynamicIntegration())
366 +      statsMask_.set(RAW_POTENTIAL);
367 +    
368 +    // if we've got restraints turned on, we'll also want a report of the
369 +    // total harmonic restraints
370 +    if (simParams->getUseRestraints()){
371 +      statsMask_.set(RESTRAINT_POTENTIAL);
372 +    }
373 +    
374 +    if (simParams->havePrintPressureTensor() &&
375 +        simParams->getPrintPressureTensor()){
376 +      statsMask_.set(PRESSURE_TENSOR);
377 +    }
378 +
379 +    // Why do we have both of these?
380 +    if (simParams->getAccumulateBoxDipole()) {
381 +      statsMask_.set(SYSTEM_DIPOLE);
382 +    }
383 +    if (info_->getCalcBoxDipole()){
384 +      statsMask_.set(SYSTEM_DIPOLE);
385 +    }
386 +
387 +    // Why do we have both of these?
388 +    if (simParams->getAccumulateBoxQuadrupole()) {
389 +      statsMask_.set(SYSTEM_QUADRUPOLE);
390 +    }
391 +    if (info_->getCalcBoxQuadrupole()){
392 +      statsMask_.set(SYSTEM_QUADRUPOLE);
393 +    }
394 +
395 +    if (simParams->havePrintHeatFlux()) {
396 +      if (simParams->getPrintHeatFlux()){
397 +        statsMask_.set(HEATFLUX);
398 +      }
399 +    }    
400 +    
401 +    
402 +    if (simParams->haveTaggedAtomPair() && simParams->havePrintTaggedPairDistance()) {
403 +      if (simParams->getPrintTaggedPairDistance()) {
404 +        statsMask_.set(TAGGED_PAIR_DISTANCE);
405 +      }
406 +    }
407 +    
408    }
409  
410 +  void Stats::parseStatFileFormat(const std::string& format) {
411 +    StringTokenizer tokenizer(format, " ,;|\t\n\r");
412 +
413 +    while(tokenizer.hasMoreTokens()) {
414 +      std::string token(tokenizer.nextToken());
415 +      toUpper(token);
416 +      StatsMapType::iterator i = statsMap_.find(token);
417 +      if (i != statsMap_.end()) {
418 +        statsMask_.set(i->second);
419 +      } else {
420 +        sprintf( painCave.errMsg,
421 +                 "Stats::parseStatFileFormat: %s is not a recognized\n"
422 +                 "\tstatFileFormat keyword.\n", token.c_str() );
423 +        painCave.isFatal = 0;
424 +        painCave.severity = OPENMD_ERROR;
425 +        simError();            
426 +      }
427 +    }  
428 +  }
429 +
430 +  Stats::~Stats() {
431 +    data_.clear();
432 +    statsMap_.clear();
433 +  }
434 +
435 +  std::string Stats::getTitle(int index) {
436 +    assert(index >=0 && index < ENDINDEX);
437 +    return data_[index].title;
438 +  }
439 +
440 +  std::string Stats::getUnits(int index) {
441 +    assert(index >=0 && index < ENDINDEX);
442 +    return data_[index].units;
443 +  }
444 +
445 +  std::string Stats::getDataType(int index) {
446 +    assert(index >=0 && index < ENDINDEX);
447 +    return data_[index].dataType;
448 +  }
449 +
450 +  void Stats::collectStats(){
451 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
452 +    Thermo thermo(info_);
453 +  
454 +    for (unsigned int i = 0; i < statsMask_.size(); ++i) {
455 +      if (statsMask_[i]) {
456 +        switch (i) {
457 +        case TIME:
458 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getTime());
459 +          break;
460 +        case KINETIC_ENERGY:
461 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getKinetic());
462 +          break;
463 +        case POTENTIAL_ENERGY:
464 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getPotential());
465 +          break;
466 +        case TOTAL_ENERGY:
467 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getTotalEnergy());
468 +          break;
469 +        case TEMPERATURE:
470 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getTemperature());
471 +          break;
472 +        case PRESSURE:
473 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getPressure());
474 +          break;
475 +        case VOLUME:
476 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getVolume());
477 +          break;
478 +        case CONSERVED_QUANTITY:
479 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getConservedQuantity());
480 +          break;
481 +        case PRESSURE_TENSOR:
482 +          dynamic_cast<MatrixAccumulator *>(data_[i].accumulator)->add(thermo.getPressureTensor());
483 +          break;
484 +        case SYSTEM_DIPOLE:
485 +          dynamic_cast<VectorAccumulator *>(data_[i].accumulator)->add(thermo.getSystemDipole());
486 +          break;
487 +        case SYSTEM_QUADRUPOLE:
488 +          dynamic_cast<MatrixAccumulator *>(data_[i].accumulator)->add(thermo.getSystemQuadrupole());
489 +          break;
490 +        case HEATFLUX:
491 +          dynamic_cast<VectorAccumulator *>(data_[i].accumulator)->add(thermo.getHeatFlux());
492 +          break;
493 +        case HULLVOLUME:
494 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getHullVolume());
495 +          break;
496 +        case GYRVOLUME:
497 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getGyrationalVolume());
498 +          break;
499 +        case TRANSLATIONAL_KINETIC:
500 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getTranslationalKinetic());
501 +          break;
502 +        case ROTATIONAL_KINETIC:
503 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getRotationalKinetic());
504 +          break;
505 +        case LONG_RANGE_POTENTIAL:
506 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getLongRangePotential());
507 +          break;
508 +        case VANDERWAALS_POTENTIAL:
509 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getLongRangePotentials()[VANDERWAALS_FAMILY]);
510 +          break;
511 +        case ELECTROSTATIC_POTENTIAL:
512 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getLongRangePotentials()[ELECTROSTATIC_FAMILY]);
513 +          break;
514 +        case METALLIC_POTENTIAL:
515 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getLongRangePotentials()[METALLIC_FAMILY]);
516 +          break;
517 +        case HYDROGENBONDING_POTENTIAL:
518 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getLongRangePotentials()[HYDROGENBONDING_FAMILY]);
519 +          break;
520 +        case RECIPROCAL_POTENTIAL:
521 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getReciprocalPotential());
522 +          break;
523 +        case SHORT_RANGE_POTENTIAL:
524 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getShortRangePotential());
525 +          break;
526 +        case BOND_POTENTIAL:
527 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getBondPotential());
528 +          break;
529 +        case BEND_POTENTIAL:
530 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getBendPotential());
531 +          break;
532 +        case DIHEDRAL_POTENTIAL:
533 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getTorsionPotential());
534 +          break;
535 +        case INVERSION_POTENTIAL:
536 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getInversionPotential());
537 +          break;
538 +        case RAW_POTENTIAL:
539 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getRawPotential());
540 +          break;
541 +        case RESTRAINT_POTENTIAL:
542 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(snap->getRestraintPotential());
543 +          break;
544 +        case TAGGED_PAIR_DISTANCE:
545 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getTaggedAtomPairDistance());
546 +          break;
547 +        case ELECTRONIC_TEMPERATURE:
548 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getElectronicTemperature());
549 +          break;
550 +        case COM:
551 +          dynamic_cast<VectorAccumulator *>(data_[i].accumulator)->add(thermo.getCom());
552 +          break;
553 +        case COM_VELOCITY:
554 +          dynamic_cast<VectorAccumulator *>(data_[i].accumulator)->add(thermo.getComVel());
555 +          break;
556 +        case ANGULAR_MOMENTUM:
557 +          dynamic_cast<VectorAccumulator *>(data_[i].accumulator)->add(thermo.getAngularMomentum());
558 +          break;
559 +          /*
560 +        case SHADOWH:
561 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getShadowHamiltionian());
562 +          break;
563 +        case HELFANDMOMENT:
564 +          dynamic_cast<Accumulator *>(data_[i].accumulator)->add(thermo.getHelfandMoment());
565 +          break;
566 +          */
567 +        }
568 +      }
569 +    }
570 +  }
571 +
572 +  int Stats::getIntData(int index) {
573 +    assert(index >=0 && index < ENDINDEX);
574 +    RealType value;
575 +    dynamic_cast<Accumulator *>(data_[index].accumulator)->getLastValue(value);
576 +    return (int) value;
577 +  }
578 +  RealType Stats::getRealData(int index) {
579 +    assert(index >=0 && index < ENDINDEX);
580 +    RealType value(0.0);
581 +    dynamic_cast<Accumulator *>(data_[index].accumulator)->getLastValue(value);
582 +    return value;
583 +  }
584 +  Vector3d Stats::getVectorData(int index) {
585 +    assert(index >=0 && index < ENDINDEX);
586 +    Vector3d value;
587 +    dynamic_cast<VectorAccumulator*>(data_[index].accumulator)->getLastValue(value);
588 +    return value;
589 +  }
590 +  Mat3x3d Stats::getMatrixData(int index) {
591 +    assert(index >=0 && index < ENDINDEX);
592 +    Mat3x3d value;
593 +    dynamic_cast<MatrixAccumulator*>(data_[index].accumulator)->getLastValue(value);
594 +    return value;
595 +  }
596 +
597 +  Stats::StatsBitSet Stats::getStatsMask() {
598 +    return statsMask_;
599 +  }
600 +  Stats::StatsMapType Stats::getStatsMap() {
601 +    return statsMap_;
602 +  }
603 +  void Stats::setStatsMask(Stats::StatsBitSet mask) {
604 +    statsMask_ = mask;
605 +  }
606 +
607   }

Comparing trunk/src/brains/Stats.cpp (property svn:keywords):
Revision 541 by tim, Sun May 22 21:05:15 2005 UTC vs.
Revision 2022 by gezelter, Fri Sep 26 22:22:28 2014 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines