Skip to content
Snippets Groups Projects
Commit bb0538cd authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'rt_unphysical_float_to_double' into 'master'

use doubles to compute F^2, as on some occations it may exceed the single precision limits

See merge request !1854
parents b571bd55 09ba6851
Branches
Tags
6 merge requests!1891Merge master into Zoom merge,!1887Updating . . .,!1878updating working branch,!1873Merging master into zoom branch,!1861Fixes a missing member of zoom_props,!1854use doubles to compute F^2, as on some occations it may exceed the single precision limits
...@@ -72,11 +72,11 @@ __attribute__((always_inline)) INLINE static void rt_check_unphysical_state( ...@@ -72,11 +72,11 @@ __attribute__((always_inline)) INLINE static void rt_check_unphysical_state(
} }
/* Check for too high fluxes */ /* Check for too high fluxes */
const float flux2 = flux[0] * flux[0] + flux[1] * flux[1] + flux[2] * flux[2]; const double flux2 = flux[0] * flux[0] + flux[1] * flux[1] + flux[2] * flux[2];
const float flux_norm = sqrtf(flux2); const double flux_norm = sqrt(flux2);
const float flux_max = rt_params.reduced_speed_of_light * *energy_density; const double flux_max = rt_params.reduced_speed_of_light * *energy_density;
if (flux_norm > flux_max) { if (flux_norm > flux_max) {
const float correct = flux_max / flux_norm; const double correct = flux_max / flux_norm;
flux[0] *= correct; flux[0] *= correct;
flux[1] *= correct; flux[1] *= correct;
flux[2] *= correct; flux[2] *= correct;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment