Skip to content

Commit

Permalink
Add VelocityVerlet related types
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Jun 27, 2017
1 parent 3ef4a73 commit 927b7ae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/OrdinaryDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module OrdinaryDiffEq

export LawsonEuler, NorsettEuler

export SymplecticEuler
export SymplecticEuler, VelocityVerlet

#export Verlet, VelocityVerlet

Expand Down
2 changes: 2 additions & 0 deletions src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ isfsal(alg::NorsettEuler) = true
isfsal(alg::Euler) = true
isfsal(alg::SplitEuler) = true
isfsal(alg::SymplecticEuler) = true
isfsal(alg::VelocityVerlet) = true
isfsal(alg::Midpoint) = true
isfsal(alg::SSPRK22) = true
isfsal(alg::SSPRK33) = true
Expand Down Expand Up @@ -80,6 +81,7 @@ alg_order(alg::LawsonEuler) = 1
alg_order(alg::NorsettEuler) = 1
alg_order(alg::SplitEuler) = 1
alg_order(alg::SymplecticEuler) = 1
alg_order(alg::VelocityVerlet) = 2
alg_order(alg::Midpoint) = 2
alg_order(alg::IIF1) = 1
alg_order(alg::IIF2) = 2
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ immutable SSPRK104 <: OrdinaryDiffEqAlgorithm end

#immutable Verlet <: OrdinaryDiffEqAlgorithm end
immutable SymplecticEuler <: OrdinaryDiffEqAlgorithm end
#immutable VelocityVerlet <: OrdinaryDiffEqAdaptiveAlgorithm end
immutable VelocityVerlet <: OrdinaryDiffEqAlgorithm end

immutable SplitEuler <: OrdinaryDiffEqAlgorithm end

Expand Down
22 changes: 22 additions & 0 deletions src/caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ immutable SymplecticEulerConstantCache <: OrdinaryDiffEqConstantCache end

alg_cache(alg::SymplecticEuler,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,::Type{Val{false}}) = SymplecticEulerConstantCache()

immutable VelocityVerletCache{uType,rateType} <: OrdinaryDiffEqMutableCache
u::uType
uprev::uType
tmp::uType
k::rateType
fsalfirst::rateType
end

u_cache(c::VelocityVerletCache) = ()
du_cache(c::VelocityVerletCache) = (c.k,c.fsalfirst)

immutable VelocityVerletConstantCache <: OrdinaryDiffEqConstantCache end

function alg_cache(alg::VelocityVerlet,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,::Type{Val{true}})
tmp = similar(u)
k = zeros(rate_prototype)
fsalfirst = zeros(rate_prototype)
VelocityVerletCache(u,uprev,k,tmp,fsalfirst)
end

alg_cache(alg::VelocityVerlet,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,::Type{Val{false}}) = VelocityVerletConstantCache()

immutable MidpointCache{uType,rateType} <: OrdinaryDiffEqMutableCache
u::uType
uprev::uType
Expand Down

0 comments on commit 927b7ae

Please sign in to comment.