38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
39 |
|
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
+ |
#ifdef IS_MPI |
42 |
+ |
#include <mpi.h> |
43 |
+ |
#endif |
44 |
|
|
45 |
|
#include <cmath> |
46 |
|
#include <sstream> |
57 |
|
#include "utils/Tuple.hpp" |
58 |
|
#include "brains/Thermo.hpp" |
59 |
|
#include "math/ConvexHull.hpp" |
57 |
– |
#ifdef IS_MPI |
58 |
– |
#include <mpi.h> |
59 |
– |
#endif |
60 |
|
|
61 |
|
#ifdef _MSC_VER |
62 |
|
#define isnan(x) _isnan((x)) |
1874 |
|
RealType area = getDividingArea(); |
1875 |
|
areaAccumulator_->add(area); |
1876 |
|
Mat3x3d hmat = currentSnap_->getHmat(); |
1877 |
+ |
Vector3d u = angularMomentumFluxVector_; |
1878 |
+ |
u.normalize(); |
1879 |
+ |
|
1880 |
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
1881 |
|
|
1882 |
|
int selei(0); |
1883 |
|
StuntDouble* sd; |
1884 |
|
int binNo; |
1885 |
+ |
RealType mass; |
1886 |
+ |
Vector3d vel; |
1887 |
+ |
Vector3d rPos; |
1888 |
+ |
RealType KE; |
1889 |
+ |
Vector3d L; |
1890 |
+ |
Mat3x3d I; |
1891 |
+ |
RealType r2; |
1892 |
|
|
1893 |
|
vector<RealType> binMass(nBins_, 0.0); |
1894 |
< |
vector<RealType> binPx(nBins_, 0.0); |
1895 |
< |
vector<RealType> binPy(nBins_, 0.0); |
1896 |
< |
vector<RealType> binPz(nBins_, 0.0); |
1897 |
< |
vector<RealType> binOmegax(nBins_, 0.0); |
1888 |
< |
vector<RealType> binOmegay(nBins_, 0.0); |
1889 |
< |
vector<RealType> binOmegaz(nBins_, 0.0); |
1894 |
> |
vector<Vector3d> binP(nBins_, V3Zero); |
1895 |
> |
vector<RealType> binOmega(nBins_, 0.0); |
1896 |
> |
vector<Vector3d> binL(nBins_, V3Zero); |
1897 |
> |
vector<Mat3x3d> binI(nBins_); |
1898 |
|
vector<RealType> binKE(nBins_, 0.0); |
1899 |
|
vector<int> binDOF(nBins_, 0); |
1900 |
|
vector<int> binCount(nBins_, 0); |
1934 |
|
binNo = int(rPos.length() / binWidth_); |
1935 |
|
} |
1936 |
|
|
1937 |
< |
RealType mass = sd->getMass(); |
1938 |
< |
Vector3d vel = sd->getVel(); |
1939 |
< |
Vector3d rPos = sd->getPos() - coordinateOrigin_; |
1940 |
< |
Vector3d aVel = cross(rPos, vel); |
1941 |
< |
|
1937 |
> |
mass = sd->getMass(); |
1938 |
> |
vel = sd->getVel(); |
1939 |
> |
rPos = sd->getPos() - coordinateOrigin_; |
1940 |
> |
KE = 0.5 * mass * vel.lengthSquare(); |
1941 |
> |
L = mass * cross(rPos, vel); |
1942 |
> |
I = outProduct(rPos, rPos) * mass; |
1943 |
> |
r2 = rPos.lengthSquare(); |
1944 |
> |
I(0, 0) += mass * r2; |
1945 |
> |
I(1, 1) += mass * r2; |
1946 |
> |
I(2, 2) += mass * r2; |
1947 |
> |
|
1948 |
> |
// Project the relative position onto a plane perpendicular to |
1949 |
> |
// the angularMomentumFluxVector: |
1950 |
> |
// Vector3d rProj = rPos - dot(rPos, u) * u; |
1951 |
> |
// Project the velocity onto a plane perpendicular to the |
1952 |
> |
// angularMomentumFluxVector: |
1953 |
> |
// Vector3d vProj = vel - dot(vel, u) * u; |
1954 |
> |
// Compute angular velocity vector (should be nearly parallel to |
1955 |
> |
// angularMomentumFluxVector |
1956 |
> |
// Vector3d aVel = cross(rProj, vProj); |
1957 |
> |
|
1958 |
|
if (binNo >= 0 && binNo < nBins_) { |
1959 |
|
binCount[binNo]++; |
1960 |
|
binMass[binNo] += mass; |
1961 |
< |
binPx[binNo] += mass*vel.x(); |
1962 |
< |
binPy[binNo] += mass*vel.y(); |
1963 |
< |
binPz[binNo] += mass*vel.z(); |
1964 |
< |
binOmegax[binNo] += aVel.x(); |
1941 |
< |
binOmegay[binNo] += aVel.y(); |
1942 |
< |
binOmegaz[binNo] += aVel.z(); |
1943 |
< |
binKE[binNo] += 0.5 * (mass * vel.lengthSquare()); |
1961 |
> |
binP[binNo] += mass*vel; |
1962 |
> |
binKE[binNo] += KE; |
1963 |
> |
binI[binNo] += I; |
1964 |
> |
binL[binNo] += L; |
1965 |
|
binDOF[binNo] += 3; |
1966 |
|
|
1967 |
|
if (sd->isDirectional()) { |
1968 |
|
Vector3d angMom = sd->getJ(); |
1969 |
< |
Mat3x3d I = sd->getI(); |
1969 |
> |
Mat3x3d Ia = sd->getI(); |
1970 |
|
if (sd->isLinear()) { |
1971 |
|
int i = sd->linearAxis(); |
1972 |
|
int j = (i + 1) % 3; |
1973 |
|
int k = (i + 2) % 3; |
1974 |
< |
binKE[binNo] += 0.5 * (angMom[j] * angMom[j] / I(j, j) + |
1975 |
< |
angMom[k] * angMom[k] / I(k, k)); |
1974 |
> |
binKE[binNo] += 0.5 * (angMom[j] * angMom[j] / Ia(j, j) + |
1975 |
> |
angMom[k] * angMom[k] / Ia(k, k)); |
1976 |
|
binDOF[binNo] += 2; |
1977 |
|
} else { |
1978 |
< |
binKE[binNo] += 0.5 * (angMom[0] * angMom[0] / I(0, 0) + |
1979 |
< |
angMom[1] * angMom[1] / I(1, 1) + |
1980 |
< |
angMom[2] * angMom[2] / I(2, 2)); |
1978 |
> |
binKE[binNo] += 0.5 * (angMom[0] * angMom[0] / Ia(0, 0) + |
1979 |
> |
angMom[1] * angMom[1] / Ia(1, 1) + |
1980 |
> |
angMom[2] * angMom[2] / Ia(2, 2)); |
1981 |
|
binDOF[binNo] += 3; |
1982 |
|
} |
1983 |
|
} |
1985 |
|
} |
1986 |
|
|
1987 |
|
#ifdef IS_MPI |
1988 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binCount[0], |
1989 |
< |
nBins_, MPI::INT, MPI::SUM); |
1990 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binMass[0], |
1991 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
1992 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binPx[0], |
1993 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
1994 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binPy[0], |
1995 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
1996 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binPz[0], |
1997 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
1998 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmegax[0], |
1999 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
2000 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmegay[0], |
2001 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
2002 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmegaz[0], |
2003 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
2004 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binKE[0], |
2005 |
< |
nBins_, MPI::REALTYPE, MPI::SUM); |
2006 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binDOF[0], |
2007 |
< |
nBins_, MPI::INT, MPI::SUM); |
1988 |
> |
|
1989 |
> |
for (int i = 0; i < nBins_; i++) { |
1990 |
> |
|
1991 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binCount[i], |
1992 |
> |
1, MPI::INT, MPI::SUM); |
1993 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binMass[i], |
1994 |
> |
1, MPI::REALTYPE, MPI::SUM); |
1995 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binP[i], |
1996 |
> |
3, MPI::REALTYPE, MPI::SUM); |
1997 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binL[i], |
1998 |
> |
3, MPI::REALTYPE, MPI::SUM); |
1999 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binI[i], |
2000 |
> |
9, MPI::REALTYPE, MPI::SUM); |
2001 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binKE[i], |
2002 |
> |
1, MPI::REALTYPE, MPI::SUM); |
2003 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binDOF[i], |
2004 |
> |
1, MPI::INT, MPI::SUM); |
2005 |
> |
//MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &binOmega[i], |
2006 |
> |
// 1, MPI::REALTYPE, MPI::SUM); |
2007 |
> |
} |
2008 |
> |
|
2009 |
|
#endif |
2010 |
|
|
2011 |
< |
Vector3d vel; |
1990 |
< |
Vector3d aVel; |
2011 |
> |
Vector3d omega; |
2012 |
|
RealType den; |
2013 |
|
RealType temp; |
2014 |
|
RealType z; |
2025 |
|
den = binMass[i] * 3.0 * PhysicalConstants::densityConvert |
2026 |
|
/ (4.0 * M_PI * (pow(router,3) - pow(rinner,3))); |
2027 |
|
} |
2028 |
< |
vel.x() = binPx[i] / binMass[i]; |
2008 |
< |
vel.y() = binPy[i] / binMass[i]; |
2009 |
< |
vel.z() = binPz[i] / binMass[i]; |
2010 |
< |
aVel.x() = binOmegax[i] / binCount[i]; |
2011 |
< |
aVel.y() = binOmegay[i] / binCount[i]; |
2012 |
< |
aVel.z() = binOmegaz[i] / binCount[i]; |
2028 |
> |
vel = binP[i] / binMass[i]; |
2029 |
|
|
2030 |
+ |
omega = binI[i].inverse() * binL[i]; |
2031 |
+ |
|
2032 |
+ |
// omega = binOmega[i] / binCount[i]; |
2033 |
+ |
|
2034 |
|
if (binCount[i] > 0) { |
2035 |
|
// only add values if there are things to add |
2036 |
|
temp = 2.0 * binKE[i] / (binDOF[i] * PhysicalConstants::kb * |
2052 |
|
dynamic_cast<VectorAccumulator *>(data_[j].accumulator[i])->add(vel); |
2053 |
|
break; |
2054 |
|
case ANGULARVELOCITY: |
2055 |
< |
dynamic_cast<VectorAccumulator *>(data_[j].accumulator[i])->add(aVel); |
2055 |
> |
dynamic_cast<VectorAccumulator *>(data_[j].accumulator[i])->add(omega); |
2056 |
|
break; |
2057 |
|
case DENSITY: |
2058 |
|
dynamic_cast<Accumulator *>(data_[j].accumulator[i])->add(den); |