--- branches/development/src/brains/Thermo.cpp 2011/11/22 20:38:56 1665 +++ branches/development/src/brains/Thermo.cpp 2012/05/22 21:55:31 1715 @@ -51,6 +51,7 @@ #include "primitives/Molecule.hpp" #include "utils/simError.h" #include "utils/PhysicalConstants.hpp" +#include "types/MultipoleAdapter.hpp" namespace OpenMD { @@ -142,8 +143,44 @@ namespace OpenMD { RealType temperature = ( 2.0 * this->getKinetic() ) / (info_->getNdf()* PhysicalConstants::kb ); return temperature; + } + + RealType Thermo::getElectronicTemperature() { + SimInfo::MoleculeIterator miter; + std::vector::iterator iiter; + Molecule* mol; + Atom* atom; + RealType cvel; + RealType cmass; + RealType kinetic = 0.0; + RealType kinetic_global = 0.0; + + for (mol = info_->beginMolecule(miter); mol != NULL; mol = info_->nextMolecule(miter)) { + for (atom = mol->beginFluctuatingCharge(iiter); atom != NULL; + atom = mol->nextFluctuatingCharge(iiter)) { + cmass = atom->getChargeMass(); + cvel = atom->getFlucQVel(); + + kinetic += cmass * cvel * cvel; + + } + } + +#ifdef IS_MPI + + MPI_Allreduce(&kinetic, &kinetic_global, 1, MPI_REALTYPE, MPI_SUM, + MPI_COMM_WORLD); + kinetic = kinetic_global; + +#endif //is_mpi + + kinetic = kinetic * 0.5 / PhysicalConstants::energyConvert; + return ( 2.0 * kinetic) / (info_->getNFluctuatingCharges()* PhysicalConstants::kb ); } + + + RealType Thermo::getVolume() { Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); return curSnapshot->getVolume(); @@ -209,7 +246,7 @@ namespace OpenMD { RealType volume = this->getVolume(); Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); - Mat3x3d tau = curSnapshot->statData.getTau(); + Mat3x3d tau = curSnapshot->getTau(); pressureTensor = (p_global + PhysicalConstants::energyConvert* tau)/volume; @@ -364,15 +401,12 @@ namespace OpenMD { } } - if (atom->isDipole() ) { + MultipoleAdapter ma = MultipoleAdapter(atom->getAtomType()); + if (ma.isDipole() ) { Vector3d u_i = atom->getElectroFrame().getColumn(2); - GenericData* data = dynamic_cast(atom->getAtomType())->getPropertyByName("Dipole"); - if (data != NULL) { - moment = (dynamic_cast(data))->getData(); - - moment *= debyeToCm; - dipoleVector += u_i * moment; - } + moment = ma.getDipoleMoment(); + moment *= debyeToCm; + dipoleVector += u_i * moment; } } }