Ejemplo n.º 1
0
    def calculate_trajectory_iterator(
        self,
        start_lambda=0.0,
        stop_on_singularity=True,
        OdeMethodKwargs={"stepsize": 1e-3},
        return_cartesian=False,
    ):
        """
        Calculate trajectory in manifold according to geodesic equation.
        Yields an iterator.

        Parameters
        ----------
        start_lambda : float
            Starting lambda, defaults to 0.0, (lambda ~= t)
        stop_on_singularity : bool
            Whether to stop further computation on reaching singularity, defaults to True
        OdeMethodKwargs : dict
            Kwargs to be supplied to the ODESolver, defaults to {'stepsize': 1e-3}
            Dictionary with key 'stepsize' along with an float value is expected.
        return_cartesian : bool
            True if coordinates and velocities are required in cartesian coordinates(SI units), defaults to Falsed

        Yields
        ------
        float
            proper time
        ~numpy.ndarray
            array of [t, x1, x2, x3, velocity_of_time, v1, v2, v3] for each proper time(lambda).

        """
        ODE = RK45(
            fun=self.f_vec,
            t0=start_lambda,
            y0=self.initial_vec,
            t_bound=1e300,
            **OdeMethodKwargs
        )
        crossed_event_horizon = False
        _event_hor = (
            kerrnewman_utils.event_horizon(self.M.value, self.a.value, self.Q.value)[0]
            * 1.001
        )

        while True:
            if not return_cartesian:
                yield ODE.t, ODE.y
            else:
                v = ODE.y
                si_vals = BoyerLindquistConversion(
                    v[1], v[2], v[3], v[5], v[6], v[7], self.a.value
                ).convert_cartesian()
                yield ODE.t, np.hstack((v[0], si_vals[:3], v[4], si_vals[3:]))
            ODE.step()
            if (not crossed_event_horizon) and (ODE.y[1] <= _event_hor):
                warnings.warn("particle reached event horizon. ", RuntimeWarning)
                if stop_on_singularity:
                    break
                else:
                    crossed_event_horizon = True
Ejemplo n.º 2
0
def strip_velocities(coords):
    if isinstance(coords, BoyerLindquistConversion):
        vals = coords.values()
        return BoyerLindquistConversion(*vals[:3], a=vals[-1])
    elif isinstance(coords, (CartesianConversion, SphericalConversion)):
        vals = coords.values()
        return type(coords)(*vals[:3])
    return None
Ejemplo n.º 3
0
def bl_coords():
    return BoyerLindquistConversion(t=0.,
                                    r=10.,
                                    theta=np.pi / 2,
                                    phi=np.pi / 4,
                                    v_r=10.,
                                    v_th=-20.,
                                    v_p=20.)
Ejemplo n.º 4
0
    def calculate_trajectory(
        self,
        start_lambda=0.0,
        end_lambda=10.0,
        stop_on_singularity=True,
        OdeMethodKwargs={"stepsize": 1e-3},
        return_cartesian=False,
    ):
        """
        Calculate trajectory in manifold according to geodesic equation

        Parameters
        ----------
        start_lambda : float
            Starting lambda(proper time), defaults to 0, (lambda ~= t)
        end_lamdba : float
            Lambda(proper time) where iteartions will stop, defaults to 100000
        stop_on_singularity : bool
            Whether to stop further computation on reaching singularity, defaults to True
        OdeMethodKwargs : dict
            Kwargs to be supplied to the ODESolver, defaults to {'stepsize': 1e-3}
            Dictionary with key 'stepsize' along with an float value is expected.
        return_cartesian : bool
            True if coordinates and velocities are required in cartesian coordinates(SI units), defaults to False

        Returns
        -------
        ~numpy.ndarray
            N-element array containing proper time.
        ~numpy.ndarray
            (n,8) shape array of [t, x1, x2, x3, velocity_of_time, v1, v2, v3] for each proper time(lambda).

        """
        vecs = list()
        lambdas = list()
        crossed_event_horizon = False
        ODE = RK45(fun=self.f_vec,
                   t0=start_lambda,
                   y0=self.initial_vec,
                   t_bound=end_lambda,
                   **OdeMethodKwargs)

        _event_hor = kerr_utils.event_horizon(self.M.value,
                                              self.a.value)[0] * 1.001

        while ODE.t < end_lambda:
            vecs.append(ODE.y)
            lambdas.append(ODE.t)
            ODE.step()
            if (not crossed_event_horizon) and (ODE.y[1] <= _event_hor):
                warnings.warn("particle reached event horizon. ",
                              RuntimeWarning)
                if stop_on_singularity:
                    break
                else:
                    crossed_event_horizon = True

        vecs, lambdas = np.array(vecs), np.array(lambdas)

        if not return_cartesian:
            return lambdas, vecs
        else:
            cart_vecs = list()
            for v in vecs:
                si_vals = BoyerLindquistConversion(
                    v[1], v[2], v[3], v[5], v[6], v[7],
                    self.a.value).convert_cartesian()
                cart_vecs.append(
                    np.hstack((v[0], si_vals[:3], v[4], si_vals[3:])))
            return lambdas, np.array(cart_vecs)
Ejemplo n.º 5
0
def bl_coords():
    return BoyerLindquistConversion(
        10.0, 1.5707963267948966, 0.7853981633974483, 10.0, -20.0, 20.0, 0.0
    )
Ejemplo n.º 6
0
                warnings.warn("particle reached Schwarzchild Radius. ", RuntimeWarning)
>>>>>>> 0e311bec1be2508a28ebd8a3f8b7b944db997269
                if stop_on_singularity:
                    break
                else:
                    crossed_event_horizon = True

        vecs, lambdas = np.array(vecs), np.array(lambdas)

        if not return_cartesian:
            return lambdas, vecs
        else:
            cart_vecs = list()
            for v in vecs:
                si_vals = BoyerLindquistConversion(
                    v[1], v[2], v[3], v[5], v[6], v[7], self.a.value
                ).convert_cartesian()
                cart_vecs.append(np.hstack((v[0], si_vals[:3], v[4], si_vals[3:])))
            return lambdas, np.array(cart_vecs)

    def calculate_trajectory_iterator(
        self,
        start_lambda=0.0,
        stop_on_singularity=True,
        OdeMethodKwargs={"stepsize": 1e-3},
        return_cartesian=False,
    ):
        """
        Calculate trajectory in manifold according to geodesic equation.
        Yields an iterator.
Ejemplo n.º 7
0
def strip_velocities(coords):
    if isinstance(coords, BoyerLindquistConversion):
        vals = coords.values()
        return BoyerLindquistConversion(*vals[:3], a=vals[-1])
    vals = coords.values()
    return type(coords)(*vals[:3])