8#include "RadialDistribution.h"
9#include <util/math/feq.h>
10#include <util/format/Int.h>
11#include <util/format/Dbl.h>
23 outputIntegral_(false)
32 nSnapshot_(other.nSnapshot_),
33 outputIntegral_(other.outputIntegral_)
47 nSnapshot_ = other.nSnapshot_;
58 read<double>(in,
"max",
max_);
59 read<int>(in,
"nBin",
nBin_);
84 loadParameter<double>(ar,
"max",
max_);
85 loadParameter<int>(ar,
"nBin",
nBin_);
94 UTIL_THROW(
"Inconsistent value for binWidth_");
132 { outputIntegral_ = outputIntegral; }
139 double r, rho, prefactor, dV, hist, integral;
140 prefactor = 4.0*3.14159265359/3.0;
143 for (
int i=0; i <
nBin_; ++i) {
145 dV = prefactor*double(3*i*i + 3*i + 1);
146 hist = double(
histogram_[i])/double(nSnapshot_);
147 rho = hist/(dV*norm_);
148 out <<
Dbl(r, 18, 8) <<
Dbl(rho, 18, 8);
149 if (outputIntegral_) {
150 integral += (hist - dV*norm_)/norm_;
151 out <<
Dbl(integral, 18, 8);
int capacity() const
Return allocated size.
Saving archive for binary istream.
Saving / output archive for binary ostream.
void allocate(int capacity)
Allocate the underlying C array.
Wrapper for a double precision number, for formatted ostream output.
A distribution (or histogram) of values for a real variable.
int nBin() const
Get the number of bins.
double binWidth_
width of bin = (max_-min_)/nBin_ .
double min_
minimum value.
DArray< long > histogram_
Histogram of occurences, one element per bin.
double max_
maximum value.
Distribution & operator=(const Distribution &other)
Assignment operator.
int nSample_
Number of sampled values in Histogram.
int nReject_
Number of sampled values that were out of range.
virtual void clear()
Clear (i.e., zero) previously allocated histogram.
double max() const
Get maximum value in range of histogram.
void setClassName(const char *className)
Set class name string.
Distribution (or histogram) of values for particle separations.
void setParam(double max, int nBin)
Set parameters and initialize.
virtual void readParameters(std::istream &in)
Read values of min, max, and nBin from file.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
void setNorm(double norm)
Set the factor used to normalize the RDF before output.
RadialDistribution()
Default constructor.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void setOutputIntegral(bool outputIntegral)
Set true to enable output of spatial integral of g(r).
RadialDistribution & operator=(const RadialDistribution &other)
Assignment.
void output(std::ostream &out)
Output the distribution to file.
void beginSnapshot()
Mark the beginning of a "snapshot" (i.e., a sampled time step).
virtual void clear()
Clear all accumulators.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
bool feq(double x, double y, double eps=1.0E-10)
Are two floating point numbers equal to within round-off error?
Utility classes for scientific computation.