-
-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Description
I used ode_order_lowering
for the first time and was caught a little off guard by the resulting equation order, i.e. descending order instead of ascending. I was essentially doing the following. Which works just fine.
using ModelingToolkit
@variables t x(t)
D = Differential(t)
eqs = [(D∘D)(x) ~ -1]
sys = ode_order_lowering(ODESystem(eqs))
tspan = (0.0, 1.0)
u0 = [x => 100.0, D(x) =>0.0]
prob = ODEProblem(sys,u0,tspan,jac=true)
However, I then went to update prob
via remake(prob, u0=[x_value, dx_value])
which is incorrect. It needs to be u0=[dx_value, x_value]
.
A couple thoughts:
- The order seems unnatural. I don't know if I've ever seen an ODE lowered in that order in a textbook. Obviously, the order doesn't matter in principle, but it does impact the interface for updating the resulting numerical problem. At a minimum this should be documented.
- Possibly add a "sort order" kwarg to
ode_order_lowering
. However, I think below is a better option - Treat
u0 = [x => 100.0, D(x) =>0.0]
as a template for the interface, e.g. reorder the equations based on the order in the array. However, I can see situations where the order of the equations impacts performance and using a symbolic transformation to put it in a favorable form would conflict w/ this, e.g. grouping uncertain states forexpectation()
to prevent cache miss.
Metadata
Metadata
Assignees
Labels
No labels