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

Subsystem not namespaced when substituted coefficient is 1 #2855

Closed
hersle opened this issue Jul 9, 2024 · 1 comment · Fixed by JuliaSymbolics/SymbolicUtils.jl#624
Closed
Assignees
Labels
bug Something isn't working

Comments

@hersle
Copy link
Contributor

hersle commented Jul 9, 2024

I am puzzled by this behavior:

using ModelingToolkit
using ModelingToolkit: t_nounits as t

function buggy(ϵval)
    @variables x(t)
    ϵ, = GlobalScope.(@parameters ϵ) # never namespace
    @named A = ODESystem(Equation[], t)
    @named B = ODESystem([substitute*x ~ 0, ϵ => ϵval)], t)
    C = compose(A, B)
    return equations(C)
end

buggy(-1) # [-B₊x(t) ~ 0], as expected
buggy(0)  # [0 ~ 0], as expected
buggy(1)  # [x(t) ~ 0], but expected [B₊x(t) ~ 0]
buggy(2)  # [2B₊x(t) ~ 0], as expected

Why is the namespacing on x dropped only when ϵ => 1 is substituted?

This blocks me from programmatically generating a more complex hierarchical system.

@hersle hersle added the bug Something isn't working label Jul 9, 2024
@ChrisRackauckas
Copy link
Member

To be perfectly honest, I'm also pretty baffled. It might have to do with the 1*x => x rule getting in the way, but I don't see why that would effect namespacing.

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

Successfully merging a pull request may close this issue.

3 participants