Skip to content

Commit e4a0cde

Browse files
committed
use ap access style from MTK
1 parent f6dfcaa commit e4a0cde

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

docs/src/batch_linearization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ code = SymbolicControlSystems.print_c_array(stdout, Cs_disc[1:7:end], xs[1:7:end
152152
The generated code starts by defining the interpolation vector `xs`, this variable is called `Cs_interp_vect` in the generated code. The code then defines all the ``A`` matrices as a 3-dimensional array, followed by a function that performs the interpolation `interpolate_Cs_A`. This function takes the output array as the first argument, a pointer to the 3D array with interpolation matrices, the interpolation vector as well as the interpolation variable `t`, in this document called ``v``. The same code is then repeated for the matrices ``B,C,D`` as well if they require interpolation (if they are all the same, no interpolation code is written).
153153

154154
## Linearize around a trajectory
155-
We can linearize around a trajectory obtained from `solve` using the function [`trajectory_ss`](@ref). We provide it with a vector of time points along the trajectory at which to linearize, and in this case we specify the inputs and outputs to linearize between as analysis points `:r` and `:y`.
155+
We can linearize around a trajectory obtained from `solve` using the function [`trajectory_ss`](@ref). We provide it with a vector of time points along the trajectory at which to linearize, and in this case we specify the inputs and outputs to linearize between as analysis points `r` and `y`.
156156
```@example BATCHLIN
157157
timepoints = 0:0.01:8
158-
Ps2, ssys = trajectory_ss(closed_loop, :r, :y, sol; t=timepoints)
158+
Ps2, ssys = trajectory_ss(closed_loop, closed_loop.r, closed_loop.y, sol; t=timepoints)
159159
bodeplot(Ps2, w, legend=false)
160160
```
161161

src/ode_system.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function RobustAndOptimalControl.named_ss(
201201
end
202202
ny = length(outputs)
203203
matrices, ssys = ModelingToolkit.linearize(sys, inputs, outputs; kwargs...)
204-
symstr(x) = Symbol(string(x))
204+
symstr(x) = Symbol(x isa AnalysisPoint ? x.name : string(x))
205205
unames = symstr.(inputs)
206206
fm(x) = convert(Matrix{Float64}, x)
207207
if nu > 0 && size(matrices.B, 2) == 2nu
@@ -289,7 +289,7 @@ function named_sensitivity_function(
289289
end
290290
nu = length(inputs)
291291
matrices, ssys = fun(sys, inputs, args...; kwargs...)
292-
symstr(x) = Symbol(string(x))
292+
symstr(x) = Symbol(x isa AnalysisPoint ? x.name : string(x))
293293
unames = symstr.(inputs)
294294
fm(x) = convert(Matrix{Float64}, x)
295295
if nu > 0 && size(matrices.B, 2) == 2nu

test/test_ODESystem.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ eqs = [connect(r.output, F.input)
266266
connect(F.output, sys_inner.add.input1)]
267267
sys_outer = ODESystem(eqs, t, systems = [F, sys_inner, r], name = :outer)
268268

269-
matrices, _ = Blocks.get_sensitivity(sys_outer, [:inner_plant_input, :inner_plant_output])
269+
matrices, _ = Blocks.get_sensitivity(sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output])
270270
S = ss(matrices...)
271271

272-
Sn = get_named_sensitivity(sys_outer, [:inner_plant_input, :inner_plant_output])
272+
Sn = get_named_sensitivity(sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output])
273273

274274
@test S == Sn.sys
275275

276-
@test Sn.u == Sn.y == [:inner_plant_input, :inner_plant_output]
276+
@test Sn.u == Sn.y == [:outer₊inner₊plant_input, :outer₊inner₊plant_output] == [:outer₊inner₊plant_input, :outer₊inner₊plant_output]
277277

278278

279279
## Test connector names

test/test_batchlin.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ sol = solve(prob, Rodas5P(), abstol=1e-8, reltol=1e-8)
7272

7373
time = 0:0.1:8
7474
inputs, outputs = [duffing.u.u], [duffing.y.u]
75-
Ps2, ssys = trajectory_ss(closed_loop, :r, :y, sol; t=time)
75+
Ps2, ssys = trajectory_ss(closed_loop, closed_loop.r, closed_loop.y, sol; t=time)
7676
@test length(Ps2) == length(time)
7777
# bodeplot(Ps2)

0 commit comments

Comments
 (0)