Solver method tuning
Use this page to choose an integrator, set its tolerances, get a stalled run moving, and decide what to do when a run leaves the EOS tables or reads table values with no EOS data behind them. _EnergyParameters.solver_method (see src/aragog/parser.py) selects the integrator for the stiff time integration. It accepts 3 values: "cvode" (the default), "radau" and "bdf".
Default is CVODE
Normal PROTEUS runs use solver_method = "cvode" with use_jax_jacobian = true. The other two values are fallback paths, not equivalents.
Choose an integrator
solver_method |
Solver | When to use |
|---|---|---|
"cvode" |
SUNDIALS CVODE via scikits_odes |
The default for all normal runs. Modified Newton with a cached Jacobian, the solver class of SPIDER. Required for the JAX-traced analytic Jacobian path. |
"radau" |
scipy solve_ivp(method="Radau") |
Pure-Python fallback when scikits_odes is not installed. Fully implicit. Reliable on smooth profiles, but stalls at the rheological transition on long cooling runs. |
"bdf" |
scipy solve_ivp(method="BDF") |
Pure-Python fallback. Cheaper per step than Radau, weaker at sharp Jacobians. Use it only for quick smoke tests. |
If you select "cvode" and scikits_odes is missing, the solver logs a warning and falls back to Radau. See Installation: production solver path.
Pick tolerances
Start with solver.atol (absolute) and solver.rtol (relative) both at 1e-8. Loosen them only for a quick check, because a loose tolerance can lock CVODE (see below). The solver floors atol at \(10^{-8}\) and uses rtol as given.
| Use | atol |
rtol |
What you get |
|---|---|---|---|
| Coupled run, CVODE + JAX | 1e-8 (from atol_temperature_equivalent) |
1e-8 |
The PROTEUS defaults for Aragog in proteus.config._interior. Tight enough that the energy-conservation checks close. |
| Standalone smoke test | 1e-7 |
1e-7 |
Lets the integrator march through the rheological transition in seconds. Acceptable for a first-run check, not for paper plots. With CVODE it logs the tolerance warning. Not measured for locks. |
| Tight verification or parity test | 1e-10 (applied as 1e-8) |
1e-10 |
For SPIDER bit-parity diagnostics. Wall time roughly doubles. |
When a CVODE call stalls
A call that stalls or runs far slower than expected can be locked at the convective switch, which is the convective mask together with the \(\kappa_h\) floor. Check for a lock first, because its remedy is different.
Signs of a lock:
- The step stays at one small value.
- The entropy difference across one basic node oscillates with period 2 (around zero in the measured locks, all at \(D = 0\)).
- In the measured locks CVODE used about 1.4 RHS evaluations per step (1.14 in a recorded run on the quasi_steady core) and evaluated its Jacobian about every 50 to 60 steps. With INFO logging, the
CVODE statsline showsrhs_wrap/nstand a smalllast_step.
A lock can run for a long time without an error, or end in CV_TOO_MUCH_WORK once max_steps is used up in one output interval.
What to do:
- For a lock at the default
convective_threshold = 0, setrtolandatolto1e-8. Locks were seen atrtol1e-6and not at1e-8. A CVODE run logs one warning whensolver.rtolis above1e-8. - For a stall without this pattern, raise
max_steps. The PROTEUS retry ladder raisesmax_stepsand relaxesrtol, and the relaxedrtolcan itself be above1e-8(see PROTEUS coupling). - If the stall persists with an effective
rtolof1e-8, the cause is usually a sharp solidus or liquidus crossing, not the integrator class. Consider enablingphi_step_cap. - With
convective_thresholdabove 0, the cause can also be a node whose gradient stays near \(dS/dr = 0\). The default 0 does not have that jump. CVODE also stalled at1e-8at \(D > 0\), and no remedy was measured there (see Heat transport).
The measured counts behind this advice are in Lock measurements.
CVODE
- CVODE is the default and the only path that supports the JAX-traced analytic Jacobian (
use_jax_jacobian = true). - With no JAX CVODE factory registered, CVODE uses a finite-difference Jacobian. In a PROTEUS run that also happens when JAX is not importable. It is correct, but takes \(O(N)\) RHS evaluations per Jacobian build and is noisier on stiff profiles. See the CVODE and JAX explainer.
- The tolerance warning also names a configured
atolabove1e-8, but only on theenergy_balancecore, the one setup whose lock data show a looseatoladding to the lock. No lock data exist for the other core boundary conditions,core_moduleincluded, so the warning makes noatolclaim for them. - CVODE accepts a SUNDIALS root function for melt-fraction step capping; see the
phi_step_caphow-to.
Radau and BDF
- Both use
solve_ivpwithdense_output=Falseand a 1 yrmax_stepnear phase boundaries. - They do not support the JAX-traced Jacobian. scipy computes a Jacobian by finite differences when needed.
- They register the melt-fraction capping logic as a
solve_ivpevent withterminal=True, so the same TOML config behaves consistently. - With
phase_boundary_cap = "fixed"the 1 yrmax_stepactivates at the same trigger on all 3 integrators. - The default
"rate"runs only on CVODE: it arms within the larger ofphase_boundary_entropy_marginand the stiff-zone half-width and integrates the call in segments. The scipy paths fall back to the 1 yr step.
Leaving the EOS tables
The entropy state of CVODE has no lower bound, but the EOS tables stop at a minimum entropy \(S_\mathrm{min}\). Below it every lookup is clamped to the table edge, so a cell keeps losing entropy at a fixed temperature. This happens when a prescribed surface flux, fixed over a coupling step, drains the top cell after it crystallises.
Two controls deal with this. The guard needs no setting and fails a call that has left the tables. The floor is off by default and stops a call before it leaves them.
Trial steps and Newton iterates of the integrator can evaluate the right-hand side below \(S_\mathrm{min}\), with clamped lookups, with the floor on or off and at any margin.
EOS table guard
The guard is a safety net. It does not set the step and does not remove the cause of a drain.
What it does. With the rheology off, a call fails when a cell entropy lies outside the global entropy range of the loaded tables by more than \(10^{-3}\) J kg\(^{-1}\) K\(^{-1}\), in an accepted or root-search state. With the rheology on, an invariant raises instead.
What you see.
- The call ends with status -1 after it has run to its end, with an ERROR message that names the guard, the cell, its entropy and the table range.
- The result holds the states from before the first one outside, or the start state for a start outside.
dt_actualis the time from the call start to the last state kept. The energy integrals are zero, andF_cmb_step_avgisNone. cvode_flag_nameisEOS_TABLE_GUARD, andcvode_flagkeeps its value, which is 0 on the scipy paths.- Before that, the EOS lookup logs an out-of-range WARNING on the 1st, 10th, 100th, ... occurrence of each lookup. For an EOS that a caller builds with
strict_range=True, the lookup raises instead: on a scipy path the error reaches the caller, and on CVODE the solver call reports it.
What to do.
- Retry the call with a shorter step. This does not help for a start outside, and the message says so.
- A caller can run the call with
strict_accepted_range = True: an accepted state outside the tables then raisesAcceptedStateRangeError, and a retry ladder of the caller can count it as a failed attempt and halve the step. When the retry ladder of PROTEUS fails, PROTEUS keeps the previous interior state for that step and stops the run at the third such failure in a row. - Look at the coupling step: a flux fixed over a step is what drains the top cell.
What it does not judge.
- The extrapolated basic nodes: with the floor off they can lie below \(S_\mathrm{min}\) in a returned state.
- The padded rows of a pressure column. When the mask files mark them 0, the EOS domain check reports lookups on them.
- A run with constant properties or without tables, and a call that does not advance.
A cell at a table edge. It passes until it has moved past the edge by the tolerance, so it fails after about \(10^{-3}\) J kg\(^{-1}\) K\(^{-1}\) over its outward rate.
Where the guard runs. Only EntropySolver.solve has the guard. The direct JAX integration in aragog.jax.solver does not.
EOS floor
Turn the floor on in a standalone run when a drain must stop at a known entropy, with a state that stays inside the table. PROTEUS has no key for it, so PROTEUS runs have the floor off.
How. Set energy.eos_floor_margin \(m\) to a positive value below the entropy span of the tables. The tested value is 100 J kg\(^{-1}\) K\(^{-1}\). The default is \(m = 0\), which is off, as is \(m \le 0\).
What it does. The floor is one more component of the step-cap root function. It ends the call when the entropy it watches reaches \(S_\mathrm{min} + m\), or \(S_\mathrm{min} + m/2\) when the call starts below \(S_\mathrm{min} + m\).
- It watches the smaller of the top basic-node entropy, which sets the surface temperature, and the smallest cell entropy. The CMB basic node is not watched.
- With
top_node = 'limited'and with a prescribed surface temperature (outer_boundary_condition = 5), the top basic node is not the linear extrapolation of the cells, so the floor watches the top cell in its place.
What you see.
- At a stop, CVODE returns status 0 with a shorter
dt_actual, and scipy returns status 1 at the event. A WARNING logs the stop and its level. - A refused call returns status 1,
dt_actual = 0and its start state, with a WARNING. A start close to the table can be refused, and a call that ends below the table is discarded in the same way; see Floor refusals.
What it costs. With \(m > 0\) the floor is armed in every solve with the entropy EOS, except on the gradient core. A call in which it does not fire takes the same steps and gives the same result as without it.
What it does not do. The floor guards the table range, not its resolution. Where a table is flat in temperature above \(S_\mathrm{min}\), a stop at the level still gives the clamped edge temperature.
- In the solid table of the floor tests, \(T\) is the same over the first 4 entropy rows (\(S_\mathrm{min}\) to \(S_\mathrm{min} + 322\) J kg\(^{-1}\) K\(^{-1}\)) at every pressure up to 6 GPa. With \(m = 100\) the floor keeps the state inside the table but the surface temperature at the edge value.
- In one PALEOS solid table at the lowest pressure, \(T\) is the same over the rows from about \(S_\mathrm{min} + 70\) to \(S_\mathrm{min} + 620\) J kg\(^{-1}\) K\(^{-1}\).
With the floor on, every state a call returns is inside the table when the call starts inside it, and the returned states and the energy trace cannot hold a state below \(S_\mathrm{min}\).
Lookups outside the valid window of the tables
A table generator can fill the nodes of a P-S table where the EOS has no valid value, outside the temperature window of the phase. Zalmoxis marks these nodes 0 in valid_mask_melt.dat and valid_mask_solid.dat next to the tables (format in Reference: data). A lookup on a filled node returns a value, but no EOS data stands behind it. The window of a pressure column is the entropy range from its lowest to its highest valid node; between 2 columns, the window ends are linear in pressure. A column with no valid node (Zalmoxis writes one when it fills a column in full) has no window: a point at its pressure, or between it and a neighbouring column, counts as outside at any tolerance. One table entropy cell is the mean spacing of the entropy axis of the phase's temperature table, in J kg\(^{-1}\) K\(^{-1}\); it is not a cell of the solver mesh.
What it does. After each call, the solver checks the lookup points of the states of the call: its quadrature nodes (the accepted steps and the root-search points), which a CVODE call checks chunk by chunk as it steps, or the output states of a call that has no such nodes. A lookup point is a cell or a basic node, at the pressure of the node and the entropy that the right-hand side gives the EOS there:
- A cell: its entropy.
- A basic node: the mesh transform of the cell entropies, with 3 exceptions. With
core_bc = "energy_balance"or"core_module", the CMB node is the bottom cell carried to the CMB by the CMB entropy gradient of the state. Withcore_bc = "gradient", the basic-node entropies are rebuilt from the state. Withouter_boundary_condition = 5, the top node holds the entropy of the set surface temperature. - A point in the mush: read on the melt table at the liquidus entropy and on the solid table at the solidus entropy; the larger of the 2 distances counts.
- A single-phase point where the phase blend gives the mixed-phase properties a weight above 0 (with
matprop_smooth_widthabove 0, a band on each side of the mush): read on its own table and at the 2 phase-boundary entropies; the largest distance counts.
A point counts when it lies more than eos_domain_tolerance_cells (default 5) table entropy cells outside its window. A non-finite point always counts.
Near the upper edge of a window, 5 cells is a large temperature step. On the PALEOS tables of 2 PROTEUS runs (measured outside the test suite), the temperature rises over the 5 nodes below the upper edge by 316 to 733 K on the melt table and 626 to 1106 K on the solid table (10 to 90 % of the pressure columns, a table set up to 101 GPa), and by 1070 to 5541 K and 1341 to 2428 K on a table set up to 1.26 TPa. A filled value 5 cells out can thus miss the EOS temperature by hundreds to thousands of kelvin, if the slope inside the window holds outside it.
What you see.
- With
eos_domain_check = "warn", the default: 1 WARNING per call. It names the worst point (time, node, radius, pressure, entropy, table, window ends, distance in cells, and the temperature that the table returns at that lookup) and the count of points outside, summed over the judged states of the call. The result is the same as with the check off. - With
"raise": the call raisesEOSDomainErrorwith the same text, and the solver keeps the solution from the call start (none on a first call).EOSDomainErroris aRuntimeError, so in a PROTEUS run it ends like a failed Aragog call: PROTEUS keeps the previous interior state for the step, and after 3 failed calls in a row it stops the run with status 20. PROTEUS passes noeos_domain_check, so its runs use the default"warn".
What to do. Look at the node that the message names. With top_node = "linear", the default, the top basic node is a linear extrapolation from the 2 top cells, so it can leave the window while every cell is inside. Its temperature is then a filled table value, and Aragog reports it as T_magma (with a live lid and the mush base, T_magma is a blend that includes it).
What it does not judge.
- A call that keeps no energy trace: the check then reads the output states only, so a state that leaves the window and returns between 2 output points is not seen. The solver says so in 1 INFO line.
- A call that fails (the EOS table guard or the integrator).
- A 0 node between 2 valid nodes of a column: it lies inside the window. The EOS logs 1 INFO line with the count of such nodes when it reads the masks.
- Tables with neither mask file: the check is off, and the EOS logs 1 INFO line when the first call looks for the masks.
- Runs with constant properties.
- Phase-boundary lookups outside the smoothing band of the NumPy phase evaluator: the mixing flux reads them where \(S_\mathrm{liq} - S_\mathrm{sol} < 1\) J kg\(^{-1}\) K\(^{-1}\) (it floors that gap at 1), and the JAX evaluator at its band edge, with a blend weight of at most \(4.4 \times 10^{-16}\).
- A bad mask or setting: each call checks both settings before it integrates, and the first call reads the masks then. With only one of the 2 files it raises
FileNotFoundError; with a mask that breaks the rules of Validity masks, or a bad setting, it raisesValueError(TypeErrorfor a tolerance that is not a number). The solver keeps its last solution."off"does not read the masks. - Points closer to the window than the tolerance. The phase boundaries of a table can lie just outside its windows, so the mush lookups of ordinary runs read nodes near the window; the default tolerance leaves these out. Over the mantle pressure range of 13 PROTEUS runs on 2 table sets, the liquidus lies at most 2.29 cells outside the melt window and the solidus at most 1.35 cells outside the solid window (measured outside the test suite;
tests/test_eos_domain.pypins 2.29 and 1.12 for one set).
Where the check runs. Only EntropySolver.solve has the check. The direct JAX integration in aragog.jax.solver does not.
Reference
Floor refusals
When the floor refuses a call
Levels. A start counts as above the level \(S_\mathrm{min} + m\) or \(S_\mathrm{min} + m/2\) only when it lies more than \(10^{-6} m\) above it. The band of a start at the table is \(S_\mathrm{min}\) to \(S_\mathrm{min} + 2 \times 10^{-6} m\).
Start at or below \(S_\mathrm{min} + m/2\). The call arms a level at half its distance to \(S_\mathrm{min}\). It does not advance (status 1, dt_actual = 0) when the rate of that entropy at the call start, taken over every component no more than \(10^{-6} m\) above that entropy, reaches the level before the call ends. Between \(S_\mathrm{min} + 2 \times 10^{-6} m\) and \(S_\mathrm{min} + m/2\) the refusal depends on the call span, so a caller that retries with a shorter span can then advance.
Rate of a linear top node. Above \(S_\mathrm{min} + 2 \times 10^{-6} m\), the rate of a linear top basic node (not with top_node = 'limited' or outer boundary condition 5) is the larger of its own rate and the rate of the top cell. The node is a linear extrapolation of the top 2 cells and can fall when only the gradient below it steepens. Inside the band its own rate counts.
Start at or below \(S_\mathrm{min} + 2 \times 10^{-6} m\). The call also arms half its distance to \(S_\mathrm{min}\), but does not advance on any fall of its lowest component, however slow, at every span, nor when no level fits strictly between \(S_\mathrm{min}\) and the start.
Start at or below \(S_\mathrm{min}\). Every such start is refused. This includes a linear top basic node extrapolated below \(S_\mathrm{min}\) from a steep top gradient while every cell is inside the table and the node or the top cell rises, so no call advances from a top node outside the table.
A top node that falls only by extrapolation. While the top cell warms, it advances above the band in calls that each stop at half its distance, and is refused once inside the band. That takes at most \(\lceil \log_2 (d_0 / 2 \times 10^{-6} m) \rceil\) calls that stop at the floor from a distance \(d_0 \le m/2\). A call too short to reach its level adds one that does not stop.
What continues. Above \(S_\mathrm{min} + 2 \times 10^{-6} m\), a drain too slow to reach half the distance in the call, a pause or a warming surface continues. A call with no span (start equal to end) skips the floor.
A call that ends below the table. A call whose returned states or energy trace hold a top basic-node or cell entropy below \(S_\mathrm{min}\) is discarded. It is solved again as a refusal, so its state, time and energy trace stay at the call start. The WARNING names the time after the call start, and that entropy and the level as offsets from \(S_\mathrm{min}\).
Warnings. The refusal WARNING says that the entropy is at or below the table minimum, leaves no level between it and the table minimum, falls at the table minimum, or falls too fast between the band and \(S_\mathrm{min} + m/2\), also when the start rate is NaN. A floor stop at the call start, where the level lies within the root location error of the start, is a refusal with its own WARNING.
In PROTEUS, if the floor were on. PROTEUS would treat a refused call as a failed attempt. Its retry ladder retries with half the span and an atol up to 5 times larger. That can then advance between \(S_\mathrm{min} + 2 \times 10^{-6} m\) and \(S_\mathrm{min} + m/2\), so under a drain that does not stop the surface entropy can come closer to \(S_\mathrm{min}\) than \(m/2\). At the table minimum a shorter span does not advance a falling start. When the ladder runs out, PROTEUS would keep the interior state of the previous step while the other modules advance, and stop the run at the third failure in a row.
Root location limits
How exactly a stop lands on its level
CVODE locates a root to a time tolerance of about \(100\,u\,(|t| + |h|)\), with \(u\) the unit roundoff, \(t\) the absolute call time and \(h\) the step. A stop can lie below its level by up to about \(|dS/dt| \times 2.2 \times 10^{-14} \times (|t| + |h|)\), with \(t\) and \(h\) in yr. For steps much shorter than \(t\) that is about \(|dS/dt| \times 2.2 \times 10^{-14} \times t\).
scipy event location also loses precision with \(t\), more slowly, and a scipy event can stop on either side of its level.
For the 11-cell state of the floor tests under \(10^6\) W m\(^{-2}\), a stop at \(10^9\) yr lay:
| Integrator | Distance from the level (J kg\(^{-1}\) K\(^{-1}\)) |
|---|---|
| CVODE | \(1.6 \times 10^{-3}\) below |
| Radau | \(6 \times 10^{-6}\) below |
| BDF | \(9 \times 10^{-6}\) above |
Lock measurements
What the lock counts rest on
Setup. A probe variant of the energy_balance isentropic start of tests/test_phase_boundary_cap.py: 24 nodes, 200 yr, fixed cap unless stated. It draws the initial entropy uniformly between 8000 and 8400 J/kg/K for each run and adds a relative noise of \(10^{-15}\). The probe script is not in the repository, and the runs were on macOS arm64. The counts hold for this 24-node standalone case at the default convective_threshold = 0, where the switch is at \(dS/dr = 0\), not for a coupled solve. In these runs the CMB node took the floored eddy diffusivity of node 1, not the current CMB node rule; the counts are not measured again under that rule.
What counts as locked. A run that has not reached 200 yr after 600 s of wall time. Every run was screened at 60 s, and each run that missed that was run again alone to 600 s, by which time a locked run had used about \(1.7 \times 10^5\) RHS evaluations.
rtol and atol |
Setup | Locked |
|---|---|---|
both 1e-6 |
the setup above | 12 of 1133 |
both 1e-6 |
quasi_steady core | 4 of 474 |
both 1e-6 |
rate cap | 2 of 286; 2 more finished only after 233 s and 346 s |
both 1e-5 |
the setup above, each run to 600 s | 0 of 80, too few to show it safe; the slowest finished after 100.6 s and \(6.5 \times 10^4\) RHS evaluations |
both 1e-8 |
fixed cap, energy_balance core | 0 of 1026 |
both 1e-8 |
rate cap, energy_balance core | 0 of 627 |
both 1e-8 |
fixed cap, quasi_steady core | 0 of 1224 |
atol 1e-8, rtol 2e-8, 5e-8 or 1e-7 (the PROTEUS retry ladder) |
fixed cap, each value and core | 0 in each set of 1308 to 1836 runs |
atol 1e-8, rtol 5e-8 |
rate cap | 0 of 620 |
atol 1e-8, rtol 1e-7 |
rate cap | 0 of 636 |
The median run needed about \(1.6 \times 10^4\) RHS evaluations at 1e-5, against about \(1.3 \times 10^3\) at 1e-8.
Recorded steps. 2 of the counted runs were run again with every accepted step recorded. Both kept a constant step with a period-2 oscillation of the entropy difference at mid-mantle nodes, at 1.41 RHS evaluations per step on the energy_balance core, where the difference stayed just below zero, and at 1.14 on the quasi_steady core, around zero. The other counted runs were not checked for the pattern.
Why \(D > 0\) differs. At \(D = 0\) the interior flux and the convective CMB flux are continuous at the switch and only their slopes jump. At \(D > 0\) the convective flux stays continuous at 0, but the mixing flux of a mush (for a positive eddy_diffusivity_chemical) and the CMB flux jump at 0 (the minimum drive of the node above the CMB switches off there) and the floor flux jumps at \(D\) (see Heat transport). So the \(D = 0\) counts and the 1e-8 remedy do not carry over to \(D > 0\), and the probe did not cover it.
On CI. The AVX-512 numpy path makes the test's own case, at its single fixed initial entropy, stall at 1e-6, judged by the CI test timeout rather than by the 600 s criterion.
See also
- CVODE and JAX explainer: why the analytic Jacobian helps and how
set_jax_cvode_factoryis wired. phi_step_caphow-to: SUNDIALS-rootfn capping of \(|\Delta\phi|\) across a step.- Installation: production solver path: runtime requirement for
use_jax_jacobian = true. - Solid-state convection explainer: mantle rheology, stagnant-lid closures, and step control during solid-state thermal evolution.