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

Initialization System fails to remove an equation #3312

Open
bradcarman opened this issue Jan 11, 2025 · 0 comments
Open

Initialization System fails to remove an equation #3312

bradcarman opened this issue Jan 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@bradcarman
Copy link
Contributor

Take the following. The equation left in the initialization system is already an observable.

using ModelingToolkit
using ModelingToolkitStandardLibrary.Blocks
using ModelingToolkit: t_nounits as t, D_nounits as D

vars = @variables y(t) dy(t) ddy(t)
systems = @named begin
    src = SampledData(Float64)
    int = Integrator()
end 
eqs = [
    y ~ src.output.u
    D(y) ~ dy
    D(dy) ~ ddy
    connect(src.output, int.input)
]

@mtkbuild sys = ODESystem(eqs, t; systems)
initprob = ModelingToolkit.InitializationProblem(sys, 0.0) # Warning: Initialization system is overdetermined. 1 equations for 0 unknowns.

As can be seen we have an overdetermined system, which I believe is a bug.

If we look at the equations we see...

julia> initprob.f.sys |> equations
1-element Vector{Equation}:
 0 ~ -src₊output₊u(t) + ModelingToolkitStandardLibrary.Blocks.get_sampled_data(t, src₊buffer)

But if we look at the observed, we can see that src₊output₊u(t) is already known and shouldn't be an equation.

julia> ModelingToolkit.observed(initprob.f.sys)[2]
src₊output₊u(t) ~ ModelingToolkitStandardLibrary.Blocks.get_sampled_data(0.0, src₊buffer)

Versions...

Status `C:\Users\bradl\AppData\Local\Temp\jl_uvgnDL\Project.toml`

  [961ee093] ModelingToolkit v9.60.0
  [16a59e39] ModelingToolkitStandardLibrary v2.19.0 `C:\Work\ModelingToolkitStandardLibrary.jl`
@bradcarman bradcarman added the bug Something isn't working label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant