SciML / DiffEqDevTools.jl

Benchmarking, testing, and development tools for differential equations and scientific machine learning (SciML)
https://benchmarks.sciml.ai/
Other
48 stars 35 forks source link

Add BVP precision diagram #116

Closed ErikQQY closed 1 year ago

ErikQQY commented 1 year ago
using BoundaryValueDiffEq, DiffEqDevTools, OrdinaryDiffEq

λ = 1
function prob_bvp_linear_1_analytic(u, λ, t)
    a = 1 / sqrt(λ)
    [(exp(-a * t) - exp((t - 2) * a)) / (1 - exp(-2 * a)),
        (-a * exp(-t * a) - a * exp((t - 2) * a)) / (1 - exp(-2 * a))]
end
function prob_bvp_linear_1_f!(du, u, p, t)
    du[1] = u[2]
    du[2] = 1 / p * u[1]
end
function prob_bvp_linear_1_bc!(res, u, p, t)
    res[1] = u[1][1] - 1
    res[2] = u[end][1]
end
prob_bvp_linear_1_function = ODEFunction(prob_bvp_linear_1_f!,
    analytic = prob_bvp_linear_1_analytic)
prob_bvp_linear_1_tspan = (0.0, 1.0)
prob_bvp_linear_1 = BVProblem(prob_bvp_linear_1_function,
    prob_bvp_linear_1_bc!,
    [1.0, 0.0],
    prob_bvp_linear_1_tspan,
    λ)
sol=solve(prob_bvp_linear_1, Shooting(Tsit5()), abstol=1e-14, reltol=1e-14)
test_sol = TestSolution(sol.t, sol.u)

abstols = 1.0 ./ 10.0 .^ (2:5)
reltols = 1.0 ./ 10.0 .^ (2:5);
setups = [Dict(:alg=>MIRK4(), :dts=>1.0./5.0.^((1:length(reltols)) .+ 1))
Dict(:alg=>MIRK5(), :dts=>1.0./5.0.^((1:length(reltols)) .+ 1))]
labels = ["Julia: MIRK4"
"Julia: MIRK5"]

wp=WorkPrecisionSet(prob_bvp_linear_1,abstols,reltols,setups; appxsol = test_sol, names = labels,print_names = true)

bvp_wp