| 47 |  | namespace oopse { | 
| 48 |  |  | 
| 49 |  | GofXyz::GofXyz(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2, double len, int nrbins) | 
| 50 | < | : RadialDistrFunc(info, filename, sele1, sele2), len_(len), nRBins_(nrbins) { | 
| 50 | > | : RadialDistrFunc(info, filename, sele1, sele2), len_(len), halfLen_(len/2), nRBins_(nrbins) { | 
| 51 |  | setOutputName(getPrefix(filename) + ".gxyz"); | 
| 52 |  |  | 
| 53 | < | deltaR_ = len_ / nRBins_; | 
| 53 | > | deltaR_ =  len_ / nRBins_; | 
| 54 |  |  | 
| 55 |  | histogram_.resize(nRBins_); | 
| 56 |  | for (int i = 0 ; i < nRBins_; ++i) { | 
| 135 |  | double y = dot(r12, i->second.yaxis); | 
| 136 |  | double z = dot(r12, i->second.zaxis); | 
| 137 |  |  | 
| 138 | < | int xbin = x / deltaR_; | 
| 139 | < | int ybin = y / deltaR_; | 
| 140 | < | int zbin = z / deltaR_; | 
| 138 | > | // x, y and z's possible values range -halfLen_ to halfLen_ | 
| 139 | > | int xbin = (x+ halfLen_) / deltaR_; | 
| 140 | > | int ybin = (y + halfLen_) / deltaR_; | 
| 141 | > | int zbin = (z + halfLen_) / deltaR_; | 
| 142 |  |  | 
| 143 |  | if (xbin < nRBins_ && ybin < nRBins_ && zbin < nRBins_) { | 
| 144 |  | ++histogram_[x][y][z]; | 
| 147 |  | } | 
| 148 |  |  | 
| 149 |  | void GofXyz::writeRdf() { | 
| 150 | < | std::ofstream rdfStream(outputFilename_.c_str()); | 
| 150 | > | std::ofstream rdfStream(outputFilename_.c_str(), std::ios::binary); | 
| 151 |  | if (rdfStream.is_open()) { | 
| 152 | < | rdfStream << "#g(x, y, z)\n"; | 
| 153 | < | rdfStream << "#selection1: (" << selectionScript1_ << ")\t"; | 
| 154 | < | rdfStream << "selection2: (" << selectionScript2_ << ")\n"; | 
| 155 | < | rdfStream << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "deltaR = " << deltaR_ <<"\n"; | 
| 152 | > | //rdfStream << "#g(x, y, z)\n"; | 
| 153 | > | //rdfStream << "#selection1: (" << selectionScript1_ << ")\t"; | 
| 154 | > | //rdfStream << "selection2: (" << selectionScript2_ << ")\n"; | 
| 155 | > | //rdfStream << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "deltaR = " << deltaR_ <<"\n"; | 
| 156 |  | for (int i = 0; i < histogram_.size(); ++i) { | 
| 157 |  |  | 
| 158 |  | for(int j = 0; j < histogram_[i].size(); ++j) { | 
| 159 |  |  | 
| 160 |  | for(int k = 0;k < histogram_[i].size(); ++k) { | 
| 161 | < |  | 
| 161 | < | rdfStream << histogram_[i][j][k]/nProcessed_ << "\t"; | 
| 161 | > | rdfStream.write(reinterpret_cast<char *>(&histogram_[i][j][k] ), sizeof(histogram_[i][j][k] )); | 
| 162 |  | } | 
| 163 | – | rdfStream << "\n"; | 
| 163 |  | } | 
| 164 |  | } | 
| 165 |  |  |