Skip to content

NRPyPN 2.0.2

Latest

Choose a tag to compare

@zachetienne zachetienne released this 18 Oct 22:47
· 5 commits to main since this release

NRPyPN 2.0.2

NRPyPN 2.0.2 corrects four transcription defects that NRPyPN 2.0.1 inherited from
the NRPyPN code in the nrpytutorial.
It also records the history of each discrepancy in the docstrings of the affected
modules, adds a Validation section to the README, and regenerates the trusted
values that the tests compare against.

There are no API changes and no dependency changes. Outputs change only for
spinning binaries, as described under Who is affected.

  • Release commit: Release NRPyPN 2.0.2 (tag v2.0.2)
  • Previous release: NRPyPN 2.0.1
  • PyPI version: 2.0.2 (nrpypn/release.txt)

Contents

  1. Summary of changes
  2. Who is affected
  3. The four corrections in detail
  4. Effect on numerical results
  5. Documentation changes
  6. Trusted values regenerated
  7. Checks performed
  8. History of each discrepancy
  9. Limitations and open points
  10. Upgrading
  11. Packaging and release

Summary of changes

# Module Correction Quantities that change
1 PN_Hamiltonian_SSS.py Coefficient of the m1/m2 block of the cubic-in-spin Hamiltonian: -3 m1/(2 m2) → -9 m1/(4 m2) cubic-in-spin terms of a_7 in PN_p_t.py and PN_MOmega.py; four monomials of the r^(-4) group of the closed-form p_r in PN_p_r.py, and dr_dt, so the closed-form p_r also changes for aligned spins; the full-Hamiltonian route to p_r
2 PN_Hamiltonian_SS.py S1·p1 → S1·p2 in the 3/(2 m2² r12³) block of the S1S2 3PN Hamiltonian the full-Hamiltonian route to p_r only
3 PN_Hamiltonian_SO.py Added the term +(n12·p2)(p2·p2)/(m1 m2³) to the third bracket of the 3.5PN spin-orbit Hamiltonian nothing in the center-of-mass frame (the term vanishes there)
4 PN_p_r.py Reversed the signs of the two in-plane-spin groups (r^(-7/2) and r^(-4)) of the closed-form p_r closed-form p_r for binaries with in-plane spin components

What each correction can change:

  • Nonspinning binaries are unchanged by all four corrections.
  • Correction 1 changes nothing unless both bodies spin: every term of the changed
    block, and of the resulting change of a_7, contains a spin component of each
    body.
  • Correction 2 changes only the full-Hamiltonian route to p_r, and only if the
    spin of body 2 has a component along n12 and the spin of body 1 has an in-plane
    component (so not for spins aligned with the orbital angular momentum).
  • Correction 3 changes nothing in the center-of-mass frame.
  • Correction 4 changes only the closed-form p_r, and only if an x-component and
    a y-component of the spins are both nonzero (every term of the two groups
    contains one of each, with x along n12 and y along the tangential momentum of
    body 1).
  • p_t and M·Omega change only through correction 1.

Who is affected

Input p_t and M·Omega p_r, closed form (default) p_r, full-Hamiltonian route
Nonspinning unchanged unchanged unchanged
One spinning body, spin aligned with the orbital angular momentum unchanged unchanged unchanged
Both bodies spinning, spins aligned changes (correction 1) changes (correction 1) changes (correction 1)
One spinning body, with x- and y-components of spin unchanged changes (correction 4) unchanged
Both bodies spinning, with x- and y-components of spin changes (correction 1) changes (corrections 1 and 4) changes (corrections 1 and 2)

The size of the changes in the repository's own evaluation cases, and in IDs 21
to 25 of Table V of Ramos-Buades, Husa, and Pratten, is given under
Effect on numerical results.

The four corrections in detail

1. Cubic-in-spin Hamiltonian: coefficient -9/4

Where: nrpypn/PN_Hamiltonian_SSS.py, then nrpypn/PN_p_t.py,
nrpypn/PN_MOmega.py and nrpypn/PN_p_r.py.

