6#include <deal.II/base/exceptions.h>
11#ifdef LETHE_WITH_QMOMKIT
12# include <qmomkit/distributions.hpp>
19 <<
"The scalars function of the QMOM " << arg1 <<
" has " << arg2
20 <<
" expressions, but the QMOM physics transports " << arg3
21 <<
" scalars (the \"number of scalars\" of the QMOM subsection)."
23 <<
"Give one expression per scalar, separated by semicolons.");
27 <<
"The number density of the particle size distribution of "
28 <<
"the QMOM physics must be positive or zero, but it is "
29 << arg1 <<
" particles/m^3.");
33 <<
"QMOMKit could not compute the moments of the particle size "
34 <<
"distribution of the QMOM physics: " << arg1 << std::endl
35 <<
"Check the parameters of the distribution.");
42 const std::string &description)
51 QMOMScalarExpressionsCountError(description,
55#ifndef LETHE_WITH_QMOMKIT
57 AssertThrow(
functions.distribution_type ==
59 QMOMWithoutQMOMKitError());
66 const unsigned int component)
const
68 AssertIndexRange(component, this->n_components);
73 return functions.scalars->value(p, component);
81 Vector<double> &values)
const
83 AssertDimension(values.size(), this->n_components);
85 for (
unsigned int i_scalar = 0; i_scalar <
n_scalars; ++i_scalar)
86 values[i_scalar] =
functions.scalars->value(p, i_scalar);
89 for (
unsigned int i_moment = 0; i_moment <
n_moments; ++i_moment)
90 values[
n_scalars + i_moment] = moments[i_moment];
96 Vector<double> &values)
const
98 AssertDimension(values.size(),
n_scalars);
100 for (
unsigned int i_scalar = 0; i_scalar <
n_scalars; ++i_scalar)
101 values[i_scalar] =
functions.scalars->value(p, i_scalar);
107 Vector<double> &values)
const
109 AssertDimension(values.size(),
n_moments);
112 for (
unsigned int i_moment = 0; i_moment <
n_moments; ++i_moment)
113 values[i_moment] = moments[i_moment];
120 Function<dim>::set_time(new_time);
127 [[maybe_unused]]
const Point<dim> &p)
const
131 std::vector<double> moments(
n_moments, 0.);
132 if (
functions.distribution_type == DistributionType::none)
135#ifdef LETHE_WITH_QMOMKIT
137 Vector<double> distribution_values(
functions.distribution->n_components);
138 functions.distribution->vector_value(p, distribution_values);
139 const double number_density = distribution_values[0];
141 AssertThrow(number_density >= 0.,
142 QMOMNegativeNumberDensityError(number_density));
145 if (number_density <= 0.)
148 qmomkit::DistributionSpecification distribution;
151 case DistributionType::normal:
153 qmomkit::NormalDistribution{.mean = distribution_values[1],
154 .standard_deviation =
155 distribution_values[2]};
157 case DistributionType::lognormal:
159 qmomkit::LogNormalDistribution{.normal_mean = distribution_values[1],
160 .normal_standard_deviation =
161 distribution_values[2]};
163 case DistributionType::gamma:
165 qmomkit::GammaDistribution{.shape = distribution_values[1],
166 .scale = distribution_values[2]};
168 case DistributionType::weibull:
170 qmomkit::WeibullDistribution{.shape = distribution_values[1],
171 .scale = distribution_values[2]};
173 case DistributionType::beta:
175 qmomkit::BetaDistribution{.alpha = distribution_values[1],
176 .beta = distribution_values[2]};
178 case DistributionType::chi:
179 distribution = qmomkit::ChiDistribution{.degrees_of_freedom =
180 distribution_values[1]};
182 case DistributionType::chi_squared:
183 distribution = qmomkit::ChiSquaredDistribution{
184 .degrees_of_freedom = distribution_values[1]};
186 case DistributionType::none:
187 Assert(
false, ExcInternalError());
191 const qmomkit::RawMomentResult result =
192 qmomkit::compute_raw_moments(distribution,
n_moments - 1, number_density);
193 AssertThrow(result.ok(), QMOMKitMomentsError(result.message));
195 for (
unsigned int i_moment = 0; i_moment <
n_moments; ++i_moment)
196 moments[i_moment] = result.moments[i_moment];
Function of all the QMOM fields, built from the functions of the scalars and from the particle size d...
double value(const Point< dim > &p, const unsigned int component) const override
Evaluate one component of the function: scalar component if component < n_scalars,...
void vector_value(const Point< dim > &p, Vector< double > &values) const override
Evaluate all the components of the function. The moments are computed once for all of them.
Parameters::QMOMFunctions< dim > functions
Functions of the scalars and particle size distribution.
const unsigned int n_scalars
Number of scalars.
void moment_values(const Point< dim > &p, Vector< double > &values) const
Evaluate the moments only, indexed from 0 regardless of the scalars. The moments are computed once fo...
void set_time(const double new_time) override
Set the time of the function and of the underlying functions.
QMOMFieldFunction(const Parameters::QMOMFunctions< dim > &functions, const unsigned int n_scalars, const unsigned int n_moments, const std::string &description)
Constructor. Verifies that the scalars function has one component per scalar, unless there are no sca...
const unsigned int n_moments
Number of moments.
std::vector< double > compute_moments(const Point< dim > &p) const
Compute the raw moments of the particle size distribution at a point.
void scalar_values(const Point< dim > &p, Vector< double > &values) const
Evaluate the scalars only, indexed from 0 regardless of the moments.
QMOMDistributionType
Family of the particle size distribution from which the moments of the QMOM physics are computed....
DeclException3(QMOMScalarExpressionsCountError, std::string, unsigned int, unsigned int,<< "The scalars function of the QMOM "<< arg1<< " has "<< arg2<< " expressions, but the QMOM physics transports "<< arg3<< " scalars (the \"number of scalars\" of the QMOM subsection)."<< std::endl<< "Give one expression per scalar, separated by semicolons.")
DeclException1(QMOMNegativeNumberDensityError, double,<< "The number density of the particle size distribution of "<< "the QMOM physics must be positive or zero, but it is "<< arg1<< " particles/m^3.")
Vector-valued function of the fields of the quadrature method of moments (QMOM) physics: the scalars ...
Functions of space and time prescribing the fields of the QMOM physics. They are used for the initial...