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

Wrong namespace for default array parameter value #2344

Closed
baggepinnen opened this issue Nov 3, 2023 · 3 comments · Fixed by #2594 or #2603
Closed

Wrong namespace for default array parameter value #2344

baggepinnen opened this issue Nov 3, 2023 · 3 comments · Fixed by #2594 or #2603
Labels
arrays bug Something isn't working

Comments

@baggepinnen
Copy link
Contributor

The following code produces an incorrectly namespaced parameter constant₊k [defaults to constant₊k2[1]]. The correct answer should be

constant₊k [defaults to k2[1]]
using ModelingToolkitStandardLibrary.Blocks
@parameters t
D = Differential(t)
function FML2(; name)
    @parameters begin
        k2[1:1] = [1.0]
    end
    systems = @named begin
        constant = Constant(k = k2[1])
    end
    @variables begin
        x(t) = 0
    end
    eqs = [
       D(x) ~ constant.output.u + k2[1]
    ]
    ODESystem(eqs, t; systems, name)
end

@named model = FML2()
ssys = structural_simplify((model))
julia> ssys = structural_simplify((model))
Model model with 1 equations
States (1):
  x(t) [defaults to 0]
Parameters (2):
  k2[1] [defaults to 1.0]
  constant₊k [defaults to constant₊k2[1]]: Constant output value of block
Incidence matrix:1×2 SparseArrays.SparseMatrixCSC{Num, Int64} with 1 stored entry:
   ×

This error leads to subsequent

julia> prob = ODEProblem(ssys, [], (0, 10))
ERROR: ArgumentError: Any[constant₊k2[1]] are either missing from the variable map or missing from the system's states/parameters list.
Stacktrace:

The problem appears related to k2 being an array

@baggepinnen baggepinnen added bug Something isn't working arrays labels Nov 3, 2023
@baggepinnen
Copy link
Contributor Author

Might be related to #2252

@avinashresearch1
Copy link
Contributor

The same issue also occurs for variable symbolic arrays: #2477

@baggepinnen
Copy link
Contributor Author

Still a problem in ModelingToolkit v9.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays bug Something isn't working
Projects
None yet
3 participants