forked from Shallyn/pyWaveformGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpHamiltonian.c
5672 lines (4888 loc) · 219 KB
/
pHamiltonian.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Writer: Xiaolin.liu
*
* This module contains basic functions for calculating EOB real SpinHamiltonian.
* Functions list:
Calculate_EOBSpinHamiltonian()
* Kernel:
* 20xx.xx.xx, LOC
**/
#include "pHamiltonian.h"
#include "pEnergyFlux.h"
#include "pFactorizedWaveform.h"
#include "newFactorizedWaveformPrec.h"
#include "myLog.h"
#include <gsl/gsl_deriv.h>
// Calibrationv21_Sep8a
// K
static const REAL8 coeff00K = 1.7336;
static const REAL8 coeff01K = -1.62045;
static const REAL8 coeff02K = -1.38086;
static const REAL8 coeff03K = 1.43659;
static const REAL8 coeff10K = 10.2573;
static const REAL8 coeff11K = 2.26831;
static const REAL8 coeff12K = 0;
static const REAL8 coeff13K = -0.426958;
static const REAL8 coeff20K = -126.687;
static const REAL8 coeff21K = 17.3736;
static const REAL8 coeff22K = 6.16466;
static const REAL8 coeff23K = 0;
static const REAL8 coeff30K = 267.788;
static const REAL8 coeff31K = -27.5201;
static const REAL8 coeff32K = 31.1746;
static const REAL8 coeff33K = -59.1658;
// dSO
static const REAL8 coeff00dSO = -44.5324;
static const REAL8 coeff01dSO = 0;
static const REAL8 coeff02dSO = 0;
static const REAL8 coeff03dSO = 66.1987;
static const REAL8 coeff10dSO = 0;
static const REAL8 coeff11dSO = 0;
static const REAL8 coeff12dSO = -343.313;
static const REAL8 coeff13dSO = -568.651;
static const REAL8 coeff20dSO = 0;
static const REAL8 coeff21dSO = 2495.29;
static const REAL8 coeff22dSO = 0;
static const REAL8 coeff23dSO = 147.481;
static const REAL8 coeff30dSO = 0;
static const REAL8 coeff31dSO = 0;
static const REAL8 coeff32dSO = 0;
static const REAL8 coeff33dSO = 0;
// dSS
static const REAL8 coeff00dSS = 6.06807;
static const REAL8 coeff01dSS = 0;
static const REAL8 coeff02dSS = 0;
static const REAL8 coeff03dSS = 0;
static const REAL8 coeff10dSS = -36.0272;
static const REAL8 coeff11dSS = 37.1964;
static const REAL8 coeff12dSS = 0;
static const REAL8 coeff13dSS = -41.0003;
static const REAL8 coeff20dSS = 0;
static const REAL8 coeff21dSS = 0;
static const REAL8 coeff22dSS = -326.325;
static const REAL8 coeff23dSS = 528.511;
static const REAL8 coeff30dSS = 706.958;
static const REAL8 coeff31dSS = 0;
static const REAL8 coeff32dSS = 1161.78;
static const REAL8 coeff33dSS = 0.;
INT EOBCalculateSpinEOBHamCoeffs(SpinEOBHCoeffs *coeffs,
const REAL8 eta,
const REAL8 a,
HyperParams *params)
{
if (!coeffs)
return CEV_FAILURE;
memset (coeffs, 0, sizeof (SpinEOBHCoeffs));
REAL8 KK, k0, k1, k2, k3, k4, k5, k5l, k1p2, k1p3;
REAL8 m1PlusEtaKK;
REAL8 chi = a / (1. - 2. * eta);
REAL8 eta2 = eta * eta, eta3 = eta2 * eta;
REAL8 chi2 = chi * chi, chi3 = chi2 * chi;
static const REAL8 ln2 = 0.6931471805599453094172321214581765680755;
coeffs->KK = KK =
coeff00K + coeff01K * chi + coeff02K * chi2 + coeff03K * chi3 +
coeff10K * eta + coeff11K * eta * chi + coeff12K * eta * chi2 +
coeff13K * eta * chi3 + coeff20K * eta2 + coeff21K * eta2 * chi +
coeff22K * eta2 * chi2 + coeff23K * eta2 * chi3 + coeff30K * eta3 +
coeff31K * eta3 * chi + coeff32K * eta3 * chi2 + coeff33K * eta3 * chi3;
if (params && params->flagTuning)
coeffs->KK = params->KK;
m1PlusEtaKK = -1. + eta * KK;
/* Eqs. 5.77 - 5.81 of BB1 */
coeffs->k0 = k0 = KK * (m1PlusEtaKK - 1.);
coeffs->k1 = k1 = -2. * (k0 + KK) * m1PlusEtaKK;
k1p2 = k1 * k1;
k1p3 = k1 * k1p2;
coeffs->k2 = k2 =
(k1 * (k1 - 4. * m1PlusEtaKK)) / 2. -
a * a * k0 * m1PlusEtaKK * m1PlusEtaKK;
coeffs->k3 = k3 =
-k1 * k1 * k1 / 3. + k1 * k2 + k1 * k1 * m1PlusEtaKK - 2. * (k2 -
m1PlusEtaKK)
* m1PlusEtaKK - a * a * k1 * m1PlusEtaKK * m1PlusEtaKK;
coeffs->k4 = k4 =
(24. * k1 * k1 * k1 * k1 - 96. * k1 * k1 * k2 + 48. * k2 * k2 -
64. * k1 * k1 * k1 * m1PlusEtaKK + 48. * a * a * (k1 * k1 -
2. * k2) *
m1PlusEtaKK * m1PlusEtaKK + 96. * k1 * (k3 + 2. * k2 * m1PlusEtaKK) -
m1PlusEtaKK * (192. * k3 +
m1PlusEtaKK * (-3008. + 123. * CST_PI * CST_PI))) / 96.;
/* Include eta^2 terms at 4PN from arXiv:1305.4884 */
coeffs->k5 = k5 = m1PlusEtaKK * m1PlusEtaKK
* (-4237. / 60. + 128. / 5. * CST_GAMMA +
2275. * CST_PI * CST_PI / 512. - 1. / 3. * a * a * (k1p3 -
3. * k1 * k2 +
3. * k3) -
(k1p3 * k1p2 - 5. * k1p3 * k2 + 5. * k1 * k2 * k2 +
5. * k1p2 * k3 - 5. * k2 * k3 -
5. * k1 * k4) / 5. / m1PlusEtaKK / m1PlusEtaKK + (k1p2 * k1p2 -
4. * k1p2 * k2 +
2. * k2 * k2 +
4. * k1 * k3 -
4. * k4) / 2. /
m1PlusEtaKK + 256. / 5. * ln2 + (41. * CST_PI * CST_PI / 32. -
221. / 6.) * eta);
coeffs->k5l = k5l = m1PlusEtaKK * m1PlusEtaKK * 64. / 5.;
coeffs->d1v2 =
coeff00dSO + coeff01dSO * chi + coeff02dSO * chi2 + coeff03dSO * chi3 +
coeff10dSO * eta + coeff11dSO * eta * chi + coeff12dSO * eta * chi2 +
coeff13dSO * eta * chi3 + coeff20dSO * eta2 + coeff21dSO * eta2 * chi +
coeff22dSO * eta2 * chi2 + coeff23dSO * eta2 * chi3 + coeff30dSO * eta3 +
coeff31dSO * eta3 * chi + coeff32dSO * eta3 * chi2 + coeff33dSO * eta3 * chi3;
// dSS
coeffs->dheffSSv2 =
coeff00dSS + coeff01dSS * chi + coeff02dSS * chi2 + coeff03dSS * chi3 +
coeff10dSS * eta + coeff11dSS * eta * chi + coeff12dSS * eta * chi2 +
coeff13dSS * eta * chi3 + coeff20dSS * eta2 + coeff21dSS * eta2 * chi +
coeff22dSS * eta2 * chi2 + coeff23dSS * eta2 * chi3 + coeff30dSS * eta3 +
coeff31dSS * eta3 * chi + coeff32dSS * eta3 * chi2 + coeff33dSS * eta3 * chi3;
if (params && params->flagTuning)
{
coeffs->d1v2 = params->dSO;
coeffs->dheffSSv2 = params->dSS;
}
return CEV_SUCCESS;
}
INT XLALSimIMRCalculateSpinPrecEOBHCoeffs_v2(
SpinEOBHCoeffs *coeffs, /**<< OUTPUT, EOB parameters including pre-computed coefficients */
const REAL8 eta, /**<< symmetric mass ratio */
REAL8 a, /**<< Normalized deformed Kerr spin */
REAL8 chi, /**<< The augmented spin, with correct aligned-spin limit */
const UINT SpinAlignedEOBversion, /**<< 4 for SEOBNRv4P; Possible to extend this later later */
HyperParams *params
)
{
REAL8 KK, k0, k1, k2, k3, k4, k5, k5l, k1p2, k1p3;
REAL8 m1PlusEtaKK;
if (!coeffs)
{
return CEV_FAILURE;
}
// coeffs->SpinAlignedEOBversion = SpinAlignedEOBversion;
const int debugPK = 0;
// if (debugPK)
// {
// PRINT_LOG_INFO(LOG_CRITICAL, "In XLALSimIMRCalculateSpinPrecEOBHCoeffs: SpinAlignedEOBversion = %d,%d\n",
// (int)SpinAlignedEOBversion, (int)coeffs->SpinAlignedEOBversion);
// fflush(NULL);
// }
static const REAL8 third = 1. / 3.;
static const REAL8 fifth = 1. / 5.;
static const REAL8 ln2 = 0.6931471805599453094172321214581765680755; // log(2.)
coeffs->b3 = 0.;
coeffs->bb3 = 0.;
REAL8 eta2 = eta * eta, eta3 = eta2 * eta;
REAL8 chi2 = chi * chi, chi3 = chi2 * chi;
coeffs->KK = KK = 0;
if (SpinAlignedEOBversion == 4)
{
// See Eq.(4.8) and Eq.(4.12) in Bohe et al
coeffs->KK = KK =
coeff00K + coeff01K * chi + coeff02K * chi2 + coeff03K * chi3 +
coeff10K * eta + coeff11K * eta * chi + coeff12K * eta * chi2 +
coeff13K * eta * chi3 + coeff20K * eta2 + coeff21K * eta2 * chi +
coeff22K * eta2 * chi2 + coeff23K * eta2 * chi3 + coeff30K * eta3 +
coeff31K * eta3 * chi + coeff32K * eta3 * chi2 + coeff33K * eta3 * chi3;
}
if (params && params->flagTuning)
coeffs->KK = params->KK;
m1PlusEtaKK = -1. + eta * KK;
const REAL8 invm1PlusEtaKK = 1. / m1PlusEtaKK;
/* Eqs.(5.77 - 5.81) of Baruasse and Buonnano PRD 81, 084024 (2010) */
coeffs->k0 = k0 = KK * (m1PlusEtaKK - 1.);
coeffs->k1 = k1 = -2. * (k0 + KK) * m1PlusEtaKK;
k1p2 = k1 * k1;
k1p3 = k1 * k1p2;
coeffs->k2 = k2 = (k1 * (k1 - 4. * m1PlusEtaKK)) * 0.5 - a * a * k0 * m1PlusEtaKK * m1PlusEtaKK;
coeffs->k3 = k3 = -(k1 * k1) * k1 * third + k1 * k2 + (k1 * k1) * m1PlusEtaKK - 2. * (k2 - m1PlusEtaKK) * m1PlusEtaKK - a * a * k1 * (m1PlusEtaKK * m1PlusEtaKK);
coeffs->k4 = k4 = ((24. / 96.) * (k1 * k1) * (k1 * k1) - (96. / 96.) * (k1 * k1) * k2 + (48. / 96.) * k2 * k2 - (64. / 96.) * (k1 * k1) * k1 * m1PlusEtaKK + (48. / 96.) * (a * a) * (k1 * k1 - 2. * k2) * (m1PlusEtaKK * m1PlusEtaKK) +
(96. / 96.) * k1 * (k3 + 2. * k2 * m1PlusEtaKK) - m1PlusEtaKK * ((192. / 96.) * k3 + m1PlusEtaKK * (-(3008. / 96.) + (123. / 96.) * CST_PI * CST_PI)));
if (SpinAlignedEOBversion == 4)
{
// Look at Eq.(A2C) in Steinhoff et al. The last term from Eq.(2.3) in Bohe et al.
coeffs->k5 = k5 = m1PlusEtaKK * m1PlusEtaKK * (-4237. / 60. + 128. / 5. * CST_GAMMA + 2275. * CST_PI * CST_PI / 512. - third * (a * a) * (k1p3 - 3. * (k1 * k2) + 3. * k3) - ((k1p3 * k1p2) - 5. * (k1p3 * k2) + 5. * k1 * k2 * k2 + 5. * k1p2 * k3 - 5. * k2 * k3 - 5. * k1 * k4) * fifth * invm1PlusEtaKK * invm1PlusEtaKK + ((k1p2 * k1p2) - 4. * (k1p2 * k2) + 2. * k2 * k2 + 4. * k1 * k3 - 4. * k4) * 0.5 * invm1PlusEtaKK + (256. / 5.) * ln2 + (41. * CST_PI * CST_PI / 32. - 221. / 6.) * eta);
// This is the first term in the brackets in Eq.(A2C) in Steinhoff et al.
coeffs->k5l = k5l = (m1PlusEtaKK * m1PlusEtaKK) * (64. / 5.);
}
/* Now calibrated parameters for spin models */
if (SpinAlignedEOBversion == 4)
{
coeffs->d1 = 0.;
coeffs->dheffSS = 0.;
// dSO: Eq.(4.13) in Bohe et al
coeffs->d1v2 =
coeff00dSO + coeff01dSO * chi + coeff02dSO * chi2 + coeff03dSO * chi3 +
coeff10dSO * eta + coeff11dSO * eta * chi + coeff12dSO * eta * chi2 +
coeff13dSO * eta * chi3 + coeff20dSO * eta2 + coeff21dSO * eta2 * chi +
coeff22dSO * eta2 * chi2 + coeff23dSO * eta2 * chi3 + coeff30dSO * eta3 +
coeff31dSO * eta3 * chi + coeff32dSO * eta3 * chi2 + coeff33dSO * eta3 * chi3;
// dSS: Eq.(4.14) in Bohe et al
coeffs->dheffSSv2 =
coeff00dSS + coeff01dSS * chi + coeff02dSS * chi2 + coeff03dSS * chi3 +
coeff10dSS * eta + coeff11dSS * eta * chi + coeff12dSS * eta * chi2 +
coeff13dSS * eta * chi3 + coeff20dSS * eta2 + coeff21dSS * eta2 * chi +
coeff22dSS * eta2 * chi2 + coeff23dSS * eta2 * chi3 + coeff30dSS * eta3 +
coeff31dSS * eta3 * chi + coeff32dSS * eta3 * chi2 + coeff33dSS * eta3 * chi3;
// printf("dSO %.16e, dSS %.16e\n", coeffs->d1v2,coeffs->dheffSSv2);
}
if (params && params->flagTuning)
{
coeffs->d1v2 = params->dSO;
coeffs->dheffSSv2 = params->dSS;
}
// print_debug("Hparams:\n");
// print_err("a = %.16e, eta = %.16e, chi = %.16e\n", a, eta, chi);
// print_err("K = %.16e, k0 = %.16e, k1 = %.16e\n", KK, k0, k1);
// print_err("k2 = %.16e, k3 = %.16e, k4 = %.16e\n", k2, k3, k4);
// print_err("k5 = %.16e, k5l = %.16e, d1v2 = %.16e, dheffSSv2 = %.16e\n", k5, k5l, coeffs->d1v2, coeffs->dheffSSv2);
return CEV_SUCCESS;
}
void CalculateSpinEOBHSACoeffs(REAL8 m1, REAL8 m2, REAL8 s1z, REAL8 s2z, SpinEOBHSACoeffs *coeffs)
{
REAL8 mtot = m1 + m2;
REAL8 eta = m1*m2/mtot/mtot;
REAL8 s1N = s1z * m1*m1 / mtot / mtot;
REAL8 s2N = s2z * m2*m2 / mtot / mtot;
coeffs->eta = eta;
REAL8 sigmaStar, sigmaKerr;
sigmaStar = coeffs->sigmaStar = m2*s1N/m1 + m1*s2N/m2;
sigmaKerr = coeffs->sigmaKerr = s1N + s2N;
if(sigmaKerr < 0.0)
coeffs->sign = -1.;
else
coeffs->sign = 1.;
REAL8 a;
a = coeffs->a = fabs(coeffs->sigmaKerr);
coeffs->a2 = a*a;
REAL8 chi, chi2, chi3;
REAL8 eta2, eta3;
chi = sigmaKerr / (1. - eta*2.);
chi2 = chi*chi;
chi3 = chi2*chi;
eta2 = eta*eta;
eta3 = eta2*eta;
REAL8 KK, m1PlusEtaKK;
KK = 1.7336 + (-1.62045)*chi + (-1.38086)*chi2 + (1.43659)*
chi3 + (10.2573)*eta + (2.26831)*eta*chi + (-0.426958)*eta*
chi3 + (-126.687)*eta2 + (17.3736)*eta2*chi + (6.16466)*eta2*
chi2 + (267.788)*eta3 + (-27.5201)*eta3*chi + (31.1746)*eta3*
chi2 + (-59.1658)*eta3*chi3;
REAL8 k0, k1, k2, k3, k4;
m1PlusEtaKK = -1. + eta*KK;
coeffs->k0 = k0 = KK*(m1PlusEtaKK - 1.);
coeffs->k1 = k1 = -2.*(k0 + KK)*m1PlusEtaKK;
coeffs->k2 = k2 = (k1*(k1 - 4.*m1PlusEtaKK))*0.5 - a*a*k0*m1PlusEtaKK*m1PlusEtaKK;
coeffs->k3 = k3 = -(k1*k1)*k1*(1./3.) + k1*k2 + (k1*k1)*m1PlusEtaKK -
2.*(k2 - m1PlusEtaKK)*m1PlusEtaKK -
a*a*k1*(m1PlusEtaKK*m1PlusEtaKK);
coeffs->k4 = k4 = ((24./96.)*(k1*k1)*(k1*k1) - (96./96.)*(k1*k1)*k2 + (48./96.)*
k2*k2 - (64./96.)*(k1*k1)*k1*m1PlusEtaKK + (48./96.)*(a*a)*(k1*k1 - 2.*k2)*(m1PlusEtaKK*
m1PlusEtaKK) + (96./96.)*k1*(k3 + 2.*k2*m1PlusEtaKK) -
m1PlusEtaKK*((192./96.)*k3 + m1PlusEtaKK*(-(3008./96.) + (123./96.)*CST_PI*CST_PI)));
REAL8 k1p2 = k1*k1;
REAL8 k1p3 = k1*k1p2;
REAL8 invm1PlusEtaKK = 1./m1PlusEtaKK;
coeffs->k5 = m1PlusEtaKK*
m1PlusEtaKK*(-4237./60. + 128./5.*CST_GAMMA +
2275.*CST_PI*CST_PI/
512. - (1./3.)*(a*a)*(k1p3 - 3.*(k1*k2) +
3.*k3) - ((k1p3*k1p2) - 5.*(k1p3*k2) + 5.*k1*k2*k2 +
5.*k1p2*k3 - 5.*k2*k3 - 5.*k1*k4)*(1./5.)*invm1PlusEtaKK*
invm1PlusEtaKK + ((k1p2*k1p2) - 4.*(k1p2*k2) + 2.*k2*k2 +
4.*k1*k3 - 4.*k4)*0.5*invm1PlusEtaKK + (256./5.)*
CST_LN2 + (41.*CST_PI*CST_PI/32. - 221./6.)*eta);
coeffs->k5l = (m1PlusEtaKK*m1PlusEtaKK)*(64./5.);
REAL8 d1v2 = -44.5324 +
66.1987*chi3 + (-343.313)*eta*chi2 + (-568.651)*eta*
chi3 + (2495.29)*eta2*chi + (147.481)*eta2*chi3;
REAL8 dheffSSv2 =
6.06807 + (-36.0272)*eta +
37.1964*eta*chi + (-41.0003)*eta*chi3 + (-326.325)*eta2*
chi2 + (528.511)*eta2*chi3 + (706.958)*eta3 + (1161.78)*eta3*
chi2;
// print_debug("k1 = %.16e, k2 = %.16e, k3 = %.16e, k4 = %.16e, k5 = %.16e, k5l = %.16e\n",
// k1, k2, k3, k4, coeffs->k5, coeffs->k5l);
coeffs->b3 = 0;
coeffs->bb3 = 0;
coeffs->invm1PlusEtaKK = invm1PlusEtaKK;
coeffs->PQ4 = 2.*eta*(4.-3.*eta);
coeffs->Pds0u = eta*(7.*sigmaStar - 4.*sigmaKerr)/6.;
coeffs->Pds0p2 = eta * (3.*sigmaKerr + 4.*sigmaStar)/12.;
coeffs->Pds0pn2 = -eta*(6.*sigmaKerr + 5.*sigmaStar)/2.;
coeffs->PdsSu2 = eta*(353. - 27.*eta)/36.;
coeffs->PdsSup2 = (-103. + 60.*eta)*eta / 36.;
coeffs->PdsSpn4 = 5.*eta*eta;
coeffs->PdsSp4 = (-23.-3.*eta)*eta/72.;
coeffs->PdsSupn2 = (47. - 54.*eta)*eta/12.;
coeffs->PdsSp2pn2 = (16. - 21.*eta)*eta/12.;
coeffs->PdsKu2 = (-56. - 21.*eta)*eta/9.;
coeffs->PdsKpn4 = 5.*27*eta*eta/24.;
coeffs->PdsKp4 = -45.*eta/144.;
coeffs->PdsKup2 = (-109.+51.*eta)*eta/36.;
coeffs->PdsKp2pn2 = (6. - 39.*eta)*eta/24.;
coeffs->PdsKupn2 = (-16.-147.*eta)*eta/24.;
coeffs->PdsKu3 = d1v2 * eta;
coeffs->Peffss = dheffSSv2 * eta * (s1N*s1N + s2N*s2N);
// print_debug("PdsKu2 = %.16e, PdsKpn4 = %.16e, PdsKup2 = %.16e, PdsKp2pn2 = %.16e, PdsKupn2 = %.16e, PdsKu3 = %.16e\n",
// coeffs->PdsKu2, coeffs->PdsKpn4, coeffs->PdsKup2, coeffs->PdsKp2pn2, coeffs->PdsKupn2, coeffs->PdsKu3);
coeffs->D2 = 6.*eta;
coeffs->D3 = 2.*(26.-3.*eta)*eta;
return;
}
REAL8 EOBSAHamiltonian(REAL8 r, REAL8 prT, REAL8 pphi, SpinEOBHSACoeffs *coeffs, REAL8 *csi)
{
REAL8 r2 = r*r;
REAL8 u = 1./r, u2, u3, u4, u5, logu;
REAL8 deltaU, deltaU0, deltaULog, deltaU_u;
REAL8 deltaT, deltaT_r, DD, deltaR, B, CC, w2, Lambda, Lambda_r, invLambda;
REAL8 invxia, pr, wfd, wfd_r;
REAL8 alpha, beta, gammar, gammaphi;
REAL8 pnBar2, pBar2, Xi;
REAL8 deltaSigma0, deltaSigmaS, deltaSigmaK;
REAL8 HNS, SStar, wr, BR, nur, sqQ, QTilde;
REAL8 HTwr, HSOL, HSONL, HSS, HSSeff, HS, Heff, Hreal;
REAL8 pf = coeffs->sign * pphi;
u2 = u*u;
u3 = u2*u;
u4 = u3*u;
u5 = u4*u;
deltaU0 = coeffs->invm1PlusEtaKK * (coeffs->invm1PlusEtaKK + 2.*u) + coeffs->a2 * u2;
// logu = log2(u)*CST_INV_LOG2E;
// logu = log(u);
const REAL8 invlog_2e = 0.69314718055994530941723212145817656807550013436026;
logu = log2(u)*invlog_2e;
// const REAL8 logarg = coeffs->k1*u + coeffs->k2*u2 + coeffs->k3*u3 + coeffs->k4*u4
// + coeffs->k5*u5 + coeffs->k5l*u5*logu;
const REAL8 logarg = u*(coeffs->k1 + u*(coeffs->k2 + u*(coeffs->k3 + u*(coeffs->k4 + u*(coeffs->k5 + coeffs->k5l*logu)))));
// deltaULog = 1. + coeffs->eta*coeffs->k0 + coeffs->eta*log1p(fabs(1. + logarg) - 1.);
deltaULog = 1. + coeffs->eta*coeffs->k0 + coeffs->eta*log(1. + logarg);
deltaU = deltaU0 * deltaULog;
// deltaU_u = 2.*(coeffs->invm1PlusEtaKK + coeffs->a2*u) * deltaULog +
// deltaU0 * coeffs->eta * (coeffs->k1 + 2.*coeffs->k2*u + 3.*coeffs->k3*u2 + 4.*coeffs->k4*u3 + 5.*(coeffs->k5 + coeffs->k5l*logu)*u4) / (1.+logarg);
deltaU_u = 2.*(coeffs->invm1PlusEtaKK + coeffs->a2*u) * deltaULog +
deltaU0 * coeffs->eta * (coeffs->k1 +
u*(2.*coeffs->k2 +
u*(3.*coeffs->k3 +
u*(4.*coeffs->k4 +
u*5.*(coeffs->k5 + coeffs->k5l*logu))))) / (1.+logarg);
deltaT = r2 * deltaU;
deltaT_r = 2.*r*deltaU - deltaU_u;
DD = 1. + log(1. + coeffs->D2 * u2 + coeffs->D3 * u3);
// DD = 1. + log1p(coeffs->D2 * u2 + coeffs->D3 * u3);
deltaR = deltaT * DD;
B = sqrt(deltaT);
CC = sqrt(deltaR);
w2 = r2 + coeffs->a2;
Lambda = w2*w2 - coeffs->a2*deltaT;
Lambda_r = 4.*r*w2 - coeffs->a2*deltaT_r;
invLambda = 1./Lambda;
invxia = w2 / (B*CC);
*csi = B*CC / w2;
pr = prT * invxia;
wfd = 2.*coeffs->a*r + coeffs->b3 / r + coeffs->bb3 / r;
wfd_r = 2.*coeffs->a - coeffs->b3 * u2 - coeffs->bb3*u2;
alpha = r * B * sqrt(invLambda);
beta = wfd * invLambda;
gammar = deltaR * u2;
gammaphi = r2 * invLambda;
pnBar2 = gammar * pr*pr;
pBar2 = pnBar2 + gammaphi * pf*pf;
Xi = 1. + coeffs->PQ4 * prT * prT *prT *prT * u2 + pBar2;
HNS = pf * beta + alpha * sqrt(Xi);
// if(IS_DEBUG){
// print_debug( "term 1 in Hns: %.16e\n", coeffs->PQ4 * prT * prT *prT *prT * u2 );
// print_debug( "term 2 in Hns: %.16e\n", 0.0 );
// print_debug( "term 3 in Hns = %.16e\n", gammaphi * pf*pf );
// print_debug( "term 4 in Hns = %.16e\n", pnBar2 );
// print_debug( "term 5 in Hns = %.16e\n", 1./(alpha*alpha) );
// print_debug( "term 6 in Hns = %.16e\n", pf );}
deltaSigma0 = coeffs->Pds0u * u + coeffs->Pds0p2 * pBar2 + coeffs->Pds0pn2 * pnBar2;
deltaSigmaS = coeffs->PdsSu2 * u2 + coeffs->PdsSup2 * u*pBar2 + coeffs->PdsSpn4*pnBar2*pnBar2 + coeffs->PdsSp4*pBar2*pBar2 +
coeffs->PdsSupn2*u*pnBar2+coeffs->PdsSp2pn2*pBar2*pnBar2;
deltaSigmaK = coeffs->PdsKu2*u2 + coeffs->PdsKup2*u*pBar2 + coeffs->PdsKpn4*pnBar2*pnBar2 + coeffs->PdsKp4*pBar2*pBar2 +
coeffs->PdsKupn2 * u*pnBar2 + coeffs->PdsKp2pn2*pBar2*pnBar2 + coeffs->PdsKu3 * u3;
SStar = coeffs->sign*(coeffs->sigmaStar + deltaSigma0 + deltaSigmaS * coeffs->sigmaStar + deltaSigmaK * coeffs->sigmaKerr);
wr = (-Lambda_r * wfd + Lambda * wfd_r) * invLambda*invLambda;
BR = -sqrt(1./DD) + deltaT_r/(2.*B);
nur = u + 0.5*w2*(-4.*r*deltaT + w2*deltaT_r)*invLambda/deltaT;
sqQ = sqrt(1. + pBar2);
QTilde = sqQ * (1. + sqQ);
REAL8 alpha2 = alpha*alpha;
HTwr = 0.5 * CC * SStar * (r2 * alpha2*pf*pf + deltaT*(r2*QTilde - pr*pr*deltaR))*u3 / (B*QTilde*alpha);
HSOL = alpha2*u*(-B+r*alpha)*pf*SStar/(deltaT*sqQ);
HSONL = alpha2*SStar*CC*pf*(-BR*(1.+sqQ) + B*nur*(1.+2.*sqQ))*u/(deltaT*QTilde);
HSS = -0.5*u3*SStar*SStar;
HS = beta*SStar + wr*HTwr + HSOL + HSONL;
HSSeff = coeffs->Peffss * u4;
Heff = HNS + HS + HSS + HSSeff;
Hreal = sqrt(1. + 2.*coeffs->eta*(Heff-1.));
// if (IS_DEBUG)
// {
// print_debug("u = %.16e, \n", u);
// print_debug("a = %.16e, eta = %.16e\n", coeffs->a, coeffs->eta);
// print_debug("logarg = %.16e, deltaU0 = %.16e, deltaULog = %.16e\n", logarg, deltaU0, deltaULog);
// print_debug("deltaU = %.16e, deltaU_u = %.16e\n", deltaU, deltaU_u);
// print_debug("deltaT = %.16e, deltaT_r = %.16e\n", deltaT, deltaT_r);
// print_debug("DD = %.16e, deltaR = %.16e\n", DD, deltaR);
// print_debug("wfd = %.16e, wfd_r = %.16e\n", wfd, wfd_r);
// print_debug("pr = %.16e, pnBar2 = %.16e, pBar2 = %.16e\n", pr, pnBar2, pBar2);
// print_debug("alpha = %.16e, beta = %.16e, gammar = %.16e, gammaphi = %.16e\n", alpha, beta, gammar, gammaphi);
// print_debug("deltasigma0 = %.16e, deltasigmaS = %.16e, deltasigmaK = %.16e\n", deltaSigma0, deltaSigmaS, deltaSigmaK);
// print_debug("BR = %.16e, nur = %.16e, wr = %.16e, SStar = %.16e\n", BR, nur, wr, SStar);
// print_debug("Hns = %.16e, HTwr = %.16e, HSOL = %.16e, HSONL = %.16e\n", HNS, HTwr, HSOL, HSONL);
// print_debug("HeffSS = %.16e, HS = %.16e, Heff = %.16e\n", HSSeff, HS, Heff);
// print_debug("Hreal = %.16e\n", Hreal);
// }
return Hreal;
}
REAL8 EOBHamiltonian(const REAL8 eta,
REAL8Vector * x,
REAL8Vector * p,
REAL8Vector * s1Vec,
REAL8Vector * s2Vec,
REAL8Vector * sigmaKerr,
REAL8Vector * sigmaStar,
INT tortoise,
SpinEOBHCoeffs *coeffs)
{
REAL8 r, r2, nx, ny, nz;
REAL8 sKerr_x, sKerr_y, sKerr_z, a, a2;
REAL8 sStar_x, sStar_y, sStar_z;
REAL8 e3_x, e3_y, e3_z;
REAL8 costheta; /* Cosine of angle between Skerr and r */
REAL8 xi2, xi_x, xi_y, xi_z; /* Cross product of unit vectors in direction of Skerr and r */
REAL8 vx, vy, vz, pxir, pvr, pn, prT, pr, pf, ptheta2; /*prT is the tortoise pr */
REAL8 w2, rho2;
REAL8 u, u2, u3, u4, u5;
REAL8 bulk, deltaT, deltaR, Lambda;
REAL8 D, qq, ww, B, w, MU, nu, BR, wr, nur, mur;
REAL8 wcos, nucos, mucos, ww_r, Lambda_r;
REAL8 logTerms, deltaU, deltaU_u, Q, deltaT_r, pn2, pp;
REAL8 deltaSigmaStar_x, deltaSigmaStar_y, deltaSigmaStar_z;
REAL8 sx, sy, sz, sxi, sv, sn, s3;
REAL8 H, Hns, Hs, Hss, Hreal, Hwcos, Hwr, HSOL, HSONL;
REAL8 m1PlusetaKK;
/* Terms which come into the 3.5PN mapping of the spins */
//REAL8 aaa, bbb, a13P5, a23P5, a33P5, b13P5, b23P5, b33P5;
REAL8 sMultiplier1, sMultiplier2;
/*Temporary p vector which we will make non-tortoise */
REAL8 tmpP[3];
REAL8 csi;
/* Spin gauge parameters. (YP) simplified, since both are zero. */
// static const double aa=0., bb=0.;
//printf( "In Hamiltonian:\n" );
//printf( "x = %.16e\t%.16e\t%.16e\n", x->data[0], x->data[1], x->data[2] );
//printf( "p = %.16e\t%.16e\t%.16e\n", p->data[0], p->data[1], p->data[2] );
r2 =
x->data[0] * x->data[0] + x->data[1] * x->data[1] +
x->data[2] * x->data[2];
r = sqrt (r2);
nx = x->data[0] / r;
ny = x->data[1] / r;
nz = x->data[2] / r;
sKerr_x = sigmaKerr->data[0];
sKerr_y = sigmaKerr->data[1];
sKerr_z = sigmaKerr->data[2];
sStar_x = sigmaStar->data[0];
sStar_y = sigmaStar->data[1];
sStar_z = sigmaStar->data[2];
a2 = sKerr_x * sKerr_x + sKerr_y * sKerr_y + sKerr_z * sKerr_z;
a = GET_SQRT (a2);
if (a != 0.)
{
e3_x = sKerr_x / a;
e3_y = sKerr_y / a;
e3_z = sKerr_z / a;
}
else
{
e3_x = 0.;
e3_y = 0.;
e3_z = 1.;
}
costheta = e3_x * nx + e3_y * ny + e3_z * nz;
xi2 = 1. - costheta * costheta;
xi_x = -e3_z * ny + e3_y * nz;
xi_y = e3_z * nx - e3_x * nz;
xi_z = -e3_y * nx + e3_x * ny;
vx = -nz * xi_y + ny * xi_z;
vy = nz * xi_x - nx * xi_z;
vz = -ny * xi_x + nx * xi_y;
w2 = r2 + a2;
rho2 = r2 + a2 * costheta * costheta;
u = 1. / r;
u2 = u * u;
u3 = u2 * u;
u4 = u2 * u2;
u5 = u4 * u;
//printf( "KK = %.16e\n", coeffs->KK );
m1PlusetaKK = -1. + eta * coeffs->KK;
/* Eq. 5.75 of BB1 */
bulk = 1. / (m1PlusetaKK * m1PlusetaKK) + (2. * u) / m1PlusetaKK + a2 * u2;
/* Eq. 5.73 of BB1 */
logTerms =
1. + eta * coeffs->k0 + eta * GET_LN (1. + coeffs->k1 * u + coeffs->k2 * u2 +
coeffs->k3 * u3 + coeffs->k4 * u4 +
coeffs->k5 * u5 +
coeffs->k5l * u5 * GET_LN (u));
//printf( "bulk = %.16e, logTerms = %.16e\n", bulk, logTerms );
/* Eq. 5.73 of BB1 */
deltaU = bulk * logTerms;
/* Eq. 5.71 of BB1 */
deltaT = r2 * deltaU;
/* ddeltaU/du */
deltaU_u = 2. * (1. / m1PlusetaKK + a2 * u) * logTerms +
bulk * (eta *
(coeffs->k1 +
u * (2. * coeffs->k2 +
u * (3. * coeffs->k3 +
u * (4. * coeffs->k4 +
5. * (coeffs->k5 +
coeffs->k5l * GET_LN (u)) * u))))) / (1. +
coeffs->
k1 * u +
coeffs->
k2 * u2 +
coeffs->
k3 * u3 +
coeffs->
k4 * u4 +
(coeffs->
k5 +
coeffs->
k5l *
GET_LN (u))
* u5);
/* ddeltaT/dr */
deltaT_r = 2. * r * deltaU - deltaU_u;
/* Eq. 5.39 of BB1 */
Lambda = w2 * w2 - a2 * deltaT * xi2;
/* Eq. 5.83 of BB1, inverse */
D = 1. + log (1. + 6. * eta * u2 + 2. * (26. - 3. * eta) * eta * u3);
/* Eq. 5.38 of BB1 */
deltaR = deltaT * D;
/* See Hns below, Eq. 4.34 of Damour et al. PRD 62, 084011 (2000) */
qq = 2. * eta * (4. - 3. * eta);
/* See Hns below. In Sec. II D of BB2 b3 and bb3 coeffs are chosen to be zero. */
ww = 2. * a * r + coeffs->b3 * eta * a2 * a * u + coeffs->bb3 * eta * a * u;
/* We need to transform the momentum to get the tortoise co-ord */
if (tortoise)
{
csi = GET_SQRT (deltaT * deltaR) / w2; /* Eq. 28 of Pan et al. PRD 81, 084041 (2010) */
}
else
{
csi = 1.0;
}
//printf( "csi(miami) = %.16e\n", csi );
prT = p->data[0] * nx + p->data[1] * ny + p->data[2] * nz;
/* p->data is BL momentum vector; tmpP is tortoise momentum vector */
tmpP[0] = p->data[0] - nx * prT * (csi - 1.) / csi;
tmpP[1] = p->data[1] - ny * prT * (csi - 1.) / csi;
tmpP[2] = p->data[2] - nz * prT * (csi - 1.) / csi;
pxir = (tmpP[0] * xi_x + tmpP[1] * xi_y + tmpP[2] * xi_z) * r;
pvr = (tmpP[0] * vx + tmpP[1] * vy + tmpP[2] * vz) * r;
pn = tmpP[0] * nx + tmpP[1] * ny + tmpP[2] * nz;
pr = pn;
pf = pxir;
ptheta2 = pvr * pvr / xi2;
//printf( "pr = %.16e, prT = %.16e\n", pr, prT );
//printf( " a = %.16e, r = %.16e\n", a, r );
//printf( "D = %.16e, ww = %.16e, rho = %.16e, Lambda = %.16e, xi = %.16e\npr = %.16e, pf = %.16e, deltaR = %.16e, deltaT = %.16e\n",
//D, ww, sqrt(rho2), Lambda, sqrt(xi2), pr, pf, deltaR, deltaT );
/* Eqs. 5.36 - 5.46 of BB1 */
/* Note that the tortoise prT appears only in the quartic term, explained in Eqs. 14 and 15 of Tarrachini et al. */
Hns =
GET_SQRT (1. + prT * prT * prT * prT * qq * u2 + ptheta2 / rho2 +
pf * pf * rho2 / (Lambda * xi2) +
pr * pr * deltaR / rho2) / GET_SQRT (Lambda / (rho2 * deltaT)) +
pf * ww / Lambda;
//printf( "term 1 in Hns: %.16e\n", prT*prT*prT*prT*qq*u2 );
//printf( "term 2 in Hns: %.16e\n", ptheta2/rho2 );
//printf( "term 3 in Hns = %.16e\n", pf*pf*rho2/(Lambda*xi2) );
//printf( "term 4 in Hns = %.16e\n", pr*pr*deltaR/rho2 );
//printf( "term 5 in Hns = %.16e\n", Lambda/(rho2*deltaT) );
//printf( "term 6 in Hns = %.16e\n", pf*ww/Lambda );
/* Eqs. 5.30 - 5.33 of BB1 */
B = GET_SQRT (deltaT);
w = ww / Lambda;
nu = 0.5 * GET_LN (deltaT * rho2 / Lambda);
MU = 0.5 * GET_LN (rho2);
/* dLambda/dr */
Lambda_r = 4. * r * w2 - a2 * deltaT_r * xi2;
ww_r =
2. * a - (a2 * a * coeffs->b3 * eta) * u2 - coeffs->bb3 * eta * a * u2;
/* Eqs. 5.47a - 5.47d of BB1 */
BR =
(-2. * deltaT + GET_SQRT (deltaR) * deltaT_r) / (2. * GET_SQRT (deltaR * deltaT));
wr = (-Lambda_r * ww + Lambda * ww_r) / (Lambda * Lambda);
nur =
(r / rho2 +
(w2 * (-4. * r * deltaT + w2 * deltaT_r)) / (2. * deltaT * Lambda));
mur = (r / rho2 - 1. / sqrt (deltaR));
/* Eqs. 5.47f - 5.47h of BB1 */
wcos = -2. * a2 * costheta * deltaT * ww / (Lambda * Lambda);
nucos = a2 * costheta * w2 * (w2 - deltaT) / (rho2 * Lambda);
mucos = a2 * costheta / rho2;
/* Eq. 5.52 of BB1, (YP) simplified */
//Q = 1. + pvr*pvr/(exp(2.*MU)*xi2) + exp(2.*nu)*pxir*pxir/(B*B*xi2) + pn*pn*deltaR/exp(2.*MU);
Q =
1. + pvr * pvr / (rho2 * xi2) +
deltaT * rho2 / Lambda * pxir * pxir / (B * B * xi2) +
pn * pn * deltaR / rho2;
pn2 = pr * pr * deltaR / rho2;
pp = Q - 1.;
//printf( "pn2 = %.16e, pp = %.16e\n", pn2, pp );
//printf( "sigmaKerr = %.16e, sigmaStar = %.16e\n", sKerr_z, sStar_z );
/* Eq. 5.68 of BB1, (YP) simplified for aa=bb=0. */
/*
deltaSigmaStar_x=(- 8.*aa*(1. + 3.*pn2*r - pp*r)*sKerr_x - 8.*bb*(1. + 3.*pn2*r - pp*r)*sStar_x +
eta*(-8.*sKerr_x - 36.*pn2*r*sKerr_x + 3.*pp*r*sKerr_x + 14.*sStar_x - 30.*pn2*r*sStar_x + 4.*pp*r*sStar_x))/(12.*r);
deltaSigmaStar_y=(-8.*aa*(1. + 3.*pn2*r - pp*r)*sKerr_y - 8.*bb*(1. + 3.*pn2*r - pp*r)*sStar_y +
eta*(-8.*sKerr_y - 36.*pn2*r*sKerr_y + 3.*pp*r*sKerr_y + 14.*sStar_y - 30.*pn2*r*sStar_y + 4.*pp*r*sStar_y))/(12.*r);
deltaSigmaStar_z=(-8.*aa*(1. + 3.*pn2*r - pp*r)*sKerr_z - 8.*bb*(1. + 3.*pn2*r - pp*r)*sStar_z +
eta*(-8.*sKerr_z - 36.*pn2*r*sKerr_z + 3.*pp*r*sKerr_z + 14.*sStar_z - 30.*pn2*r*sStar_z + 4.*pp*r*sStar_z))/(12.*r);
*/
deltaSigmaStar_x =
eta * (-8. * sKerr_x - 36. * pn2 * r * sKerr_x + 3. * pp * r * sKerr_x +
14. * sStar_x - 30. * pn2 * r * sStar_x +
4. * pp * r * sStar_x) / (12. * r);
deltaSigmaStar_y =
eta * (-8. * sKerr_y - 36. * pn2 * r * sKerr_y + 3. * pp * r * sKerr_y +
14. * sStar_y - 30. * pn2 * r * sStar_y +
4. * pp * r * sStar_y) / (12. * r);
deltaSigmaStar_z =
eta * (-8. * sKerr_z - 36. * pn2 * r * sKerr_z + 3. * pp * r * sKerr_z +
14. * sStar_z - 30. * pn2 * r * sStar_z +
4. * pp * r * sStar_z) / (12. * r);
/* Now compute the additional 3.5PN terms. */
/* The following gauge parameters correspond to those given by
* Eqs. (69) and (70) of BB2 (aaa -> a0, bbb -> b0).
* In SEOBNRv1 model, we chose to set all of them to zero,
* described between Eqs. (3) and (4).
*/
/*
aaa = -3./2.*eta;
bbb = -5./4.*eta;
a1 = eta*eta/2.;
a2 = -(1./8.)*eta*(-7. + 8.*eta);
a3 = -((9.*eta*eta)/16.);
b1 = 1./16.*eta*(9. + 5.*eta);
b2 = -(1./8.)*eta*(-17. + 5.*eta);
b3 = -3./8.*eta*eta;
*/
/*aaa = 0.;
bbb = 0.;
a13P5 = 0.;
a23P5 = 0.;
a33P5 = 0.;
b13P5 = 0.;
b23P5 = 0.;
b33P5 = 0.;
*/
/* Eq. 52 of BB2, (YP) simplified for zero gauge parameters */
/*
sMultiplier1 =-(2.*(24.*b23P5 + eta*(-353. + 27.*eta) + bbb*(56. + 60.*eta)) +
2.*(24.*b13P5 - 24.*b23P5 + bbb*(14. - 66.*eta) + 103.*eta - 60.*eta*eta)*pp*
r + 120.*(2.*b33P5 - 3.*eta*(bbb + eta))*pn2*pn2*r*r +
(-48.*b13P5 + 4.*bbb*(1. + 3.*eta) + eta*(23. + 3.*eta))*pp*pp*
r*r + 6.*pn2*r*(16.*b13P5 + 32.*b23P5 + 24.*b33P5 - 47.*eta +
54.*eta*eta + 24.*bbb*(1. + eta) +
(24.*b13P5 - 24.*b33P5 - 16.*eta + 21.*eta*eta + bbb*(-2. + 30.*eta))*pp*
r))/(72.*r*r);
*/
sMultiplier1 =
-(2. * eta * (-353. + 27. * eta) +
2. * (103. * eta - 60. * eta * eta) * pp * r +
120. * (-3. * eta * eta) * pn2 * pn2 * r * r +
(eta * (23. + 3. * eta)) * pp * pp * r * r +
6. * pn2 * r * (-47. * eta + 54. * eta * eta +
(-16. * eta +
21. * eta * eta) * pp * r)) / (72. * r * r);
/* Eq. 52 of BB2, (YP) simplified for zero gauge parameters */
/*
sMultiplier2 = (-16.*(6.*a23P5 + 7.*eta*(8. + 3.*eta) + aaa*(14. + 15.*eta)) +
4.*(-24.*a13P5 + 24.*a23P5 - 109.*eta + 51.*eta*eta + 2.*aaa*(-7. + 33.*eta))*
pp*r + 30.*(-16.*a33P5 + 3.*eta*(8.*aaa + 9.*eta))*pn2*pn2*r*r +
(96.*a13P5 - 45.*eta - 8.*aaa*(1. + 3.*eta))*pp*pp*r*r -
6.*pn2*r*(32.*a13P5 + 64.*a23P5 + 48.*a33P5 + 16.*eta + 147.*eta*eta +
48.*aaa*(1. + eta) + (48.*a13P5 - 48.*a33P5 - 6.*eta + 39.*eta*eta +
aaa*(-4. + 60.*eta))*pp*r))/(144.*r*r);
*/
sMultiplier2 =
(-16. * (7. * eta * (8. + 3. * eta)) +
4. * (-109. * eta + 51. * eta * eta) * pp * r +
810. * eta * eta * pn2 * pn2 * r * r - 45. * eta * pp * pp * r * r -
6. * pn2 * r * (16. * eta + 147. * eta * eta +
(-6. * eta +
39. * eta * eta) * pp * r)) / (144. * r * r);
/* Eq. 52 of BB2 */
deltaSigmaStar_x +=
sMultiplier1 * sigmaStar->data[0] + sMultiplier2 * sigmaKerr->data[0];
deltaSigmaStar_y +=
sMultiplier1 * sigmaStar->data[1] + sMultiplier2 * sigmaKerr->data[1];
deltaSigmaStar_z +=
sMultiplier1 * sigmaStar->data[2] + sMultiplier2 * sigmaKerr->data[2];
/* And now the (calibrated) 4.5PN term */
deltaSigmaStar_x += coeffs->d1 * eta * sigmaStar->data[0] / (r * r * r);
deltaSigmaStar_y += coeffs->d1 * eta * sigmaStar->data[1] / (r * r * r);
deltaSigmaStar_z += coeffs->d1 * eta * sigmaStar->data[2] / (r * r * r);
deltaSigmaStar_x += coeffs->d1v2 * eta * sigmaKerr->data[0] / (r * r * r);
deltaSigmaStar_y += coeffs->d1v2 * eta * sigmaKerr->data[1] / (r * r * r);
deltaSigmaStar_z += coeffs->d1v2 * eta * sigmaKerr->data[2] / (r * r * r);
//printf( "deltaSigmaStar_x = %.16e, deltaSigmaStar_y = %.16e, deltaSigmaStar_z = %.16e\n",
// deltaSigmaStar_x, deltaSigmaStar_y, deltaSigmaStar_z );
sx = sStar_x + deltaSigmaStar_x;
sy = sStar_y + deltaSigmaStar_y;
sz = sStar_z + deltaSigmaStar_z;
sxi = sx * xi_x + sy * xi_y + sz * xi_z;
sv = sx * vx + sy * vy + sz * vz;
sn = sx * nx + sy * ny + sz * nz;
s3 = sx * e3_x + sy * e3_y + sz * e3_z;
/* Eq. 3.45 of BB1, second term */
Hwr =
(GET_EXP (-3. * MU - nu) * GET_SQRT (deltaR) *
(GET_EXP (2. * (MU + nu)) * pxir * pxir * sv -
B * GET_EXP (MU + nu) * pvr * pxir * sxi +
B * B * xi2 * (GET_EXP (2. * MU) * (GET_SQRT (Q) + Q) * sv +
pn * pvr * sn * GET_SQRT (deltaR) -
pn * pn * sv * deltaR))) / (2. * B * (1. +
GET_SQRT (Q)) *
GET_SQRT (Q) * xi2);
/* Eq. 3.45 of BB1, third term */
Hwcos =
(GET_EXP (-3. * MU - nu) *
(sn *
(-(GET_EXP (2. * (MU + nu)) * pxir * pxir) +
B * B * (pvr * pvr - GET_EXP (2. * MU) * (GET_SQRT (Q) + Q) * xi2)) -
B * pn * (B * pvr * sv -
GET_EXP (MU +
nu) * pxir * sxi) * GET_SQRT (deltaR))) / (2. * B * (1. +
GET_SQRT
(Q)) *
GET_SQRT (Q));
/* Eq. 3.44 of BB1, leading term */
HSOL =
(GET_EXP (-MU + 2. * nu) * (-B + GET_EXP (MU + nu)) * pxir * s3) / (B * B *
GET_SQRT (Q) *
xi2);
/* Eq. 3.44 of BB1, next-to-leading term */
HSONL =
(GET_EXP (-2. * MU + nu) *
(-(B * GET_EXP (MU + nu) * nucos * pxir * (1. + 2. * GET_SQRT (Q)) * sn * xi2) +
(-(BR * GET_EXP (MU + nu) * pxir * (1. + GET_SQRT (Q)) * sv) +
B * (GET_EXP (MU + nu) * nur * pxir * (1. + 2. * GET_SQRT (Q)) * sv +
B * mur * pvr * sxi + B * sxi * (-(mucos * pn * xi2) +
GET_SQRT (Q) * (mur * pvr -
nur * pvr + (-mucos +
nucos) *
pn * xi2)))) *
GET_SQRT (deltaR))) / (B * B * (GET_SQRT (Q) + Q) * xi2);
/* Eq. 3.43 and 3.45 of BB1 */
Hs = w * s3 + Hwr * wr + Hwcos * wcos + HSOL + HSONL;
/* Eq. 5.70 of BB1, last term */
Hss = -0.5 * u3 * (sx * sx + sy * sy + sz * sz - 3. * sn * sn);
/* Add correction for leading-order spin-induced quadrupole, relevant for BNS - this is zero when kappa_1,2=1 */
/* Eq. 5.70 of BB1 */
H = Hns + Hs + Hss;
/* Add the additional calibrated term */
REAL8 Hess = 0;
Hess = coeffs->dheffSS * eta * (sKerr_x * sStar_x + sKerr_y * sStar_y +
sKerr_z * sStar_z) / (r * r * r * r);
/* One more calibrated term proportional to S1^2+S2^2. Note that we use symmetric expressions of m1,m2 and S1,S2 */
/*H += coeffs->dheffSSv2 * eta / (r*r*r*r) / (1.-4.*eta)
* ( (sKerr_x*sKerr_x + sKerr_y*sKerr_y + sKerr_z*sKerr_z)*(1.-4.*eta+2.*eta*eta)
+(sKerr_x*sStar_x + sKerr_y*sStar_y + sKerr_z*sStar_z)*(-2.*eta+4.*eta*eta)
+(sStar_x*sStar_x + sStar_y*sStar_y + sStar_z*sStar_z)*(2.*eta*eta) );*/
Hess += coeffs->dheffSSv2 * eta / (r * r * r * r)
* (s1Vec->data[0] * s1Vec->data[0] + s1Vec->data[1] * s1Vec->data[1] +
s1Vec->data[2] * s1Vec->data[2] + s2Vec->data[0] * s2Vec->data[0] +
s2Vec->data[1] * s2Vec->data[1] + s2Vec->data[2] * s2Vec->data[2]);
H += Hess;
/* Real Hamiltonian given by Eq. 2, ignoring the constant -1. */
Hreal = GET_SQRT (1. + 2. * eta * (H - 1.));
return Hreal;
}
double GSLSpinHamiltonianWrapper( double x, void *params )
{
HcapDerivParams *dParams = (HcapDerivParams *)params;
SpinEOBParams *seobParams = dParams->params;
SpinEOBHCoeffs *seobHamCoeffs = seobParams->seobCoeffs;
REAL8 tmpVec[12];
REAL8 s1normData[3], s2normData[3], sKerrData[3], sStarData[3];
/* These are the vectors which will be used in the call to the Hamiltonian */
REAL8Vector r, p, spin1, spin2, spin1norm, spin2norm;
REAL8Vector sigmaKerr, sigmaStar;
int i;
REAL8 a;
REAL8 m1 = seobParams->m1;
REAL8 m2 = seobParams->m2;
REAL8 mT2 = (m1+m2)*(m1+m2);
/* Use a temporary vector to avoid corrupting the main function */
memcpy( tmpVec, dParams->values, sizeof(tmpVec) );
/* Set the relevant entry in the vector to the correct value */
tmpVec[dParams->varyParam] = x;
/* Set the LAL-style vectors to point to the appropriate things */
r.length = p.length = spin1.length = spin2.length = spin1norm.length = spin2norm.length = 3;
sigmaKerr.length = sigmaStar.length = 3;
r.data = tmpVec;
p.data = tmpVec+3;
spin1.data = tmpVec+6;
spin2.data = tmpVec+9;
spin1norm.data = s1normData;
spin2norm.data = s2normData;
sigmaKerr.data = sKerrData;
sigmaStar.data = sStarData;
memcpy( s1normData, tmpVec+6, 3*sizeof(REAL8) );
memcpy( s2normData, tmpVec+9, 3*sizeof(REAL8) );
for ( i = 0; i < 3; i++ )
{
s1normData[i] /= mT2;
s2normData[i] /= mT2;
}
/* Calculate various spin parameters */
EOBCalculateSigmaKerr( &sigmaKerr, &spin1norm, &spin2norm );
EOBCalculateSigmaStar( &sigmaStar, m1, m2, &spin1norm, &spin2norm );
a = sqrt( sigmaKerr.data[0]*sigmaKerr.data[0] + sigmaKerr.data[1]*sigmaKerr.data[1]
+ sigmaKerr.data[2]*sigmaKerr.data[2] );
// EOBCalculateSpinEOBHamCoeffs(seobHamCoeffs, seobParams->eta, a, params);
return EOBHamiltonian( seobParams->eta, &r, &p, &spin1norm, &spin2norm, &sigmaKerr, &sigmaStar, seobParams->tortoise, seobHamCoeffs ) / seobParams->eta;
}
/* Wrapper for GSL to call the Hamiltonian function */
static double
GSLSpinAlignedHamiltonianWrapper (double x, void *params)
{
HcapDerivParams *dParams = (HcapDerivParams *) params;
SpinEOBParams *seobParams = dParams->params;
REAL8 tmpVec[6];
/* These are the vectors which will be used in the call to the Hamiltonian */
REAL8Vector r, p;
REAL8Vector *s1Vec = seobParams->s1Vec;
REAL8Vector *s2Vec = seobParams->s2Vec;
REAL8Vector *sigmaKerr = seobParams->sigmaKerr;
REAL8Vector *sigmaStar = seobParams->sigmaStar;
/* Use a temporary vector to avoid corrupting the main function */
memcpy (tmpVec, dParams->values, sizeof (tmpVec));
/* Set the relevant entry in the vector to the correct value */
tmpVec[dParams->varyParam] = x;
/* Set the LAL-style vectors to point to the appropriate things */
r.length = p.length = 3;
r.data = tmpVec;
p.data = tmpVec + 3;
REAL8 rX = tmpVec[0];
REAL8 prT = tmpVec[3];
REAL8 pphi = tmpVec[4]*rX;
return EOBHamiltonian(seobParams->eta, &r, &p, s1Vec, s2Vec,
sigmaKerr, sigmaStar,
seobParams->tortoise,
seobParams->seobCoeffs) / seobParams->eta;
// print_debug("Deriv....(r,prT,pphi)=(%.16e, %.16e, %.16e) H = %.16e\n",
// rX, prT, pphi, H);
// return H;
}
double
GSLSpinAlignedHamiltonianWrapper_SA (double x, void *params)
{
HcapDerivParams *dParams = (HcapDerivParams *) params;
SpinEOBParams *seobParams = dParams->params;
REAL8 tmpVec[6];
/* These are the vectors which will be used in the call to the Hamiltonian */
// REAL8Vector r, p;
// REAL8Vector *s1Vec = seobParams->s1Vec;
// REAL8Vector *s2Vec = seobParams->s2Vec;
// REAL8Vector *sigmaKerr = seobParams->sigmaKerr;
// REAL8Vector *sigmaStar = seobParams->sigmaStar;
/* Use a temporary vector to avoid corrupting the main function */
memcpy (tmpVec, dParams->values, sizeof (tmpVec));
/* Set the relevant entry in the vector to the correct value */
tmpVec[dParams->varyParam] = x;