ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/StatWriter.cpp
Revision: 484
Committed: Wed Apr 9 13:59:35 2003 UTC (21 years, 3 months ago) by gezelter
File size: 1761 byte(s)
Log Message:
Added volume and enthalpy to status file

File Contents

# User Rev Content
1 mmeineke 377 #include <cstring>
2     #include <iostream>
3     #include <fstream>
4    
5     #include "ReadWrite.hpp"
6     #include "simError.h"
7    
8    
9     StatWriter::StatWriter( SimInfo* the_entry_plug ){
10    
11     entry_plug = the_entry_plug;
12    
13     #ifdef IS_MPI
14     if(worldRank == 0 ){
15     #endif // is_mpi
16    
17     strcpy( outName, entry_plug->statusName );
18    
19 gezelter 484 //std::cerr << "Opening " << outName << " for stat\n";
20 mmeineke 377
21     outFile.open(outName, ios::out | ios::trunc );
22    
23     if( !outFile ){
24    
25     sprintf( painCave.errMsg,
26     "Could not open \"%s\" for stat output.\n",
27     outName);
28     painCave.isFatal = 1;
29     simError();
30     }
31    
32     //outFile.setf( ios::scientific );
33 gezelter 484 outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\tpressure\tvolume\tenthalpy\n";
34 mmeineke 377
35    
36    
37     #ifdef IS_MPI
38     }
39    
40     sprintf( checkPointMsg,
41     "Sucessfully opened output file for stating.\n");
42     MPIcheckPoint();
43     #endif // is_mpi
44    
45     tStats = new Thermo( entry_plug );
46     }
47    
48     StatWriter::~StatWriter( ){
49    
50     #ifdef IS_MPI
51     if(worldRank == 0 ){
52     #endif // is_mpi
53    
54     outFile.close();
55     delete tStats;
56    
57     #ifdef IS_MPI
58     }
59     #endif // is_mpi
60     }
61    
62     void StatWriter::writeStat( double currentTime ){
63    
64 gezelter 484 double totE, potE, kinE, temp, press, vol, enthalpy;
65 mmeineke 377
66     totE = tStats->getTotalE();
67     potE = tStats->getPotential();
68     kinE = tStats->getKinetic();
69     temp = tStats->getTemperature();
70 gezelter 477 press = tStats->getPressure();
71 gezelter 484 vol = tStats->getVolume();
72     enthalpy = tStats->getEnthalpy();
73 mmeineke 377
74     #ifdef IS_MPI
75     if(worldRank == 0 ){
76     #endif // is_mpi
77    
78     outFile.precision(8);
79     outFile
80     << currentTime << "\t"
81     << totE << "\t"
82     << potE << "\t"
83     << kinE << "\t"
84 gezelter 468 << temp << "\t"
85 gezelter 484 << press << "\t"
86     << vol << "\t"
87     << enthalpy << "\n";
88    
89 mmeineke 377 outFile.flush();
90    
91     #ifdef IS_MPI
92     }
93     #endif // is_mpi
94     }