Skip to content

Repository files navigation

OA Mass-Radius Model

OA is a compact, explainable interior model for the interview exercise: computing and plotting mass-radius relationships for differentiated planets. The implementation is inspired by the following works: Seager et al. (2007) and Huang et al. (2022).

The model is intentionally staged:

  1. Modified-polytrope EOS and single shooting.
  2. Double shooting to a fitting mass.
  3. Seager-inspired cold EOS regimes for Fe, MgSiO3, and H2O.
  4. Optional low-pressure EOS sensitivity experiments.
  5. Thin isothermal ideal-gas atmosphere.
  6. MAGRATHEA-like explicit ideal-gas envelope layer with self-gravity.
  7. A small emulator trained on OA outputs.

Environment

cd /home/gugli/OA_model
source .venv/bin/activate

Run Tests

python -m pytest -q

Train and Evaluate the OA Emulator

Task 2 uses the completed clean dataset at data/emulator_dataset_30k_checkpoints/emulator_dataset_clean.csv (with the identical figures/emulator_dataset_clean.csv as a fallback). It never starts dataset generation implicitly. Run the complete candidate comparison, grouped-curve selection, evaluation, plotting, and benchmark with:

python scripts/train_emulator.py

Results are written to data/emulator_task2/, the selected inference bundle is data/emulator_task2/selected_emulator.joblib, and diagnostic plots use the figures/emulator_task2_*.png prefix. Repeating the same command with the same dataset and training configuration validates and reuses the cached results; changing either invalidates that cache.

The model is a single fast surrogate for OA within the sampled parameter domain and the fixed 0.1-bar transit-pressure convention. It is not an independent physical model and should not be used for extrapolation.

Build and Execute the Extended Notebook

The Python builder is the source of truth for the extended notebook. Generate it, then execute every cell with an unlimited notebook timeout:

python scripts/build_mr_exercise_notebook.py
jupyter nbconvert --to notebook --execute OA_mass_radius_exercise_extended.ipynb --inplace --ExecutePreprocessor.timeout=-1

If Task 2 outputs are already complete, the notebook loads the cached artifacts. If they are missing, it invokes scripts/train_emulator.py; it does not regenerate the Task 1 dataset.

Execute the Original Notebook

jupyter nbconvert --to notebook --execute OA_mass_radius_model.ipynb --inplace

Important Assumptions

The fiducial condensed model is cold and temperature-independent. EOS-regime switching is not treated as a physical phase diagram. Bare-solid radii are defined near zero pressure, while atmospheric transit radii are defined at 100 mbar. The water EOS is a Seager et al. (2007)-style bulk-radius construction, not a detailed near-surface water mineralogy model. TFD is conditional and is not implemented in v1 because the validated 0.1-15 Earth-mass grid remains below the Seager TFD thresholds.

The explicit gas-envelope option treats the envelope as the outermost mass layer, so the gas mass contributes to enclosed mass during the hydrostatic integration. Its default gas EOS remains intentionally simple: ideal H/He, isothermal above 100 bar and adiabatic below. Warnings are emitted when the gas base pressure exceeds 0.1 GPa, when the gas mass fraction exceeds 1%, or when deep-envelope temperatures leave the conservative pedagogical regime.

About

Interior model for cold, spherical, fully differentiated rocky exoplanets. Plus ML emulator of OA.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages