Skip to content

Commit 9c1ce5c

Browse files
committed
add a test
1 parent 929b9f5 commit 9c1ce5c

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

docs/src/batch_linearization.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ closed_loop_eqs = [
115115
plot(layout=2)
116116
117117
# Simulate each individual controller
118-
# for C in Cs
119-
# @named Ci = System(C)
120-
# eqs = [
121-
# closed_loop_eqs
122-
# connect(fb.output, Ci.input)
123-
# connect(Ci.output, duffing.u)
124-
# ]
125-
# @named closed_loop = System(eqs, t, systems=[duffing, Ci, fb, ref, F])
126-
# prob = ODEProblem(structural_simplify(closed_loop), [F.x => 0, F.xd => 0], (0.0, 8.0))
127-
# sol = solve(prob, Rodas5P(), abstol=1e-8, reltol=1e-8)
128-
# plot!(sol, idxs=[duffing.y.u, duffing.u.u], layout=2, lab="")
129-
# end
118+
for C in Cs
119+
@named Ci = System(C)
120+
eqs = [
121+
closed_loop_eqs
122+
connect(fb.output, Ci.input)
123+
connect(Ci.output, duffing.u)
124+
]
125+
@named closed_loop = System(eqs, t, systems=[duffing, Ci, fb, ref, F])
126+
prob = ODEProblem(structural_simplify(closed_loop), [F.x => 0, F.xd => 0], (0.0, 8.0))
127+
sol = solve(prob, Rodas5P(), abstol=1e-8, reltol=1e-8)
128+
plot!(sol, idxs=[duffing.y.u, duffing.u.u], layout=2, lab="")
129+
end
130130
131131
# Simulate gain-scheduled controller
132132
@named Cgs = GainScheduledStateSpace(Cs, xs, interpolator=LinearInterpolation)
@@ -219,6 +219,10 @@ plot(
219219
)
220220
```
221221
if we open at both `y` and `v` or we open at `u`, we get controllers for the different values of the scheduling variable, and the corresponding measurement feedback (which is the same as the scheduling variable in this case).
222+
```@example BATCHLIN
223+
using Test
224+
@test all(sminreal.(controllersv) .== sminreal.(controllersu))
225+
```
222226

223227
However, if we only open at `y` we get controller linearizations that _still contain the closed loop through the scheduling connection_ `v`. We can verify this by looking at what variables are present in the input-output map
224228
```@example BATCHLIN
@@ -248,6 +252,5 @@ Batch linearization in multiple different operating points is an intuitive way t
248252

249253

250254
```@example BATCHLIN
251-
using Test
252255
@test sol(6.99, idxs=closed_loop.duffing.y.u) ≈ 0.0 atol=0.01
253256
```

0 commit comments

Comments
 (0)