summaryrefslogtreecommitdiff
path: root/test/test_doublenull.py
blob: a61af3345985eb662a5e941ec64ef07a57431422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from unittest import TestCase

import numpy as np
from   numpy.testing import assert_allclose

from math_utils      import array_utils
from nr_analysis_axi import doublenull, invars

class TestDoubleNull(TestCase):

    def setUp(self):
        datafile = os.path.splitext(__file__)[0] + '.npz'

        self.data = np.load(datafile)

    def test_null_curves(self):
        rays = doublenull.null_curves(self.data['t'], self.data['x'],
                                      self.data['gxx'], np.zeros_like(self.data['gxx']),
                                      -(self.data['alpha'] ** 2))

        assert_allclose(rays[0], self.data['ray_times'], 1e-12)
        assert_allclose(rays[1], self.data['rays_pos'],  1e-12)
        assert_allclose(rays[2], self.data['rays_neg'],  1e-12)

    def test_null_coordinates(self):
        x = self.data['x']
        idx = x.shape[0] // 2
        gxx = self.data['gxx']
        uv = 0.5 * array_utils.array_reflect(invars.dist_proper(x[idx:], gxx[0, idx:]), -1)

        coords = doublenull.null_coordinates(self.data['t'], x, uv, uv,
                                             gxx, np.zeros_like(gxx),
                                             -(self.data['alpha'] ** 2))
        assert_allclose(coords[0], self.data['uxt'], 1e-12)
        assert_allclose(coords[1], self.data['vxt'], 1e-12)