ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/StatWriter.cpp
Revision: 1213
Committed: Tue Jun 1 18:07:34 2004 UTC (20 years, 3 months ago) by chrisfen
File size: 2988 byte(s)
Log Message:
Fixed bug in useLiquidThermInt routine in ForceFields.cpp

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 1212 if (entry_plug->useSolidThermInt && !entry_plug->useLiquidThermInt) {
40 chrisfen 1187 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 chrisfen 1212 if (entry_plug->useLiquidThermInt) {
55     rawFile.open(rawName, ios::out | ios::trunc );
56    
57     if( !rawFile ){
58    
59     sprintf( painCave.errMsg,
60     "Could not open \"%s\" for stat output.\n",
61     rawName);
62     painCave.isFatal = 1;
63     simError();
64     }
65    
66     rawFile << "#time(fs)\tRaw Pot\n";
67     }
68    
69 mmeineke 377 #ifdef IS_MPI
70     }
71    
72     sprintf( checkPointMsg,
73     "Sucessfully opened output file for stating.\n");
74     MPIcheckPoint();
75     #endif // is_mpi
76    
77     tStats = new Thermo( entry_plug );
78     }
79    
80     StatWriter::~StatWriter( ){
81    
82     #ifdef IS_MPI
83     if(worldRank == 0 ){
84     #endif // is_mpi
85    
86     outFile.close();
87 chrisfen 1180 rawFile.close();
88 mmeineke 377 delete tStats;
89    
90     #ifdef IS_MPI
91     }
92     #endif // is_mpi
93     }
94    
95     void StatWriter::writeStat( double currentTime ){
96    
97 mmeineke 799 double totE, potE, kinE, temp, press, vol;
98 tim 763 double conservedQuantity;
99 mmeineke 377
100     totE = tStats->getTotalE();
101     potE = tStats->getPotential();
102     kinE = tStats->getKinetic();
103     temp = tStats->getTemperature();
104 gezelter 477 press = tStats->getPressure();
105 gezelter 484 vol = tStats->getVolume();
106 tim 763 conservedQuantity = entry_plug->the_integrator->getConservedQuantity();
107 mmeineke 377 #ifdef IS_MPI
108     if(worldRank == 0 ){
109     #endif // is_mpi
110    
111     outFile.precision(8);
112     outFile
113     << currentTime << "\t"
114     << totE << "\t"
115     << potE << "\t"
116     << kinE << "\t"
117 gezelter 468 << temp << "\t"
118 gezelter 484 << press << "\t"
119     << vol << "\t"
120 tim 763 << conservedQuantity << "\n";
121 gezelter 484
122 mmeineke 377 outFile.flush();
123    
124     #ifdef IS_MPI
125     }
126     #endif // is_mpi
127     }
128 chrisfen 1180
129     void StatWriter::writeRaw( double currentTime ){
130    
131     double rawPot, rawHarm;
132    
133     rawPot = entry_plug->vRaw;
134     rawHarm = entry_plug->vHarm;
135    
136     #ifdef IS_MPI
137     if(worldRank == 0 ){
138     #endif // is_mpi
139    
140     rawFile.precision(8);
141     rawFile
142     << currentTime << "\t"
143     << rawPot << "\t"
144     << rawHarm << "\n";
145    
146     rawFile.flush();
147    
148     #ifdef IS_MPI
149     }
150     #endif // is_mpi
151     }