|
877 | 877 | sol = solve(prob, Rodas5P())
|
878 | 878 | @test SciMLBase.successful_retcode(sol)
|
879 | 879 | end
|
| 880 | + |
| 881 | +@testset "Issue#3205" begin |
| 882 | + using ModelingToolkitStandardLibrary.Electrical |
| 883 | + import ModelingToolkitStandardLibrary.Mechanical.Rotational as MR |
| 884 | + using ModelingToolkitStandardLibrary.Blocks |
| 885 | + using SciMLBase |
| 886 | + |
| 887 | + function dc_motor(R1 = 0.5) |
| 888 | + R = R1 # [Ohm] armature resistance |
| 889 | + L = 4.5e-3 # [H] armature inductance |
| 890 | + k = 0.5 # [N.m/A] motor constant |
| 891 | + J = 0.02 # [kg.m²] inertia |
| 892 | + f = 0.01 # [N.m.s/rad] friction factor |
| 893 | + tau_L_step = -0.3 # [N.m] amplitude of the load torque step |
| 894 | + |
| 895 | + @named ground = Ground() |
| 896 | + @named source = Voltage() |
| 897 | + @named ref = Blocks.Step(height = 0.2, start_time = 0) |
| 898 | + @named pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035) |
| 899 | + @named feedback = Blocks.Feedback() |
| 900 | + @named R1 = Resistor(R = R) |
| 901 | + @named L1 = Inductor(L = L) |
| 902 | + @named emf = EMF(k = k) |
| 903 | + @named fixed = MR.Fixed() |
| 904 | + @named load = MR.Torque() |
| 905 | + @named load_step = Blocks.Step(height = tau_L_step, start_time = 3) |
| 906 | + @named inertia = MR.Inertia(J = J) |
| 907 | + @named friction = MR.Damper(d = f) |
| 908 | + @named speed_sensor = MR.SpeedSensor() |
| 909 | + |
| 910 | + connections = [connect(fixed.flange, emf.support, friction.flange_b) |
| 911 | + connect(emf.flange, friction.flange_a, inertia.flange_a) |
| 912 | + connect(inertia.flange_b, load.flange) |
| 913 | + connect(inertia.flange_b, speed_sensor.flange) |
| 914 | + connect(load_step.output, load.tau) |
| 915 | + connect(ref.output, feedback.input1) |
| 916 | + connect(speed_sensor.w, :y, feedback.input2) |
| 917 | + connect(feedback.output, pi_controller.err_input) |
| 918 | + connect(pi_controller.ctr_output, :u, source.V) |
| 919 | + connect(source.p, R1.p) |
| 920 | + connect(R1.n, L1.p) |
| 921 | + connect(L1.n, emf.p) |
| 922 | + connect(emf.n, source.n, ground.g)] |
| 923 | + |
| 924 | + @named model = ODESystem(connections, t, |
| 925 | + systems = [ |
| 926 | + ground, |
| 927 | + ref, |
| 928 | + pi_controller, |
| 929 | + feedback, |
| 930 | + source, |
| 931 | + R1, |
| 932 | + L1, |
| 933 | + emf, |
| 934 | + fixed, |
| 935 | + load, |
| 936 | + load_step, |
| 937 | + inertia, |
| 938 | + friction, |
| 939 | + speed_sensor |
| 940 | + ]) |
| 941 | + end |
| 942 | + |
| 943 | + model = dc_motor() |
| 944 | + sys = structural_simplify(model) |
| 945 | + |
| 946 | + prob = ODEProblem(sys, [sys.L1.i => 0.0], (0, 6.0)) |
| 947 | + |
| 948 | + @test_nowarn remake(prob, p = prob.p) |
| 949 | +end |
0 commit comments