Skip to content

Commit

Permalink
Merge pull request #129 from devmotion/verner_rk_eest
Browse files Browse the repository at this point in the history
Update tableaus and error estimate calculation of Verner RK methods
  • Loading branch information
ChrisRackauckas authored Aug 8, 2017
2 parents c48f07a + 06f2c16 commit 28fe64b
Show file tree
Hide file tree
Showing 7 changed files with 462 additions and 389 deletions.
21 changes: 9 additions & 12 deletions src/caches/verner_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,21 @@ struct Vern7Cache{uType,uArrayType,rateType,uEltypeNoUnits,TabType} <: OrdinaryD
k9::rateType
k10::rateType
utilde::uArrayType
update::uArrayType
tmp::uType
atmp::uEltypeNoUnits
tab::TabType
end

u_cache(c::Vern7Cache) = (c.utilde,c.update,c.atmp)
u_cache(c::Vern7Cache) = (c.utilde,c.atmp)
du_cache(c::Vern7Cache) = (c.k1,c.k2,c.k3,c.k4,c.k5,c.k6,c.k7,c.k8,c.k9,c.k10)

function alg_cache(alg::Vern7,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,reltol,::Type{Val{true}})
tab = Vern7ConstantCache(real(uEltypeNoUnits),real(tTypeNoUnits))
k1 = zeros(rate_prototype); k2 = zeros(rate_prototype); k3 = zeros(rate_prototype); k4 = zeros(rate_prototype);
k5 = zeros(rate_prototype); k6 = zeros(rate_prototype); k7 = zeros(rate_prototype); k8 = zeros(rate_prototype);
k9 = zeros(rate_prototype); k10 = zeros(rate_prototype); utilde = similar(u,indices(u)); update = similar(u,indices(u))
k9 = zeros(rate_prototype); k10 = zeros(rate_prototype); utilde = similar(u,indices(u))
tmp = similar(u); atmp = similar(u,uEltypeNoUnits,indices(u))
Vern7Cache(u,uprev,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,utilde,update,tmp,atmp,tab)
Vern7Cache(u,uprev,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,utilde,tmp,atmp,tab)
end

alg_cache(alg::Vern7,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,reltol,::Type{Val{false}}) = Vern7ConstantCache(real(uEltypeNoUnits),real(tTypeNoUnits))
Expand All @@ -83,13 +82,12 @@ struct Vern8Cache{uType,uArrayType,rateType,uEltypeNoUnits,TabType} <: OrdinaryD
k12::rateType
k13::rateType
utilde::uArrayType
update::uArrayType
tmp::uType
atmp::uEltypeNoUnits
tab::TabType
end

u_cache(c::Vern8Cache) = (c.utilde,c.update,c.atmp)
u_cache(c::Vern8Cache) = (c.utilde,c.atmp)
du_cache(c::Vern8Cache) = (c.k1,c.k2,c.k3,c.k4,c.k5,c.k6,c.k7,c.k8,c.k9,c.k10,c.k11,c.k12,c.k13)

function alg_cache(alg::Vern8,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,reltol,::Type{Val{true}})
Expand All @@ -100,9 +98,9 @@ function alg_cache(alg::Vern8,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev
k8 = zeros(rate_prototype); tmp = similar(u)
k9 = zeros(rate_prototype); k10 = zeros(rate_prototype); k11 = zeros(rate_prototype);
k12 = zeros(rate_prototype); k13 = zeros(rate_prototype)
utilde = similar(u,indices(u)); update = similar(u,indices(u));
utilde = similar(u,indices(u))
atmp = similar(u,uEltypeNoUnits,indices(u))
Vern8Cache(u,uprev,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,utilde,update,tmp,atmp,tab)
Vern8Cache(u,uprev,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,utilde,tmp,atmp,tab)
end

alg_cache(alg::Vern8,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,reltol,::Type{Val{false}}) = Vern8ConstantCache(real(uEltypeNoUnits),real(tTypeNoUnits))
Expand All @@ -127,13 +125,12 @@ struct Vern9Cache{uType,uArrayType,rateType,uEltypeNoUnits,TabType} <: OrdinaryD
k15::rateType
k16::rateType
utilde::uArrayType
update::uArrayType
tmp::uType
atmp::uEltypeNoUnits
tab::TabType
end

u_cache(c::Vern9Cache) = (c.utilde,c.update,c.atmp)
u_cache(c::Vern9Cache) = (c.utilde,c.atmp)
du_cache(c::Vern9Cache) = (c.k1,c.k2,c.k3,c.k4,c.k5,c.k6,c.k7,c.k8,c.k9,c.k10,c.k11,c.k12,c.k13,c.k14,c.k15,c.k16)

function alg_cache(alg::Vern9,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,reltol,::Type{Val{true}})
Expand All @@ -143,11 +140,11 @@ function alg_cache(alg::Vern9,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev
k5 = zeros(rate_prototype); k6 = zeros(rate_prototype);k7 = zeros(rate_prototype);
k8 = zeros(rate_prototype);
k9 = zeros(rate_prototype); k10 = zeros(rate_prototype); k11 = zeros(rate_prototype);
k12 = zeros(rate_prototype); update = similar(u,indices(u))
k12 = zeros(rate_prototype);
k13 = zeros(rate_prototype); k14 = zeros(rate_prototype); k15 = zeros(rate_prototype);
k16 =zeros(rate_prototype);
utilde = similar(u,indices(u)); tmp = similar(u); atmp = similar(u,uEltypeNoUnits,indices(u));
Vern9Cache(u,uprev,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,utilde,update,tmp,atmp,tab)
Vern9Cache(u,uprev,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,utilde,tmp,atmp,tab)
end

alg_cache(alg::Vern9,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,reltol,::Type{Val{false}}) = Vern9ConstantCache(real(uEltypeNoUnits),real(tTypeNoUnits))
Loading

0 comments on commit 28fe64b

Please sign in to comment.