24 #include <gsl/gsl_vector.h>
25 #include <gsl/gsl_spline.h>
26 #include <gsl/gsl_multiroots.h>
27 #include <gsl/gsl_roots.h>
29 #include <lal/LALConstants.h>
30 #include <lal/LALDatatypes.h>
31 #include <lal/TimeSeries.h>
32 #include <lal/Units.h>
35 #define c ((REAL8)(LAL_C_SI))
36 #define G ((REAL8)(LAL_G_SI))
37 #define pi ((REAL8)(LAL_PI))
38 #define pc ((REAL8)(LAL_PC_SI))
39 #define Msun ((REAL8)(LAL_MSUN_SI))
40 #define Msun_sec ((REAL8)(G*Msun/(c*c*c)))
41 #define GPC_sec ((REAL8)(pc*pow(10.,9.)/c))
50 static INT4 HGimri_start(
REAL8 m,
REAL8 M,
REAL8 q,
REAL8 D,
REAL8 Sdotn,
REAL8 phi0,
REAL8 p0,
REAL8Sequence *hplus,
REAL8Sequence *hcross,
REAL8 dt,
UINT4 Npts);
100 REAL8 d1 = 1975./896.;
102 REAL8 l1_5 = -191./160.;
103 REAL8 d2 = 1152343./451584.;
106 return (1./(pow(p0,3/2.)+
q))*(1. + nu*(d0+d1/p0+(d1_5+
q*l1_5)*pow(p0,-1.5)+d2*pow(p0,-2.0))) -
pi*(
f_min)*(
m+
M)*
Msun_sec;
119 REAL8 pref = -6.4/(pow(
r,7./2.));
148 REAL8 c10a,c10b,c10c;
149 REAL8 c11a,c11b,c11c;
150 REAL8 higherorderfit,
c1,
c2,correction,circbit;
155 c1=c1a+(c1b+c1c/rtr)/rtr;
160 c2=(c2a+(c2b+c2c/rtr)/rtr);
199 736.2086781-283.9553066*rtr+q_abs*(-1325.1852209+483.266206498*rtr)+pow(q_abs,2.0)*(634.49936445-219.223848944*rtr)
200 +(82.07804475-25.82025864*rtr)+q_abs*(-904.16109275+301.477789146*rtr)+pow(q_abs,2.0)*(827.31891826-271.9659423*rtr)
203 higherorderfit = q_abs*
c1 + pow(q_abs,3.)*
c2
204 + cosInc*( c3a+(c3b+c3c/rtr)/rtr )
205 + pow(q_abs,2.)*cosInc*(c4a+(c4b+c4c/rtr)/rtr)
206 + pow(q_abs,4.)*cosInc*(c5a+(c5b+c5c/rtr)/rtr)
207 + q_abs*(c6a+(c6b+c6c/rtr)/rtr)
208 + pow(q_abs,3.)*(c7a+(c7b+c7c/rtr)/rtr)
209 + pow(q_abs,2.)*cosInc*(c8a+(c8b+c8c/rtr)/rtr)
210 + pow(q_abs,4.)*cosInc*(c9a+(c9b+c9c/rtr)/rtr)
211 + pow(q_abs,3.)*(c10a+(c10b+c10c/rtr)/rtr)
212 + pow(q_abs,4.)*cosInc*(c11a+(c11b+c11c/rtr)/rtr)
216 circbit = cosInc - (61./12.)*q_abs/(
r*rtr) -1247.*cosInc/(336.*
r) + 4.*
pi*cosInc/(
r*rtr) - 44711.*cosInc/(9072.*
r*
r)
217 + (33./16.)*q_abs*q_abs*cosInc/(
r*
r) + higherorderfit/(
r*
r*rtr);
221 return(sign*nu*pref*circbit);
261 const REAL8 a0n = gsl_vector_get (
x, 0);
262 const REAL8 a0p = gsl_vector_get (
x, 1);
263 const REAL8 a1n = gsl_vector_get (
x, 2);
264 const REAL8 a1p = gsl_vector_get (
x, 3);
265 const REAL8 a2n = gsl_vector_get (
x, 4);
266 const REAL8 a2p = gsl_vector_get (
x, 5);
303 gsl_vector_set (f, 0, yy0);
304 gsl_vector_set (f, 1, yy1);
305 gsl_vector_set (f, 2, yy2);
306 gsl_vector_set (f, 3, yy3);
307 gsl_vector_set (f, 4, yy4);
308 gsl_vector_set (f, 5, yy5);
349 const REAL8 a0c = gsl_vector_get (z, 0);
350 const REAL8 a0cp = gsl_vector_get (z, 1);
351 const REAL8 a1c = gsl_vector_get (z, 2);
352 const REAL8 a1cp = gsl_vector_get (z, 3);
353 const REAL8 a2c = gsl_vector_get (z, 4);
354 const REAL8 a2cp = gsl_vector_get (z, 5);
391 gsl_vector_set (g, 0, yy0);
392 gsl_vector_set (g, 1, yy1);
393 gsl_vector_set (g, 2, yy2);
394 gsl_vector_set (g, 3, yy3);
395 gsl_vector_set (g, 4, yy4);
396 gsl_vector_set (g, 5, yy5);
413 return ((2.*
r-
q/sqrt(
r)-0.5*(
r*
r-2.*
q*sqrt(
r)+
q*
q)*(3.*
r*
r-6.*
r+3.*
q*sqrt(
r))/denom1)/sqrt(denom1));
431 return ( dRdr/pow(Vt,2.) - 2.*R*dVtdr/pow(Vt,3.) );
475 final_mass = (
M+
m)*(1. + nu*(sqrt(8./9.)-1.) - 0.498*nu*nu);
476 final_q = q_abs - 0.129*q_abs*q_abs*nu - 0.384*q_abs*nu*nu - 2.686*q_abs*nu + 2.*sqrt(3.)*nu - 3.454*nu*nu + 2.353*nu*nu*nu;
489 REAL8 d1 = 1975./896.;
491 REAL8 l1_5 = -191./160.;
492 REAL8 d2 = 1152343./451584.;
503 Z1 = 1. + pow((1.-
q*
q),1./3.)*(pow(1.+
q, 1./3.)+pow(1.-
q, 1./3.));
504 Z2 = sqrt(3.*
q*
q + Z1*Z1);
505 r_isco = 3. + Z2 - sign*sqrt((3. - Z1)*(3. + Z1 + 2.*Z2));
506 E_isco = (1.+
q/pow(r_isco,1.5)-2./r_isco)/sqrt(1.+(2.*
q)/pow(r_isco,1.5)-3./r_isco);
507 L_isco = sqrt(r_isco)*(1.+pow(
q,2.)/pow(r_isco,2.)-(2.*
q)/pow(r_isco,1.5))/sqrt(1.+(2.*
q)/pow(r_isco,1.5)-3./r_isco);
508 omega_isco = (1./(pow(r_isco,3/2.)+
q))*(1. + nu*(d0+d1/r_isco+(d1_5+
q*l1_5)*pow(r_isco,-1.5)+d2*pow(r_isco,-2.0)));
509 gamma_isco = sqrt(1. - 3./r_isco + 2.*
q/pow(r_isco,1.5))/(1. +
q/pow(r_isco,1.5));
518 eps_dot = (1.13197 + 0.0713235*
q*
q + (0.183783*
q)/(-2.34484 + 2.15323*
q));
519 a_isco = (3./pow(r_isco,6.)) * (r_isco*r_isco + 2.*(
q*
q*(E_isco*E_isco-1.) - L_isco*L_isco )*r_isco + 10.*pow(L_isco-
q*E_isco,2.));
520 b_isco = (2./pow(r_isco,4.)) * ( (L_isco -
q*
q*E_isco*omega_isco)*r_isco - 3.*(L_isco -
q*E_isco)*(1. -
q*omega_isco) );
521 k_isco = (32./5.)*pow(omega_isco,7./3.)*eps_dot/gamma_isco;
527 REAL8 r_plunge, E_plunge, L_plunge;
530 r_match = r_isco + sqrt(1.0*pow(nu*b_isco*k_isco,4./5.)/pow(a_isco,6./5.));
531 L_match = sqrt(r_match)*(1.+pow(
q,2.)/pow(r_match,2.)-(2.*
q)/pow(r_match,1.5))/sqrt(1.+(2.*
q)/pow(r_match,1.5)-3./r_match);
532 r_plunge = r_isco + pow(nu*b_isco*k_isco,2./5.)*pow(a_isco,-3./5.)*(-6./pow(3.412-.75,2.));
533 E_plunge = E_isco - omega_isco*k_isco*pow(a_isco*b_isco*k_isco,-1./5.)*(3.412-0.75)*pow(nu,4./5.);
534 L_plunge = L_isco - k_isco*pow(a_isco*b_isco*k_isco,-1./5.)*(3.412-0.75)*pow(nu,4./5.);
535 r_lightring = 2.*(1.+cos((2./3.)*acos(-
q)));
544 INT4 i_finalplunge = 0;
552 REAL8 r_K2,drdt_K2, dphidt_K2,d2rdt2_K2=0.;
553 REAL8 r_K3,drdt_K3,dphidt_K3,d2rdt2_K3;
554 REAL8 r_K4,drdt_K4,dphidt_K4,d2rdt2_K4;
560 dphidt = (1./(pow(
r,3/2.)+
q))*(1. + nu*(d0+d1/
r+(d1_5+
q*l1_5)*pow(
r,-1.5)+d2*pow(
r,-2.0)));
565 XLALPrintError(
"XLAL Error: Beginning inside Transition (Stage 2). Specify larger initial frequency f_min\n");
582 switch (currentStage) {
591 dphidt = (1./(pow(
r,3/2.)+
q))*(1. + nu*(d0+d1/
r+(d1_5+
q*l1_5)*pow(
r,-1.5)+d2*pow(
r,-2.0)));
594 r_K2 =
r + (
dt/2.)*drdt;
596 dphidt_K2 = (1./(pow(r_K2,3/2.)+
q))*(1. + nu*(d0+d1/r_K2+(d1_5+
q*l1_5)*pow(r_K2,-1.5)+d2*pow(r_K2,-2.0)));
599 r_K3 =
r + (
dt/2.)*drdt_K2;
601 dphidt_K3 = (1./(pow(r_K3,3/2.)+
q))*(1. + nu*(d0+d1/r_K3+(d1_5+
q*l1_5)*pow(r_K3,-1.5)+d2*pow(r_K3,-2.0)));
604 r_K4 =
r + (
dt)*drdt_K3;
606 dphidt_K4 = (1./(pow(r_K4,3/2.)+
q))*(1. + nu*(d0+d1/r_K4+(d1_5+
q*l1_5)*pow(r_K4,-1.5)+d2*pow(r_K4,-2.0)));
609 hplus->
data[
i] = ((4.*
mu*pow(dphidt*
r,2.))/D) * ((1.+pow(
Sdotn,2.))/2.) * cos(2.*phi);
610 hcross->
data[
i] = ((4.*
mu*pow(dphidt*
r,2.))/D) *
Sdotn * sin(2.*phi);
613 dr = (1./6.)*
dt*(drdt+2.*drdt_K2+2.*drdt_K3+drdt_K4);
614 if (
r+dr < r_match) {
625 phi += (1./6.)*
dt*(dphidt+2.*dphidt_K2+2.*dphidt_K3+dphidt_K4);
638 d2rdt2 = gamma_isco*gamma_isco*(
639 - a_isco*(
r-r_isco)*(
r-r_isco)
640 + b_isco*(L_match-L_isco-nu*k_isco*gamma_isco*(
i-i_match)*
dt));
641 dphidt = (1./(pow(
r,3/2.)+
q))*(1. + nu*(d0+d1/
r+(d1_5+
q*l1_5)*pow(
r,-1.5)+d2*pow(
r,-2.0)));
642 d2phidt2 = (dphidt-dphidt_old)/(
dt);
645 r_K2 =
r+(
dt/2.)*drdt;
646 drdt_K2 = drdt+(
dt/2.)*d2rdt2;
647 dphidt_K2 = (1./(pow(r_K2,3/2.)+
q))*(1. + nu*(d0+d1/r_K2+(d1_5+
q*l1_5)*pow(r_K2,-1.5)+d2*pow(r_K2,-2.0)));
648 d2rdt2_K2 = gamma_isco*gamma_isco*(
649 - a_isco*(r_K2-r_isco)*(r_K2-r_isco)
650 + b_isco*(L_match-L_isco-nu*k_isco*gamma_isco*((
i-i_match)*
dt+(
dt/2.))));
653 r_K3 =
r+(
dt/2.)*drdt_K2;
654 drdt_K3 = drdt+(
dt/2.)*d2rdt2_K2;
655 dphidt_K3 = (1./(pow(r_K3,3/2.)+
q))*(1. + nu*(d0+d1/r_K3+(d1_5+
q*l1_5)*pow(r_K3,-1.5)+d2*pow(r_K3,-2.0)));
656 d2rdt2_K3 = gamma_isco*gamma_isco*(
657 - a_isco*(r_K3-r_isco)*(r_K3-r_isco)
658 + b_isco*(L_match-L_isco-nu*k_isco*gamma_isco*((
i-i_match)*
dt+(
dt/2.))));
661 r_K4 =
r+(
dt)*drdt_K3;
662 drdt_K4 = drdt+(
dt/2.)*d2rdt2_K3;
663 dphidt_K4 = (1./(pow(r_K4,3/2.)+
q))*(1. + nu*(d0+d1/r_K4+(d1_5+
q*l1_5)*pow(r_K4,-1.5)+d2*pow(r_K4,-2.0)));
664 d2rdt2_K4 = gamma_isco*gamma_isco*(
665 - a_isco*(r_K4-r_isco)*(r_K4-r_isco)
666 + b_isco*(L_match-L_isco-nu*k_isco*gamma_isco*((
i-i_match)*
dt+(
dt))));
670 (1. - 2.*(2.*
Sdotn*
Sdotn-1.)*pow(cos(phi),2.) - 3.*cos(2.*phi))*drdt*drdt
671 + (3. + (2.*
Sdotn*
Sdotn-1.))*(2.*cos(2.*phi)*dphidt*dphidt + sin(2.*phi)*d2phidt2)*
r*
r
672 + (4.*(3.+(2.*
Sdotn*
Sdotn-1.))*sin(2.*phi)*dphidt*drdt
673 + (1.-2.*(2.*
Sdotn*
Sdotn-1.)*pow(cos(phi),2.)-3.*cos(2.*phi))*d2rdt2)*
r);
675 hcross->
data[
i] = (-2.*
mu/D)*
Sdotn*( sin(2.*(phi))*drdt*drdt
676 +
r*
r*(-2.*sin(2.*(phi))*dphidt*dphidt + cos(2.*( phi))*d2phidt2)
677 +
r*(4.*cos(2.*(phi))*dphidt*drdt + sin(2.*(phi))*d2rdt2));
680 dr = (1./6.)*
dt*(drdt+2.*drdt_K2+2.*drdt_K3+drdt_K4);
681 if (
r+dr < r_plunge) {
684 dphidt = (L_plunge*(
r-2.)+2.*E_plunge*
q)/(E_plunge*(
r*
r*
r+(2.+
r)*
q*
q) - 2.*
q*L_plunge);
694 phi += (1./6.)*
dt*(dphidt+2.*dphidt_K2+2.*dphidt_K3+dphidt_K4);
695 drdt += (1./6.)*
dt*(d2rdt2+2.*d2rdt2_K2+2.*d2rdt2_K3+d2rdt2_K4);
710 if (i_finalplunge == 10) {
716 #if __GNUC__ >= 7 && !defined __INTEL_COMPILER
725 dphidt = (L_plunge*(
r-2.)+2.*E_plunge*
q)/(E_plunge*(
r*
r*
r+(2.+
r)*
q*
q) - 2.*
q*L_plunge);
726 d2phidt2 = (dphidt-dphidt_old)/(
dt);
730 r_K2 =
r + (
dt/2.)*drdt;
731 drdt_K2 = drdt + (
dt/2.)*d2rdt2;
732 dphidt_K2 = (L_plunge*(r_K2-2.)+2.*E_plunge*
q)/(E_plunge*(r_K2*r_K2*r_K2+(2.+r_K2)*
q*
q) - 2.*
q*L_plunge);
736 r_K3 =
r + (
dt/2.)*drdt_K2;
737 drdt_K3 = drdt + (
dt/2.)*d2rdt2_K2;
738 dphidt_K3 = (L_plunge*(r_K3-2.)+2.*E_plunge*
q)/(E_plunge*(r_K3*r_K3*r_K3+(2.+r_K3)*
q*
q) - 2.*
q*L_plunge);
742 r_K4 =
r + (
dt)*drdt_K3;
743 drdt_K4 = drdt + (
dt)*d2rdt2_K3;
744 dphidt_K4 = (L_plunge*(r_K4-2.)+2.*E_plunge*
q)/(E_plunge*(r_K4*r_K4*r_K4+(2.+r_K4)*
q*
q) - 2.*
q*L_plunge);
748 hplus->
data[
i] = (
mu/(2.*D))*((1. - 2.*(2.*
Sdotn*
Sdotn-1.)*pow(cos(phi),2.) - 3.*cos(2.*phi))*drdt*drdt
749 + (3. + (2.*
Sdotn*
Sdotn-1.))*(2.*cos(2.*phi)*dphidt*dphidt + sin(2.*phi)*d2phidt2)*
r*
r
750 + (4.*(3.+(2.*
Sdotn*
Sdotn-1.))*sin(2.*phi)*dphidt*drdt
751 + (1.-2.*(2.*
Sdotn*
Sdotn-1.)*pow(cos(phi),2.)-3.*cos(2.*phi))*d2rdt2)*
r);
753 hcross->
data[
i] = (-2.*
mu/D)*
Sdotn*( sin(2.*(phi))*drdt*drdt
754 +
r*
r*(-2.*sin(2.*(phi))*dphidt*dphidt + cos(2.*( phi))*d2phidt2)
755 +
r*(4.*cos(2.*(phi))*dphidt*drdt + sin(2.*(phi))*d2rdt2));
759 r += (1./6.)*
dt*(drdt+2.*drdt_K2+2.*drdt_K3+drdt_K4);
760 phi += (1./6.)*
dt*(dphidt+2.*dphidt_K2+2.*dphidt_K3+dphidt_K4);
761 drdt += (1./6.)*
dt*(d2rdt2+2.*d2rdt2_K2+2.*d2rdt2_K3+d2rdt2_K4);
764 if ((
r < r_lightring) && (currentStage ==
PLUNGE)) {
781 if (
r !=
r ||
r < 0.0) {
787 if (i_finalplunge <= 10)
788 XLALPrintError(
"Failed to complete 10 steps inside light ring. Use smaller time step dt. ");
801 if (i_finalplunge <= 10)
802 XLALPrintError(
"Failed to complete 10 steps inside light ring. Use smaller time step dt. ");
811 XLALPrintError(
"XLAL Error: Reached Npts before finishing plunge. Binary either failed to plunge, or Npts is too small.\n");
826 REAL8 fq[11] = {0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.98};
829 REAL8 w0_arr[11] = {0.3737, 0.3870, 0.4021, 0.4195, 0.4398, 0.4641, 0.4940, 0.5326, 0.5860, 0.6716, 0.8254};
830 REAL8 wi0_arr[11] = {0.0890, 0.0887, 0.0883, 0.0877, 0.0869, 0.0856, 0.0838, 0.0808, 0.0756, 0.0649, 0.0386};
833 REAL8 w1_arr[11] = {0.3467, 0.3619, 0.3790, 0.3984, 0.4208, 0.4474, 0.4798, 0.5212, 0.5779, 0.6677, 0.8249};
834 REAL8 wi1_arr[11] = {0.2739, 0.2725, 0.2705, 0.2680, 0.2647, 0.2602, 0.2538, 0.2442, 0.2281, 0.1953, 0.1159};
837 REAL8 w2_arr[11] = {0.3011, 0.3192, 0.3393, 0.3619, 0.3878, 0.4179, 0.4542, 0.4999, 0.5622, 0.6598, 0.8238};
838 REAL8 wi2_arr[11] = {0.4783, 0.4735, 0.4679, 0.4613, 0.4533, 0.4433, 0.4303, 0.4123, 0.3839, 0.3275, 0.1933};
841 const gsl_interp_type *bn = gsl_interp_cspline;
842 gsl_interp_accel *acc = gsl_interp_accel_alloc();
845 gsl_spline *spline0 = gsl_spline_alloc(bn,
N);
846 gsl_spline *spline1 = gsl_spline_alloc(bn,
N);
847 gsl_spline *spline2 = gsl_spline_alloc(bn,
N);
848 gsl_spline *spline3 = gsl_spline_alloc(bn,
N);
849 gsl_spline *spline4 = gsl_spline_alloc(bn,
N);
850 gsl_spline *spline5 = gsl_spline_alloc(bn,
N);
853 gsl_spline_init(spline0, fq, w0_arr,
N);
854 gsl_spline_init(spline1, fq, wi0_arr,
N);
855 gsl_spline_init(spline2, fq, w1_arr,
N);
856 gsl_spline_init(spline3, fq, wi1_arr,
N);
857 gsl_spline_init(spline4, fq, w2_arr,
N);
858 gsl_spline_init(spline5, fq, wi2_arr,
N);
865 w0 = gsl_spline_eval(spline0,
final_q, acc);
867 w1 = gsl_spline_eval(spline2,
final_q, acc);
869 w2 = gsl_spline_eval(spline4,
final_q, acc);
873 gsl_spline_free(spline0);
874 gsl_spline_free(spline1);
875 gsl_spline_free(spline2);
876 gsl_spline_free(spline3);
877 gsl_spline_free(spline4);
878 gsl_spline_free(spline5);
903 i_interp[
i] =
i+(i_lightring-10);
904 hp_interp[
i] = hplus->
data[
i+(i_lightring-10)]*D;
905 hx_interp[
i] = hcross->
data[
i+(i_lightring-10)]*D;
909 gsl_spline *spline_hp = gsl_spline_alloc(gsl_interp_cspline, 20);
910 gsl_spline *spline_hx = gsl_spline_alloc(gsl_interp_cspline, 20);
911 gsl_spline_init(spline_hp, i_interp, hp_interp, 20);
912 gsl_spline_init(spline_hx, i_interp, hx_interp, 20);
923 hp_1 = gsl_spline_eval(spline_hp, i_interp[9], acc);
924 dhpdi_1 = gsl_spline_eval_deriv(spline_hp, i_interp[9], acc);
925 hx_1 = gsl_spline_eval(spline_hx, i_interp[9], acc);
926 dhxdi_1 = gsl_spline_eval_deriv(spline_hx, i_interp[9], acc);
929 hp_2 = gsl_spline_eval(spline_hp, i_interp[10], acc);
930 dhpdi_2 = gsl_spline_eval_deriv(spline_hp, i_interp[10], acc);
931 hx_2 = gsl_spline_eval(spline_hx, i_interp[10], acc);
932 dhxdi_2 = gsl_spline_eval_deriv(spline_hx, i_interp[10], acc);
935 hp_3 = gsl_spline_eval(spline_hp, i_interp[11], acc);
936 dhpdi_3 = gsl_spline_eval_deriv(spline_hp, i_interp[11], acc);
937 hx_3 = gsl_spline_eval(spline_hx, i_interp[11], acc);
938 dhxdi_3 = gsl_spline_eval_deriv(spline_hx, i_interp[11], acc);
941 gsl_spline_free(spline_hp);
942 gsl_spline_free(spline_hx);
981 const gsl_multiroot_fsolver_type *T;
982 const gsl_multiroot_fsolver_type *
Q;
983 gsl_multiroot_fsolver *plus_solver;
984 gsl_multiroot_fsolver *cross_solver;
985 INT4 statusp, statusc;
987 const size_t nmatch = 6;
994 REAL8 x_init[6] = {-0.392254, 4.575194, -0.870431, 5.673678, 0.979356, -3.637467};
995 REAL8 z_init[6] = {-0.392254, 4.575194, -0.870431, 5.673678, 0.979356, -3.637467};
996 gsl_vector *xmr = gsl_vector_alloc(nmatch);
997 gsl_vector *z = gsl_vector_alloc(nmatch);
999 for (
size_t i=0;
i<nmatch;
i++) {
1000 gsl_vector_set(xmr,
i, x_init[
i]);
1001 gsl_vector_set(z,
i, z_init[
i]);
1005 T = gsl_multiroot_fsolver_hybrids;
1006 Q = gsl_multiroot_fsolver_hybrids;
1007 plus_solver = gsl_multiroot_fsolver_alloc(T, 6);
1008 cross_solver = gsl_multiroot_fsolver_alloc(
Q, 6);
1009 gsl_multiroot_fsolver_set(plus_solver, &f_plus, xmr);
1010 gsl_multiroot_fsolver_set(cross_solver, &f_cross, z);
1012 REAL8 fminval = 1.e-5;
1013 size_t MaxITS = 200000;
1018 statusp = gsl_multiroot_fsolver_iterate(plus_solver);
1020 statusp = gsl_multiroot_test_residual(plus_solver->f, fminval);
1022 while (statusp == GSL_CONTINUE && iter < MaxITS);
1028 statusc = gsl_multiroot_fsolver_iterate(cross_solver);
1030 statusc = gsl_multiroot_test_residual(cross_solver->f, fminval);
1032 while (statusc == GSL_CONTINUE && iter < MaxITS);
1034 if (statusc != GSL_SUCCESS) {
1040 a0n = gsl_vector_get(plus_solver->x,0);
1041 a0p = gsl_vector_get(plus_solver->x,1);
1042 a1n = gsl_vector_get(plus_solver->x,2);
1043 a1p = gsl_vector_get(plus_solver->x,3);
1044 a2n = gsl_vector_get(plus_solver->x,4);
1045 a2p = gsl_vector_get(plus_solver->x,5);
1046 a0c = gsl_vector_get(cross_solver->x,0);
1047 a0cp = gsl_vector_get(cross_solver->x,1);
1048 a1c = gsl_vector_get(cross_solver->x,2);
1049 a1cp = gsl_vector_get(cross_solver->x,3);
1050 a2c = gsl_vector_get(cross_solver->x,4);
1051 a2cp = gsl_vector_get(cross_solver->x,5);
1054 gsl_multiroot_fsolver_free(plus_solver);
1055 gsl_multiroot_fsolver_free(cross_solver);
1056 gsl_vector_free(xmr);
1064 REAL8 hp0, hp1, hp2;
1065 REAL8 hc0, hc1, hc2;
1067 REAL8 hp_ringdown, hc_ringdown;
1073 for (
UINT4 i=i_lightring;
i<Npts;
i++) {
1085 hp_ringdown = (hp0+hp1+hp2);
1086 hc_ringdown = -(hc0+hc1+hc2);
1089 hplus->
data[
i] = ringdown_amp*hp_ringdown;
1090 hcross->
data[
i] = ringdown_amp*hc_ringdown;
1093 if (fabs(hplus->
data[
i]) < 1.e-30) {
1140 XLALPrintError(
"XLAL Error: Minimum frequency is %f. f_min must be greater than 0\n",
f_min);
1144 if (
q >= 1 ||
q<=-1) {
1145 XLALPrintError(
"XLAL Error: Magnitude of BH spin %f must be less than 1.\n",
q);
1150 XLALPrintWarning(
"XLAL Warning: Mass-ratio is %f. Code likely inaccurate for mass ratios m2/m1 > 1/10\n",
m/
M);
1154 XLALPrintError(
"XLAL Error: Distance %f Mpc to source must be greater than 0 Mpc.\n",dist);
1165 size_t iter=0, max_iter = 100;
1166 const gsl_root_fsolver_type *T;
1167 gsl_root_fsolver *
s;
1179 F.params = &p0Params;
1183 REAL8 p_high = 500.;
1187 if (
q==0.) p_low = 6.;
1189 REAL8 Z1 = 1. + pow((1.-
q*
q),1./3.)*(pow(1.+
q, 1./3.)+pow(1.-
q, 1./3.));
1190 REAL8 Z2 = sqrt(3.*
q*
q + Z1*Z1);
1191 p_low = 3. + Z2 - (
q/fabs(
q))*sqrt((3. - Z1)*(3. + Z1 + 2.*Z2));
1195 T = gsl_root_fsolver_brent;
1196 s = gsl_root_fsolver_alloc(T);
1197 gsl_root_fsolver_set(
s, &F, p_low, p_high);
1201 status = gsl_root_fsolver_iterate(
s);
1202 p0 = gsl_root_fsolver_root(
s);
1203 p_low = gsl_root_fsolver_x_lower(
s);
1204 p_high = gsl_root_fsolver_x_upper(
s);
1205 status = gsl_root_test_interval (p_low, p_high, 0, 0.001);
1207 while (
status == GSL_CONTINUE && iter < max_iter);
1208 gsl_root_fsolver_free(
s);
1210 if (
status != GSL_SUCCESS) {
1211 XLALPrintError(
"XLAL Error: Rootfinding failed. Could not find inital radius ISCO < r < 500M satisfying specified initial frequency.\n");
1216 XLALPrintWarning(
"XLAL Warning: Beginning at large initial radius p0 = %fM. Code will require long runtime to compute waveform.\n",p0);
1224 size_t length = 1000/
dt;
1228 if (*hplus == NULL || *hcross == NULL)
1232 i_ref =
HGimri_start(
m*
Msun_sec,
M*
Msun_sec,
q,dist*
GPC_sec,Sdotn,phi0,p0,(*hplus)->data,(*hcross)->data,
dt/((
m+
M)*
Msun_sec),length);
static INT4 HGimri_start(REAL8 m, REAL8 M, REAL8 q, REAL8 D, REAL8 Sdotn, REAL8 phi0, REAL8 p0, REAL8Sequence *hplus, REAL8Sequence *hcross, REAL8 dt, UINT4 Npts)
static REAL8 XLALHGimri_AngMomFlux(REAL8 q, REAL8 r, REAL8 nu)
static INT4 XLALHGimri_CrossEquations(const gsl_vector *z, void *params, gsl_vector *g)
static REAL8 XLALHGimri_dFdr(REAL8 E, REAL8 Lz, REAL8 a, REAL8 r)
static REAL8 XLALHGimri_dLzdr(REAL8 q, REAL8 r)
static INT4 XLALHGimri_PlusEquations(const gsl_vector *x, void *params, gsl_vector *f)
static REAL8 XLALHGimri_initialP(REAL8 p0, void *params)
INT4 XLALHGimriGenerator(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 phi0, REAL8 dt, REAL8 m1, REAL8 m2, REAL8 f_min, REAL8 r, REAL8 inc, REAL8 s1z)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalStrainUnit
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)