Skip to content

Cannot determine ordering of Dual tags ForwardDiff #1867

Closed
@ValentinKaisermayer

Description

@ValentinKaisermayer
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Mechanical.Rotational
using ModelingToolkitStandardLibrary.Blocks
import ModelingToolkitStandardLibrary
using ModelingToolkit, OrdinaryDiffEq
using Plots, Test

@parameters t
D = Differential(t)

begin
    R = 0.5
    L = 4.5e-3
    k = 0.5
    J = 0.02
    f = 0.01
    V_step = 10
    tau_L_step = -0.3
    @named ground = Ground()
    @named source = Voltage()
    @named ref = Blocks.Step(height = 1, start_time = 0)
    @named pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035)
    @named feedback = Blocks.Feedback()
    @named R1 = Resistor(R = R)
    @named L1 = Inductor(L = L)
    @named emf = EMF(k = k)
    @named fixed = Fixed()
    @named load = Torque(use_support = false)
    @named load_step = Blocks.Step(height = tau_L_step, start_time = 3)
    @named inertia = Inertia(J = J)
    @named friction = Damper(d = f)
    @named speed_sensor = SpeedSensor()

    connections = [connect(fixed.flange, emf.support, friction.flange_b)
                   connect(emf.flange, friction.flange_a, inertia.flange_a)
                   connect(inertia.flange_b, load.flange)
                   connect(inertia.flange_b, speed_sensor.flange)
                   connect(load_step.output, load.tau)
                   connect(ref.output, feedback.input1)
                   connect(speed_sensor.w, feedback.input2)
                   connect(feedback.output, pi_controller.err_input)
                   connect(pi_controller.ctr_output, source.V)
                   connect(source.p, R1.p)
                   connect(R1.n, L1.p)
                   connect(L1.n, emf.p)
                   connect(emf.n, source.n, ground.g)]

    @named model = ODESystem(connections, t,
                             systems = [
                                 ground,
                                 ref,
                                 pi_controller,
                                 feedback,
                                 source,
                                 R1,
                                 L1,
                                 emf,
                                 fixed,
                                 load,
                                 load_step,
                                 inertia,
                                 friction,
                                 speed_sensor,
                             ])
    sys = structural_simplify(model)
    prob = ODAEProblem(sys, [], (0, 6.0))
    sol = solve(prob, Rodas4())
end

ERROR: Cannot determine ordering of Dual tags ForwardDiff.Tag{Base.Fix2{NonlinearFunction{false, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#17303069610336657609"), Symbol("##arg#15917610875745784951")), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0x19ed51ea, 0x40e8fba4, 0x28e22dee, 0xd8d17769, 0xecff016c)}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing}, Tuple{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, Float64} and ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}
```

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