Skip to content

Incomplete derivative expansion with DataInterpolations #2169

@contradict

Description

@contradict

See this discourse discussion for the source of this example, simplified here.

using ModelingToolkit, OrdinaryDiffEq, DataInterpolations

Cp = 0.0244:0.011:0.387
TSR = 2.0:0.25:10.0
cp = CubicSpline(Cp, TSR)

@variables t ω(t)
D = Differential(t)
eqs = [D(ω) ~ cp(8*ω)]
@named sys = ODESystem(eqs, t)
sys = structural_simplify(sys)

u0 = [ω=>0.9]
tspan = (0.0, 1000.0)
prob = ODEProblem(sys, u0, tspan, [], jac = true)

Inspecting prob.f.jac.jac_iip

julia> prob.f.jac.jac_iip
RuntimeGeneratedFunction(#=in ModelingToolkit=#, #=using ModelingToolkit=#, :((ˍ₋out, ˍ₋arg1, ˍ₋arg2, t)->begin
          #= /home/user/.julia/packages/SymbolicUtils/H684H/src/code.jl:350 =#
          #= /home/user/.julia/packages/SymbolicUtils/H684H/src/code.jl:351 =#
          #= /home/user/.julia/packages/SymbolicUtils/H684H/src/code.jl:352 =#
          begin
              begin
                  begin
                      #= /home/user/.julia/packages/Symbolics/3jLt1/src/build_function.jl:520 =#
                      #= /home/user/.julia/packages/SymbolicUtils/H684H/src/code.jl:399 =# @inbounds begin
                              #= /home/user/.julia/packages/SymbolicUtils/H684H/src/code.jl:395 =#
                              ˍ₋out[1] = (*)(8, (Differential(ω(t)))(([0.0244, 0.0354, 0.0464, 0.0574, 0.0684, 0.0794, 0.0904, 0.1014, 0.1124, 0.1234, 0.1344, 0.1454, 0.1564, 0.1674, 0.1784, 0.1894, 0.2004, 0.2114, 0.2224, 0.2334, 0.2444, 0.2554, 0.2664, 0.2774, 0.2884, 0.2994, 0.3104, 0.3214, 0.3324, 0.3434, 0.3544, 0.3654, 0.3764, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5, 4.75, 5.0, 5.25, 5.5, 5.75, 6.0, 6.25, 6.5, 6.75, 7.0, 7.25, 7.5, 7.75, 8.0, 8.25, 8.5, 8.75, 9.0, 9.25, 9.5, 9.75, 10.0])((*)(8, ˍ₋arg1[1]))))
                              #= /home/user/.julia/packages/SymbolicUtils/H684H/src/code.jl:397 =#
                              nothing
                          end
                  end
              end
          end
      end))

There is still an unexpanded Differential(ω(t)) in there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions