From bbfdae2ec30fd7a40b776c560b9805d679210be8 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 31 Aug 2024 16:27:39 -0400 Subject: [PATCH] format --- docs/src/implicit/PDIRK.md | 2 +- .../src/caches/basic_caches.jl | 2 +- lib/OrdinaryDiffEqCore/src/interp_func.jl | 4 ++-- .../src/rosenbrock_caches.jl | 4 +++- test/interface/get_du.jl | 18 +++++++++++------- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/src/implicit/PDIRK.md b/docs/src/implicit/PDIRK.md index 636c8dd705..4838693e9c 100644 --- a/docs/src/implicit/PDIRK.md +++ b/docs/src/implicit/PDIRK.md @@ -18,7 +18,7 @@ these matrices can be factorized and the underlying steps can be computed in par which is why these are the parallel DIRK methods. !!! warning "Experimental" - + `OrdinaryDiffEqPDIRK` is experimental, as there are no parallel DIRK tableaus that achieve good performance in the literature. diff --git a/lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl b/lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl index 9bbc9bd177..32d3774859 100644 --- a/lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl +++ b/lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl @@ -13,7 +13,7 @@ mutable struct CompositeCache{T, F} <: OrdinaryDiffEqCache current::Int end -function get_fsalfirstlast(cache::CompositeCache, u) +function get_fsalfirstlast(cache::CompositeCache, u) _x = get_fsalfirstlast(cache.caches[1], u) if first(_x) !== nothing return _x diff --git a/lib/OrdinaryDiffEqCore/src/interp_func.jl b/lib/OrdinaryDiffEqCore/src/interp_func.jl index d839c53bdd..782f7e249c 100644 --- a/lib/OrdinaryDiffEqCore/src/interp_func.jl +++ b/lib/OrdinaryDiffEqCore/src/interp_func.jl @@ -75,7 +75,8 @@ function SciMLBase.strip_interpolation(id::InterpolationData) end function strip_cache(cache) - if hasfield(typeof(cache), :jac_config) || hasfield(typeof(cache), :grad_config) || hasfield(typeof(cache), :nlsolver) + if hasfield(typeof(cache), :jac_config) || hasfield(typeof(cache), :grad_config) || + hasfield(typeof(cache), :nlsolver) fieldnums = length(fieldnames(typeof(cache))) noth_list = fill(nothing, fieldnums) cache_type_name = Base.typename(typeof(cache)).wrapper @@ -84,4 +85,3 @@ function strip_cache(cache) cache end end - diff --git a/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_caches.jl b/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_caches.jl index bf8cfb33cd..6a26cf2dba 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_caches.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_caches.jl @@ -4,7 +4,9 @@ abstract type RosenbrockConstantCache <: OrdinaryDiffEqConstantCache end # Fake values since non-FSAL get_fsalfirstlast(cache::RosenbrockMutableCache, u) = (nothing, nothing) -get_fsalfirstlast(cache::GenericRosenbrockMutableCache, u) = (cache.fsalfirst, cache.fsallast) +function get_fsalfirstlast(cache::GenericRosenbrockMutableCache, u) + (cache.fsalfirst, cache.fsallast) +end ################################################################################ diff --git a/test/interface/get_du.jl b/test/interface/get_du.jl index f4ad7c9c37..d745a63132 100644 --- a/test/interface/get_du.jl +++ b/test/interface/get_du.jl @@ -6,7 +6,7 @@ function lorenz!(du, u, p, t) end u0 = [1.0; 0.0; 0.0] tspan = (0.0, 3.0) -condition(u,t,integrator) = t == 0.2 +condition(u, t, integrator) = t == 0.2 cache = zeros(3) affect!(integrator) = cache .= get_du(integrator) dusave = DiscreteCallback(condition, affect!) @@ -14,13 +14,17 @@ affect2!(integrator) = get_du!(cache, integrator) dusave_inplace = DiscreteCallback(condition, affect2!) prob = ODEProblem(lorenz!, u0, tspan) -sol = solve(prob, Tsit5(), tstops = [0.2], callback = dusave, abstol=1e-12, reltol=1e-12) +sol = solve( + prob, Tsit5(), tstops = [0.2], callback = dusave, abstol = 1e-12, reltol = 1e-12) res = copy(cache) -for alg in [Vern6(), Vern7(), Vern8(), Vern9(), Rodas4(), Rodas4P(), Rodas5(), Rodas5P(), TRBDF2(), KenCarp4(), FBDF(), QNDF()] - sol = solve(prob, alg, tstops = [0.2], callback = dusave, abstol=1e-12, reltol=1e-12) - @test res ≈ cache rtol=1e-5 +for alg in [Vern6(), Vern7(), Vern8(), Vern9(), Rodas4(), Rodas4P(), + Rodas5(), Rodas5P(), TRBDF2(), KenCarp4(), FBDF(), QNDF()] + sol = solve( + prob, alg, tstops = [0.2], callback = dusave, abstol = 1e-12, reltol = 1e-12) + @test res≈cache rtol=1e-5 - sol = solve(prob, alg, tstops = [0.2], callback = dusave_inplace, abstol=1e-12, reltol=1e-12) - @test res ≈ cache rtol=1e-5 + sol = solve(prob, alg, tstops = [0.2], callback = dusave_inplace, + abstol = 1e-12, reltol = 1e-12) + @test res≈cache rtol=1e-5 end