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

Comparing trunk/src/brains/Stats.cpp (property svn:keywords):
Revision 555 by chuckv, Mon May 30 14:01:52 2005 UTC vs.
Revision 2046 by gezelter, Tue Dec 2 22:11:04 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines