ModelingToolkit.jl
ModelingToolkit.jl copied to clipboard
Cannot use structural parameter as array size
@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)
Duplicate of https://github.com/SciML/ModelingToolkit.jl/issues/2453?
Is there a workaround to allow variable sized arrays?
For what? That seems very orthogonal to this issue.
With https://github.com/SciML/ModelingToolkit.jl/pull/3107, this is now possible