00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "radialdensityhist.h"
00019 #include "cluster.h"
00020 #include "configurationdatabase.h"
00021
00022 #include <cmath>
00023
00024 #include <fstream>
00025 using std::ofstream;
00026
00027 #include <iomanip>
00028 using std::ios;
00029 using std::scientific;
00030 using std::showpos;
00031
00032
00033 RadialDensityHistogram::RadialDensityHistogram(const ConfigurationDatabase &conf):BaseHistogram(conf.doubleValue("RadialDensityHistogram", "min"), conf.doubleValue("RadialDensityHistogram", "max"), conf.intValue("RadialDensityHistogram", "bins"))
00034 {
00035 m_pullingInterval=conf.intValue("RadialDensityHistogram", "pull");
00036 m_pi=conf.doubleValue("RadialDensityHistogram", "PI");
00037 }
00038
00039 void RadialDensityHistogram::acquire(const Cluster& cluster)
00040 {
00041 int clusterSize = int(cluster.size());
00042 double del = (m_max - m_min)/m_bins;
00043 ++m_numberHistogramsTaken;
00044
00045 for(int i = 0; i < clusterSize ; ++i)
00046 {
00047 double rsep = sqrt((cluster[i].properties.position.x - cluster.positionCentreMass().x) * (cluster[i].properties.position.x - cluster.positionCentreMass().x) + (cluster[i].properties.position.y - cluster.positionCentreMass().y) * (cluster[i].properties.position.y - cluster.positionCentreMass().y) + (cluster[i].properties.position.z - cluster.positionCentreMass().z) * (cluster[i].properties.position.z - cluster.positionCentreMass().z));
00048
00049 int nbin=static_cast<int>((rsep - m_min)/del);
00050 if((nbin < m_bins) && (nbin >= 0))
00051 m_histogramBin.at(nbin)++;
00052 }
00053 return;
00054 }
00055
00056 void RadialDensityHistogram::write(int numAtoms, string base_name)
00057 {
00058
00059
00060 ofstream out((base_name+".rdh").c_str());
00061 out.precision(Cluster::PRECISION);
00062 out.setf(ios::scientific);
00063 out.setf(ios::showpos);
00064
00065 double aconst=(4.0*m_pi/3.0);
00066 double del = (m_max - m_min)/m_bins;
00067
00068
00069
00070 double rlower,rupper,ravge,vol,r;
00071 for(int i = 0; i < m_bins; ++i)
00072 {
00073 rlower=i*del + m_min;
00074 rupper=rlower + del;
00075 ravge=(rupper + rlower)/2.;
00076 vol=aconst*( pow(rupper,3) - pow(rlower,3) );
00077 if(m_histogramBin[i] != 0)
00078 r=( (double)(m_histogramBin[i]) )/(( (double)(m_numberHistogramsTaken) )*vol);
00079 else
00080 r=0.;
00081 out << ravge << " " << r << "\n";
00082 }
00083
00084 out.close();
00085
00086
00087 return;
00088 }
00089
00090