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

Failure in expanding derivative--Any[D(t)(f(v1(t))), D(t)(v2(t))] #1369

Open
ven-k opened this issue Nov 20, 2024 · 1 comment
Open

Failure in expanding derivative--Any[D(t)(f(v1(t))), D(t)(v2(t))] #1369

ven-k opened this issue Nov 20, 2024 · 1 comment

Comments

@ven-k
Copy link
Contributor

ven-k commented Nov 20, 2024

@component function DerOfFunc(; name)
  vars = @variables begin
    v0(t)
    v1(t)
    v2(t)
    v3(t)
  end
  eqs = Equation[
    v0 ~ 0
    v1 ~ f1(v0)
    v2 ~ D(v1)
    v3 ~ D(v2)
  ]
  return ODESystem(eqs, t, vars, []; systems = [], name)
end

@mtkbuild model = DerOfFunc()

Results in:

ERROR: BoundsError: attempt to access 1-element Vector{Any} at index [2] (see complete stacktrace)

complete stacktrace
┌ Info: Any[Differential(t)(f1(v0(t))), Differential(t)(v0(t))]
│   length(inner_args) = 2
│   i = 2
└   l = 2
[ Info: Any[true]
ERROR: BoundsError: attempt to access 1-element Vector{Any} at index [2]
Stacktrace:
  [1] getindex(A::Vector{Any}, i1::Int64)
    @ Base ./essentials.jl:13
  [2] expand_derivatives(O::SymbolicUtils.BasicSymbolic{Real}, simplify::Bool; occurrences::SymbolicUtils.BasicSymbolic{Real}) (repeats 4 times)
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:260
  [3] expand_derivatives(O::SymbolicUtils.BasicSymbolic{Real}, simplify::Bool; occurrences::Nothing)
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:260
  [4] expand_derivatives
    @ ~/.julia/dev/Symbolics/src/diff.jl:183 [inlined]
  [5] derivative(O::SymbolicUtils.BasicSymbolic{Real}, var::SymbolicUtils.BasicSymbolic{Real}; simplify::Bool)
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:448
  [6] derivative(O::SymbolicUtils.BasicSymbolic{Real}, var::SymbolicUtils.BasicSymbolic{Real})
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:444
  [7] eq_derivative!(ts::TearingState{…}, ieq::Int64; kwargs::@Kwargs{})
    @ ModelingToolkit.StructuralTransformations ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/symbolics_tearing.jl:66
  [8] eq_derivative!
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/symbolics_tearing.jl:59 [inlined]
  [9] pantelides!(state::TearingState{…}; finalize::Bool, maxiters::Int64, kwargs::@Kwargs{})
    @ ModelingToolkit.StructuralTransformations ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/pantelides.jl:186
 [10] pantelides!
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/pantelides.jl:127 [inlined]
 [11] dummy_derivative_graph!(state::TearingState{…}, jac::Function; state_priority::Function, log::Val{…}, kwargs::@Kwargs{})
    @ ModelingToolkit.StructuralTransformations ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/partial_state_selection.jl:176
 [12] dummy_derivative_graph!
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/partial_state_selection.jl:172 [inlined]
 [13] #dummy_derivative#133
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/structural_transformation/symbolics_tearing.jl:686 [inlined]
 [14] _structural_simplify!(state::TearingState{…}, io::Nothing; simplify::Bool, check_consistency::Bool, fully_determined::Bool, warn_initialize_determined::Bool, dummy_derivative::Bool, kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systemstructure.jl:695
 [15] _structural_simplify!
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systemstructure.jl:675 [inlined]
 [16] structural_simplify!(state::TearingState{…}, io::Nothing; simplify::Bool, check_consistency::Bool, fully_determined::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systemstructure.jl:635
 [17] __structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systems.jl:94
 [18] __structural_simplify
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systems.jl:75 [inlined]
 [19] structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, split::Bool, allow_symbolic::Bool, allow_parameter::Bool, conservative::Bool, fully_determined::Bool, kwargs::@Kwargs{})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systems.jl:33
 [20] structural_simplify
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systems.jl:28 [inlined]
 [21] structural_simplify(sys::ODESystem)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/systems.jl:28
 [22] top-level scope
    @ ~/.julia/packages/ModelingToolkit/UXr3S/src/systems/abstractsystem.jl:2147
Some type information was truncated. Use `show(err)` to see complete types.

occurences fails to detect the signature of Any[D(t)(f(v1(t))), D(t)(v2(t))]

@ChrisRackauckas
Copy link
Member

@mtkbuild does not exist in Symbolics. What's the actual issue here?

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

2 participants