diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3baf87d..b5c33c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ concurrency: jobs: test: runs-on: ubuntu-latest + timeout-minutes: 20 strategy: matrix: node-version: [18, 20, 22] @@ -34,3 +35,4 @@ jobs: - run: node turbulence/table.mjs quick - run: node turbulence/edges.mjs quick - run: node turbulence/edges.mjs 256 + - run: node orbits/table.mjs quick diff --git a/README.md b/README.md index 6ac95ec..eb6f4de 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ with Claude (Anthropic), for [Foundation0](https://github.com/Foundation-0/f0). with gravity in place of electric attraction (the "gravitational atom"). It is still a wave cloud, not planets on orbits. The same equation, a wave held by a pull that weakens with distance, gives the same solution at any scale. The nesting lives in the equations, not the objects. +- **Solar systems are not little galaxies, except at the Milky Way's centre.** Around one dominant mass, orbits follow + Kepler's law at every radius. The planets match it to 0.13%, about what they weigh together against the Sun. Across + the Milky Way's disk the speed instead stays between 200 and 234 km/s, because the mass is spread out. A Kepler + region ends where its host's tide wins, at a density ratio rather than a size: 1.4 pc for the Sun in the Galaxy, + 0.36 au for Jupiter. In a three-body model a planet keeps moons, and the Sun comets, out to about half that + radius, though passing stars cut the Oort cloud shorter. The Milky Way has its own small solar system around its + central black hole, about 1.3 pc in radius ([orbits](orbits/)). - **Quantum paths are fractal, between two lengths.** A free particle's path, recorded by position measurements finer than ħ/p, has fractal dimension 2, against 1 for a classical trajectory (Abbott and Wise, 1981); below ħ/mc, in a single-particle model, the speed of light makes it smooth again. Its surroundings draw @@ -211,13 +218,15 @@ node witness-map/table.mjs # every object at a 250 nm gap, then th node witness-map/table.mjs 1e-6 cryo # 1 µm gap, everything in a 4 K vacuum node notes/bh-lensing.mjs # every number in the black hole note node critical/table.mjs # the critical-point study's numbers (about 65 s) +node orbits/table.mjs quick # the orbits study's numbers, without its stability scans ``` `witness-map/model.js` is the whole model, including `gravAtom` for the black hole note. It loads in Node (`require`) and in a browser (`window.WM`). `npm test` also checks `gravitational-atom/atom.js` (second study, below). The third study's checks, `tests/critical.mjs`, add about 65 s of seeded Monte Carlo runs, most of it percolation with nine seeds. CI runs every line above except the `critical/table.mjs` line: it repeats the tests' -seeded runs and prints the results without checking them. +seeded runs and prints the results without checking them. The orbits study's full table (`node orbits/table.mjs`, +about 11 minutes) is not run by CI either. ## Checks diff --git a/orbits/README.md b/orbits/README.md new file mode 100644 index 0000000..7ff4a84 --- /dev/null +++ b/orbits/README.md @@ -0,0 +1,330 @@ +# Orbits: is a galaxy a big solar system? + +Status: **exploration, not peer reviewed, no new result claimed.** Issue +[#36](https://github.com/Foundation-0/fractals/issues/36). + +The repository's README opens with "atoms look a little like solar systems, solar systems a little like galaxies". +The first half has a study, the Witness Map. This one takes the second half. A solar system and a spiral galaxy +are both flat, rotating disks, but they do not orbit alike. This study asks where each one's law of motion holds, +what ends it, and what, if anything, repeats from one scale to the next. + +## Short answer + +| Question | Answer | +|---|---| +| Is a galaxy a big solar system? | No. Around one dominant mass, orbital speed falls as Kepler's v ∝ r^−1/2. Across the Milky Way's disk the speed falls only from 234 to 200 km/s between 5 and 25 kpc. Read as spherical, the mass inside grows 3.7-fold over that range, where a Kepler system's would stay fixed. Both figures come from Eilers et al.'s (2019) fit. | +| How exact is Kepler's law in the Solar System? | In JPL's 1800–2050 fit, n²a³ matches GM☉ to within 1.3×10⁻³ for all eight planets. That is about the planets' total mass, 1.34×10⁻³ of the Sun's. Jupiter's excess is mostly its own mass in the two-body law; Uranus's and Neptune's are mostly the other planets' pull, and Saturn's fitted 2.2×10⁻⁴ is below its own 2.9×10⁻⁴ (see below). P ∝ a^1.49986 over 0.39 to 30 au. | +| Does the Galaxy have a Kepler region? | Yes, around Sgr A*. The star S2 orbits it as a planet orbits the Sun, plus general relativity's precession: 12.2′ per orbit from their elements (they quote 12.1′). The speed's log slope passes −1/4 about 1.3 pc out (1.0 to 1.8 pc across the cluster-mass range; 0.7 to 1.9 pc for thresholds from −0.4 to −0.1). The stars inside weigh as much as the black hole by 1.8 to 3.2 pc. | +| What ends a Kepler region? | For a body orbiting in a host (a planet, the Sun), the host's tide. Satellites are held inside its tidal radius, r_J³ = Gm/(4A(A − B)), apart from quasi-satellite orbits beyond about 2 r_H that Shen and Tremaine (2008) find around Jupiter, Uranus and Neptune. Inside r_J, the body's mean density is 4A/Ω times the host's mean density inside the orbit (host taken as spherical): 3 for a planet around the Sun, 2.25 for the Sun in the Galaxy. For the Sun, r_J = 1.37 pc = 2.8×10⁵ au. At the Galaxy's centre, where Sgr A* sits still, the region ends instead where the surrounding stars' mass approaches the black hole's. | +| How much of that region is used? | About half, for orbits that do not plunge, in this study's three-body runs. Of circular orbits facing every way, half have escaped by 0.52 r_J around a planet and by 0.436 r_J (1.23×10⁵ au) for the Sun. Polar orbits are lost much sooner, to Lidov–Kozai cycles: half are lost by 0.14 to 0.15 r_H around a planet (half or more out to 0.3 r_H; further out, to 0.45 r_H, between about a fifth and two-thirds) and by 0.06 r_J for the Sun, in 20 turns of the host. For near-circular moons near the ecliptic, Nesvorný et al. (2003) put the limits at about 0.4 and 0.7 r_H (prograde, retrograde), and the model gives 0.46 and 0.78. The Oort cloud's outer limit is placed between 6.5×10⁴ au (Correa-Otto and Calandra 2019, where the frequency of stellar passages, acting with the tide, sets it) and 2×10⁵ au, which is 0.23 to 0.71 r_J. | +| What does repeat? | Kepler regions nested inside one another: moons in a planet's, planets and comets in the Sun's. Each is bounded by its host's tide at a similar fraction of the tidal radius, though for the Oort cloud passing stars cut it shorter. Also flat disks: the planets' orbits are tilted by about 2° on average (6° for Mercury), and the Galaxy's thin disk has a scale height 0.04 of the Sun's orbital radius. | + +## Kepler's law in the Solar System + +Around one mass M, a circular orbit of radius r has speed √(GM/r), and P² = 4π²a³/G(M + m). Nothing in the law +sets a size, so it holds from the Sun's surface out to wherever another pull competes. + +JPL's approximate elements (Standish and Williams, Table 1, a fit to 1800–2050) give each planet's semi-major axis a +and its mean-longitude rate, n = L̇: +- This is the orbit's angular rate. For a near-circular orbit, n²a is the mean inward pull at a. That equals GM( 1 kpc), its log slope stays within ±0.15 of zero from 3.6 to 49 kpc. The r^−1.8 bulge is about as flat, from 7 to 180 pc, but that is a dense bulge, not a single mass. +- **The spherical reading.** Gauss's theorem gives the true mass inside a sphere (the disk by quadrature). v²R/G overstates it by 12% at 8 kpc: 9.00 against 8.00×10¹⁰ M☉. The true growth from 5 to 25 kpc is 4.03-fold rather than 3.65. +- **Γ.** Bovy (2017) warns that A and B cannot be read directly as the circular velocity and its slope, since his C and K are about a fifth of A. Γ = 2(1 − d ln v/d ln R) is 2.12 from Eilers et al.'s slope and 2.21 from MWPotential2014's, against 2.25 from A and B. r_J hardly moves: 1.366 pc from Eilers et al.'s curve. + +Going outward, the model's speed falls by less than Kepler's law would give: +- **The model.** The log slope is −0.21 at 100 kpc and −0.27 at 200 kpc, because the NFW halo's mass still grows. +- **The data.** Gaia DR3 analyses differ on whether the measured curve turns down past about 19 kpc. + - Jiao et al. (2023) report "a Keplerian decline". + - Koop et al. (2024) find Jeans-equation curves robust with their statistics only to about 15 kpc. In simulations they find such curves off by as much as 15%, but likely of order 10%. + +## An acceleration scale, and why this study does not use it + +In other galaxies the shift from Kepler-like to flat tracks an acceleration, not a radius. The observed and +baryonic accelerations follow one relation, which bends at g† = 1.20 ± 0.02 (random) ± 0.24 (systematic) × 10⁻¹⁰ +m s⁻² (McGaugh, Lelli and Schombert 2016). + +- **Where the Sun's pull reaches it.** At 7,030 au, inside its tidal radius. +- **The Galaxy's own pull at the Sun.** v²/R₀ = 2.1×10⁻¹⁰ m s⁻², or 1.7 g†. + +Wide binary stars at 2 to 30 thousand au test gravity at these accelerations, and the results disagree: +- **Chae (2023).** Finds observed over predicted acceleration of 1.43 ± 0.06 at g_N = 10^−10.15 m s⁻². +- **Banik et al. (2024).** Prefer the best Newtonian model over the best MOND one at 19σ; their fit to α_grav excludes MOND at 16σ. +- **Later analyses** still split. + +The study reports the scale and leaves the question to the Witness Map and issue #3. + +## What does repeat: thin disks + +The planets' orbits lie within a few degrees of the invariable plane, the plane perpendicular to the Solar System's +total angular momentum (Souami and Souchay 2012). Computed from JPL's elements, the inclinations are: +- Mercury 6.3°, Venus 2.2°, Earth–Moon 1.6°, Mars 1.7°; +- Jupiter 0.33°, Saturn 0.93°, Uranus 1.0°, Neptune 0.73°. + +The rms of sin i is 0.045, or 0.023 without Mercury. + +The Galaxy's thin disk has an exponential scale height of 300 ± 50 pc over a scale length of 2.6 ± 0.5 kpc +(Bland-Hawthorn and Gerhard 2016). Their ratio, 0.12, is the axis ratio of its density contours. Height over +orbital radius is 300 pc over the Sun's 8.2 kpc, 0.037, against the planets' rms sin i of 0.045: both a few percent. +The two measures differ by a factor of about 2 in convention. An exponential scale height h has rms z = √2 h, and an +orbit tilted by i has rms z/r = sin i/√2. Compared as rms height over radius, the thin disk is 0.052 and the planets +0.032. + +Both are flat for the same reason: gas that radiates its energy but keeps its angular momentum settles into a disk. +The Galaxy's present thickness is also set by the stars' later heating. What the disks orbit differs: one dominant +mass, or mass spread through the disk and halo. + +## Run it + +``` +node orbits/table.mjs # every computed number above except the 100-turn runs and the values credited to #37's review or re-review (about 11 minutes) +node orbits/table.mjs quick # sections 1-4 only, well under a second (run by CI) +node orbits/table.mjs long # adds the 100-turn runs, about 14 minutes in all +node tests/orbits.mjs # the checks, about 6 s (also run by npm test) +``` + +The table exits with an error if any printed value is not a finite number. + +## Checks + +`tests/orbits.mjs` has 43 checks. Each prints its source, the published or expected value, the model's value and +the tolerance. "#37's review" marks values a reviewer read in the paper's arXiv source; "#37's re-review" marks +what the second review checked or calculated, in an arXiv source or against Crossref, as each label says. + +| What | Against | Kind | +|---|---|---| +| In the 1800–2050 fit, n²a³/GM☉ − 1 below the planets' mass fraction for all eight, and below 5×10⁻⁵ for the inner four | JPL Table 1, IAU 2015, DE430 | published elements; an observed size, not a bound | +| Exponent 3/2, to the most the first check allows | the same | model-internal, independent of GM☉ | +| 4A/Ω = 3 from the model's own curve near Sgr A*; Jacobi radius = Hill radius for a point mass | the model | model-internal | +| The Sun's r_J = 2.8×10⁵ au | Correa-Otto and Calandra 2019 | #37's review; on Jiang and Tremaine's nearby constants | +| S2: Kepler mass, 12.1′ precession, 120 au, 7,700 km/s | GRAVITY 2020 | Table E.1, appendix B, sect. 1.2 | +| Stars weigh 2 M_BH at 3 to 4 pc; the cusp's mass inside 3 pc and 0.01 pc | Schödel et al. 2018; Alexander 2005; Feldmeier-Krause et al. 2017; GRAVITY 2024 | #37's review | +| Kepler slope −1/2 inside 0.1 pc; the −1/4 radius in closed form against bisection | — | model; model-internal | +| ellipticK(1/√2); gammaP(½, x) = erf √x at three points | closed forms | arithmetic | +| MWPotential2014: the 220 km/s normalisation; halo mass 0.8×10¹² inside 245 kpc; the disk's sphere mass tending to its total, and its Kuzmin and Plummer limits; shape within 5% of Eilers et al.; flat (abs. slope < 0.25) at 5 to 25 kpc | Bovy 2015 Table 1; closed forms; Eilers et al. 2019 | model-internal; #37's review; arithmetic | +| MWPotential2014's derived values: bulge mass 0.5 and disk mass 6.8×10¹⁰ M☉, v²R/G at 60 kpc 4.1×10¹¹ M☉, log slope −0.10 at 8 kpc, dark-matter density 0.008 M☉ pc⁻³ at 8 kpc | Bovy 2015 Table 1 | #37's re-review (arXiv source); at Table 1's rounding | +| Jupiter's and Saturn's tilts to the invariable plane | Souami and Souchay 2012 | search text, not confirmed in the paper | +| Planet: prograde mostly kept at 0.4 r_H and lost by 0.6; prograde edge 0.4 ± 0.1; retrograde edge between 0.7 and 1 r_H | Nesvorný et al. 2003 and Shen and Tremaine 2008, as Shen and Tremaine give them | model; #37's review | +| Retrograde in the plane at 0.85 r_J: mostly lost around a point mass, kept by the Sun | — | model | +| The Jacobi integral kept over 20 turns on an orbit that stays; the Galaxy's ν²/Ω² in SI | equations of motion; Poisson's equation | model-internal; arithmetic | +| The Sun's polar orbits at 0.3 r_J lost by plunging, not escape; a point mass's polar orbits lost between 0.1 and 0.2 r_H before any escapes | Lidov–Kozai | model | +| The Sun: none escape from 0.3 r_J, most by 0.6 | — | model | +| The Sun's all-directions edge within the Oort cloud's quoted 6.5×10⁴ to 2×10⁵ au | Correa-Otto and Calandra 2019; Dones et al. 2004 | #37's review; as cited | + +## What the model leaves out + +- **The planets' long-period pull on one another.** Kepler's law is checked only to the size of the planets' masses. +- **Hill's problem is the tide to first order, on a circular host orbit.** The study drops the Sun's vertical oscillation through the disk (82 Myr with this model's ν) and its radial epicycles. It also leaves out: + - passing stars, which with the tide set the Oort cloud's actual edge, and molecular clouds, which also strip it; + - the planets' scattering of comets that plunge inward; + - for moons, the planet's oblateness and its other moons, which damp Lidov–Kozai cycles close in. +- **Circular starting orbits only.** Real moons and comets start on eccentric orbits. + - **The edges' definition.** They are set at half the orbits escaping, or lost, within 20 turns of the host, on a grid of 0.025 r_J (single planes) or 0.05 r_J (all directions). + - **Plunge radius.** It is 10⁻³ r_J. Raising it to 10⁻² moves the Sun's all-directions escaped edge out, from 0.437 to 0.460, and its lost edge in, from 0.411 to 0.394 (24 directions). + - **Chaos and sampling.** Single orbits near an edge are chaotic: changing Γ by 10⁻⁴ either way moves the Sun's in-plane retrograde edge from 0.925 to 0.95, as one orbit of eight changes its fate. (Changing ν²/Ω² by 10⁻⁴ leaves the Sun's polar-across edge at 0.40 in this sample.) With 8 starting angles the in-plane edges carry sampling errors of up to about 0.03 and the polar escape edges up to about 0.025 (see the table's resolution above). + - **Longer runs** move the edges inward a little (see the 100-turn values above). +- **MWPotential2014 is one model among many.** Its halo sets the flat range, and it has no nuclear star cluster. The checks pin its halo, its Kuzmin and Plummer limits pin the disk's a and b to galpy's values, and Table 1's derived values (bulge and disk masses, the mass inside 60 kpc, the slope at R₀ and the local dark-matter density) are checked at Table 1's rounding. The bulge's slope and cut-off are taken from galpy's source and not tested: its mass follows from its 5% share of the force at R₀, and the bulge-mass check, at Table 1's rounding, pins that share only to about 10%. The Galactic-centre numbers use the separate power-law cusp above, which is valid only inside its 3 pc break. +- **Spherical mass estimates.** v²R/G and 3Ω²/4πG treat a flattened galaxy as spherical. In MWPotential2014 this overstates the mass inside 8 kpc by 12%. It shifts the 3.7-fold growth to 4.0 and the Sun's 2.25 to 2.53, but not the contrast with Kepler's fixed mass. + +## Sources + +Each entry says how it was read. "#37's review" means a reviewer checked the values used here in the arXiv source, +or in the primary file, during #37's review. "#37's re-review" marks what the second review checked or calculated: +values in an arXiv source, a reference matched against Crossref where the entry says so, or its averaged-tide cone. + +- W. M. Folkner et al., *The Planetary and Lunar Ephemerides DE430 and DE431*, IPN Progress Report 42-196 (2014), Table 8. #37's review. +- E. M. Standish and J. G. Williams, *Approximate Positions of the Planets*, JPL Solar System Dynamics (credited there to Standish and Williams 1992), Table 1 (1800–2050). Checked against the SSD page in #37's review. +- A. Prša et al., *Nominal values for selected solar and planetary quantities: IAU 2015 Resolution B3*, Astron. J. 152, 41 (2016). https://doi.org/10.3847/0004-6256/152/2/41. #37's review. +- D. Souami and J. Souchay, *The solar system's invariable plane*, A&A 543, A133 (2012). https://doi.org/10.1051/0004-6361/201219011. Search text; not reached in #37's review. The plane's orientation is confirmed through Li, Xia and Zhou 2019; the per-planet tilts are not. +- J. Li, Z. J. Xia and L. Zhou, *Calibration of the angular momenta of the minor planets in the solar system*, A&A 630, A68 (2019). https://doi.org/10.1051/0004-6361/201834196. For the invariable plane's orientation, as #37's review read it. +- Y.-F. Jiang and S. Tremaine, *The evolution of wide binary stars*, MNRAS 401, 977 (2010). https://doi.org/10.1111/j.1365-2966.2009.15744.x. The tidal-radius formula and constants, as #37's review quotes them. +- J. Binney and S. Tremaine, *Galactic Dynamics*, 2nd ed., Princeton (2008). The formula, as Jiang and Tremaine use it; section not confirmed. +- J. Bovy, *Galactic rotation in Gaia DR1*, MNRAS 468, L63 (2017). https://doi.org/10.1093/mnrasl/slx027. #37's review. +- J. A. Correa-Otto and M. F. Calandra, *Stability in the most external region of the Oort Cloud: evolution of the ejected comets*, MNRAS 490, 2495 (2019). https://doi.org/10.1093/mnras/stz2671. #37's review (sect. 4.3). +- Y. Shen and S. Tremaine, *Stability of the Distant Satellites of the Giant Planets in the Solar System*, AJ 136, 2453 (2008). https://doi.org/10.1088/0004-6256/136/6/2453. #37's review; title as Crossref gives it (#37's re-review). +- D. Nesvorný, J. L. A. Alvarellos, L. Dones and H. F. Levison, *Orbital and collisional evolution of the irregular satellites*, AJ 126, 398 (2003). As Shen and Tremaine quote it; the reference matches Crossref (#37's re-review), the text was not read. +- M. L. Lidov, Planet. Space Sci. 9, 719 (1962), and Y. Kozai, AJ 67, 591 (1962). The references match Crossref (#37's re-review); the texts were not read. +- C. F. McKee, A. Parravano and D. J. Hollenbach, *Stars, gas, and dark matter in the solar neighborhood*, ApJ 814, 13 (2015). https://arxiv.org/abs/1509.05334. #37's review. +- J. Heisler and S. Tremaine, *The influence of the Galactic tidal field on the Oort comet cloud*, Icarus 65, 13 (1986). Search text; not reached in #37's review. +- L. Dones, P. R. Weissman, H. F. Levison and M. J. Duncan, *Oort cloud formation and dynamics*, in *Comets II*, 153–174 (2004). The reference matches Crossref (#37's re-review); the text was not read. The edge "as far as 2 × 10^5 AU" is as cited in search text. +- GRAVITY Collaboration, *Detection of the Schwarzschild precession in the orbit of the star S2 near the Galactic centre massive black hole*, A&A 636, L5 (2020). https://doi.org/10.1051/0004-6361/202037813. #37's review (sect. 1.2, appendix B, Table E.1). +- GRAVITY Collaboration, *Mass distribution in the Galactic Center based on interferometric astrometry of multiple stellar orbits*, A&A 657, L12 (2022). https://doi.org/10.1051/0004-6361/202142465. #37's review. +- GRAVITY Collaboration, *Improving constraints on the extended mass distribution in the Galactic center with stellar orbits*, A&A 692, A242 (2024). https://doi.org/10.1051/0004-6361/202452274. #37's review (sect. 4.3). +- R. Schödel, D. Merritt and A. Eckart, A&A 502, 91 (2009). https://doi.org/10.1051/0004-6361/200810922. #37's review. +- R. Schödel et al., A&A 609, A27 (2018). https://doi.org/10.1051/0004-6361/201730452. #37's review (sect. 4.5). +- T. Alexander, *Stellar processes near the massive black hole in the Galactic center*, Phys. Rep. 419, 65 (2005). https://doi.org/10.1016/j.physrep.2005.08.002. #37's review (sect. 3.1.2). +- A. Feldmeier-Krause et al., *Triaxial orbit-based modelling of the Milky Way Nuclear Star Cluster*, MNRAS 466, 4040 (2017). https://doi.org/10.1093/mnras/stw3377. #37's review (sect. 3.3.2). +- D. Merritt, *Dynamics and Evolution of Galactic Nuclei*, Princeton (2013), and D. Merritt, in *Coevolution of Black Holes and Galaxies*, ed. L. C. Ho, p. 263 (2004). Definitions only, as GRAVITY 2024 and Feldmeier-Krause et al. cite them. +- J. Bovy, *galpy: A Python Library for Galactic Dynamics*, ApJS 216, 29 (2015). https://doi.org/10.1088/0067-0049/216/2/29. Table 1 and galpy's source, #37's review. +- A.-C. Eilers, D. W. Hogg, H.-W. Rix and M. K. Ness, ApJ 871, 120 (2019). https://doi.org/10.3847/1538-4357/aaf648. #37's review (eq. 7). +- J. Bland-Hawthorn and O. Gerhard, *The Galaxy in Context: Structural, Kinematic, and Integrated Properties*, ARA&A 54, 529 (2016). https://doi.org/10.1146/annurev-astro-081915-023441. #37's review. +- Y. Jiao et al., A&A 678, A208 (2023). https://doi.org/10.1051/0004-6361/202347513. #37's review. +- O. Koop et al., A&A 692, A50 (2024). https://arxiv.org/abs/2405.19028. #37's review. +- S. S. McGaugh, F. Lelli and J. M. Schombert, PRL 117, 201101 (2016). https://doi.org/10.1103/PhysRevLett.117.201101. #37's review. +- K.-H. Chae, ApJ 952, 128 (2023). https://doi.org/10.3847/1538-4357/ace101. #37's review. +- I. Banik et al., MNRAS 527, 4573 (2024). https://doi.org/10.1093/mnras/stad3393. #37's review. diff --git a/orbits/model.js b/orbits/model.js new file mode 100644 index 0000000..12e28c8 --- /dev/null +++ b/orbits/model.js @@ -0,0 +1,384 @@ +/* Orbits: is a galaxy a big solar system? Where Kepler's law holds, where rotation curves go flat, and what sets the + * boundary. Part of https://github.com/Foundation-0/fractals (issue #36). No dependencies. Loads in Node (require) and + * in a browser (window.ORB). + * + * Kepler's law. Around one dominant mass M, a circular orbit of radius r has speed v = sqrt(GM/r), so v falls as + * r^(-1/2) and the period P obeys P^2 = 4 pi^2 a^3 / (G(M + m)). The law holds at every radius from the central body to + * where something else's pull competes, so it repeats across scales with no size of its own. + * + * Where it stops. A body of mass m on a circular orbit of angular speed Omega in a host keeps its own satellites + * inside the tidal (Jacobi) radius, where its pull matches the host's tidal stretch less the centrifugal term + * (Binney & Tremaine 2008, as Jiang & Tremaine 2010 give it; section not confirmed): + * r_J^3 = G m / (4 Omega^2 - kappa^2) = G m / (4 A (A - B)), Omega = A - B, kappa^2 = -4 B (A - B), + * with A and B the host's Oort constants at the orbit. For a point-mass host A = 3 Omega / 4 and B = -Omega / 4, and + * r_J is Hill's radius a (m / 3M)^(1/3). For a flat rotation curve A = -B = Omega / 2. Either way the mean density of + * m inside r_J, 3m / (4 pi r_J^3), equals 4A/Omega times the host's mean density inside the orbit, 3 Omega^2 / (4 pi G) + * (spherical host): 3 times for a point mass, 2 for a flat curve, and in general 2(1 - dln v/dln R). So the edge is set + * by a ratio of mean densities, not a size. The host's density here is its mean inside the orbit, not its local + * density. + * + * Flat curves. Where the enclosed mass grows as M( { const d = Math.PI / 180; return [Math.sin(i * d) * Math.sin(Om * d), -Math.sin(i * d) * Math.cos(Om * d), Math.cos(i * d)]; }; + // A planet's orbital inclination to the invariable plane [deg]. + function tiltToInvariable(p) { + const n = orbitNormal(p.i, p.Om), m = orbitNormal(INVARIABLE.i, INVARIABLE.Om); + return Math.acos(Math.min(1, n[0] * m[0] + n[1] * m[1] + n[2] * m[2])) * 180 / Math.PI; + } + const planetMassFraction = () => PLANETS.reduce((s, p) => s + 1 / p.sunOver, 0); + + // Kepler's third law for one planet: the GM its orbit implies, n^2 a^3, against GM_sun, with n the mean-longitude + // rate Ldot: the orbit's angular rate, for which n^2 a is the mean inward pull at a on a near-circular orbit + // (G M( 1e-16 * a; i++) { const an = (a + b) / 2; b = Math.sqrt(a * b); a = an; } + return Math.PI / (2 * a); + } + const ringPotential = (r, b) => -(2 / Math.PI) * ellipticK(2 * Math.sqrt(r * b) / (r + b)) / (r + b); // per unit G m + function ringExcess(p, { own = true, which = () => true } = {}) { + let ex = own ? 1 / p.sunOver : 0; + for (const q of PLANETS) { + if (q === p || !which(q)) continue; + const h = 1e-6 * p.a, pull = (ringPotential(p.a + h, q.a) - ringPotential(p.a - h, q.a)) / (2 * h); // inward > 0 + ex += p.a * p.a * pull / q.sunOver; + } + return ex; + } + + // Least-squares slope of log P against log a: 3/2 for Kepler. + function keplerExponent(list = PLANETS) { + const xs = list.map(p => Math.log(p.a)), ys = list.map(p => Math.log(kepler(p).P)); + const mx = xs.reduce((s, x) => s + x, 0) / xs.length, my = ys.reduce((s, y) => s + y, 0) / ys.length; + let sxy = 0, sxx = 0; + xs.forEach((x, i) => { sxy += (x - mx) * (ys[i] - my); sxx += (x - mx) ** 2; }); + return sxy / sxx; + } + + // ---------- where a Kepler domain ends ---------- + // Jacobi radius [m] of a body of GM [m^3/s^2] in a host with Oort constants A, B [km/s/kpc]. + const jacobi = (GM, A, B) => Math.cbrt(GM / (4 * A * (A - B) * C.kmskpc ** 2)); + // Hill radius [same unit as a] for a point-mass host: the Jacobi radius with A = 3 Omega/4, B = -Omega/4. + const hill = (a, massRatio) => a * Math.cbrt(massRatio / 3); + // Oort constants of a point-mass host and of a flat rotation curve, at angular speed Omega. + const oortKepler = Omega => ({ A: 0.75 * Omega, B: -0.25 * Omega }); + const oortFlat = Omega => ({ A: 0.5 * Omega, B: -0.5 * Omega }); + // The body's mean density inside r_J over the host's mean density inside the orbit (spherical host): 4A/Omega, + // which is 2(1 - dln v/dln R) for a rotation curve v(R). + const densityRatio = (A, B) => 4 * A / (A - B); + // Where a mass's own pull falls to an acceleration g: r = sqrt(GM/g) [m]. + const radiusAtAcceleration = (GM, g) => Math.sqrt(GM / g); + + // ---------- Sgr A* and S2 ---------- + // GRAVITY Collaboration 2020 (A&A 636, L5), Table E.1: S2's semi-major axis [mas], eccentricity, period [yr]; their + // fitted mass [M_sun] and distance [pc]. + const S2 = { aMas: 125.058, e: 0.884649, P: 16.0455, M: 4.261e6, R0: 8246.7, fSP: 1.10, fSPerr: 0.19 }; + function orbitOf({ aMas, e, P, R0 }, M) { + const aAU = aMas * 1e-3 * R0, Mk = aAU ** 3 / (P * P); // Kepler's third law in au, yr, M_sun (m << M) + const mass = M === undefined ? Mk : M, GM = mass * C.GMsun, a = aAU * C.au; + const precession = 6 * Math.PI * GM / (C.c * C.c * a * (1 - e * e)); // rad per orbit + const rp = a * (1 - e); + return { + aAU, keplerMass: Mk, precessionArcmin: precession * 180 / Math.PI * 60, + periAU: rp / C.au, periSpeed: Math.sqrt(GM * (1 + e) / rp) / 1e3, periOverRs: rp / (2 * GM / (C.c * C.c)), + }; + } + + // The stars around Sgr A*: inside the break near 3 pc the density falls as r^-gamma, gamma = 1.13 (Schodel et al. + // 2018: the light-density slope of the innermost 1-2 pc, which mass follows at constant M/L; their robust range is + // 1.1-1.4), so their mass grows as r^(3 - gamma); 0.5 to 1.5 million solar masses lie inside 1 pc (Schodel, Merritt & + // Eckart 2009). Radii in pc. + const CUSP = { M1: 1.0e6, M1lo: 0.5e6, M1hi: 1.5e6, gamma: 1.13, rBreak: 3 }; + const cuspMass = (r, M1 = CUSP.M1, gamma = CUSP.gamma) => M1 * Math.pow(r, 3 - gamma); + // The radius where the stars inside weigh k times Sgr A* (k = 1, the equal-mass radius; k = 2, the usual influence + // radius). Radii beyond rBreak extrapolate the power law past the break, where the density falls faster, so they are + // lower limits. + const cuspRadius = (k, Mbh, M1 = CUSP.M1, gamma = CUSP.gamma) => Math.pow(k * Mbh / M1, 1 / (3 - gamma)); + // dln v / dln r for Sgr A* plus the cusp: (dln M / dln r - 1) / 2. + const cuspSlope = (r, Mbh, M1 = CUSP.M1, gamma = CUSP.gamma) => { const m = cuspMass(r, M1, gamma); return ((3 - gamma) * m / (Mbh + m) - 1) / 2; }; + // Where that slope equals s (between -1/2 and (2 - gamma)/2), in closed form: the stars' mass is then + // Mbh (2s + 1) / ((3 - gamma) - (2s + 1)). + const cuspSlopeRadius = (s, Mbh, M1 = CUSP.M1, gamma = CUSP.gamma) => + Math.pow(Mbh * (2 * s + 1) / ((3 - gamma) - (2 * s + 1)) / M1, 1 / (3 - gamma)); + + // ---------- the Milky Way ---------- + function lgamma(z) { // Lanczos, g = 7; |error| < 1e-14 for z > 0 + const c = [0.99999999999980993, 676.5203681218851, -1259.1392167224028, 771.32342877765313, -176.61502916214059, + 12.507343278686905, -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7]; + if (z < 0.5) return Math.log(Math.PI / Math.sin(Math.PI * z)) - lgamma(1 - z); + z -= 1; let x = c[0]; + for (let i = 1; i < 9; i++) x += c[i] / (z + i); + const t = z + 7.5; + return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(x); + } + function gammaP(s, x) { // regularised lower incomplete gamma: series below s + 1, continued fraction above + if (x <= 0) return 0; + const pre = Math.exp(-x + s * Math.log(x) - lgamma(s)); + if (x < s + 1) { + let sum = 1 / s, term = 1 / s; + for (let n = 1; n < 1000; n++) { term *= x / (s + n); sum += term; if (term < sum * 1e-17) break; } + return pre * sum; + } + let b = x + 1 - s, c = 1e300, d = 1 / b, h = d; // modified Lentz + for (let i = 1; i < 1000; i++) { + const an = -i * (i - s); b += 2; + d = an * d + b; if (Math.abs(d) < 1e-300) d = 1e-300; + c = b + an / c; if (Math.abs(c) < 1e-300) c = 1e-300; + d = 1 / d; const del = d * c; h *= del; + if (Math.abs(del - 1) < 1e-16) break; + } + return 1 - pre * h; + } + + // Bovy 2015 (ApJS 216, 29), sec. 3.5: MWPotential2014. + const MWP14 = { R0: 8, v0: 220, f: { bulge: 0.05, disk: 0.6, halo: 0.35 }, alpha: 1.8, rc: 1.9, a: 3, b: 0.28, rs: 16 }; + const SGRA = { M: 4.297e6 }; // GRAVITY Collaboration 2022 (A&A 657, L12) + + function galaxy(par = MWP14, { bh = SGRA.M } = {}) { + const shape = { + bulge: r => gammaP((3 - par.alpha) / 2, (r / par.rc) ** 2), // M( R * R / Math.pow(R * R + (par.a + par.b) ** 2, 1.5), // v^2 / (G M_disk), mid-plane + halo: r => Math.log(1 + r / par.rs) - (r / par.rs) / (1 + r / par.rs), // M( ({ + bh: C.G * M.bh / R, bulge: C.G * M.bulge * shape.bulge(R) / R, disk: C.G * M.disk * shape.disk(R), + halo: C.G * M.halo * shape.halo(R) / R, + }); + const v2 = R => { const p = parts(R); return p.bh + p.bulge + p.disk + p.halo; }; + const v = R => Math.sqrt(v2(R)); + const slope = R => { const h = 1e-4; return Math.log(v(R * (1 + h)) / v(R * (1 - h))) / Math.log((1 + h) / (1 - h)); }; + const bulgeMass = r => M.bulge * shape.bulge(r); + // The disk's mass inside a sphere of radius r, by Gauss's theorem: (r^2 / G) times the mean over the sphere of the + // outward radial pull, here r^2/2 times the integral over mu = z/r of dPhi/dr for the Miyamoto-Nagai potential + // -G M / sqrt(R^2 + (a + sqrt(z^2 + b^2))^2) (Simpson's rule in mu on [0, 1], doubled by symmetry). + const diskSphereMass = r => { + const n = 4000, a = par.a, b = par.b; + const f = mu => { + const z = r * mu, R = r * Math.sqrt(Math.max(0, 1 - mu * mu)), zeta = Math.sqrt(z * z + b * b), D = Math.hypot(R, a + zeta); + return (R * R + (a + zeta) * z * z / zeta) / (r * D * D * D); + }; + let sum = f(0) + f(1); + for (let i = 1; i < n; i++) sum += (i % 2 ? 4 : 2) * f(i / n); + return M.disk * r * r * sum / (3 * n); + }; + // The total mass inside a sphere of radius r [M_sun]. + const sphereMass = r => M.bh + bulgeMass(r) + diskSphereMass(r) + M.halo * shape.halo(r); + // The halo's (NFW) density at radius r [M_sun/pc^3]. + const haloDensity = r => M.halo / (4 * Math.PI * par.rs ** 3) / ((r / par.rs) * (1 + r / par.rs) ** 2) / 1e9; + // the smallest radius above r0 where f crosses zero, by a log grid then bisection + const cross = (f, r0, r1) => { + let lo = r0, flo = f(lo); + for (let r = r0 * 1.02; r <= r1; r *= 1.02) { + const fr = f(r); + if (Math.sign(fr) !== Math.sign(flo)) { + let a = lo, b = r; + for (let i = 0; i < 100; i++) { const m = Math.sqrt(a * b); if (Math.sign(f(m)) === Math.sign(flo)) a = m; else b = m; } + return Math.sqrt(a * b); + } + lo = r; flo = fr; + } + return NaN; + }; + return { + par, M, parts, v, slope, bulgeMass, diskSphereMass, sphereMass, haloDensity, cross, + // where the bulge's stars inside r first weigh k times Sgr A* (k = 1, equal mass; k = 2, the influence radius) + influence: (k = 1) => cross(r => bulgeMass(r) - k * M.bh, 1e-6, 1), + // the longest run of radii (kpc, on a grid 0.5% apart) where |dln v / dln R| < tol; by default outside the bulge + // (R > 1 kpc), since the r^-1.8 bulge is also flat to +-0.15 from about 7 to 180 pc + flatRange: (tol = 0.15, rMin = 1, rMax = 300) => { + let best = [NaN, NaN], start = NaN, last = NaN; + for (let r = rMin; r <= rMax * 1.0001; r *= 1.005) { + if (Math.abs(slope(r)) < tol) { if (Number.isNaN(start)) start = r; last = r; } + else if (!Number.isNaN(start)) { + if (Number.isNaN(best[0]) || last / start > best[1] / best[0]) best = [start, last]; + start = NaN; + } + } + if (!Number.isNaN(start) && (Number.isNaN(best[0]) || last / start > best[1] / best[0])) best = [start, last]; + return best; + }, + }; + } + + // ---------- Hill's problem: which orbits a body keeps inside its tidal radius ---------- + // A satellite of a body on a circular orbit in a host, in the frame rotating with the body (x away from the host's + // centre, y along the motion, z out of the plane), lengths in r_J and times in 1/Omega (Binney & Tremaine 2008, + // as Jiang & Tremaine 2010 give it; Heisler & Tremaine 1986 for the vertical tide): + // x'' = 2y' + Gam x - Gam x/r^3, y'' = -2x' - Gam y/r^3, z'' = -nu2 z - Gam z/r^3, + // with Gam = 4A/Omega (3 for a point-mass host, so these are Hill's equations) and nu2 = (vertical tidal frequency / + // Omega)^2: 1 for a point-mass host; for a disk, (4 pi G rho0 + 2(A^2 - B^2)) / Omega^2 by Poisson's equation, with + // rho0 the local mid-plane density. The tidal radius r_J is where the x-axis forces balance (x = 1). + const HOST_KEPLER = { name: 'point-mass host (a planet around the Sun)', Gam: 3, nu2: 1 }; + function hostDisk(A, B, rho0) { // A, B in km/s/kpc; rho0 in M_sun/pc^3 + const Omega = A - B, nuz = 4 * Math.PI * C.G * rho0 * 1e9 + 2 * (A * A - B * B); // (km/s/kpc)^2; 1 pc^-3 = 1e9 kpc^-3 + return { name: 'disk host (the Sun in the Galaxy)', Gam: 4 * A / Omega, nu2: nuz / (Omega * Omega), A, B, rho0 }; + } + + function hillDeriv(s, Gam, nu2, out) { + const x = s[0], y = s[1], z = s[2], vx = s[3], vy = s[4], vz = s[5]; + const r2 = x * x + y * y + z * z, k = Gam / (r2 * Math.sqrt(r2)); + out[0] = vx; out[1] = vy; out[2] = vz; + out[3] = 2 * vy + Gam * x - k * x; out[4] = -2 * vx - k * y; out[5] = -nu2 * z - k * z; + } + // Dormand-Prince 5(4) with step control (Hairer, Norsett & Wanner, Solving ODEs I, sec. II.5). + const DP = { + a: [[], [1 / 5], [3 / 40, 9 / 40], [44 / 45, -56 / 15, 32 / 9], [19372 / 6561, -25360 / 2187, 64448 / 6561, -212 / 729], + [9017 / 3168, -355 / 33, 46732 / 5247, 49 / 176, -5103 / 18656], [35 / 384, 0, 500 / 1113, 125 / 192, -2187 / 6784, 11 / 84]], + e: [71 / 57600, 0, -71 / 16695, 71 / 1920, -17253 / 339200, 22 / 525, -1 / 40], + }; + // Follows one orbit for `orbits` turns of the host (time 2 pi orbits). Fate: 'escapes' once r > rEsc, 'plunges' + // once r < rIn (1e-3 r_J is 0.74 of Jupiter's radius; for the Sun it is 283 au, outside the planets), otherwise + // 'stays'. Returns the final state s too. Throws on non-finite settings, on a non-finite step, or after maxSteps + // (by default 2.5e5 per turn of the host; the hardest orbit in the tables, a polar orbit at 0.025 r_J that stays, + // needs about 7e4 per turn; steps per turn grow as a^-1.5, so the cap would fire only below about 0.012 r_J, under + // the smallest radius scanned here), rather than looping. + function hillOrbit(host, s0, { orbits = 20, rEsc = 3, rIn = 1e-3, tol = 1e-10, maxSteps = 2.5e5 * orbits } = {}) { + if (![orbits, rEsc, rIn, tol, maxSteps, host.Gam, host.nu2, ...s0].every(Number.isFinite)) throw new Error('hillOrbit: non-finite input'); + const T = 2 * Math.PI * orbits, k = Array.from({ length: 7 }, () => new Float64Array(6)); + const y = new Float64Array(6), s = Float64Array.from(s0); + let t = 0, h = 1e-3, steps = 0; + hillDeriv(s, host.Gam, host.nu2, k[0]); + while (t < T) { + if (t + h > T) h = T - t; + for (let j = 1; j < 7; j++) { + for (let i = 0; i < 6; i++) { let acc = s[i]; for (let m = 0; m < j; m++) acc += h * DP.a[j][m] * k[m][i]; y[i] = acc; } + hillDeriv(y, host.Gam, host.nu2, k[j]); + } + let err = 0; + for (let i = 0; i < 6; i++) { + let ei = 0; for (let m = 0; m < 7; m++) ei += DP.e[m] * k[m][i]; + err = Math.max(err, Math.abs(h * ei) / (tol * (1 + Math.abs(s[i])))); + } + if (!Number.isFinite(err) || !(h > 0)) throw new Error(`hillOrbit: non-finite step at t = ${t}`); + if (steps > maxSteps) throw new Error(`hillOrbit: more than ${maxSteps} steps`); + if (err <= 1) { + t += h; steps++; + for (let i = 0; i < 6; i++) { s[i] = y[i]; k[0][i] = k[6][i]; } + const r = Math.hypot(s[0], s[1], s[2]); + if (r > rEsc) return { fate: 'escapes', t, steps, s: Array.from(s) }; + if (r < rIn) return { fate: 'plunges', t, steps, s: Array.from(s) }; + } + h *= Math.min(5, Math.max(0.2, 0.9 * Math.pow(err, -0.2))); + } + return { fate: 'stays', t, steps, s: Array.from(s) }; + } + // A circular orbit of radius a (in r_J) about the body, at the two-body speed, in the plane with unit normal n + // (rotating-frame axes; n = +z is prograde, -z retrograde), starting at angle phi. + function hillStart(host, a, n, phi) { + const [nx, ny, nz] = n; + let ux, uy, uz; + if (Math.abs(nz) < 0.9) { ux = -ny; uy = nx; uz = 0; } else { ux = 0; uy = -nz; uz = ny; } + const un = Math.hypot(ux, uy, uz); ux /= un; uy /= un; uz /= un; + const wx = ny * uz - nz * uy, wy = nz * ux - nx * uz, wz = nx * uy - ny * ux; + const c = Math.cos(phi), s = Math.sin(phi), v = Math.sqrt(host.Gam / a); + const x = a * (c * ux + s * wx), y = a * (c * uy + s * wy), z = a * (c * uz + s * wz); + // velocity in the rotating frame: the inertial circular velocity less Omega x r, Omega = +z + return [x, y, z, v * (-s * ux + c * wx) + y, v * (-s * uy + c * wy) - x, v * (-s * uz + c * wz)]; + } + // n directions spread evenly over the sphere (Fibonacci lattice). + function sphere(n) { + const out = [], g = Math.PI * (3 - Math.sqrt(5)); + for (let i = 0; i < n; i++) { const z = 1 - 2 * (i + 0.5) / n, r = Math.sqrt(1 - z * z); out.push([r * Math.cos(g * i), r * Math.sin(g * i), z]); } + return out; + } + // Fractions of orbits that stay, escape and plunge, over the given orbit normals and nPhase starting angles each. + // Hill's equations are symmetric under r -> -r, v -> -v: a start at phi + pi is the inverted start at phi, with the + // same fate. So the starting angles span the half turn [0, pi). The equations are also symmetric under z -> -z, and + // under time reversal with y -> -y. For a normal in the x-z plane (or, with z -> -z as well and an inversion, the + // y-z plane), as in every single-plane scan here, the start at pi - phi is then the mirror of the start at phi run + // backward. Its fate matches nearly always in the plane but often not for polar orbits, so it is no duplicate there; + // still, the angles phi = pi (p + offset)/nPhase are offset by a quarter step so that no such pair falls in one + // sample. offset = 0.75 takes the mirrored set pi - phi instead. + function hillFates(host, a, normals, { nPhase = 4, offset = 0.25, ...opt } = {}) { + const n = { stays: 0, escapes: 0, plunges: 0 }; + for (const nv of normals) for (let p = 0; p < nPhase; p++) n[hillOrbit(host, hillStart(host, a, nv, Math.PI * (p + offset) / nPhase), opt).fate]++; + const tot = normals.length * nPhase; + return { stays: n.stays / tot, escapes: n.escapes / tot, plunges: n.plunges / tot }; + } + // Fates on a grid of radii (in r_J), and the radius where a fraction first reaches one half (linear interpolation + // between grid points; NaN if it never does): edge for the orbits that escaped, edgeLost for those escaped or plunged. + // A half reached already at the first grid point returns that point, so start the grid inside the edge. + function halfPoint(rows, frac) { + for (let i = 0; i < rows.length; i++) { + const f = frac(rows[i]); + if (f >= 0.5) { + if (i === 0) return rows[0].a; + const g = frac(rows[i - 1]); + return rows[i - 1].a + (rows[i].a - rows[i - 1].a) * (0.5 - g) / (f - g); + } + } + return NaN; + } + function hillScan(host, normals, as, opt = {}) { + const rows = as.map(a => ({ a, ...hillFates(host, a, normals, opt) })); + return { rows, edge: halfPoint(rows, r => r.escapes), edgeLost: halfPoint(rows, r => r.escapes + r.plunges) }; + } + + // McGaugh, Lelli & Schombert 2016: the acceleration where the radial acceleration relation bends. + const GDAGGER = 1.20e-10; // m s^-2 + + const api = { + C, PLANETS, INVARIABLE, tiltToInvariable, planetMassFraction, kepler, ellipticK, ringExcess, keplerExponent, jacobi, hill, oortKepler, oortFlat, densityRatio, + radiusAtAcceleration, S2, orbitOf, CUSP, cuspMass, cuspRadius, cuspSlope, cuspSlopeRadius, lgamma, gammaP, MWP14, SGRA, galaxy, GDAGGER, + HOST_KEPLER, hostDisk, hillOrbit, hillStart, sphere, hillFates, hillScan, + }; + if (typeof module !== 'undefined' && module.exports) module.exports = api; else root.ORB = api; +})(typeof window !== 'undefined' ? window : globalThis); diff --git a/orbits/table.mjs b/orbits/table.mjs new file mode 100644 index 0000000..cae06c1 --- /dev/null +++ b/orbits/table.mjs @@ -0,0 +1,246 @@ +// Prints every computed number in orbits/README.md, except the values the README credits to #37's review or re-review. Run: node orbits/table.mjs (about 11 minutes; the stability scans of +// section 5 take nearly all of it), node orbits/table.mjs quick (well under a second; section 5 left out), or +// node orbits/table.mjs long (adds the all-directions scans followed for 100 turns of the host). +// Exits with code 1 if any printed line holds NaN or Infinity. +import { createRequire } from 'node:module'; +const O = createRequire(import.meta.url)('./model.js'); +const { C } = O; +const e3 = x => x.toExponential(3), f = (x, d = 3) => x.toFixed(d); +const quick = process.argv[2] === 'quick', long = process.argv[2] === 'long'; +const print = console.log; +let bad = false; +console.log = (...a) => { if (/NaN|Infinity/.test(a.join(' '))) bad = true; print(...a); }; +process.on('exit', () => { if (bad) { print('non-finite value printed'); process.exitCode = 1; } }); + +console.log('1. Kepler in the Solar System (JPL approximate elements, Table 1, 1800-2050; GM_sun IAU 2015; masses DE430)\n'); +console.log(' n = the mean-longitude rate Ldot (the angular rate); excess = n^2 a^3/GM_sun - 1'); +console.log(' planet a [au] P [yr] excess own mass/Sun own + inner planets own + other planets as rings'); +let inner = 0; +for (const p of O.PLANETS) { + const k = O.kepler(p); + console.log(` ${p.name.padEnd(9)} ${f(p.a, 6).padStart(10)} ${f(k.P, 5).padStart(11)} ${e3(k.excess).padStart(10)} ${e3(k.own)} ${e3(k.own + inner)} ${e3(O.ringExcess(p)).padStart(10)}`); + inner += k.own; +} +{ + const nep = O.PLANETS[7], nA = (nep.Ldot + 0.32241464) * Math.PI / 180 / (36525 * C.day); + console.log(` with the mean-anomaly rate Ldot - wdot instead (Table 1's wdot = -0.32241464 deg/century), Neptune's excess would be ${e3(nA * nA * (nep.a * C.au) ** 3 / C.GMsun - 1)}`); +} +const mu = O.planetMassFraction(); +console.log(` all eight planets together: ${e3(mu)} of the Sun's mass; largest |excess| ${e3(Math.max(...O.PLANETS.map(p => Math.abs(O.kepler(p).excess))))}`); +console.log(` largest |excess| of the inner four: ${e3(Math.max(...O.PLANETS.slice(0, 4).map(p => Math.abs(O.kepler(p).excess))))}`); +console.log(` fitted exponent of P against a: ${f(O.keplerExponent(), 6)} over all eight (0.39 to 30 au), ${f(O.keplerExponent(O.PLANETS.slice(0, 4)), 6)} over the inner four; Kepler 1.5`); +console.log(` mass inside Neptune's orbit over mass inside Mercury's: 1 + ${e3(mu - 1 / O.PLANETS[7].sunOver)}`); +console.log(` the other planets' rings alone: ${O.PLANETS.map(p => `${p.name} ${e3(O.ringExcess(p, { own: false }))}`).join(', ')}`); +{ + const J = O.PLANETS[4]; + console.log(` Jupiter's ring term from the planets inside its orbit: ${e3(O.ringExcess(J, { own: false, which: q => q.a < J.a }))};` + + ` outside: ${e3(O.ringExcess(J, { own: false, which: q => q.a > J.a }))}`); +} +console.log(` Saturn's ring estimate minus its fit: ${e3(O.ringExcess(O.PLANETS[5]) - O.kepler(O.PLANETS[5]).excess)}`); + +console.log('\n2. Where a Kepler domain ends: the tidal (Jacobi) radius, r_J^3 = G m / (4 A (A - B))\n'); +const OORT = { A: 15.3, B: -11.9, dA: 0.4, dB: 0.4 }; // Bovy 2017 +const rJ = O.jacobi(C.GMsun, OORT.A, OORT.B); +const rJs = [[OORT.A + OORT.dA, OORT.B], [OORT.A - OORT.dA, OORT.B], [OORT.A, OORT.B + OORT.dB], [OORT.A, OORT.B - OORT.dB]].map(([A, B]) => O.jacobi(C.GMsun, A, B) / C.pc); +console.log(` the Sun in the Galaxy (A = ${OORT.A}, B = ${OORT.B} km/s/kpc, Bovy 2017): r_J = ${f(rJ / C.pc)} pc = ${f(rJ / C.au / 1e5, 2)}e5 au` + + ` (moving A or B by its error: ${f(Math.min(...rJs))} to ${f(Math.max(...rJs))} pc)`); +console.log(` with A = 14.8 and Omega = 29.6 km/s/kpc (B = A - Omega; Jiang & Tremaine's constants as Correa-Otto & Calandra round them): ` + + `${f(O.jacobi(C.GMsun, 14.8, 14.8 - 29.6) / C.au / 1e5, 2)}e5 au`); +console.log(` the Sun's mean density inside r_J over the Galaxy's inside the Sun's orbit: 4A/(A - B) = ${f(O.densityRatio(OORT.A, OORT.B), 2)}` + + ` (3 for a point-mass host, 2 for a flat rotation curve; 2(1 - dln v/dln R) with dln v/dln R = -(A + B)/(A - B) = ${f(-(OORT.A + OORT.B) / (OORT.A - OORT.B))})`); +const rhoJ = 1 / (4 / 3 * Math.PI * (rJ / C.pc) ** 3); +console.log(` that mean density: ${f(rhoJ, 3)} M_sun/pc^3; the Galaxy's spherical mean inside the Sun's orbit, 3 Omega^2/(4 pi G): ` + + `${f(3 * ((OORT.A - OORT.B) * 1e-3) ** 2 / (4 * Math.PI * C.G * 1e9 * 1e-6), 3)} M_sun/pc^3; the local mid-plane density is about 0.10`); +for (const p of O.PLANETS) console.log(` Hill radius of ${p.name.padEnd(8)} a (m/3M)^(1/3) = ${f(O.hill(p.a, 1 / p.sunOver), 4)} au = ${f(O.hill(p.a, 1 / p.sunOver) / p.a, 4)} a`); +console.log(` the Sun's own pull falls to g+ = ${O.GDAGGER.toExponential(2)} m/s^2 at ${f(O.radiusAtAcceleration(C.GMsun, O.GDAGGER) / C.au, 0)} au` + + ` (${f(O.radiusAtAcceleration(C.GMsun, O.GDAGGER) / rJ, 3)} r_J)`); + +console.log('\n3. Sgr A*: a Kepler domain at the centre of the Galaxy (S2, GRAVITY Collaboration 2020)\n'); +const s2 = O.orbitOf(O.S2), s2M = O.orbitOf(O.S2, O.S2.M); +console.log(` a = ${O.S2.aMas} mas at R0 = ${O.S2.R0} pc: ${f(s2.aAU, 1)} au; P = ${O.S2.P} yr; e = ${O.S2.e}`); +console.log(` Kepler's third law: M = a^3/P^2 = ${f(s2.keplerMass / 1e6, 4)}e6 M_sun (their fit ${O.S2.M / 1e6}e6)`); +console.log(` Schwarzschild precession 6 pi GM / (c^2 a (1 - e^2)) = ${f(s2M.precessionArcmin, 2)} arcmin per orbit; measured f_SP = ${O.S2.fSP} +- ${O.S2.fSPerr} of it`); +console.log(` pericentre ${f(s2M.periAU, 0)} au = ${f(s2M.periOverRs, 0)} Schwarzschild radii, at ${f(s2M.periSpeed, 0)} km/s (${f(s2M.periSpeed * 1e3 / C.c * 100, 2)}% of c)`); +const MBH = O.SGRA.M, K = O.CUSP; +console.log(` Sgr A* today: ${MBH / 1e6}e6 M_sun (GRAVITY Collaboration 2022). The stars around it: ${K.M1lo / 1e6} to ${K.M1hi / 1e6}e6 M_sun inside 1 pc` + + ` (Schodel, Merritt & Eckart 2009), density ~ r^-${K.gamma} inside ~${K.rBreak} pc (Schodel et al. 2018); mass ~ r^${f(3 - K.gamma, 2)}`); +for (const [lab, M1] of [['low', K.M1lo], ['middle', K.M1], ['high', K.M1hi]]) { + console.log(` ${lab.padEnd(6)} (${M1 / 1e6}e6 inside 1 pc): dln v/dln r passes -1/4 at ${f(O.cuspSlopeRadius(-0.25, MBH, M1), 2)} pc and 0 at` + + ` ${f(O.cuspSlopeRadius(0, MBH, M1), 2)} pc; stars weigh as much as Sgr A* inside ${f(O.cuspRadius(1, MBH, M1), 2)} pc, twice as much inside` + + ` ${f(O.cuspRadius(2, MBH, M1), 2)} pc`); +} +console.log(` (radii past the ${K.rBreak} pc break extrapolate the power law; the density falls faster there, so they are lower limits)`); +console.log(` middle: where dln v/dln r = -0.4, -0.3, -0.25, -0.2, -0.1: ${[-0.4, -0.3, -0.25, -0.2, -0.1].map(s => f(O.cuspSlopeRadius(s, MBH), 2)).join(', ')} pc`); +console.log(` dln v/dln r (middle): ${[0.01, 0.1, 0.5, 1, 2, 3].map(r => `${f(O.cuspSlope(r, MBH))} at ${r} pc`).join(', ')}`); +console.log(` the stars' mass (middle) inside 3 pc: ${e3(O.cuspMass(3))} M_sun; inside 0.01 pc: ${f(O.cuspMass(0.01), 0)} M_sun`); +console.log(` with gamma = 1.4 instead (the top of Schodel et al.'s 1.1-1.4), the middle "twice" radius: ${f(O.cuspRadius(2, MBH, K.M1, 1.4), 2)} pc`); +console.log(` the stars inside 1 pc (middle): ${f(O.cuspMass(1) / MBH, 2)} of Sgr A*'s mass; their density at 1 pc, (3 - gamma) M1/(4 pi): ` + + `${e3((3 - K.gamma) * K.M1 / (4 * Math.PI))} M_sun/pc^3, ${e3((3 - K.gamma) * K.M1 / (4 * Math.PI) / 0.10)} times the 0.10 near the Sun; Sgr A* is ${e3(MBH)} Suns`); +const g = O.galaxy(); +console.log(` for comparison, MWPotential2014's bulge (fit on kpc scales, no nuclear star cluster) plus Sgr A*: stars weigh as much as Sgr A* inside` + + ` ${f(g.influence(1) * 1e3, 2)} pc, twice as much inside ${f(g.influence(2) * 1e3, 2)} pc`); + +console.log('\n4. The Galaxy: v(R) and its log slope in the mid-plane (MWPotential2014, Bovy 2015, plus Sgr A*)\n'); +console.log(` component masses: bulge ${e3(g.M.bulge)}, disk ${e3(g.M.disk)} M_sun; halo 4 pi rho_s r_s^3 = ${e3(g.M.halo)} M_sun`); +console.log(' R [kpc] v [km/s] dln v/dln R fractions of v^2: BH, bulge, disk, halo'); +for (const R of [1e-5, 1e-4, 1e-3, 3e-3, 1e-2, 0.03, 0.1, 0.3, 1, 3, 5, 8, 15, 25, 50, 100, 200]) { + const p = g.parts(R), v2 = p.bh + p.bulge + p.disk + p.halo; + console.log(` ${String(R).padEnd(10)} ${f(g.v(R), 1).padStart(9)} ${f(g.slope(R)).padStart(8)} ${[p.bh, p.bulge, p.disk, p.halo].map(x => f(x / v2, 3)).join(', ')}`); +} +const flat = g.flatRange(0.15), flatBulge = g.flatRange(0.15, 1e-3, 1); +console.log(` |dln v/dln R| < 0.15 outside the bulge (R > 1 kpc) from ${f(flat[0], 2)} to ${f(flat[1], 1)} kpc; the r^-1.8 bulge is also that flat from` + + ` ${f(flatBulge[0] * 1e3, 0)} to ${f(flatBulge[1] * 1e3, 0)} pc`); +const EILERS = { v0: 229.0, dv: -1.7, R0: 8.122, Rmin: 5, Rmax: 25 }; // Eilers et al. 2019 +const ve = R => EILERS.v0 + EILERS.dv * (R - EILERS.R0); +console.log(` Eilers et al. 2019: v = ${EILERS.v0} ${EILERS.dv} (R - ${EILERS.R0}) km/s for ${EILERS.Rmin} to ${EILERS.Rmax} kpc;` + + ` dln v/dln R = ${f(EILERS.dv * EILERS.Rmin / ve(EILERS.Rmin))} at ${EILERS.Rmin}, ${f(EILERS.dv * EILERS.R0 / ve(EILERS.R0))} at R0, ${f(EILERS.dv * EILERS.Rmax / ve(EILERS.Rmax))} at ${EILERS.Rmax} kpc`); +{ + const Rs = [5, 8.122, 15, 25]; + console.log(` Eilers et al.'s v at ${Rs.join(', ')} kpc: ${Rs.map(R => f(ve(R), 1)).join(', ')} km/s; the model's: ${Rs.map(R => f(g.v(R), 1)).join(', ')}`); + console.log(` shape, (v/v(R0)) / (v_Eilers/v_Eilers(R0)) - 1: ${Rs.map(R => f(g.v(R) / g.v(8.122) / (ve(R) / ve(8.122)) - 1)).join(', ')}; level at R0: ${f(g.v(8.122) / 229 - 1)}`); +} +const Mgrow = ve(EILERS.Rmax) ** 2 * EILERS.Rmax / (ve(EILERS.Rmin) ** 2 * EILERS.Rmin); +console.log(` mass inside 25 kpc over mass inside 5 kpc, v^2 R / G (spherical): ${f(Mgrow, 2)}; for Kepler it would be 1`); +{ + const vRG = R => g.v(R) ** 2 * R / C.G; + console.log(` MWPotential2014: mass inside a sphere of 8 kpc ${e3(g.sphereMass(8))} M_sun, against v^2 R/G = ${e3(vRG(8))} (${f(vRG(8) / g.sphereMass(8) - 1)} over)`); + console.log(` MWPotential2014: mass inside 25 kpc over 5 kpc, true ${f(g.sphereMass(25) / g.sphereMass(5), 2)}, v^2 R/G ${f(vRG(25) / vRG(5), 2)}`); + const Rsun = 8.122, rhoMean = g.sphereMass(Rsun) / (4 / 3 * Math.PI * (Rsun * 1e3) ** 3); + console.log(` the Sun's mean density inside r_J over MWPotential2014's true mean density inside ${Rsun} kpc: ${f(rhoJ / rhoMean, 2)};` + + ` 2.25 times the 8 kpc overstatement alone: ${f(O.densityRatio(OORT.A, OORT.B) * vRG(8) / g.sphereMass(8), 2)}`); + const gamE = 2 * (1 - EILERS.dv * EILERS.R0 / ve(EILERS.R0)), gamM = 2 * (1 - g.slope(Rsun)); + console.log(` Gam = 4A/Omega = 2(1 - dln v/dln R) from Eilers et al.'s slope at R0: ${f(gamE, 2)}; from MWPotential2014's: ${f(gamM, 2)}; from Bovy's A, B: 2.25`); + console.log(` r_J from Eilers et al.'s curve at R0 (Omega = v/R0, A = Gam Omega/4): ${f(O.jacobi(C.GMsun, gamE * ve(Rsun) / Rsun / 4, gamE * ve(Rsun) / Rsun / 4 - ve(Rsun) / Rsun) / C.pc)} pc`); +} +for (const Mb of [5e10, 6e10, 1e11]) console.log(` ${e3(Mb)} M_sun all inside 25 kpc, as a point mass: v(25 kpc) = ${f(Math.sqrt(C.G * Mb / 25), 0)} km/s (measured ${f(ve(25), 0)})`); +console.log(' (the stars: 5 +- 1 x 10^10 M_sun, Bland-Hawthorn & Gerhard 2016; 10^11 is twice that)'); +const gR0 = (ve(EILERS.R0) * 1e3) ** 2 / (EILERS.R0 * C.kpc); +console.log(` the Galaxy's pull at the Sun: v^2/R0 = ${e3(gR0)} m/s^2 = ${f(gR0 / O.GDAGGER, 2)} g+`); + +console.log('\n4b. What does repeat: thin disks\n'); +console.log(` inclinations to the invariable plane (JPL Table 1 elements; plane from Souami & Souchay 2012): ` + + O.PLANETS.map(p => `${p.name} ${f(O.tiltToInvariable(p), 3)}`).join(', ') + ' deg'); +const tilts = O.PLANETS.map(p => O.tiltToInvariable(p) * Math.PI / 180); +console.log(` mean inclination over the eight: ${f(O.PLANETS.reduce((a, p) => a + O.tiltToInvariable(p), 0) / 8, 2)} deg`); +console.log(` rms sin(i) over the eight: ${f(Math.sqrt(tilts.reduce((a, t) => a + Math.sin(t) ** 2, 0) / 8), 3)}; without Mercury: ${f(Math.sqrt(tilts.slice(1).reduce((a, t) => a + Math.sin(t) ** 2, 0) / 7), 3)}`); +console.log(` the Galaxy's thin disk: scale height 300 +- 50 pc over scale length 2.6 +- 0.5 kpc = ${f(0.3 / 2.6, 3)}, the axis ratio of its density` + + ` contours; over the Sun's radius 8.2 kpc = ${f(0.3 / 8.2, 3)} (Bland-Hawthorn & Gerhard 2016)`); +console.log(` as rms height over radius: the thin disk ${f(Math.SQRT2 * 0.3 / 8.2, 3)} (an exponential profile has rms z = sqrt2 h), the planets` + + ` ${f(Math.sqrt(tilts.reduce((a, t) => a + Math.sin(t) ** 2, 0) / 8) / Math.SQRT2, 3)} (an orbit tilted by i has rms z/r = sin i/sqrt2)`); + +if (!quick) { + console.log('\n5. Which orbits a body keeps: circular orbits followed for 20 turns of the host (Hill\'s problem)\n'); + const RHO0 = 0.10; // M_sun/pc^3, local mid-plane density (McKee, Parravano & Hollenbach 2015: 0.097 +- 0.013) + const sun = O.hostDisk(OORT.A, OORT.B, RHO0), turnGyr = n => n * 2 * Math.PI / ((OORT.A - OORT.B) * C.kmskpc) / C.yr / 1e9; + console.log(` point-mass host: Gam = 4A/Omega = ${O.HOST_KEPLER.Gam}, (nu/Omega)^2 = ${O.HOST_KEPLER.nu2}`); + console.log(` the Sun in the Galaxy (A, B as above, rho0 = ${RHO0} M_sun/pc^3): Gam = ${f(sun.Gam, 3)}, (nu/Omega)^2 = ${f(sun.nu2, 2)}`); + console.log(` 20 turns of the host: ${f(turnGyr(20), 2)} Gyr for the Sun; ${f(20 * O.kepler(O.PLANETS[4]).P, 0)} yr for Jupiter`); + console.log(` an orbit counts as plunged inside 1e-3 r_J: ${f(1e-3 * rJ / C.au, 0)} au for the Sun, ${f(1e-3 * O.hill(O.PLANETS[4].a, 1 / O.PLANETS[4].sunOver) * C.au / 7.1492e7, 2)} Jupiter radii (71,492 km)`); + console.log(` the Sun's vertical oscillation through the disk with this nu: ${f(2 * Math.PI / (Math.sqrt(sun.nu2) * (OORT.A - OORT.B) * C.kmskpc) / C.yr / 1e6, 0)} Myr`); + const planes = { 'prograde, in the plane': [[0, 0, 1]], 'retrograde, in the plane': [[0, 0, -1]], 'polar, plane holds the host': [[0, 1, 0]], 'polar, plane across it': [[1, 0, 0]] }; + const grid = (a0, a1, da) => { const out = []; for (let a = a0; a <= a1 + 1e-9; a += da) out.push(+a.toFixed(4)); return out; }; + const big = grid(0.3, 1.2, 0.025), all = grid(0.025, 1.2, 0.025); + const sunNu1 = { ...sun, nu2: 1, name: 'the Sun in the Galaxy with (nu/Omega)^2 = 1' }; + console.log(' radius [r_J] where half the orbits (8 starting angles over [0, pi), a quarter step off pi p/8) have escaped beyond 3 r_J / are lost'); + console.log(' (escaped, or plunged within 1e-3 r_J):'); + console.log(' orbit point-mass host the Sun in the Galaxy the same with (nu/Omega)^2 = 1'); + const profiles = []; + for (const [k, n] of Object.entries(planes)) { + const polar = k.startsWith('polar'); + const e = [O.HOST_KEPLER, sun, sunNu1].map(h => O.hillScan(h, n, polar ? all : big, { nPhase: 8 })); + console.log(` ${k.padEnd(28)} ${e.map(r => `${f(r.edge, 3)} / ${f(r.edgeLost, 3)}`.padStart(13)).join(' ')}`); + const firstPlunge = e.map(r => r.rows.find(x => x.plunges > 0)); // undefined if none plunge, so a NaN radius still prints as NaN + if (!polar) profiles.push(`${k}: first plunge at ${firstPlunge.map(row => (row ? f(row.a, 3) : 'none')).join(', ')} r_J`); + } + console.log(' (an orbit that starts in the plane stays in it, so the vertical tide cannot act on the first two rows; with these 8 angles their'); + console.log(' plunges begin only outside the escape edge, so the two radii agree. For polar rows "lost" is the first radius where half are lost.)'); + for (const p of profiles) console.log(` ${p} [point mass | Sun | Sun, nu2 = 1]`); + { + const polars = Object.entries(planes).filter(([k]) => k.startsWith('polar')), hosts = [['point mass', O.HOST_KEPLER], ['the Sun', sun], ['the Sun, nu2 = 1', sunNu1]]; + console.log(' polar rows with the mirrored set of 8 angles (pi - phi, a quarter step the other way), escaped / lost [point mass | Sun | Sun, nu2 = 1]:'); + for (const [k, n] of polars) + console.log(` ${k.padEnd(28)}${hosts.map(([, h]) => { const r = O.hillScan(h, n, all, { nPhase: 8, offset: 0.75 }); return `${f(r.edge, 3)} / ${f(r.edgeLost, 3)}`.padStart(13); }).join(' ')}`); + const as32 = grid(0.1, 0.5, 0.025); + console.log(` polar rows with 32 angles: the fraction lost (escaped or plunged) at a = ${as32[0]} to ${as32[as32.length - 1]} r_J in steps of 0.025, and the edges:`); + for (const [k, n] of polars) for (const [name, h] of hosts) { + const r = O.hillScan(h, n, as32, { nPhase: 32 }), lost = r.edgeLost === as32[0] ? `below ${as32[0]}` : f(r.edgeLost, 3); + console.log(` ${k}, ${name}: ${r.rows.map(x => f(x.escapes + x.plunges, 2)).join(' ')}; escaped by ${f(r.edge, 3)}, lost by ${lost}`); + } + } + { + const at = h => O.hillScan(h, [[1, 0, 0]], big, { nPhase: 8 }).edge, atR = h => O.hillScan(h, [[0, 0, -1]], big, { nPhase: 8 }); + console.log(` the Sun's polar-across escape edge at (nu/Omega)^2 = ${f(sun.nu2, 4)}, -1e-4, +1e-4: ${[0, -1e-4, 1e-4].map(d => f(at({ ...sun, nu2: sun.nu2 + d }), 3)).join(', ')}`); + const rG = [0, -1e-4, 1e-4].map(d => atR({ ...sun, Gam: sun.Gam + d })), at925 = r => r.rows.find(x => Math.abs(x.a - 0.925) < 1e-9).escapes * 8; + console.log(` the Sun's retrograde in-plane escape edge at Gam = ${f(sun.Gam, 4)}, -1e-4, +1e-4: ${rG.map(r => f(r.edge, 3)).join(', ')}` + + ` (orbits of 8 escaped at 0.925 r_J: ${rG.map(at925).join(', ')})`); + } + { // a start and its time-reversed mirror (pi - phi): how often their fates differ, around a point mass + const as = grid(0.15, 0.5, 0.05), diff = n => { let d = 0, t = 0; + for (const a of as) for (let p = 0; p < 8; p++) { + const A = O.hillOrbit(O.HOST_KEPLER, O.hillStart(O.HOST_KEPLER, a, n, Math.PI * (p + 0.25) / 8)).fate; + const B = O.hillOrbit(O.HOST_KEPLER, O.hillStart(O.HOST_KEPLER, a, n, Math.PI - Math.PI * (p + 0.25) / 8)).fate; + t++; if (A !== B) d++; + } + return `${d} of ${t}`; }; + console.log(` point mass, a = 0.15 to 0.5 r_H: mirrored pairs whose fates differ: retrograde in the plane ${diff([0, 0, -1])}, polar through the host ${diff([0, 1, 0])}, polar across ${diff([1, 0, 0])}`); + } + { + const s75 = Math.sin(75 * Math.PI / 180), c75 = Math.cos(75 * Math.PI / 180), as75 = grid(0.1, 0.4, 0.05); + for (const [name, h] of [['point mass', O.HOST_KEPLER], ['the Sun', sun]]) { + const row = [[s75, 0, c75], [0, s75, c75]].map(n => as75.map(a => f(O.hillFates(h, a, [n], { nPhase: 32 }).plunges, 2)).join(' ')); + console.log(` tilted 75 deg (prograde side), 32 angles, ${name}: plunged fraction at a = ${as75.join(', ')}: node along y: ${row[0]}; node along x: ${row[1]}`); + } + } + console.log(' (polar orbits are lost to Lidov-Kozai cycles, whose eccentricity reaches 1 at 90 deg; below the "lost" radius the cycle takes longer than 20 turns)'); + { + const gamE = 2 * (1 - EILERS.dv * EILERS.R0 / ve(EILERS.R0)), sunE = { ...sun, Gam: gamE }; + console.log(` retrograde in the plane with Gam = ${f(gamE, 2)} (Eilers et al.'s slope): escaped by ${f(O.hillScan(sunE, [[0, 0, -1]], big, { nPhase: 8 }).edge, 3)} r_J`); + const s64 = (h, n) => { const r = O.hillScan(h, [n], grid(0.3, 1.3, 0.025), { nPhase: 64 }), first = r.rows.find(x => x.plunges > 0); + return `${f(r.edge, 3)} (lost ${f(r.edgeLost, 3)}, first plunge at ${first ? f(first.a, 3) : 'none'})`; }; + console.log(' in the plane with 64 starting angles, escaped (lost, first plunge) [r_J]:'); + console.log(` point mass prograde ${s64(O.HOST_KEPLER, [0, 0, 1])}, retrograde ${s64(O.HOST_KEPLER, [0, 0, -1])}`); + console.log(` the Sun prograde ${s64(sun, [0, 0, 1])}, retrograde ${s64(sun, [0, 0, -1])}; retrograde with Gam = ${f(gamE, 2)} ${s64(sunE, [0, 0, -1])}`); + } + { + // how far from polar plunges reach: orbit normals tilted by delta from polar (i = 90 +- delta), with the line of + // nodes along x or along y, x 16 starting angles each, at a few radii inside the escape edge (a node azimuth om + pi + // is the mirror image of om under z -> -z, so it would repeat the same orbits; at 0 deg the two senses coincide) + const fromPolar = (h, a, deltas) => deltas.map(d => { + const i = (90 - d) * Math.PI / 180, ns = []; + for (const s of [1, -1]) for (const om of [0, 0.5]) ns.push([Math.sin(i) * Math.cos(om * Math.PI), Math.sin(i) * Math.sin(om * Math.PI), s * Math.cos(i)]); + return O.hillFates(h, a, ns, { nPhase: 16 }).plunges; + }); + const dK = grid(0, 20, 2), dS = grid(0, 40, 4); + for (const a of [0.2, 0.3, 0.4]) console.log(` point mass, a = ${a} r_H: plunged fraction at ${dK[0]}-${dK[dK.length - 1]} deg from polar (step 2): ${fromPolar(O.HOST_KEPLER, a, dK).map(x => f(x, 2)).join(' ')}`); + for (const a of [0.2, 0.3]) console.log(` the Sun, a = ${a} r_J: plunged fraction at ${dS[0]}-${dS[dS.length - 1]} deg from polar (step 4): ${fromPolar(sun, a, dS).map(x => f(x, 2)).join(' ')}`); + } + const dirs = O.sphere(48), asIso = grid(0.2, 1.0, 0.05); + console.log('\n orbits facing every way (48 directions x 4 starting angles, grid 0.05 r_J): fractions that stay, escape, and plunge within 1e-3 r_J'); + const iso = {}; + for (const [name, h] of [['point-mass host', O.HOST_KEPLER], ['the Sun in the Galaxy', sun]]) { + iso[name] = O.hillScan(h, dirs, asIso, { nPhase: 4 }); + console.log(` ${name}: half have escaped by ${f(iso[name].edge, 3)} r_J; half are lost (escaped or plunged) by ${f(iso[name].edgeLost, 3)} r_J`); + for (const r of iso[name].rows) console.log(` a = ${f(r.a, 2)} r_J: stay ${f(r.stays, 2)}, escape ${f(r.escapes, 2)}, plunge ${f(r.plunges, 2)}`); + } + console.log(` for the Sun: half escaped by ${f(iso['the Sun in the Galaxy'].edge * rJ / C.au / 1e5, 2)}e5 au`); + const dirs24 = O.sphere(24); + for (const rho of [0.08, 0.12]) { + const e = O.hillScan(O.hostDisk(OORT.A, OORT.B, rho), dirs24, asIso, { nPhase: 4 }).edge; + console.log(` with rho0 = ${rho} (24 directions): (nu/Omega)^2 = ${f(O.hostDisk(OORT.A, OORT.B, rho).nu2, 2)}, half escaped by ${f(e, 3)} r_J`); + } + { + const base = O.hillScan(sun, dirs24, asIso, { nPhase: 4 }), r2 = O.hillScan(sun, dirs24, asIso, { nPhase: 4, rIn: 1e-2 }); + console.log(` the Sun at rho0 = 0.10 with 24 directions, for comparison: half escaped by ${f(base.edge, 3)}, half lost by ${f(base.edgeLost, 3)} r_J`); + console.log(` with plunges counted inside 1e-2 r_J instead (24 directions): half escaped by ${f(r2.edge, 3)}, half lost by ${f(r2.edgeLost, 3)} r_J;` + + ` largest plunged fraction ${f(Math.max(...r2.rows.map(x => x.plunges)), 2)} (against ${f(Math.max(...base.rows.map(x => x.plunges)), 2)})`); + } + const oort = [6.5e4, 1e5, 2e5].map(x => x * C.au / rJ); + console.log(` the Oort cloud's outer limit: 6.5e4 au (Correa-Otto & Calandra's a_crit), 1e5 au, 2e5 au (Dones et al. 2004) = ${oort.map(x => f(x, 2)).join(', ')} r_J`); + if (long) { + console.log(`\n the same (24 directions x 4 angles), followed for 100 turns of the host (${f(turnGyr(100), 1)} Gyr for the Sun):`); + for (const [name, h] of [['point-mass host', O.HOST_KEPLER], ['the Sun in the Galaxy', sun]]) { + const r20 = O.hillScan(h, dirs24, asIso, { nPhase: 4 }), r = O.hillScan(h, dirs24, asIso, { nPhase: 4, orbits: 100 }); + console.log(` ${name}: half escaped by ${f(r.edge, 3)} r_J (${f(r20.edge, 3)} over 20 turns); half lost by ${f(r.edgeLost, 3)} (${f(r20.edgeLost, 3)})`); + } + } +} diff --git a/tests/orbits.mjs b/tests/orbits.mjs new file mode 100644 index 0000000..4c0a3e5 --- /dev/null +++ b/tests/orbits.mjs @@ -0,0 +1,184 @@ +// Checks the orbits study (orbits/model.js) against published values and its own closed forms. Run: npm test. +// Each check prints the source, the published or expected value, the model's value and the tolerance. "Arithmetic" and +// "model-internal" mark checks of the code against a closed form or itself, not against nature; "model" marks a model +// result with no published value to compare. Sources were read in search results and abstracts only +// (orbits/README.md, Sources), except where a check says otherwise; "#37's review" marks values a reviewer read in the +// paper's arXiv source. +import { createRequire } from 'node:module'; +const O = createRequire(import.meta.url)('../orbits/model.js'); +const { C } = O; + +let fails = 0; +const fmt = x => (Math.abs(x) >= 1e-3 && Math.abs(x) < 1e6 ? x.toPrecision(5) : x.toExponential(3)); +function near(name, got, want, tol, src) { + const ok = Number.isFinite(got) && Math.abs(got - want) <= tol; + console.log(`${ok ? 'PASS' : 'FAIL'} ${name}\n model ${fmt(got)} expected ${fmt(want)} +- ${fmt(tol)} ${src}`); + if (!ok) fails++; +} +function check(name, ok, detail, src) { + console.log(`${ok ? 'PASS' : 'FAIL'} ${name}\n ${detail} ${src}`); + if (!ok) fails++; +} + +// 1. Kepler's third law across the planets. +const JPL = 'JPL approximate elements, Table 1 (1800-2050; checked against the SSD page in #37\'s review); GM_sun IAU 2015 B3; masses DE430'; +const mu = O.planetMassFraction(), ex = O.PLANETS.map(p => O.kepler(p).excess), big = Math.max(...ex.map(Math.abs)); +check('In this 1800-2050 fit, n^2 a^3 matches GM_sun for every planet to within the planets\' total mass over the Sun\'s', + ex.every(x => Math.abs(x) <= mu), + `largest |n^2 a^3 / GM_sun - 1| = ${fmt(big)} (${O.PLANETS[ex.map(Math.abs).indexOf(big)].name}); sum of m/M_sun = ${fmt(mu)}` + + ' (an observed size, not a physical bound: smeared into rings, the other planets\' pull alone gives up to 1.36e-3, for Uranus)', JPL); +{ + const inner = Math.max(...ex.slice(0, 4).map(Math.abs)); + near('The inner four planets: largest |n^2 a^3 / GM_sun - 1|', inner, 0, 5e-5, + `${JPL}; a regression bound, which a GM_sun error beyond -1.3e-5 or +5.5e-5, or a century-length error beyond -0.6e-5 or +2.7e-5, would break`); +} +{ + const xs = O.PLANETS.map(p => Math.log(p.a)), mx = xs.reduce((s, x) => s + x, 0) / xs.length; + const tolP = 0.5 * mu * xs.reduce((s, x) => s + Math.abs(x - mx), 0) / xs.reduce((s, x) => s + (x - mx) ** 2, 0); + near('Kepler\'s exponent: P ~ a^p over 0.39 to 30 au', O.keplerExponent(), 1.5, tolP, + `${JPL}; tolerance 0.5 mu sum|dln a| / sum(dln a)^2, the most the first check allows: model-internal, implied by it but independent of GM_sun`); +} + +// 2. Where a Kepler region ends. +{ + const g = O.galaxy(), oortAt = R => { // Oort constants from the model's own curve: A = (v/R - dv/dR)/2, B = -(v/R + dv/dR)/2 + const v = g.v(R), dv = v / R * g.slope(R); + return { A: (v / R - dv) / 2, B: -(v / R + dv) / 2 }; + }; + const k = oortAt(1e-5); + near('4A/Omega from the model Galaxy\'s curve 1e-5 kpc from Sgr A*, where a point mass rules: Hill\'s 3', O.densityRatio(k.A, k.B), 3, 0.005, + 'model-internal (densityRatio against the curve\'s own Oort constants)'); + const a = O.PLANETS[4].a * C.au, q = 1 / O.PLANETS[4].sunOver, o = O.oortKepler(Math.sqrt(C.GMsun / a ** 3) / C.kmskpc); + near('Jacobi radius with point-mass Oort constants / Hill radius a (m/3M)^(1/3), for Jupiter', O.jacobi(C.GMsun * q, o.A, o.B) / O.hill(a, q), 1, 1e-12, 'model-internal'); +} +near('The Sun\'s tidal radius in the Galaxy [1e5 au], from Bovy 2017\'s A = 15.3, B = -11.9 km/s/kpc', O.jacobi(C.GMsun, 15.3, -11.9) / C.au / 1e5, 2.8, 0.05, + 'Correa-Otto & Calandra 2019 (MNRAS 490, 2495): "r_J ~ 2.8 x 10^5 au" (#37\'s review), from Jiang & Tremaine\'s constants (2.78e5 au), so this confirms ' + + 'the formula on nearby inputs; tolerance the rounding of 2.8'); + +// 3. Sgr A*: S2's orbit and the stars around it. +const G20 = 'GRAVITY Collaboration 2020 (A&A 636, L5), read in a transcription and in #37\'s review'; +const s2 = O.orbitOf(O.S2), s2M = O.orbitOf(O.S2, O.S2.M); +near('S2: Kepler\'s third law returns GRAVITY\'s fitted mass [1e6 M_sun]', s2.keplerMass / 1e6, O.S2.M / 1e6, 0.012, + `${G20}, Table E.1; consistency with their own fit (tolerance its 0.012 error), not a measurement`); +near('S2: Schwarzschild precession per orbit [arcmin]', s2M.precessionArcmin, 12.1, 0.1, + `${G20}, appendix B: "the 12.1' precession"; tolerance one unit in the last digit (the formula with their Table E.1 M, a, e gives 12.16')`); +near('S2: pericentre distance [au]', s2M.periAU, 120, 5, `${G20}, sect. 1.2: "pericentre at 120 AU", rounded to 10 au`); +near('S2: speed at pericentre [km/s]', s2M.periSpeed, 7700, 50, `${G20}, sect. 1.2: "7700 km/s", rounded to 100 km/s`); +{ + const K = O.CUSP, M = O.SGRA.M, r2 = [K.M1hi, K.M1, K.M1lo].map(m => O.cuspRadius(2, M, m)); + check('The stars inside r weigh twice Sgr A* at 3 to 4 pc in the literature; the cusp model brackets it', + r2[0] <= 3 && r2[2] >= 4, + `model ${fmt(r2[0])} to ${fmt(r2[2])} pc (middle ${fmt(r2[1])}) for 0.5-1.5e6 M_sun inside 1 pc and density ~ r^-1.13; radii past the 3 pc ` + + 'break extrapolate the cusp, where the density falls faster, so they are lower limits and the upper side holds a fortiori', + 'Schodel et al. 2018 sect. 4.5 (7.8e6 M_sun inside 3 pc, "roughly twice" Sgr A*), Alexander 2005 (2m reached by <~4 pc), Feldmeier-Krause et al. ' + + '2017 sect. 3.3.2 (4.0 +2.2/-1.1 pc with M_BH = 4e6 and Merritt\'s 2004 definition), GRAVITY Collaboration 2024 sect. 4.3 (3.9 pc in their cusp ' + + 'simulation); all #37\'s review; inputs Schodel et al. 2009, 2018'); + near('The cusp model\'s stars inside 3 pc [1e6 M_sun] (middle mass inside 1 pc)', O.cuspMass(3) / 1e6, 7.8, 0.6, + 'Schodel et al. 2018 sect. 4.5: "7.8+-0.6 x 10^6 M_sun" within 3 pc (#37\'s review)'); + near('The cusp model\'s stars inside 0.01 pc [M_sun]', O.cuspMass(0.01), 180, 30, 'Schodel et al. 2018: "180+-30" within 0.01 pc (#37\'s review)'); + near('Kepler inside 0.1 pc of Sgr A*: dln v/dln r', O.cuspSlope(0.1, M), -0.5, 0.01, 'model (Sgr A* plus the cusp)'); + let lo = 1e-3, hi = 30; + for (let i = 0; i < 200; i++) { const m = Math.sqrt(lo * hi); if (O.cuspSlope(m, M) < -0.25) lo = m; else hi = m; } + near('Where dln v/dln r = -1/4: the closed form against bisection [pc]', O.cuspSlopeRadius(-0.25, M), lo, 1e-9, 'model-internal'); +} + +// Special functions the model uses: the complete elliptic integral and the incomplete gamma function. +near('ellipticK(1/sqrt 2) [the lemniscate value Gamma(1/4)^2 / (4 sqrt pi)]', O.ellipticK(Math.SQRT1_2), 1.8540746773013719, 1e-14, 'arithmetic'); +for (const x of [0.25, 1, 4]) { + const erf = { 0.25: 0.5204998778130465, 1: 0.8427007929497149, 4: 0.9953222650189527 }[x]; // erf(sqrt x) + near(`gammaP(1/2, ${x}) = erf(sqrt ${x})`, O.gammaP(0.5, x), erf, 1e-13, `arithmetic (${x < 1.5 ? 'series' : 'continued fraction'})`); +} + +// 4. The Galaxy. +const g = O.galaxy(), g0 = O.galaxy(O.MWP14, { bh: 0 }); +near('MWPotential2014 normalisation identity: v_c(8 kpc) without Sgr A* [km/s] (G and the shapes cancel)', g0.v(8), 220, 1e-9, + 'model-internal (parameters as in galpy\'s source)'); +{ + const T1 = 'Bovy 2015, Table 1 (arXiv source, mwpotential2014.txt), as #37\'s re-review read it; tolerance the rounding of the printed value'; + near('MWPotential2014: bulge mass [1e10 M_sun]', g0.M.bulge / 1e10, 0.5, 0.05, T1); + near('MWPotential2014: disk mass [1e10 M_sun]', g0.M.disk / 1e10, 6.8, 0.05, T1); + near('MWPotential2014: mass inside 60 kpc, as v^2 R/G [1e11 M_sun]', g0.v(60) ** 2 * 60 / C.G / 1e11, 4.1, 0.05, `${T1} (the true sphere mass is 4.05)`); + near('MWPotential2014: dln v_c/dln R at R0 = 8 kpc', g0.slope(8), -0.10, 0.005, T1); + near('MWPotential2014: dark-matter density at R0 [M_sun/pc^3]', g0.haloDensity(8), 0.008, 0.0005, T1); +} +near('MWPotential2014: halo mass inside 245 kpc [1e12 M_sun]', g0.parts(245).halo * 245 / C.G / 1e12, 0.8, 0.05, + 'Bovy 2015, Table 1: M_vir = 0.8e12 M_sun with r_vir = 245 kpc (#37\'s review); tolerance the rounding of 0.8'); +near('The disk\'s mass inside a sphere of 1e4 kpc / its total (Gauss\'s theorem by quadrature)', g.diskSphereMass(1e4) / g.M.disk, 1, 1e-3, + 'model-internal (the Miyamoto-Nagai mass outside 1e4 kpc is about 3e-4 of the total)'); +near('Disk sphere mass, Kuzmin limit (b -> 0): fraction inside 8 kpc = 1 - a / sqrt(r^2 + a^2)', ((G) => G.diskSphereMass(8) / G.M.disk)(O.galaxy({ ...O.MWP14, b: 1e-9 })), + 1 - 3 / Math.hypot(8, 3), 1e-8, 'arithmetic (closed form)'); +near('Disk sphere mass, Plummer limit (a = 0): fraction inside 0.3 kpc = r^3 / (r^2 + b^2)^(3/2)', ((G) => G.diskSphereMass(0.3) / G.M.disk)(O.galaxy({ ...O.MWP14, a: 0 })), + 0.3 ** 3 / (0.09 + 0.28 ** 2) ** 1.5, 1e-8, 'arithmetic (closed form)'); +{ + const Rs = [5, 8.122, 15, 25], ve = R => 229.0 - 1.7 * (R - 8.122); + const rel = Rs.map(R => (g.v(R) / g.v(8.122)) / (ve(R) / ve(8.122)) - 1); + check('The shape of MWPotential2014\'s curve, v(R)/v(R0), within 5% of Eilers et al.\'s from 5 to 25 kpc', rel.every(r => Math.abs(r) < 0.05), + `ratio to Eilers - 1 = ${rel.map(r => r.toFixed(3)).join(', ')} at ${Rs.join(', ')} kpc; the level differs by ${(g.v(8.122) / 229 - 1).toFixed(3)} (220 against 229 km/s)`, + 'Eilers et al. 2019 (ApJ 871, 120), eq. 7 (#37\'s review); tolerance their 2-5% systematic uncertainty out to about 20 kpc (the slope\'s 0.46 ' + + 'km/s/kpc systematic gives 0.6% at 5 kpc and 3.9% at 25 kpc)'); + const sl = Rs.map(R => g.slope(R)), se = Rs.map(R => -1.7 * R / ve(R)); + check('Flat, not Kepler, from 5 to 25 kpc: |dln v/dln R| < 0.25 in the model and in Eilers et al.\'s fit', + sl.every(s => Math.abs(s) < 0.25) && se.every(s => Math.abs(s) < 0.25), + `model ${sl.map(s => s.toFixed(3)).join(', ')}; Eilers ${se.map(s => s.toFixed(3)).join(', ')}; Kepler -0.5`, 'Eilers et al. 2019; model'); +} + +// 5. Thin disks: the planets' tilts to the invariable plane. +const SS = 'Souami & Souchay 2012 (A&A 543, A133), as quoted in search text, not confirmed in the paper; tolerance covers epoch and element differences'; +near('Jupiter\'s inclination to the invariable plane [deg]', O.tiltToInvariable(O.PLANETS[4]), 0.3219, 0.01, SS); +near('Saturn\'s inclination to the invariable plane [deg]', O.tiltToInvariable(O.PLANETS[5]), 0.9254, 0.01, SS); + +// 6. Hill's problem: which orbits a body keeps (20 turns of the host, 8 starting angles each unless stated). +{ + const K = O.HOST_KEPLER, sun = O.hostDisk(15.3, -11.9, 0.10); + const NV = 'Nesvorny et al. 2003, as Shen & Tremaine 2008 (AJ 136, 2453) quote them: semi-major axes of "~0.7 r_H for retrograde satellites and ' + + '~0.4 r_H for prograde ones", for nearly circular orbits near the ecliptic (#37\'s review)'; + const esc = (h, a, n) => O.hillFates(h, a, [n], { nPhase: 8 }).escapes, pro = [esc(K, 0.4, [0, 0, 1]), esc(K, 0.6, [0, 0, 1])]; + check('Point-mass host: prograde circular orbits mostly kept at 0.4 r_H, mostly lost by 0.6', pro[0] < 0.5 && pro[1] >= 0.5, + `fraction escaped ${pro[0].toFixed(2)} at 0.4 r_H (must be < 0.5), ${pro[1].toFixed(2)} at 0.6 r_H (must be >= 0.5)`, 'model'); + const edgePro = O.hillScan(K, [[0, 0, 1]], [0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7], { nPhase: 8 }).edge; + near('Point-mass host: radius where half the prograde circular orbits in the plane have escaped [r_H]', edgePro, 0.4, 0.1, + `${NV}; tolerance covers their different criterion and integration time`); + const gRet = []; for (let a = 0.6; a <= 1.0001; a += 0.025) gRet.push(+a.toFixed(3)); + const edgeRet = O.hillScan(K, [[0, 0, -1]], gRet, { nPhase: 8 }).edge; + check('Point-mass host: the retrograde in-plane edge lies between 0.7 r_H (near-circular, near-ecliptic orbits) and r_H (some coplanar ones)', + edgeRet >= 0.7 && edgeRet <= 1, `half escaped by ${fmt(edgeRet)} r_H (must be 0.7 to 1)`, + `${NV}; Shen & Tremaine 2008 abstract: "some coplanar retrograde satellites ... can survive out to ~r_H" (#37's review)`); + const r85 = [esc(K, 0.85, [0, 0, -1]), esc(sun, 0.85, [0, 0, -1])]; + check('Retrograde in the plane at 0.85 r_J: mostly lost around a point mass, kept by the Sun (its flatter curve, Gam = 2.25, not its vertical tide)', + r85[0] >= 0.5 && r85[1] <= 0.25, + `fraction escaped ${r85[0].toFixed(2)} (point mass; must be >= 0.5), ${r85[1].toFixed(2)} (the Sun; must be <= 0.25)`, 'model'); + { + const s0 = O.hillStart(sun, 0.3, [0.6, 0, 0.8], 0.7), end = O.hillOrbit(sun, s0, { orbits: 20 }); + const EJ = ([x, y, z, vx, vy, vz]) => (vx * vx + vy * vy + vz * vz) / 2 - sun.Gam * x * x / 2 + sun.nu2 * z * z / 2 - sun.Gam / Math.hypot(x, y, z); + const dE = EJ(end.s) - EJ(s0); + check('The Sun in the Galaxy: Jacobi integral |v|^2/2 - Gam x^2/2 + nu2 z^2/2 - Gam/r kept over 20 turns (a = 0.3, tilted orbit, which stays)', + end.fate === 'stays' && Math.abs(dE) <= 1e-6, `change ${fmt(dE)} (must be within 1e-6); fate ${end.fate} (must be stays)`, + 'model-internal (a conserved quantity of the equations of motion)'); + } + { + const pol = O.hillFates(sun, 0.3, [[1, 0, 0]], { nPhase: 8 }); + check('The Sun: polar circular orbits at 0.3 r_J are lost within 20 turns, by plunging (Lidov-Kozai), not by escaping', + pol.plunges >= 0.5 && pol.escapes === 0, `plunge ${pol.plunges.toFixed(2)} (must be >= 0.5), escape ${pol.escapes.toFixed(2)} (must be 0)`, + 'model (Lidov 1962, Kozai 1962: the eccentricity reaches 1 at 90 deg)'); + const L = O.hillScan(K, [[1, 0, 0]], [0.1, 0.2], { nPhase: 8 }); + check('Point-mass host: polar orbits (plane across the host) are lost by plunging between 0.1 and 0.2 r_H, before any escapes', + L.rows.every(r => r.escapes === 0) && L.edgeLost > 0.1 && L.edgeLost <= 0.2, + `half lost by ${fmt(L.edgeLost)} r_H (must be above 0.1 and at most 0.2); escaped fractions ${L.rows.map(r => r.escapes.toFixed(2)).join(', ')} (must all be 0)`, + 'model (the edgeLost path)'); + } + const Om = 27.2 * C.kmskpc, want = (4 * Math.PI * C.GMsun * 0.10 / C.pc ** 3 + 2 * (15.3 ** 2 - 11.9 ** 2) * C.kmskpc ** 2) / Om ** 2; + near('The Sun in the Galaxy: (vertical tidal frequency / Omega)^2', sun.nu2, want, 1e-12 * want, 'arithmetic in SI (Poisson\'s equation), independent of C.G'); + const dirs = O.sphere(12), fz = [0.3, 0.6].map(a => O.hillFates(sun, a, dirs, { nPhase: 2 })); + check('The Sun: no orbit, facing any way, escapes from 0.3 r_J (0.85e5 au); most escape by 0.6 r_J (1.7e5 au)', + fz[0].escapes === 0 && fz[1].escapes >= 0.5, + fz.map((r, i) => `at ${[0.3, 0.6][i]} r_J: stay ${r.stays.toFixed(2)}, escape ${r.escapes.toFixed(2)}, plunge ${r.plunges.toFixed(2)}`).join('; ') + + ' (12 directions x 2 angles)', 'model'); + const rJ = O.jacobi(C.GMsun, 15.3, -11.9), edge = O.hillScan(sun, dirs, [0.2, 0.3, 0.4, 0.5, 0.6], { nPhase: 2 }).edge * rJ / C.au; + check('The Sun\'s all-directions escape edge lies within the Oort cloud\'s quoted outer limits, 6.5e4 to 2e5 au', edge >= 6.5e4 && edge <= 2e5, + `half have escaped by ${fmt(edge)} au (12 directions x 2 angles, grid 0.1 r_J from 0.2 r_J = 5.7e4 au; the tide alone, no passing stars)`, + 'Correa-Otto & Calandra 2019 sect. 4.3: a_crit ~ 6.5e4 au, set by the frequency of stellar passages acting with the tide (#37\'s review); ' + + 'Dones et al. 2004: as far as 2e5 au, as cited in search text; a wide window: at fixed r_J the edge stays between about 1.20 and 1.33e5 au for Gam from 0.5 to 2 times its value (in steps of 0.025), so this checks the scale, not the tide\'s details'); +} + +console.log(fails ? `\n${fails} check(s) failed` : '\nall orbits checks pass'); +process.exit(fails ? 1 : 0);