From 94b09bf509ada878787fd8e3960a206ad03c2425 Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Wed, 11 Sep 2024 08:36:35 +0100 Subject: [PATCH] Move warning for Planck peak outside NU_MIN_R, NU_MAX_R from packet prop to grid update --- grid.cc | 15 ++++++++++++++- kpkt.cc | 4 ---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/grid.cc b/grid.cc index 668c55b7a..8f7d9d346 100644 --- a/grid.cc +++ b/grid.cc @@ -1876,7 +1876,20 @@ void set_nnetot(const int modelgridindex, const float nnetot) { void set_kappagrey(const int modelgridindex, const float kappagrey) { modelgrid[modelgridindex].kappagrey = kappagrey; } -void set_Te(const int modelgridindex, const float Te) { modelgrid[modelgridindex].Te = Te; } +void set_Te(const int modelgridindex, const float Te) { + if (Te > 0.) { + // ignore the zero initialisation value for this check + const double nu_peak = 5.879e10 * Te; + if (nu_peak > NU_MAX_R || nu_peak < NU_MIN_R) { + printout( + "[warning] modelgridindex %d B_planck(Te=%g K) peak at %g Hz is outside frequency range NU_MIN_R %g NU_MAX_R " + "%g\n", + modelgridindex, Te, nu_peak, NU_MIN_R, NU_MAX_R); + } + } + + modelgrid[modelgridindex].Te = Te; +} void set_TR(const int modelgridindex, const float TR) { modelgrid[modelgridindex].TR = TR; } diff --git a/kpkt.cc b/kpkt.cc index 24a293c84..c5df06603 100644 --- a/kpkt.cc +++ b/kpkt.cc @@ -242,10 +242,6 @@ auto sample_planck_analytic(const double T) -> double { // return a randomly chosen frequency according to the Planck distribution of temperature T using a Monte Carlo method auto sample_planck_montecarlo(const double T) -> double { const double nu_peak = 5.879e10 * T; - if (nu_peak > NU_MAX_R || nu_peak < NU_MIN_R) { - printout("[warning] sample_planck: intensity peaks outside frequency range\n"); - } - const double B_peak = radfield::dbb(nu_peak, T, 1); while (true) {