Skip to content

Commit 501222a

Browse files
committed
More robustly bound the root
1 parent 684681f commit 501222a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/modules/Harder_precip_phase.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ void Harder_precip_phase::run(mesh_elem& face)
113113
};
114114

115115
double guess = T;
116-
double min = -50;
117-
double max = 50;
116+
// Ensure these cover more than the range of plausible.
117+
// It's just to ensure the root is bounded.
118+
double min = -100;
119+
double max = 100;
118120
double digits = 6;
119121

120122
double Ti = 0;
@@ -127,16 +129,6 @@ void Harder_precip_phase::run(mesh_elem& face)
127129
{
128130
SPDLOG_ERROR("Ta={}, RH={}, ea={}, guess={}, min={}, max={}",
129131
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-
}
140132
CHM_THROW_EXCEPTION(module_error, "Harder_precip_phase newton_raphson_iterate failed to converge");
141133
}
142134

0 commit comments

Comments
 (0)