@essrt/physics 22.1.0 → 23.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +2 -1
  2. package/package.json +9 -3
  3. package/src/constants/coefficients.d.ts +11 -11
  4. package/src/constants/coefficients.js +4 -4
  5. package/src/constants/generated.d.ts +4 -16
  6. package/src/constants/generated.js +8 -32
  7. package/src/constants/units.cjs +20 -0
  8. package/src/deltat/deep-time-chain.js +457 -0
  9. package/src/deltat/deep-time.cjs +68 -25
  10. package/src/deltat/moon-distance-artifact.cjs +23 -0
  11. package/src/deltat/moon-distance-history.cjs +115 -0
  12. package/src/earth/deep-orbital-history.cjs +69 -19
  13. package/src/earth/mass-chain.cjs +95 -0
  14. package/src/earth/mean-obliquity-history.cjs +94 -0
  15. package/src/earth/precession-composed.cjs +49 -3
  16. package/src/index.js +23 -1
  17. package/src/layer0/derive-params.js +1 -5
  18. package/src/layer0/index.js +30 -17
  19. package/src/math/angles.cjs +38 -0
  20. package/src/model.js +100 -266
  21. package/src/moon/arguments.cjs +5 -31
  22. package/src/moon/month-chain.cjs +12 -19
  23. package/src/planets/chain-artifact.js +2 -2
  24. package/src/time/calendar.cjs +165 -0
  25. package/types/constants/coefficients.d.ts +11 -11
  26. package/types/constants/generated.d.ts +4 -16
  27. package/types/constants/units.d.cts +8 -0
  28. package/types/deltat/deep-time-chain.d.ts +266 -0
  29. package/types/deltat/deep-time.d.cts +42 -12
  30. package/types/deltat/moon-distance-artifact.d.cts +22 -0
  31. package/types/deltat/moon-distance-history.d.cts +36 -0
  32. package/types/earth/deep-orbital-history.d.cts +5 -3
  33. package/types/earth/mass-chain.d.cts +78 -0
  34. package/types/earth/mean-obliquity-history.d.cts +32 -0
  35. package/types/earth/precession-composed.d.cts +11 -1
  36. package/types/index.d.ts +8 -1
  37. package/types/layer0/derive-params.d.ts +3 -2
  38. package/types/layer0/index.d.ts +9 -6
  39. package/types/math/angles.d.cts +18 -0
  40. package/types/model.d.ts +21 -3
  41. package/types/moon/arguments.d.cts +2 -6
  42. package/types/moon/month-chain.d.cts +7 -13
  43. package/types/time/calendar.d.cts +78 -0
  44. package/src/deltat/recession-history.cjs +0 -169
  45. package/types/deltat/recession-history.d.cts +0 -80
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The mass chain in §9 order: Δa (the Sun's tidal coupling to the Earth–Moon
3
+ * barycentric wobble, leading order), the corrected Moon distance, Kepler on
4
+ * the Moon's orbit → G(M_E + M_M), the DE440 split → GM_E and GM_M, Kepler on
5
+ * Earth's orbit → G(M_☉ + M_E), the subtraction → GM_☉ and M_☉.
6
+ * @param {{
7
+ * moonDistanceKm: number, moonSiderealMonthDays: number, meanSiderealYearDays: number,
8
+ * meanLengthOfDaySeconds: number, massRatioEarthMoon: number, currentAUDistanceKm: number,
9
+ * gravitationalConstantKm3KgS2: number,
10
+ * }} c
11
+ * @returns {{
12
+ * meanSiderealYearSeconds: number, moonOrbitalShiftKm: number, moonDistanceCorrectedKm: number,
13
+ * gmEarthMoonSystemKm3S2: number, gmEarthAloneKm3S2: number, gmMoonAloneKm3S2: number,
14
+ * gmSunPlusEarthKm3S2: number, gmSunKm3S2: number, sunMassKg: number,
15
+ * }}
16
+ */
17
+ export function computeMassChainJ2000(c: {
18
+ moonDistanceKm: number;
19
+ moonSiderealMonthDays: number;
20
+ meanSiderealYearDays: number;
21
+ meanLengthOfDaySeconds: number;
22
+ massRatioEarthMoon: number;
23
+ currentAUDistanceKm: number;
24
+ gravitationalConstantKm3KgS2: number;
25
+ }): {
26
+ meanSiderealYearSeconds: number;
27
+ moonOrbitalShiftKm: number;
28
+ moonDistanceCorrectedKm: number;
29
+ gmEarthMoonSystemKm3S2: number;
30
+ gmEarthAloneKm3S2: number;
31
+ gmMoonAloneKm3S2: number;
32
+ gmSunPlusEarthKm3S2: number;
33
+ gmSunKm3S2: number;
34
+ sunMassKg: number;
35
+ };
36
+ /**
37
+ * The Moon's J2000 periods on the IAU inputs. The two precession inputs are
38
+ * equinox-OF-DATE observables (3231.50 d / 6798.38 d; the legacy "ICRF" name
39
+ * is kept); the star-referenced periods remove the equinox's own precession,
40
+ * 1/T_E = 1/T_I ∓ 1/T_p (the perigee advances, the node regresses), T_p the
41
+ * J2000 precession anchor in days. The months follow kinematically.
42
+ * @param {{
43
+ * moonSiderealMonthDays: number, moonApsidalPrecessionDaysInput: number, moonNodalPrecessionDaysInput: number,
44
+ * axialPrecessionJ2000Days: number, meanSiderealYearDays: number, meanSolarYearDays: number,
45
+ * }} c
46
+ * @returns {{
47
+ * moonApsidalPrecessionDaysEarth: number, moonNodalPrecessionDaysEarth: number,
48
+ * moonApsidalJ2000Seconds: number, moonNodalJ2000Seconds: number, moonSiderealMonthJ2000Seconds: number,
49
+ * moonAnomalisticMonthDays: number, moonNodalMonthDays: number, moonSynodicMonthDays: number, moonTropicalMonthDays: number,
50
+ * moonFullMoonCycleEarthDays: number, moonFullMoonCycleICRFDays: number,
51
+ * moonApsidalMeetsNodalDays: number, moonLunarLevelingCycleDays: number,
52
+ * moonDraconicYearICRFDays: number, moonDraconicYearEarthDays: number,
53
+ * }}
54
+ */
55
+ export function computeMoonPeriodsJ2000(c: {
56
+ moonSiderealMonthDays: number;
57
+ moonApsidalPrecessionDaysInput: number;
58
+ moonNodalPrecessionDaysInput: number;
59
+ axialPrecessionJ2000Days: number;
60
+ meanSiderealYearDays: number;
61
+ meanSolarYearDays: number;
62
+ }): {
63
+ moonApsidalPrecessionDaysEarth: number;
64
+ moonNodalPrecessionDaysEarth: number;
65
+ moonApsidalJ2000Seconds: number;
66
+ moonNodalJ2000Seconds: number;
67
+ moonSiderealMonthJ2000Seconds: number;
68
+ moonAnomalisticMonthDays: number;
69
+ moonNodalMonthDays: number;
70
+ moonSynodicMonthDays: number;
71
+ moonTropicalMonthDays: number;
72
+ moonFullMoonCycleEarthDays: number;
73
+ moonFullMoonCycleICRFDays: number;
74
+ moonApsidalMeetsNodalDays: number;
75
+ moonLunarLevelingCycleDays: number;
76
+ moonDraconicYearICRFDays: number;
77
+ moonDraconicYearEarthDays: number;
78
+ };
@@ -0,0 +1,32 @@
1
+ export type MeanObliquityTable = {
2
+ /**
3
+ * - ascending, 0 first, uniform 1-Myr step
4
+ */
5
+ ageMa: ReadonlyArray<number>;
6
+ /**
7
+ * - the cited mean obliquity column, degrees
8
+ */
9
+ obliquityDeg: ReadonlyArray<number>;
10
+ };
11
+ /**
12
+ * @typedef {Object} MeanObliquityTable
13
+ * @property {ReadonlyArray<number>} ageMa - ascending, 0 first, uniform 1-Myr step
14
+ * @property {ReadonlyArray<number>} obliquityDeg - the cited mean obliquity column, degrees
15
+ */
16
+ /**
17
+ * @param {{ table: MeanObliquityTable }} deps
18
+ * @returns {{
19
+ * meanObliquityDegAtAge: (tMa: number) => number|null,
20
+ * cosRatioAtAge: (tMa: number) => number|null,
21
+ * meanObliquityJ2000Deg: number,
22
+ * spanMa: number,
23
+ * }}
24
+ */
25
+ export function createMeanObliquityHistory(deps: {
26
+ table: MeanObliquityTable;
27
+ }): {
28
+ meanObliquityDegAtAge: (tMa: number) => number | null;
29
+ cosRatioAtAge: (tMa: number) => number | null;
30
+ meanObliquityJ2000Deg: number;
31
+ spanMa: number;
32
+ };
@@ -24,14 +24,20 @@ export function computeSolarTorqueShare(c: {
24
24
  * moonDistanceMetresAtAge: (tMa: number) => (number | null),
25
25
  * moonDistanceJ2000Metres: number,
26
26
  * yearToTMa: (year: number) => number,
27
+ * meanObliquityCosRatioAtAge?: (tMa: number) => (number | null),
27
28
  * }} deps - p0 = the model's derived J2000 rate, 1,296,000/axial0 (S5; a
