From e4494a8df1f20d35a45ccda7406fac83ccff1741 Mon Sep 17 00:00:00 2001 From: Sergio Martin Alvarez Date: Fri, 28 Jul 2023 19:54:09 +0100 Subject: [PATCH 1/4] Bug fix: correct unit conversion for Stokes in Synchrotron to Jy --- src/RadiativeTransfer.cpp | 5 ++--- src/Synchrotron.h | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/RadiativeTransfer.cpp b/src/RadiativeTransfer.cpp index cc1679f6..cd3110e6 100644 --- a/src/RadiativeTransfer.cpp +++ b/src/RadiativeTransfer.cpp @@ -2186,9 +2186,8 @@ void CRadiativeTransfer::getSyncIntensity(photon_package * pp, // Set current index in photon package pp->setSpectralID(i_wave + i_extra * nr_used_wavelengths); - // Get wavelength/frequency of the photon package - double mult = 1e+26 * subpixel_fraction * tracer[i_det]->getDistanceFactor() * con_c / - (pp->getFrequency() * pp->getFrequency()); + // Convert W/m2/Hz/sr to Jy + double mult = 1e+26 * subpixel_fraction * tracer[i_det]->getDistanceFactor(); // Include foreground extinction if necessary mult *= dust->getForegroundExtinction(tracer[i_det]->getWavelength(pp->getWavelength())); diff --git a/src/Synchrotron.h b/src/Synchrotron.h index 16b86032..0fe1b944 100644 --- a/src/Synchrotron.h +++ b/src/Synchrotron.h @@ -13,8 +13,10 @@ #define syn_kB 1.380662e-16 // Boltzmann constant [erg/K] #define syn_c 2.99792458e10 // speed of light [m/s] -// conversion factor 1/cm -> 1/m -#define syn_SI 100.0 +// conversion factor 100.0 (1/cm -> 1/m) * 1e-3 (erg s^-1 cm^-2 Hz^-1 -> W m^-2 Hz^-1) +#define syn_SI 0.1 +// conversion factor 100.0 (1/cm -> 1/m) +#define syn_SI_abs 100.0 // container class for the parameters of sync. RT class syn_param @@ -74,9 +76,9 @@ class syn_param j_Q *= syn_SI; j_V *= syn_SI; - alpha_I *= syn_SI; - alpha_Q *= syn_SI; - alpha_V *= syn_SI; + alpha_I *= syn_SI_abs; + alpha_Q *= syn_SI_abs; + alpha_V *= syn_SI_abs; kappa_Q *= syn_SI; kappa_V *= syn_SI; From fa03e65bde021ee09b3996cd5743876be2881bd9 Mon Sep 17 00:00:00 2001 From: Sergio Martin Alvarez Date: Fri, 28 Jul 2023 19:55:15 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Bug=20fix=20/=20suggested=20change:=20exten?= =?UTF-8?q?ded=20gmin=20pre-factor=20to=20follow=20equati=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Synchrotron.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Synchrotron.cpp b/src/Synchrotron.cpp index 32621e5c..c8b52e7e 100644 --- a/src/Synchrotron.cpp +++ b/src/Synchrotron.cpp @@ -239,9 +239,10 @@ syn_param CSynchrotron::get_Power_Law_Parameter(double n_e, res.j_V = res.j_I / sqrt(nu / (3. * nu_c * sin_theta)) * getI_V_p(p, tan_theta); // additional correction for g_min>1 (see Reissl et al. 2018) - res.j_I /= (g_min * g_min); - res.j_Q /= (g_min * g_min); - res.j_V /= (g_min * g_min); + double gmin_den = pow(g_min, 1 - p); + res.j_I *= gmin_den; + res.j_Q *= gmin_den; + res.j_V *= gmin_den; double du = sqrt(res.j_I * res.j_I - res.j_Q * res.j_Q); @@ -272,9 +273,9 @@ syn_param CSynchrotron::get_Power_Law_Parameter(double n_e, // * log(g_min)/tan_theta; // additional correction for g_min>1 (see Reissl et al. 2018) - res.alpha_I /= (g_min * g_min); - res.alpha_Q /= (g_min * g_min); - res.alpha_V /= (g_min * g_min); + res.alpha_I *= gmin_den; + res.alpha_Q *= gmin_den; + res.alpha_V *= gmin_den; // converting back into SI; res.scale(); From 32f18417b2c239553e32abbbc7cabfda34956b9a Mon Sep 17 00:00:00 2001 From: Sergio Martin Alvarez Date: Fri, 28 Jul 2023 19:56:30 +0100 Subject: [PATCH 3/4] Fix typo: missing 1 in Gamma_A_p calculation --- src/Synchrotron.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Synchrotron.h b/src/Synchrotron.h index 0fe1b944..e24f0f17 100644 --- a/src/Synchrotron.h +++ b/src/Synchrotron.h @@ -492,7 +492,7 @@ class CSynchrotron double Gamma_A_p(double g_min, double g_max, double p) { - return Gamma((3. * p + 2.) / 12.) * Gamma((3. * p + 22.) / 12.) / + return Gamma((3. * p + 12.) / 12.) * Gamma((3. * p + 22.) / 12.) / (4. * (pow(g_min, 1. - p) - pow(g_max, 1. - p))); } From 98009c9a167c758ea6f96342503b74fa8ecc0e89 Mon Sep 17 00:00:00 2001 From: Sergio Martin Alvarez Date: Fri, 28 Jul 2023 19:57:47 +0100 Subject: [PATCH 4/4] Suggested comments change: correct units in comment --- src/Synchrotron.cpp | 2 +- src/Synchrotron.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Synchrotron.cpp b/src/Synchrotron.cpp index c8b52e7e..4607e274 100644 --- a/src/Synchrotron.cpp +++ b/src/Synchrotron.cpp @@ -104,7 +104,7 @@ syn_param CSynchrotron::get_Thermal_Parameter(double n_e, double T_e, double l, n_e *= 1e-6; // n_e in 1/ccm - B *= 1e4; // B in mu Gauss + B *= 1e4; // B in Gauss double sin_theta = sin(theta); double cos_theta = cos(theta); diff --git a/src/Synchrotron.h b/src/Synchrotron.h index e24f0f17..7b97673a 100644 --- a/src/Synchrotron.h +++ b/src/Synchrotron.h @@ -11,7 +11,7 @@ #define syn_e 4.80320680e-10 // electron charge [Statcoulomb] #define syn_h 6.6260693e-27 // Planck constant [erg/s] #define syn_kB 1.380662e-16 // Boltzmann constant [erg/K] -#define syn_c 2.99792458e10 // speed of light [m/s] +#define syn_c 2.99792458e10 // speed of light [cm/s] // conversion factor 100.0 (1/cm -> 1/m) * 1e-3 (erg s^-1 cm^-2 Hz^-1 -> W m^-2 Hz^-1) #define syn_SI 0.1