Skip to content

Commit

Permalink
fix mass matrix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Aug 13, 2017
1 parent ed6cfca commit eb0fd35
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/initdt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
dt = tdir*min(100dt₀,dt₁,dtmax_tdir)
end

@muladd function ode_determine_initdt{uType,tType}(u0::uType,t,tdir,dtmax,abstol,reltol,internalnorm,prob::AbstractODEProblem{uType,tType,false},order)
@muladd function ode_determine_initdt{uType,tType}(u0::uType,t,tdir,dtmax,abstol,reltol,internalnorm,prob::AbstractODEProblem{uType,tType,false},order,alg)
f = prob.f
oneunit_tType = oneunit(tType)
dtmax_tdir = tdir*dtmax
Expand Down
39 changes: 27 additions & 12 deletions test/mass_matrix_tests.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using OrdinaryDiffEq, Base.Test

const A = [-2.0 1 4
const mm_A = [-2.0 1 4
4 -2 1
2 1 3]
const b = A*ones(3)
function f(t,u,du)
A_mul_B!(du,A,u)
tmp = t*b
const mm_b = mm_A*ones(3)
function mm_f(t,u,du)
A_mul_B!(du,mm_A,u)
tmp = t*mm_b
du .+= tmp
end
function f(::Type{Val{:analytic}},t,u0)
function mm_f(::Type{Val{:analytic}},t,u0)
@. 2ones(3)*exp(t) - t - 1
end
function g(t,u,du)
function mm_g(t,u,du)
du .= u + t
end
function g(::Type{Val{:analytic}},t,u0)
function mm_g(::Type{Val{:analytic}},t,u0)
@. 2ones(3)*exp(t) - t - 1
end
prob2 = ODEProblem(g,ones(3),(0.0,1.0))
prob = ODEProblem(f,ones(3),(0.0,1.0),mass_matrix=A)
prob2 = ODEProblem(mm_g,ones(3),(0.0,1.0))
prob = ODEProblem(mm_f,ones(3),(0.0,1.0),mass_matrix=mm_A)

######################################### Test each method for exactness

Expand Down Expand Up @@ -63,12 +63,27 @@ sol2 = solve(prob2,ImplicitEuler())

@test norm(sol .- sol2) 0 atol=1e-9

sol = solve(prob, Trapezoid())
sol2 = solve(prob2,Trapezoid())

@test norm(sol .- sol2) 0 atol=1e-9


#=
sol = solve(prob, TRBDF2())
sol2 = solve(prob2,TRBDF2())
@test norm(sol .- sol2) ≈ 0 atol=1e-9
#sol = solve(prob, SDIRK2())
#sol2 = solve(prob2, SDIRK2())
#@test norm(sol .- sol2) ≈ 0 atol=1e-11
#sol = solve(prob, Rodas3(),adaptive=false,dt=1/10)
#sol2 = solve(prob2, Rodas3(),adaptive=false,dt=1/10)
sol = solve(prob, TRBDF2(),adaptive=false,dt=1/10)
sol2 = solve(prob2, TRBDF2(),adaptive=false,dt=1/10)
=#
2 changes: 1 addition & 1 deletion test/ode/ode_cache_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OrdinaryDiffEq, DiffEqBase

NON_IMPLICIT_ALGS = filter((x)->isleaftype(x) && !OrdinaryDiffEq.isimplicit(x()),union(subtypes(OrdinaryDiffEqAlgorithm),subtypes(OrdinaryDiffEqAdaptiveAlgorithm)))
NON_IMPLICIT_ALGS = filter((x)->isleaftype(x) && !OrdinaryDiffEq.isimplicit(x()),union(subtypes(OrdinaryDiffEq.OrdinaryDiffEqAlgorithm),subtypes(OrdinaryDiffEq.OrdinaryDiffEqAdaptiveAlgorithm)))

f = function (t,u,du)
for i in 1:length(u)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tic()
@time @testset "Initial Dt Tests" begin include("ode/ode_initdt_tests.jl") end
@time @testset "OwrenZen Tests" begin include("owrenzen_tests.jl") end
@time @testset "Rosenbrock Tests" begin include("ode/ode_rosenbrock_tests.jl") end
@time @testset "Mass Matrix Tests" begin include("mass_matrix_tests.jl") end
@time @testset "Differentiation Trait Tests" begin include("differentiation_traits_tests.jl") end
@time @testset "Partitioned Methods Tests" begin include("partitioned_methods_tests.jl") end
@time @testset "Split Methods Tests" begin include("split_methods_tests.jl") end
Expand Down

0 comments on commit eb0fd35

Please sign in to comment.