Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial conditions via observed variables #1836

Closed
lamorton opened this issue Sep 24, 2022 · 1 comment · Fixed by #2403
Closed

Initial conditions via observed variables #1836

lamorton opened this issue Sep 24, 2022 · 1 comment · Fixed by #2403

Comments

@lamorton
Copy link
Contributor

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.

@bowenszhu
Copy link
Member

julia> ModelingToolkit.get_defaults(simp)
Dict{Any, Any}()

Something is missing in ODESystem.defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants