Skip to content

Commit 797dd31

Browse files
Merge pull request #411 from ChrisRackauckas-Claude/fix-dc-motor-tutorial-warnings
Fix warnings in DC Motor PI tutorial
2 parents 4778382 + 6da4fa9 commit 797dd31

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/src/tutorials/dc_motor_pi.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ so that it can be represented as a system of `ODEs` (ordinary differential equat
7777

7878
```@example dc_motor_pi
7979
sys = mtkcompile(model)
80-
prob = ODEProblem(sys, [sys.L1.i => 0.0], (0, 6.0))
80+
# Provide complete initial conditions for all state variables
81+
u0 = Dict(
82+
sys.L1.i => 0.0, # Initial inductor current
83+
sys.inertia.w => 0.0, # Initial angular velocity
84+
sys.inertia.phi => 0.0, # Initial angle
85+
sys.pi_controller.int.x => 0.0 # Initial PI integrator state
86+
)
87+
prob = ODEProblem(sys, u0, (0, 6.0))
8188
sol = solve(prob)
8289
8390
p1 = plot(sol.t, sol[sys.inertia.w], ylabel = "Angular Vel. in rad/s",
@@ -107,12 +114,14 @@ T(s) &= \dfrac{P(s)C(s)}{I + P(s)C(s)}
107114

108115
```@example dc_motor_pi
109116
using ControlSystemsBase
117+
# Get sensitivity function
110118
matrices_S,
111-
simplified_sys = Blocks.get_sensitivity(
119+
simplified_sys_S = Blocks.get_sensitivity(
112120
model, :y, op = Dict(unknowns(sys) .=> 0.0))
113121
So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system
122+
# Get complementary sensitivity function
114123
matrices_T,
115-
simplified_sys = Blocks.get_comp_sensitivity(
124+
simplified_sys_T = Blocks.get_comp_sensitivity(
116125
model, :y, op = Dict(unknowns(sys) .=> 0.0))
117126
To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system
118127
bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
@@ -123,7 +132,7 @@ Similarly, we may compute the loop-transfer function and plot its Nyquist curve
123132

124133
```@example dc_motor_pi
125134
matrices_L,
126-
simplified_sys = Blocks.get_looptransfer(
135+
simplified_sys_L = Blocks.get_looptransfer(
127136
model, :y, op = Dict(unknowns(sys) .=> 0.0))
128137
L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback
129138
Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot

0 commit comments

Comments
 (0)