43 |
|
#include <algorithm> |
44 |
|
#include <fstream> |
45 |
|
#include "applications/staticProps/RNEMDStats.hpp" |
46 |
+ |
#include "primitives/Molecule.hpp" |
47 |
|
#include "utils/PhysicalConstants.hpp" |
48 |
|
|
49 |
|
namespace OpenMD { |
85 |
|
data_.push_back(density); |
86 |
|
} |
87 |
|
|
88 |
< |
void RNEMDZ::processStuntDouble(StuntDouble* sd, int bin) { |
89 |
< |
RealType mass = sd->getMass(); |
89 |
< |
Vector3d pos = sd->getPos(); |
90 |
< |
Vector3d vel = sd->getVel(); |
91 |
< |
RealType KE = 0.5 * (mass * vel.lengthSquare()); |
92 |
< |
int dof = 3; |
88 |
> |
void RNEMDZ::processFrame(int istep) { |
89 |
> |
RealType z; |
90 |
|
|
91 |
< |
if (sd->isDirectional()) { |
92 |
< |
Vector3d angMom = sd->getJ(); |
93 |
< |
Mat3x3d I = sd->getI(); |
94 |
< |
if (sd->isLinear()) { |
95 |
< |
int i = sd->linearAxis(); |
96 |
< |
int j = (i + 1) % 3; |
97 |
< |
int k = (i + 2) % 3; |
98 |
< |
KE += 0.5 * (angMom[j] * angMom[j] / I(j, j) + |
99 |
< |
angMom[k] * angMom[k] / I(k, k)); |
100 |
< |
dof += 2; |
101 |
< |
} else { |
102 |
< |
KE += 0.5 * (angMom[0] * angMom[0] / I(0, 0) + |
103 |
< |
angMom[1] * angMom[1] / I(1, 1) + |
104 |
< |
angMom[2] * angMom[2] / I(2, 2)); |
105 |
< |
dof += 3; |
91 |
> |
hmat_ = currentSnapshot_->getHmat(); |
92 |
> |
for (int i = 0; i < nBins_; i++) { |
93 |
> |
z = (((RealType)i + 0.5) / (RealType)nBins_) * hmat_(2,2); |
94 |
> |
dynamic_cast<Accumulator*>(z_->accumulator[i])->add(z); |
95 |
> |
} |
96 |
> |
volume_ = currentSnapshot_->getVolume(); |
97 |
> |
|
98 |
> |
|
99 |
> |
Molecule* mol; |
100 |
> |
RigidBody* rb; |
101 |
> |
StuntDouble* sd; |
102 |
> |
SimInfo::MoleculeIterator mi; |
103 |
> |
Molecule::RigidBodyIterator rbIter; |
104 |
> |
int i; |
105 |
> |
|
106 |
> |
vector<RealType> binMass(nBins_, 0.0); |
107 |
> |
vector<Vector3d> binVel(nBins_, V3Zero); |
108 |
> |
vector<RealType> binKE(nBins_, 0.0); |
109 |
> |
vector<unsigned int> binDof(nBins_, 0); |
110 |
> |
vector<unsigned int> binCount(nBins_, 0); |
111 |
> |
|
112 |
> |
|
113 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
114 |
> |
mol = info_->nextMolecule(mi)) { |
115 |
> |
|
116 |
> |
// change the positions of atoms which belong to the rigidbodies |
117 |
> |
|
118 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
119 |
> |
rb = mol->nextRigidBody(rbIter)) { |
120 |
> |
rb->updateAtoms(); |
121 |
|
} |
122 |
|
} |
123 |
+ |
|
124 |
+ |
if (evaluator_.isDynamic()) { |
125 |
+ |
seleMan_.setSelectionSet(evaluator_.evaluate()); |
126 |
+ |
} |
127 |
|
|
128 |
< |
RealType temp = 2.0 * KE / (dof * PhysicalConstants::kb * |
113 |
< |
PhysicalConstants::energyConvert); |
114 |
< |
RealType den = mass * nBins_ * PhysicalConstants::densityConvert / volume_; |
128 |
> |
// loop over the selected atoms: |
129 |
|
|
130 |
< |
dynamic_cast<Accumulator *>(temperature->accumulator[bin])->add(temp); |
131 |
< |
dynamic_cast<VectorAccumulator *>(velocity->accumulator[bin])->add(vel); |
132 |
< |
dynamic_cast<Accumulator *>(density->accumulator[bin])->add(den); |
130 |
> |
for (sd = seleMan_.beginSelected(i); sd != NULL; |
131 |
> |
sd = seleMan_.nextSelected(i)) { |
132 |
> |
|
133 |
> |
// figure out where that object is: |
134 |
> |
Vector3d pos = sd->getPos(); |
135 |
> |
Vector3d vel = sd->getVel(); |
136 |
> |
RealType m = sd->getMass(); |
137 |
|
|
138 |
+ |
int bin = getBin(pos); |
139 |
+ |
|
140 |
+ |
binCount[bin] += 1; |
141 |
+ |
|
142 |
+ |
binMass[bin] += m; |
143 |
+ |
binVel[bin] += vel; |
144 |
+ |
binKE[bin] += 0.5 * (m * vel.lengthSquare()); |
145 |
+ |
binDof[bin] += 3; |
146 |
+ |
|
147 |
+ |
if (sd->isDirectional()) { |
148 |
+ |
Vector3d angMom = sd->getJ(); |
149 |
+ |
Mat3x3d I = sd->getI(); |
150 |
+ |
if (sd->isLinear()) { |
151 |
+ |
int i = sd->linearAxis(); |
152 |
+ |
int j = (i + 1) % 3; |
153 |
+ |
int k = (i + 2) % 3; |
154 |
+ |
binKE[bin] += 0.5 * (angMom[j] * angMom[j] / I(j, j) + |
155 |
+ |
angMom[k] * angMom[k] / I(k, k)); |
156 |
+ |
binDof[bin] += 2; |
157 |
+ |
} else { |
158 |
+ |
binKE[bin] += 0.5 * (angMom[0] * angMom[0] / I(0, 0) + |
159 |
+ |
angMom[1] * angMom[1] / I(1, 1) + |
160 |
+ |
angMom[2] * angMom[2] / I(2, 2)); |
161 |
+ |
binDof[bin] += 3; |
162 |
+ |
} |
163 |
+ |
} |
164 |
+ |
} |
165 |
+ |
|
166 |
+ |
for (unsigned int i = 0; i < nBins_; i++) { |
167 |
+ |
|
168 |
+ |
if (binDof[i] > 0) { |
169 |
+ |
RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb * |
170 |
+ |
PhysicalConstants::energyConvert); |
171 |
+ |
RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert |
172 |
+ |
/ volume_; |
173 |
+ |
Vector3d vel = binVel[i] / RealType(binCount[i]); |
174 |
+ |
dynamic_cast<Accumulator *>(temperature->accumulator[i])->add(temp); |
175 |
+ |
dynamic_cast<VectorAccumulator *>(velocity->accumulator[i])->add(vel); |
176 |
+ |
dynamic_cast<Accumulator *>(density->accumulator[i])->add(den); |
177 |
+ |
dynamic_cast<Accumulator *>(counts_->accumulator[i])->add(1); |
178 |
+ |
} |
179 |
+ |
} |
180 |
|
} |
181 |
+ |
|
182 |
+ |
void RNEMDZ::processStuntDouble(StuntDouble* sd, int bin) { |
183 |
+ |
} |
184 |
|
|
185 |
|
RNEMDR::RNEMDR(SimInfo* info, const std::string& filename, |
186 |
|
const std::string& sele, int nrbins) |