--- trunk/OOPSE/libmdtools/NPTi.cpp 2003/10/28 16:03:37 829 +++ trunk/OOPSE/libmdtools/NPTi.cpp 2003/11/06 22:01:37 855 @@ -7,7 +7,7 @@ #include "Thermo.hpp" #include "ReadWrite.hpp" #include "Integrator.hpp" -#include "simError.h" +#include "simError.h" #ifdef IS_MPI #include "mpiSimulation.hpp" @@ -17,17 +17,35 @@ // modification of the Hoover algorithm: // // Melchionna, S., Ciccotti, G., and Holian, B. L., 1993, -// Molec. Phys., 78, 533. +// Molec. Phys., 78, 533. // // and -// +// // Hoover, W. G., 1986, Phys. Rev. A, 34, 2499. template NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff): T( theInfo, the_ff ) { + GenericData* data; + DoubleArrayData * etaValue; + vector etaArray; + eta = 0.0; oldEta = 0.0; + + if( theInfo->useInitXSstate ){ + // retrieve eta from simInfo if + data = info->getProperty(ETAVALUE_ID); + if(data){ + etaValue = dynamic_cast(data); + + if(etaValue){ + etaArray = etaValue->getData(); + eta = etaArray[0]; + oldEta = eta; + } + } + } } template NPTi::~NPTi() { @@ -40,15 +58,15 @@ template void NPTi::evolveEtaA() { } template void NPTi::evolveEtaA() { - eta += dt2 * ( instaVol * (instaPress - targetPressure) / + eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); oldEta = eta; } template void NPTi::evolveEtaB() { - + prevEta = eta; - eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) / + eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); } @@ -65,7 +83,7 @@ template void NPTi::getPosScale(double } -template void NPTi::getPosScale(double pos[3], double COM[3], +template void NPTi::getPosScale(double pos[3], double COM[3], int index, double sc[3]){ int j; @@ -90,9 +108,9 @@ template void NPTi::scaleSimBox( void ) ); painCave.isFatal = 1; simError(); - } else { - info->scaleBox(scaleFactor); - } + } else { + info->scaleBox(scaleFactor); + } } @@ -109,29 +127,50 @@ template double NPTi::getConservedQuant double thermostat_potential; double barostat_kinetic; double barostat_potential; - + Energy = tStats->getTotalE(); - thermostat_kinetic = fkBT* tt2 * chi * chi / + thermostat_kinetic = fkBT* tt2 * chi * chi / (2.0 * eConvert); thermostat_potential = fkBT* integralOfChidt / eConvert; - barostat_kinetic = 3.0 * NkBT * tb2 * eta * eta / + barostat_kinetic = 3.0 * NkBT * tb2 * eta * eta / (2.0 * eConvert); - - barostat_potential = (targetPressure * tStats->getVolume() / p_convert) / + + barostat_potential = (targetPressure * tStats->getVolume() / p_convert) / eConvert; conservedQuantity = Energy + thermostat_kinetic + thermostat_potential + barostat_kinetic + barostat_potential; - + // cout.width(8); // cout.precision(8); -// cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic << -// "\t" << thermostat_potential << "\t" << barostat_kinetic << +// cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic << +// "\t" << thermostat_potential << "\t" << barostat_kinetic << // "\t" << barostat_potential << "\t" << conservedQuantity << endl; - return conservedQuantity; + return conservedQuantity; } + +template string NPTi::getAdditionalParameters(void){ + string parameters; + const int BUFFERSIZE = 2000; // size of the read buffer + char buffer[BUFFERSIZE]; + + sprintf(buffer,"\t%G\t%G;", chi, integralOfChidt); + parameters += buffer; + + sprintf(buffer,"\t%G\t0\t0;", eta); + parameters += buffer; + + sprintf(buffer,"\t0\t%G\t0;", eta); + parameters += buffer; + + sprintf(buffer,"\t0\t0\t%G;", eta); + parameters += buffer; + + return parameters; + +}