What was wrong. In Eq. 3.12 of Levi and Steinhoff
(arXiv:1410.2601), the block proportional to
m1/m2 lies inside the group multiplied by 3/2. Its coefficient is therefore
3/2 × (-3/2) = -9/4. NRPyPN 2.0.1 used -3/2, as if the block lay outside the
group.

The code change.

# before
-3*m1/(2*m2)*(   dot(S1U,S1U)  *dot(S2U,cross(nU,p2U))
# after
-9*m1/(4*m2)*(   dot(S1U,S1U)  *dot(S2U,cross(nU,p2U))

Propagation. a_7 of M·Omega and p_t, the r^(-4) cubic terms of the
closed-form p_r, and dr_dt (which depends on this Hamiltonian at p_r = 0, on
p_t and on M·Omega) follow from this Hamiltonian, so they change with it. For
aligned spins the closed-form p_r changes only through dr_dt.
Writing q = m2/m1 (with q >= 1) and

B = 2 chi1x^2 chi2z + 2 chi1x chi1z chi2x - chi1y^2 chi2z - chi1z^2 chi2z
    + q^2 (2 chi1x chi2x chi2z + 2 chi1z chi2x^2 - chi1z chi2y^2 - chi1z chi2z^2),

the new a_7 minus the old a_7 is

  • 15 q B / (8 (q+1)^4) for p_t (PN_p_t.py),
  • 9 q B / (8 (q+1)^4) for M·Omega (PN_MOmega.py).

Every term of B contains a spin component of body 1 and a spin component of
body 2, so B = 0 whenever either body is nonspinning.

a_7 enters M·Omega as a_7 / r^(7/2) inside the bracket
1 + sum_k a_k / r^(k/2), so the correction is a 3.5PN-order term.

Coefficients changed in the a_7 of PN_p_t.py (eight monomials; the same
eight monomials change in PN_MOmega.py, with the factor 15 replaced by 9 and
45 by 27):

Monomial Old coefficient New coefficient
chi1x chi2x chi2z 15 (2q+1) q² / (4 (q+1)^4) 15 (3q+1) q² / (4 (q+1)^4)
chi1x chi2x chi1z 15 (q+2) q / (4 (q+1)^4) 15 (q+3) q / (4 (q+1)^4)
chi1z chi2x² 15 q² (2q+3) / (4 (q+1)^4) 45 q² / (4 (q+1)^3)
chi1z chi2y² -15 q² (q+2) / (4 (q+1)^4) -15 q² (3q+4) / (8 (q+1)^4)
chi1z chi2z² -15 q² / (4 (q+1)^3) -15 q² (3q+2) / (8 (q+1)^4)
chi1x² chi2z 15 q (3q+2) / (4 (q+1)^4) 45 q / (4 (q+1)^3)
chi1y² chi2z -15 q (2q+1) / (4 (q+1)^4) -15 q (4q+3) / (8 (q+1)^4)
chi1z² chi2z -15 q / (4 (q+1)^3) -15 q (2q+3) / (8 (q+1)^4)

Size of the change in p_t. For 1 <= q <= 8, |chi1|, |chi2| <= 0.9 and
r >= 10, the largest relative change of p_t that a numerical search finds is
7.7e-5, at q = 2.81, r = 10, |chi1| = |chi2| = 0.9. This is a search
result and is not proved to be the global maximum.

p_r. Four monomials of the r^(-4) group of the closed-form p_r carry
the factors (5q+3) and (3q+5), where NRPyPN 2.0.1 and the printed formula of
Ramos-Buades, Husa, and Pratten
(arXiv:1810.00036, Eq. 2.16) have (5q+2) and
(2q+5):

# before
+(+chi1z*(+3*q   *(5*q+2)*chi1x*chi2y/(2*(q+1)**4)
          -3*q**2*(2*q+5)*chi2x*chi2y/(2*(q+1)**4))
  +chi1y*chi2z*(+3*q**2*(2*q+5)*chi2x/(2*(q+1)**4)
                -3*q   *(5*q+2)*chi1x/(2*(q+1)**4)))/r**4
# after
+(+chi1z*(-3*q   *(5*q+3)*chi1x*chi2y/(2*(q+1)**4)
          +3*q**2*(3*q+5)*chi2x*chi2y/(2*(q+1)**4))
  +chi1y*chi2z*(-3*q**2*(3*q+5)*chi2x/(2*(q+1)**4)
                +3*q   *(5*q+3)*chi1x/(2*(q+1)**4)))/r**4

(The reversed overall signs in this group belong to correction 4.)

Related note on the literature. The docstring of PN_Hamiltonian_SSS.py
records that Eq. 2.13 of Hergt and Schäfer
(arXiv:0809.2208) prints the prefactor
3 m2/(4 m1) where 3 m1/(4 m2), which reproduces Eq. 3.12 of Levi and
Steinhoff, is needed. Eq. 3.12 itself is not at fault.

2. Spin-spin Hamiltonian: S1·p2

Where: nrpypn/PN_Hamiltonian_SS.py, function f_H_SS_S1S2_3PN.

What was wrong. The 3/(2 m2² r12³) block of Eq. 2.11 of Steinhoff, Hergt, and
Schäfer (arXiv:0712.1716) contains S1·p2.
NRPyPN 2.0.1 had S1·p1.

# before
-dot(S2U,n12U)*dot(S1U,p1U)*dot(p2U,n12U))*3/(2*m2**2*r12**3)
# after
-dot(S2U,n12U)*dot(S1U,p2U)*dot(p2U,n12U))*3/(2*m2**2*r12**3)

