Commit 2a80d4aa authored by James Kennington's avatar James Kennington
Browse files

add initial manifold API for mu coordinates

parent a9ed2e8e
Pipeline #475263 passed with stage
in 4 minutes and 5 seconds
......@@ -5,10 +5,11 @@ References:
Star Coalescence Using Focused Reduced Order Quadrature.” Physical Review D 102, no. 10 (November 9, 2020):
104020. https://doi.org/10.1103/PhysRevD.102.104020.
"""
from typing import Tuple
from typing import Tuple, Union
import numpy
from manifold import coordinate
from manifold.sources import cbc
......@@ -321,3 +322,36 @@ def transform_standard_to_mu(m_1: float, m_2: float, s1_x: float, s1_y: float, s
"""
psi = transform_standard_to_phase(m_1, m_2, s1_x, s1_y, s1_z, s2_x, s2_y, s2_z, f_ref)
return transform_phase_to_mu(psi[0], psi[1], psi[2], u_matrix)
################################################################################
# MANIFOLD COORDINATE API #
################################################################################
class Mu1(coordinate.CoordinateType):
"""Mu 1"""
key = 'mu1'
class Mu2(coordinate.CoordinateType):
"""Mu 2"""
key = 'mu2'
class Mu1Mu2(cbc.CBCCoordFunc):
key = "mu1_mu2"
f_ref = 200 # TODO generalize this
TO_TYPES = (cbc.M1, cbc.M2, cbc.S1Z, cbc.S2Z)
FROM_TYPES = (Mu1, Mu2)
def __call__(self, c: Union[coordinate.Coordinates, coordinate.CoordsDict], inv=False):
if inv:
c = self._normalize_coorddict(c, inv=True)
m1, m2, s1, s2 = c[cbc.M1], c[cbc.M2], c[cbc.S1Z], c[cbc.S2Z]
mu = transform_standard_to_mu(m_1=m1, m_2=m2, s1_x=0, s1_y=0, s1_z=s1, s2_x=0, s2_y=0, s2_z=s2, f_ref=self.f_ref)
return numpy.array([mu[0], mu[1]])
else: # go from mu to standard
# TODO why is c an array?
# TODO invertibility problems in paper / loss of information
raise NotImplementedError
......@@ -3,7 +3,9 @@
import numpy
from numpy import testing
from manifold.sources import cbc_mu
from manifold import coordinate
from manifold.sources import cbc_mu, cbc
from manifold.utilities import common
class TestSpinVariables:
......@@ -90,3 +92,17 @@ class TestCoordinateTransformations:
testing.assert_almost_equal(numpy.array(list(res)),
numpy.array([-0.0006, -0.0039, 0.0]),
decimal=4)
class TestMuManifoldAPI:
"""Test group for mu coords manifold api agreement"""
def test_coordfunc_inverse(self):
"""Test coordfunc inverse transformation"""
c = coordinate.Coordinates(10.0, 20.0, 0.5, 0.2, coord_types=[cbc.M1, cbc.M2, cbc.S1Z, cbc.S2Z])
bounds = common.bounds_from_lists(['m1', 'm2', 'S1z', 'S2z'], [0.1, 0.1, -1, -1], [400, 400, 1, 1])
cfunc = cbc_mu.Mu1Mu2(**bounds)
c_t = cfunc(c.to_dict(), inv=True)
testing.assert_almost_equal(c_t, numpy.array([-0.0006, -0.0039]), decimal=4)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment