From ecb13e89c0b1dd9d3bf06af270f6a56be218e4aa Mon Sep 17 00:00:00 2001 From: "clara.bayley" Date: Mon, 29 Apr 2024 23:19:42 +0200 Subject: [PATCH] fix: correct forumlar for dN_dr --- .../add_supers_at_domain_top.cpp | 18 ++++++++---------- .../add_supers_at_domain_top.hpp | 4 ++-- src/config/config.yaml | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libs/cartesiandomain/add_supers_at_domain_top.cpp b/libs/cartesiandomain/add_supers_at_domain_top.cpp index e66ddd86c..b5a32542a 100644 --- a/libs/cartesiandomain/add_supers_at_domain_top.cpp +++ b/libs/cartesiandomain/add_supers_at_domain_top.cpp @@ -138,7 +138,8 @@ std::pair 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 @@ -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; } diff --git a/libs/cartesiandomain/add_supers_at_domain_top.hpp b/libs/cartesiandomain/add_supers_at_domain_top.hpp index 58e212ac4..1dd1800be 100644 --- a/libs/cartesiandomain/add_supers_at_domain_top.hpp +++ b/libs/cartesiandomain/add_supers_at_domain_top.hpp @@ -52,7 +52,7 @@ struct CreateSuperdrop { std::vector 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 @@ -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); diff --git a/src/config/config.yaml b/src/config/config.yaml index bbce3e1ca..ac9092c4b 100644 --- a/src/config/config.yaml +++ b/src/config/config.yaml @@ -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