@@ -77,7 +77,14 @@ so that it can be represented as a system of `ODEs` (ordinary differential equat
7777
7878``` @example dc_motor_pi
7979sys = 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))
8188sol = solve(prob)
8289
8390p1 = 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
109116using ControlSystemsBase
117+ # Get sensitivity function
110118matrices_S,
111- simplified_sys = Blocks.get_sensitivity(
119+ simplified_sys_S = Blocks.get_sensitivity(
112120 model, :y, op = Dict(unknowns(sys) .=> 0.0))
113121So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system
122+ # Get complementary sensitivity function
114123matrices_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))
117126To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system
118127bodeplot([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
125134matrices_L,
126- simplified_sys = Blocks.get_looptransfer(
135+ simplified_sys_L = Blocks.get_looptransfer(
127136 model, :y, op = Dict(unknowns(sys) .=> 0.0))
128137L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback
129138Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot
0 commit comments