Benchmark: Solution of the HIRES problem
We use the stiff HIRES problem prob_pds_hires to assess the efficiency of different solvers from OrdinaryDiffEq.jl and PositiveIntegrators.jl.
using OrdinaryDiffEqFIRK, OrdinaryDiffEqRosenbrock, OrdinaryDiffEqSDIRKusing PositiveIntegrators# select HIRES problemprob = prob_pds_hiresTo keep the following code as clear as possible, we define a helper function hires_plot that we use for plotting.
using Plotsfunction hires_plot(sols, labels = fill("", length(sols)), sol_ref = nothing) if !(sols isa Vector) sols = [sols] end if !(labels isa Vector) labels = [labels] end layout = (4, 2) size = (800, 800) linewidth = 2 tickfontsize = 7 xguide = ["" "" "" "" "" "" "t" "t"] yguide = ["u₁" "u₂" "u₃" "u₄" "u₅" "u₆" "u₇" "u₈"] legend = :best legendfontsize = 7 widen = true # Time points for plotting interpolated solutions. They resolve the fast # initial transient while keeping the figure files small. tspan = prob_pds_hires.tspan plotat = [range(first(tspan), 3.0, length = 101); range(3.0, last(tspan), length = 301)[2:end]] p = plot(; layout, size) if !isnothing(sol_ref) plot!(p, sol_ref; linestyle = :dash, label = "Ref.", linewidth, plotat, color = :black, legend, legendfontsize) end for (sol, label) in zip(sols, labels) # Solutions with more time steps than `plotat` are only plotted at # `plotat`, which reduces the file size without visible changes. points = length(sol.t) > length(plotat) ? (; plotat) : (; denseplot = false) plot!(p, sol; xguide, tickfontsize, yguide, legend, legendfontsize, widen, linewidth, label, points...) end return pendFirst, we show approximations of Rosenbrock23() and MPRK22(1.0) using loose tolerances.
# compute reference solution for plottingref_sol = solve(prob, Rodas4P(); abstol = 1e-14, reltol = 1e-13);# compute solutions with loose tolerancesabstol = 1e-2reltol = 1e-1sol_Ros23 = solve(prob, Rosenbrock23(); abstol, reltol);sol_MPRK = solve(prob, MPRK22(1.0); abstol, reltol);# plot solutionshires_plot([sol_Ros23, sol_MPRK], ["Rosenbrock23", "MPRK22(1.0)"], ref_sol)The Rosenbrock23 solution contains negative values in the components $u_5$ and $u_6$.
isnonnegative(sol_Ros23)falseThe MPRK22(1.0) solution is nonnegative, but the components $u_5$ and $u_6$ decay too slowly. Neither solution resolves the rapid change of $u_7$ and $u_8$ near the final time.
OrdinaryDiffEq.jl provides the solver option isoutofdomain, which can be used in combination with isnegative to guarantee nonnegative solutions.
# compute solution with isoutofdomain = isnegativesol_Ros23 = solve(prob, Rosenbrock23(); abstol, reltol, isoutofdomain = isnegative); #reject negative solutionsisnonnegative(sol_Ros23)trueWith stricter tolerances, MPRK schemes also capture the behavior near the final time.
sol1 = solve(prob, MPRK43I(1.0, 0.5); abstol = 1e-4, reltol = 1e-3);sol2 = solve(prob, MPRK43I(1.0, 0.5); abstol = 1e-6, reltol = 1e-5);# plot solutionshires_plot([sol1, sol2], ["MPRK43I(1.0,0.5), abstol=1e-4", "MPRK43I(1.0,0.5), abstol=1e-6"], ref_sol)Work-Precision diagrams
In the following we show several work-precision diagrams, which compare different methods with respect to computing time and the respective error. We focus solely on adaptive methods.
Since the HIRES problem is stiff, we need to use a suited implicit scheme to compute a reference solution, see the solver guide. Note that we cannot use the recommended method radau(), since prob_pds_hires uses StaticArrays.jl instead of standard Arrays.
# select solver to compute reference solutionalg_ref = Rodas4P()We use the functions work_precision_adaptive and work_precision_adaptive! to compute the data for the diagrams. Furthermore, the following absolute and relative tolerances are used.
# set absolute and relative tolerancesabstols = 1.0 ./ 10.0 .^ (2:1:9)reltols = abstols .* 10.0The error chosen to compare the performances of different solvers is the relative maximum error at the final time $t = 321.8122$. We do not use the relative maximum error over all time steps (rel_max_error_overall), since most components of the initial value vanish. The reference values of some components are therefore tiny after the first time step, and the relative error over all time steps is close to one for all tolerances considered here.
# select relative maximum error at the end of the problem's time span.compute_error = rel_max_error_tendWe start with a comparison of different adaptive MPRK schemes.
# choose methods to comparealgs = [MPRK22(0.5); MPRK22(2.0 / 3.0); MPRK22(1.0); SSPMPRK22(0.5, 1.0); MPRK43I(1.0, 0.5); MPRK43I(0.5, 0.75); MPRK43II(0.5); MPRK43II(2.0 / 3.0)]labels = ["MPRK22(0.5)"; "MPRK22(2/3)"; "MPRK22(1.0)"; "SSPMPRK22(0.5,1.0)"; "MPRK43I(1.0,0.5)"; "MPRK43I(0.5,0.75)"; "MPRK43II(0.5)"; "MPRK43II(2.0/3.0)"]# compute work-precision datawp = work_precision_adaptive(prob, algs, labels, abstols, reltols, alg_ref; compute_error)# plot work-precision diagramplot(wp, labels; title = "HIRES benchmark", legend = :outerright, color = permutedims([repeat([1], 3)..., 2, repeat([3], 2)..., repeat([4], 2)...]), xlims = (10^-4, 10^2), xticks = 10.0 .^ (-4:1:2), ylims = (10^-5, 10^0), yticks = 10.0 .^ (-5:1:0), minorticks = 10)The third-order schemes are more efficient than the second-order schemes, and MPRK43I(1.0, 0.5) performs best. Next, we compare the MPDeC methods to MPRK43I(1.0, 0.5).
# choose methods to comparealgs = [MPRK43I(1.0, 0.5); MPDeC(2); MPDeC(3); MPDeC(4); MPDeC(5); MPDeC(6); MPDeC(7); MPDeC(8); MPDeC(9); MPDeC(10)]labels = ["MPRK43I(1.0,0.5)"; "MPDeC(2)"; "MPDeC(3)"; "MPDeC(4)"; "MPDeC(5)"; "MPDeC(6)"; "MPDeC(7)"; "MPDeC(8)"; "MPDeC(9)"; "MPDeC(10)"]# compute work-precision datawp = work_precision_adaptive(prob, algs, labels, abstols, reltols, alg_ref; compute_error)# plot work-precision diagramplot(wp, labels; title = "HIRES benchmark", legend = :outerright, color = permutedims([3, repeat([5], 9)...]), xlims = (10^-4, 10^2), xticks = 10.0 .^ (-4:1:2), ylims = (10^-5, 10^0), yticks = 10.0 .^ (-5:1:0), minorticks = 10)The higher-order MPDeC methods yield smaller errors for loose tolerances, but their errors stop decreasing at about $10^{-3}$ for the stricter tolerances. Overall, the MPDeC methods do not provide a clear benefit compared to MPRK43I(1.0, 0.5).
For comparisons with schemes from OrdinaryDiffEq.jl, we choose the second-order scheme MPRK22(1.0), the third-order scheme MPRK43I(1.0, 0.5), and the 10th order scheme MPDeC(10). We compare these schemes with a selection of second- and third-order stiff solvers from OrdinaryDiffEq.jl. To guarantee nonnegative solutions, we use the solver option isoutofdomain = isnegative.
# select reference MPRK methodsalgs1 = [MPRK22(1.0); MPRK43I(1.0, 0.5); MPDeC(10)]labels1 = ["MPRK22(1.0)"; "MPRK43I(1.0,0.5)"; "MPDeC(10)"]# select methods from OrdinaryDiffEqalgs2 = [TRBDF2(); Kvaerno3(); KenCarp3(); Rodas3(); ROS2(); ROS3(); Rosenbrock23()]labels2 = ["TRBDF2"; "Kvaerno3"; "KenCarp3"; "Rodas3"; "ROS2"; "ROS3"; "Rosenbrock23"]# compute work-precision datawp = work_precision_adaptive(prob, algs1, labels1, abstols, reltols, alg_ref; compute_error)# add work-precision data with isoutofdomain = isnegativework_precision_adaptive!(wp, prob, algs2, labels2, abstols, reltols, alg_ref; compute_error, isoutofdomain = isnegative)# plot work-precision diagramplot(wp, [labels1; labels2]; title = "HIRES benchmark", legend = :outerright, color = permutedims([1, 3, 5, repeat([4], 3)..., repeat([6], 4)...]), xlims = (10^-8, 10^2), xticks = 10.0 .^ (-8:1:2), ylims = (10^-5, 10^0), yticks = 10.0 .^ (-5:1:0), minorticks = 10)For this problem, the schemes from OrdinaryDiffEq.jl are clearly more efficient than the MPRK schemes for all tolerances considered here. Among them, only ROS2() is noticeably slower. For loose tolerances, it rejects many steps due to isoutofdomain = isnegative, since it produces negative values otherwise.
Finally, we compare the selected MPRK schemes to some recommended solvers of higher order from OrdinaryDiffEq.jl. Again, to guarantee nonnegative solutions we select the solver option isoutofdomain = isnegative.
algs3 = [Rodas5P(); Rodas4P(); RadauIIA5()]labels3 = ["Rodas5P"; "Rodas4P"; "RadauIIA5"]# compute work-precision datawp = work_precision_adaptive(prob, algs1, labels1, abstols, reltols, alg_ref; compute_error)# add work-precision data with isoutofdomain = isnegativework_precision_adaptive!(wp, prob, algs3, labels3, abstols, reltols, alg_ref; compute_error, isoutofdomain = isnegative)# plot work-precision diagramplot(wp, [labels1; labels3]; title = "HIRES benchmark", legend = :outerright, color = permutedims([1, 3, 5, repeat([6], 2)..., 7]), xlims = (10^-8, 10^2), xticks = 10.0 .^ (-8:1:2), ylims = (10^-5, 10^0), yticks = 10.0 .^ (-5:1:0), minorticks = 10)Again, the schemes from OrdinaryDiffEq.jl are more efficient than the MPRK schemes.
Package versions
These results were obtained using the following versions.
using InteractiveUtilsversioninfo()println()using PkgPkg.status(["PositiveIntegrators", "StaticArrays", "LinearSolve", "OrdinaryDiffEqFIRK", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqSDIRK"], mode = PKGMODE_MANIFEST)Julia Version 1.13.4
Commit c1ac32ab733 (2026-11-13 17:30 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × AMD EPYC 7763 64-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-20.1.8 (ORCJIT, znver3)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)
Environment:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE = eager
Status `~/work/PositiveIntegrators.jl/PositiveIntegrators.jl/docs/Manifest.toml`
[47edcb42] ADTypes v1.24.0
[14f7f29c] AMD v0.5.4
[4fba245c] ArrayInterface v7.30.2
[38540f10] CommonSolve v0.2.14
[2569d6c7] ConcreteStructs v0.2.8
[187b0558] ConstructionBase v1.6.1
[82cc6244] DataInterpolations v10.1.4
[2b5f629d] DiffEqBase v7.21.6
[a0c0ee7d] DifferentiationInterface v0.7.22
⌅ [ffbed154] DocStringExtensions v0.9.5
[4e289a0a] EnumX v1.0.7
[7034ab61] FastBroadcast v1.5.1
[442a2c76] FastGaussQuadrature v1.3.0
[a4df4552] FastPower v1.5.1
[6a86dc24] FiniteDiff v2.33.0
[f6369f11] ForwardDiff v1.5.0
[46192b85] GPUArraysCore v0.2.2
[ba0b0d4f] Krylov v0.10.12
[2faa5264] LHLFactorization v2.2.2
[7ed4a6bd] LinearSolve v5.18.3
[1914dd2f] MacroTools v0.5.16
[46d2c3a1] MuladdMacro v0.2.7
[bbf590c4] OrdinaryDiffEqCore v4.19.1
[4302a76b] OrdinaryDiffEqDifferentiation v3.12.5
[5960d6e9] OrdinaryDiffEqFIRK v2.8.9
[127b3ac7] OrdinaryDiffEqNonlinearSolve v2.9.10
[43230ef6] OrdinaryDiffEqRosenbrock v2.7.5
[b4bd8bb3] OrdinaryDiffEqRosenbrockTableaus v2.4.2
[2d112036] OrdinaryDiffEqSDIRK v2.9.8
[f517fe37] Polyester v0.7.19
[d1b20bf0] PositiveIntegrators v0.2.25-DEV `~/work/PositiveIntegrators.jl/PositiveIntegrators.jl`
[d236fae5] PreallocationTools v1.7.1
[aea7be01] PrecompileTools v1.4.0
[21216c6a] Preferences v1.6.1
[0c0d3e7f] PureKLU v1.6.0
[3cdcf5f2] RecipesBase v1.4.0
[731186ca] RecursiveArrayTools v4.5.6
[189a3867] Reexport v1.2.2
[0bca4576] SciMLBase v3.58.0
[a6db7da4] SciMLLogging v2.1.0
[c0aeaf25] SciMLOperators v1.30.4
[53ae85a6] SciMLStructures v1.10.6
[efcf1570] Setfield v1.2.0
[a57abbd0] SparseColumnPivotedQR v2.1.8
[90137ffa] StaticArrays v1.9.25
[1e83bf80] StaticArraysCore v1.4.5
[10745b16] Statistics v1.11.5
[2efcf032] SymbolicIndexingInterface v0.3.56
[781d530d] TruncatedStacktraces v1.4.0
[856f044c] MKL_jll v2025.2.0+0
[b77e0a4c] InteractiveUtils v1.11.0
[8f399da3] Libdl v1.11.0
[37e2e46d] LinearAlgebra v1.13.0
[d6f4376e] Markdown v1.11.0
[9a3f8284] Random v1.11.0
[2f01184e] SparseArrays v1.13.0
[4536629a] OpenBLAS_jll v0.3.30+1
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`