diff --git a/Exec/science/Detonation/problem_initialize_state_data.H b/Exec/science/Detonation/problem_initialize_state_data.H index f594e8f15e..8460f583d6 100644 --- a/Exec/science/Detonation/problem_initialize_state_data.H +++ b/Exec/science/Detonation/problem_initialize_state_data.H @@ -22,7 +22,15 @@ void problem_initialize_state_data (int i, int j, int k, state(i,j,k,URHO) = problem::dens; - Real sigma = 1.0_rt / (1.0_rt + std::exp(-(c_T - xcen)/ width)); + Real sigma_arg = -(c_T - xcen) / width; + Real sigma; + // need to avoid FP overflow for sigma_arg >= 709 + // 1/(1 + exp(100)) ~= 3e-44, which is much smaller than machine epsilon + if (sigma_arg < 100) { + sigma = 1.0_rt / (1.0_rt + std::exp(sigma_arg)); + } else { + sigma = 0.0_rt; + } state(i,j,k,UTEMP) = problem::T_l + (problem::T_r - problem::T_l) * (1.0_rt - sigma);