|
Contains a vector with radii and probabilities of a user defined particle size distribution (PSD) More...
#include <PSD.h>
Public Types | |
enum class | TYPE { CUMULATIVE_NUMBER_DISTRIBUTION , CUMULATIVE_LENGTH_DISTRIBUTION , CUMULATIVE_VOLUME_DISTRIBUTION , CUMULATIVE_AREA_DISTRIBUTION , PROBABILITYDENSITY_NUMBER_DISTRIBUTION , PROBABILITYDENSITY_LENGTH_DISTRIBUTION , PROBABILITYDENSITY_AREA_DISTRIBUTION , PROBABILITYDENSITY_VOLUME_DISTRIBUTION } |
Enum class which stores the possible types of CDFs and PDFs. Particle size distributions can be represented by different probabilities based on number of particles, length of particles, surface area of particles or volume of particles. More... | |
Public Member Functions | |
PSD () | |
Constructor; sets everything to 0 or default. More... | |
PSD (const PSD &other) | |
Copy constructor with deep copy. More... | |
~PSD () | |
Destructor; default destructor. More... | |
PSD * | copy () const |
Creates a copy on the heap and returns a pointer. More... | |
void | printPSD () const |
Prints radii and probabilities of the PSD vector. More... | |
Mdouble | drawSample () |
Draw a sample radius from a CUMULATIVE_NUMBER_DISTRIBUTION. More... | |
Mdouble | insertManuallyByVolume (Mdouble volume) |
Draw sample radius manually per size class and check the volumeAllowed of each size class to insert the PSD as accurate as possible. More... | |
void | validateCumulativeDistribution () |
Validates if a CDF starts with zero and adds up to unity. More... | |
void | validateProbabilityDensityDistribution () |
Validates if the integral of the PDF equals to unity. More... | |
MERCURYDPM_DEPRECATED void | setPSDFromVector (std::vector< DistributionElements > psd, TYPE PSDType) |
Deprecated version of reading in PSDs from a vector. More... | |
void | setPSDFromCSV (const std::string &fileName, TYPE PSDType, bool headings=false, Mdouble unitScalingFactorRadii=1.0) |
read in the PSD vector with probabilities and radii saved in a .csv file. More... | |
void | setDistributionUniform (Mdouble radMin, Mdouble radMax, int numberOfBins) |
create a PSD vector for a uniform distribution. More... | |
void | setDistributionNormal (Mdouble mean, Mdouble standardDeviation, int numberOfBins) |
create a PSD vector for a normal distribution. More... | |
void | setDistributionLogNormal (Mdouble mean, Mdouble standardDeviation, int numberOfBins) |
create a PSD vector for a normal distribution. More... | |
void | convertProbabilityDensityToCumulative () |
Converts a PDF to a CDF by integration. More... | |
void | convertCumulativeToProbabilityDensity () |
Converts a CDF to a PDF by derivation. More... | |
void | convertProbabilityDensityToProbabilityDensityNumberDistribution (TYPE PDFType) |
convert any PDF to a PROBABILITYDENSITY_NUMBER_DISTRIBUTION. More... | |
void | convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution () |
convert a PROBABILITYDENSITY_NUMBER_DISTRIBUTION to a PROBABILITYDENSITY_VOLUME_DISTRIBUTION. More... | |
void | convertCumulativeToCumulativeNumberDistribution (TYPE CDFType) |
convert any other CDF to a CUMULATIVE_NUMBER_DISTRIBUTION. More... | |
void | cutoffCumulativeNumber (Mdouble quantileMin, Mdouble quantileMax, Mdouble minPolydispersity=0.1) |
cutoff the PSD at given quantiles. More... | |
void | cutoffAndSqueezeCumulative (Mdouble quantileMin, Mdouble quantileMax, Mdouble squeeze, Mdouble minPolydispersity=0.1) |
cutoff the PSD at given quantiles and make it less polydisperse by squeezing it. More... | |
Mdouble | getMinRadius () const |
Get smallest radius of the PSD. More... | |
Mdouble | getMaxRadius () const |
Get largest radius of the PSD. More... | |
std::vector< DistributionElements > | getParticleSizeDistribution () const |
Get the PSD vector. More... | |
void | setParticleSizeDistribution (std::vector< DistributionElements >) |
set the PSD by a suitable vector. More... | |
int | getInsertedParticleNumber () const |
Get the number of particles already inserted into the simulation. More... | |
void | decrementNParticlesPerClass () |
Decrement nParticlesPerClass_ counter. More... | |
void | decrementVolumePerClass (Mdouble volume) |
Decrement volumePerClass_ counter. More... | |
Mdouble | getRadius (int index) const |
get a radius at a certain index of the particleSizeDistribution_ More... | |
Mdouble | getNumberDx (Mdouble x) const |
Calculate a certain diameter (e.g. D10, D50, D90, etc.) from a percentile x of the number based PSD. More... | |
Mdouble | getVolumeDx (Mdouble x) const |
Calculate a certain diameter (e.g. D10, D50, D90, etc.) from a percentile x of the volume based PSD. More... | |
Mdouble | getRadiusByQuantile (Mdouble quantile) const |
Calculate the quantile of the PSD. More... | |
Mdouble | getQuantileByRadius (Mdouble radius) const |
Calculates the quantile corresponding to a certain radius. More... | |
Mdouble | getVolumetricMeanRadius () const |
get a volumetric mean radius of the PSD. More... | |
Mdouble | getSizeRatio () const |
get the size ratio (width) of the PSD. More... | |
void | cutHighSizeRatio () |
Check if the size ratio is too high and cut it. More... | |
void | setFixedSeed (int seed) |
set a fixed seed for the random number generator; this is used for the PSDSelfTest to reproduce results More... | |
Static Public Member Functions | |
static PSD | getDistributionNormal (Mdouble mean, Mdouble standardDeviation, int numberOfBins) |
static PSD | getDistributionLogNormal (Mdouble mean, Mdouble standardDeviation, int numberOfBins) |
static std::vector< Mdouble > | linspace (Mdouble Min, Mdouble Max, int numberOfBins) |
compute central momenta of the user defined PSD. / void computeCentralMomenta(); More... | |
Private Attributes | |
std::vector< DistributionElements > | particleSizeDistribution_ |
std::vector< int > | nParticlesPerClass_ |
std::vector< Mdouble > | volumePerClass_ |
int | index_ |
RNG | random_ |
Friends | |
bool | operator< (const DistributionElements &l, const DistributionElements &r) |
determines if a certain value of the PSD vector is lower than another one. Used for std::lower_bound() More... | |
bool | operator< (const DistributionElements &l, Mdouble r) |
determines if a certain value of the PSD vector is lower than a double. More... | |
std::ostream & | operator<< (std::ostream &os, DistributionElements &p) |
Writes to output stream. More... | |
std::istream & | operator>> (std::istream &is, DistributionElements &p) |
Reads from input stream. More... | |
Mdouble | operator== (DistributionElements l, Mdouble r) |
Determines if a certain value of the PSD vector is equal to a double. More... | |
Contains a vector with radii and probabilities of a user defined particle size distribution (PSD)
Stores radii and probabilities of a particle size distribution (PSD) in a vector of type DistributionElements and converts them to a PSD which can be used by insertionBoundaries which insert particles into a simulation:
Cumulative distribution function (CDF): gives percentage of particles p_i whose radius r is less than a certain radius r_i. It requires p_0 = 0 and p_end = 1. The CDF's probabilities can be number, length, area or volume based. The cumulative number distribution function (CUMULATIVE_NUMBER_DISTRIBUTION) is used as PSD in MercuryDPM, as it can be interpreted as the probability that a particle's radius is less than r_i: CDF(r<r_i) = p_i.
Probability density function (PDF): p_i is the percentage of particles whose radius is between r_i-1 and r_i. It requires p_0=0 and sum(p_i)=1. The PDF's probabilities can also be number, length, area or volume based. PDF's are utilized to convert any type of PDF to a probability number density function (PROBABILITYDENSITY_NUMBER_DISTRIBUTION) which in a next step are converted to the default CUMULATIVE_NUMBER_DISTRIBUTION.
Sieve data: p_i is the percentage of particles whose radius is between r_i and r_i+1. It requires sum(p_i)=1. relation to PDF: p_i = p(PDF)_i-1. Sieve data is not yet used in this class.
Default distribution is the CUMULATIVE_NUMBER_DISTRIBUTION.
|
strong |
Enum class which stores the possible types of CDFs and PDFs. Particle size distributions can be represented by different probabilities based on number of particles, length of particles, surface area of particles or volume of particles.
PSD::PSD | ( | ) |
Constructor; sets everything to 0 or default.
Default constructor; sets every data member to 0 or default.
References index_, random_, and RNG::setRandomSeed().
Referenced by copy().
PSD::PSD | ( | const PSD & | other | ) |
Copy constructor with deep copy.
Copy constructor
References index_, particleSizeDistribution_, and random_.
|
default |
Destructor; default destructor.
Destructor. Since there are no pointers in this class, there is no need for any actions here.
void PSD::convertCumulativeToCumulativeNumberDistribution | ( | TYPE | CDFType | ) |
convert any other CDF to a CUMULATIVE_NUMBER_DISTRIBUTION.
converts any of the CDFTypes to a the default CUMULATIVE_NUMBER_DISTRIBUTION based on their TYPE.
[in] | PDFType | Type of the PDF: PROBABILITYDENSITY_LENGTH_DISTRIBUTION, PROBABILITYDENSITY_AREA_DISTRIBUTION or PROBABILITYDENSITY_VOLUME_DISTRIBUTION, Where L = Length, A = Area and V = Volume. |
References CUMULATIVE_AREA_DISTRIBUTION, CUMULATIVE_LENGTH_DISTRIBUTION, CUMULATIVE_VOLUME_DISTRIBUTION, ERROR, logger, and particleSizeDistribution_.
Referenced by PSDSelfTest::setupInitialConditions().
void PSD::convertCumulativeToProbabilityDensity | ( | ) |
Converts a CDF to a PDF by derivation.
Convert any type of CDF to a PDF. Probabilities are derivated for each radius by substracting the CDF probabilities (i.e. pPDF_i = pCDF_i - pCDF_i-1).
References particleSizeDistribution_, and validateProbabilityDensityDistribution().
Referenced by getVolumeDx(), getVolumetricMeanRadius(), insertManuallyByVolume(), setPSDFromCSV(), and setPSDFromVector().
void PSD::convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution | ( | ) |
convert a PROBABILITYDENSITY_NUMBER_DISTRIBUTION to a PROBABILITYDENSITY_VOLUME_DISTRIBUTION.
converts a PROBABILITYDENSITY_NUMBER_DISTRIBUTION to a PROBABILITYDENSITY_VOLUME_DISTRIBUTION. Used for getVolumetricMeanRadius() and insertManuallyByVolume().
References particleSizeDistribution_, and mathsFunc::square().
Referenced by getVolumeDx(), getVolumetricMeanRadius(), and insertManuallyByVolume().
void PSD::convertProbabilityDensityToCumulative | ( | ) |
Converts a PDF to a CDF by integration.
Convert any type of PDF to a CDF. Probabilities are integrated for each radius by cumulatively summing them up (i.e. p_i = p_i + p_i-1).
References particleSizeDistribution_, and validateCumulativeDistribution().
Referenced by getVolumeDx(), insertManuallyByVolume(), setPSDFromCSV(), and setPSDFromVector().
void PSD::convertProbabilityDensityToProbabilityDensityNumberDistribution | ( | TYPE | PDFType | ) |
convert any PDF to a PROBABILITYDENSITY_NUMBER_DISTRIBUTION.
converts any of the PDFTypes to a PROBABILITYDENSITY_NUMBER_DISTRIBUTION based on their TYPE. This is a helper function which enables the convertProbabilityDensityToCumulative function to convert the psd into the default TYPE (CUMULATIVE_NUMBER_DISTRIBUTION).
[in] | PDFType | Type of the PDF: PROBABILITYDENSITY_LENGTH_DISTRIBUTION, PROBABILITYDENSITY_AREA_DISTRIBUTION or PROBABILITYDENSITY_VOLUME_DISTRIBUTION, Where L = Length, A = Area and V = Volume. |
References ERROR, logger, particleSizeDistribution_, PROBABILITYDENSITY_AREA_DISTRIBUTION, PROBABILITYDENSITY_LENGTH_DISTRIBUTION, PROBABILITYDENSITY_VOLUME_DISTRIBUTION, and mathsFunc::square().
Referenced by insertManuallyByVolume(), setPSDFromCSV(), and setPSDFromVector().
PSD * PSD::copy | ( | ) | const |
Creates a copy on the heap and returns a pointer.
Copy method; creates a copy on the heap and returns its pointer.
References PSD().
void PSD::cutHighSizeRatio | ( | ) |
Check if the size ratio is too high and cut it.
Checks if the Size ratio of the PSD is too high and cuts the PSD at head and tail by 10 percent to avoid inaccurate results.
References cutoffCumulativeNumber(), getSizeRatio(), logger, and WARN.
void PSD::cutoffAndSqueezeCumulative | ( | Mdouble | quantileMin, |
Mdouble | quantileMax, | ||
Mdouble | squeeze, | ||
Mdouble | minPolydispersity = 0.1 |
||
) |
cutoff the PSD at given quantiles and make it less polydisperse by squeezing it.
Cuts off the CDF at given minimum and maximum quantiles, applies a minimum polydispersity at the base and squeezes the distribution to make it less polydisperse.
[in] | quantileMin | undersize quantile to cut off the lower part of the CDF. |
[in] | quantileMax | oversize quantile to cut off the upper part of the CDF. |
[in] | squeeze | applies a squeezing factor ([0,1]) which determines the degree the PDF gets squeezed. |
[in] | minPolydispersity | applies a minimum of polydispersity ([0,1]) at the base of the CDF. |
References cutoffCumulativeNumber(), getNumberDx(), and particleSizeDistribution_.
void PSD::cutoffCumulativeNumber | ( | Mdouble | quantileMin, |
Mdouble | quantileMax, | ||
Mdouble | minPolydispersity = 0.1 |
||
) |
cutoff the PSD at given quantiles.
Cuts off the CDF at given minimum and maximum quantiles and applies a minimum polydispersity at the base.
[in] | quantileMin | undersize quantile to cut off the lower part of the CDF. |
[in] | quantileMax | oversize quantile to cut off the upper part of the CDF. |
[in] | minPolydispersity | Applies a minimum of polydispersity ([0,1]) at the base of the CDF. |
References getRadiusByQuantile(), getSizeRatio(), INFO, logger, and particleSizeDistribution_.
Referenced by cutHighSizeRatio(), and cutoffAndSqueezeCumulative().
void PSD::decrementNParticlesPerClass | ( | ) |
Decrement nParticlesPerClass_ counter.
Decrement the nParticlesPerClass_ counter of the last inserted class by 1. This is utilized when a particle is generated but failed to be placed into an insertionBoundary.
References index_, and nParticlesPerClass_.
void PSD::decrementVolumePerClass | ( | Mdouble | volume | ) |
Decrement volumePerClass_ counter.
Decrement the volumePerClass_ counter of the last inserted class by the volume of the particle. This is utilized when a particle is generated but failed to be placed into an insertionBoundary.
[in] | volume | Volume of the particle which failed to be inserted. |
References index_, and volumePerClass_.
Mdouble PSD::drawSample | ( | ) |
Draw a sample radius from a CUMULATIVE_NUMBER_DISTRIBUTION.
Draws a sample probability of a real uniform distribution. A random number is generated in range [0,1] and by linear interpolation a suitable radius is returned. This function is only valid for CumulativeNumberDistributions as particles are drawn and not volumes, areas or lengths.
References RNG::getRandomNumber(), particleSizeDistribution_, and random_.
|
inlinestatic |
References setDistributionLogNormal().
Referenced by DistributionSelfTest::setupInitialConditions().
|
inlinestatic |
References setDistributionNormal().
Referenced by Material::setPSD(), Drum::setupInitialConditions(), and RotatingDrumWet::setupInitialConditions().
int PSD::getInsertedParticleNumber | ( | ) | const |
Get the number of particles already inserted into the simulation.
Gets the number of particles already inserted into the simulation by summing up the particles inserted in each class.
References nParticlesPerClass_.
Mdouble PSD::getMaxRadius | ( | ) | const |
Get largest radius of the PSD.
Gets the maximum radius of the PSD.
References particleSizeDistribution_.
Referenced by getSizeRatio(), GranuDrum::GranuDrum(), and GranuHeap::GranuHeap().
Mdouble PSD::getMinRadius | ( | ) | const |
Get smallest radius of the PSD.
Gets the minimal radius of the PSD.
References particleSizeDistribution_.
Referenced by getSizeRatio(), GranuHeap::GranuHeap(), Calibration::setSpecies(), and Material::setSpecies().
Calculate a certain diameter (e.g. D10, D50, D90, etc.) from a percentile x of the number based PSD.
Gets the diameter from a certain percentile of the number based PSD.
[in] | x | double which determines the obtained diameter as a percentile of the PSD. |
References getRadiusByQuantile().
Referenced by cutoffAndSqueezeCumulative(), and GranuHeap::GranuHeap().
std::vector< DistributionElements > PSD::getParticleSizeDistribution | ( | ) | const |
Get the PSD vector.
Gets the vector containing radii and probabilities of the PSD.
References particleSizeDistribution_.
Calculates the quantile corresponding to a certain radius.
Calculates the quantile corresponding to a certain radius.
radius | The radius to find the quantile for. |
References particleSizeDistribution_.
Mdouble PSD::getRadius | ( | int | index | ) | const |
get a radius at a certain index of the particleSizeDistribution_
\details Compute the raw momenta of the inserted PSD by converting it to a PDF, calculating the moments m_i according to \f$ m_i = \sum_{j=0}^n \f$ scaling it by the number of particles inserted into the simulation (moments are computed from a PROBABILITYDENSITY_NUMBER_DISTRIBUTION) and converting it back to a CDF. See <a href="https://en.wikipedia.org/wiki/Moment_(mathematics)#Significance_of_the_moments">Wikipedia</a> for details. ‍/
void PSD::computeRawMomenta() { convertCumulativeToProbabilityDensity(); for (size_t im = 0; im < momenta_.size(); ++im) { // prevent summing up of moments for each time step of the simulation momenta_[im] = 0; for (auto& it : particleSizeDistribution_) { momenta_[im] += std::pow(it.internalVariable, im) * it.probability; } } // zeroth-moment equals particle number for a PROBABILITYDENSITY_NUMBER_DISTRIBUTION momenta_[0] *= getInsertedParticleNumber(); convertProbabilityDensityToCumulative(); }
/*!
Compute the central momenta of the PSD from their respective raw momenta. / void PSD::computeCentralMomenta() { computeRawMomenta(); Mdouble mean = momenta_[1]; momenta_[5] += -5 * mean * momenta_[4] + 10 * mean * mean * momenta_[3]
/*!
Compute the standardised momenta of the PSD from their respective central momenta. / void PSD::computeStandardisedMomenta() { computeCentralMomenta(); Mdouble std = std::sqrt(momenta_[2]); momenta_[3] /= std * std * std; momenta_[4] /= std * std * std * std; momenta_[5] /= std * std * std * std * std; }
/*!
Gets the radius of a particle from the PSD.
[in] | i | An integer which is the index of the vector containing the radius. |
References particleSizeDistribution_.
Calculate the quantile of the PSD.
gets the radius from a certain quantile of the PSD
[in] | quantile | double which determines the returned radius as a quantile of the PSD. |
References logger, and particleSizeDistribution_.
Referenced by cutoffCumulativeNumber(), getNumberDx(), and getVolumeDx().
Mdouble PSD::getSizeRatio | ( | ) | const |
get the size ratio (width) of the PSD.
Gets the size ratio (width) of the PSD defined by the ratio of minimum to maximum particle radius.
References getMaxRadius(), and getMinRadius().
Referenced by cutHighSizeRatio(), cutoffCumulativeNumber(), and setPSDFromCSV().
Calculate a certain diameter (e.g. D10, D50, D90, etc.) from a percentile x of the volume based PSD.
Gets the diameter from a certain percentile of the volume based PSD.
[in] | x | double which determines the obtained diameter as a percentile of the PSD. |
References convertCumulativeToProbabilityDensity(), convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution(), convertProbabilityDensityToCumulative(), and getRadiusByQuantile().
Referenced by GranuDrum::GranuDrum(), GranuHeap::GranuHeap(), Calibration::setSpecies(), and Material::setSpecies().
Mdouble PSD::getVolumetricMeanRadius | ( | ) | const |
get a volumetric mean radius of the PSD.
Gets a radius such that a monodisperse system has the same number of particles as a polydisperse system. (i.e. mean += p_i * 0.5*(r_i^3 + r_i-1^3)
References convertCumulativeToProbabilityDensity(), convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution(), mathsFunc::cubic(), and particleSizeDistribution_.
Draw sample radius manually per size class and check the volumeAllowed of each size class to insert the PSD as accurate as possible.
Draws a sample probability of a real uniform distribution within a given size class. A random number is generated in the size class range [r_i,r_i+1] and by linear interpolation a suitable radius is returned. from a CUMULATIVE_VOLUME_DISTRIBUTION the volumeAllowed of each class is checked to insert the PSD as accurate as possible. This function is only valid for cumulativeNumberDistributions as particles are drawn and not volumes, areas or lengths. Furthermore this insertion routine is most accurate for non-continuous particle insertion.
[in] | volume | volume of the geometry to be filled. |
References convertCumulativeToProbabilityDensity(), convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution(), convertProbabilityDensityToCumulative(), convertProbabilityDensityToProbabilityDensityNumberDistribution(), index_, nParticlesPerClass_, particleSizeDistribution_, constants::pi, PROBABILITYDENSITY_VOLUME_DISTRIBUTION, and volumePerClass_.
compute central momenta of the user defined PSD. / void computeCentralMomenta();
\brief compute raw momenta of the user defined PSD. ‍/
void computeRawMomenta();
/*!
/*!
compute standardised momenta of the user defined PSD. / void computeStandardisedMomenta();
/*!
get momenta of the user defined PSD. / std::array<Mdouble, 6> getMomenta() const;
/*! \brief create a vector of linearly spaced values.
creates a vector of doubles containing linearly spaced values between Min and Max.
[in] | Min | A double which is the minimum value of the vector. |
[in] | Max | A double which is the maximum value of the vector. |
[in] | numberOfBins | An integer which is the number of bins of the vector. |
Referenced by setDistributionLogNormal(), setDistributionNormal(), and setDistributionUniform().
void PSD::printPSD | ( | ) | const |
Prints radii and probabilities of the PSD vector.
Prints the radii [m] and probabilities [%] of the psd vector. It currently supports nanometers, micrometers, milimeters and meters as size units.
References INFO, logger, and particleSizeDistribution_.
create a PSD vector for a normal distribution.
sets the particle size distribution to a discretised normal (gaussian) cumulative number distribution, which covers the range of 3 * standardDeviation (99,73% of all values covered).
[in] | mean | Double representing the mean of the particle size distribution |
[in] | standardDeviation | Double representing the standard deviation of the particle size distribution |
[in] | numberOfBins | Integer determining the number of bins (aka. particle size classes or resolution) of the particle size distribution See https://en.cppreference.com/w/cpp/numeric/random/lognormal_distribution |
References mathsFunc::exp(), constants::i, linspace(), particleSizeDistribution_, and validateCumulativeDistribution().
Referenced by getDistributionLogNormal().
create a PSD vector for a normal distribution.
sets the particle size distribution to a discretised normal (gaussian) cumulative number distribution, which covers the range of 3 * standardDeviation (99,73% of all values covered).
[in] | mean | Double representing the mean of the particle size distribution |
[in] | standardDeviation | Double representing the standard deviation of the particle size distribution |
[in] | numberOfBins | Integer determining the number of bins (aka. particle size classes or resolution) of the particle size distribution |
References constants::i, linspace(), logger, particleSizeDistribution_, and validateCumulativeDistribution().
Referenced by getDistributionNormal(), and DistributionToPSDSelfTest::setupInitialConditions().
create a PSD vector for a uniform distribution.
sets the particle size distribution to a discretised uniform (linear) cumulative number distribution
[in] | radMin | Double representing The smallest particle radius of the particle size distribution |
[in] | radMax | Double representing the biggest particle radius of the particle size distribution |
[in] | numberOfBins | Integer determining the number of bins (aka. particle size classes or resolution) of the particle size distribution |
References constants::i, linspace(), particleSizeDistribution_, and validateCumulativeDistribution().
Referenced by BoundariesSelfTest::BoundariesSelfTest(), FluxBoundarySelfTest::FluxBoundarySelfTest(), CubeInsertionBoundary::set(), InsertionBoundarySelfTest::setupInitialConditions(), FullRestartTest::setupInitialConditions(), Chute::setupInitialConditions(), ChuteWithHopper::setupInitialConditions(), and T_protectiveWall::T_protectiveWall().
|
inline |
set a fixed seed for the random number generator; this is used for the PSDSelfTest to reproduce results
References random_, and RNG::setRandomSeed().
void PSD::setParticleSizeDistribution | ( | std::vector< DistributionElements > | particleSizeDistribution | ) |
set the PSD by a suitable vector.
sets the PSD from a vector of the DistributionElements class; used to read in PSDs from a restart file.
[in] | particleSizeDistribution | vector containing the radii and probabilities specifying the PSD. |
References particleSizeDistribution_.
Referenced by convertPSD2ToPSD(), and PSDSelfTest::setupInitialConditions().
void PSD::setPSDFromCSV | ( | const std::string & | fileName, |
TYPE | PSDType, | ||
bool | headings = false , |
||
Mdouble | unitScalingFactorRadii = 1.0 |
||
) |
read in the PSD vector with probabilities and radii saved in a .csv file.
creates the PSD vector from probabilities and radii saved in a .csv file. Radii should be located at the first column and probabilities at the second column of the file. The Type of PSD will be converted to the default cumulative number distribution function (CUMULATIVE_NUMBER_DISTRIBUTION) for further processing.
[in] | fileName | Name of the .csv file containing the radii and probabilities of the PSD. |
[in] | PSDType | Type of the PSD: CUMULATIVE_VOLUME_DISTRIBUTION, CUMULATIVE_NUMBER_DISTRIBUTION, CUMULATIVE_LENGTH_DISTRIBUTION, CUMULATIVE_AREA_DISTRIBUTION, PROBABILITYDENSITY_VOLUME_DISTRIBUTION, PROBABILITYDENSITY_NUMBER_DISTRIBUTION, PROBABILITYDENSITY_LENGTH_DISTRIBUTION PROBABILITYDENSITY_AREA_DISTRIBUTION. |
[in] | headings | If TRUE the file is assumed to have headings and the first row will be skipped. If FALSE the file has no headings and the file will be read in as is. Default is FALSE. |
[in] | unitScalingFactorRadii | Scaling factor of radii to match SI-units. |
References convertCumulativeToProbabilityDensity(), convertProbabilityDensityToCumulative(), convertProbabilityDensityToProbabilityDensityNumberDistribution(), CUMULATIVE_AREA_DISTRIBUTION, CUMULATIVE_LENGTH_DISTRIBUTION, CUMULATIVE_VOLUME_DISTRIBUTION, csvReader::getFirstColumn(), csvReader::getSecondColumn(), getSizeRatio(), constants::i, INFO, logger, particleSizeDistribution_, PROBABILITYDENSITY_AREA_DISTRIBUTION, PROBABILITYDENSITY_LENGTH_DISTRIBUTION, PROBABILITYDENSITY_NUMBER_DISTRIBUTION, PROBABILITYDENSITY_VOLUME_DISTRIBUTION, csvReader::read(), csvReader::setHeader(), validateCumulativeDistribution(), and validateProbabilityDensityDistribution().
Referenced by MultiplePSDSelfTest::setupInitialConditions(), PSDManualInsertionSelfTest::setupInitialConditions(), and PSDSelfTest::setupInitialConditions().
MERCURYDPM_DEPRECATED void PSD::setPSDFromVector | ( | std::vector< DistributionElements > | psdVector, |
TYPE | PSDType | ||
) |
Deprecated version of reading in PSDs from a vector.
creates the psd vector from radii and probabilities filled in by hand. The Type of PSD will be converted to the default cumulative number distribution function (CUMULATIVE_NUMBER_DISTRIBUTION) for further processing.
[in] | psdVector | Vector containing radii and probabilities ([0,1]). |
[in] | PSDType | Type of the PSD: CUMULATIVE_VOLUME_DISTRIBUTION, CUMULATIVE_NUMBER_DISTRIBUTION, CUMULATIVE_LENGTH_DISTRIBUTION, CUMULATIVE_AREA_DISTRIBUTION, PROBABILITYDENSITY_VOLUME_DISTRIBUTION, PROBABILITYDENSITY_NUMBER_DISTRIBUTION, PROBABILITYDENSITY_LENGTH_DISTRIBUTION, PROBABILITYDENSITY_AREA_DISTRIBUTION. |
References convertCumulativeToProbabilityDensity(), convertProbabilityDensityToCumulative(), convertProbabilityDensityToProbabilityDensityNumberDistribution(), CUMULATIVE_AREA_DISTRIBUTION, CUMULATIVE_LENGTH_DISTRIBUTION, CUMULATIVE_VOLUME_DISTRIBUTION, particleSizeDistribution_, PROBABILITYDENSITY_AREA_DISTRIBUTION, PROBABILITYDENSITY_LENGTH_DISTRIBUTION, PROBABILITYDENSITY_NUMBER_DISTRIBUTION, PROBABILITYDENSITY_VOLUME_DISTRIBUTION, validateCumulativeDistribution(), and validateProbabilityDensityDistribution().
Referenced by Calibration::setPSD(), and Material::setPSD().
void PSD::validateCumulativeDistribution | ( | ) |
Validates if a CDF starts with zero and adds up to unity.
Validates if a distribution is cumulative by first checking if the psd vector is empty and that the scaling of probabilities is in the range [0,1]. Also it checks if each consecutive value is higher than the latter value (i.e. assuming piecewise linear CDF: p_i > p_i-1). Further it replaces probabilities if the CDF does not start with zero or does not end with unity (i.e. p_0=0 and p_end=1)
References constants::i, INFO, logger, and particleSizeDistribution_.
Referenced by convertProbabilityDensityToCumulative(), setDistributionLogNormal(), setDistributionNormal(), setDistributionUniform(), setPSDFromCSV(), and setPSDFromVector().
void PSD::validateProbabilityDensityDistribution | ( | ) |
Validates if the integral of the PDF equals to unity.
Validates if a PDF is valid by first checking if the PDF starts with zero (i.e. p_0=0). Further it checks if the integral is equal to unity (i.e. assuming piecewise constant PDF: sum(p_i)=1).
References INFO, logger, and particleSizeDistribution_.
Referenced by convertCumulativeToProbabilityDensity(), setPSDFromCSV(), and setPSDFromVector().
|
friend |
determines if a certain value of the PSD vector is lower than another one. Used for std::lower_bound()
Required to use std::lower_bound for finding when the probability is higher than a certain value.
|
friend |
determines if a certain value of the PSD vector is lower than a double.
required to use std::lower_bound for finding when the probability provided as a double is higher than a certain value.
|
friend |
Writes to output stream.
Writes to output stream. This function is used for restart files.
|
friend |
Determines if a certain value of the PSD vector is equal to a double.
Required to use std::distance to find the index of the PSD size class in which a particle has to be inserted
|
friend |
Reads from input stream.
reads from input stream. This function is used for restart files.
|
private |
Integer which determines the class in which a particle has to be inserted for the manual insertion routine.
Referenced by decrementNParticlesPerClass(), decrementVolumePerClass(), insertManuallyByVolume(), and PSD().
|
private |
Vector of integers which represents the number of inserted particles in each size class. The classes in this vector are defined to contain the particles between size r_i and r_i-1. (e.g. size class 12 consists of particles between size class 12 and 11 of the PDF)
Referenced by decrementNParticlesPerClass(), getInsertedParticleNumber(), and insertManuallyByVolume().
|
private |
Vector of the DistributionElements class which stores radii as internalVariable and probabilities of a PSD.
Referenced by convertCumulativeToCumulativeNumberDistribution(), convertCumulativeToProbabilityDensity(), convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution(), convertProbabilityDensityToCumulative(), convertProbabilityDensityToProbabilityDensityNumberDistribution(), cutoffAndSqueezeCumulative(), cutoffCumulativeNumber(), drawSample(), getMaxRadius(), getMinRadius(), getParticleSizeDistribution(), getQuantileByRadius(), getRadius(), getRadiusByQuantile(), getVolumetricMeanRadius(), insertManuallyByVolume(), printPSD(), PSD(), setDistributionLogNormal(), setDistributionNormal(), setDistributionUniform(), setParticleSizeDistribution(), setPSDFromCSV(), setPSDFromVector(), validateCumulativeDistribution(), and validateProbabilityDensityDistribution().
|
private |
Mercury random number generator object used to draw random numbers from a random initial seed
Referenced by drawSample(), PSD(), and setFixedSeed().
|
private |
Vector of doubles which stores the volume of inserted particles for each size class. This vector is used in the insertManuallyByVolume() function to check if the volumeAllowed per class is exceeded and thus no further particles should be added to a certain class. The classes in this vector are defined to contain the volume of particles between size r_i and r_i-1. (e.g. size class 12 consists of the particles' volume between size class 12 and 11 of the PDF)
Referenced by decrementVolumePerClass(), and insertManuallyByVolume().