Example #1
0
def test_cartesian_norm():
    test_data_x = 1 * u.km
    test_data_y = 1 * u.km
    test_data_z = 1 * u.km

    test_obj = Cartesian(x=test_data_x, y=test_data_y, z=test_data_z)
    assert_allclose((test_obj.norm()).si.value, (np.sqrt(3) * u.km).si.value,
                    rtol=0,
                    atol=1e-5)
Example #2
0
    def coord_photon_bl(self, x, y, z):
        """

        Parameters
        ----------
        r_obs : float
                The observer is located at a distance r_obs from
                the black hole center

        theta_obs: float
                The observer is located at an angle theta_obs
                from the positive black hole z'-axis
                (coinciding with the spin axis)

        phi_obs: float
                The observer is located at an angle phi_obs
                with respect to the black hole’s x′-axis

        M : float
            Mass of massive body

        a : float
            Spin factor

        x , y , z: float
            Coordinates in observer's coordinate system i.e. observer grid

        x_bh , y_bh , z_bh:
            Coordinates in black hole's  coordinate system

        Returns
        -------
        array
            (r, θ, φ) conditions for a photon on the observer grid

        """

        D = ((np.sqrt((self.r_obs * self.r_obs) +
                      (self.a * self.a))) - z) * np.sin(self.theta_obs)
        -(y * np.cos(self.theta_obs))

        x_bh = (D * np.cos(self.phi_obs)) - (x * np.sin(self.phi_obs))
        y_bh = (D * np.sin(self.phi_obs)) + (x * np.cos(self.phi_obs))
        z_bh = (self.r_obs - z) * np.cos(self.theta_obs) + (
            y * np.sin(self.theta_obs))

        blackhole_grid = Cartesian(x_bh, y_bh, z_bh)

        return blackhole_grid.to_bl(self.a)
Example #3
0
def test_cartesian_dot():
    test_data_x = 3 * u.km
    test_data_y = 3 * u.km
    test_data_z = 3 * u.km

    test_data_x_target = 3 * u.km
    test_data_y_target = 3 * u.km
    test_data_z_target = 3 * u.km

    test_obj = Cartesian(x=test_data_x, y=test_data_y, z=test_data_z)
    test_target_obj = Cartesian(x=test_data_x_target,
                                y=test_data_y_target,
                                z=test_data_z_target)

    assert_allclose(
        (test_obj.dot(test_target_obj)).si.value,
        (27 * u.km * u.km).si.value,
        rtol=0,
        atol=1e-5,
    )
Example #4
0
def cartesian():
    return Cartesian(20.0 * u.km, 311e3 * u.m, 210e5 * u.cm)
Example #5
0
        to_cartesian.si_values(), cartesian.si_values(), rtol=0.0, atol=1e-6
    )


def test_BoyerLindquistToSpherical(boyerlindquist, spherical):
    bl = boyerlindquist
    to_spherical = bl.to_spherical()
    assert_allclose(
        to_spherical.si_values(), spherical.si_values(), rtol=0.0, atol=1e-6
    )


@pytest.mark.parametrize(
    "cart, a",
    [
        (Cartesian(10 * u.m, 10 * u.m, 0 * u.m), 0.7 * u.m),
        (Cartesian(-732.0 * u.km, 456 * u.km, -90 * u.km), 9.0 * u.km),
        (Cartesian(-0.732 * u.km, -1.456 * u.km, 90 * u.m), 21 * u.m),
        (Cartesian(2 * u.m, -1 * u.m, 0 * u.cm), 0 * u.cm),
    ],
)
def test_cycle_CartesianBL(cart, a):
    bl = cart.to_bl(a)
    cart2 = bl.to_cartesian()
    assert_allclose(cart2.si_values(), cart.si_values(), rtol=0.0, atol=1e-6)


@pytest.mark.parametrize(
    "bl",
    [
        BoyerLindquist(3 * u.m, 120 * u.deg, 175 * u.deg, 0.3 * u.m),
def cartesian():
    return Cartesian(0.0 * u.s, 2e4 * u.m, 311e3 * u.m, 210e3 * u.m)
def test_BoyerLindquistToSpherical(boyerlindquist, spherical):
    M = 1e24 * u.kg
    a = 0.75 * u.one
    bl = boyerlindquist
    to_spherical = bl.to_spherical(M=M, a=a)
    assert_allclose(to_spherical.values(),
                    spherical.values(),
                    rtol=0.0,
                    atol=1e-6)


@pytest.mark.parametrize(
    "cart, M, a",
    [
        (Cartesian(1e0 * u.s, 10 * u.m, 10 * u.m,
                   0 * u.m), 1e24 * u.kg, 0.7 * u.one),
        (Cartesian(1e1 * u.s, -732e2 * u.m, 456e2 * u.m,
                   -90e2 * u.m), 3e10 * u.kg, 0.9 * u.one),
        (Cartesian(1e2 * u.s, -0.732e2 * u.m, -1.456e2 * u.m,
                   90 * u.m), 55e20 * u.kg, 0.3 * u.one),
        (Cartesian(1e3 * u.s, 2 * u.m, -1 * u.m,
                   0 * u.m), 7e10 * u.kg, 0 * u.one),
    ],
)
def test_cycle_CartesianBL(cart, M, a):
    bl = cart.to_bl(M=M, a=a)
    cart2 = bl.to_cartesian(M=M, a=a)
    assert_allclose(cart2.values(), cart.values(), rtol=0.0, atol=1e-6)


@pytest.mark.parametrize(