From b3d1ed27ce55875a74b0308e71257c4f480dad93 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 1 Oct 2018 16:30:34 -0500 Subject: fall back to old scattering rms calculation when n = 0 --- src/path.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/path.c b/src/path.c index 9634479..d26e461 100644 --- a/src/path.c +++ b/src/path.c @@ -155,9 +155,12 @@ path *path_init(double *pos, double *dir, double T0, double range, double theta0 * * Since there is no nice closed form solution for this, we estimate it by * evaluating the result at the middle of the track. */ - p->theta0 = 4*range*pow(theta0,2)*gsl_sf_psi_n(1,p->n-0.5)/pow(M_PI,2); - - p->theta0 = fmax(MIN_THETA0, p->theta0); + if (p->n > 0) { + p->theta0 = 4*range*pow(theta0,2)*gsl_sf_psi_n(1,p->n-0.5)/pow(M_PI,2); + p->theta0 = fmax(MIN_THETA0, p->theta0); + } else { + p->theta0 = theta0; + } p->s = s; p->x = x; @@ -195,7 +198,10 @@ void path_eval(path *p, double s, double *pos, double *dir, double *T, double *t normalize(dir); - *theta0 = p->theta0; + if (p->n > 0) + *theta0 = p->theta0; + else + *theta0 = fmax(MIN_THETA0,p->theta0*sqrt(s)); } void path_free(path *p) -- cgit