Skip to content

Commit 30762dd

Browse files
committed
Continuous init
1 parent 35b473e commit 30762dd

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/continuous.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@ struct Continuous <: AbstractProcess
33
f :: Vector{Function}
44
order :: UInt8
55
stiff :: Bool
6+
t :: Vector{Float64}
67
q :: Vector{Taylor1}
78
x :: Vector{Taylor1}
89
p :: Vector{Float64}
910
function Continuous(func::Function, env::Environment, q::Vector{Float64}, p::Vector{Float64}=Float64[]; order::Number=4, stiff::Bool=false)
10-
cont = new(BaseEvent(env), func(), UInt8(order), stiff, Vector{Taylor1}(), Vector{Taylor1}(), p)
11+
cont = new(BaseEvent(env), func(), UInt8(order), stiff, Vector{Float64}(), Vector{Taylor1}(), Vector{Taylor1}(), p)
1112
for q₀ in q
13+
push!(cont.t, now(env))
1214
push!(cont.q, q₀ + Taylor1(Float64, order+1))
1315
end
14-
t = now(env) + Taylor1(Float64, order+1)
16+
t = now(env) + Taylor1(Float64, order+1)
1517
for (i, q₀) in enumerate(q)
16-
push!(cont.x, integrate(cont.f[i](t, cont.q, cont.p), q₀))
18+
push!(cont.x, integrate(cont.f[i](t₀, cont.q, cont.p), q₀))
19+
end
20+
for i in 1:order-1
21+
for (i, xᵢ) in enumerate(cont.x)
22+
cont.q[i] = deepcopy(cont.x[i])
23+
end
24+
for (i, qᵢ) in enumerate(cont.q)
25+
cont.x[i] = integrate(cont.f[i](t₀, cont.q, cont.p), q[i])
26+
end
1727
end
1828
cont
1929
end

test/continuous.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ end
88
sim = Simulation()
99
cont = @continuous stiffeq(sim, [0.0, 20.0], [2020.0]; order=6, stiff=true)
1010
run(sim, 500.0)
11+
println(cont.x)
12+
println(cont.q)

0 commit comments

Comments
 (0)