BCR Work-Precision Diagrams

Chris Rackauckas

The following benchmark is of a 1122 ODEs with 24388 terms that describe a stiff chemical reaction network.

using ReactionNetworkImporters, OrdinaryDiffEq, DiffEqBiological,
      Sundials, Plots, DiffEqDevTools, ODEInterface, ODEInterfaceDiffEq,
      LSODA
gr()
prnbng = loadrxnetwork(BNGNetwork(), "BNGRepressilator",
                       joinpath(pathof(ReactionNetworkImporters),"..","..",
                       "data","bcr","bcr.net"))
ERROR: SystemError: opening file "/home/crackauckas/.julia/packages/ReactionNetworkImporters/nZg9K/src/ReactionNetworkImporters.jl/../../data/bcr/bcr.net": Not a directory
rn = deepcopy(prnbng.rn)
ERROR: UndefVarError: prnbng not defined
addodes!(rn; build_jac=false, build_symfuncs=false, build_paramjac=false)
ERROR: UndefVarError: rn not defined
tf = 100000.0
oprob = ODEProblem(rn, prnbng.u₀, (0.,tf), prnbng.p);
ERROR: UndefVarError: prnbng not defined
sparsejac_rn = deepcopy(prnbng.rn)
ERROR: UndefVarError: prnbng not defined
addodes!(sparsejac_rn; build_jac=true, sparse_jac = true, build_symfuncs=false, build_paramjac=false)
ERROR: UndefVarError: sparsejac_rn not defined
tf = 100000.0
sparsejacprob = ODEProblem(sparsejac_rn, prnbng.u₀, (0.,tf), prnbng.p);
ERROR: UndefVarError: prnbng not defined
@show numspecies(rn) # Number of ODEs
ERROR: UndefVarError: rn not defined
@show numreactions(rn) # Apprx. number of terms in the ODE
ERROR: UndefVarError: rn not defined
@show numparams(rn) # Number of Parameters
ERROR: UndefVarError: rn not defined

Picture of the solution

sol = solve(oprob, CVODE_BDF(), saveat=tf/10000., reltol=1e-5, abstol=1e-5)
ERROR: UndefVarError: oprob not defined
plot(sol,legend=false)
ERROR: UndefVarError: sol not defined

For these benchmarks we will be using the timeseries error with these saving points since the final time point is not well-indicative of the solution behavior (capturing the oscillation is the key!).

Generate Test Solution

@time sol = solve(oprob,CVODE_BDF(),abstol=1/10^12,reltol=1/10^12)
ERROR: UndefVarError: oprob not defined
test_sol = TestSolution(sol)
ERROR: UndefVarError: sol not defined

Dense + Automatic Jacobian Solves

Due to the computational cost of the problem, we are only going to focus on the methods which demonstrated computational efficiency on the smaller biochemical benchmark problems. This excludes the exponential integrator, stabilized explicit, and extrapolation classes of methods.

abstols = 1.0 ./ 10.0 .^ (5:8)
reltols = 1.0 ./ 10.0 .^ (5:8);
setups = [Dict(:alg=>Rosenbrock23()),
          Dict(:alg=>TRBDF2()),
          Dict(:alg=>CVODE_BDF()),
          Dict(:alg=>rodas()),
          Dict(:alg=>radau()),
          Dict(:alg=>Rodas4()),
          Dict(:alg=>Rodas5()),
          Dict(:alg=>KenCarp4()),
          Dict(:alg=>RadauIIA5()),
          Dict(:alg=>ROS34PW1a()),
          Dict(:alg=>lsoda()),
          ]
wp = WorkPrecisionSet(prob,abstols,reltols,setups;error_estimate=:l2,
                      saveat=tf/10000.,appxsol=test_sol,maxiters=Int(1e5),numruns=1)
ERROR: UndefVarError: test_sol not defined
plot(wp)
ERROR: UndefVarError: wp not defined

Sparse + Analytical Jacobian

abstols = 1.0 ./ 10.0 .^ (5:8)
reltols = 1.0 ./ 10.0 .^ (5:8);
setups = [Dict(:alg=>Rosenbrock23()),
          Dict(:alg=>TRBDF2()),
          Dict(:alg=>CVODE_BDF()),
          Dict(:alg=>rodas()),
          Dict(:alg=>radau()),
          Dict(:alg=>Rodas4()),
          Dict(:alg=>Rodas5()),
          Dict(:alg=>KenCarp4()),
          Dict(:alg=>RadauIIA5()),
          Dict(:alg=>ROS34PW1a()),
          Dict(:alg=>lsoda()),
          ]
wp = WorkPrecisionSet(sparsejacprob,abstols,reltols,setups;error_estimate=:l2,
                      saveat=tf/10000.,appxsol=test_sol,maxiters=Int(1e5),numruns=1)
ERROR: UndefVarError: test_sol not defined
plot(wp)
ERROR: UndefVarError: wp not defined