--- trunk/OOPSE/libmdtools/Thermo.cpp 2003/04/09 04:06:43 483 +++ trunk/OOPSE/libmdtools/Thermo.cpp 2003/07/08 20:56:10 574 @@ -132,10 +132,42 @@ double Thermo::getTemperature(){ temperature = ( 2.0 * this->getKinetic() ) / ((double)entry_plug->ndf * kb ); 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[9]; + + u = this->getTotalE(); + + this->getPressureTensor(press); + p = (press[0] + press[4] + press[8]) / 3.0; + + v = this->getVolume(); + + return (u + (p*v)/e_convert); +} + +double Thermo::getVolume() { + + double volume; + double Hmat[9]; + + entry_plug->getBoxM(Hmat); + + // volume = h1 (dot) h2 (cross) h3 + + volume = Hmat[0] * ( (Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]) ) + + Hmat[1] * ( (Hmat[5]*Hmat[6]) - (Hmat[8]*Hmat[3]) ) + + Hmat[2] * ( (Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]) ); + + return volume; } 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; @@ -161,13 +193,13 @@ void Thermo::getPressureTensor(double press[9]){ double vcom[3]; double p_local[9], p_global[9]; double theBox[3]; - double* tau; + //double* tau; int i, 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 +231,10 @@ 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; + press[i] = (p_global[i] - entry_plug->tau[i]*e_convert) / volume; } }