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

fix: fix array variables in mtkmodel #3063

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AayushSabharwal
Copy link
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@baggepinnen
Copy link
Contributor

This PR appears to break something in Multibody.jl, on this branch, the example
https://juliacomputing.github.io/Multibody.jl/dev/examples/wheel/#Slip-based-planar-wheel
fails already upon model instantiation with an error

julia> @named model = TwoTrackWithDifferentialGear()
ERROR: MethodError: no method matching hasmetadata(::Vector{Num}, ::Type{Symbolics.VariableDefaultValue})

Closest candidates are:
  hasmetadata(::Num, ::Any)
   @ Symbolics ~/.julia/packages/Symbolics/XnDVB/src/Symbolics.jl:187
  hasmetadata(::Complex{Num}, ::Any)
   @ Symbolics ~/.julia/packages/Symbolics/XnDVB/src/Symbolics.jl:187
  hasmetadata(::SymbolicUtils.Symbolic, ::Any)
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/ij6YM/src/types.jl:631

Stacktrace:
  [1] hasdefault(v::Vector{Num})
    @ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/utils.jl:237
  [2] collect_defaults!(defs::Dict{Any, Any}, vars::Vector{Any})
    @ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/utils.jl:255
  [3] process_variables!(var_to_name::Dict{Any, Any}, defs::Dict{Any, Any}, vars::Vector{Any})
    @ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/utils.jl:248
  [4] ODESystem(deqs::Vector{…}, iv::Num, dvs::Vector{…}, ps::Vector{…}; controls::Vector{…}, observed::Vector{…}, systems::Vector{…}, tspan::Nothing, name::Symbol, default_u0::Dict{…}, default_p::Dict{…}, defaults::Dict{…}, guesses::Dict{…}, initializesystem::Nothing, initialization_eqs::Vector{…}, schedule::Nothing, connector_type::Nothing, preface::Nothing, continuous_events::Nothing, discrete_events::Nothing, parameter_dependencies::Vector{…}, checks::Bool, metadata::Nothing, gui_metadata::ModelingToolkit.GUIMetadata)
    @ ModelingToolkit ~/.julia/dev/ModelingToolkit/src/systems/diffeqs/odesystem.jl:245
  [5] #__FixedTranslation__#11
    @ ~/.julia/packages/UnPack/EkESO/src/UnPack.jl:705 [inlined]
  [6] __FixedTranslation__(; name::Symbol, r::Vector{Int64}, radius::Nothing, render::Nothing, phi::Nothing, w::Nothing)
    @ Multibody.PlanarMechanics ./none:0
  [7] __FixedTranslation__
    @ ./none:0 [inlined]
  [8] #_#411
    @ ~/.julia/dev/ModelingToolkit/src/systems/model_parsing.jl:25 [inlined]
  [9] macro expansion
    @ ~/.julia/dev/ModelingToolkit/src/systems/abstractsystem.jl:1950 [inlined]
 [10] 
    @ Main ~/.julia/dev/ModelingToolkit/src/systems/model_parsing.jl:138
 [11] __TwoTrackWithDifferentialGear__
    @ ~/.julia/dev/ModelingToolkit/src/systems/model_parsing.jl:138 [inlined]
 [12] #_#411
    @ ~/.julia/dev/ModelingToolkit/src/systems/model_parsing.jl:25 [inlined]
 [13] top-level scope
    @ ~/.julia/dev/ModelingToolkit/src/systems/abstractsystem.jl:1950
Some type information was truncated. Use `show(err)` to see complete types.

the example works on MTK master

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

Successfully merging this pull request may close these issues.

2 participants