ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/StatWriter.cpp
Revision: 1187
Committed: Sat May 22 18:16:18 2004 UTC (20 years, 3 months ago) by chrisfen
File size: 2638 byte(s)
Log Message:
Fixed Thermodynamic integration code.

File Contents

# User Rev Content
1 tim 1078 #define _LARGEFILE_SOURCE64
2 mmeineke 723 #define _FILE_OFFSET_BITS 64
3    
4 gezelter 829 #include <string.h>
5 mmeineke 377 #include <iostream>
6     #include <fstream>
7    
8     #include "ReadWrite.hpp"
9     #include "simError.h"
10    
11    
12     StatWriter::StatWriter( SimInfo* the_entry_plug ){
13    
14     entry_plug = the_entry_plug;
15    
16     #ifdef IS_MPI
17     if(worldRank == 0 ){
18     #endif // is_mpi
19    
20     strcpy( outName, entry_plug->statusName );
21 chrisfen 1180 strcpy( rawName, entry_plug->rawPotName );
22    
23 gezelter 484 //std::cerr << "Opening " << outName << " for stat\n";
24 mmeineke 377
25     outFile.open(outName, ios::out | ios::trunc );
26    
27     if( !outFile ){
28    
29     sprintf( painCave.errMsg,
30     "Could not open \"%s\" for stat output.\n",
31     outName);
32     painCave.isFatal = 1;
33     simError();
34     }
35 chrisfen 1180
36 mmeineke 377 //outFile.setf( ios::scientific );
37 mmeineke 799 outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\tpressure\tvolume\tconserved quantity\n";
38 mmeineke 377
39 chrisfen 1187 if (entry_plug->useThermInt) {
40     rawFile.open(rawName, ios::out | ios::trunc );
41    
42     if( !rawFile ){
43    
44     sprintf( painCave.errMsg,
45     "Could not open \"%s\" for stat output.\n",
46     rawName);
47     painCave.isFatal = 1;
48     simError();
49     }
50    
51     rawFile << "#time(fs)\tRaw Pot\t Raw Harm\n";
52     }
53 mmeineke 377
54     #ifdef IS_MPI
55     }
56    
57     sprintf( checkPointMsg,
58     "Sucessfully opened output file for stating.\n");
59     MPIcheckPoint();
60     #endif // is_mpi
61    
62     tStats = new Thermo( entry_plug );
63     }
64    
65     StatWriter::~StatWriter( ){
66    
67     #ifdef IS_MPI
68     if(worldRank == 0 ){
69     #endif // is_mpi
70    
71     outFile.close();
72 chrisfen 1180 rawFile.close();
73 mmeineke 377 delete tStats;
74    
75     #ifdef IS_MPI
76     }
77     #endif // is_mpi
78     }
79    
80     void StatWriter::writeStat( double currentTime ){
81    
82 mmeineke 799 double totE, potE, kinE, temp, press, vol;
83 tim 763 double conservedQuantity;
84 mmeineke 377
85     totE = tStats->getTotalE();
86     potE = tStats->getPotential();
87     kinE = tStats->getKinetic();
88     temp = tStats->getTemperature();
89 gezelter 477 press = tStats->getPressure();
90 gezelter 484 vol = tStats->getVolume();
91 tim 763 conservedQuantity = entry_plug->the_integrator->getConservedQuantity();
92 mmeineke 377 #ifdef IS_MPI
93     if(worldRank == 0 ){
94     #endif // is_mpi
95    
96     outFile.precision(8);
97     outFile
98     << currentTime << "\t"
99     << totE << "\t"
100     << potE << "\t"
101     << kinE << "\t"
102 gezelter 468 << temp << "\t"
103 gezelter 484 << press << "\t"
104     << vol << "\t"
105 tim 763 << conservedQuantity << "\n";
106 gezelter 484
107 mmeineke 377 outFile.flush();
108    
109     #ifdef IS_MPI
110     }
111     #endif // is_mpi
112     }
113 chrisfen 1180
114     void StatWriter::writeRaw( double currentTime ){
115    
116     double rawPot, rawHarm;
117    
118     rawPot = entry_plug->vRaw;
119     rawHarm = entry_plug->vHarm;
120    
121     #ifdef IS_MPI
122     if(worldRank == 0 ){
123     #endif // is_mpi
124    
125     rawFile.precision(8);
126     rawFile
127     << currentTime << "\t"
128     << rawPot << "\t"
129     << rawHarm << "\n";
130    
131     rawFile.flush();
132    
133     #ifdef IS_MPI
134     }
135     #endif // is_mpi
136     }