Toy problems and the M1 conformance cases
Status: M1 draft, 2026-10-23; §4 (the .esm versions and the M2 end-to-end cases) added 2026-10-25; §5 (reseact-shaped problems for partitioning, M3) added 2026-11-24. Normative for both implementations.
M1’s gate (architecture §14) is conformance tiers 2 and 3 on toy problems. The problems are written by hand in each language behind the operator interface (operator-interface.md
), not compiled from .esm documents (D53): at M1 Rust had no public reentrant right-hand side (U4, since released in EarthSciAST 0.5.0). .esm versions of the same problems join the suite at M2 (§4), planned and run end to end, and must give the same results.
Each problem below fixes its equations, operators, layout, parameters, initial state and interval exactly. Both implementations MUST implement every listed operator call (operator-interface.md §3) with hand-derived derivatives, not automatic differentiation, so the derivatives themselves are under test. The Julia implementation’s ForwardDiff Jacobian of rhs is a test oracle for them.
Indices are 0-based. “Cell” coordinates are $x_c = (c + \tfrac12)/\text{ncells}$. The names given to state components ($y$, $\mathrm{O_3}$, $A$, …) are the variable names a run config uses for them, for example in adjoint.functional; a problem with cells has one index set, cell. At M1 every toy leaf runs with dt_scope: global (tape.md covers no other scope until M3), whatever D17’s default for its locality. Toy operators carry no locality, so at M1 an imex partition (spec/run-config.md §4.5) names operators only, and a locality name in it is refused. A problem’s operators exist under the names given here, so a case’s run config names them in its schedule and has no operators key.
1. Problems
1.1 forced_decay
A linear, non-autonomous scalar problem with an exact solution. It tests convergence order for every method, the stage-time arguments $t_n + c_i h$, and Rosenbrock’s $f_t$ term.
- State: $u \in \mathbb{R}^1$,
dense. Parameters $p = (k, \omega) = (2, 3)$. Interval $[0, 2]$, $u(0) = 1$. - One operator,
decay: $u’ = -k u + \sin(\omega t)$.depends_on_t= true,linear_in_u= true. - Exact solution, with $A(t) = \dfrac{k \sin \omega t - \omega \cos \omega t}{k^2 + \omega^2}$: $u(t) = \big(u(0) - A(0)\big) e^{-kt} + A(t)$.
1.2 van_der_pol
Nonlinear, so the second-order terms of Rosenbrock adjoints are nonzero.
- State: $u = (y, z)$,
dense. Parameter $p = (\mu)$. $u(0) = (2, 0)$. - One operator,
oscillator: $y’ = z$, $\ z’ = \mu (1 - y^2) z - y$.depends_on_t= false,linear_in_u= false. - Variants:
nonstiff, $\mu = 1$ on $[0, 6.3]$;stiff, $\mu = 1000$ on $[0, 1]$.
1.3 robertson
Classic stiff kinetics with a conservation law.
- State: $u = (y_1, y_2, y_3)$,
dense. Parameters $p = (k_1, k_2, k_3) = (0.04,\ 3\times10^{7},\ 10^{4})$. Interval $[0, 40]$, $u(0) = (1, 0, 0)$. - One operator,
kinetics: $y_1’ = -k_1 y_1 + k_3 y_2 y_3$, $\ y_2’ = k_1 y_1 - k_3 y_2 y_3 - k_2 y_2^2$, $\ y_3’ = k_2 y_2^2$. - Invariant: $y_1 + y_2 + y_3 = 1$.
1.4 photostationary_cells
A batch of independent cells with time-varying photolysis: the shape of reseact’s chemistry. It tests block_diagonal layout and batched block LU, and gives each cell different stiffness over time.
- State:
block_diagonal, ncells = 16, n = 3; species order $(\mathrm{NO_2}, \mathrm{NO}, \mathrm{O_3})$, species-major (operator-interface.md §2). Parameters $p = (j_0, k, \omega) = (10^{-2},\ 4.4\times10^{-4},\ 2\pi/3600)$. Interval $[0, 3600]$. Initial state in every cell: $(10, 5, 40)$. - One operator,
photochemistry. With $\varphi_c = 2\pi c/\text{ncells}$ and $j_c(t) = \tfrac12 j_0 \big(1 + \sin(\omega t + \varphi_c)\big)$, and $r_c = j_c,\mathrm{NO_2} - k,\mathrm{NO},\mathrm{O_3}$ in cell $c$: $\mathrm{NO_2}’ = -r_c$, $\ \mathrm{NO}’ = r_c$, $\ \mathrm{O_3}’ = r_c$.depends_on_t= true,linear_in_u= false. - Invariants per cell: $\mathrm{NO_2} + \mathrm{NO}$ and $\mathrm{NO_2} + \mathrm{O_3}$.
1.5 advection_reaction
Two operators that do not commute, for splitting order, subcycle, and adjoints through sequence and strang.
- Periodic 1-D grid, ncells = 64, $\Delta x = 1/64$. Species $(A, B)$, species-major. Parameters $p = (v, k_1, k_2) = (1, 50, 25)$. Interval $[0, 0.5]$. $A(0) = 1 + \tfrac12 \sin(2\pi x_c)$, $B(0) = 0$.
- Operator
transport(densestructure): first-order upwind advection of $A$ only, $A_c’ = -v,(A_c - A_{c-1})/\Delta x$ with $A_{-1} \equiv A_{63}$. $B$ does not move.linear_in_u= true. - Operator
reaction(block_diagonal, n = 2): $A’ = -k_1 A + k_2 B$, $\ B’ = k_1 A - k_2 B$.linear_in_u= true. - Invariant: $\sum_c (A_c + B_c)$.
- Because $B$ does not advect, the operators do not commute, so Lie splitting has a first-order and Strang a second-order splitting error.
1.6 source_decay_map
A leaf and a map in sequence, with an exact discrete solution. It tests map, bind_dt and the map adjoint.
- State: $u \in \mathbb{R}^1$,
dense. Parameters $p = (a, r) = (1, 0.5)$. Interval $[0, 4]$, $u(0) = 0$. - Operator
source: $u’ = a$. - Map operator
decay: $u \leftarrow u, e^{-r \Delta}$, with $\Delta$ the length of the map node’s interval (spec/run-config.md §4.4). - With schedule
sequence[leaf source (ForwardEuler, dt "step"), map decay]and macro step $\Delta$, the exact discrete solution is $u_{n+1} = (u_n + a\Delta), e^{-r\Delta}$.
1.7 cubic_roots (M4b)
An unbounded solve per cell with an exact answer. It tests newton, ptc, the diagonal pairing (spec/plan.md §5.9) and the residual document.
- Unknown $z \in \mathbb{R}^4$ over index set
cell, an algebraic unknown withdefault0; parameter $c_i = i$. - Algebraic equation
0 ~ c - z - z^3(elementwise), so $g = c - z - z^3$ and $\partial g_i/\partial z_i = -1 - 3z_i^2 < 0$. - Roots: $z = (0.6823278038280193,\ 1,\ 1.2134116627622296,\ 1.378796700129551)$.
1.8 box_lcp (M4b)
A bounded solve with both bounds active (D95). It tests the projected and semismooth methods, a referenced upper bound and the active set.
- Unknown $z \in \mathbb{R}^2$ over index set
k,lb0,ubthe parameter $z_{\max} = (0.25,\ 10)$ (a reference),default0. - One array algebraic equation
0 ~ b - A z, written as afaqoverkwith the product contracted over a second index, $b = (1, -2)$, $A = \begin{pmatrix} 2 & 1 \ 1 & 2 \end{pmatrix}$, so its one residual block pairs with $z$ by a diagonal band whose column index is contracted (spec/plan.md §5.9.4). - Solution $z = (0.25,\ 0)$: $z_1$ at its upper bound with $g_1 = 0.5 \ge 0$, $z_2$ at its lower bound with $g_2 = -2.25 \le 0$; nondegenerate. Active set:
upper[0],lower[1]. - Informative. The same system written as two scalar unknowns and two scalar equations, each reading both, has two diagonal pairings that give different answers, and is refused (
solve_pairing_ambiguous, spec/plan.md §5.9.6); it is the refusal fixture for that code.
1.9 phase_joint (M4b)
A joint bounded solve of an unbounded and a bounded unknown of different shapes, the form MOSAIC’s Kelvin and MESA solves take when solved together (D120).
- Index sets
cell(2) andsalt(2). Unknowns: water $w$ overcell, unbounded; solid $s$ overcell×salt,lb0. Bothdefault0 except $w$,default1. - Parameters: totals $T = \begin{pmatrix} 2 & 1 \ 0.5 & 1 \end{pmatrix}$ (cell × salt), $K = (1, 10)$, $\kappa = 0.5$.
- Algebraic equations:
0 ~ κ Σ_j (T_j - s_j) - wovercell, and0 ~ (T_j - s_j)/(K_j w) - 1overcell×salt(the rate $S - 1$). - Solution: cell 1, $w = 1$, $s = (1, 0)$ (salt 1 saturated, salt 2 at $S = 0.1$); cell 2, $w = 0.75$, $s = (0, 0)$ ($S = (0.667, 0.133)$). The pairing is unique by extents: the
cellresidual with $w$, thecell×saltresidual with $s$.
1.10 robertson_dae (M4b)
§1.3 as an index-1 DAE (D122): $y_3$ is an algebraic unknown and its equation is the conservation law 0 ~ 1 - y1 - y2 - y3; $y_1$, $y_2$ keep §1.3’s equations. A coupled node with Rodas4, TRBDF2 or Kvaerno4 integrates it; the reference is §1.3’s solution, whose $y_1, y_2$ the DAE matches to the integration tolerance and whose $y_3$ it matches exactly up to the conservation law. Its initial state $y_3 = 0$ is consistent; a variant with the default of $y_3$ set to 0.5 tests the consistent initialization (§14.4 of spec/methods.md), which must return $y_3 = 0$ before the first step.
1.11 picard_roots (M4b)
A picard solve per cell, and converged.rel_change. It tests the frozen documents (spec/plan.md §6.5, D124).
- Unknown $z \in \mathbb{R}^4$ over index set
cell, an algebraic unknown withdefault0; parameter $c_i = i/4$; observed $\nu = 1 + z^2$ (elementwise). - Algebraic equation
0 ~ c - ν z, written with its unknown on the left (ν z - c ~ 0), so $g = c - z - z^3$. - Picard freezes $\nu$: its Jacobian is $-\nu$, and the iteration is $z \leftarrow c/(1 + z^2)$, which contracts at rate $2c z/(1+z^2)^2$ at the root, 0.64 in the slowest cell.
- Roots: $z = (0.2367329038645632,\ 0.4238537990697833,\ 0.5673642266809228,\ 0.6823278038280195)$.
- Variant
picard_stiff.esm(D139): $c_i = 2.5 i$, roots $(1.1147471097045167, 1.5159802276928207, 1.787609408374904, 2)$, where plain Picard diverges (its rate $2z^2/(1+z^2)$ exceeds 1 at every root); caseunderrelax_frozenrecovers with $\nu$ under-relaxed by 0.5. - Variant
picard_faces.esm(D137): the same overcell×face(2 × 2), $c = ((0.25, 0.5), (0.75, 1.0))$ (rows by cell), so the same four roots; casel1_by_faceconverges on the relative change of $\nu$ undernorm: {"l1_by": "face"}(stride2,count2).
1.13 solve_limit (M4b)
Step limits evaluated after a solve node (step.after, D138). Fixture toy_solve_limit.
- Scalar algebraic unknown $z$ (
default0) withz + z^3 ~ c, $c = 1$, so $z = 0.6823278038280195$; state $x$, $x(0) = 1$, $x’ = -z x$; the observed step limit $\mathrm{lim} = 0.1/(z + 0.01)$;step.limits["Box.lim", {"max": 1}],resolution0.01, on $[0, 1]$. - Schedule
sequence[solve z (id z_solve, newton), leaf x ForwardEuler dt step]. - Case
after(step.after: "z_solve"): every macro step sees the solved $z$, $\mathrm{lim} = 0.14444$, floored to 0.14: seven steps of 0.14 (reasonBox.lim), then 0.02 (tstop); $x(1) = (1 - 0.14 z)^7 (1 - 0.02 z)$. Casebefore(the default): the first step sees the warm start $z = 0$, $\mathrm{lim} = 10$, so one step of 1 (max); $x(1) = 1 - z$.
1.12 column_imex (M4b)
Implicit columns and IMEX Euler with the per-column banded solve (D131). Fixture toy_column_imex.
- Index sets
x(4, horizontal) andlev(6, vertical). States $A$ and $B$ overx×lev; $A$ starts at $1 + i/4 + k^2/8$ (anic), $B$ at 0.25. Parameters $k_z = 40$, $v = 0.5$, $k_f = 3$, $k_b = 1.5$. Interval $[0, 1]$, macro step 0.25. - Three operators, by locality:
vertical(column), $A_k’ \mathrel{+}= k_z (A_{k+1} - 2A_k + A_{k-1})$ with zero flux at both ends;horizontal(stencil), periodic upwind advection of $A$ alongxat speed $v$;chemistry(pointwise), $r = k_f A - k_b B$, $A’ \mathrel{-}= r$, $B’ \mathrel{+}= r$. - Invariant: $\sum (A + B)$ over every cell.
- The column leaf over
verticalandchemistryhas two variables, so its level-major column (operator-interface.md §4) couples $A$ and $B$ at one level beside the diagonal: $k_l = k_u = 2$. - Cases:
rodas4andtrbdf2(a stencil leaf, SSPRK33, then the column leaf withbanded),imex(one IMEX Euler leaf,horizontalexplicit, the others implicit,banded). Checks: each case agrees with the same case run withdense_luover the whole leaf to $10^{-12}$ relative (the two factor different matrices: the whole leaf in species-major order against each column in level-major order, so they agree to roundoff, not bitwise), takes the same steps, and conserves the invariant to roundoff.
1.12 switch_slide, switch_cross, switch_leave (issue #81)
Switching surfaces of ifelse predicates (spec/methods.md §16), on one scalar state $x$, $x(0) = 0$, over $[0, 200]$, with $a = b = 0.01$ and $x_c = 1$. Each is .esm only (../tests/conformance/toys/switch_*.esm), run by the run configs in ../tests/conformance/switching/ (TRBDF2, reltol 1e-8, abstol 1e-10, step.dt 50) and by the same configs with another method; both test suites check them (julia/EarthSciIntegrator.jl/test/switching.jl, rust/earthsci-integrator/tests/switching.rs).
switch_slide, issue #81’s reproduction: $x’ = a$ where $x < x_c$, $-b$ elsewhere. Both sides point into $x = x_c$, which $x$ reaches at $t = 100$ and slides on: $x = at$ up to $t = 100$, then $x_c$. Issue #81’s checks are $x(50) = 0.5$ torel1e-6 and $x(200) = 1$ toabs1e-3; the suites also check $x = 1$ at $t = 100, 150, 200$ to 1e-8. A Rosenbrock leaf refuses the sliding mode (§16.5).switch_cross, the issue’s control: $x’ = a$ where $x < x_c$, $10a$ elsewhere; $x$ crosses once at $t = 100$: $x = x_c + 10a(t - 100)$ after it.switch_leave: $x’ = a$ where $x < x_c$, $ct - b$ elsewhere, with $b = 0.015$ and $c = 10^{-4}$. $x$ reaches $x_c$ at $t = 100$, slides while the upper side’s field $ct - b$ points into the surface, and leaves it upward at $t = b/c = 150$: $x = x_c + c(t - 150)^2/2$ after it, 1.125 at $t = 200$.
The cases with a sliding mode and with a crossing check every output at multiples of 5 against these exact solutions to rel 1e-7 (TRBDF2, Kvaerno4, Tsit5; BackwardEuler on switch_slide with the issue’s checks only, since it accepts the first step of every invocation untested, §5.5), and the replay of each run (spec/tape.md §3) bitwise.
1.13 switch_cells, switch_cells_elementwise, switch_coupled (issue #81)
One switching surface per cell of an array (spec/methods.md §16.1), and the refusal of coupled sliding modes (§16.5). Each is .esm only (../tests/conformance/toys/), run by ../tests/conformance/switching/{cells,cells_elementwise,coupled}.TRBDF2.run.json (as §1.12’s) and by the same configs with another method, in both test suites.
switch_cells: a state $x$ over index setcellof size 4, $x(0) = 0$, with per-cell parameters, $x_i’ = a_i$ where $x_i < x_{c,i}$ and $c_i t - b_i$ elsewhere, written per cell in afaq(afaqsite, four surfaces). With $a = (0.01, 0.008, 0.0125, 0.02)$, $b = (0.01, -0.1, 0.015, 0.01)$, $c = (0, 0, 10^{-4}, 0)$ and $x_c = (1, 1, 1, 3.5)$, the cells reach their surfaces at different times:- cell 1 slides on $x = 1$ from $t = 100$;
- cell 2 crosses at $t = 125$: $x = 1 + 0.1(t - 125)$ after it;
- cell 3 slides from $t = 80$ and leaves upward at $t = 150$: $x = 1 + 5 \times 10^{-5}(t - 150)^2$ after it;
- cell 4 slides on $x = 3.5$ from $t = 175$.
So cells 1 and 3 slide at once over $[100, 150]$, cell 2 crosses while they slide, and cell 3 leaves while cell 1 slides.
switch_cells_elementwise: the same, with the switch written elementwise in an observed rate $r$ of shape[cell],r = ifelse(x < x_c, a, c t - b), and $x_i’ = r_i$ (an elementwise site).switch_coupled: $x’ = a$ where $x < 1$, $-a$ elsewhere; $y’ = 2a$ where $y < x$, $-2a$ elsewhere; $a = 0.01$, $x(0) = 0.6$, $y(0) = 0$. $x$ slides on $x = 1$ from $t = 40$; at $t = 50$, $y$ reaches $x$, where both sides point into $y = x$ too, but $x$’s switch moves $y - x$: the run ends with the refusal of §16.5.
The suites check every output at multiples of 5 of every cell against these exact solutions to rel 1e-7 (TRBDF2, Kvaerno4, Tsit5), the replay of each run bitwise, and switch_coupled’s refusal.
2. Cases
../tests/conformance/m1/cases.json
lists the cases. It is generated by make_cases.py
beside it; CI checks the two agree. A case is a run config (spec/run-config.md) whose model is toy:<problem> or toy:<problem>/<variant>, plus what the run config does not carry: the interval (tspan, which the harness passes as the caller’s interval, spec/run-config.md §1.1), output times, the functional for gradient cases, and the checks. The file validates against schemas/cases.schema.json
.
model: "toy:..." is legal only in conformance cases. Implementations accept it only from the test harness.
2.1 Checks
| Check | Meaning | Tier |
|---|---|---|
order | Run the case at fixed dt for each value in dts. The observed order, the least-squares slope of $\log$ error against $\log$ dt for the end-state error in the max norm, is at least expected − 0.3. On forced_decay every method measures within 0.1 of its order at dts 0.1–0.0125, or above it, except ROS2 (1.71, pre-asymptotic), whose case uses dts 0.025–0.003125 (1.92). The implicit methods measure, in both implementations: BackwardEuler and IMEXEuler 0.985, TRBDF2 2.014, SDIRK2 1.913, Kvaerno3 2.966, Kvaerno4 4.588, Theta at θ = ½ 2.005. The error is against the exact solution where §1 gives one, otherwise against the reference result. | 2 |
oracle | Run the same method in OrdinaryDiffEq with the same step sequence (adaptive = false, tstops from our tape; D31). End states agree to rtol. The check fails if OrdinaryDiffEq’s solve does not return a successful code. OrdinaryDiffEq’s SDIRK methods run with NLNewton(κ = 1e-6) instead of the default $\kappa = 1/100$: at the default, its Kvaerno4, which reuses $J$ across steps and takes each explicit first stage from the previous step’s last one (spec/methods.md §5.1, §5.3), ends robertson.Kvaerno4.adaptive’s imposed step sequence with ConvergenceFailure ($y_3 = 0.166$ against 0.284); with $\kappa = 10^{-6}$ it agrees to $3\cdot10^{-8}$. Not reported upstream. Julia only; Rust compares with the Julia result through cross_language. | 2 |
invariant | The problem’s invariants hold at every output time to rtol. | 2 |
exact_discrete | The end state equals §1’s exact discrete solution to rtol. | 2 |
reference | Output states agree with the reference result (§3) to rtol, relative to the largest magnitude of each state component over the run. | 2 |
dot_product | spec/adjoint.md §7.1 for every step, with the frozen-tape tangent. Julia only (D44). | 2 |
fd_gradient | spec/adjoint.md §7.2, central differences at the listed epsilons. | 2 |
reverse_diff | Agreement with SciMLSensitivity.ReverseDiffAdjoint through OrdinaryDiffEq’s same method, with the tape’s step sequence imposed (spec/adjoint.md §7.3), to rtol; on cases too large for a ReverseDiff tape, and for Kvaerno4, through which ReverseDiffAdjoint returns a zero gradient, ForwardDiff through the same solve (§7.3). Julia only. | 2 |
replay | Replaying from the start with the tape reproduces every accepted step and the end state bitwise (D10). | 2 |
cross_language | Julia and Rust results (§3) agree: output states and gradients to rtol, and accepted step counts exactly. With rtol_steps_differ the step sequences may differ, in count or in any step’s $t$ or $h$, since a roundoff-level accept/reject flip changes every later step, and the toy problems call each platform’s own sin, cos and pow, which may differ in the last bit (spec/adjoint.md §7.5); an adaptive controller can turn such a bit into a different step size. When they do, states and gradients agree to rtol_steps_differ instead, which is set from the case’s reltol because the two then differ by about the global error. States are compared relative to the largest magnitude of each state component over the run in either result, as for reference; the functional relative to its magnitude; each gradient vector (u0, p) relative to its largest-magnitude entry. When the step counts agree, the tapes must also agree by path and count (spec/tape.md §5): the same records in the same order, with the same accepted counts and return codes. Run in CI by compare_results.py
on the two implementations’ result files. | 3 |
A check fails loudly with the measured quantity and the threshold.
3. Result files
For cross_language and for references, an implementation writes one result file per case, validated by schemas/result.schema.json
:
The values in this example are illustrative:
{
"case": "robertson.Rodas4.adaptive",
"producer": "julia",
"t": [0, 10, 40],
"u": [[1, 0, 0], [0.84136, 1.6e-05, 0.15862], [0.71583, 9.2e-06, 0.28416]],
"stats": {"accepted": 63, "rejected": 2, "rhs_calls": 410},
"functional": 0.28416,
"gradient": {"u0": [0.1, 0.2, 0.3], "p": [-1.2, 3.4e-08, -5.6e-05]}
}
producerisjulia,rust, orreference(a high-accuracy OrdinaryDiffEq solve, for cases without an exact solution).tis $t_0$ followed by the case’s output times: the times of the case’ssaveatlist that lie in $(t_0, t_f]$, in increasing order and each once, or $t_f$ alone when the case has nosaveat. A listed $t_0$ is not repeated, a listed time outside $[t_0, t_f]$ is dropped, and $t_f$ is not added to a list that omits it; sosaveat[0, 1, 2]withtspan[0, 2]givest=[0, 1, 2].uholds the full state at each of them, in the layout of §1. Numbers are written in shortest round-trip form.functionalandgradientare present for gradient cases only.stats.acceptedandstats.rejectedsum over all leaves and macro steps.
Result files under tests/conformance/m1/reference/ are checked in. They are produced by a Julia script with OrdinaryDiffEq (Rodas5P for stiff and Vern9 for non-stiff problems, reltol = abstol = 1e-13); for advection_reaction the reference integrates the unsplit sum of both operators, so order checks measure the splitting error. The script and the files arrive with the Julia M1 implementation. Julia and Rust results are produced by CI and compared there, not checked in.
4. The toy problems as .esm documents (M2)
M2’s runtimes execute plans end to end (D80). The gate replays the M1 cases on .esm versions of the problems: the planner plans each case, the runtime builds its operators from the plan (spec/operator-interface.md §8) and runs it, and the result must match the same implementation’s run of the M1 case on the hand-written problem. Julia and Rust both run them from M2; both build their right-hand sides through the public reentrant rhs_program (U4, EarthSciAST 0.5.0; D53).
4.1 Documents
The documents are in ../tests/conformance/toys/
, esm 1.3.0, each validated by EarthSciAST in conformance tier 0 (spec/plan.md §0.2). Each writes §1’s equations with §1’s parameter values, initial state and interval (solver.time_span), and evaluates to the same right-hand side up to the order of floating-point operations:
| Problem | File | Components and operators | Layout of §1 |
|---|---|---|---|
forced_decay | forced_decay.esm | model Decay; operator decay = {"components": "Decay"} | Decay.u |
van_der_pol | van_der_pol_nonstiff.esm, van_der_pol_stiff.esm (one document per variant, since a run config cannot override a parameter) | model Oscillator; oscillator | Oscillator.y, Oscillator.z |
robertson | robertson.esm | model Kinetics; kinetics | Kinetics.y1, y2, y3 |
photostationary_cells | photostationary_cells.esm | model Photo, arrays over index set cell (16), $\varphi_c$ written as $(\pi/8)(i - 1)$ for 1-based $i$; photochemistry | Photo.NO2, Photo.NO, Photo.O3, species-major |
advection_reaction | advection_reaction.esm | model Reaction owns $A$ and $B$ and the exchange; model Transport authors D(Reaction.A) (periodic upwind, the seam cell reading cell 64), joined by operator_compose; transport = {"components": "Transport"}, reaction = {"components": "Reaction"} | Reaction.A, Reaction.B, species-major |
source_decay_map | source_decay_map.esm | model Box; the map is the observed Box.u_decayed reading Box.dt (eqice’s form) | Box.u |
source_decay_map is planned from M4b, when map operators arrive (D132; fixture toy_source_decay_map); at M2 its document was validated and its planning was a refusal fixture (unsupported_map_operator).
4.2 Cases
../tests/conformance/m2/cases.json
is generated from the M1 cases by make_cases.py
beside it; CI checks the two agree. An M2 case is the M1 case, changed as follows:
idis the M1 case’sidprefixed withm2., so the two suites’ result files (§3) never carry the samecase;modelis the problem’s document, relative to the cases file, andoperatorsdefines the problem’s operators by the selectors of §4.1, so the M1 schedule’s operator names resolve;- every leaf’s
control.dt_scopeisglobal, as at M1 (D17’scelldefault for pointwise leaves waits for M3, and at M2 an omitteddt_scoperesolves toglobaltoo, D94); adjointis removed and the only check istoy_equivalence(§4.3): planned operators provide novjp_por second-order calls at M2, so they support only the adjoints of spec/operator-interface.md §8.3 (with respect to the initial state), which each implementation’s own tests check;layoutlists the variables of §4.1’s last column.
Left out: source_decay_map (maps), and every case with a Rosenbrock leaf on a time-dependent problem (forced_decay, photostationary_cells), since planned operators have no ft at M2 (spec/plan.md §10 item 4; U17 restores them), and the planner refuses such a leaf (unsupported_time_derivative, D94). That leaves 41 of the 51 M1 cases.
4.3 The toy_equivalence check
A runtime writes an M2 case’s result file (§3) with u in the case’s layout: the listed variables’ cells, each variable column-major, in the listed order. That is §1’s layout. The check compares this result file with the same implementation’s result file for the M1 case named by against, by the rule of the cross_language check (§2.1) with the check’s rtol and rtol_steps_differ: states agree to rtol relative to each component’s largest magnitude when the step sequences agree, and to rtol_steps_differ when they differ, in count or in any accepted step’s $t$ or $h$. Only states and step sequences are compared, not tape paths; an M1 gradient case’s functional and gradient have no counterpart in its M2 run. The two runs evaluate the same equations in a different order of floating-point operations (the hand-written right-hand side against EarthSciAST’s compiled one, and species order inside a block_lu block), so step sequences may differ in adaptive runs, as between languages.
4.4 Cases with data input (D87)
M2’s runtimes also fetch data and run leaves that read it (spec/operator-interface.md §8.4). Three problems with no M1 counterpart gate this, each with an exact solution, so their checks are against a reference rather than toy_equivalence. Together they exercise everything an esm data source can declare that reseact.esm uses, and the rest of esm-spec §8: data_decay the two-record bracket across a file boundary (this section), data_monthly calendar cadence, a custom substitution and mirrors (§4.5), data_points a points source with codes, a record filter and a discovered extent (§4.6). Their data files are small, checked in beside each model with the generator that writes them and the reference result files; CI regenerates them and compares decoded values (not bytes, which the HDF5 library stamps) and references.
data_decay (tests/conformance/toys/data_decay.esm). Model Decay, domain.temporal.reference_time 2016-01-01T00:00:00Z, index sets x (3) and rec (2):
- state
u[x], $u(t_0) = 1$; one operatordecay={"components": "Decay"}, pointwise; Decay.F_k[rec, x], a data-fed parameter (default1.0e-4) from sourceRate:kindgrid,url_templatedata/data_decay/rate_{date:%Y%m%d}.nc,temporal{"start": "2016-01-01T00:00:00Z", "frequency": "PT1H", "file_period": "P1D", "records_per_file": 24, "time_variable": "time"},metadata.esio_format"netcdf",file_variableK, and itsrecaxis a record axis ("records": true, spec/plan.md §4.1);Decay.s[x], a data-fed parameter (default1.0) from sourceScale, astaticsource with notemporal(const), filedata/data_decay/scale.nc,file_variableS;- the observed weight
Decay.w$= \mathrm{frac}(t/3600)$, and $u_i’ = -s_i,\big((1 - w),F_k[1, i] + w,F_k[2, i]\big),u_i$.
Data. Two daily files, rate_20160101.nc and rate_20160102.nc, each with K(time, x) for the 24 hourly records of its day (CF time in hours since 2016-01-01 00:00:00), and scale.nc with S(x). All are netCDF-4, a few kilobytes, checked in under tests/conformance/toys/data/data_decay/ with their generator make_data.py, which also writes the reference result file. The values are $K_{h,i} = 10^{-4},(1 + i/2 + (h \bmod 5)/4)$ for hour $h$ counted from the origin and $i = 0, 1, 2$, and $S_i = 1 + i/4$. CI regenerates the files and compares their decoded values (not their bytes, which the HDF5 library stamps) and the reference.
Exact solution. The blend is linear in $t$ within each hour, so with $\kappa_i(t) = s_i,k_i(t)$, $u_i(t) = \exp!\big(-\int_{t_0}^{t} \kappa_i\big)$, the integral a sum of trapezoids $1800,s_i,(K_{h,i} + K_{h+1,i})$ over whole hours plus a partial one. The generator evaluates it in binary64 at each output time.
Cases. The interval is $[79200, 93600]$ (22:00 on 1 January to 02:00 on 2 January), so the run crosses a file boundary at midnight, and forcing epochs begin at 79200 ($t_0$), 82800, 86400, 90000 and 93600 ($t_f$, a refresh time read only by the stages at exactly $t_f$; spec/operator-interface.md §8.4.3), and the last sample needs the 03:00 record of 2 January, which rate_20160102.nc holds; output.saveat is 3600, and step.hit is ["forcing_refresh", "output"] (spec/plan.md §7.3):
| id | schedule | checks |
|---|---|---|
m2.data_decay.tsit5 | one adaptive Tsit5 leaf, reltol 1e-8, abstol 1e-12 | reference at rtol 1e-6; cross_language with rtol_steps_differ |
m2.data_decay.tsit5_dt600 | one Tsit5 leaf, dt 600 | reference at rtol 1e-7; cross_language |
The runtimes’ own tests add the check of spec/operator-interface.md §8.4.2 item 3 on this model: each buffer at $t_0$ equals EarthSciAST’s esm_problem forcing buffer for the same providers, bit for bit. They also run a variant whose initial condition reads data, ic(u[i]) = Decay.s[i], and check that the run starts from $u_i(t_0) = S_i$, the data value, not the default 1.0 (spec/operator-interface.md §8.4.5), and ends at $S_i$ times the exact solution above. An adaptive Tsit5 run also exercises the selection of spec/operator-interface.md §8.4.1: its stages with $c = 1$ land on each hourly boundary, where $w = 0$ and only the new epoch’s bracket gives the right rate. A Rosenbrock case waits for time-derivative documents (U17), since decay depends on $t$ through $w$.
4.5 data_monthly: calendar cadence, a custom substitution and mirrors
tests/conformance/toys/data_monthly.esm mounts a component file inventory.esm (model Inv, with source Inventory and the data-fed parameter) through {"ref": "data_monthly/inventory.esm", "url_substitutions": {"sector": "point"}}, so the custom substitution is bound by the model at load (esm-spec §4.7, §8.2). Model Emis, domain.temporal.reference_time 2016-01-01T00:00:00Z, index set x (3):
- state
c[x], $c(t_0) = 0$; one operatoremis, pointwise; $c_i’ = E_i$; Emis.E[x], mapped byparam_to_varfrom the data-fedInv.E(which carries thedefault1.0e-6, since the surviving parameter is the source’s declaration, EarthSciAST#634), from sourceInventory:kindgrid,url_templateabsent/inv_{sector}_{date:%Y%m}.nc(no such directory, so the read must fail over),mirrors["inv_{sector}_{date:%Y%m}.nc"],temporal{"start": "2016-01-01T00:00:00Z", "frequency": "P1M", "file_period": "P1M", "records_per_file": 1, "time_variable": "time"},metadata.esio_format"netcdf";file_variableE_day,unit_conversionthe expression $1/86400$ (per day to per second), aselecttaking cells 2–4 of the file’s 5 along itsxdimension, one record per sample.- Data.
inv_point_201601.nc,inv_point_201602.nc,inv_point_201603.nc, eachE_day(time, x)with one record, $E_{m,i} = 10^{-6},(m + i)$ for month $m$ = 1, 2, 3 and file cell $i$ = 1…5. - Exact solution. $E$ is constant within each calendar month, so $c_i(t)$ is the sum over months of $E_{m,i+1}/86400$ times the seconds of the month inside $[t_0, t]$.
- Cases. Interval from 2016-01-20 to 2016-03-10 (
timegiven as timestamps, D74), so the run crosses 1 February and 1 March 2016, a 31-day and a 29-day month, and a cadence of fixed length lands on neither;output.saveat1 day;step.hit["forcing_refresh", "output"].m2.data_monthly.tsit5: one adaptiveTsit5leaf;referenceatrtol1e-10 (the solution is piecewise linear and every month boundary is a tstop),cross_languagewithrtol_steps_differ.
4.6 data_points: a points source with codes, a record filter and an extent
tests/conformance/toys/data_points.esm. Model Src, index sets x (3) and stn sized by the metaparameter N_STN (default 4):
- state
c[x], $c(0) = 0$; one operatorsources, pointwise; $c_i’ = \sum_j \text{rate}_j,[\text{cell}_j = i]$, afaqsum overstnofifelseon the code (it reads no state across cells, so the operator is pointwise); - source
Stations:kindpoints, notemporal(const),url_templatedata_points/stations.csv,metadata.esio_format"csv",record_filter{"require_finite": ["rate"]},extent{"metaparameter": "N_STN"}; data-fedSrc.rate[stn](file_variablerate,default1.0e-3) andSrc.cell[stn](file_variablecell,codesmapping the text codes"a","b","c"to 1, 2, 3,default1.0). - Data.
stations.csv, six rows, two with arateofNaN(not blank: EarthSciIO’s CSV readers never read a blank cell asNaN, so a blank would make the column text), so four survive the filter and the discovered extent equals the plannedN_STN. - Exact solution. $c_i(t) = t \sum_{j:,\text{cell}_j = i} \text{rate}_j$.
- Cases. Interval $[0, 3600]$,
output.saveat600.m2.data_points.tsit5: one adaptiveTsit5leaf;referenceatrtol1e-12,cross_language. The runtimes’ tests add a variant run withN_STNbound to 5 at load, which must be refused before the first step for the extent mismatch (spec/operator-interface.md §8.4.2 item 4).
The Rust CSV reader this case needs arrived with EarthSciIO’s document providers (spec/plan.md §10 item 19).
5. reseact-shaped problems for partitioning (M3)
M3’s runtime cases (spec/partitioning.md §9) run small reseact-shaped problems with each dt_scope and check that results do not depend on how the work is divided. They have no M1 counterpart and no exact solution: their checks are invariance and scope_agreement (spec/partitioning.md §9.3), each implementation on its own, and cross_language.
5.1 reseact_mini
../tests/conformance/toys/reseact_mini.esm
, esm 1.3.0, written with its data by make_data.py
(CI regenerates both and compares the document’s text and the data’s decoded values). Model Mini, domain.temporal.reference_time 2016-01-01T00:00:00Z, index sets lon (6), lat (4), lev (5) and rec (2, a record axis), 120 cells, 360 DOFs; solver.time_span $[79200, 90000]$ (22:00 on 1 January to 01:00 on 2 January 2016).
States
NO2,NO,O3over[lon, lat, lev], defaults 10, 5 and 40.A data-fed parameter
TS[rec, lon, lat](default290) from sourceMet:kindgrid,url_templatedata/reseact_mini/met_{date:%Y%m%d}.nc, hourly records, 24 per daily file,metadata.esio_format"netcdf", file variableTS(time, lon, lat)with $T_{h,i,j} = 285 + 2i + 1.5j + 3 \sin(2\pi h/24)$ for hour $h$ from the origin and 1-based $i$, $j$. The observedw$= t/3600 - \lfloor t/3600 \rfloor$ blends the two records, as reseact’s GEOS-FP fields are blended.With 1-based cell indices $(i, j, k)$:
- photolysis $J = j_0 \max\big(0, \sin(\omega t + (\pi/3)(i - 1))\big),(1 - 0.15(k - 1))$, $j_0 = 10^{-2}$, $\omega = 2\pi/10800$: a sun that rises and sets at a different time in each longitude and weakens with level, so cells switch between day and night stiffness at different times;
- thermal rate $k_T = k_0 (1 + 0.01(T - 290))$, $k_0 = 4.4 \times 10^{-4}$, $T = T_1 + w (T_2 - T_1)$ the blend of
TSat the cell’s column; - $r = J,\mathrm{NO_2} - k_T,\mathrm{NO},\mathrm{O_3}$; chemistry $\mathrm{NO_2}’ = -r$, $\mathrm{NO}’ = r + e_0 \max(0, 2 - k)$ (an NO source at the surface, $e_0 = 0.002$), $\mathrm{O_3}’ = r - v_d,\mathrm{O_3}$ ($v_d = 1.5 \times 10^{-5}$): pointwise;
- periodic first-order upwind advection along
lon, $-(u/\Delta x)(X_{i} - X_{i-1})$ with cell 1 reading cell 6, $u = 10.5$, $\Delta x = 20000.5$: stencil; - a column mean along
lev, $k_{\text{mix}}(\bar X - X_k)$, $k_{\text{mix}} = 5 \times 10^{-4}$: column.
The three parts are summands of one equation per species, so a run config selects them by locality, as reseact.esm’s own run config does:
transport= stencil and column,chemistry= pointwise.
5.2 Cases
../tests/conformance/m3/cases.json
, generated by make_cases.py
. Every reseact_mini case runs $[79200, 90000]$ with the prototype’s split: step.dt 300, hit ["forcing_refresh", "output"], output.saveat 1800; transport SSPRK43 (reltol 1e-4, abstol 1e-6, dt0 15, dt_scope global), then chemistry (reltol 1e-4, abstol 1e-9, dt0 0.5, domain.nonnegative "all", on_violation "reject"). The run crosses a daily file boundary at midnight and an epoch boundary every hour. Results are reported in the layout Mini.NO2, Mini.NO, Mini.O3.
| id | chemistry | dt_scope, partition | checks |
|---|---|---|---|
m3.reseact_mini.global | Rosenbrock23, block_lu without pivoting | global, 4 shards | invariance (shards 1–120, lanes 1–8, threads 1–4), cross_language |
m3.reseact_mini.cell | Rosenbrock23 | cell, 4 shards, 8 lanes | invariance, scope_agreement with m3.reseact_mini.global at 1e-3, cross_language |
m3.reseact_mini.global_trbdf2 | TRBDF2 | global, 4 shards | invariance, cross_language |
m3.reseact_mini.cell_trbdf2 | TRBDF2 | cell, 4 shards, 8 lanes | invariance, scope_agreement with m3.reseact_mini.global_trbdf2 at 1e-3, cross_language |
m3.reseact_mini.shard | TRBDF2 | shard, 4 shards, reshard every 2 | invariance (lanes and threads only), scope_agreement with m3.reseact_mini.global_trbdf2 at 1e-3, cross_language |
photostationary_cells (§1.4, its .esm of §4.1) runs one TRBDF2 leaf (reltol 1e-6, abstol 1e-9, 3 shards) on $[0, 3600]$ with step.dt 600 and output every 600 s, as m3.photostationary_cells.global and m3.photostationary_cells.cell; the second checks scope_agreement with the first at 1e-5. Its cells’ photolysis is phase-shifted, so their step sequences differ under cell.
cross_language uses rtol 1e-9 and rtol_steps_differ 1e-3 throughout. The Rosenbrock23 cases need the time-derivative document (spec/plan.md §6.7), since the chemistry depends on $t$; the TRBDF2 cases do not.