diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-01-23 10:03:29 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-01-23 10:03:46 +0100 |
commit | 3be71694e0f72ab01400914e9abba771aa0faaf1 (patch) | |
tree | df71c0c89c245faea12c9097453727df8673669e /test | |
parent | 79a38a85bb13a746effdb13bba649c5a6e1c2465 (diff) |
doublenull: add a function for inverse double-null coordinates
I.e. computing T/X(U, V).
Diffstat (limited to 'test')
-rw-r--r-- | test/test_doublenull.npz | bin | 103064 -> 119924 bytes | |||
-rw-r--r-- | test/test_doublenull.py | 28 |
2 files changed, 28 insertions, 0 deletions
diff --git a/test/test_doublenull.npz b/test/test_doublenull.npz Binary files differindex db5fc85..bf7b384 100644 --- a/test/test_doublenull.npz +++ b/test/test_doublenull.npz diff --git a/test/test_doublenull.py b/test/test_doublenull.py index 204870d..41fbc91 100644 --- a/test/test_doublenull.py +++ b/test/test_doublenull.py @@ -4,6 +4,9 @@ from unittest import TestCase import numpy as np from numpy.testing import assert_allclose +from scipy.integrate import cumulative_trapezoid +from scipy.interpolate import interp1d + from math_utils import array_utils from nr_analysis_axi import doublenull, invars @@ -43,3 +46,28 @@ class TestDoubleNull(TestCase): assert_allclose(coords[1], self.data['vxt'], 1e-12) #self.update_refs(uxt = coords[0], vxt = coords[1]) + + def test_null_coordinates_inv(self): + t = self.data['t'] + x = self.data['x'] + idx = x.shape[0] // 2 + + gxx = self.data['gxx'] + alpha = self.data['alpha'] + + # proper time τ(t) + tau_t = cumulative_trapezoid(alpha[:, idx], t, initial = 0.0) + + # uniform grid in τ + tau_uniform = np.linspace(tau_t[0], tau_t[-1], t.shape[0]) + + # t on the uniform τ grid + t_tau = interp1d(tau_t, t)(tau_uniform) + + Tuv, Xuv = doublenull.null_coordinates_inv(t, x, tau_uniform, + gxx, None, -(alpha ** 2), + uv_times = t_tau) + assert_allclose(Tuv, self.data['Tuv'], 1e-12) + assert_allclose(Xuv, self.data['Xuv'], 1e-12) + + #self.update_refs(Tuv = Tuv, Xuv = Xuv) |