示例#1
0
def kerr_time_velocity(pos_vec, vel_vec, mass, a):
    """
    Velocity of coordinate time wrt proper metric

    Parameters
    ----------
    pos_vector : ~numpy.array
        Vector with r, theta, phi components in SI units
    vel_vector : ~numpy.array
        Vector with velocities of r, theta, phi components in SI units
    mass : ~astropy.units.kg
        Mass of the body
    a : float
        Any constant

    Returns
    -------
    ~astropy.units.one
        Velocity of time

    """
    _scr = utils.schwarzschild_radius(mass).value
    g = metric(constant.c.value, pos_vec[0], pos_vec[1], _scr, a)
    A = g[0, 0]
    B = 2 * g[0, 3]
    C = (g[1, 1] * (vel_vec[0]**2) + g[2, 2] * (vel_vec[1]**2) + g[3, 3] *
         (vel_vec[2]**2) - 1)
    D = (B**2) - (4 * A * C)
    vt = (B + np.sqrt(D)) / (2 * A)
    return vt * u.one
示例#2
0
    def _draw_attractor(self):
        radius = schwarzschild_radius(self.mass)
        if self.attractor_radius_scale == -1.0:
            minrad_nooverlap = self.mindist(self.__xarr[0], self.__yarr[0])
            for i in range(0, len(self.__xarr)):
                minrad_nooverlap = min(
                    minrad_nooverlap,
                    self.mindist(self.__xarr[i], self.__yarr[i]))

            xlen = max(self.__xarr) - min(self.__xarr)
            ylen = max(self.__yarr) - min(self.__yarr)
            minlen_plot = min(xlen, ylen)
            mulitplier = minlen_plot / (12 * radius)
            min_radius = radius * mulitplier

            radius = min(min_radius, minrad_nooverlap)
            self.get_curr_plot_radius = radius
            self.ax.add_patch(
                mpl.patches.Circle((0, 0),
                                   radius,
                                   lw=0,
                                   color=self.attractor_color))
        else:
            radius = radius * self.attractor_radius_scale
            self.get_curr_plot_radius = radius
            self.ax.add_patch(
                mpl.patches.Circle((0, 0),
                                   radius.value,
                                   lw=0,
                                   color=self.attractor_color))
示例#3
0
def test_calculate_trajectory(
    pos_vec, vel_vec, time, M, a, start_lambda, end_lambda, OdeMethodKwargs
):
    _scr = schwarzschild_radius(M).value
    obj = Kerr.from_BL(pos_vec, vel_vec, time, M, a)
    ans = obj.calculate_trajectory(
        start_lambda=start_lambda,
        end_lambda=end_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
    )
    ans = ans[1]
    testarray = list()
    for ansi in ans:
        g = kerr_utils.metric(_c, ansi[1], ansi[2], _scr, a)
        tmp = (
            g[0][0] * (ansi[4] ** 2)
            + g[1][1] * (ansi[5] ** 2)
            + g[2][2] * (ansi[6] ** 2)
            + g[3][3] * (ansi[7] ** 2)
            + 2 * g[0][3] * ansi[4] * ansi[7]
        )
        testarray.append(tmp)
    testarray = np.array(testarray, dtype=float)
    comparearray = np.ones(shape=ans[:, 4].shape, dtype=float)
    assert_allclose(testarray, comparearray, 1e-4)
示例#4
0
def test_radius_ergosphere_for_nonrotating_case():
    M = 5e27
    a = 0.0
    _scr = utils.schwarzschild_radius(M * u.kg).value
    a1 = kerr_utils.radius_ergosphere(_scr, a, np.pi / 5)
    a2 = kerr_utils.radius_ergosphere(_scr, a, np.pi / 5, "Spherical")
    assert_allclose(a1, a2, rtol=0.0, atol=1e-5)
    assert_allclose(a1[0], _scr, rtol=0.0, atol=1e-5)