Effect. The difference contains the explicit factor p2·n12, so it vanishes
on circular orbits together with its r and p_t derivatives. p_t,
M·Omega and the closed-form p_r are therefore unchanged. Its first and second
derivatives with respect to p_r do not vanish in general, so it changes the
full-Hamiltonian route to p_r (use_alternative_approach_for_p_r=True).

3. Spin-orbit Hamiltonian: the missing 3.5PN term

Where: nrpypn/PN_Hamiltonian_SO.py, function HS2011_Omega_SO_3p5PN_pt3.

What was wrong. The third bracket of the 3.5PN spin-orbit Hamiltonian of
Hartung and Steinhoff (arXiv:1104.3079, Eq. 5)
ends with +(n12·p2)(p2·p2)/(m1 m2³). NRPyPN 2.0.1 omitted it. The term is
printed in all four arXiv versions of that paper.

# before
-5*dot(n12U,p1U)*dot(p2U,p2U)/(16*m1**2*m2**2))*cross(p1U,p2U)[i])/r12**2
# after
-5*dot(n12U,p1U)*dot(p2U,p2U)/(16*m1**2*m2**2)
+dot(n12U,p2U)*dot(p2U,p2U)/(m1*m2**3))*cross(p1U,p2U)[i])/r12**2

Effect. The bracket multiplies p1 × p2, which vanishes in the center-of-mass
frame (p2 = -p1) that NRPyPN uses for quasicircular initial data. The added term
therefore does not change p_t, M·Omega, or either route to p_r. The trusted
fixture value of the isolated Hamiltonian, H_SO_3p5PN in
tests/PN_Hamiltonian_SO.py, changes from 102.890225 to 102.397799.

4. Closed-form p_r: signs of the in-plane-spin groups

Where: nrpypn/PN_p_r.py, function f_p_r.

What was wrong. The two groups of the closed-form p_r that involve in-plane
spin components (the r^(-7/2) and r^(-4) groups) had the signs printed in the
paper. With the conventions of this module they must have the opposite signs.

The module computes dr_dt = (dE_GW/dt + dM/dt) / (dH_circ/dr), which is positive
on an inspiral and is minus the radial velocity, and p_r is minus the outward
radial momentum. Hamilton's equation for the module's Hamiltonian then fixes the
sign of the in-plane groups. With the signs of NRPyPN 2.0.1 the closed form and
the full-Hamiltonian route (use_alternative_approach_for_p_r=True) disagree at
the order of those groups; with the corrected signs they agree through the orders
kept.

# before
+(-(6*q+13)*q**2*chi1x*chi2y/(4*(q+1)**4)
  -(6*q+ 1)*q**2*chi2x*chi2y/(4*(q+1)**4)
  +chi1y*(-q*(   q+6)*chi1x/(4*(q+1)**4)
          -q*(13*q+6)*chi2x/(4*(q+1)**4)))/r**div(7,2)
