I got it to work with the following
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)
Though, it seems strange to me that I need to give the initial values ra=>r_(0), sa=>s_(0) for the rabbit’s path. I initially thought that these were determined somehow. It also leads to a bit of an inconsistency if we give values other than those.