Propagate exoplanets with their real orbital period
Every exoplanet was propagated with gmForParent(undefined) — the Sun's gravitational parameter — so the whole catalogue orbited as though each host were exactly one solar mass. Most hosts are red dwarfs far lighter than that, and a heavier central mass pulls harder and shortens the period, so their planets were whirling round much too fast: TRAPPIST-1 is 0.09 solar masses, and its planets were completing an orbit in roughly a third of the true time. pl_orbper was already in the TAP query and was being discarded on the way into the record. It is now kept, along with st_mass. A period and a semi-major axis together pin the host's gravitational parameter exactly, via GM = n^2 a^3 — no stellar model, no assumption, just the inverse of the orbitalPeriodDays helper that was already there. resolveGravitationalParameter picks the best available source: the measured period, else the published host mass, else one solar mass as before. A derived value implying something outside 0.01-150 solar masses is rejected and falls through, since a period and axis taken from disagreeing solutions would otherwise send a planet spinning at a visibly absurd rate. Note the direction of the error, which is the opposite of what it looks like: assuming a *heavier* host than reality makes a planet orbit *faster*. A test pins it, and caught me stating it backwards first. The NASA Exoplanet Archive is unreachable from this environment (egress policy returns 403 on CONNECT), so exoplanets.json cannot be regenerated here and still carries no periods. Behaviour is therefore unchanged until `npm run etl` is run somewhere with archive access, at which point every planet with a published period starts moving correctly with no further code changes. build.ts reports how many records gained a period, and rejects non-positive ones. Tests: 171 passing, up from 151, including a new end-to-end check that TRAPPIST-1 b with its real period completes exactly one orbit in 1.51088 days and sits a full diameter away at half that. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WaySiNst4HhDXBHnMy8p5G
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { CartesianCoordinates } from './coordinates';
|
||||
import { DEFAULT_EPOCH_JD } from './constants';
|
||||
import { DEFAULT_EPOCH_JD, GM_SUN_AU3_PER_DAY2 } from './constants';
|
||||
import { OrbitalElements } from '../models/body.model';
|
||||
|
||||
const DEG_TO_RAD = Math.PI / 180;
|
||||
@@ -34,6 +34,72 @@ export function orbitalPeriodDays(semiMajorAxisAu: number, gmAu3PerDay2: number)
|
||||
return TWO_PI / meanMotionRadPerDay(semiMajorAxisAu, gmAu3PerDay2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gravitational parameter implied by a measured orbital period — the inverse of
|
||||
* {@link orbitalPeriodDays}: `GM = n^2 * a^3`, with `n = 2*pi / T`.
|
||||
*
|
||||
* This is how an exoplanet's host star gets its mass into the propagator. Nothing about the
|
||||
* star needs to be known or guessed: the period and the semi-major axis between them pin the
|
||||
* gravitational parameter exactly.
|
||||
*/
|
||||
export function gravitationalParameterFromPeriod(semiMajorAxisAu: number, periodDays: number): number {
|
||||
const meanMotion = TWO_PI / periodDays;
|
||||
return meanMotion * meanMotion * semiMajorAxisAu * semiMajorAxisAu * semiMajorAxisAu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plausible range for a host star's mass, in solar masses — from below the hydrogen-burning
|
||||
* limit to beyond the heaviest known stars. Used only to reject a derived value that cannot be
|
||||
* a star, which would otherwise send a planet spinning at a visibly absurd rate.
|
||||
*/
|
||||
const MIN_PLAUSIBLE_STELLAR_MASS_SOLAR = 0.01;
|
||||
const MAX_PLAUSIBLE_STELLAR_MASS_SOLAR = 150;
|
||||
|
||||
function isPositiveFinite(value: number | undefined): value is number {
|
||||
return value !== undefined && Number.isFinite(value) && value > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The gravitational parameter to propagate a planet with, in AU^3/day^2, best source first:
|
||||
*
|
||||
* 1. **Its measured orbital period.** Exact, and independent of any stellar model.
|
||||
* 2. **Its host star's measured mass.**
|
||||
* 3. **One solar mass**, as a last resort.
|
||||
*
|
||||
* Falling back to the Sun is a real approximation, not a neutral default. Most exoplanet hosts
|
||||
* are red dwarfs far lighter than the Sun, and a heavier central mass pulls harder and shortens
|
||||
* the period, so assuming solar mass makes their planets whirl round far too fast. TRAPPIST-1
|
||||
* is 0.09 solar masses; its planets were completing an orbit in roughly a third of the true
|
||||
* time.
|
||||
*/
|
||||
export function resolveGravitationalParameter(input: {
|
||||
semiMajorAxisAu: number;
|
||||
periodDays?: number;
|
||||
hostStarMassSolar?: number;
|
||||
}): number {
|
||||
const { semiMajorAxisAu, periodDays, hostStarMassSolar } = input;
|
||||
|
||||
if (isPositiveFinite(periodDays) && isPositiveFinite(semiMajorAxisAu)) {
|
||||
const derived = gravitationalParameterFromPeriod(semiMajorAxisAu, periodDays);
|
||||
const impliedMassSolar = derived / GM_SUN_AU3_PER_DAY2;
|
||||
// A period and axis drawn from disagreeing solutions can imply something that is not a
|
||||
// star; prefer a known-approximate answer over a confidently wrong one.
|
||||
if (impliedMassSolar >= MIN_PLAUSIBLE_STELLAR_MASS_SOLAR && impliedMassSolar <= MAX_PLAUSIBLE_STELLAR_MASS_SOLAR) {
|
||||
return derived;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
isPositiveFinite(hostStarMassSolar) &&
|
||||
hostStarMassSolar >= MIN_PLAUSIBLE_STELLAR_MASS_SOLAR &&
|
||||
hostStarMassSolar <= MAX_PLAUSIBLE_STELLAR_MASS_SOLAR
|
||||
) {
|
||||
return GM_SUN_AU3_PER_DAY2 * hostStarMassSolar;
|
||||
}
|
||||
|
||||
return GM_SUN_AU3_PER_DAY2;
|
||||
}
|
||||
|
||||
/** Normalizes an angle (radians) into [0, 2*pi). */
|
||||
function normalizeAngle(angleRad: number): number {
|
||||
const wrapped = angleRad % TWO_PI;
|
||||
|
||||
Reference in New Issue
Block a user