--- trunk/src/applications/staticProps/GofRAngle.cpp 2005/02/10 14:15:52 309 +++ trunk/src/applications/staticProps/GofRAngle.cpp 2005/02/17 16:21:07 360 @@ -46,18 +46,27 @@ namespace oopse { namespace oopse { -GofRAngle::GofRAngle(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2, double len) - : RadialDistrFunc(info, filename, sele1, sele2, len){ +GofRAngle::GofRAngle(SimInfo* info, const std::string& filename, const std::string& sele1, + const std::string& sele2, double len, int nrbins, int nangleBins) + : RadialDistrFunc(info, filename, sele1, sele2), len_(len), nRBins_(nrbins), nAngleBins_(nangleBins){ - histogram_.resize(nbins_); - avgGofr_.resize(nbins_); + deltaR_ = len_ /nRBins_; + deltaCosAngle_ = 2.0 / nAngleBins_; + + histogram_.resize(nRBins_); + avgGofr_.resize(nRBins_); + for (int i = 0 ; i < nRBins_; ++i) { + histogram_[i].resize(nAngleBins_); + avgGofr_[i].resize(nAngleBins_); + } } void GofRAngle::preProcess() { - avgGofr_.resize(nbins_); - for (int i = 0; i < avgGofr_.size(); ++i) + + for (int i = 0; i < avgGofr_.size(); ++i) { std::fill(avgGofr_[i].begin(), avgGofr_[i].end(), 0); + } } void GofRAngle::initalizeHistogram() { @@ -69,9 +78,10 @@ void GofRAngle::processHistogram() { void GofRAngle::processHistogram() { + int nPairs = getNPairs(); double volume = info_->getSnapshotManager()->getCurrentSnapshot()->getVolume(); - double pairDensity = npairs_ /volume; - double pairConstant = ( 4.0 * PI * pairDensity ) / 3.0; + double pairDensity = nPairs /volume; + double pairConstant = ( 4.0 * NumericConstant::PI * pairDensity ) / 3.0; for(int i = 0 ; i < histogram_.size(); ++i){ @@ -99,13 +109,16 @@ void GofRAngle::collectHistogram(StuntDouble* sd1, Stu currentSnapshot_->wrapVector(r12); double distance = r12.length(); - int whichBin = distance / deltaR_; + int whichRBin = distance / deltaR_; - - double cosAngle = evaluateAngle(sd1, sd2); - histogram_[whichBin] ++; - - npairs_++; + if (distance <= len_) { + double cosAngle = evaluateAngle(sd1, sd2); + double halfBin = (nAngleBins_ - 1) * 0.5; + int whichThetaBin = halfBin * (cosAngle + 1.0); + ++histogram_[whichRBin][whichThetaBin]; + + ++npairs_; + } } void GofRAngle::writeRdf() { @@ -114,42 +127,45 @@ void GofRAngle::writeRdf() { rdfStream << "#radial distribution function\n"; rdfStream << "#selection1: (" << selectionScript1_ << ")\t"; rdfStream << "selection2: (" << selectionScript2_ << ")\n"; - rdfStream << "#r\tcorrValue\n"; + rdfStream << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "deltaR = " << deltaR_ <<"\n"; + rdfStream << "#nAngleBins =" << nAngleBins_ << "deltaCosAngle = " << deltaCosAngle_ << "\n"; for (int i = 0; i < avgGofr_.size(); ++i) { double r = deltaR_ * (i + 0.5); for(int j = 0; j < avgGofr_[i].size(); ++j) { - double cosAngle = ; - rdfStream << r << "\t" << cosAngle << "\t" << avgGofr_[i][j]/nProcessed_ << "\n"; + double cosAngle = -1.0 + (j + 0.5)*deltaCosAngle_; + rdfStream << avgGofr_[i][j]/nProcessed_ << "\t"; } + + rdfStream << "\n"; } } else { - - + sprintf(painCave.errMsg, "GofRAngle: unable to open %s\n", outputFilename_.c_str()); + painCave.isFatal = 1; + simError(); } rdfStream.close(); } - - double GofRTheta::evaluateAngle(StuntDouble* sd1, StuntDouble* sd2) { Vector3d pos1 = sd1->getPos(); Vector3d pos2 = sd2->getPos(); Vector3d r12 = pos1 - pos2; currentSnapshot_->wrapVector(r12); r12.normalize(); - Vector3d dipole = sd1->getElectroFrame().getColumn(2)£» + Vector3d dipole = sd1->getElectroFrame().getColumn(2); dipole.normalize(); - return dot(); + return dot(r12, dipole); } double GofROmega::evaluateAngle(StuntDouble* sd1, StuntDouble* sd2) { Vector3d v1 = sd1->getElectroFrame().getColumn(2); - Vector3d v2 = sd1->getElectroFrame().getColumn(2); - - + Vector3d v2 = sd1->getElectroFrame().getColumn(2); + v1.normalize(); + v2.normalize(); + return dot(v1, v2); }