示例#5
0
def test_event_horizon_for_nonrotating_case():
    M = 5e27
    a = 0.0
    _scr = utils.schwarzschild_radius(M * u.kg).value
    a1 = kerr_utils.event_horizon(_scr, a, np.pi / 4)
    a2 = kerr_utils.event_horizon(_scr, a, np.pi / 4, "Spherical")
    assert_allclose(a1, a2, rtol=0.0, atol=1e-5)
    assert_allclose(a1[0], _scr, rtol=0.0, atol=1e-5)
示例#6
0
 def __init__(self, pos_vec, vel_vec, time, M):
     self.M = M
     self.pos_vec = pos_vec
     self.vel_vec = vel_vec
     self.time = time
     self.time_vel = time_velocity(pos_vec, vel_vec, M)
     self.initial_vec = np.hstack(
         (self.time.value, self.pos_vec, self.time_vel.value, self.vel_vec))
     self.schwarzschild_r = schwarzschild_radius(M)
示例#7
0
 def __init__(self, sph_coords, M, time):
     self.M = M
     self.input_coords = sph_coords
     self.time = time
     pos_vec, vel_vec = (
         self.input_coords.si_values()[:3],
         self.input_coords.si_values()[3:],
     )
     time_vel = schwarzschild_utils.time_velocity(pos_vec, vel_vec, M)
     self.initial_vec = np.hstack(
         (self.time.value, pos_vec, time_vel.value, vel_vec))
     self.scr = schwarzschild_radius(M)
示例#8
0
 def __init__(self, pos_vec, vel_vec, q, time, M, a, Q):
     self.M = M
     self.a = a
     self.Q = Q
     self.q = q
     self.pos_vec = pos_vec
     self.vel_vec = vel_vec
     self.time = time
     self.time_vel = kerrnewman_utils.kerrnewman_time_velocity(
         self.pos_vec, self.vel_vec, self.M, self.a, Q)
     self.initial_vec = np.hstack(
         (self.time.value, self.pos_vec, self.time_vel.value, self.vel_vec))
     self.schwarzschild_r = schwarzschild_radius(M)
示例#9
0
    def __init__(self, bl_coords, M, time):
        self.input_coords = bl_coords
        self.M = M
        self.a = self.input_coords.a.to(u.m)
        self.time = time

        pos_vec, vel_vec = (
            self.input_coords.si_values()[:3],
            self.input_coords.si_values()[3:],
        )
        time_vel = kerr_utils.kerr_time_velocity(pos_vec, vel_vec, self.M,
                                                 self.a.value)

        self.initial_vec = np.hstack(
            (self.time.value, pos_vec, time_vel.value, vel_vec))
        self.scr = schwarzschild_radius(M)
示例#10
0
    def __init__(self, bl_coords, q, M, Q, time):
        self.input_coords = bl_coords
        self.name = "KerrNewman"
        self.M = M
        self.a = self.input_coords.a.to(u.m)
        self.Q = Q
        self.q = q

        pos_vec, vel_vec = (
            self.input_coords.si_values()[:3],
            self.input_coords.si_values()[3:],
        )
        self.time = time
        time_vel = kerrnewman_utils.kerrnewman_time_velocity(
            pos_vec, vel_vec, self.M, self.a.value, Q)
        self.initial_vec = np.hstack(
            (self.time.value, pos_vec, time_vel.value, vel_vec))
        self.scr = schwarzschild_radius(M)
def test_calculate_trajectory(pos_vec, vel_vec, time, M, start_lambda,
                              end_lambda, OdeMethodKwargs):
    cl = Schwarzschild.from_spherical(pos_vec, vel_vec, time, M)
    ans = cl.calculate_trajectory(
        start_lambda=start_lambda,
        end_lambda=end_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
    )
    _c, _scr = constant.c.value, schwarzschild_radius(M).value
    ans = ans[1]
    testarray = list()
    for i in ans:
        g = schwarzschild_utils.metric(_c, i[1], i[2], _scr)
        testarray.append(g[0][0] * (i[4]**2) + g[1][1] * (i[5]**2) + g[2][2] *
                         (i[6]**2) + g[3][3] * (i[7]**2))
    testarray = np.array(testarray, dtype=float)
    comparearray = np.ones(shape=ans[:, 4].shape, dtype=float)
    assert_allclose(testarray, comparearray, 1e-4)
