Usage
Standalone vs PROTEUS-coupled mode
This page documents standalone Zalmoxis use (python -m zalmoxis -c <config>.toml).
When Zalmoxis is driven from inside the PROTEUS framework, none of the TOML sections shown here are read.
PROTEUS reads its own [interior_struct.zalmoxis] block and calls zalmoxis.solver.main() directly.
For the PROTEUS recipe, see Coupling to PROTEUS.
Quick start
Run the default configuration (1 Earth-mass planet with a PALEOS iron core and MgSiO3 mantle):
python -m zalmoxis -c input/default.toml
Output files appear in output/, or in the folder [Output] output_dir names. The PALEOS data files must be downloaded first (see installation).
What happens when you run Zalmoxis
Zalmoxis computes the internal structure of a planet. Given a total mass and composition (which layers the planet has, and what each layer is made of), it finds the radial profiles of pressure, density, gravity, and temperature from the center to the surface. The result is a self-consistent model of the planet's interior: how big it is, where the core-mantle boundary sits, and how conditions change with depth.
For the mathematical details of how the solver works, see the process flow explanation.
Modifying the configuration
All input parameters live in a single TOML file. To change the planet mass, for example, open input/default.toml and edit the [InputParameter] section.
Before:
[InputParameter]
planet_mass = 1.0 # in Earth masses
After (5 Earth-mass super-Earth):
[InputParameter]
planet_mass = 5.0 # in Earth masses
Then re-run:
python -m zalmoxis -c input/default.toml
For the full list of parameters (EOS selection, temperature modes, solver settings, output options), see the configuration reference.
A planet with an ice layer
A third layer of water ice above the mantle needs 3 changes in a copy of input/default.toml:
- a mantle mass fraction above 0; the ice layer takes the rest of the mass;
- an EOS for the ice layer;
- a surface temperature below 647 K, the critical point of H\(_2\)O. The configuration check refuses a hotter surface with an H\(_2\)O layer in every temperature mode but
isothermal.
[AssumptionsAndInitialGuesses]
core_mass_fraction = 0.325
mantle_mass_fraction = 0.575 # the ice layer takes the rest: 0.1 of the planet mass
temperature_mode = "adiabatic"
surface_temperature = 300
[EOS]
ice_layer = "PALEOS:H2O"
Run it as before:
python -m zalmoxis -c my_ice.toml
In planet_profile.txt of this run:
- The last 18 of the 150 nodes lie in the ice layer, which starts at the enclosed mass \(0.9 M\).
- The temperature follows the H\(_2\)O adiabat from 300 K at the surface to 509 K at the deepest ice node, near 11.5 GPa.
- The adiabat continues through the mantle and the core to 929 K at the centre.
- With
ice_layer = "Seager2007:H2O", an EOS without temperature dependence, every ice node stays at 300 K. - The
Seager2007:H2Orun ends in a surface stop on macOS arm64: the rows past the stop hold zero pressure, and the solver logs the surface-stop warning. On another platform the same run can end with or without a surface stop, so check every run; Check the surface pressure of a result explains the check.
Layer boundaries inside a node segment explains how the adiabat crosses the boundary between 2 nodes.
Output files
python -m zalmoxis writes all its files into its output folder: the existing folder that [Output] output_dir names, or else output/ of the Zalmoxis root (created on the first run). The folder looks like:
output/
├── planet_profile.txt # radial profiles (single run)
├── planet_profile5.0.txt # radial profiles (batch run, mass in filename)
├── calculated_planet_mass_radius.txt # summary: mass and radius per run
├── planet_profile.png # 6-panel structure plot (if plots_enabled)
├── mantle_PT_profile.pdf # mantle P-T plot (if plots_enabled and the mantle EOS uses melting curves)
├── zalmoxis.log # log of python -m zalmoxis
├── pressure_profiles.txt # iteration diagnostics (DEBUG, command-line run)
└── density_profiles.txt # iteration diagnostics (DEBUG, command-line run)
The grid runner tools/grids/run_grid.py does not use output_dir. It writes grid_summary.csv, a <label>.json result per grid point and, with [output] save_profiles = true, a <label>.csv profile per grid point into the folder that [output] dir of the grid file names, relative to the Zalmoxis root, by default output/grid_results/. It loads its base config with load_zalmoxis_config, which checks output_dir, so a base config that sets output_dir must still name an existing, writable folder, although the grid runner writes nothing there.
The EOS caches are written outside the output folder: the binary cache <table>.cache.pkl beside each unified PALEOS table file (under data/ for the downloaded tables), and the PALEOS API cache in data/EOS_PALEOS_API/ of the Zalmoxis root.
Profile files
When data_enabled = true (the default), the solver writes radial profiles as tab-separated text:
planet_profile.txt: Full radial profile for a single-mass run.planet_profile{mass}.txt: Same format, with the planet mass (in Earth masses) appended. Produced by batch runs to distinguish between different masses.
The columns are:
| Column | Unit | Description |
|---|---|---|
radius |
m | Distance from the planet center |
density |
kg/m\(^3\) | Local density |
gravity |
m/s\(^2\) | Local gravitational acceleration |
pressure |
Pa | Local pressure |
temperature |
K | Local temperature |
mass_enclosed |
kg | Total mass enclosed within this radius |
The first row is the center (r = 0) and the last row is the surface. Rows beyond the point where the ODE terminal event fired are the surface: they keep the mass at the stop and zero pressure, their gravity is that of the stop mass at their radius, and their density is the EOS density at the target surface pressure (zero for a result without a pressure solve, density_from_eos False).
Check the surface pressure of a result
zalmoxis.solver.main() returns a dict with the same profiles: result['pressure'][-1] is the pressure \(P(R)\) at the outer radius, and the target is target_surface_pressure of the configuration.
A profile whose integration stopped before the outer radius is padded: result['padded'] is True and the rows past the stop hold zero pressure. When the solver accepts a padded profile, it logs a warning (The accepted profile ends in a surface stop: ...); in an adiabatic temperature mode with the mantle and ice boundary in the padded top cell, it logs a second one, which names the nodes that miss the adiabat: every node below the cell with the surface anchor (adiabatic), only the padded node with the CMB anchor (adiabatic_from_cmb).
The accept test passes a padded profile when the target is below pressure_tolerance (\(10^9\) Pa by default), so read padded and compare \(P(R)\) with the target before you use the surface values.
Padded accepts explains when this happens, and the tutorial Check that a structure meets its surface pressure shows the check step by step.
Summary file
calculated_planet_mass_radius.txt: Two-column summary (calculated mass in kg, calculated radius in m). Each row corresponds to one completed simulation. Appended across successive runs, so multiple runs accumulate in one file.
Iteration profiles (optional)
When the Python logging level is set to DEBUG and the configuration names a folder in debug_profile_dir, the solver writes per-iteration profiles into that folder:
pressure_profiles.txt: Pressure vs. radius for every iteration of the pressure adjustment loop.density_profiles.txt: Density vs. radius for every iteration.
Enable with logging.getLogger('fwl.zalmoxis').setLevel(logging.DEBUG). Set debug_profile_dir in the [Output] table of the TOML file, or as a key of the configuration dict that you pass to solver.main(); it must name a folder that exists. load_zalmoxis_config checks the key; solver.main() does not, so call validate_config on a dict that you build yourself. The command-line run (python -m zalmoxis) sets the key to its output folder, output_dir, when it is not set; it logs at INFO, so it writes the files only when the level of fwl.zalmoxis is DEBUG. Without the key, a DEBUG solve logs and writes no profile file. These files are useful for diagnosing convergence behavior. They grow large quickly (about 50 MB each for a 1 Earth-mass planet). The files start again at the first pressure solve of each structure solve (each call of _solve, so each Newton step and each retry of solver.main()), so after a run they hold the last structure solve; a later run below DEBUG or without the key leaves them as they are.
Adjust tolerance_outer, tolerance_inner, max_iterations_outer, max_iterations_inner in the [IterativeProcess] block (see Configuration) if convergence is slow.
Plots (optional)
When plots_enabled = true in the [Output] section, Zalmoxis automatically generates profile plots after each run. To enable:
[Output]
plots_enabled = true
The profile plot is a six-panel figure showing the radial profiles of density, pressure, temperature, gravity, phase state, and mass enclosed:

