From 04dd1f0c2369980fd474853bacf8047b3d2be074 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Wed, 22 May 2019 12:09:47 -0400 Subject: make sure theta0 is less than MAX_THETA0 in get_probability() to prevent a gsl error --- src/scattering.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/scattering.c') diff --git a/src/scattering.c b/src/scattering.c index 5a7f7a9..c4babae 100644 --- a/src/scattering.c +++ b/src/scattering.c @@ -219,6 +219,10 @@ double get_probability(double beta, double cos_theta, double theta0) * we are going to square it everywhere. */ sin_theta = sqrt(1-pow(cos_theta,2)); + /* Make sure theta0 is less than MAX_THETA0, otherwise it's possible that + * gsl_spline2d_eval() will quit. */ + if (theta0 > MAX_THETA0) theta0 = MAX_THETA0; + return gsl_spline2d_eval(spline, beta*cos_theta, beta*sin_theta*theta0, xacc, yacc)/(theta0*sin_theta); } -- cgit