28
29
  * number or a LAZY getter — the callers' certified year laws read the
29
30
  * deep-time factory this is built inside, so the anchor is resolved on
30
31
  * the first RATE use, never at construction; the torque term needs no
31
- * anchor); lodJ2000Seconds the SAME day basis lodSecondsAtAge(0) returns.
32
+ * anchor); lodJ2000Seconds the SAME day basis lodSecondsAtAge(0) returns;
33
+ * meanObliquityCosRatioAtAge the cited mean obliquity's cos ε̄(t)/cos ε̄(0)
34
+ * (OPTIONAL — absent, the rate of date is the constant alone, bit-identical).
32
35
  * @returns {{
33
36
  * composedRateArcsecPerYrAtAge: (tMa: number) => (number | null),
34
37
  * composedPeriodYearsAtAge: (tMa: number) => (number | null),
38
+ * torqueRateArcsecPerYrAtAge: (tMa: number) => (number | null),
39
+ * torquePeriodYearsAtAge: (tMa: number) => (number | null),
40
+ * obliquityFactorAtAge: (tMa: number) => (number | null),
35
41
  * composedRateArcsecPerYrAtYear: (year: number) => (number | null),
36
42
  * composedPeriodYearsAtYear: (year: number) => (number | null),
37
43
  * composedRateRatioAtAge: (tMa: number) => (number | null),
@@ -49,9 +55,13 @@ export function createComposedPrecession(deps: {
49
55
  moonDistanceMetresAtAge: (tMa: number) => (number | null);
50
56
  moonDistanceJ2000Metres: number;
51
57
  yearToTMa: (year: number) => number;
58
+ meanObliquityCosRatioAtAge?: (tMa: number) => (number | null);
52
59
  }): {
53
60
  composedRateArcsecPerYrAtAge: (tMa: number) => (number | null);
54
61
  composedPeriodYearsAtAge: (tMa: number) => (number | null);
62
+ torqueRateArcsecPerYrAtAge: (tMa: number) => (number | null);
63
+ torquePeriodYearsAtAge: (tMa: number) => (number | null);
64
+ obliquityFactorAtAge: (tMa: number) => (number | null);
55
65
  composedRateArcsecPerYrAtYear: (year: number) => (number | null);
56
66
  composedPeriodYearsAtYear: (year: number) => (number | null);
57
67
  composedRateRatioAtAge: (tMa: number) => (number | null);
package/types/index.d.ts CHANGED
@@ -14,10 +14,12 @@ export { createSecularSeriesOverride } from "./planets/secular-series.cjs";
14
14
  export { createDeepEccChannel } from "./moon/deep-ecc-channel.cjs";
15
15
  export { createDeepOrbitalHistory } from "./earth/deep-orbital-history.cjs";
16
16
  export { createSiderealYearChannel } from "./earth/sidereal-year-channel.cjs";
17
+ export { createMeanObliquityHistory } from "./earth/mean-obliquity-history.cjs";
17
18
  export { createPlanetModel } from "./planets/model.cjs";
18
19
  export { PLANET_DISPLAY_NAMES } from "./planets/display-names.cjs";
19
20
  export { createDeltaTCycles } from "./deltat/cycles.cjs";
20
21
  export { createDeepTimeLod } from "./deltat/deep-time.cjs";
22
+ export { createMoonDistanceHistory } from "./deltat/moon-distance-history.cjs";
21
23
  export { deltaTEspenakMeeusCanonSeconds } from "./deltat/historical.cjs";
22
24
  export { createEclipseFinders } from "./eclipse/finders.cjs";
23
25
  export function createModel(constants?: Constants, opts?: {
@@ -57,6 +59,11 @@ import { REFERENCE_DATA } from './constants/index.js';
57
59
  import { assembleModel } from './model.js';
58
60
  export { GENERATED as DEFAULT_CONSTANTS, CONSTANTS_HASH, MODEL_VERSION, PREPRINT_DOI, REFERENCE_DATA };
59
61
  export { FITTED_COEFFICIENTS, COEFFICIENTS_HASH } from "./constants/index.js";
62
+ export { GREGORIAN_START, GREGORIAN_START_JD, calendarToJD, jdToCalendar, jdToDecimalYear, dayFractionToHMS, julianCalendarToJD, jdToJulianCalendar } from "./time/calendar.cjs";
63
+ export { DEG2RAD, RAD2DEG, ARCSEC_PER_TURN, ARCSEC_PER_RAD, wrap360, wrap180, wrap180Closed, wrap2pi, wrapPi } from "./math/angles.cjs";
64
+ export { createDeepTimeChain, MOON_ECC_SENSITIVITY_PERIGEE, MOON_ECC_SENSITIVITY_NODE } from "./deltat/deep-time-chain.js";
65
+ export { computeMassChainJ2000, computeMoonPeriodsJ2000 } from "./earth/mass-chain.cjs";
66
+ export { SECONDS_PER_DAY, DAYS_PER_JULIAN_YEAR, JULIAN_CENTURY_DAYS, SECONDS_PER_JULIAN_YEAR } from "./constants/units.cjs";
60
67
  export { computeEarthFrameOfDate, solveWheelAngleForLongitude, computeSceneWorldFrameJ2000, SCENE_EQUINOX_VIEW_AZIMUTH_DEG } from "./earth/frame-of-date.cjs";
61
68
  export { derivePlanetGeometry, scaffoldOrbitInputs } from "./planets/geometry.cjs";
62
69
  export { buildPlanetChainsFromArtifactData, computePlanetElementsAtYear, computeHeliocentricEclipticFromElements, computePoissonArgRad, computeOsculatingElements, solveKeplerRad, computeApsidalSecularDegPerYr, ANCHOR_EPOCH_YEAR, ANCHOR_EPOCH_JD } from "./planets/keplerian-chain.cjs";
@@ -66,5 +73,5 @@ export { CHAIN_ARTIFACT, CHAIN_ARTIFACT_HASH } from "./planets/chain-artifact.js
66
73
  export { DEEP_MODES_ARTIFACT, DEEP_MODES_ARTIFACT_HASH } from "./moon/deep-modes-artifact.cjs";
67
74
  export { createYearLengths, computeMeanTropicalYearJ2000Days, ONE_FAMILY_WINDOW_YEARS } from "./earth/year-lengths.cjs";
68
75
  export { computeSolarTorqueShare, createComposedPrecession } from "./earth/precession-composed.cjs";
69
- export { createMoonRecessionHistory, createSolarChannelBudget } from "./deltat/recession-history.cjs";
76
+ export { MOON_DISTANCE_ARTIFACT, MOON_DISTANCE_ARTIFACT_HASH } from "./deltat/moon-distance-artifact.cjs";
70
77
  export { evalClimateL1OrbitalPermil, laggedL1Terms, createAlphaGiaChannel } from "./climate/l1-orbital.cjs";
@@ -12,9 +12,10 @@ export type RawEpochConstants = {
12
12
  * km/s (fallback 299792458 m/s if falsy)
13
13
  */
14
14
  speedOfLightKmPerS: number;
15
+ /**
16
+ * the LLR recession rate — the cited distance history's J2000 slope
17
+ */
15
18
  alpha1PerMa: number;
16
- alpha3PerMa3: number;
17
- alpha4PerMa4: number;
18
19
  meanSiderealYearSeconds: number;
19
20
  /**
20
21
  * ω₀: the J2000 day length, SI seconds (the SI day since plan 09)
@@ -1,6 +1,8 @@
1
- export function createEpochPrimitives({ params: p, alphaAtAgeMa }: {
1
+ export function createEpochPrimitives({ params: p, alphaAtAgeMa, moonDistanceMetresAtAge, meanObliquityCosRatioAtAge }: {
2
2
  params: EpochParams;
3
3
  alphaAtAgeMa: (tMa: number) => number;
4
+ moonDistanceMetresAtAge: (tMa: number) => number | null;
5
+ meanObliquityCosRatioAtAge?: (tMa: number) => number | null;
4
6
  }): EpochPrimitives;
5
7
  export type EpochParams = {
6
8
  /**
@@ -8,11 +10,9 @@ export type EpochParams = {
8
10
  */
9
11
  epochYear: number;
10
12
  /**
11
- * Moon recession, LLR-anchored
13
+ * Moon recession, LLR-anchored (the J2000 slope of the cited history)
12
14
  */
13
15
  alpha1PerMa: number;
14
- alpha3PerMa3: number;
15
- alpha4PerMa4: number;
16
16
  /**
17
17
  * a_Moon at J2000, metres
18
18
  */
@@ -47,11 +47,14 @@ export type EpochParams = {
47
47
  };
48
48
  export type EpochPrimitives = {
49
49
  tMa: (year: number) => number;
50
- moonDistanceMetres: (year: number) => number;
50
+ /**
51
+ * - null beyond the cited history's span
52
+ */
53
+ moonDistanceMetres: (year: number) => number | null;
51
54
  lodSeconds: (year: number) => number | null;
52
55
  siderealYearSeconds: (year: number) => number;
53
56
  /**
54
- * sidereal less one equinox turn per T_p(t) (the composed precession period)
57
+ * sidereal less one equinox turn per T_p(t) (the composed precession period on the RATE of date)
55
58
  */
56
59
  tropicalYearSeconds: (year: number) => number;
57
60
  };
@@ -0,0 +1,18 @@
1
+ /** π/180 — degrees to radians. */
2
+ export const DEG2RAD: number;
3
+ /** 180/π — radians to degrees. */
4
+ export const RAD2DEG: number;
5
+ /** Arcseconds in a full turn. */
6
+ export const ARCSEC_PER_TURN: 1296000;
7
+ /** Arcseconds per radian, 206264.806… */
8
+ export const ARCSEC_PER_RAD: number;
9
+ /** @param {number} x degrees @returns {number} the same angle in [0, 360) */
10
+ export function wrap360(x: number): number;
11
+ /** @param {number} x degrees @returns {number} the same angle in [−180, 180) */
12
+ export function wrap180(x: number): number;
13
+ /** @param {number} x degrees @returns {number} the same angle in (−180, 180] */
14
+ export function wrap180Closed(x: number): number;
15
+ /** @param {number} x radians @returns {number} the same angle in [0, 2π) */
16
+ export function wrap2pi(x: number): number;
17
+ /** @param {number} x radians @returns {number} the same angle in [−π, π) */
18
+ export function wrapPi(x: number): number;
package/types/model.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * RA-day-offset Fourier amplitudes (ms). KNOWN EXCEPTION carried over from
3
+ * the reference adapters: these are fit results that live as literals in the
4
+ * engine too — packaging them into FITTED_COEFFICIENTS is the remaining
5
+ * §7a-step-1b move; until then this is their single packaged home.
6
+ */
1
7
  /**
2
8
  * Assemble the model surfaces from a resolved constants context + fitted
3
9
  * coefficients. Internal: `createModel` in index.js composes this with the
@@ -41,7 +47,7 @@ export function assembleModel(C: Readonly<Record<string, any>>, F: Readonly<Reco
41
47
  lunarSmallParameter: number;
42
48
  moonMassFraction: number;
43
49
  solarTidalShiftKm: number;
44
- moonDistanceCorrectedKm: any;
50
+ moonDistanceCorrectedKm: number;
45
51
  gmEarthMoonSystemKm3S2: number;
46
52
  gmEarthKm3S2: number;
47
53
  gmMoonKm3S2: number;
@@ -69,10 +75,18 @@ export function assembleModel(C: Readonly<Record<string, any>>, F: Readonly<Reco
69
75
  tropicalYearSecondsAtYear: (year: number) => number;
70
76
  }>;
71
77
  lunisolar: Readonly<{
72
- /** The mean lunisolar precession period T_p(t), years — the composed torque rate's period on the derived J2000 anchor (25,771.4 at J2000). @param {number} year @returns {number} */
78
+ /** The mean lunisolar precession period T_p(t), years — 1,296,000/the precession RATE of date (25,771.6 at J2000): THE published deep-time clock. @param {number} year @returns {number} */
73
79
  meanPeriodYearsAtYear: (year: number) => number;
74
- /** The composed rate ψ̇(t) = [ω/ω₀]·p₀·[f_S + (1 − f_S)(a₀/a_M)³], ″/yr (p₀ = 50.2883, derived). @param {number} year @returns {number} */
80
+ /** THE PRECESSION RATE OF DATE ψ̇(t) = [ω/ω₀]·p₀·[f_S + (1 − f_S)(a₀/a_M)³] × cos ε̄(t)/cos ε̄(0), ″/yr — the constant's scaling on the spin and the lunar torque times the cited mean obliquity's cosine (plan 12 §8 option (a); p₀ = 50.2880, the IAU 2006 input). @param {number} year @returns {number} */
75
81
  meanRateArcsecPerYrAtYear: (year: number) => number;
82
+ /** THE PRECESSION CONSTANT OF DATE as a rate on the J2000 obliquity, ″/yr — the spin and torque scaling alone (the hybrid obliquity integration's integrand: its own ŝ·n̂ carries the cosine). @param {number} year @returns {number} */
83
+ torqueRateArcsecPerYrAtYear: (year: number) => number;
84
+ /** 1,296,000/the torque rate, years. @param {number} year @returns {number} */
85
+ torquePeriodYearsAtYear: (year: number) => number;
86
+ /** cos ε̄(t)/cos ε̄(0) — the rate of date's obliquity factor on the constant (1 at J2000; 1.0075 at the Devonian, 1.0245 at 2.46 Ga). @param {number} year @returns {number} */
87
+ precessionObliquityFactorAtYear: (year: number) => number;
88
+ /** THE CITED MEAN OBLIQUITY OF DATE ε̄(t), degrees — Farhat et al. 2022's own column of the Earth–Moon history (a Myr-scale MEAN: 23.25° at age 0 against the J2000 instant 23.44°; 22.23° Devonian, 19.73° at 2.46 Ga); read as the shape cos ε̄(t)/cos ε̄(0) on the precession rate. NaN beyond the input's span (4,429 Ma); forward of J2000 the J2000 slope is held. @param {number} year @returns {number} */
89
+ meanObliquityCitedDegAtYear: (year: number) => number;
76
90
  /** The of-date period — the one-family beat inside ±2 Myr, the composed mean beyond. @param {number} year @returns {number} */
77
91
  ofDatePeriodYearsAtYear: (year: number) => number;
78
92
  /** f_S, the solar fraction of the J2000 precession torque. */
@@ -142,6 +156,10 @@ export function assembleModel(C: Readonly<Record<string, any>>, F: Readonly<Reco
142
156
  earth: Readonly<{
143
157
  perihelionLongitudeDeg: (year: number) => number;
144
158
  obliquityDeg: (year: number) => number;
159
+ /** The hybrid's own domain, [yearFrom, yearTo] — the banked ζ series' span, ±10 Myr about J2000 (plan 12 §8.5: the published surfaces serve `obliquityDeg` inside it only; null without a series, i.e. a bare createModel()). */
160
+ obliquityHybridDomainYears: [number, number] | null;
161
+ /** The cited mean obliquity of date ε̄(t) (Farhat et al. 2022's column; plan 12 §8 option (a)), degrees — a Myr-scale mean; NaN beyond 4,429 Ma. @param {number} year @returns {number} */
162
+ meanObliquityCitedDeg: (year: number) => number;
145
163
  eccentricity: (year: number) => number;
146
164
  inclinationDeg: (year: number) => number;
147
165
  ascendingNodeDeg: (year: number) => number;
@@ -121,12 +121,7 @@ export function createMoonArguments({ constants, fns }: {
121
121
  };
122
122
  };
123
123
  };
124
- /**
125
- * Astronomical JD → decimal year: Julian calendar before 1582-10-15,
126
- * Gregorian after (Meeus Ch. 7 inverse). The S3-aligned coordinate for the
127
- * Sun secular deviations. @param {number} jd @returns {number}
128
- */
129
- export function jdToDecimalYear(jd: number): number;
124
+ import { jdToDecimalYear } from "../time/calendar.cjs";
130
125
  /**
131
126
  * @typedef {{Lp: number, D: number, M: number, Mp: number, F: number}} MoonArgsDeg
132
127
  */
@@ -137,3 +132,4 @@ export function jdToDecimalYear(jd: number): number;
137
132
  * 5c: it was written as the era unit's twelfth, H/12, "lattice-derived";
138
133
  * the value is kept bit-identical and named for what it is). */
139
134
  export const SECULAR_COMPLETION_TAPER_YEARS: 27943.083333333332;
135
+ export { jdToDecimalYear };
@@ -2,9 +2,6 @@
2
2
  * @param {{
3
3
  * constants: {
4
4
  * aMoonNowMetres: number,
5
- * alpha1PerMa: number,
6
- * alpha3PerMa3: number,
7
- * alpha4PerMa4: number,
8
5
  * gmEarthMoonM3PerS2: number,
9
6
  * massRatioEarthMoon: number,
10
7
  * moonSiderealMonthInputDays: number,
@@ -20,7 +17,7 @@
20
17
  * meanSiderealYearSecondsAtAge: (tMa: number) => number,
21
18
  * precessionPeriodYearsAtAge: (tMa: number) => (number | null),
22
19
  * modulation: (tMa: number, s: number) => number,
23
- * distanceMetresAtAge?: (tMa: number) => number,
20
+ * distanceMetresAtAge: (tMa: number) => number|null,
24
21
  * },
25
22
  * }} deps — fns are the ENGINE'S OWN layer-0/1 evaluators and the shared
26
23
  * eccentricity channel's modulation; constants are the engine's derived
@@ -30,16 +27,13 @@
30
27
  * 5c — the tropical month's equinox turn, formerly the counter's 13/H(t),
31
28
  * 0.086 % slow: the chain's J2000 tropical month sat 5.85 ms above the IAU
32
29
  * input, the 1/T_p form is within 0.1 ms of it).
33
- * fns.distanceMetresAtAge, when present, OVERRIDES the internal quartic —
34
- * the Driver-1½ regime-aware history (recession-history.cjs); absent, the
35
- * internal quartic is the pure twin (bit-identical for t ≤ jointMa).
30
+ * fns.distanceMetresAtAge is the engine's CITED distance history
31
+ * (deltat/moon-distance-history; plan 12 option A — the internal quartic
32
+ * twin this chain carried until then is deleted; null beyond the span).
36
33
  */
37
34
  export function createMoonMonthChain({ constants, fns }: {
38
35
  constants: {
39
36
  aMoonNowMetres: number;
40
- alpha1PerMa: number;
41
- alpha3PerMa3: number;
42
- alpha4PerMa4: number;
43
37
  gmEarthMoonM3PerS2: number;
44
38
  massRatioEarthMoon: number;
45
39
  moonSiderealMonthInputDays: number;
@@ -55,11 +49,11 @@ export function createMoonMonthChain({ constants, fns }: {
55
49
  meanSiderealYearSecondsAtAge: (tMa: number) => number;
56
50
  precessionPeriodYearsAtAge: (tMa: number) => (number | null);
57
51
  modulation: (tMa: number, s: number) => number;
58
- distanceMetresAtAge?: (tMa: number) => number;
52
+ distanceMetresAtAge: (tMa: number) => number | null;
59
53
  };
60
54
  }): {
61
- distanceMetresAtAge: (tMa: number) => number;
62
- distanceKmAtAge: (tMa: number) => number;
55
+ distanceMetresAtAge: (tMa: number) => number | null;
56
+ distanceKmAtAge: (tMa: number) => number | null;
63
57
  solarDeltaAKmAtAge: (tMa: number, aApparentKm: number) => number | null;
64
58
  distanceCorrectedKmAtAge: (tMa: number) => number | null;
65
59
  siderealMonthSecondsAtAge: (tMa: number) => number | null;
@@ -0,0 +1,78 @@
1
+ /** The first Gregorian calendar day, as a calendar date. */
2
+ export const GREGORIAN_START: Readonly<{
3
+ year: 1582;
4
+ month: 10;
5
+ day: 15;
6
+ }>;
7
+ /** The first Gregorian calendar day, as a JD (00:00 UT). */
8
+ export const GREGORIAN_START_JD: 2299160.5;
9
+ /**
10
+ * Calendar date → Julian Day (Meeus 7.1). The calendar is decided by the
11
+ * date itself: Julian before 1582-10-15, Gregorian from it on.
12
+ * @param {number} year astronomical year (0 = 1 BC)
13
+ * @param {number} month 1–12
14
+ * @param {number} day 1–31, may carry a fraction
15
+ * @param {number} [dayFraction=0] added to the day (e.g. hour/24)
16
+ * @returns {number} JD
17
+ */
18
+ export function calendarToJD(year: number, month: number, day: number, dayFraction?: number): number;
19
+ /**
20
+ * Julian Day → calendar date (Meeus ch. 7 inverse). Gregorian for
21
+ * JD ≥ 2299160.5, Julian before.
22
+ * @param {number} jd
23
+ * @returns {{year: number, month: number, day: number, dayFrac: number, calendar: 'Julian'|'Gregorian'}}
24
+ * day the integer day of month, dayFrac in [0, 1) the fraction since 00:00
25
+ */
26
+ export function jdToCalendar(jd: number): {
27
+ year: number;
28
+ month: number;
29
+ day: number;
30
+ dayFrac: number;
31
+ calendar: "Julian" | "Gregorian";
32
+ };
33
+ /**
34
+ * Julian Day → decimal year: the year plus the elapsed fraction of that
35
+ * calendar year (Julian or Gregorian leap rule as the date's calendar has
36
+ * it). Jan 1 00:00 → year exactly. The S3-aligned coordinate of the Sun's
37
+ * secular deviations and the browser's `julianDateToDecimalYear`.
38
+ * @param {number} jd
39
+ * @returns {number}
40
+ */
41
+ export function jdToDecimalYear(jd: number): number;
42
+ /**
43
+ * The day fraction as hours, minutes and whole seconds (floored, as the
44
+ * browser's date strings always did).
45
+ * @param {number} dayFrac in [0, 1)
46
+ * @returns {{hour: number, minute: number, second: number}}
47
+ */
48
+ export function dayFractionToHMS(dayFrac: number): {
49
+ hour: number;
50
+ minute: number;
51
+ second: number;
52
+ };
53
+ /**
54
+ * Proleptic JULIAN calendar date → Julian Day, no reform: the convention the
55
+ * NASA eclipse canons and the Babylonian/Greek record tables use for every
56
+ * pre-1582 date, and the browser's eclipse diagnostics apply to their whole
57
+ * table (so a post-reform Gregorian date in such a table — 1654 Aug 12 —
58
+ * lands ten days late; the tables name the convention). Same expression
59
+ * order as the copies it replaces.
60
+ * @param {number} year astronomical year (0 = 1 BC)
61
+ * @param {number} month 1–12
62
+ * @param {number} day 1–31
63
+ * @param {number} [dayFraction=0] added to the day (e.g. hour/24)
64
+ * @returns {number} JD
65
+ */
66
+ export function julianCalendarToJD(year: number, month: number, day: number, dayFraction?: number): number;
67
+ /**
68
+ * Julian Day → proleptic JULIAN calendar date, no reform (the inverse of
69
+ * `julianCalendarToJD`; the NASA-convention diagnostics' printer).
70
+ * @param {number} jd
71
+ * @returns {{year: number, month: number, day: number, dayFrac: number}}
72
+ */
73
+ export function jdToJulianCalendar(jd: number): {
74
+ year: number;
75
+ month: number;
76
+ day: number;
77
+ dayFrac: number;
78
+ };
@@ -1,169 +0,0 @@
1
- /**
2
- * Regime-aware lunar recession history + the solar angular-momentum
3
- * channels (Driver 1½) — THE shared implementation.
4
- *
5
- * Background (docs/99 §"The ungated mid-Precambrian window", docs/106 §D,
6
- * and the research record in tools/explore/{farhat-divergence-probe,
7
- * fit-regime-recession}.js — the hand-shaped regime-aware-recession-study.js
8
- * was deleted at plan 09 step 7e): Farhat 2022's
9
- * central result is that lunar recession followed a resonant STAIRCASE —
10
- * a single smooth quartic anchored at the modern LLR rate, the gated
11
- * 0–650 Ma era and the Roche crossing cannot follow it through the
12
- * 1–3.5 Ga window (−8.9σ Joffre, −11.4σ Moodies). This module carries
13
- * the regime-aware history:
14
- *
15
- * t ≤ jointMa — the calibrated quartic, BIT-IDENTICAL (the
16
- * Wells/Wu-gated era; its α set is the calibrated
17
- * effective closed-budget pair and is not touched).
18
- * jointMa..genesisMa — monotone cubic Hermite (Fritsch–Carlson) through
19
- * the fitted knots, value- AND slope-continuous at
20
- * the joint (analytic polynomial derivative), ending
21
- * at the rigid Roche limit at genesisMa.
22
- * t ≥ genesisMa — clamped at the Roche value (the Moon does not
23
- * exist beyond its genesis; boundary value, not an
24
- * extrapolation).
25
- *
26
- * The solar channels (explicit ONLY beyond jointMa — inside the gated era
27
- * they are absorbed by the α calibration, and applying them there without
28
- * recalibration measurably breaks Wells; see the study's variant 3):
29
- * leak τ_s = β₀ (a/a₀)⁶ · τ_moon — ocean solar tide (M²/AU⁶ ratio
30
- * scaling of the semidiurnal torque)
31
- * pump τ_t = f_p · (τ_moon + τ_s) inside [pumpStartMa, pumpEndMa] —
32
- * the insolation-driven atmospheric thermal tide
33
- * (Zahnle–Walker 1987; Bartlett–Stevenson 2016;
34
- * Mitchell–Kirscher 2023). The FITTED f_p ≈ 0.45 over a ~300 Myr
35
- * window (degenerate with 0.15 × 900 Myr — the data constrain
36
- * the INTEGRATED pump, ~2σ preferred over zero, Zhou 2024's
37
- * contrary reading honestly noted in the fit record).
38
- *
39
- * Fit provenance: tools/explore/fit-regime-recession.js — 11 anchors
40
- * (Lantink/Joffre 2022 · Weeli Wolli · Zhou 2024 ×3 paired a+LOD ·
41
- * Meyers–Malinverno 2018 · Nanfen 2023 · Moodies), all ≤1.3σ; genesis
42
- * pinned at the shipped 4498 Ma Roche crossing (the genesis profile is
43
- * flat — the data do not constrain it). The knot values ARE the shipped
44
- * definition (metre-rounded at fit time, not truncated from a more
45
- * precise source).
46
- */
47
-
48
- 'use strict';
49
-
50
- /**
51
- * @typedef {Object} RecessionRegime
52
- * @property {number} jointMa - regime boundary; quartic below, spline above
53
- * @property {number[]} knotAgesMa - interior knot ages (ascending)
54
- * @property {number[]} knotDistancesKm - fitted knot distances
55
- * @property {number} genesisMa - the Roche-crossing epoch
56
- * @property {number} rocheLimitKm - the rigid Roche endpoint
57
- */
58
-
59
- /**
60
- * @param {{
61
- * aMoonNowMetres: number,
62
- * alpha1PerMa: number, alpha3PerMa3: number, alpha4PerMa4: number,
63
- * regime: RecessionRegime,
64
- * }} deps
65
- * @returns {{ distanceMetresAtAge: (tMa: number) => number }}
66
- */
67
- function createMoonRecessionHistory(deps) {
68
- const { aMoonNowMetres: aNow, alpha1PerMa: a1, alpha3PerMa3: a3, alpha4PerMa4: a4 } = deps;
69
- const R = deps.regime;
70
-
71
- /** The calibrated quartic (identical expression to every consumer).
72
- * @param {number} tMa @returns {number} */
73
- const polyM = (tMa) => aNow * (1 + a1 * tMa + a3 * tMa * tMa * tMa + a4 * tMa * tMa * tMa * tMa);
74
- /** Analytic slope of the quartic, m/Ma.
75
- * @param {number} tMa @returns {number} */
76
- const polySlopeM = (tMa) => aNow * (a1 + 3 * a3 * tMa * tMa + 4 * a4 * tMa * tMa * tMa);
77
-
78
- // Knot chain: joint (value+slope from the quartic) → fitted knots → Roche.
79
- const ts = [R.jointMa, ...R.knotAgesMa, R.genesisMa];
80
- const vs = [polyM(R.jointMa), ...R.knotDistancesKm.map((km) => km * 1000), R.rocheLimitKm * 1000];
81
- const n = ts.length;
82
- const d = [];
83
- for (let i = 0; i < n - 1; i++) d.push((vs[i + 1] - vs[i]) / (ts[i + 1] - ts[i]));
84
- const m = new Array(n);
85
- m[0] = polySlopeM(R.jointMa);
86
- for (let i = 1; i < n - 1; i++) m[i] = (d[i - 1] * d[i] <= 0) ? 0 : (d[i - 1] + d[i]) / 2;
87
- m[n - 1] = d[n - 2];
88
- // Fritsch–Carlson monotonicity limiter — the history must be monotone
89
- // into the past (the Moon only recedes on the mean).
90
- for (let i = 0; i < n - 1; i++) {
91
- if (d[i] === 0) { m[i] = 0; m[i + 1] = 0; continue; }
92
- const a = m[i] / d[i], b = m[i + 1] / d[i];
93
- const s = a * a + b * b;
94
- if (s > 9) { const tau = 3 / Math.sqrt(s); m[i] = tau * a * d[i]; m[i + 1] = tau * b * d[i]; }
95
- }
96
-
97
- /** @param {number} tMa @returns {number} metres */
98
- function distanceMetresAtAge(tMa) {
99
- if (tMa <= R.jointMa) return polyM(tMa);
100
- if (tMa >= R.genesisMa) return R.rocheLimitKm * 1000;
101
- let i = 0;
102
- while (i < n - 2 && tMa > ts[i + 1]) i++;
103
- const h = ts[i + 1] - ts[i], s = (tMa - ts[i]) / h, s2 = s * s, s3 = s2 * s;
104
- return (2 * s3 - 3 * s2 + 1) * vs[i] + (s3 - 2 * s2 + s) * h * m[i]
105
- + (-2 * s3 + 3 * s2) * vs[i + 1] + (s3 - s2) * h * m[i + 1];
106
- }
107
-
108
- return { distanceMetresAtAge };
109
- }
110
-
111
- /**
112
- * The solar angular-momentum channels: L_EM(t) integrated backward from
113
- * J2000 with the ocean leak and the thermal-tide pump, explicit only
114
- * beyond jointMa. Absent this module, every consumer's L_EM is the J2000
115
- * constant — which remains the exact behaviour for t ≤ jointMa.
116
- *
117
- * @param {{
118
- * lTotalJ2000KgM2S: number,
119
- * mMoonAloneKg: number, gmEmM3PerS2: number, eFactorMoon: number,
120
- * beta0: number,
121
- * pumpStartMa: number, pumpEndMa: number, pumpFactor: number,
122
- * jointMa: number, genesisMa: number,
123
- * distanceMetresAtAge: (tMa: number) => number,
124
- * stepMa?: number,
125
- * }} deps
126
- * @returns {{ lEmAtAgeKgm2S: (tMa: number) => number }}
127
- */
128
- function createSolarChannelBudget(deps) {
129
- const STEP = deps.stepMa ?? 5;
130
- /** @param {number} aM @returns {number} */
131
- const lOrb = (aM) => deps.mMoonAloneKg * Math.sqrt(deps.gmEmM3PerS2 * aM) * deps.eFactorMoon;
132
- const a0 = deps.distanceMetresAtAge(0);
133
-
134
- /** @type {Float64Array|null} */
135
- let table = null;
136
- const build = () => {
137
- const nSteps = Math.ceil(deps.genesisMa / STEP) + 1;
138
- const t = new Float64Array(nSteps);
139
- let L = deps.lTotalJ2000KgM2S;
140
- for (let i = 0; i < nSteps; i++) {
141
- t[i] = L;
142
- const tMa = i * STEP;
143
- const dLorb = lOrb(deps.distanceMetresAtAge(tMa)) - lOrb(deps.distanceMetresAtAge(tMa + STEP));
144
- const mid = tMa + STEP / 2;
145
- const leakDt = mid > deps.jointMa ? deps.beta0 * Math.pow(deps.distanceMetresAtAge(tMa) / a0, 6) * dLorb : 0;
146
- const pumpDt = (mid > deps.pumpStartMa && mid < deps.pumpEndMa) ? deps.pumpFactor * (dLorb + leakDt) : 0;
147
- L = L - (pumpDt - leakDt);
148
- }
149
- return t;
150
- };
151
-
152
- /** @param {number} tMa @returns {number} */
153
- function lEmAtAgeKgm2S(tMa) {
154
- // The channels are zero below jointMa by construction — return the
155
- // constant EXACTLY there (no table interpolation), so the gated era
156
- // stays bit-identical to the closed-budget engine (the 1-ULP fixture
157
- // gates depend on this).
158
- if (tMa <= deps.jointMa) return deps.lTotalJ2000KgM2S;
159
- if (table === null) table = build();
160
- const x = tMa / STEP;
161
- const i = Math.min(Math.floor(x), table.length - 2);
162
- const f = Math.min(x - i, 1);
163
- return table[i] * (1 - f) + table[i + 1] * f;
164
- }
165
-
166
- return { lEmAtAgeKgm2S };
167
- }
168
-
169
- module.exports = { createMoonRecessionHistory, createSolarChannelBudget };