示例#12
0
def test_calculate_trajectory(
    pos_vec, vel_vec, time, M, start_lambda, end_lambda, OdeMethodKwargs
):
    cl = Schwarzschild.from_spherical(pos_vec, vel_vec, time, M)
    ans = cl.calculate_trajectory(
        start_lambda=start_lambda,
        end_lambda=end_lambda,
        OdeMethodKwargs=OdeMethodKwargs,
    )
    _c, _scr = constant.c.value, schwarzschild_radius(M).value
    ans = ans[1]
    testarray = (
        (1 - (_scr / ans[:, 1])) * np.square(ans[:, 4])
        - (np.square(ans[:, 5])) / ((1 - (_scr / ans[:, 1])) * (_c ** 2))
        - np.square(ans[:, 1] / _c)
        * (np.square(ans[:, 6]) + np.square(np.sin(ans[:, 2])) * np.square(ans[:, 7]))
    )
    comparearray = np.ones(shape=ans[:, 4].shape, dtype=float)
    assert_allclose(testarray, comparearray, 1e-4)
示例#13
0
def test_scaled_spin_factor():
    a = 0.8
    M = 5e24 * u.kg
    a1 = kerr_utils.scaled_spin_factor(a, M.value)
    a2 = utils.schwarzschild_radius(M).value * a * 0.5
    assert_allclose(a2, a1, rtol=1e-9)
get_ipython().system('ls')

# In[ ]:

# In[ ]:

import numpy as np
import astropy.units as u
import matplotlib.pyplot as plt
from einsteinpy.utils import kerr_utils, schwarzschild_radius
from einsteinpy.utils import bl_coord_transforms

# In[ ]:

M = 4e30
scr = schwarzschild_radius(M * u.kg).value
# for nearly maximally rotating black hole
a1 = 0.499999 * scr
# for ordinary black hole
a2 = 0.3 * scr

# In[ ]:

ergo1, ergo2, hori1, hori2 = list(), list(), list(), list()
thetas = np.linspace(0, np.pi, 720)
for t in thetas:
    ergo1.append(kerr_utils.radius_ergosphere(M, a1, t, "Spherical"))
    ergo2.append(kerr_utils.radius_ergosphere(M, a2, t, "Spherical"))
    hori1.append(kerr_utils.event_horizon(M, a1, t, "Spherical"))
    hori2.append(kerr_utils.event_horizon(M, a2, t, "Spherical"))
ergo1, ergo2, hori1, hori2 = np.array(ergo1), np.array(ergo2), np.array(
示例#15
0
 def _draw_attractor(self, min_radius=10 * u.km):
     radius = max(schwarzschild_radius(self.mass) * 10000, min_radius.to(u.km))
     color = "#ffcc00"
     self.ax.add_patch(mpl.patches.Circle((0, 0), radius.value, lw=0, color=color))
示例#16
0
'''
REF : https://docs.einsteinpy.org/en/stable/
'''

import numpy as np
import sympy
from astropy import units as u
import matplotlib.pyplot as plt
from einsteinpy.utils import kerr_utils, schwarzschild_radius
'''
Variables
'''
M = 4e30
scr = schwarzschild_radius(M * u.kg).value  # calculates radius based on M

# for a near maximally rotating BH
a1 = 0.499999 * scr

# for an ordinary BH
a2 = 0.3 * scr
'''
Calculating Ergosphere and Event Horizon (spherical coords)
'''
ergo1, ergo2, hori1, hori2 = list(), list(), list(), list()
thetas = np.linspace(0, np.pi, 720)

for angle in thetas:
    ergo1.append(kerr_utils.radius_ergosphere(M, a1, angle, "Spherical"))
    ergo2.append(kerr_utils.radius_ergosphere(M, a2, angle, "Spherical"))
    hori1.append(kerr_utils.event_horizon(M, a1, angle, "Spherical"))
    hori2.append(kerr_utils.event_horizon(M, a2, angle, "Spherical"))