Closed
Description
Sometimes structural_simplify
eliminates the variable that I wanted to use to set the initial condition of a system. It would be nice to have a way to specify the initial state by providing values for these 'observed' variables rather that the ones that that end up being the 'states' of the system. Here's an example:
using ModelingToolkit
@parameters C R
@variables t V(t) Q(t) I(t)
eqs = [V ~ C * Q,
D(Q) ~ I,
V ~ I * R]
@named sys = ODESystem(eqs)
simp = structural_simplify(sys)
states(simp)
The charge Q
is the remaining state variable. I typically don't know how many coulombs I put on the capacitor, it's the initial voltage that I measure. So I end up manually solving for Q
in terms of V
& plugging in my initial condition for V
to find the initial condition for Q
that goes into u0
.