@@ -78,7 +78,7 @@ void Harder_precip_phase::run(mesh_elem& face)
78
78
double Ta = (*face)[" t" _s]+273.15 ; // K
79
79
double T = (*face)[" t" _s];
80
80
double RH = (*face)[" rh" _s];
81
- double ea = RH/100 * 0.611 *exp ( (17.3 *T) / (237.3 +T));
81
+ double ea = RH/100.0 * 0.611 *exp ( (17.3 *T) / (237.3 +T));
82
82
83
83
// (A.6)
84
84
double D = 2.06 * pow (10 ,-5 ) * pow (Ta/273.15 ,1.75 );
@@ -117,7 +117,29 @@ void Harder_precip_phase::run(mesh_elem& face)
117
117
double max = 50 ;
118
118
double digits = 6 ;
119
119
120
- double Ti = boost::math::tools::newton_raphson_iterate (fx, guess, min, max, digits);
120
+ double Ti = 0 ;
121
+
122
+ try
123
+ {
124
+ Ti = boost::math::tools::newton_raphson_iterate (fx, guess, min, max, digits);
125
+ }
126
+ catch (...)
127
+ {
128
+ SPDLOG_ERROR (" Ta={}, RH={}, ea={}, guess={}, min={}, max={}" ,
129
+ Ta, RH, ea, guess, min, max);
130
+ try
131
+ {
132
+ // try again but instrument it this time to see what went wrong
133
+ #define BOOST_MATH_INSTRUMENT
134
+ Ti = boost::math::tools::newton_raphson_iterate (fx, guess, min, max, digits);
135
+ #undef BOOST_MATH_INSTRUMENT
136
+ }
137
+ catch (...)
138
+ {
139
+ }
140
+ CHM_THROW_EXCEPTION (module_error, " Harder_precip_phase newton_raphson_iterate failed to converge" );
141
+ }
142
+
121
143
122
144
double frTi = 1.0 / (1.0 +b*pow (c,Ti));
123
145
0 commit comments