1 |
mmeineke |
10 |
#include <cstring> |
2 |
|
|
#include <iostream> |
3 |
|
|
#include <fstream> |
4 |
|
|
|
5 |
|
|
#include "ReadWrite.hpp" |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
StatWriter::StatWriter( SimInfo* the_entry_plug ){ |
9 |
|
|
|
10 |
|
|
entry_plug = the_entry_plug; |
11 |
|
|
|
12 |
|
|
strcpy( outName, entry_plug->statusName ); |
13 |
|
|
outFile.open(outName, ios::out | ios::trunc ); |
14 |
|
|
|
15 |
|
|
if( !outFile ){ |
16 |
|
|
|
17 |
|
|
cerr << "Could not open \"" << outName << "\" for stat output.\n"; |
18 |
|
|
exit(8); |
19 |
|
|
} |
20 |
|
|
|
21 |
|
|
//outFile.setf( ios::scientific ); |
22 |
|
|
outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n"; |
23 |
|
|
|
24 |
|
|
tStats = new Thermo( entry_plug ); |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
StatWriter::~StatWriter( ){ |
28 |
|
|
|
29 |
|
|
outFile.close(); |
30 |
|
|
delete tStats; |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
void StatWriter::writeStat( double currentTime ){ |
34 |
|
|
|
35 |
|
|
outFile.precision(8); |
36 |
|
|
outFile |
37 |
|
|
<< currentTime << "\t" |
38 |
|
|
<< tStats->getTotalE() << "\t" |
39 |
|
|
<< tStats->getPotential() << "\t" |
40 |
|
|
<< tStats->getKinetic() << "\t" |
41 |
|
|
<< tStats->getTemperature() << "\n"; |
42 |
|
|
outFile.flush(); |
43 |
|
|
} |