Keplerian dumbbell and spin-orbit coupling
The Keplerian dumbbell.
- Class:
KeplerianDumbbellSystem - Import:
from skcomplex.systems.physics.celestial_mechanics import KeplerianDumbbellSystem - Field:
physics/celestial_mechanics - Topics:
mechanics,ode,second order,gravity,spin-orbit coupling,lagrangian - References:
- Dilão and Murteira 2020
- Dilão 2023
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 KeplerianDumbbellSystem
trajectory = KeplerianDumbbellSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
u |
1.0 |
vu |
0.0 |
theta |
0.0 |
omega |
1.0 |
phi |
0.0 |
spin |
3.0 |
v |
0.0 |
vv |
0.0 |
psi |
1.5707963267948966 |
vpsi |
0.0 |
delta |
0.5 |
epsilon |
0.1 |
mu |
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 | none |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class KeplerianDumbbellSystem(BaseSystem):
"""The Keplerian dumbbell.
Two masses on a rigid massless arm orbit a primary under gravity.
The centre of mass of the dumbbell at the cylindrical coordinates `(u, theta, v)` about the primary and the arm at
the spherical angles `(phi, psi)` move under the dimensionless Lagrangian `L = (u'² + u² theta'² + v'²) / 2 + I
(psi'² + sin² psi phi'²) / 2 + (1 - delta) / rho12 + delta / rho13`, with the moment of inertia `I = delta (1 -
delta) epsilon² / mu` of the arm. The distances of the two masses from the primary are `rho12² = u² + v² + delta²
epsilon² + 2 delta epsilon P` and `rho13² = u² + v² + (1 - delta)² epsilon² - 2 (1 - delta) epsilon P`, with `P = u
sin psi cos(theta - phi) + v cos psi`. Its Euler-Lagrange equations are the equations of motion of Dilão and
Murteira. The gravity gradient across the arm couples the spin to the orbit, the simplest spin-orbit coupling of a
rigid body. For `epsilon = 0` the orbit is a Kepler orbit, of period `2π` at `u = 1`. The energy and the angular
momentum about the normal to the orbital plane are conserved. By default the arm spins three times faster than it
orbits, in the orbital plane, and its spin and orbit exchange angular momentum. The system has the coordinates
`dumbbell.u`, `dumbbell.theta`, `dumbbell.v`, `dumbbell.phi`, and `dumbbell.psi`, their velocities named with a
prime, and the observables `dumbbell.energy` and `dumbbell.angular_momentum`.
Args:
u:
The initial distance of the centre of mass from the axis through the primary.
vu:
The initial radial velocity.
theta:
The initial orbital angle.
omega:
The initial orbital angular velocity.
phi:
The initial azimuth of the arm.
spin:
The initial spin of the arm about the normal to the orbital plane.
v:
The initial height above the orbital plane.
vv:
The initial vertical velocity.
psi:
The initial polar angle of the arm, `pi / 2` in the orbital plane.
vpsi:
The initial rate of the polar angle of the arm.
delta:
The share of the second mass in the mass of the dumbbell, `1 / 2` for equal masses.
epsilon:
The length of the arm in units of the mean orbit radius.
mu:
The share of the primary in the mass of the three bodies.
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.
Examples:
>>> from skcomplex.systems.physics.celestial_mechanics import KeplerianDumbbellSystem
>>> KeplerianDumbbellSystem(epsilon=0.2).prepare().system_.elements[0].epsilon
0.2
"""
field = 'physics/celestial_mechanics'
topics = ('mechanics', 'ode', 'second order', 'gravity', 'spin-orbit coupling', 'lagrangian')
references = ('Dilão and Murteira 2020', 'Dilão 2023')
until = 60.0
dt = 0.05
invariants: ClassVar[Mapping[str, float]] = {'dumbbell.energy': 1e-6, 'dumbbell.angular_momentum': 1e-6}
observables = (
Observable('energy', _get_dumbbell_energy, element='dumbbell'),
Observable('angular_momentum', _get_dumbbell_momentum, element='dumbbell'),
)
def __init__(
self,
u: float = 1.0,
vu: float = 0.0,
theta: float = 0.0,
omega: float = 1.0,
*,
phi: float = 0.0,
spin: float = 3.0,
v: float = 0.0,
vv: float = 0.0,
psi: float = 1.5707963267948966,
vpsi: float = 0.0,
delta: float = 0.5,
epsilon: float = 0.1,
mu: float = 0.9,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.u = u
self.vu = vu
self.theta = theta
self.omega = omega
self.phi = phi
self.spin = spin
self.v = v
self.vv = vv
self.psi = psi
self.vpsi = vpsi
self.delta = delta
self.epsilon = epsilon
self.mu = mu
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of two masses on a rigid arm that orbit a primary.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
dumbbell = DumbbellElement(
'dumbbell',
u=self.u,
theta=self.theta,
v=self.v,
phi=self.phi,
psi=self.psi,
delta=self.delta,
epsilon=self.epsilon,
mu=self.mu,
values={"u'": self.vu, "theta'": self.omega, "v'": self.vv, "phi'": self.spin, "psi'": self.vpsi},
)
motion = DumbbellMotionInteraction('motion', target='dumbbell')
solver = ScipyODESolver(method='DOP853', rtol=1e-10, atol=1e-12)
self.system_ = System(self.label, elements=[dumbbell], interactions=[motion], solver=solver)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
DumbbellElement, fromElement
Interactions:
DumbbellMotionInteraction, fromInteraction
class DumbbellElement(Element):
"""Rigid dumbbell orbiting a primary.
The element holds the position of its centre of mass and the orientation of its arm.
The cylindrical coordinates `(u, theta, v)` place the centre of mass of the dumbbell relative to the primary, and
the spherical angles `(phi, psi)` give the direction of its arm, of length `epsilon` in units of the mean orbit
radius. The mass `1 - delta` of the dumbbell sits at `delta epsilon` along the arm and the mass `delta` at
`1 - delta` against it. The five coordinates are those `DumbbellMotionInteraction` moves, and their velocities are
the derivatives `u'`, `theta'`, `v'`, `phi'`, and `psi'`.
Args:
label:
The label of the dumbbell.
u:
The initial distance from the axis through the primary.
theta:
The initial orbital angle.
v:
The initial height above the orbital plane.
phi:
The initial azimuth of the arm.
psi:
The initial polar angle of the arm, `pi / 2` in the orbital plane.
delta:
The share of the second mass in the mass of the dumbbell, `1 / 2` for equal masses.
epsilon:
The length of the arm in units of the mean orbit radius.
mu:
The share of the primary in the mass of the three bodies.
values:
Further values by name, such as an initial velocity named with a prime, or `None`.
Examples:
>>> from skcomplex.systems.physics.celestial_mechanics import DumbbellElement
>>> DumbbellElement('dumbbell').delta
0.5
"""
def __init__(
self,
label: str,
*,
u: float = 1.0,
theta: float = 0.0,
v: float = 0.0,
phi: float = 0.0,
psi: float = math.pi / 2,
delta: Annotated[float, RealSet.open(0, 1)] = 0.5,
epsilon: Annotated[float, RealSet.closed_open(0, oo)] = 0.1,
mu: Annotated[float, RealSet.open(0, 1)] = 0.9,
values: Mapping[str, object] | None = None,
) -> None:
super().__init__(label, values=values)
self.u = u
self.theta = theta
self.v = v
self.phi = phi
self.psi = psi
self.delta = delta
self.epsilon = epsilon
self.mu = mu
class DumbbellMotionInteraction(LagrangianInteraction):
"""Motion of a rigid dumbbell around a primary.
The motion is the Euler-Lagrange equations of the Lagrangian of its orbit and its spin.
The Lagrangian is `L = (u'² + u² theta'² + v'²) / 2 + I (psi'² + sin² psi phi'²) / 2 + (1 - delta) / rho12 + delta /
rho13`, with the moment of inertia `I = delta (1 - delta) epsilon² / mu` of the arm and the distances `rho12` and
`rho13` of the two masses from the primary, all read from the target.
Args:
label:
The label of the interaction.
target:
The path of the dumbbell.
Examples:
>>> from skcomplex.systems.physics.celestial_mechanics import DumbbellMotionInteraction
>>> DumbbellMotionInteraction('motion', target='dumbbell').target
'dumbbell'
"""
def __init__(self, label: str, *, target: Role) -> None:
super().__init__(label)
self.target = target
def _get_coordinates(self, context: SimpleNamespace) -> list[Expression]:
"""Return the coordinates `(u, theta, v, phi, psi)` of the dumbbell."""
return [getattr(context.target, name) for name in COORDINATES]
def _get_lagrangian(
self,
context: SimpleNamespace,
positions: list[Expression],
velocities: list[Expression],
) -> Expression:
"""Return the Lagrangian of the orbit and the spin of the dumbbell.
Args:
context:
The namespace of the dumbbell, the time `t`, and the parameters.
positions:
The symbols of the coordinates.
velocities:
The symbols of the velocities.
Returns:
lagrangian:
The Lagrangian.
"""
target = context.target
d = SimpleNamespace(
**dict(zip(COORDINATES, positions, strict=True)),
delta=target.delta,
epsilon=target.epsilon,
mu=target.mu,
)
rates = SimpleNamespace(**dict(zip(COORDINATES, velocities, strict=True)))
kinetic, potential = _get_dumbbell_parts(d, rates)
return kinetic - potential
Equations
The equations are those that symbolic returns for the system with its default parameters.
dumbbell.u: diff(u_dumbbell(t), t, t) == u_dumbbell(t)*diff(theta_dumbbell(t), t)^2 + (delta_dumbbell*epsilon_dumbbell*cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t)) + u_dumbbell(t))*(delta_dumbbell - 1)/(delta_dumbbell^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*delta_dumbbell*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2) - ((delta_dumbbell - 1)*epsilon_dumbbell*cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t)) + u_dumbbell(t))*delta_dumbbell/((delta_dumbbell - 1)^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2)
dumbbell.theta: diff(theta_dumbbell(t), t, t) == ((delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell*sin(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t)/((delta_dumbbell - 1)^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2) - (delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell*sin(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t)/(delta_dumbbell^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*delta_dumbbell*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2) - 2*u_dumbbell(t)*diff(theta_dumbbell(t), t)*diff(u_dumbbell(t), t))/u_dumbbell(t)^2
dumbbell.v: diff(v_dumbbell(t), t, t) == (delta_dumbbell*epsilon_dumbbell*cos(psi_dumbbell(t)) + v_dumbbell(t))*(delta_dumbbell - 1)/(delta_dumbbell^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*delta_dumbbell*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2) - ((delta_dumbbell - 1)*epsilon_dumbbell*cos(psi_dumbbell(t)) + v_dumbbell(t))*delta_dumbbell/((delta_dumbbell - 1)^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2)
dumbbell.phi: diff(phi_dumbbell(t), t, t) == -(2*(delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell^2*cos(psi_dumbbell(t))*sin(psi_dumbbell(t))*diff(phi_dumbbell(t), t)*diff(psi_dumbbell(t), t)/mu_dumbbell - (delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell*sin(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t)/((delta_dumbbell - 1)^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2) + (delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell*sin(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t)/(delta_dumbbell^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*delta_dumbbell*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2))*mu_dumbbell/((delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell^2*sin(psi_dumbbell(t))^2)
dumbbell.psi: diff(psi_dumbbell(t), t, t) == ((delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell^2*cos(psi_dumbbell(t))*sin(psi_dumbbell(t))*diff(phi_dumbbell(t), t)^2/mu_dumbbell + (cos(-phi_dumbbell(t) + theta_dumbbell(t))*cos(psi_dumbbell(t))*u_dumbbell(t) - sin(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell/((delta_dumbbell - 1)^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2) - (cos(-phi_dumbbell(t) + theta_dumbbell(t))*cos(psi_dumbbell(t))*u_dumbbell(t) - sin(psi_dumbbell(t))*v_dumbbell(t))*(delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell/(delta_dumbbell^2*epsilon_dumbbell^2 + 2*(cos(-phi_dumbbell(t) + theta_dumbbell(t))*sin(psi_dumbbell(t))*u_dumbbell(t) + cos(psi_dumbbell(t))*v_dumbbell(t))*delta_dumbbell*epsilon_dumbbell + u_dumbbell(t)^2 + v_dumbbell(t)^2)^(3/2))*mu_dumbbell/((delta_dumbbell - 1)*delta_dumbbell*epsilon_dumbbell^2)