# after
+(+(6*q+13)*q**2*chi1x*chi2y/(4*(q+1)**4)
  +(6*q+ 1)*q**2*chi2x*chi2y/(4*(q+1)**4)
  +chi1y*(+q*(   q+6)*chi1x/(4*(q+1)**4)
          +q*(13*q+6)*chi2x/(4*(q+1)**4)))/r**div(7,2)

The r^(-4) group changes sign as shown in correction 1 (combined with the new
factors).

Effect. The closed-form p_r changes by -0.96, -0.12, +0.14, +0.55
and +0.49 percent in Table V IDs 21 to 25 of Ramos-Buades, Husa, and Pratten.
Aligned spins are unchanged by this correction.

Effect on numerical results

Evaluation cases of eval_p_t_and_p_r.py

These are the six cases that test_results_against_trusted() compares against;
q = m2/m1.

Case p_t before p_t after relative change p_r before p_r after relative change
q=2, chi1=(0,0,0), chi2=(-0.3535,0.3535,0.5), r=10.8 0.07935004039 0.07935004039 0 5.426257e-4 5.456208e-4 +5.5e-3
q=8, chi1=(0,0,0.5), chi2=(0,0,0.5), r=11 0.03455036898 0.03455024367 -3.6e-6 9.757353e-5 9.757079e-5 -2.8e-5
q=1.5, chi1=(0,0,-0.6), chi2=(0,0,0.6), r=10.8 0.08685565588 0.08685599881 +3.9e-6 6.770197e-4 6.770418e-4 +3.3e-5
q=4, chi1=(0,0,-0.8), chi2=(0,0,0.8), r=11 0.05580775375 0.05580876089 +1.8e-5 2.511426e-4 2.511777e-4 +1.4e-4
q=1, nonspinning, r=12 0.08509409272 0.08509409272 0 5.398602e-4 5.398602e-4 0
q=1.391, chi1=(0.4381,-0.221,0.314), chi2=(-0.1,0.4,-0.26), r=8.124981 0.1089403562 0.1089395942 -7.0e-6 2.093970e-3 2.074150e-3 -9.5e-3

The q=2 case has a single spinning body with in-plane spin components, so only
correction 4 changes it. The q=1 case is nonspinning and does not change.

Table V of Ramos-Buades, Husa, and Pratten

Closed-form p_r for IDs 21 to 25 (the in-plane-spin cases) changes by -0.96,
-0.12, +0.14, +0.55 and +0.49 percent (correction 4).

Agreement between the two routes to p_r

For the random state with seed 0 that the nrpytutorial notebook PN-p_r.ipynb
uses, the saved notebook output gives a relative difference between the closed
form and the full-Hamiltonian route of 3.9e-3. With these corrections the same
state gives 8.6e-4.

Documentation changes

  • README. A new Validation section states that agreement with a reference
    shows that an expression was transcribed as that reference prints it, not that
    the printed expression is correct. It lists the four corrections and says that
    the comparison with the Mathematica notebooks of Ramos-Buades, Husa, and
    Pratten was made, for M·Omega and p_r, through transcriptions that the
    nrpytutorial labels as taken from them. The Special Thanks sentence about those
    notebooks now says they served as a reference when expressions were checked.
    The project title and the required citation are unchanged.
  • Docstrings recording the history of each discrepancy in
    PN_Hamiltonian_SSS.py, PN_Hamiltonian_SS.py, PN_Hamiltonian_SO.py,
    PN_p_t.py, PN_MOmega.py and PN_p_r.py. See
    History of each discrepancy.
  • Unit vector convention. n12U is (x1 - x2)/r12, pointing from object 2 to
    object 1, and n21U is (x2 - x1)/r12, as in the cited papers. The docstrings
    of PN_Hamiltonian_SSS.py, PN_Hamiltonian_SS.py and PN_Hamiltonian_SO.py
    said the opposite. The code already used the cited convention.
  • PN-order label. The leading cubic-in-spin Hamiltonian is 3.5PN for rapidly
    rotating bodies (Levi and Steinhoff). The docstrings of
    PN_Hamiltonian_SSS.py now say so. The names (such as H_SSS_3PN) keep the
    label 3PN that the nrpytutorial used and are unchanged.
  • Equation number. The closed-form p_r is Eq. 2.16 of
    arXiv:1810.00036, not Eq. 2.18 as the
    docstring said (checked in versions 1 and 2).
  • Sign convention of dr_dt and p_r. dr_dt is -dr/dt (minus the radial
    velocity), and p_r is minus the outward radial momentum. Older docstrings and
    comments in PN_p_r.py called dr_dt simply dr/dt.
  • Comment in eval_p_t_and_p_r.py explaining why the trusted values of the
    cases with spin were regenerated, and that the S1·p2 correction does not
    change them.

