--- trunk/src/rnemd/RNEMD.cpp 2013/06/16 15:15:42 1879 +++ trunk/src/rnemd/RNEMD.cpp 2014/02/26 14:14:50 1969 @@ -38,6 +38,9 @@ * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). * [4] Vardeman & Gezelter, in progress (2009). */ +#ifdef IS_MPI +#include +#endif #include #include @@ -54,9 +57,6 @@ #include "utils/Tuple.hpp" #include "brains/Thermo.hpp" #include "math/ConvexHull.hpp" -#ifdef IS_MPI -#include -#endif #ifdef _MSC_VER #define isnan(x) _isnan((x)) @@ -547,6 +547,7 @@ namespace OpenMD { if (hasSelectionB_) { selectionB_ = rnemdParams->getSelectionB(); + } else { if (usePeriodicBoundaryConditions_) { Mat3x3d hmat = currentSnap_->getHmat(); @@ -573,6 +574,7 @@ namespace OpenMD { selectionB_ = selectionBstream.str(); } else { selectionB_ = "select hull"; + BisHull_ = true; hasSelectionB_ = true; } } @@ -752,15 +754,18 @@ namespace OpenMD { } #ifdef IS_MPI - int worldRank = MPI::COMM_WORLD.Get_rank(); - - bool my_min_found = min_found; - bool my_max_found = max_found; + int worldRank; + MPI_Comm_rank( MPI_COMM_WORLD, &worldRank); + + int my_min_found = min_found; + int my_max_found = max_found; // Even if we didn't find a minimum, did someone else? - MPI::COMM_WORLD.Allreduce(&my_min_found, &min_found, 1, MPI::BOOL, MPI::LOR); + MPI_Allreduce(&my_min_found, &min_found, 1, MPI_INT, MPI_LOR, + MPI_COMM_WORLD); // Even if we didn't find a maximum, did someone else? - MPI::COMM_WORLD.Allreduce(&my_max_found, &max_found, 1, MPI::BOOL, MPI::LOR); + MPI_Allreduce(&my_max_found, &max_found, 1, MPI_INT, MPI_LOR, + MPI_COMM_WORLD); #endif if (max_found && min_found) { @@ -779,8 +784,8 @@ namespace OpenMD { min_vals.rank = worldRank; // Who had the minimum? - MPI::COMM_WORLD.Allreduce(&min_vals, &min_vals, - 1, MPI::REALTYPE_INT, MPI::MINLOC); + MPI_Allreduce(&min_vals, &min_vals, + 1, MPI_REALTYPE_INT, MPI_MINLOC, MPI_COMM_WORLD); min_val = min_vals.val; if (my_max_found) { @@ -791,8 +796,8 @@ namespace OpenMD { max_vals.rank = worldRank; // Who had the maximum? - MPI::COMM_WORLD.Allreduce(&max_vals, &max_vals, - 1, MPI::REALTYPE_INT, MPI::MAXLOC); + MPI_Allreduce(&max_vals, &max_vals, + 1, MPI_REALTYPE_INT, MPI_MAXLOC, MPI_COMM_WORLD); max_val = max_vals.val; #endif @@ -852,13 +857,13 @@ namespace OpenMD { Vector3d min_vel; Vector3d max_vel = max_sd->getVel(); - MPI::Status status; + MPI_Status* status; // point-to-point swap of the velocity vector - MPI::COMM_WORLD.Sendrecv(max_vel.getArrayPointer(), 3, MPI::REALTYPE, - min_vals.rank, 0, - min_vel.getArrayPointer(), 3, MPI::REALTYPE, - min_vals.rank, 0, status); + MPI_Sendrecv(max_vel.getArrayPointer(), 3, MPI_REALTYPE, + min_vals.rank, 0, + min_vel.getArrayPointer(), 3, MPI_REALTYPE, + min_vals.rank, 0, MPI_COMM_WORLD, status); switch(rnemdFluxType_) { case rnemdKE : @@ -869,11 +874,11 @@ namespace OpenMD { Vector3d max_angMom = max_sd->getJ(); // point-to-point swap of the angular momentum vector - MPI::COMM_WORLD.Sendrecv(max_angMom.getArrayPointer(), 3, - MPI::REALTYPE, min_vals.rank, 1, - min_angMom.getArrayPointer(), 3, - MPI::REALTYPE, min_vals.rank, 1, - status); + MPI_Sendrecv(max_angMom.getArrayPointer(), 3, + MPI_REALTYPE, min_vals.rank, 1, + min_angMom.getArrayPointer(), 3, + MPI_REALTYPE, min_vals.rank, 1, + MPI_COMM_WORLD, status); max_sd->setJ(min_angMom); } @@ -898,13 +903,13 @@ namespace OpenMD { Vector3d max_vel; Vector3d min_vel = min_sd->getVel(); - MPI::Status status; + MPI_Status* status; // point-to-point swap of the velocity vector - MPI::COMM_WORLD.Sendrecv(min_vel.getArrayPointer(), 3, MPI::REALTYPE, - max_vals.rank, 0, - max_vel.getArrayPointer(), 3, MPI::REALTYPE, - max_vals.rank, 0, status); + MPI_Sendrecv(min_vel.getArrayPointer(), 3, MPI_REALTYPE, + max_vals.rank, 0, + max_vel.getArrayPointer(), 3, MPI_REALTYPE, + max_vals.rank, 0, MPI_COMM_WORLD, status); switch(rnemdFluxType_) { case rnemdKE : @@ -915,11 +920,11 @@ namespace OpenMD { Vector3d max_angMom; // point-to-point swap of the angular momentum vector - MPI::COMM_WORLD.Sendrecv(min_angMom.getArrayPointer(), 3, - MPI::REALTYPE, max_vals.rank, 1, - max_angMom.getArrayPointer(), 3, - MPI::REALTYPE, max_vals.rank, 1, - status); + MPI_Sendrecv(min_angMom.getArrayPointer(), 3, + MPI_REALTYPE, max_vals.rank, 1, + max_angMom.getArrayPointer(), 3, + MPI_REALTYPE, max_vals.rank, 1, + MPI_COMM_WORLD, status); min_sd->setJ(max_angMom); } @@ -1088,22 +1093,22 @@ namespace OpenMD { Kcw *= 0.5; #ifdef IS_MPI - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Phx, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Phy, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Phz, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Pcx, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Pcy, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Pcz, 1, MPI::REALTYPE, MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, &Phx, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Phy, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Phz, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Pcx, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Pcy, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Pcz, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Khx, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Khy, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Khz, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Khw, 1, MPI::REALTYPE, MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, &Khx, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Khy, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Khz, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Khw, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Kcx, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Kcy, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Kcz, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Kcw, 1, MPI::REALTYPE, MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, &Kcx, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Kcy, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Kcz, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Kcw, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); #endif //solve coldBin coeff's first @@ -1580,18 +1585,22 @@ namespace OpenMD { Kc *= 0.5; #ifdef IS_MPI - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Ph[0], 3, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Pc[0], 3, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Lh[0], 3, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Lc[0], 3, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Mh, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Kh, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Mc, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &Kc, 1, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, Ih.getArrayPointer(), 9, - MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, Ic.getArrayPointer(), 9, - MPI::REALTYPE, MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, &Ph[0], 3, MPI_REALTYPE, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Pc[0], 3, MPI_REALTYPE, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Lh[0], 3, MPI_REALTYPE, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Lc[0], 3, MPI_REALTYPE, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Mh, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Kh, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Mc, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &Kc, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, Ih.getArrayPointer(), 9, + MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, Ic.getArrayPointer(), 9, + MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); #endif @@ -1729,27 +1738,34 @@ namespace OpenMD { Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot(); if (hasSelectionA_) { - int isd; - StuntDouble* sd; - vector aSites; - seleManA_.setSelectionSet(evaluatorA_.evaluate()); - for (sd = seleManA_.beginSelected(isd); sd != NULL; - sd = seleManA_.nextSelected(isd)) { - aSites.push_back(sd); - } + + if (evaluatorA_.hasSurfaceArea()) + areaA = evaluatorA_.getSurfaceArea(); + else { + + cerr << "selection A did not have surface area, recomputing\n"; + int isd; + StuntDouble* sd; + vector aSites; + seleManA_.setSelectionSet(evaluatorA_.evaluate()); + for (sd = seleManA_.beginSelected(isd); sd != NULL; + sd = seleManA_.nextSelected(isd)) { + aSites.push_back(sd); + } #if defined(HAVE_QHULL) - ConvexHull* surfaceMeshA = new ConvexHull(); - surfaceMeshA->computeHull(aSites); - areaA = surfaceMeshA->getArea(); - delete surfaceMeshA; + ConvexHull* surfaceMeshA = new ConvexHull(); + surfaceMeshA->computeHull(aSites); + areaA = surfaceMeshA->getArea(); + delete surfaceMeshA; #else - sprintf( painCave.errMsg, + sprintf( painCave.errMsg, "RNEMD::getDividingArea : Hull calculation is not possible\n" - "\twithout libqhull. Please rebuild OpenMD with qhull enabled."); - painCave.severity = OPENMD_ERROR; - painCave.isFatal = 1; - simError(); + "\twithout libqhull. Please rebuild OpenMD with qhull enabled."); + painCave.severity = OPENMD_ERROR; + painCave.isFatal = 1; + simError(); #endif + } } else { if (usePeriodicBoundaryConditions_) { @@ -1765,30 +1781,35 @@ namespace OpenMD { } if (hasSelectionB_) { - int isd; - StuntDouble* sd; - vector bSites; - seleManB_.setSelectionSet(evaluatorB_.evaluate()); - for (sd = seleManB_.beginSelected(isd); sd != NULL; - sd = seleManB_.nextSelected(isd)) { - bSites.push_back(sd); - } + if (evaluatorB_.hasSurfaceArea()) + areaB = evaluatorB_.getSurfaceArea(); + else { + cerr << "selection B did not have surface area, recomputing\n"; + int isd; + StuntDouble* sd; + vector bSites; + seleManB_.setSelectionSet(evaluatorB_.evaluate()); + for (sd = seleManB_.beginSelected(isd); sd != NULL; + sd = seleManB_.nextSelected(isd)) { + bSites.push_back(sd); + } + #if defined(HAVE_QHULL) - ConvexHull* surfaceMeshB = new ConvexHull(); - surfaceMeshB->computeHull(bSites); - areaB = surfaceMeshB->getArea(); - delete surfaceMeshB; + ConvexHull* surfaceMeshB = new ConvexHull(); + surfaceMeshB->computeHull(bSites); + areaB = surfaceMeshB->getArea(); + delete surfaceMeshB; #else - sprintf( painCave.errMsg, - "RNEMD::getDividingArea : Hull calculation is not possible\n" - "\twithout libqhull. Please rebuild OpenMD with qhull enabled."); - painCave.severity = OPENMD_ERROR; - painCave.isFatal = 1; - simError(); + sprintf( painCave.errMsg, + "RNEMD::getDividingArea : Hull calculation is not possible\n" + "\twithout libqhull. Please rebuild OpenMD with qhull enabled."); + painCave.severity = OPENMD_ERROR; + painCave.isFatal = 1; + simError(); #endif - - + } + } else { if (usePeriodicBoundaryConditions_) { // in periodic boundaries, the surface area is twice the x-y @@ -1800,7 +1821,7 @@ namespace OpenMD { areaB = 4.0 * M_PI * pow(sphereBRadius_, 2); } } - + dividingArea_ = min(areaA, areaB); hasDividingArea_ = true; return dividingArea_; @@ -1860,19 +1881,27 @@ namespace OpenMD { RealType area = getDividingArea(); areaAccumulator_->add(area); Mat3x3d hmat = currentSnap_->getHmat(); + Vector3d u = angularMomentumFluxVector_; + u.normalize(); + seleMan_.setSelectionSet(evaluator_.evaluate()); int selei(0); StuntDouble* sd; int binNo; + RealType mass; + Vector3d vel; + Vector3d rPos; + RealType KE; + Vector3d L; + Mat3x3d I; + RealType r2; vector binMass(nBins_, 0.0); - vector binPx(nBins_, 0.0); - vector binPy(nBins_, 0.0); - vector binPz(nBins_, 0.0); - vector binOmegax(nBins_, 0.0); - vector binOmegay(nBins_, 0.0); - vector binOmegaz(nBins_, 0.0); + vector binP(nBins_, V3Zero); + vector binOmega(nBins_, 0.0); + vector binL(nBins_, V3Zero); + vector binI(nBins_); vector binKE(nBins_, 0.0); vector binDOF(nBins_, 0); vector binCount(nBins_, 0); @@ -1912,37 +1941,50 @@ namespace OpenMD { binNo = int(rPos.length() / binWidth_); } - RealType mass = sd->getMass(); - Vector3d vel = sd->getVel(); - Vector3d rPos = sd->getPos() - coordinateOrigin_; - Vector3d aVel = cross(rPos, vel); - + mass = sd->getMass(); + vel = sd->getVel(); + rPos = sd->getPos() - coordinateOrigin_; + KE = 0.5 * mass * vel.lengthSquare(); + L = mass * cross(rPos, vel); + I = outProduct(rPos, rPos) * mass; + r2 = rPos.lengthSquare(); + I(0, 0) += mass * r2; + I(1, 1) += mass * r2; + I(2, 2) += mass * r2; + + // Project the relative position onto a plane perpendicular to + // the angularMomentumFluxVector: + // Vector3d rProj = rPos - dot(rPos, u) * u; + // Project the velocity onto a plane perpendicular to the + // angularMomentumFluxVector: + // Vector3d vProj = vel - dot(vel, u) * u; + // Compute angular velocity vector (should be nearly parallel to + // angularMomentumFluxVector + // Vector3d aVel = cross(rProj, vProj); + if (binNo >= 0 && binNo < nBins_) { binCount[binNo]++; binMass[binNo] += mass; - binPx[binNo] += mass*vel.x(); - binPy[binNo] += mass*vel.y(); - binPz[binNo] += mass*vel.z(); - binOmegax[binNo] += aVel.x(); - binOmegay[binNo] += aVel.y(); - binOmegaz[binNo] += aVel.z(); - binKE[binNo] += 0.5 * (mass * vel.lengthSquare()); + binP[binNo] += mass*vel; + binKE[binNo] += KE; + binI[binNo] += I; + binL[binNo] += L; binDOF[binNo] += 3; if (sd->isDirectional()) { Vector3d angMom = sd->getJ(); - Mat3x3d I = sd->getI(); + Mat3x3d Ia = sd->getI(); if (sd->isLinear()) { int i = sd->linearAxis(); int j = (i + 1) % 3; int k = (i + 2) % 3; - binKE[binNo] += 0.5 * (angMom[j] * angMom[j] / I(j, j) + - angMom[k] * angMom[k] / I(k, k)); + binKE[binNo] += 0.5 * (angMom[j] * angMom[j] / Ia(j, j) + + angMom[k] * angMom[k] / Ia(k, k)); binDOF[binNo] += 2; } else { - binKE[binNo] += 0.5 * (angMom[0] * angMom[0] / I(0, 0) + - angMom[1] * angMom[1] / I(1, 1) + - angMom[2] * angMom[2] / I(2, 2)); + binKE[binNo] += 0.5 * (angMom[0] * angMom[0] / Ia(0, 0) + + angMom[1] * angMom[1] / Ia(1, 1) + + angMom[2] * angMom[2] / Ia(2, 2)); binDOF[binNo] += 3; } } @@ -1950,30 +1992,30 @@ namespace OpenMD { } #ifdef IS_MPI - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binCount[0], - nBins_, MPI::INT, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binMass[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binPx[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binPy[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binPz[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmegax[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmegay[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmegaz[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binKE[0], - nBins_, MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binDOF[0], - nBins_, MPI::INT, MPI::SUM); + + for (int i = 0; i < nBins_; i++) { + + MPI_Allreduce(MPI_IN_PLACE, &binCount[i], + 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &binMass[i], + 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &binP[i], + 3, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &binL[i], + 3, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &binI[i], + 9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &binKE[i], + 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &binDOF[i], + 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + //MPI_Allreduce(MPI_IN_PLACE, &binOmega[i], + // 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + } + #endif - Vector3d vel; - Vector3d aVel; + Vector3d omega; RealType den; RealType temp; RealType z; @@ -1990,13 +2032,12 @@ namespace OpenMD { den = binMass[i] * 3.0 * PhysicalConstants::densityConvert / (4.0 * M_PI * (pow(router,3) - pow(rinner,3))); } - vel.x() = binPx[i] / binMass[i]; - vel.y() = binPy[i] / binMass[i]; - vel.z() = binPz[i] / binMass[i]; - aVel.x() = binOmegax[i] / binCount[i]; - aVel.y() = binOmegay[i] / binCount[i]; - aVel.z() = binOmegaz[i] / binCount[i]; + vel = binP[i] / binMass[i]; + + omega = binI[i].inverse() * binL[i]; + // omega = binOmega[i] / binCount[i]; + if (binCount[i] > 0) { // only add values if there are things to add temp = 2.0 * binKE[i] / (binDOF[i] * PhysicalConstants::kb * @@ -2018,7 +2059,7 @@ namespace OpenMD { dynamic_cast(data_[j].accumulator[i])->add(vel); break; case ANGULARVELOCITY: - dynamic_cast(data_[j].accumulator[i])->add(aVel); + dynamic_cast(data_[j].accumulator[i])->add(omega); break; case DENSITY: dynamic_cast(data_[j].accumulator[i])->add(den); @@ -2065,7 +2106,9 @@ namespace OpenMD { #ifdef IS_MPI // If we're the root node, should we print out the results - int worldRank = MPI::COMM_WORLD.Get_rank(); + int worldRank; + MPI_Comm_rank( MPI_COMM_WORLD, &worldRank); + if (worldRank == 0) { #endif rnemdFile_.open(rnemdFileName_.c_str(), std::ios::out | std::ios::trunc );