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

Duplicate Global Parameters #992

Closed
bradcarman opened this issue Apr 29, 2021 · 1 comment
Closed

Duplicate Global Parameters #992

bradcarman opened this issue Apr 29, 2021 · 1 comment

Comments

@bradcarman
Copy link
Contributor

When using GlobalScope() for child components, the parent component then contains duplicates of the global parameter. See https://discourse.julialang.org/t/how-to-create-global-parameters-in-modelingtoolkit-jl/60065/4?u=brad_carman for an example reproduction of the bug.

@hersle
Copy link
Contributor

hersle commented Jul 17, 2024

This is no longer an issue.

using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D

@variables p(t)
@parameters rho
rho = GlobalScope(rho)

fluid(;name) = ODESystem(Equation[], t, [p], [rho]; defaults=[rho=>1000, p=>0], name)

@named A = fluid()
@named B = fluid()

eqs = [
    D(B.p) ~ A.p
    0 ~ (A.p) - (A.rho)
]

@named comp = ODESystem(eqs, t, [], []; systems=[A, B])

gives only one rho in

Model comp with 2 equations
Unknowns (2):
  A₊p(t) [defaults to 0]
  B₊p(t) [defaults to 0]
Parameters (1):
  rho [defaults to 1000]

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

No branches or pull requests

3 participants