Trusted values regenerated

Files under nrpypn/tests/ hold the trusted values that each module compares its
own output against when run as a script. These changed:

File Reason
tests/PN_Hamiltonian_SSS.py correction 1
tests/PN_p_t.py correction 1
tests/PN_MOmega.py correction 1
tests/PN_p_r_AlternativeFalse.py corrections 1, 2 and 4
tests/PN_p_r_AlternativeTrue.py corrections 1 and 2
tests/PN_Hamiltonian_SS.py correction 2
tests/PN_Hamiltonian_SO.py correction 3

Fixture values of the isolated Hamiltonians (evaluated at the fixed random inputs
that NRPy's validate_expressions uses):

Key Before After
PN_Hamiltonian_SSS.py, H_SSS_3PN 3.56845 2.72235
PN_Hamiltonian_SS.py, H_SS_S1S2_3PN 8.60496 8.39405
PN_Hamiltonian_SO.py, H_SO_3p5PN 102.890225 102.397799

eval_p_t_and_p_r.py: the trusted p_t and p_r of the cases with spin are
regenerated because of corrections 1 and 4. Corrections 2 and 3 do not change
these values, and the nonspinning case is unchanged. See the table under
Effect on numerical results.

The regenerated files are written by the installed NRPy. In tests/PN_p_t.py, and
for Htot_xyplane_binary in the two tests/PN_p_r_*.py files, the regenerated
values are mpf where the previous values were mpc with zero imaginary part.
tests/PN_MOmega.py keeps mpc for MOmega and a_6.

Checks performed

  • The corrected cubic-in-spin Hamiltonian follows Eq. 3.12 of Levi and Steinhoff
    (the nested coefficient 3/2 × (-3/2) = -9/4).
  • The changes to a_7 in p_t and M·Omega, and the changed p_r groups, were
    re-derived from the corrected Hamiltonian and compared with the code using
    NRPy's validate_expressions. The previous expressions do not satisfy the same
    comparison.
  • The corrected S1·p2 term and the added spin-orbit term were compared with
    Eq. 2.11 of arXiv:0712.1716 and Eq. 5 of arXiv:1104.3079.
  • The corrected in-plane signs make the closed-form p_r agree with the
    full-Hamiltonian route through the orders kept.
  • Every module that has trusted values passes its comparison: the six modules whose
    values were regenerated (PN_Hamiltonian_SSS.py, PN_Hamiltonian_SS.py,
    PN_Hamiltonian_SO.py, PN_MOmega.py, PN_p_t.py, PN_p_r.py) and the two
    unchanged ones (PN_Hamiltonian_NS.py, PN_dE_GW_dt_and_dM_dt.py).
    eval_p_t_and_p_r.test_results_against_trusted() also passes.
  • A source distribution and a wheel built from the release commit have version
    2.0.2, contain py.typed, and contain the same module files as the release
    commit.

History of each discrepancy

Each of the four discrepancies is also recorded in the docstring of the module
that it affects. What is known about their origin comes from the public history
and notebooks of the nrpytutorial (pinned at commit
a32e120f5642bee00e32e9e04dd8cb4c58ae661c).

Cubic-in-spin coefficient.

  • The first version of the cubic-in-spin Hamiltonian in the nrpytutorial (commit
    981876f0, 2020-05-09) had the block inside the group, as in Eq. 3.12.
  • Commit 61cb9fc8 (2020-05-10, "PN-Hamiltonian-SSS now fully validated") moved
    the block outside the group in the code, giving the coefficient -3/2. The
    reason for the move is not recorded in the commit message, patch or notebook.
  • The nrpytutorial notebooks and NRPyPN 2.0.1 carry that form. The validation
    recorded in the notebook compares two hand transcriptions with each other and
    with its own module, which share the coefficient and so cannot detect it.
  • The a_7 printed by Ramos-Buades, Husa, and Pratten
    (arXiv:1810.00036) corresponds to -3/2 as
    well. So does the a_7 that the nrpytutorial notebook PN-MOmega.ipynb labels
    as taken directly from the authors' Mathematica notebook, and the closed-form
    p_r of PN-p_r.ipynb has the factors (5q+2) and (2q+5) of the paper.

S1·p1 versus S1·p2. The nrpytutorial notebook
PN-Hamiltonian-Spin-Spin.ipynb displays S1·p2 in its equation, but its module
and both of the transcriptions that it compares with each other have S1·p1. The
comparison cannot detect it, and NRPyPN 2.0.1 inherited S1·p1.

Spin-orbit term. In PN-Hamiltonian-Spin-Orbit.ipynb, the module and the first
transcription lack the term; the second transcription (pt3v2) has it. The
notebook compares them with p2 = -p1, where p1 × p2 vanishes, so the
difference was not detected. NRPyPN 2.0.1 inherited the omission.

Signs of the in-plane groups. The nrpytutorial (PN-p_r.ipynb and
PN_p_r.py) has the signs that the paper's Eq. 2.16 prints, which are opposite to
the corrected ones, while using the same positive dr_dt. This is probably a convention mismatch that the
tutorial did not catch; it was not verified against the paper's conventions. The
tutorial's comparison against Table V of the paper prints a good or not-good label
for both routes, decided by the full-Hamiltonian route alone: good if
|pub0 - full|/pub0 <= |pub0 - pub1|/pub1, where pub0 and pub1 are the
printed iteration-0 and iteration-1 values. It does not test the closed form and
asserts nothing. For Table V IDs 21 to 25 the printed iteration differences are
6.1e-5 to 8.3e-5, while this sign changes the closed form by 7.5e-7 to
5.9e-6.

Limitations and open points

  • The authors' original Mathematica notebook was not available. Statements about
    it are limited to what the nrpytutorial notebooks PN-MOmega.ipynb and
    PN-p_r.ipynb record. PN-p_t.ipynb records no Mathematica transcription of
    a_7.
  • The reason that the cubic-in-spin block was moved in the nrpytutorial is not
    recorded in the public commit message, patch or notebook. This says nothing
    about private records.
  • The relative change of p_t of 7.7e-5 quoted above is the largest value found
    by a numerical search. It is not a proved bound.
  • The cause of the sign difference in the in-plane groups is probably a
    convention mismatch and was not verified against the paper's conventions.
  • Agreement between the closed-form and full-Hamiltonian routes to p_r holds
    through the orders kept, not exactly (8.6e-4 for the seed-0 state).
  • The leading cubic-in-spin names retain the label 3PN. Only the docstrings state
    the 3.5PN counting.
  • This release does not change the PN model, the retained orders, the radiation
    flux, or any unchanged coefficient, and it does not claim to certify them.

Upgrading

Once 2.0.2 is published on PyPI:

pip install --upgrade nrpypn
  • Results for spinning binaries change, as described above. To reproduce results
    from NRPyPN 2.0.1, install nrpypn==2.0.1.
  • There are no API changes, and requirements.txt is unchanged.
  • Initial data generated for nonspinning binaries, or for binaries in which only
    one body spins with spin aligned with the orbital angular momentum, is
    unchanged.
  • The citation information in the README is unchanged.

Packaging and release

  • nrpypn/release.txt: version = "2.0.2".
  • setup.py records the commands for creating the GitHub release (an annotated
    tag v2.0.2) in addition to the existing PyPI upload instructions.
  • The release is made in a dedicated commit, Release NRPyPN 2.0.2, that changes
    only nrpypn/release.txt and the instructions in setup.py. The corrections
    are in the preceding commit.