A call of post_processing with id_mass puts the mass label into the names of the plot files, as it does for the profiles (planet_profile5.0.png, mantle_PT_profile5.0.pdf).
Example: 1 \(M_\oplus\) planet with a PALEOS iron core and MgSiO\(_3\) mantle at \(T_s\) = 3000 K (adiabatic mode). The dashed vertical line marks the core-mantle boundary (CMB).
- Density (top left): drops from ~14,000 kg/m\(^3\) at the center (iron core) to ~3,000 kg/m\(^3\) at the surface (silicate mantle). The sharp step at the CMB reflects the iron-to-silicate transition.
- Pressure (top center): decreases monotonically from ~350 GPa at the center to 1 atm at the surface, on a logarithmic scale.
- Temperature (top right): follows the adiabatic gradient from 3000 K at the surface to ~8000 K at the center. The steeper gradient in the iron core reflects iron's different \(\nabla_{\mathrm{ad}}\).
- Gravity (bottom left): rises through the core (as enclosed mass grows faster than \(r^2\)), peaks near the CMB at ~10 m/s\(^2\), and stays roughly constant through the mantle.
- Phase state (bottom center): colored bars showing the thermodynamically stable phase at each depth, read from the PALEOS table's phase column. Liquid iron in the core (at 3000 K surface temperature), bridgmanite (solid MgSiO\(_3\)) in the mantle, with a thin liquid layer near the surface.
- Mass enclosed (bottom right): enclosed mass as a function of radius. The CMB is visible as the kink where the slope changes from the dense core to the lighter mantle.
Core arrays
Every solve whose profile reaches the core mass returns result['core'] (otherwise it is None, as for a pass cut before its pressure solve): r, m, P, rho, g, T (m, kg, Pa, kg/m\(^3\), m/s\(^2\), K) at the core nodes plus a node at the core mass, the core-mantle boundary (CMB); phase per node (1 inner core, 0 outer core); w_<el> per light element; and M_ic [kg], R_icb [m], P_icb [Pa], solid_above_icb_mass_fraction and the flag solid_above_icb, all at the inner-core mass of the solved layers (P_icb is the pressure at M_ic by the rule of the inner-core boundary, never below the pressure of the node at the core mass); w_layers holds the light-element fractions of each layer. The CMB node comes from an event of the structure integration at the core mass. Every accepted solve asserts that this node holds the core mass to \(10^{-10}\) (core_cmb_node), that each core-array density is that of its layer EOS to \(10^{-6}\) (core_density_eos), that the light-element masses of the nodes equal \(M_\mathrm{ic} w_\mathrm{ic} + M_\mathrm{oc} w_\mathrm{oc}\) of the layer compositions to \(10^{-10}\) (core_element_mass) and that no core node lies outside the table of its side (core_table_box). The node at the core mass takes the layer of the core just below it for its density and phase.
Every result carries 3 keys of the inner-core boundary (ICB) test, which hold values only with a two-layer core:
icb_convergedis True unless the returned pass fails the ICB tests (inner-core boundary); a solve with no ICB rule keeps True.icb_superheat[K] is the superheat \(S\) of the outer-core liquid at the ICB on an adiabat withcore_liquidus: positive where the liquid lies above the melting curve and negative below it, taken at the centre with no inner core and, with a core solid to the core-mantle boundary, at the CMB point with the core-side temperature of the temperature at the CMB point. It isNoneon a given profile and withoutcore_liquidus.icb_adiabat[kg] is the inner-core mass that the adiabat of the returned pass took. It isNonewithout an adiabat or without a two-layer core.
A solve with a core temperature table (core_temperature_arrays) carries 3 more keys:
core_T_usedis True when the table set the core temperature, and False when the core has no temperature-dependent equation of state and the table is unused; an unused table counts no node in the next 2 keys.core_T_nodes_outsideis the number of core nodes whose pressure lies outside the table.core_T_max_excessis the largest distance of such a node beyond the table, as a fraction of the table rangeP_arr[-1] - P_arr[0]; 0.0 when no node lies outside. Above 0.1 the result is not accepted (convergedis False).
Parameter grids
To sweep over combinations of parameters and plot the results, see the parameter grids guide.
See also
- First run walks through a single Earth-mass run from start to finish.