-
-
Notifications
You must be signed in to change notification settings - Fork 236
Closed
Description
In the following, the values of the state variables ra=r_(t) and sa=s_(t) can be determined for any initial value, yet MTK still identifies them as state variables that must be given an initial value. And giving them an initial value other than r_(0) and s_(0) leads to issues with the solution.
using ModelingToolkit
using DifferentialEquations
## Fox-Rabbit Pursuit
@variables t x(t) y(t) R(t) ra(t) sa(t) dra(t) dsa(t)
@parameters k
D = Differential(t)
# rabbit's path, an outward spiral
r_(t) = sqrt(1+t) * cos(t)
s_(t) = sqrt(1+t) * sin(t)
@named rabbitfox_model = ODESystem([
ra ~ r_(t),
sa ~ s_(t),
D(ra) ~ dra,
D(sa) ~ dsa,
D(x) ~ R * (ra - x),
D(y) ~ R * (sa - y),
R ~ k * sqrt(dra^2 + dsa^2)/
sqrt((ra - x)^2 + (sa - y)^2),
])
prob = ODEProblem(structural_simplify(rabbitfox_model),
[x=>3, y=>0, ra=>r_(0), sa=>s_(0)],
(0, 5.071),
[k=>1.1]
)
sol = solve(prob)(As a newbie to MTK), I originally thought that the initial values for ra and sa would be automagically determined.
This issue is in response to this discussion: https://discourse.julialang.org/t/argumenterror-in-fox-rabbit-pursuit-problem-with-modelingtoolkit-jl/61222/2
Metadata
Metadata
Assignees
Labels
No labels