Skip to content

Cannot use structural parameter as array size #2704

@baggepinnen

Description

@baggepinnen
@mtkmodel Foo begin
    @structural_parameters begin
        nx = 2
    end
    @variables begin
        (x(t)[1:nx]), [description = "State"]
    end
    @equations begin
    end
end
ERROR: promotion of types Int64 and Symbol failed to change any arguments

With explicit array size, it works

julia> @mtkmodel Foo begin
           @structural_parameters begin
               nx = 2
           end
           @variables begin
               (x(t)[1:2]), [description = "State"]
           end
           @equations begin
           end
       end
ModelingToolkit.Model{typeof(__Foo__), Dict{Symbol, Any}}(__Foo__, Dict{Symbol, Any}(:variables => Dict{Symbol, Dict{Symbol, Any}}(:x => Dict(:type => Real, :description => "State", :size => (2,))), :kwargs => Dict{Symbol, Dict}(:nx => Dict(:value => 2), :x => Dict{Symbol, Union{Nothing, UnionAll}}(:value => nothing, :type => AbstractArray{Real})), :structural_parameters => Dict{Symbol, Dict}(:nx => Dict(:value => 2)), :independent_variable => t, :equations => Any[]), false)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions