Skip to content

Frame dragging around a spinning mass

A particle without angular momentum that falls into a spinning mass.

  • Class: KerrFrameDraggingSystem
  • Import: from skcomplex.systems.physics.celestial_mechanics import KerrFrameDraggingSystem
  • Field: physics/celestial_mechanics
  • Topics: general relativity, ode, second order, gravity, geodesics, frame dragging
  • References:
    • Schwichtenberg 2020
    • Kerr 1963
    • Bardeen, Press, and Teukolsky 1972

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.physics.celestial_mechanics import KerrFrameDraggingSystem

trajectory = KerrFrameDraggingSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
radius 10.0
mass 1.0
spin 0.9
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time continuous
Space curved spacetime
Laws rate
Randomness deterministic
Domains vector
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class KerrFrameDraggingSystem(BaseSystem):
    """A particle without angular momentum that falls into a spinning mass.

    The mass drags the particle around it.

    The particle follows a timelike geodesic of the Kerr spacetime `KerrSpace` in the equatorial plane, in units with `G
    = c = 1`, with its proper time as the time of the system. It starts at rest in the radius at `r₀`, with zero angular
    momentum `L = g_tφ dt/dτ + g_φφ dφ/dτ = 0`. A particle without angular momentum around a static mass falls straight
    in, but the spin drags the frames around it: the particle turns with the angular velocity `dφ/dt = -g_tφ / g_φφ = 2
    M a / (r³ + a² r + 2 M a²)` of the frames at its radius, faster as it falls. The system has the position `particle.x
    = (t, r, theta, phi)` and the four-velocity `particle.x'`.

    Args:
        radius:
            The initial radius `r₀`.

        mass:
            The mass `M` of the central body.

        spin:
            The spin parameter `a`, between `-M` and `M`.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Raises:
        ValidationError:
            The particle starts inside the ergosphere, at a radius of at most `2 M`.

    Examples:
        >>> from skcomplex.systems.physics.celestial_mechanics import KerrFrameDraggingSystem
        >>> round(KerrFrameDraggingSystem().prepare().system_.elements[0].values["x'"][3], 5)
        0.00199
    """

    field = 'physics/celestial_mechanics'
    topics = ('general relativity', 'ode', 'second order', 'gravity', 'geodesics', 'frame dragging')
    references = ('Schwichtenberg 2020', 'Kerr 1963', 'Bardeen, Press, and Teukolsky 1972')
    until = 33.0
    dt = 0.1

    def __init__(
        self,
        radius: float = 10.0,
        *,
        mass: float = 1.0,
        spin: float = 0.9,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.radius = radius
        self.mass = mass
        self.spin = spin

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of a particle without angular momentum that falls into a spinning mass.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        if self.radius <= 2 * self.mass:
            error_msg = (
                f'The radius {self.radius} is inside the ergosphere at 2 M = {2 * self.mass}. Give a larger radius.'
            )
            raise ValidationError(error_msg)
        space = KerrSpace(mass=self.mass, spin=self.spin)
        g_tt = -(1 - 2 * self.mass / self.radius)
        g_tphi = -2 * self.mass * self.spin / self.radius
        g_phiphi = self.radius**2 + self.spin**2 + 2 * self.mass * self.spin**2 / self.radius
        omega = -g_tphi / g_phiphi
        rate = 1 / math.sqrt(-(g_tt + 2 * g_tphi * omega + g_phiphi * omega**2))
        particle = GeodesicParticleElement(
            'particle',
            x=[0.0, self.radius, EQUATOR, 0.0],
            values={"x'": [rate, 0.0, 0.0, omega * rate]},
        )
        geodesic = GeodesicInteraction('geodesic', target='particle', space=space)
        self.system_ = System(
            self.label,
            elements=[particle],
            interactions=[geodesic],
            space=space,
            solver=GEODESIC_SOLVER,
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

  • GeodesicParticleElement, from Element

Interactions:

  • GeodesicInteraction, from Interaction
class GeodesicParticleElement(Element):
    """Test particle at the spacetime position `x = (t, r, theta, phi)` near a mass.

    The mass is central, and the particle has its four-velocity.

    The position is a vector in the Schwarzschild or Boyer-Lindquist coordinates of the space, and its derivative `x'`
    is the four-velocity, the derivative of the position by the proper time of a massive particle or by the affine
    parameter of a light ray. The particle is drawn in the equatorial plane, at `(r cos phi, r sin phi)`.

    Args:
        label:
            The label of the particle.

        x:
            The initial position `(t, r, theta, phi)`.

        values:
            Further values by name, such as the initial four-velocity `x'`, or `None`.

    Examples:
        >>> from skcomplex.systems.physics.celestial_mechanics import GeodesicParticleElement
        >>> GeodesicParticleElement('particle', x=[0.0, 10.0, 1.5708, 0.0]).x
        [0.0, 10.0, 1.5708, 0.0]
    """

    visual = VisualSpec(
        'bodies',
        {
            'positions': _get_equatorial_position,
            'trail': None,
            'marks': _get_central_mass,
        },
    )

    def __init__(
        self,
        label: str,
        x: npt.ArrayLike = (0.0, 0.0, 0.0, 0.0),
        *,
        values: Mapping[str, object] | None = None,
    ) -> None:
        super().__init__(label, values=values)
        self.x = x

class GeodesicInteraction(Interaction):
    """Geodesic equation `x''^mu = -Γ^mu_(alpha beta)(x) x'^alpha x'^beta` of a point.

    The point is a point of a pseudo-Riemannian space. The state is a vector with one component per coordinate of
    the space, the position `x^mu` of a test particle, whose derivative `x'^mu` is the tangent. The
    time of the system is the affine parameter of the geodesic, the proper time of a timelike geodesic when the tangent
    starts with `g_(mu nu) x'^mu x'^nu = -1`. A tangent that starts null, with `g_(mu nu) x'^mu x'^nu = 0`, follows a
    light ray. Either norm is conserved along the geodesic, so it measures the error of a run. The Christoffel symbols
    are those the space derives from its metric.

    Args:
        label:
            The label of the interaction, unique among the components of its system.

        target:
            The path of the element or group whose state is the position.

        state:
            The name of the vector state that is the position.

        space:
            The pseudo-Riemannian space whose geodesics the point follows, usually the space of the system too.

    Attributes:
        space_:
            The prepared space, whose Christoffel symbols the rate reads.

    Raises:
        ValidationError:
            The state is not a name.

        SpaceError:
            The space is not a pseudo-Riemannian space, raised by `prepare`.

    Examples:
        >>> from sage.all__sagemath_symbolics import SR, matrix
        >>> from skcomplex.core.components.elements import Element
        >>> from skcomplex.core.systems import System
        >>> from skcomplex.systems.physics.common.relativity import GeodesicInteraction
        >>> from skcomplex.systems.physics.common.relativity import SpacetimeSpace
        >>> r, phi = SR.var('r phi')
        >>> plane = SpacetimeSpace(matrix(SR, [[1, 0], [0, r**2]]), (r, phi))
        >>> line = GeodesicInteraction('line', target='particle', space=plane)
        >>> particle = Element('particle', values={'x': [1.0, 0.0], "x'": [0.0, 1.0]})
        >>> system = System(elements=[particle], interactions=[line], space=plane).prepare()
        >>> trajectory = system.simulate(until=1.0, dt=0.001)
        >>> [round(float(value), 3) for value in trajectory.get_values('particle.x')[-1]]
        [1.414, 0.785]
    """

    law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (RateLaw,)

    def __init__(
        self,
        label: str,
        *,
        target: Role,
        state: str = 'x',
        space: SpacetimeSpace | None = None,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.state = state
        self.space = space

    def _check_arguments(self) -> None:
        """Raise an error for an argument the interaction cannot take.

        Raises:
            SpaceError:
                The space is not a pseudo-Riemannian space.
            ValidationError:
                The type declares states, the state is not a name, or the position has not one component per
                coordinate of the space.
        """
        super()._check_arguments()
        if not isinstance(self.state, str) or not self.state.isidentifier():
            error_msg = (
                f'{type(self).__name__} {self.label!r} moves the state {self.state!r}. Give the name of a state.'
            )
            raise ValidationError(error_msg)
        if not isinstance(self.space, SpacetimeSpace):
            error_msg = (
                f'{type(self).__name__} {self.label!r} moves a point along the geodesics of {self.space!r}. Give a '
                '`SpacetimeSpace`.'
            )
            raise SpaceError(error_msg)
        self.space_ = self.space.prepare()

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set `space_`, the prepared pseudo-Riemannian space, and the law of a binding.

        It first raises an error for a state that is not a name.

        Args:
            context:
                The namespace of the target and the time `t`.
        """
        super()._prepare(context)
        self.laws_ = self._get_geodesic_laws(context)

    def _get_geodesic_laws(self, context: SimpleNamespace) -> list[BaseLaw]:
        """Return the rate law of the second derivative of the position.

        It is minus the connection on the tangent.

        Args:
            context:
                The namespace of the target and the time `t`.

        Returns:
            laws:
                The rate law of the position.

        Raises:
            ValidationError:
                The position has not one component per coordinate of the space.
        """
        t = context.t
        position = getattr(context.target, self.state)
        components = list(position) if isinstance(position, FreeModuleElement) else [position]
        coordinates = self.space_.coordinates_
        if len(components) != len(coordinates):
            error_msg = (
                f'The position {self.state!r} of {self.label!r} has {len(components)} components for the '
                f'{len(coordinates)} coordinates of the space. Give a vector state of the dimension of the space.'
            )
            raise ValidationError(error_msg)
        at = dict(zip(coordinates, components, strict=True))
        tangent = [SR(component).diff(t) for component in components]
        indices = range(len(components))
        rate = [
            -sum(
                (
                    SR(self.space_.christoffel_[mu][alpha][beta]).subs(at) * tangent[alpha] * tangent[beta]
                    for alpha in indices
                    for beta in indices
                    if not SR(self.space_.christoffel_[mu][alpha][beta]).is_zero()
                ),
                SR(0),
            )
            for mu in indices
        ]
        if isinstance(position, FreeModuleElement):
            return [RateLaw(position.diff(t, 2), vector(SR, rate))]
        return [RateLaw(SR(position).diff(t, 2), rate[0])]