Skip to content

Commit

Permalink
fix: correct forumlar for dN_dr
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Apr 29, 2024
1 parent 7b243c3 commit ecb13e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 8 additions & 10 deletions libs/cartesiandomain/add_supers_at_domain_top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ std::pair<size_t, double> CreateSuperdrop::new_xi_radius(const double gbxvolume)
const auto log10r = double{log10rlow + frac * log10rwidth};
const auto radius = double{Kokkos::pow(10.0, log10r)};

const auto numconc = droplet_numconc_distribution(radius, log10rwidth);
const auto binwidth = double{Kokkos::pow(10.0, log10rup) - Kokkos::pow(10.0, log10rlow)};
const auto numconc = droplet_numconc_distribution(radius, binwidth);
const auto xi = (uint64_t)std::round(numconc * gbxvolume); // cast double to uint64_t

return std::make_pair(xi, radius); // xi_radius
Expand All @@ -156,19 +157,16 @@ double CreateSuperdrop::new_msol(const double radius) const {
}

/* returns the droplet number concentration from a binned droplet number concentration
distribution for a bin of width log10rwidth in log_10(r) space centred at radius. */
distribution for a bin of width 'binwidth' (in radius space) centred at radius. */
double CreateSuperdrop::droplet_numconc_distribution(const double radius,
const double log10rwidth) const {
const auto dnumconc_dlnr = numconc * lognormal_pdf(radius); // delta_numconc / delta_lnr
const auto dlnr = log10rwidth * std::log(10); // convert delta_log10(r) into delta_ln(r)

return dnumconc_dlnr * dlnr; // number of droplets per unit volume
const double binwidth) const {
const auto dnumconc_dradius = numconc * lognormal_pdf(radius); // delta_numconc / delta_radius
return dnumconc_dradius * binwidth; // number of droplets per unit volume
}

/* normalised lognormal distribution returns the probability density of a given radius */
double CreateSuperdrop::lognormal_pdf(const double radius) const {
const auto RADIUS = radius * dlc::R0;
const auto inverse_norm = RADIUS * sigtilda * std::sqrt(2.0 * std::numbers::pi);
const auto expo = (std::log(RADIUS) - MUtilda) / sigtilda;
const auto inverse_norm = radius * sigtilda * std::sqrt(2.0 * std::numbers::pi);
const auto expo = (std::log(radius) - mutilda) / sigtilda;
return std::exp(-0.5 * expo * expo) / inverse_norm;
}
4 changes: 2 additions & 2 deletions libs/cartesiandomain/add_supers_at_domain_top.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct CreateSuperdrop {
std::vector<double> log10redges; /**< edges of bins for superdroplet log_10(radius) */
double dryradius; /**< dry radius of new superdrop */
double numconc; /**< number concentration of new droplets*/
double MUtilda; /**< ln(geometric mean) of lognormal distribution */
double mutilda; /**< ln(geometric mean) of lognormal distribution */
double sigtilda; /**< ln(geometric sigma) of lognormal distribution */

/* create spatial coordinates for super-droplet by setting coord1 = coord2 = 0.0 and coord3 to a
Expand Down Expand Up @@ -85,7 +85,7 @@ struct CreateSuperdrop {
log10redges(),
dryradius(config.DRYRADIUS / dlc::R0),
numconc(config.NUMCONC * dlc::VOL0),
MUtilda(std::log(config.GEOMEAN)),
mutilda(std::log(config.GEOMEAN / dlc::R0)),
sigtilda(std::log(config.geosigma)) {
const auto log10rmin = std::log10(config.MINRADIUS / dlc::R0);
const auto log10rmax = std::log10(config.MAXRADIUS / dlc::R0);
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ boundary_conditions:
DRYRADIUS: 1e-9 # dry radius of new super-droplets (for solute mass) [m]
MINRADIUS: 1e-7 # minimum radius of new super-droplets [m]
MAXRADIUS: 1e-4 # maximum radius of new super-droplets [m]
NUMCONC: 500e6 # number concentration of new droplets [m^-3]
NUMCONC: 1e9 # number concentration of new droplets [m^-3]
GEOMEAN: 3.5e-6 # geometric mean radius of lognormal distribution [m]
geosigma: 2.0 # geometric standard deviation of lognormal distribution

0 comments on commit ecb13e8

Please sign in to comment.