ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/StatWriter.cpp
Revision: 1180
Committed: Thu May 20 20:24:07 2004 UTC (20 years, 3 months ago) by chrisfen
File size: 2615 byte(s)
Log Message:
Several additions... Restraints.cpp and .hpp were included for restraining particles in thermodynamic integration.  By including these, changes were made in Integrator, SimInfo, ForceFeilds, SimSetup, StatWriter, and possibly some other files.  Two bass keywords were also added for performing thermodynamic integration: a lambda value one and a k power one.

File Contents

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