![]() |
Shamrock 2025.10.0
Astrophysical Code
|
COALA dust coagulation helpers for a DG \(k=0\) (piecewise-constant) basis. More...
#include "shambase/assert.hpp"#include "shambase/mdspan_concepts.hpp"#include <experimental/mdspan>#include <concepts>Go to the source code of this file.
Functions | |
| template<class T> requires requires(decltype(rho_dust) rd, int j) { { rd(j) } -> std::same_as<T>; } | |
| void | shamphys::compute_gij_k0 (auto &&rho_dust, T rho_eps, shambase::is_mdspan_rank< 1 > auto massgrid, shambase::is_mdspan_rank< 1 > auto gij) |
| Build \(g_j\) coefficients on the piecewise-constant DG basis ( \(k=0\)). | |
| template<class Func> requires requires(Func f, int a, int b) { { f(a, b) }; } | |
| void | shamphys::compute_flux_coag_k0_kdv (int nbins, shambase::is_mdspan_rank< 1 > auto gij, shambase::is_mdspan_rank< 3 > auto tensor_tabflux_coag, Func &&dv, shambase::is_mdspan_rank< 1 > auto flux) |
| Coagulation flux at bin right edges for a ballistic kernel ( \(k=0\)). | |
| void | shamphys::coala_flux_diff (shambase::is_mdspan_rank< 1 > auto flux, shambase::is_mdspan_rank< 1 > auto S_coag) |
| Convert interface fluxes to a mass-bin coagulation source term. | |
| template<class T, class FuncDv, class FuncRhoDust> | |
| void | shamphys::coala_k0_source_term (int nbins, FuncDv &&dv, FuncRhoDust &&rho_dust, T rho_eps, shambase::is_mdspan_rank< 1 > auto massgrid, shambase::is_mdspan_rank< 3 > auto tabflux_coag, shambase::is_mdspan_rank< 1 > auto gij, shambase::is_mdspan_rank< 1 > auto flux, shambase::is_mdspan_rank< 1 > auto S_coag) |
COALA dust coagulation helpers for a DG \(k=0\) (piecewise-constant) basis.
C++ counterparts of the COALA Python routines used to build dust coagulation source terms in the conservative form of the Smoluchowski equation (Lombart et al., 2021). The reference implementation lives in src/pylib/shamrock/external/coala/interface_coala_shamrock.py and src/pylib/shamrock/external/coala/generate_flux_intflux.py.
Only the coagulation flux with \(k=0\) approximation.
Definition in file coala_interface.hpp.
| void shamphys::coala_flux_diff | ( | shambase::is_mdspan_rank< 1 > auto | flux, |
| shambase::is_mdspan_rank< 1 > auto | S_coag ) |
Convert interface fluxes to a mass-bin coagulation source term.
Applies the DG \(k=0\) divergence operator (finite difference across bin boundaries) to obtain the source term \(S_{\rm coag}\) in the conservative form of the Smoluchowski equation:
\[ S_{\rm coag}[0] = -\mathrm{flux}[0], \qquad S_{\rm coag}[j] = \mathrm{flux}[j-1] - \mathrm{flux}[j] \quad (j \ge 1) \]
| flux | Rank-1 view of coagulation fluxes at bin right edges |
| S_coag | Rank-1 output view of the same length; filled in place |
Definition at line 152 of file coala_interface.hpp.
| void shamphys::coala_k0_source_term | ( | int | nbins, |
| FuncDv && | dv, | ||
| FuncRhoDust && | rho_dust, | ||
| T | rho_eps, | ||
| shambase::is_mdspan_rank< 1 > auto | massgrid, | ||
| shambase::is_mdspan_rank< 3 > auto | tabflux_coag, | ||
| shambase::is_mdspan_rank< 1 > auto | gij, | ||
| shambase::is_mdspan_rank< 1 > auto | flux, | ||
| shambase::is_mdspan_rank< 1 > auto | S_coag ) |
Definition at line 164 of file coala_interface.hpp.
|
inline |
Coagulation flux at bin right edges for a ballistic kernel ( \(k=0\)).
Evaluates the flux approximation at the right boundary of each mass bin, \(\mathrm{flux}[j] \approx F(m_{j+1/2})\), by summing over all bin pairs \((l, m)\):
\[ \mathrm{flux}[j] = \sum_{l,m} \mathrm{tensor\_tabflux\_coag}[j,l,m]\, \mathrm{dv}(l,m)\, g_l\, g_m \]
Equivalent to the NumPy contraction einsum("jlm,lm,l,m->j", tensor_tabflux_coag, dv, gij, gij).
gij, tensor_tabflux_coag and flux are expected to share the same scalar element type.
| Func | Callable invoked as dv(l, m) returning the differential velocity between bins \(l\) and \(m\) (e.g. \(|\mathbf{v}_m - \mathbf{v}_l|\)) |
| nbins | Number of dust mass bins |
| gij | Rank-1 std::mdspan (shambase::is_mdspan_rank<1>) of DG coefficients \(g_l\); extent nbins |
| tensor_tabflux_coag | Rank-3 std::mdspan (shambase::is_mdspan_rank<3>) of precomputed coagulation flux entries; extents nbins (\times) nbins (\times) nbins |
| dv | Pair-wise differential-velocity callable |
| flux | Rank-1 std::mdspan (shambase::is_mdspan_rank<1>) of output fluxes; extent nbins, written in place |
Definition at line 107 of file coala_interface.hpp.
|
inline |
Build \(g_j\) coefficients on the piecewise-constant DG basis ( \(k=0\)).
For each mass bin \(j\), converts the dust density to the polynomial coefficient \(g_j = \rho_{\rm d,j} / \Delta m_j\) when \(\rho_{\rm d,j} > \rho_{\rm eps}\), and sets \(g_j = 0\) otherwise, with \Delta m_j = massgrid[j+1] - massgrid[j] the bin width from consecutive mass-grid edges.
| T | Floating-point scalar type; rho_dust must satisfy rho_dust(j) -> T, and massgrid / gij must be rank-1 std::mdspan with element type T |
| rho_dust | Callable invoked as rho_dust(j) returning dust density in bin \(j\) |
| rho_eps | Density threshold below which \(g_j\) is set to zero |
| massgrid | Rank-1 std::mdspan (shambase::is_mdspan_rank<1>) of bin-edge masses; extent must be gij.extent(0) + 1 |
| gij | Rank-1 std::mdspan (shambase::is_mdspan_rank<1>) of DG coefficients; one entry per bin, written in place |
Definition at line 54 of file coala_interface.hpp.