Skip to content

Commit d34f410

Browse files
committed
allow building coupled odes even if prob doesn't have tspan
1 parent ea3f650 commit d34f410

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ See also the online overarching tutorial for an example.
1212

1313
At the moment this is only possible for `CoupledODEs` and its derivative systems, as these are the only systems that can be made by a `DEProblem`, however it should be easy to allow e.g., `DeterministicIterated` to be created by a `DiscreteProblem`.
1414

15-
The integration is supported by the functions `current_parameter`, `set_parameter!` where a symbolic MTK parameter can be given as an index. In `observe_state`, a state variable or observed variable symbol can be given.
16-
1715
Also:
1816

1917
- Crucial bugfix for `successful_step` that was not working properly for discrete time systems.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalSystemsBase"
22
uuid = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
33
repo = "https://github.com/JuliaDynamics/DynamicalSystemsBase.jl.git"
4-
version = "3.5.0"
4+
version = "3.5.1"
55

66
[deps]
77
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"

src/core_systems/continuous_time_ode.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ function CoupledODEs(prob::ODEProblem, diffeq = DEFAULT_DIFFEQ; special_kwargs..
9696
IIP = isinplace(prob)
9797
D = length(prob.u0)
9898
P = typeof(prob.p)
99+
if prob.tspan === (nothing, nothing)
100+
# If the problem was made via MTK, it is possible to not have a default timespan.
101+
U = eltype(prob.u0)
102+
prob = SciMLBase.remake(prob; tspan = (U(0), U(Inf)))
103+
end
99104
solver, remaining = _decompose_into_solver_and_remaining(diffeq)
100105
integ = __init(prob, solver; remaining..., special_kwargs...,
101106
# Integrators are used exclusively iteratively. There is no reason to save anything.

test/mtk_integration.jl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,34 @@ set_parameter!(ds, 1, 2.0)
108108

109109
@test observe_state(ds, 1) == 1.0
110110

111-
@test_throws ArgumentError observe_state(ds, fol_1.f)
111+
@test_throws ArgumentError observe_state(ds, fol_1.f)
112+
113+
# Test that remake works also without anything initial
114+
115+
@variables t
116+
D = Differential(t)
117+
@mtkmodel Roessler begin
118+
@parameters begin
119+
a = 0.2
120+
b = 0.2
121+
c = 5.7
122+
end
123+
@variables begin
124+
x(t) = 1.0
125+
y(t) = 0.0
126+
z(t) = 0.0
127+
nlt(t) # nonlinear term
128+
end
129+
@equations begin
130+
D(x) ~ -y -z
131+
D(y) ~ x + a*y
132+
D(z) ~ b + nlt
133+
nlt ~ z*(x - c)
134+
end
135+
end
136+
137+
@mtkbuild roessler_model = Roessler()
138+
prob = ODEProblem(roessler_model)
139+
roessler = CoupledODEs(prob)
140+
141+
@test roessler isa CoupledODEs

0 commit comments

Comments
 (0)