--- trunk/src/applications/staticProps/GofXyz.cpp 2005/02/17 18:30:54 361 +++ trunk/src/applications/staticProps/GofXyz.cpp 2005/02/17 20:15:29 365 @@ -47,10 +47,10 @@ GofXyz::GofXyz(SimInfo* info, const std::string& filen namespace oopse { GofXyz::GofXyz(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2, double len, int nrbins) - : RadialDistrFunc(info, filename, sele1, sele2), len_(len), nRBins_(nrbins) { + : RadialDistrFunc(info, filename, sele1, sele2), len_(len), halfLen_(len/2), nRBins_(nrbins) { setOutputName(getPrefix(filename) + ".gxyz"); - deltaR_ = len_ / nRBins_; + deltaR_ = len_ / nRBins_; histogram_.resize(nRBins_); for (int i = 0 ; i < nRBins_; ++i) { @@ -135,32 +135,33 @@ void GofXyz::collectHistogram(StuntDouble* sd1, StuntD double y = dot(r12, i->second.yaxis); double z = dot(r12, i->second.zaxis); - int xbin = x / deltaR_; - int ybin = y / deltaR_; - int zbin = z / deltaR_; + // x, y and z's possible values range -halfLen_ to halfLen_ + int xbin = (x+ halfLen_) / deltaR_; + int ybin = (y + halfLen_) / deltaR_; + int zbin = (z + halfLen_) / deltaR_; - if (xbin < nRBins_ && ybin < nRBins_ && zbin < nRBins_) { - ++histogram_[x][y][z]; + if (xbin < nRBins_ && xbin >=0 && + ybin < nRBins_ && ybin >= 0 && + zbin < nRBins_ && zbin >=0 ) { + ++histogram_[xbin][ybin][zbin]; } } void GofXyz::writeRdf() { - std::ofstream rdfStream(outputFilename_.c_str()); + std::ofstream rdfStream(outputFilename_.c_str(), std::ios::binary); if (rdfStream.is_open()) { - rdfStream << "#g(x, y, z)\n"; - rdfStream << "#selection1: (" << selectionScript1_ << ")\t"; - rdfStream << "selection2: (" << selectionScript2_ << ")\n"; - rdfStream << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "deltaR = " << deltaR_ <<"\n"; + //rdfStream << "#g(x, y, z)\n"; + //rdfStream << "#selection1: (" << selectionScript1_ << ")\t"; + //rdfStream << "selection2: (" << selectionScript2_ << ")\n"; + //rdfStream << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "deltaR = " << deltaR_ <<"\n"; for (int i = 0; i < histogram_.size(); ++i) { for(int j = 0; j < histogram_[i].size(); ++j) { for(int k = 0;k < histogram_[i].size(); ++k) { - - rdfStream << histogram_[i][j][k]/nProcessed_ << "\t"; + rdfStream.write(reinterpret_cast(&histogram_[i][j][k] ), sizeof(histogram_[i][j][k] )); } - rdfStream << "\n"; } }