--- trunk/OOPSE/libmdtools/StatWriter.cpp 2003/08/26 20:12:51 723 +++ trunk/OOPSE/libmdtools/StatWriter.cpp 2004/06/01 17:15:43 1212 @@ -1,6 +1,7 @@ +#define _LARGEFILE_SOURCE64 #define _FILE_OFFSET_BITS 64 -#include +#include #include #include @@ -17,7 +18,8 @@ StatWriter::StatWriter( SimInfo* the_entry_plug ){ #endif // is_mpi strcpy( outName, entry_plug->statusName ); - + strcpy( rawName, entry_plug->rawPotName ); + //std::cerr << "Opening " << outName << " for stat\n"; outFile.open(outName, ios::out | ios::trunc ); @@ -30,12 +32,53 @@ StatWriter::StatWriter( SimInfo* the_entry_plug ){ painCave.isFatal = 1; simError(); } - + //outFile.setf( ios::scientific ); - outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\tpressure\tvolume\tenthalpy\n"; + outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\tpressure\tvolume\tconserved quantity\n"; - + if (entry_plug->useSolidThermInt && !entry_plug->useLiquidThermInt) { + rawFile.open(rawName, ios::out | ios::trunc ); + + if( !rawFile ){ + + sprintf( painCave.errMsg, + "Could not open \"%s\" for stat output.\n", + rawName); + painCave.isFatal = 1; + simError(); + } + + rawFile << "#time(fs)\tRaw Pot\t Raw Harm\n"; + } + if (entry_plug->useLiquidThermInt) { + if (entry_plug->useSolidThermInt) { + sprintf( painCave.errMsg, + "It appears that you have both solid and liquid thermodynamic\n" + "integration activated in your .bass file. To avoid confusion,\n" + "specify only one technique in your .bass file. Liquid-state\n" + "thermodynamic integration will be assumed for the current\n" + "simulation. If this is not what you desire, set useSolidThermInt\n" + "to 'true' and useLiquidThermInt to 'false' in your .bass file.", + rawName); + painCave.isFatal = 0; + simError(); + } + + rawFile.open(rawName, ios::out | ios::trunc ); + + if( !rawFile ){ + + sprintf( painCave.errMsg, + "Could not open \"%s\" for stat output.\n", + rawName); + painCave.isFatal = 1; + simError(); + } + + rawFile << "#time(fs)\tRaw Pot\n"; + } + #ifdef IS_MPI } @@ -54,6 +97,7 @@ StatWriter::~StatWriter( ){ #endif // is_mpi outFile.close(); + rawFile.close(); delete tStats; #ifdef IS_MPI @@ -63,7 +107,8 @@ void StatWriter::writeStat( double currentTime ){ void StatWriter::writeStat( double currentTime ){ - double totE, potE, kinE, temp, press, vol, enthalpy; + double totE, potE, kinE, temp, press, vol; + double conservedQuantity; totE = tStats->getTotalE(); potE = tStats->getPotential(); @@ -71,8 +116,7 @@ void StatWriter::writeStat( double currentTime ){ temp = tStats->getTemperature(); press = tStats->getPressure(); vol = tStats->getVolume(); - enthalpy = tStats->getEnthalpy(); - + conservedQuantity = entry_plug->the_integrator->getConservedQuantity(); #ifdef IS_MPI if(worldRank == 0 ){ #endif // is_mpi @@ -86,7 +130,7 @@ void StatWriter::writeStat( double currentTime ){ << temp << "\t" << press << "\t" << vol << "\t" - << enthalpy << "\n"; + << conservedQuantity << "\n"; outFile.flush(); @@ -94,3 +138,27 @@ void StatWriter::writeStat( double currentTime ){ } #endif // is_mpi } + +void StatWriter::writeRaw( double currentTime ){ + + double rawPot, rawHarm; + + rawPot = entry_plug->vRaw; + rawHarm = entry_plug->vHarm; + +#ifdef IS_MPI + if(worldRank == 0 ){ +#endif // is_mpi + + rawFile.precision(8); + rawFile + << currentTime << "\t" + << rawPot << "\t" + << rawHarm << "\n"; + + rawFile.flush(); + +#ifdef IS_MPI + } +#endif // is_mpi +}