1212// ApJ
1313
1414#include < string>
15+ #include < cstdio>
1516
1617#include " idefix.hpp"
1718#include " units.hpp"
@@ -84,6 +85,7 @@ void RadCooling::TownsendIntegration(real dt) {
8485 int T_indx_lo = 0 ;
8586 int T_indx_hi = static_cast <int >(temperature_data.extent (0 )) - 1 ;
8687 int T_indx_mid = 0 ;
88+ real temperature_max = temperature_data (T_indx_hi);
8789 // ideal gas eos is used
8890 real temperature = Vc (PRS ,k,j,i)/Vc (RHO ,k,j,i)*(mu*m_p/kB )*pow (vel_unit,2 );
8991
@@ -92,11 +94,12 @@ void RadCooling::TownsendIntegration(real dt) {
9294 // delta_eng(k,j,i) = ZERO_F;
9395 real del_prs = -Vc (RHO ,k,j,i)/(mu*m_p/kB )*(temperature-TcoolFloor)/pow (vel_unit,2 );
9496 delta_eng (k,j,i) = eos.GetInternalEnergy (del_prs, Vc (RHO ,k,j,i));
95- } else if ( (temperature< temperature_data (0 )) ||
96- (temperature> temperature_data (temperature_data. extent ( 0 )- 1 )) ) {
97+ } else if ((temperature < temperature_data (0 )) ||
98+ (temperature > temperature_max) ) {
9799 // tabulated data does not enclose the temperature value
98- printf (" RadCooling::TownsendIntegration Temperature out of range: T=%e, valid range=[%e, %e]\n " ,
99- temperature, temperature_data (0 ), temperature_data (temperature_data.extent (0 )-1 ));
100+ printf (" RadCooling::TownsendIntegration Temperature out of range: T=%e, "
101+ " valid range=[%e, %e]\n " ,
102+ temperature, temperature_data (0 ), temperature_max);
100103 Kokkos::abort (" RadCooling::TownsendIntegration Temperature out of range" );
101104 } else {
102105 while (T_indx_lo<=T_indx_hi) {
0 commit comments