From 52cb60dad42c1bc44c48d66977545062497bd200 Mon Sep 17 00:00:00 2001
From: zetienne <zachetie@gmail.com>
Date: Mon, 20 Nov 2017 14:10:31 -0500
Subject: [PATCH] > SEOBNRv3: Reduce error when computing finite difference
 derivatives of analytic SEOBNRv3 Hamiltonian by increasing the finite
 difference step size. This greatly improves agreement with SEOBNRv3_opt
 (which uses analytical derivatives). > SEOBNRv3/SEOBNRv3_opt: alpha Euler
 angle is not unwrapped properly in a small fraction (~ 1/100,000) of cases.
 This is corrected by replacing an if() statement with a simple while() loop
 that rarely goes to the second iteration. > > Closes Redmine 5977:
 https://bugs.ligo.org/redmine/issues/5977 > > Author: Tyler Knowles > Patch
 approved by: Riccardo Sturani

---
 .../src/LALSimIMRSpinEOBHcapNumericalDerivativePrec.c         | 4 ++--
 lalsimulation/src/LALSimIMRSpinPrecEOBEulerAngles.c           | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lalsimulation/src/LALSimIMRSpinEOBHcapNumericalDerivativePrec.c b/lalsimulation/src/LALSimIMRSpinEOBHcapNumericalDerivativePrec.c
index e2ba83a260..3932bbb093 100644
--- a/lalsimulation/src/LALSimIMRSpinEOBHcapNumericalDerivativePrec.c
+++ b/lalsimulation/src/LALSimIMRSpinEOBHcapNumericalDerivativePrec.c
@@ -97,7 +97,7 @@ static REAL8 XLALSpinPrecHcapNumDerivWRTParam(
 )
 {
 	int		debugPK = 0;
-	static const REAL8 STEP_SIZE = 1.0e-4;
+	static const REAL8 STEP_SIZE = 2.0e-4;
 
     /** lMax: l index up to which h_{lm} modes are included in the computation of the GW enegy flux: see Eq. in 13 in PRD 86,  024011 (2012) */
     static const INT4 lMax = 8;
@@ -710,7 +710,7 @@ XLALSpinPrecHcapNumDerivWRTParam(
 			     SpinEOBParams * funcParams	/**<< EOB Parameters */
 )
 {
-	static const REAL8 STEP_SIZE = 1.0e-3;
+	static const REAL8 STEP_SIZE = 2.0e-3;
 
 	HcapDerivParams	params;
 
diff --git a/lalsimulation/src/LALSimIMRSpinPrecEOBEulerAngles.c b/lalsimulation/src/LALSimIMRSpinPrecEOBEulerAngles.c
index aeb601f102..f69aba05e8 100644
--- a/lalsimulation/src/LALSimIMRSpinPrecEOBEulerAngles.c
+++ b/lalsimulation/src/LALSimIMRSpinPrecEOBEulerAngles.c
@@ -85,11 +85,11 @@ static int EulerAnglesI2P(REAL8Vector *Alpha, /**<< output: alpha Euler angle */
             }
         }
 
-        if( i>0 && Alpha->data[i] - Alpha->data[i-1] > 5. ) {
+        while( i>0 && Alpha->data[i] - Alpha->data[i-1] > 5. ) {
             *phaseCounterA = *phaseCounterA - 1;
             Alpha->data[i] -= LAL_TWOPI;
         }
-        else if ( i && Alpha->data[i] - Alpha->data[i-1] < -5. ) {
+        while( i && Alpha->data[i] - Alpha->data[i-1] < -5. ) {
             *phaseCounterA = *phaseCounterA + 1;
             Alpha->data[i] += LAL_TWOPI;
         }
-- 
GitLab