--- trunk/OOPSE/libmdtools/Thermo.cpp 2003/04/09 04:06:43 483 +++ trunk/OOPSE/libmdtools/Thermo.cpp 2003/07/10 22:15:53 590 @@ -134,23 +134,44 @@ double Thermo::getPressure() { return temperature; } +double Thermo::getEnthalpy() { + + const double e_convert = 4.184E-4; // convert kcal/mol -> (amu A^2)/fs^2 + double u, p, v; + double press[3][3]; + + u = this->getTotalE(); + + this->getPressureTensor(press); + p = (press[0][0] + press[1][1] + press[2][2]) / 3.0; + + v = this->getVolume(); + + return (u + (p*v)/e_convert); +} + +double Thermo::getVolume() { + + return entry_plug->boxVol; +} + double Thermo::getPressure() { - // returns the pressure in units of atm + // Relies on the calculation of the full molecular pressure tensor const double p_convert = 1.63882576e8; - double press[9]; + double press[3][3]; double pressure; this->getPressureTensor(press); - pressure = p_convert * (press[0] + press[4] + press[8]) / 3.0; + pressure = p_convert * (press[0][0] + press[1][1] + press[2][2]) / 3.0; return pressure; } -void Thermo::getPressureTensor(double press[9]){ +void Thermo::getPressureTensor(double press[3][3]){ // returns pressure tensor in units amu*fs^-2*Ang^-1 // routine derived via viral theorem description in: // Paci, E. and Marchi, M. J.Phys.Chem. 1996, 100, 4314-4322 @@ -160,14 +181,12 @@ void Thermo::getPressureTensor(double press[9]){ double molmass, volume; double vcom[3]; double p_local[9], p_global[9]; - double theBox[3]; - double* tau; - int i, nMols; + int i, j, k, l, nMols; Molecule* molecules; nMols = entry_plug->n_mol; molecules = entry_plug->molecules; - tau = entry_plug->tau; + //tau = entry_plug->tau; // use velocities of molecular centers of mass and molecular masses: for (i=0; i < 9; i++) { @@ -199,12 +218,14 @@ void Thermo::getPressureTensor(double press[9]){ } #endif // is_mpi - entry_plug->getBox(theBox); + volume = entry_plug->boxVol; - volume = theBox[0] * theBox[1] * theBox[2]; - - for(i=0; i<9; i++) { - press[i] = (p_global[i] - tau[i]*e_convert) / volume; + for(i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + k = 3*i + j; + l = 3*j + i; + press[i][j] = (p_global[k] - entry_plug->tau[l]*e_convert) / volume; + } } }