Notebook Status: Validated
Validation Notes: This module has been validated against the LALSuite SEOBNRv4P code that was reviewed and approved for LIGO parameter estimation by the LIGO Scientific Collaboration. That is, the value $H_{\rm real}$ output from this notebook agrees to roundoff error with the value of $H_{\rm real}$ computed by the LALSuite function XLALSimIMRSpinPrecEOBHamiltonian().
Consider two black holes with masses $m_{1}$, $m_{2}$ and spins ${\bf S}_{1}$, ${\bf S}_{2}$ in a binary system. The spinning effective one-body ("SEOB") Hamiltonian $H_{\rm real}$ (defined in this cell) describes the dynamics of this system; we will define $H_{\rm real}$ as in Barausse and Buonanno (2010) Section VE. There, $H_{\rm real}$ is canonically transformed and mapped to an effective Hamiltonian $H_{\rm eff}$ (defined in this cell) describing the motion of a test particle of mass $\mu$ (defined in this cell) and spin ${\bf S}^{*}$ (defined in this cell) moving in a defomred Kerr background. Here we seek to break up $H_{\rm real}$ and document the terms in such a way that the resulting Python code can be used to numerically evaluate $H_{\rm real}$.
We write $H_{\rm real}$ in terms of Cartesian quasi-isotropic coordinates $x$, $y$, and $z$ (see Barausse and Buonanno (2010) Section III). The spatial coordinates $r$, $\theta$, and $\phi$ referenced throughout are Boyer-Lindquist coordinates (see Barausse and Buonanno (2010) Section IV).
Please note that throughout this notebook we adpot the following conventions:
Running this notebook to completion will generate a file called v4P_Hreal_on_bottom.py. This file contains the Python function v4P_compute_Hreal(), which takes as input m1, m2 (each in solar masses), the value of the Euler-Mascheroni constant, a tortoise coordinate, and values for all twelve dynamic variables (3 components of the separation vector, three components of the momentum vector, and three spin components of each compact object). Note that the spin components should be dimensionless.
Throughout this module, we will refer to
This notebook is organized as follows:
import cmdline_helper as cmd # NRPy+: Multi-platform Python command-line interface
# Create C code output directory:
Ccodesdir = "SEOBNR"
# Then create an output directory in case it does not exist
cmd.mkdir(Ccodesdir)
The SEOB Hamiltonian $H_{\rm real}$ is given by BB2010 Equation (5.69):
\begin{equation*} H_{\rm real} = M \sqrt{ 1 + 2 \eta \left( \frac{ H_{\rm eff} }{ \mu } - 1 \right) }. \end{equation*}Here $H_{\rm eff}$ (defined in this cell) is an effective Hamiltonian (see this cell) and $M$ (defined in this cell), $\mu$ (defined in this cell), and $\eta$ (defined in this cell) are constants determined by $m_{1}$ and $m_{2}$.
%%writefile $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hreal = sp.sqrt(1 + 2*eta*(Heff - 1))
Overwriting SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
The effective Hamiltonian $H_{\rm eff}$ is given by BB2010 Equation (5.70):
\begin{equation*} H_{\rm eff} = H_{\rm S} + \underbrace{ \beta^{i} p_{i} + \alpha \sqrt{ \mu^{2} + \gamma^{ij} p_{i} p_{j} + {\cal Q}_{4} } }_{ H_{\rm NS} } - \underbrace{ \frac{ \mu }{ 2 M r^{3} } \left( \delta^{ij} - 3 n^{i} n^{j} \right) S^{*}_{i} S^{*}_{j} }_{ H_{\rm D} }. \end{equation*}Here $H_{\rm S}$ (considered further in this cell) denotes leading order effects of spin-spin and spin-orbit coupling, $H_{\rm NS}$ (considered further in this cell) is the Hamiltonian for a nonspinning test particle, and $H_{\rm D}$ (considered further in this cell) describes quadrupole deformation of the coupling of the particle's spin with itself to leading order. T2014 adds to $H_{\rm eff}$ a 3PN spin-spin term given by
\begin{equation*} \frac{d_{\rm SS} \eta }{ r^{4} } \left( {\bf S}_{1}^{2} + {\bf S}_{2}^{2} \right) \end{equation*}where $d_{\rm SS}$ is an adjustable parameter determined by fitting to numerical relativity results. Equation (4.13) of BL2017 gives
\begin{equation*} d_{\rm SS} = 528.511252 \chi^{3} \eta^{2} - 41.000256 \chi^{3} \eta + 1161.780126 \chi^{2} \eta^{3} - 326.324859 \chi^{2} \eta^{2} + 37.196389 \chi \eta + 706.958312 \eta^{3} - 36.027203 \eta + 6.068071. \end{equation*}We take $u \equiv \frac{1}{r}$ (as described in this cell), and define $\eta$ in this cell $\chi$ in this cell. Note that the coefficients for $d_{\rm SS}$ have been rounded to coincide with the LALSuite implementation (see the file LALSimIMRSpinEOBHamiltonian.h).
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Heff = Hs + Hns - Hd + dSS*eta*u*u*u*u*(S1x*S1x + S1y*S1y + S1z*S1z + S2x*S2x + S2y*S2y + S2z*S2z)
dSS = 528.511*chi*chi*chi*eta*eta - 41.0003*chi*chi*chi*eta + 1161.78*chi*chi*eta*eta*eta - 326.325*chi*chi*eta*eta
+ 37.1964*chi*eta + 706.958*eta*eta*eta - 36.0272*eta + 6.06807
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (4.17),
\begin{equation*} H_{\rm S} = H_{\rm SO} + H_{\rm SS} \end{equation*}where $H_{\rm SO}$ (defined in this cell) includes spin-orbit terms and $H_{\rm SS}$ (defined in this cell) includes spin-spin terms.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hs = Hso + Hss
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined $H_{\rm NS}$ in this cell as
\begin{equation*} H_{\rm NS} = \underbrace{ \beta^{i} p_{i} }_{ \beta\ p\ \rm sum } + \alpha \sqrt{ \smash[b]{ \underbrace{ \mu^{2} + \gamma^{ij} p_{i} p_{j} + {\cal Q}_{4} }_{ H_{\rm NS}\ \rm radicand } } }. \end{equation*}We compute $\beta\ p$ sum in this cell, $\alpha$ in this cell, and $H_{\rm NS}$ radicand in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hns = betapsum + alpha*sp.sqrt(Hnsradicand)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined $H_{\rm D}$ in this cell as:
\begin{equation*} H_{\rm D} = \underbrace{ \frac{ \mu }{ 2 M r^{3} } }_{H_{\rm D}\ {\rm coefficient}} \underbrace{ \left( \delta^{ij} - 3 n^{i} n^{j} \right) S^{*}_{i} S^{*}_{j} }_{H_{\rm D}\ {\rm sum}} \end{equation*}We compute $H_{\rm D}$ coefficient in this cell and $H_{\rm D}$ sum in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hd = Hdcoeff*Hdsum
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We will write BB2010 Equation (4.18) as:
\begin{align*} H_{\rm SO} = H_{\rm SO}\ {\rm Term\ 1} + H_{\rm SO}\ {\rm Term\ 2\ coefficient} * H_{\rm SO}\ {\rm Term\ 2}. \end{align*}We define and consider $H_{\rm SO}$ Term 1 in this cell, $H_{\rm SO}$ Term 2 coefficient in this cell, and $H_{\rm SO}$ Term 2 in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hso = HsoTerm1 + HsoTerm2coeff*HsoTerm2
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining our notation $H_{\rm SO}$ (defined in this cell) with BB2010 Equation (4.18), we have
\begin{equation*} H_{\rm SO}\ {\rm Term\ 1} = \frac{ e^{2 \nu - \tilde{\mu} } \left( e^{\tilde{\mu} + \nu} - \tilde{B} \right) \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right) \left( {\bf S} \cdot \hat{\bf S}_{\rm Kerr} \right) }{ \tilde{B}^{2} \sqrt{Q} \xi^{2} }. \end{equation*}We will write
\begin{equation*} H_{\rm SO}\ {\rm Term\ 1} = \frac{ e^{2 \nu} \left( e^{\tilde{\mu}} e^{\nu} - \tilde{B} \right) \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right) \left( {\bf S} \cdot \hat{\bf S}_{\rm Kerr} \right) }{ e^{ \tilde{\mu} } \tilde{B}^{2} \sqrt{Q} \xi^{2} }. \end{equation*}We define $e^{\tilde{\mu}}$ in this cell, $e^{\nu}$ in this cell, $\tilde{B}$ in this cell, $\hat{\bf p} \cdot \boldsymbol{\xi} r$ in this cell, ${\bf S} \cdot \hat{\bf S}_{\rm Kerr}$ in this cell, $Q$ in this cell, and $\boldsymbol{\xi}^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HsoTerm1 = exp2nu*(expmu*expnu - Btilde)*pdotxir*SdotSkerrhat/(expmu*Btilde*Btilde*sp.sqrt(Q)*xisq)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining our notation $H_{\rm SO}$ (defined in this cell) with BB2010 Equation (4.18), we have
\begin{equation*} H_{\rm SO}\ {\rm Term\ 2\ coefficient} = \frac{ e^{\nu - 2 \tilde{\mu}} }{ \tilde{B}^{2} \left( \sqrt{Q} + 1 \right) \sqrt{Q} \xi^{2} } \end{equation*}which we write in the form
\begin{equation*} H_{\rm SO}\ {\rm Term\ 2\ coefficient} = \frac{ e^{\nu} }{ e^{2 \tilde{\mu}} \tilde{B}^{2} \left( Q + \sqrt{Q} \right) \xi^{2} }. \end{equation*}We define and consider $e^{\nu}$ in this cell, $e^{\tilde{\mu}}$ in this cell, $\tilde{B}$ in this cell, $Q$ in this cell, and $\xi^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HsoTerm2coeff = expnu/(exp2mu*Btilde*Btilde*(Q + sp.sqrt(Q))*xisq)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining our notation $H_{\rm SO}$ (defined in this cell) with BB2010 Equation (4.18), we have
\begin{align*} H_{\rm SO}\ {\rm Term\ 2} &= \underbrace{ \left( {\bf S} \cdot \boldsymbol{\xi} \right) \tilde{J} \left[ \mu_r \left( \hat{\bf p} \cdot {\bf v} r \right) \left( \sqrt{Q} + 1 \right) - \mu_{\cos \theta} \left( \hat{\bf p} \cdot {\bf n} \right) \xi^{2} -\sqrt{Q} \left( \nu_r \left( \hat{\bf p} \cdot {\bf v} r \right) + \left( \mu_{\cos \theta} - \nu_{\cos \theta} \right) \left( \hat{\bf p} \cdot {\bf n} \right) \xi^{2} \right) \right] \tilde{B}^{2} }_{H_{\rm SO}\ {\rm Term\ 2a}} \\ &\ \ \ \ \ + \underbrace{ e^{\tilde{\mu} + \nu} \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right) \left( 2 \sqrt{Q} + 1 \right) \left[ \tilde{J} \nu_r \left( {\bf S} \cdot {\bf v} \right) - \nu_{\cos \theta} \left( {\bf S} \cdot {\bf n} \right) \xi^{2} \right] \tilde{B} }_{H_{\rm SO}\ {\rm Term\ 2b}} - \underbrace{ \tilde{J} \tilde{B}_{r} e^{\tilde{\mu} + \nu} \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right) \left( \sqrt{Q} + 1 \right) \left( {\bf S} \cdot {\bf v} \right) }_{H_{\rm SO}\ {\rm Term\ 2c}} \end{align*}We compute $H_{\rm SO}$ Term 2a in this cell, $H_{\rm SO}$ Term 2b in this cell, and $H_{\rm SO}$ Term 2c in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HsoTerm2 = HsoTerm2a + HsoTerm2b - HsoTerm2c
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined $H_{\rm S0}$ Term 2a in this cell as
\begin{equation*} H_{\rm SO}\ {\rm Term\ 2a} = \left( {\bf S} \cdot \boldsymbol{\xi} \right) \tilde{J} \left[ \mu_r \left( \hat{\bf p} \cdot {\bf v} r \right) \left( \sqrt{Q} + 1 \right) - \mu_{\cos \theta} \left( \hat{\bf p} \cdot {\bf n} \right) \xi^{2} -\sqrt{Q} \left( \nu_r \left( \hat{\bf p} \cdot {\bf v} r \right) + \left( \mu_{\cos \theta} - \nu_{\cos \theta} \right) \left( \hat{\bf p} \cdot {\bf n} \right) \xi^{2} \right) \right] \tilde{B}^{2}. \end{equation*}We define ${\bf S} \cdot \boldsymbol{\xi}$ in this cell, $\tilde{J}$ in this cell, $\mu_{r}$ in this cell, $\hat{\bf p} \cdot {\bf v} r$ in this cell, $Q$ in this cell, $\mu_{\cos \theta}$ in this cell, $\hat{\bf p} \cdot {\bf n}$ in this cell, $\xi^{2}$ in this cell, $\nu_{r}$ in this cell, $\nu_{\cos\theta}$ in this cell, and $\tilde{B}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HsoTerm2a = Sdotxi*Jtilde*(mur*pdotvr*(sp.sqrt(Q) + 1) - mucostheta*pdotn*xisq
- sp.sqrt(Q)*(nur*pdotvr + (mucostheta - nucostheta)*pdotn*xisq))*Btilde*Btilde
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined $H_{\rm S0}$ Term 2b in this cell as
\begin{equation*} H_{\rm SO}\ {\rm Term\ 2b} = e^{\tilde{\mu} + \nu} \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right) \left( 2 \sqrt{Q} + 1 \right) \left[ \tilde{J} \nu_r \left( {\bf S} \cdot {\bf v} \right) - \nu_{\cos \theta} \left( {\bf S} \cdot {\bf n} \right) \xi^{2} \right] \tilde{B}. \end{equation*}We define $e^{\tilde{\mu}}$ in this cell, $e^{\nu}$ in this cell, $\hat{\bf p} \cdot \xi r$ in this cell, $Q$ in this cell, $\tilde{J}$ in this cell, $\nu_{r}$ in this cell, ${\bf S} \cdot {\bf v}$ in this cell, $\nu_{\cos\theta}$ in this cell, ${\bf S} \cdot {\bf n}$ in this cell, $\xi^{2}$ in this cell, and $\tilde{B}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HsoTerm2b = expmu*expnu*pdotxir*(2*sp.sqrt(Q) + 1)*(Jtilde*nur*Sdotv - nucostheta*Sdotn*xisq)*Btilde
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined $H_{\rm S0}$ Term 2c in this cell as
\begin{equation*} H_{\rm SO}\ {\rm Term\ 2c} = \tilde{J} \tilde{B}_{r} e^{\tilde{\mu} + \nu} \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right) \left( \sqrt{Q} + 1 \right) \left( {\bf S} \cdot {\bf v} \right) \end{equation*}We define $\tilde{J}$ in this cell, $\tilde{B}_{r}$ in this cell, $e^{\tilde{\mu}}$ in this cell, $e^{\nu}$ in this cell, $\hat{\bf p} \cdot \xi r$ in this cell, $Q$ in this cell, and ${\bf S} \cdot {\bf v}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HsoTerm2c = Jtilde*Brtilde*expmu*expnu*pdotxir*(sp.sqrt(Q) + 1)*Sdotv
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We will write BB2010 Equation (4.19) as
\begin{equation*} H_{\rm SS} = H_{\rm SS}\ {\rm Term\ 1} + H_{\rm SS}\ {\rm Term\ 2\ coefficient} * H_{\rm SS}\ {\rm Term\ 2} + H_{\rm SS}\ {\rm Term\ 3\ coefficient} * H_{\rm SS}\ {\rm Term\ 3}. \end{equation*}We define $H_{\rm SS}$ Term 1 in this cell, $H_{\rm SS}$ Term 2 coefficient in this cell, $H_{\rm SS}$ Term 2 in this cell, $H_{\rm SS}$ Term 3 coefficient in this cell, and $H_{\rm SS}$ Term 3 in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hss = HssTerm1 + HssTerm2coeff*HssTerm2 + HssTerm3coeff*HssTerm3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining BB2010 Equation (4.19) with our definition of $H_{\rm SS}$ Term 1 in this cell, we have
\begin{equation*} H_{\rm SS}\ {\rm Term\ 1} = \omega \left( {\bf S} \cdot \hat{\bf S}_{\rm Kerr} \right). \end{equation*}We define $\omega$ in this cell and ${\bf S} \cdot \hat{\bf S}_{\rm Kerr}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HssTerm1 = omega*SdotSkerrhat
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining BB2010 Equation (4.19) with ore definition of $H_{\rm SS}$ Term 2 coefficient in this cell, we have
\begin{equation*} H_{\rm SS}\ {\rm Term\ 2\ coefficient} = \frac{ e^{-3 \tilde{\mu} -\nu} \tilde{J} \omega_{r} }{ 2 \tilde{B} \left( \sqrt{Q} + 1 \right) \sqrt{Q} \xi^{2} } \end{equation*}which we write as
\begin{equation*} H_{\rm SS}\ {\rm Term\ 2\ coefficient} = \frac{ \tilde{J} \omega_{r} }{ 2 e^{2 \tilde{\mu}} e^{\tilde{\mu}} e^{\nu} \tilde{B} \left( Q + \sqrt{Q} \right) \xi^{2} }. \end{equation*}We define $\tilde{J}$ in this cell, $\omega_{r}$ in this cell, $e^{\tilde{\mu}}$ in this cell, $e^{\nu}$ in this cell, $\tilde{B}$ in this cell, $Q$ in this cell, and $\xi^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HssTerm2coeff = Jtilde*omegar/(2*exp2mu*expmu*expnu*Btilde*(Q + sp.sqrt(Q))*xisq)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining BB2010 Equation (4.19) with our definition of $H_{\rm SS}$ Term 2 in this cell, we have
\begin{equation*} H_{\rm SS}\ {\rm Term\ 2} = -e^{\tilde{\mu} + \nu} \left( {\bf \hat{p}} \cdot {\bf v} r \right) \left( {\bf \hat{p}} \cdot {\bf \xi} r \right) \left( {\bf S} \cdot {\bf \xi} \right) \tilde{B} + e^{2 \left( \tilde{\mu} + \nu \right)} \left( {\bf \hat{p}} \cdot {\bf \xi} r \right)^2 \left( {\bf S} \cdot {\bf v} \right) + e^{2 \tilde{\mu}} \left( 1 + \sqrt{Q} \right) \sqrt{Q} \left( {\bf S} \cdot {\bf v} \right)\xi^2 \tilde{B}^{2} + \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left[ \left( {\bf \hat{p}} \cdot {\bf v} r \right) \left( {\bf S} \cdot {\bf n}\right) - \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left( {\bf S} \cdot {\bf v} \right)\right] \xi^{2} \tilde{B}^{2} \end{equation*}which we write as
\begin{align*} H_{\rm SS}\ {\rm Term\ 2} &= e^{\tilde{\mu}} \left( {\bf \hat{p}} \cdot {\bf \xi} r \right) \left[ e^{\tilde{\mu}} e^{2 \nu} \left( {\bf \hat{p}} \cdot {\bf \xi} r \right) \left( {\bf S} \cdot {\bf v} \right) - e^{\nu} \left( {\bf \hat{p}} \cdot {\bf v} r \right) \left( {\bf S} \cdot {\bf \xi} \right) \tilde{B} \right] \\ &\ \ \ \ \ + \xi^2 \tilde{B}^{2} \left\{ e^{2 \tilde{\mu}} \left( \sqrt{Q} + Q \right) \left( {\bf S} \cdot {\bf v} \right) + \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left[ \left( {\bf \hat{p}} \cdot {\bf v} r \right) \left( {\bf S} \cdot {\bf n}\right) - \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left( {\bf S} \cdot {\bf v} \right)\right] \right\} \end{align*}We define $e^{\tilde{\mu}}$ in this cell, $\hat{\bf p} \cdot \boldsymbol{\xi} r$ in this cell, $e^{\nu}$ in this cell, ${\bf S} \cdot {\bf v}$ in this cell, $\hat{\bf p} \cdot {\bf v} r$ in this cell, ${\bf S} \cdot \boldsymbol{\xi}$ in this cell, $\tilde{B}$ in this cell, $Q$ in this cell, $\tilde{J}$ in this cell, $\hat{\bf p} \cdot {\bf n}$ in this cell, ${\bf S} \cdot {\bf n}$ in this cell, and $\xi^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HssTerm2 = expmu*pdotxir*(expmu*exp2nu*pdotxir*Sdotv - expnu*pdotvr*Sdotxi*Btilde)
+ xisq*Btilde*Btilde*(exp2mu*(sp.sqrt(Q) + Q)*Sdotv
+ Jtilde*pdotn*(pdotvr*Sdotn - Jtilde*pdotn*Sdotv))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining BB2010 Equation (4.19) with our definition of $H_{\rm SS}$ Term 3 coefficient in this cell, we have
\begin{equation*} H_{\rm SS}\ {\rm Term\ 3\ coefficient} = \frac{ e^{-3 \tilde{\mu} - \nu} \omega_{\cos\theta} }{ 2 \tilde{B} \left( \sqrt{Q} + 1 \right) \sqrt{Q} } \end{equation*}which we write as
\begin{equation*} H_{\rm SS}\ {\rm Term\ 3\ coefficient} = \frac{ \omega_{\cos\theta} }{ 2 e^{2 \tilde{\mu}} e^{\tilde{\mu}} e^{\nu} \tilde{B} \left( Q + \sqrt{Q} \right) }. \end{equation*}We define $\omega_{\cos\theta}$ in this cell, $e^{\tilde{\mu}}$ in this cell, $e^{\nu}$ in this cell, and $\tilde{B}$ in this cell, $Q$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HssTerm3coeff = omegacostheta/(2*exp2mu*expmu*expnu*Btilde*(Q + sp.sqrt(Q)))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Combining BB2010 Equation (4.19) with our definition of $H_{\rm SS}$ Term 3 in this cell, we have
\begin{align*} H_{\rm SS}\ {\rm Term\ 3} &= -e^{2 \left( \tilde{\mu} + \nu \right)} \left( \hat{\bf p} \cdot {\bf \xi} r \right)^{2} \left( {\bf S} \cdot {\bf n} \right) + e^{\tilde{\mu} +\nu} \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left( {\bf \hat{p}} \cdot {\bf \xi} r \right) \left( {\bf S} \cdot {\bf \xi} \right) \tilde{B} \\ &\ \ \ \ \ + \left[ \left( {\bf S} \cdot {\bf n} \right) \left( {\bf \hat{p}} \cdot {\bf v} r \right)^{2} - \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left( {\bf S} \cdot {\bf v} \right) \left( {\bf \hat{p}} \cdot {\bf v} r\right) - e^{2 \tilde{\mu}} \left( 1 + \sqrt{Q} \right) \sqrt{Q} \left( {\bf S} \cdot {\bf n} \right) \xi^{2} \right] \tilde{B}^{2} \end{align*}which we write as
\begin{align*} H_{\rm SS}\ {\rm Term\ 3} &= e^{\tilde{\mu}} e^{\nu} \left( \hat{\bf p} \cdot {\bf \xi} r \right) \left[ \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left( {\bf S} \cdot {\bf \xi} \right) \tilde{B} - e^{\tilde{\mu}} e^{\nu} \left( \hat{\bf p} \cdot {\bf \xi} r \right) \left( {\bf S} \cdot {\bf n} \right) \right] \\ &\ \ \ \ \ + \left\{ \left( {\bf \hat{p}} \cdot {\bf v} r \right) \left[ \left( {\bf S} \cdot {\bf n} \right) \left( {\bf \hat{p}} \cdot {\bf v} r \right) - \tilde{J} \left( {\bf \hat{p}} \cdot {\bf n} \right) \left( {\bf S} \cdot {\bf v} \right) \right] - e^{2 \tilde{\mu}} \left( \sqrt{Q} + Q \right) \left( {\bf S} \cdot {\bf n} \right) \xi^{2} \right\} \tilde{B}^{2} \end{align*}We define $e^{\tilde{\mu}}$ in this cell, $e^{\nu}$ in this cell, $\hat{\bf p} \cdot \boldsymbol{\xi} r$ in this cell, $\tilde{J}$ in this cell, $\hat{\bf p} \cdot {\bf n}$ in this cell, ${\bf S} \cdot \boldsymbol{\xi}$ in this cell, $\tilde{B}$ in this cell, ${\bf S} \cdot {\bf n}$ in this cell, $\hat{\bf p} \cdot {\bf v} r$ in this cell, ${\bf S} \cdot {\bf v}$ in this cell, $Q$ in this cell, and $\xi^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HssTerm3 = expmu*expnu*pdotxir*(Jtilde*pdotn*Sdotxi*Btilde - expmu*expnu*pdotxir*Sdotn)
+ (pdotvr*(Sdotn*pdotvr - Jtilde*pdotn*Sdotv) - exp2mu*(sp.sqrt(Q) + Q)*Sdotn*xisq)*Btilde*Btilde
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined the term $\beta p$ sum in this cell as
\begin{equation*} \beta p\ {\rm sum} = \beta^{i} p_{i}. \end{equation*}From BB2010 Equation (5.45), we have
\begin{equation*} \beta^{i} = \frac{ g^{ti} }{ g^{tt} }, \end{equation*}but from BB2010 Equations (5.36) we see that $g^{tr} = g^{t \theta} = 0$. Thus only $\beta^{\phi}$ is nonzero. Combining BB2010 Equations (5.45), (5.36e), and (5.36a), we find
\begin{equation*} \beta^{\phi} = \frac{ -\frac{ \tilde{\omega}_{\rm fd} }{ \Delta_{t} \Sigma } }{ -\frac{ \Lambda_{t} }{ \Delta_{t} \Sigma } } = \frac{ \tilde{\omega}_{\rm fd} }{ \Lambda_{t} } \end{equation*}Therefore
\begin{equation*} \beta^{i} p_{i} = \frac{ \tilde{\omega}_{\rm fd} }{ \Lambda_{t} } p_{\phi}. \end{equation*}We define $\tilde{\omega}_{\rm fd}$ in this cell, $\Lambda_{t}$ in this cell, and $p_{\phi}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
betapsum = omegatilde*pphi/Lambdat
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.44), we have \begin{equation*} \alpha = \frac{ 1 }{ \sqrt{ -g^{tt}} }, \end{equation*}
and from BB2010 Equation (5.36a) we have
\begin{equation*} g^{tt} = -\frac{ \Lambda_{t} }{ \Delta_{t} \Sigma }. \end{equation*}Therefore
\begin{equation*} \alpha = \sqrt{ \frac{ \Delta_{t} \Sigma }{ \Lambda_{t} } }. \end{equation*}We define $\Delta_{t}$ in this cell, $\Sigma$ in this cell, and $\Lambda_{t}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
alpha = sp.sqrt(Deltat*Sigma/Lambdat)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Recall that we defined $H_{\rm NS}$ radicand in this cell as
\begin{equation*} H_{\rm NS}\ {\rm radicand} = \mu^{2} + \underbrace{\gamma^{ij} p_{i} p_{j}}_{\gamma p\ \rm sum} + {\cal Q}_{4} \end{equation*}We define $\mu$ in this cell, $\gamma p$ sum in this cell, and ${\cal Q}_{4}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hnsradicand = 1 + gammappsum + Q4
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.46), we have
\begin{equation*} \gamma^{ij} = g^{ij} - \frac{ g^{ti} g^{tj} }{ g^{tt} }. \end{equation*}Combining this result with BB2010 Equations 5.36, we have
\begin{equation*} \gamma^{r\theta} = \gamma^{r\phi} = \gamma^{\theta r} = \gamma^{\theta\phi} = \gamma^{\phi r} = \gamma^{\phi\theta} = 0 \end{equation*}and
\begin{align*} \gamma^{rr} &= g^{rr} = \frac{ \Delta_{r} }{ \Sigma } \\ \gamma^{\theta\theta} &= g^{\theta\theta} = \frac{ 1 }{ \Sigma } \\ \gamma^{\phi\phi} &= \frac{ \Sigma }{ \Lambda_{t} \sin^{2} \theta }. \end{align*}Therefore
\begin{align*} \gamma^{ij} p_{i} p_{j} &= \gamma^{rr} p_{r} p_{r} + \gamma^{\theta\theta} p_{\theta} p_{\theta} + \gamma^{\phi\phi} p_{\phi} p_{\phi} \\ &= \frac{ \Delta_{r} }{ \Sigma } p_{r}^{2} + \frac{ 1 }{ \Sigma } p_{\theta}^{2} + \frac{ \Sigma }{ \Lambda_{t} \sin^{2} \theta } p_{\phi}^{2}. \end{align*}Converting Boyer-Lindquist coordinates to tortoise coordinates (the transformation for which is found in the Appendix of P2010), we have
\begin{align*} p_{r} &= \hat{\bf p} \cdot {\bf n} \\ p_{\theta} &= \hat{\bf p} \cdot {\bf v} \frac{ r }{ \sin \theta } \\ p_{\phi} &= \hat{\bf p} \cdot \boldsymbol{\xi} r. \end{align*}Therefore
\begin{equation*} \gamma^{ij} p_{i} p_{j} = \frac{ \Delta_{r} }{ \Sigma } \left( \hat{\bf p} \cdot {\bf n} \right)^{2} + \Sigma^{-1} \left( \hat{\bf p} \cdot {\bf v} \frac{ r }{ \sin \theta } \right)^{2} + \frac{ \Sigma }{ \Lambda_{t} \sin^{2} \theta } \left( \hat{\bf p} \cdot \boldsymbol{\xi} r \right)^{2}. \end{equation*}We define $\Delta_{r}$ in this cell, $\Sigma$ in this cell, $\hat{\bf p} \cdot {\bf n}$ in this cell, $\hat{\bf p} \cdot {\bf v} r$ in this cell, $\sin^{2} \theta$ in this cell, $\Lambda_{t}$ in this cell, and $\hat{\bf p} \cdot \boldsymbol{\xi} r$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
gammappsum = Deltar/Sigma*pdotn*pdotn + 1/Sigma*pdotvr*pdotvr/sin2theta + Sigma/Lambdat/sin2theta*pdotxir*pdotxir
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From T2012 Equation (15),
\begin{equation*} {\cal Q}_{4} \propto \frac{ p_{r^{*}}^{4} }{ r^{2} } \left( r^{2} + \chi_{\rm Kerr}^{2} \right)^{4}. \end{equation*}We denote $p_{r^{*}}$ by prT. Converting from tortoise coordinates to physical coordinates(the transformation for which is found in the Appendix of P2010), we find
\begin{equation*} {\cal Q}_{4} = \frac{ prT^{4} }{ r^{2} } z_{3} \end{equation*}where $z_{3}$ is found in D2000 Equation (4.34):
\begin{equation*} z_{3} = 2 \left( 4 - 3 \nu \right) \nu. \end{equation*}In the notation of BB2010, $\nu = \eta$ (see discussion after T2012 Equation (2)). Thus
\begin{equation*} {\cal Q}_{4} = 2 prT^{4} u^{2} \left( 4 - 3 \eta \right) \eta. \end{equation*}We define prT in this cell, $u$ in this cell, and $\eta$ in this cell below.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Q4 = 2*prT*prT*prT*prT*u*u*(4 - 3*eta)*eta
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Recall we defined $H_{\rm D}$ in this cell as
\begin{equation*} H_{\rm D} = H_{\rm D}\ {\rm coeffecient} * H_{\rm D}\ {\rm sum}. \end{equation*}In this step we break down each of $H_{\rm D}$ coefficient (defined in this cell) and $H_{\rm D}$ sum (defined in this cell).
From our definition of $H_{\rm D}$ in this cell, we have
\begin{equation*} H_{\rm D}\ {\rm coefficient} = \frac{ \mu }{ 2 M r^{3} }, \end{equation*}and recalling the definition of $\eta$ we'll write
\begin{equation*} H_{\rm D}\ {\rm coefficient} = \frac{ \eta }{ 2 r^{3} }. \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hdcoeff = sp.Rational(1,2)/(r*r*r)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From our definition of $H_{\rm D}$ in this cell, we have
\begin{align*} H_{\rm D}\ {\rm sum} &= \left( \delta^{ij} - 3 n^{i} n^{j} \right) S^{*}_{i} S^{*}_{j} \\ &= \underbrace{\delta^{ij} S^{*}_{i} S^{*}_{j}}_{\rm Term\ 1} - \underbrace{3 n^{i} n^{j} S^{*}_{i} S^{*}_{j}}_{\rm Term\ 2}. \end{align*}We compute $H_{\rm D}$ Term 1 in this cell and $H_{\rm D}$ Term 2 in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Hdsum = HdsumTerm1 - HdsumTerm2
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From our definition of $H_{\rm D}$ sum Term 1 in this cell, we have
\begin{equation*} H_{\rm D}\ {\rm sum\ Term\ 1} = \delta^{ij} S^{*}_{i} S^{*}_{j} \end{equation*}where $\delta^{ij}$ is the Kronecker delta:
\begin{equation*} \delta_{ij} = \left\{ \begin{array}{cc} 0, & i \not= j \\ 1, & i = j. \end{array} \right. \end{equation*}Thus we have
\begin{equation*} H_{\rm D}\ {\rm sum\ Term\ 1} = S^{*}_{1} S^{*}_{1} + S^{*}_{2} S^{*}_{2} + S^{*}_{3} S^{*}_{3} \end{equation*}We define ${\bf S}^{*}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HdsumTerm1 = Sstar1*Sstar1 + Sstar2*Sstar2 + Sstar3*Sstar3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From our definition of $H_{\rm D}$ sum Term 2 in this cell, we have
\begin{align*} H_{\rm D}\ {\rm sum\ Term\ 2} &= 3 n^{i} n^{j} S^{*}_{i} S^{*}_{j} \\ &= 3 \left( {\bf S}^{*} \cdot {\bf n} \right)^{2} \\ \end{align*}We define ${\bf S}^{*} \cdot {\bf n}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
HdsumTerm2 = 3*Sstardotn*Sstardotn
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Sdotxi = S1*xi1 + S2*xi2 + S3*xi3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Sdotv = S1*v1 + S2*v2 + S3*v3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Sdotn = S1*n1 + S2*n2 + S3*n3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We have
\begin{equation*} {\bf S} \cdot \hat{\bf S}_{\rm Kerr} = S^{1} \hat{S}_{\rm Kerr}^{1} + S^{2} \hat{S}_{\rm Kerr}^{2} + S^{3} \hat{S}_{\rm Kerr}^{3}. \end{equation*}We define $\hat{\bf S}_{\rm Kerr}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
SdotSkerrhat = S1*Skerrhat1 + S2*Skerrhat2 + S3*Skerrhat3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Sstardotn = Sstar1*n1 + Sstar2*n2 + Sstar3*n3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.63):
\begin{equation*} {\bf S}^{*} = \boldsymbol{\sigma}^{*} + \frac{ 1 }{ c^{2} } \boldsymbol{\Delta}_{\sigma^{*}}. \end{equation*}We define $\boldsymbol{\sigma}^{*}$ in this cell and $\boldsymbol{\Delta}_{\sigma^{*}}$ in this cell.
Please note: after normalization, ${\bf S} = {\bf S}^{*}$. See BB2010 Equation (4.26).
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
S1 = Sstar1
S2 = Sstar2
S3 = Sstar3
Sstar1 = sigmastar1 + Deltasigmastar1
Sstar2 = sigmastar2 + Deltasigmastar2
Sstar3 = sigmastar3 + Deltasigmastar3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We can write $\boldsymbol{\Delta}_{\sigma^{*}}$ as
\begin{equation*} \boldsymbol{\Delta}_{\sigma^{*}} = \boldsymbol{\sigma}^{*} \left( \boldsymbol{\sigma}^{*}\ {\rm coefficient} \right) + \boldsymbol{\sigma} \left( \boldsymbol{\sigma}\ {\rm coefficient} \right) \end{equation*}For further dissection, see $\boldsymbol{\sigma}^{*}$ in this cell, $\boldsymbol{\sigma}^{*}$ coefficient in this cell, $\boldsymbol{\sigma}$ in this cell, and $\boldsymbol{\sigma}$ coefficient in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltasigmastar1 = sigmastar1*sigmastarcoeff + sigma1*sigmacoeff
Deltasigmastar2 = sigmastar2*sigmastarcoeff + sigma2*sigmacoeff
Deltasigmastar3 = sigmastar3*sigmastarcoeff + sigma3*sigmacoeff
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We will break down $\boldsymbol{\sigma}^{*}\ {\rm coefficient}$ into two terms:
\begin{equation*} \boldsymbol{\sigma}^{*}\ {\rm coefficient} = \boldsymbol{\sigma}^{*}\ {\rm coefficient\ Term\ 1} + \boldsymbol{\sigma}^{*}\ {\rm coefficient\ Term\ 2} \end{equation*}We compute $\boldsymbol{\sigma}^{*}$ coefficient Term 1 in this cell and $\boldsymbol{\sigma}^{*}$ coefficient Term 2 in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmastarcoeff = sigmastarcoeffTerm1 + sigmastarcoeffTerm2
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We build this term from BB2011 Equation (51) with $b_{0} = 0$ (see discussion preceeding T2012 Equation (4)), where what is listed below is the coefficient on $\boldsymbol{\sigma}^{*}$:
\begin{align*} \boldsymbol{\sigma}^{*}\ {\rm coefficient\ Term\ 1} &= \frac{7}{6} \eta \frac{M}{r} + \frac{1}{3} \eta \left( Q - 1 \right) - \frac{5}{2} \eta \frac{ \Delta_r }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \\ &= \frac{ \eta }{ 12 } \left( 14 \frac{ M }{ r } + 4 \left( Q - 1 \right) - 30 \frac{ \Delta_r }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right) \end{align*}We group together and compute $Q-1$ in this cell and $\frac{ \Delta_r }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2}$ in this cell; we define $r$ in this cell, $\eta$ in this cell, and $M$ in this cell below.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmastarcoeffTerm1 = eta/12*(14/r + 4*Qminus1 - 30*DrSipn2)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We build this term from BB2011 Equation (52) with all $b_{i} = 0$, $i \in \left\{0, 1, 2, 3\right\}$ (see discussion preceeding T2012 Equation (4)), and just the coefficient on $\boldsymbol{\sigma}^{*}$. In the LALSuite code this is the variable 'sMultiplier1':
\begin{align*} \boldsymbol{\sigma}^{*}\ {\rm coefficient\ Term\ 2} &= \frac{1}{36} \left( 353 \eta - 27 \eta^2 \right) \left( \frac{M}{r} \right)^{2} + \frac{5}{3} \left( 3 \eta^2 \right) \frac{ \Delta_{r}^{2} }{ \Sigma^{2} } \left( {\bf n} \cdot \hat{\bf p} \right)^{4} \\ &\ \ \ \ \ + \frac{1}{72} \left( -23 \eta -3 \eta^{2} \right) \left( Q - 1 \right)^{2} + \frac{1}{36} \left( -103 \eta + 60 \eta^{2} \right) \frac{M}{r} \left( Q - 1 \right) \\ &\ \ \ \ \ + \frac{1}{12} \left( 16 \eta - 21 \eta^{2} \right) \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \left( Q - 1 \right) + \frac{1}{12} \left( 47 \eta - 54 \eta^{2} \right) \frac{M}{r} \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \\ &= \frac{ \eta }{ 72 r^{2} } \left[ \left( 706 - 54 \eta \right) M^{2} + 360 \eta r^{2} \frac{ \Delta_{r}^{2} }{ \Sigma^{2} } \left( {\bf n} \cdot \hat{\bf p} \right)^{4} + r^{2} \left( -23 - 3 \eta \right) \left( Q - 1 \right)^{2} + \left( -206 + 120 \eta \right) M r \left( Q - 1 \right) \right. \\ &\ \ \ \ \ + \left. \left( 96 - 126 \eta \right) r^{2} \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \left( Q - 1 \right) + \left( 282 - 324 \eta \right) M r \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right] \\ &= \frac{ \eta }{ 72 r^{2} } \left[ 706 + r \left( -206 M \left( Q - 1 \right) + 282 M \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} + r \left( Q -1 \right) \left( 96 \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} - 23 \left( Q - 1 \right) \right) \right) \right. \\ &\ \ \ \ \ + \left. \eta \left( -54 M^{2} + r \left( 120 M \left( Q -1 \right) - 324 M \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right.\right.\right. \\ &\ \ \ \ \ + \left.\left.\left. r \left( 360 \frac{ \Delta_{r}^{2} }{ \Sigma^{2} } \left( {\bf n} \cdot \hat{\bf p} \right)^{4} + \left( Q - 1 \right) \left( -126 \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} - 3 \left( Q - 1 \right) \right) \right)\right) \right) \right] \end{align*}We define $r$ in this cell, $\eta$ in this cell, and $M$ in this cell; we group together and define $Q - 1$ in this cell, and $\frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmastarcoeffTerm2 = eta/(72*r*r)*(706 + r*(-206*Qminus1 + 282*DrSipn2 + r*Qminus1*(96*DrSipn2 - 23*Qminus1))
+ eta*(-54 + r*(120*Qminus1 - 324*DrSipn2
+ r*(360*DrSipn2*DrSipn2 + Qminus1*(-126*DrSipn2 - 3*Qminus1)))))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We will break down $\boldsymbol{\sigma}\ {\rm coefficient}$ into three terms:
\begin{equation*} \boldsymbol{\sigma}\ {\rm coefficient} = \boldsymbol{\sigma}\ {\rm coefficient\ Term\ 1} + \boldsymbol{\sigma}\ {\rm coefficient\ Term\ 2} + \boldsymbol{\sigma}\ {\rm coefficient\ Term\ 3} \end{equation*}We compute $\boldsymbol{\sigma}$ coefficient Term 1 in this cell, $\boldsymbol{\sigma}$ coefficient Term 2 in this cell, and $\boldsymbol{\sigma}$ coefficient Term 3 in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmacoeff = sigmacoeffTerm1 + sigmacoeffTerm2 + sigmacoeffTerm3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We build this term from BB2011 Equation (51) with $a_{0} = 0$ (see discussion preceeding T2012 Equation (4)), where what is listed below is the coefficient on $\boldsymbol{\sigma}$:
\begin{align*} \boldsymbol{\sigma}\ {\rm coefficient\ Term\ 1} &= -\frac{2}{3} \eta \frac{ M }{ r } + \frac{1}{4} \eta \left( Q - 1 \right) - 3 \eta \frac{ \Delta_r }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \\ &= \frac{ \eta }{ 12 } \left( -8 \frac{ M }{ r } + 3 \left( Q - 1 \right) - 36 \smash[b]{\underbrace{ \frac{ \Delta_r }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} }_{\rm DrSipn2}} \vphantom{\underbrace{a}_{b}} \right) \end{align*}We define $\eta$ in this cell, $M$ in this cell, $Q-1$ in this cell, and $\frac{ \Delta_r }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmacoeffTerm1 = eta/12*(-8/r + 3*Qminus1 - 36*DrSipn2)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We build this term from BB2011 Equation (52) with all $a_{i} = 0$, $i \in \left\{0, 1, 2, 3\right\}$ (see discussion preceeding T2012 Equation (4)), and just the coefficient on $\boldsymbol{\sigma}$:
\begin{align*} \boldsymbol{\sigma}\ {\rm coefficient\ Term\ 2} &= \frac{1}{9} \left( -56 \eta -21 \eta^{2} \right) \left( \frac{ M }{ r } \right)^{2} + \frac{5}{24} \left( 27 \eta^{2} \right) \frac{ \Delta_r^{2} }{ \Sigma^{2} } \left( {\bf n} \cdot \hat{\bf p} \right)^{4} \\ &\ \ \ \ \ + \frac{1}{144} \left(-45 \eta \right) \left( Q - 1 \right)^{2} + \frac{1}{36} \left( -109 \eta + 51 \eta^{2} \right) \frac{ M }{ r } \left( Q - 1 \right) \\ &\ \ \ \ \ + \frac{1}{24} \left( 6 \eta - 39\eta^{2} \right) \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \left( Q - 1 \right) + \frac{1}{24} \left( -16 \eta - 147 \eta^{2} \right) \frac{ M }{ r } \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \\ &= \frac{ \eta }{ 144 r^{2} } \left[ -896 M^{2} + r \left( -436 M \left( Q - 1 \right) - 96 M \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right.\right. \\ &\ \ \ \ \ \left.\left. + r \left( -45 \left( Q - 1 \right)^{2} + 36 \left( Q - 1 \right) \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right) \right) + \eta \left( -336 M^{2} + r \left( 204 M \left( Q -1 \right) - 882 M \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right.\right.\right. \\ &\ \ \ \ \ \left.\left.\left. + r \left( 810 \frac{ \Delta_{r}^{2} }{ \Sigma^{2} } \left( {\bf n} \cdot \hat{\bf p} \right)^{4} - 234 \left( Q - 1 \right) \frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2} \right) \right) \right) \right] \end{align*}We define $\eta$ in this cell, $M$ in this cell, $Q - 1$ in this cell, and $\frac{ \Delta_{r} }{ \Sigma } \left( {\bf n} \cdot \hat{\bf p} \right)^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmacoeffTerm2 = eta/(144*r*r)*(-896 + r*(-436*Qminus1 - 96*DrSipn2 + r*(-45*Qminus1*Qminus1
+ 36*Qminus1*DrSipn2)) + eta*(-336 + r*(204*Qminus1 - 882*DrSipn2
+ r*(810*DrSipn2*DrSipn2 - 234*Qminus1*DrSipn2))))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From Section II of T2014),
\begin{equation*} \boldsymbol{\sigma}\ {\rm coefficient\ Term\ 3} = \eta d_{\rm SO} u^{3}. \end{equation*}where $d_{\rm SO}$ is a fitting parameter. Equation (4.13) of BL2017 gives
\begin{equation*} d_{\rm SO} = 147.481449 \chi^{3} \eta^{2} - 568.651115 \chi^3 \eta + 66.198703 \chi^{3} - 343.313058 \chi^{2} \eta + 2495.293427 \chi \eta^{2} - 44.532373 \end{equation*}We define $\eta$ in this cell, $u$ in this cell, and $\chi$ in this cell. Note that the values have been rounded to agree with those in the LALSuite implementation (see the file LALSimIMRSpinEOBHamiltonian.h).
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmacoeffTerm3 = eta*dSO*u*u*u
dSO = 147.481*chi*chi*chi*eta*eta - 568.651*chi*chi*chi*eta + 66.1987*chi*chi*chi - 343.313*chi*chi*eta
+ 2495.29*chi*eta*eta - 44.5324
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.47b) we have
\begin{equation*} \omega_{r} = \frac{ \Lambda_{t} \tilde{\omega}_{\rm fd}^{\prime} - \Lambda_{t}^{\prime} \tilde{\omega}_{\rm fd} }{ \Lambda_{t}^{2} }. \end{equation*}We define $\Lambda_{t}$ in this cell, $\tilde{\omega}_{\rm fd}^{\prime}$ in this cell, $\Lambda_{t}^{\prime}$ in this cell, and $\tilde{\omega}_{\rm fd}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
omegar = (Lambdat*omegatildeprm - Lambdatprm*omegatilde)/(Lambdat*Lambdat)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.47c) we have
\begin{equation*} \nu_{r} = \frac{ r }{ \Sigma } + \frac{ \varpi^{2} \left( \varpi^{2} \Delta^{\prime}_{t} - 4 r \Delta_{t} \right) }{ 2 \Lambda_{t} \Delta_{t} }. \end{equation*}We define $r$ in this cell, $\Sigma$ in this cell, $\varpi^{2}$ in this cell, $\Delta_{t}^{\prime}$ in this cell, $\Delta_{t}$ in this cell, and $\Lambda_{t}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
nur = r/Sigma + w2*(w2*Deltatprm - 4*r*Deltat)/(2*Lambdat*Deltat)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
mur = r/Sigma - 1/sp.sqrt(Deltar)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.47f), we have
\begin{equation*} \omega_{\cos\theta} = -\frac{ 2 a^{2} \cos\theta \Delta_{t} \tilde{\omega}_{\rm fd} }{ \Lambda_{t}^{2} }. \end{equation*}We define $a$ in this cell, $\cos\theta$ in this cell, $\Delta_{t}$ in this cell, $\tilde{\omega}_{\rm fd}$ in this cell, and $\Lambda_{t}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
omegacostheta = -2*a*a*costheta*Deltat*omegatilde/(Lambdat*Lambdat)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.47g) we have
\begin{equation*} \nu_{\cos\theta} = \frac{ a^{2} \varpi^{2} \cos\theta \left( \varpi^{2} - \Delta_{t} \right) }{ \Lambda_{t} \Sigma }. \end{equation*}We define $a$ in this cell, $\varpi^{2}$ in this cell, $\cos\theta$ in this cell, $\Delta_{t}$ in this cell, $\Lambda_{t}$ in this cell, and $\Sigma$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
nucostheta = a*a*w2*costheta*(w2 - Deltat)/(Lambdat*Sigma)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
mucostheta = a*a*costheta/Sigma
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion after BB2010 Equations (5.47), we know that the prime notation indicates a derivative with respect to $r$. Using the definiton of $\Lambda_{t}$ in this cell, we have
\begin{equation*} \Lambda_{t}^{\prime} = 4 \left( a^{2} + r^{2} \right) r - a^{2} \Delta_{t}^{\prime} \sin^{2} \theta. \end{equation*}We define $a$ in this cell, $r$ in this cell, $\Delta_{u}$ in this cell, and $\sin^{2}\theta$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Lambdatprm = 4*(a*a + r*r)*r - 2*a*a*Deltatprm*sin2theta
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion after BB2010 Equation (5.47), we know that the prime notation indicates a derivative with respect to $r$. Using the definiton of $\tilde{\omega}_{\rm fd}$ in this cell, we have
\begin{equation*} \tilde{\omega}_{\rm fd}^{\prime} = 2 a M. \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
omegatildeprm = 2*a
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
omega = omegatilde/Lambdat
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.32), we have
\begin{equation*} e^{2 \nu} = \frac{ \Delta_{t} \Sigma }{ \Lambda_t }. \end{equation*}It follows that
\begin{equation*} e^{\nu} = \sqrt{ \frac{ \Delta_{t} \Sigma }{ \Lambda_t } }. \end{equation*}We define $\Delta_{t}$ in this cell, $\Sigma$ in this cell, and $\Lambda_{t}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
expnu = sp.sqrt(exp2nu)
exp2nu = Deltat*Sigma/Lambdat
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Btilde = sp.sqrt(Deltat)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.49), we have
\begin{equation*} \tilde{B}_{r} = \frac{ \sqrt{ \Delta_{r} } \Delta_{t}^{\prime} - 2 \Delta_{t} }{ 2 \sqrt{ \Delta_{r} \Delta_{t} } }. \end{equation*}We define $\Delta_{r}$ in this cell, $\Delta_{t}^{\prime}$ in this cell, and $\Delta_{t}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Brtilde = (sp.sqrt(Deltar)*Deltatprm - 2*Deltat)/(2*sp.sqrt(Deltar*Deltat))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
expmu = sp.sqrt(exp2mu)
exp2mu = Sigma
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Jtilde = sp.sqrt(Deltar)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.52),
\begin{equation*} Q = 1 + \underbrace{ \frac{ \Delta_{r} }{ \Sigma } \left( \hat{\bf p} \cdot {\bf n} \right)^{2} }_{\rm DrSipn2} + \underbrace{ \frac{ \Sigma }{ \Lambda_t \sin^{2} \theta } }_{\rm Q\ coefficient\ 1} \left( \smash[b]{ \underbrace{ \hat{\bf p} \cdot \boldsymbol{\xi} r }_{\rm pdotxir} } \right)^{2} + \underbrace{ \frac{ 1 }{ \Sigma \sin^{2} \theta } }_{\rm Q\ coefficient\ 2} \left( \smash[b]{ \underbrace{ \hat{\bf p} \cdot {\bf v} r }_{\rm pdotvr} } \right)^{2}; \end{equation*}We group togther and compute $\frac{ \Delta_{r} }{ \Sigma } \left( \hat{\bf p} \cdot {\bf n} \right)^{2}$ in this cell, $\frac{ \Sigma }{ \Lambda_t \sin^{2} \theta }$ in this cell, $\hat{\bf p} \cdot \boldsymbol{\xi} r$ in this cell, $\frac{ 1 }{ \Sigma \sin^{2} \theta }$ in this cell, and $\hat{\bf p} \cdot {\bf v} r$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Qminus1 = Q - 1
Q = 1 + DrSipn2 + Qcoeff1*pdotxir*pdotxir + Qcoeff2*pdotvr*pdotvr
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
DrSipn2 = Deltar*pdotn*pdotn/Sigma
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We defined $Q$ coefficient 1 in this cell as
\begin{equation*} Q\ {\rm coefficient\ 1} = \frac{ \Sigma }{ \Lambda_t \sin^{2} \theta } \end{equation*}We define $\Sigma$ in this cell, $\Lambda_{t}$ in this cell, and $\sin^{2} \theta$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Qcoeff1 = Sigma/(Lambdat*sin2theta)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Qcoeff2 = 1/(Sigma*sin2theta)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion preceding BB2010 Equation (3.41), the phi component of the tortoise momentum $p_{\phi}$ is given by
\begin{equation*} p_{\phi} = \hat{\bf p} \cdot \boldsymbol{\xi} r. \end{equation*}We define $\hat{\bf p} \cdot \boldsymbol{\xi} r$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
pphi = pdotxir
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We have
\begin{equation*} \hat{\bf p} \cdot {\bf v} r = \left( \hat{p}_{1} v_{1} + \hat{p}_{2} v_{2} + \hat{p}_{3} v_{3} \right) r \end{equation*}We define $\hat{\bf p}$ in this cell, ${\bf v}$ in this cell, and $r$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
pdotvr = (phat1*v1 + phat2*v2 + phat3*v3)*r
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
pdotn = phat1*n1 + phat2*n2 + phat3*n3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We have
\begin{equation*} \hat{\bf p} \cdot \boldsymbol{\xi} r = \left( \hat{p}_{1} \xi_{1} + \hat{p}_{2} \xi_{2} + \hat{p}_{3} \xi_{3} \right) r \end{equation*}We define $\hat{\bf p}$ in this cell, $\boldsymbol{\xi}$ in this cell, and $r$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
pdotxir = (phat1*xi1 + phat2*xi2 + phat3*xi3)*r
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion after BB2010 Equation (3.41), we have $\hat{\bf p} = {\bf p}/m$ where $m$ is the mass of a nonspinning test particle and ${\bf p}$ is conjugate momentum. Following Lines 319--321 of LALSimIMRSpinEOBHamiltonianPrec.c, we convert the Boyer-Lindquist momentum ${\bf p}$ to the tortoise momentum (see the appendix of P2010) via
\begin{align*} \hat{\bf p} = {\bf p} + {\rm prT} \left( 1 - \frac{1}{\rm csi1} \right) {\bf n} \end{align*}We define prT in this cell, csi1 in this cell, and ${\bf n}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
phat1 = p1 + prT*(1 - 1/csi1)*n1
phat2 = p2 + prT*(1 - 1/csi1)*n2
phat3 = p3 + prT*(1 - 1/csi1)*n3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
prT = csi2*(p1*n1 + p2*n2 + p3*n3)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the transformation to tortoise coordinates in the Appendix of P2010,
\begin{equation*} {\rm csi2} = 1 + \left( \frac{1}{2} - \frac{1}{2}{\rm sign}\left( \frac{3}{2} - \tau \right) \right) \left( {\rm csi} - 1 \right) \end{equation*}We define csi in this cell; $\tau$ is a tortoise coordinate ($\tau \in \left\{ 0, 1 ,2 \right\}$).
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
csi2 = 1 + (sp.Rational(1,2) - sp.Rational(1,2)*sp.sign(sp.Rational(3,2) - tortoise))*(csi - 1)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the transformation to tortoise coordinates in the Appendix of P2010,
\begin{equation*} {\rm csi1} = 1 + \left( 1 - \left\lvert 1 - \tau \right\rvert \right) \left( {\rm csi} - 1 \right) \end{equation*}We define csi in this cell; $\tau$ is a tortoise coordinate ($\tau \in \left\{ 0, 1 ,2 \right\}$).
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
csi1 = 1 + (1 - sp.abs(1-tortoise))*(csi - 1)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the transformation to tortoise coordinates in the Appendix of P2010,
\begin{equation*} {\rm csi} = \frac{ \sqrt{ \Delta_{t} \Delta_{r} } }{ \varpi^{2} }. \end{equation*}We define $\Delta_{t}$ in this cell, $\Delta_{r}$ in this cell, and $\varpi^{2}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
csi = sp.sqrt(Deltar*Deltat)/w2
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Lambdat = w2*w2 - a*a*Deltat*sin2theta
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltar = Deltat*Dinv
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltat = r*r*Deltau
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion after BB2010 Equation (5.47), we know that the prime notation indicates a derivative with respect to $r$. Using the definition of $\Delta_{t}$, we have
\begin{equation*} \Delta_{t}^{\prime} = 2 r \Delta_{u} + r^{2} \Delta_{u}^{\prime}. \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltatprm = 2*r*Deltau + r*r*Deltauprm
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.73), we have
\begin{equation*} \Delta_u = \bar{\Delta}_{u} \left[ \smash[b]{\underbrace{ 1 + \eta \Delta_{0} + \eta \log \left( 1 + {\rm logarg} \right) }_{\Delta_{u}\ {\rm calibration\ term}}} \vphantom{\underbrace{1}_{n}} \right] \end{equation*}We compute $\bar{\Delta}_{u}$ in this cell and $\Delta_{u}$ calibration term and logarg in this cell. From the discussion after BB2010 Equation (5.47), we know that primes denote derivatives with respect to $r$. We have
\begin{equation*} \Delta_u = \bar{\Delta}^{\prime}_{u} \left( \Delta_{u}\ {\rm calibration\ term} \right) + \bar{\Delta}_{u} \left( \Delta_{u}\ {\rm calibration\ term} \right)^{\prime} \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltauprm = Deltaubarprm*Deltaucalib + Deltaubar*Deltaucalibprm
Deltau = Deltaubar*Deltaucalib
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.75), we have
\begin{equation*} \bar{\Delta}_u = \frac{ a^{2} u^{2} }{ M^{2} } + \frac{ 1 }{ \eta K - 1 } \left( 2 u + \frac{ 1 }{ \eta K - 1 } \right). \end{equation*}We define $a$ in this cell, $u$ in this cell, $M$ in this cell, $\eta$ in this cell, and $K$ in this cell. From the discussion after BB2010 Equation (5.47), we know that primes denote derivatives with respect to $r$. We have
\begin{equation*} \bar{\Delta}^{\prime}_u = \frac{ -2 a^{2} u^{3} }{ M^{2} } - \frac{ 2 u^{2} }{ \eta K - 1 }. \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltaubarprm = -2*a*a*u*u*u - 2*u*u/(etaKminus1)
Deltaubar = a*a*u*u + (2*u + 1/etaKminus1)/etaKminus1
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.73), we have
\begin{align*} \Delta_u\ {\rm calibration\ term} &= 1 + \eta \Delta_{0} + \eta \log \left( 1 + \Delta_{1} u + \Delta_{2} u^{2} + \Delta_{3} u^{3} + \Delta_{4} u^{4} \right) \\ &= 1 + \eta \left[ \Delta_{0} + \log \left( 1 + \Delta_{1} u + \Delta_{2} u^{2} + \Delta_{3} u^{3} + \Delta_{4} u^{4} \right) \right]. \end{align*}In T2014 Equation (2) an additional term is and is defined in Equation (A2) of this paper. We then have
\begin{equation*} \Delta_u\ {\rm calibration\ term} = 1 + \eta \left[ \Delta_{0} + \log \left( 1 + \Delta_{1} u + \Delta_{2} u^{2} + \Delta_{3} u^{3} + \Delta_{4} u^{4} + \Delta_{5} u^{5} \right) \right]. \end{equation*}In the LALSuite code itself (see LALSimIMRSpinEOBHamiltonianPrec.c line 274 on Git commit a70b43d), there's one more term ($\Delta_{5\ell}$), for which documentation is elusive. That bring us to
\begin{equation*} \Delta_u\ {\rm calibration\ term} = 1 + \eta \left[ \Delta_{0} + \log \left( 1 + \underbrace{ \Delta_{1} u + \Delta_{2} u^{2} + \Delta_{3} u^{3} + \Delta_{4} u^{4} + \Delta_{5} u^{5} + \Delta_{5\ell} u^{5} \ln\left(u\right) }_{ \rm logarg } \right) \right]. \end{equation*}Note our notation for logarg. We define $u$ in this cell, $\eta$ in this cell, and the calibration coefficients $\Delta_{i}$, $i \in \left\{0, 1, 2, 3, 4\right\}$, in this cell.
From the discussion after BB2010 Equation (5.47), we know that primes denote derivatives with respect to $r$. We have \begin{equation*} \left( \Delta_u\ {\rm calibration\ term} \right)^{\prime} = \frac{ -\eta u^{2} \left( \Delta_{1} + 2 \Delta_{2} u + 3 \Delta_{3} u^{2} + 4 \Delta_{4} u^{3} + 5 \Delta_{5} u^{4} + 5 \Delta_{5\ell} u^{4} \ln\left( u \right) + \Delta_{5\ell} u^{5} u^{-1} \right) }{ 1 + {\rm logarg} }. \end{equation*}
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Deltaucalibprm = -eta*u*u*(Delta1 + u*(2*Delta2 + u*(3*Delta3
+ u*(4*Delta4 + u*(5*(Delta5 + Delta5l*sp.log(u)))))))/(1 + logarg)
Deltaucalib = 1 + eta*(Delta0 + sp.log(1 + logarg))
logarg = u*(Delta1 + u*(Delta2 + u*(Delta3 + u*(Delta4 + u*(Delta5 + Delta5l*sp.log(u))))))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta5l = etaKminus1*etaKminus1*sp.Rational(64,5)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We combine SH2016 Equation (A2c) with BL2017 Equation (2.3) (the last term in our expression) to find
\begin{align*} \Delta_{5} &= \left( \eta K - 1 \right)^{2} \left( -\frac{4237}{60} + \frac{128}{5}\gamma + \frac{2275}{512} \pi^{2} - \frac{1}{3} a^{2} \left\{ \Delta_{1}^{3} - 3 \Delta_{1} \Delta_{2} + 3 \Delta_{3} \right\} \right. \\ &\ \ \ \ \ - \frac{ \Delta_{1}^{5} - 5 \Delta_{1}^{3} \Delta_{2} + 5 \Delta_{1} \Delta_{2}^{2} + 5 \Delta_{1}^{2} \Delta_{3} - 5 \Delta_{2} \Delta_{3} - 5 \Delta_{1} \Delta_{4} }{ 5 \left( \eta K - 1 \right)^{2} } \\ &\left.\ \ \ \ \ + \frac{ \Delta_{1}^{4} - 4 \Delta_{1}^{2} \Delta_{2} + 2 \Delta_{2}^{2} + 4 \Delta_{1} \Delta_{3} - 4 \Delta_{4} }{ 2\left( \eta K - 1 \right) } + \frac{256}{5} \log(2) + \left\{ \frac{41\pi^2}{32} - \frac{221}{6} \right\} \eta \right) \end{align*}Note that we have exlcuded the first term in the brackets in (A2c); this is the term $\Delta_{5\ell}$ which we defined in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta5 = etaKminus1*etaKminus1*(sp.Rational(-4237,60) + sp.Rational(128,5)*EMgamma
+ sp.Rational(2275,512)*sp.pi*sp.pi - sp.Rational(1,3)*a*a*(Delta1*Delta1*Delta1
- 3*Delta1*Delta2 + 3*Delta3) - (Delta1*Delta1*Delta1*Delta1*Delta1
- 5*Delta1*Delta1*Delta1*Delta2 + 5*Delta1*Delta2*Delta2 + 5*Delta1*Delta1*Delta3
- 5*Delta2*Delta3 - 5*Delta1*Delta4)/(5*etaKminus1*etaKminus1)
+ (Delta1*Delta1*Delta1*Delta1 - 4*Delta1*Delta1*Delta2 + 2*Delta2*Delta2
+ 4*Delta1*Delta3 - 4*Delta4)/(2*etaKminus1) + sp.Rational(256,5)*sp.log(2)
+ (sp.Rational(41,32)*sp.pi*sp.pi - sp.Rational(221,6))*eta)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equations (5.81), we have
\begin{align*} \Delta_{4} &= \frac{1}{12} \left\{ 6 \frac{ a^{2} }{ M^{2} } \left( \Delta_{1}^{2} - 2 \Delta_{2} \right) \left( \eta K - 1 \right)^{2} + 3 \Delta_{1}^{4} - 8 \left( \eta K - 1 \right) \Delta_{1}^{3} - 12 \Delta_{2} \Delta_{1}^{2} + 12 \left[ 2 \left( \eta K - 1 \right) \Delta_{2} + \Delta_{3} \right] \Delta_{1} \right.\\ &\left.\ \ \ \ \ + 12 \left( \frac{94}{3} - \frac{41}{32} \pi^{2} \right) \left( \eta K - 1 \right)^{2} + 6 \left[ \Delta_{2}^{2} - 4 \Delta_{3} \left( \eta K - 1 \right) \right] \right\} \\ \end{align*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta4 = sp.Rational(1,12)*(6*a*a*(Delta1*Delta1 - 2*Delta2)*etaKminus1*etaKminus1 + 3*Delta1*Delta1*Delta1*Delta1
- 8*etaKminus1*Delta1*Delta1*Delta1 -12*Delta2*Delta1*Delta1 + 12*(2*etaKminus1*Delta2
+ Delta3)*Delta1 + 12*(sp.Rational(94,3)
- sp.Rational(41,32)*sp.pi*sp.pi)*etaKminus1*etaKminus1 + 6*(Delta2*Delta2
- 4*Delta3*etaKminus1))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equations (5.80), we have
\begin{align*} \Delta_{3} &= \frac{1}{3} \left[ -\Delta_{1}^{3} + 3 \left( \eta K - 1 \right) \Delta_{1}^{2} + 3 \Delta_{2} \Delta_{1} - 6 \left( \eta K - 1 \right) \left( -\eta K + \Delta_{2} + 1 \right) - 3 \frac{ a^{2} }{ M^{2} } \left( \eta K - 1 \right)^{2} \Delta_{1} \right] \\ &= -\frac{1}{3}\Delta_{1}^{3} + \left( \eta K - 1 \right) \Delta_{1}^{2} + \Delta_{2} \Delta_{1} - 2 \left( \eta K - 1 \right) \left( \Delta_{2}- \left( \eta K - 1 \right) \right) - \frac{ a^{2} }{ M^{2} } \left( \eta K - 1 \right)^{2} \Delta_{1} \end{align*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta3 = -sp.Rational(1,3)*Delta1*Delta1*Delta1 + etaKminus1*Delta1*Delta1 + Delta2*Delta1
-2*etaKminus1*(Delta2 - etaKminus1) - a*a*etaKminus1*etaKminus1*Delta1
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equations (5.79, we have
\begin{equation*} \Delta_{2} = \frac{1}{2} \Delta_{1} \left( -4 \eta K + \Delta_{1} + 4 \right) - \frac{ a^{2} }{ M^{2} } \left( \eta K - 1 \right)^{2} \Delta_{0}\\ \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta2 = sp.Rational(1,2)*Delta1*(Delta1 - 4*etaKminus1) - a*a*etaKminus1*etaKminus1*Delta0
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equations (5.78), we have
\begin{equation*} \Delta_{1} = -2 \left( \eta K - 1 \right) \left( K + \Delta_{0} \right) \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta1 = -2*etaKminus1*(K + Delta0)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equations (5.77), we have
\begin{equation*} \Delta_{0} = K \left( \eta K - 2 \right) \end{equation*}We define $K$ and $\eta K-1$ in this cell, $\eta$ in this cell, $a$ in this cell, and $M$ in this cell. Note that the constant $\gamma$ is the Euler-Mascheroni, and the value is taken from the LALSuite documentation. In the Python code we donote $\gamma$ by EMgamma.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Delta0 = K*(eta*K - 2)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
The calibration constant $K$ is defined in BL2017 Section IV, Equations (4.8) and (4.12) (equations copied from BL2017 source code):
\begin{equation*} \left.K\right|_{\chi=0} = 267.788247\, \nu^3 -126.686734\, \nu^2 + 10.257281\,\nu + 1.733598, \end{equation*}\begin{align*} K =& - 59.165806\,\chi^3\nu^3 - 0.426958\,\chi^3\nu + 1.436589\,\chi^3 + 31.17459\,\chi^2\nu^3 + 6.164663\,\chi^2\nu^2 - 1.380863\,\chi^2 \\ & - 27.520106\,\chi \nu^3 + 17.373601\,\chi\nu^2 + 2.268313\,\chi\nu - 1.62045\,\chi +\left.K\right|_{\chi=0} \end{align*}Here $\left.K\right|_{\chi=0}$ denotes the nonspining fits and $\nu = \eta$ (see discussion after BL2017 Equation (2.1)). Furthermore, most coefficients are rounded in the LALSuite code; below we round to match the values therein (see the file LALSimIMRSpinEOBHamiltonian.h). The term $\eta K - 1$ is sufficiently common that we also define it:
\begin{equation*} {\rm etaKminus1} = \eta K - 1. \end{equation*}We define $\eta$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
etaKminus1 = eta*K - 1
K = - 59.1658*chi*chi*chi*eta*eta*eta - 0.426958*chi*chi*chi*eta + 1.43659*chi*chi*chi
+ 31.1746*chi*chi*eta*eta*eta + 6.16466*chi*chi*eta*eta - 1.38086*chi*chi - 27.5201*chi*eta*eta*eta
+ 17.3736*chi*eta*eta + 2.26831*chi*eta - 1.62045*chi + Kchi0
Kchi0 = 267.788*eta*eta*eta -126.687*eta*eta + 10.2573*eta + 1.7336
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
The augmented spin $\chi$ is defined in OB2020 Equation (3.7) (where it is denoted $\tilde{\chi}$; note that $\nu = \eta$ from the first paragraph of Section II):
\begin{equation*} \chi = \frac{{\bf S}_{\rm Kerr} \cdot \hat{\bf L}}{1 - 2\eta} + \alpha\frac{({\bf S}_{1}^{\perp} + {\bf S}_{2}^{\perp}) \cdot {\bf S}_{\rm Kerr}}{ \left\lvert{\bf S}_{\rm Kerr} \right\rvert (1 - 2\eta)}. \end{equation*}From the discussion after this equation we take $\alpha = \frac{1}{2}$. We define ${\bf S}^{\perp} = {\bf S}_{1}^{\perp} + {\bf S}_{2}^{\perp}$ in this cell, ${\bf L}$ in this cell, $\left\lvert{\bf S}_{\rm Kerr} \right\rvert$ in this cell, and $\eta$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
chi = (Skerr1*Lhat1 + Skerr2*Lhat2 + Skerr3*Lhat3)/(1 - 2*eta)
+ sp.Rational(1,2)*(Sperp1*Skerr1 + Sperp2*Skerr2 + Sperp3*Skerr3)/(Skerrmag*(1. - 2.*eta))
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.40), we have
\begin{equation*} \tilde{\omega}_{\rm fd} = 2 a M r + \omega_{1}^{\rm fd} \eta \frac{ a M^{3} }{ r } + \omega_{2}^{\rm fd} \eta \frac{ M a^{3} }{ r }. \end{equation*}From discussion after BB2010 Equation (6.7), we set $\omega_{1}^{\rm fd} = \omega_{2}^{\rm fd} = 0$. Thus
\begin{equation*} \tilde{\omega}_{\rm fd} = 2 a M r. \end{equation*}We define $a$ in this cell, $M$ in this cell, and $r$ in this cell below.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
omegatilde = 2*a*r
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Dinv = 1 + sp.log(1 + 6*eta*u*u + 2*(26 - 3*eta)*eta*u*u*u)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Sigma = r*r + a*a*costheta*costheta
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
w2 = a*a + r*r
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
Using a common trigonometric idenitity,
\begin{equation*} \sin^{2} \theta = 1 - \cos^{2} \theta. \end{equation*}We define $\cos \theta$ in this cell. Note that by construction (from discussion after BB2010 Equation (5.52))
\begin{equation*} \xi^{2} = \sin^{2} \theta. \end{equation*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
xisq = sin2theta
sin2theta = 1 - costheta*costheta
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion in BB2010 after equation (5.52) (noting that ${\bf e}_{3} = \hat{\bf S}_{\rm Kerr}$),
\begin{equation*} \cos \theta = {\bf e}_{3} \cdot {\bf n} = {\bf e}_{3}^{1} n^{1} + {\bf e}_{3}^{2} n^{2} + {\bf e}_{3}^{3} n^{3}. \end{equation*}We define ${\bf e}_{3}$ in this cell and ${\bf n}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
costheta = e31*n1 + e32*n2 + e33*n3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
v1 = n2*xi3 - n3*xi2
v2 = n3*xi1 - n1*xi3
v3 = n1*xi2 - n2*xi1
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
xi1 = e32*n3 - e33*n2
xi2 = e31*n3 + e33*n1
xi3 = e31*n2 - e32*n1
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
e31 = Skerrhat1
e32 = Skerrhat2
e33 = Skerrhat3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
n1 = x/r
n2 = y/r
n3 = z/r
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Sperp1 = S1perp1 + S2perp1
Sperp2 = S1perp2 + S2perp2
Sperp3 = S1perp3 + S2perp3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion after OB2020 Equation (3.7), we find
\begin{align*} {\bf S}_{1}^{\perp} &= {\bf S}_{1} - \left( {\bf S}_{1} \cdot \hat{\bf L} \right) \hat{\bf L} \\ {\bf S}_{2}^{\perp} &= {\bf S}_{2} - \left( {\bf S}_{2} \cdot \hat{\bf L} \right) \hat{\bf L} \end{align*}%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
S2perp1 = S2x - S2dotLhat*Lhat1
S2perp2 = S2y - S2dotLhat*Lhat2
S2perp3 = S2z - S2dotLhat*Lhat3
S1perp1 = S1x - S1dotLhat*Lhat1
S1perp2 = S1y - S1dotLhat*Lhat2
S1perp3 = S1z - S1dotLhat*Lhat3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
For convenience, we here compute ${\bf S}_{1} \cdot \hat{\bf L}$ and ${\bf S}_{2} \cdot \hat{\bf L}$. We define $\hat{\bf L}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
S1dotLhat = S1x*Lhat1 + S1y*Lhat2 + S1z*Lhat3
S2dotLhat = S2x*Lhat1 + S2y*Lhat2 + S2z*Lhat3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From the discussion after P2010, the orbital angular momentum ${\bf L}$ of the system is given by
\begin{equation*} {\bf L} = {\bf x }\times{\bf p } \end{equation*}where ${\bf x} = (x, y, z)$ is the position vector and ${\bf p} = (p_{1}, p_{2}, p_{3})$ is the momentum vector. We denote by $\hat{\bf L}$ the normed orbital angular momentum.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Lhat1 = L1/Lnorm
Lhat2 = L2/Lnorm
Lhat3 = L3/Lnorm
Lnorm = sp.sqrt(L1*L1 + L2*L2 + L3*L3)
L1 = y*p3 - z*p2
L2 = z*p1 - x*p3
L3 = x*p2 - y*p1
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
a = Skerrmag
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Skerrhat1 = Skerr1/Skerrmag
Skerrhat2 = Skerr2/Skerrmag
Skerrhat3 = Skerr3/Skerrmag
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
We have
\begin{equation*} \left\lvert {\bf S}_{\rm Kerr} \right\rvert = \sqrt{ {\bf S}_{\rm Kerr}^{1} {\bf S}_{\rm Kerr}^{1} + {\bf S}_{\rm Kerr}^{2} {\bf S}_{\rm Kerr}^{2} + {\bf S}_{\rm Kerr}^{3} {\bf S}_{\rm Kerr}^{3} }. \end{equation*}We define ${\bf S}_{\rm Kerr}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Skerrmag = sp.sqrt(Skerr1*Skerr1 + Skerr2*Skerr2 + Skerr3*Skerr3)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
From BB2010 Equation (5.64):
\begin{equation*} {\bf S}_{\rm Kerr} = \boldsymbol{\sigma} + \frac{ 1 }{ c^{2} } \boldsymbol{\Delta}_{\sigma}. \end{equation*}In BB2010 Equation (5.67), $\boldsymbol{\Delta}_{\sigma} = 0$. Thus
\begin{equation*} {\bf S}_{\rm Kerr} = \boldsymbol{\sigma}. \end{equation*}We define $\boldsymbol{\sigma}$ in this cell.
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
Skerr1 = sigma1
Skerr2 = sigma2
Skerr3 = sigma3
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigma1 = S1x + S2x
sigma2 = S1y + S2y
sigma3 = S1z + S2z
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
sigmastar1 = m2/m1*S1x + m1/m2*S2x
sigmastar2 = m2/m1*S1y + m1/m2*S2y
sigmastar3 = m2/m1*S1z + m1/m2*S2z
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
u = 1/r
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
r = sp.sqrt(x*x + y*y + z*z)
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
eta = mu/M
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
mu = m1*m2/M
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
%%writefile -a $Ccodesdir/v4P_Hamiltonian-Hreal_on_top.txt
M = m1 + m2
Appending to SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt
The following code cell reverses the order of the expressions output to SEOBNR/Hamiltonian_on_top.txt and creates a Python function to validate the value of $H_{\rm real}$ against the SEOBNRv3 Hamiltonian value computed in LALSuite git commit bba40f21e9 for command-line input parameters
-M 23 -m 10 -f 20 -X 0.01 -Y 0.02 -Z -0.03 -x 0.04 -y -0.05 -z 0.06.
import numpy as np
import difflib, sys, os
# The subterms in the Hamiltonian expression are sometimes written on more than
# one line for readability in this Jupyter notebook. We first create a file of
# one-line expressions, Hamiltonian-Hreal_one_line_expressions.txt.
with open(os.path.join(Ccodesdir,"v4P_Hamiltonian-Hreal_one_line_expressions.txt"), "w") as output:
count = 0
# Read output of this notebook
for line in list(open("SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt")):
# Read the first line
if count == 0:
prevline=line
#Check if prevline is a complete expression
elif "=" in prevline and "=" in line:
output.write("%s\n" % prevline.strip('\n'))
prevline=line
# Check if line needs to be adjoined to prevline
elif "=" in prevline and not "=" in line:
prevline = prevline.strip('\n')
prevline = (prevline+line).replace(" ","")
# Be sure to print the last line.
if count == len(list(open("SEOBNR/v4P_Hamiltonian-Hreal_on_top.txt")))-1:
if not "=" in line:
print("ERROR. Algorithm not robust if there is no equals sign on the final line. Sorry.")
sys.exit(1)
else:
output.write("%s" % line)
count = count + 1
# Now reverse the expressions and write them in a function
# This formulation is used to check that we get a reasonable H_real value
with open(os.path.join(Ccodesdir,"v4P_Hreal_on_bottom.py"), "w") as output:
output.write("import numpy as np\ndef compute_v4P_Hreal(m1=23., m2=10., EMgamma=0.577215664901532860606512090082402431, tortoise=1, x=2.1242072413581923e+01, y=0., z=0., p1=0., p2=2.1696072000958128e-01, p3=1.0000000000000000e-03, S1x=4.8576675849403119e-03, S1y=9.7153351698806237e-03, S1z=-1.4573002754820936e-02, S2x=3.6730945821854912e-03, S2y=-4.5913682277318639e-03, S2z=5.5096418732782371e-03):\n")
for line in reversed(list(open("SEOBNR/v4P_Hamiltonian-Hreal_one_line_expressions.txt"))):
output.write(" %s\n" % line.rstrip().replace("sp.sqrt", "np.sqrt").replace("sp.Rational",
"np.divide").replace("sp.abs", "np.abs").replace("sp.log",
"np.log").replace("sp.sign", "np.sign").replace("sp.pi",
"np.pi"))
output.write(" return Hreal")
# Now reverse the expressions in a standalone text file
# This formulation is used as a harsher validation check that all expressions agree with a trusted list
with open(os.path.join(Ccodesdir,"v4P_Hamiltonian_expressions.txt-VALIDATION"), "w") as output:
for line in reversed(list(open("SEOBNR/v4P_Hamiltonian-Hreal_one_line_expressions.txt"))):
output.write("%s\n" % line.rstrip().replace("sp.sqrt", "np.sqrt").replace("sp.Rational",
"np.divide").replace("sp.abs", "np.abs").replace("sp.log",
"np.log").replace("sp.sign", "np.sign").replace("sp.pi",
"np.pi"))
print("Printing difference between notebook output and a trusted list of expressions...")
# Open the files to compare
file = "v4P_Hamiltonian_expressions.txt"
outfile = "v4P_Hamiltonian_expressions.txt-VALIDATION"
print("Checking file " + outfile)
with open(os.path.join(Ccodesdir,file), "r") as file1, open(os.path.join(Ccodesdir,outfile), "r") as file2:
# Read the lines of each file
file1_lines=[]
file2_lines=[]
for line in file1.readlines():
file1_lines.append(line.replace(" ", ""))
for line in file2.readlines():
file2_lines.append(line.replace(" ", ""))
num_diffs = 0
for line in difflib.unified_diff(file1_lines, file2_lines, fromfile=os.path.join(Ccodesdir,file), tofile=os.path.join(Ccodesdir,outfile)):
sys.stdout.writelines(line)
num_diffs = num_diffs + 1
if num_diffs == 0:
print("No difference. TEST PASSED!")
else:
print("ERROR: Disagreement found with the trusted file. See differences above.")
sys.exit(1)
# Import the new Hamiltonian function and the trusted Hamiltonian function
import SEOBNR.SEOBNR_v4P_Hamiltonian as Hreal_trusted
import SEOBNR.v4P_Hreal_on_bottom as Hreal_new
# Compute the trusted and new Hamiltonian values; compare; exit if they disagree!
Hreal = Hreal_trusted.compute_v4P_Hreal()
Hreal_temp = Hreal_new.compute_v4P_Hreal()
if(np.abs(Hreal-Hreal_temp)>1e-14):
print("ERROR. You have broken the Hamiltonian computation!")
print("Hreal_trusted was ",Hreal)
print("...and Hreal is now ", Hreal_temp)
sys.exit(1)
Printing difference between notebook output and a trusted list of expressions... Checking file v4P_Hamiltonian_expressions.txt-VALIDATION No difference. TEST PASSED!
The following code cell converts this Jupyter notebook into a proper, clickable $\LaTeX$-formatted PDF file. After the cell is successfully run, the generated PDF may be found in the root NRPy+ tutorial directory, with filename Tutorial-SEOBNR_Documentation.pdf (Note that clicking on this link may not work; you may need to open the PDF file through another means.)
import cmdline_helper as cmd # NRPy+: Multi-platform Python command-line interface
cmd.output_Jupyter_notebook_to_LaTeXed_PDF("Tutorial-SEOBNR_Documentation")
[NbConvertApp] WARNING | pattern 'Tutorial-SEOBNR_Documentation.ipynb' matched no files Created Tutorial-SEOBNR_Documentation.tex, and compiled LaTeX file to PDF file Tutorial-SEOBNR_Documentation.pdf