44 |
|
* |
45 |
|
* Created by Charles F. Vardeman II on 11/26/05. |
46 |
|
* @author Charles F. Vardeman II |
47 |
< |
* @version $Id: RhoZ.cpp,v 1.3 2006-01-11 19:01:20 tim Exp $ |
47 |
> |
* @version $Id: RhoZ.cpp,v 1.4 2006-03-07 16:43:52 gezelter Exp $ |
48 |
|
* |
49 |
|
*/ |
50 |
|
|
58 |
|
#include "primitives/Molecule.hpp" |
59 |
|
namespace oopse { |
60 |
|
|
61 |
< |
RhoZ::RhoZ(SimInfo* info, const std::string& filename, const std::string& sele, int len, int nrbins) |
62 |
< |
: StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info), len_(len), nRBins_(nrbins){ |
61 |
> |
RhoZ::RhoZ(SimInfo* info, const std::string& filename, const std::string& sele, double len, int nrbins) |
62 |
> |
: StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info), len_(len), nRBins_(nrbins){ |
63 |
|
|
64 |
|
evaluator_.loadScriptString(sele); |
65 |
|
if (!evaluator_.isDynamic()) { |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
< |
deltaR_ = len_ /nRBins_; |
70 |
> |
deltaR_ = len_ /(nRBins_); |
71 |
|
|
72 |
|
sliceSDLists_.resize(nRBins_); |
73 |
|
density_.resize(nRBins_); |
78 |
|
void RhoZ::process() { |
79 |
|
DumpReader reader(info_, dumpFilename_); |
80 |
|
int nFrames = reader.getNFrames(); |
81 |
< |
nProcessed_ = nFrames / step_; |
81 |
> |
nProcessed_ = nFrames/step_; |
82 |
|
|
83 |
– |
|
83 |
|
for (int istep = 0; istep < nFrames; istep += step_) { |
84 |
|
|
85 |
< |
StuntDouble* sd; |
86 |
< |
int i; |
87 |
< |
reader.readFrame(istep); |
88 |
< |
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
85 |
> |
int i; |
86 |
> |
for (i=0; i < nRBins_; i++) { |
87 |
> |
sliceSDLists_[i].clear(); |
88 |
> |
} |
89 |
|
|
90 |
< |
double sliceVolume = currentSnapshot_->getVolume() /nRBins_; |
91 |
< |
//assume simulation box will never change |
92 |
< |
//Mat3x3d hmat = currentSnapshot_->getHmat(); |
93 |
< |
double halfBoxZ = len_ /2; |
90 |
> |
StuntDouble* sd; |
91 |
> |
reader.readFrame(istep); |
92 |
> |
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
93 |
> |
|
94 |
> |
double sliceVolume = currentSnapshot_->getVolume() /nRBins_; |
95 |
> |
//assume simulation box will never change |
96 |
> |
//Mat3x3d hmat = currentSnapshot_->getHmat(); |
97 |
> |
double halfBoxZ_ = len_ / 2.0; |
98 |
|
|
99 |
|
if (evaluator_.isDynamic()) { |
100 |
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
110 |
|
//determine which atom belongs to which slice |
111 |
|
for (sd = seleMan_.beginSelected(i); sd != NULL; sd = seleMan_.nextSelected(i)) { |
112 |
|
Vector3d pos = sd->getPos(); |
113 |
< |
int binNo = (pos.z() + halfBoxZ) /deltaR_; |
113 |
> |
//int binNo = (pos.z() /deltaR_) - 1; |
114 |
> |
int binNo = (pos.z() + halfBoxZ_) /deltaR_ ; |
115 |
> |
//std::cout << "pos.z = " << pos.z() << " halfBoxZ_ = " << halfBoxZ_ << " deltaR_ = " << deltaR_ << " binNo = " << binNo << "\n"; |
116 |
|
sliceSDLists_[binNo].push_back(sd); |
117 |
|
} |
118 |
|
|
119 |
|
//loop over the slices to calculate the densities |
120 |
< |
for (std::size_t j = 0; j < sliceSDLists_.size(); ++j) { |
120 |
> |
for (i = 0; i < nRBins_; i++) { |
121 |
|
double totalMass = 0; |
122 |
< |
for (int k = 0; k < sliceSDLists_[j].size(); ++k) { |
123 |
< |
totalMass += sliceSDLists_[j][k]->getMass(); |
122 |
> |
for (int k = 0; k < sliceSDLists_[i].size(); ++k) { |
123 |
> |
totalMass += sliceSDLists_[i][k]->getMass(); |
124 |
|
} |
125 |
< |
density_[j] += totalMass/sliceVolume; |
125 |
> |
density_[i] += totalMass/sliceVolume; |
126 |
|
} |
127 |
|
} |
128 |
|
|
124 |
– |
|
129 |
|
writeDensity(); |
130 |
|
|
131 |
|
} |
136 |
|
std::ofstream rdfStream(outputFilename_.c_str()); |
137 |
|
if (rdfStream.is_open()) { |
138 |
|
rdfStream << "#RhoZ\n"; |
139 |
< |
rdfStream << "#selection: (" << selectionScript_ << ")\t"; |
139 |
> |
rdfStream << "#nFrames:\t" << nProcessed_ << "\n"; |
140 |
> |
rdfStream << "#selection: (" << selectionScript_ << ")\n"; |
141 |
|
rdfStream << "#z\tdensity\n"; |
142 |
|
for (int i = 0; i < density_.size(); ++i) { |
143 |
|
double r = deltaR_ * (i + 0.5); |
144 |
< |
rdfStream << r << "\t" << density_[i]/nProcessed_ << "\n"; |
144 |
> |
rdfStream << r << "\t" << 1.660535*density_[i]/nProcessed_ << "\n"; |
145 |
|
} |
146 |
|
|
147 |
|
} else { |