Skip to content

Commit 9ed0fe2

Browse files
test: fix initialization of some tests
1 parent 370343b commit 9ed0fe2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

test/input_output_handling.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,17 @@ eqs = [connect(torque.flange, inertia1.flange_a)
128128
connect(inertia2.flange_a, spring.flange_b, damper.flange_b)
129129
y ~ inertia2.w + torque.tau.u]
130130
model = ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper],
131-
name = :name)
131+
name = :name, guesses = [spring.flange_a.phi => 0.0])
132132
model_outputs = [inertia1.w, inertia2.w, inertia1.phi, inertia2.phi]
133133
model_inputs = [torque.tau.u]
134+
op = Dict(torque.tau.u => 0.0)
134135
matrices, ssys = linearize(
135-
model, model_inputs, model_outputs);
136+
model, model_inputs, model_outputs; op);
136137
@test length(ModelingToolkit.outputs(ssys)) == 4
137138

138139
if VERSION >= v"1.8" # :opaque_closure not supported before
139140
let # Just to have a local scope for D
140-
matrices, ssys = linearize(model, model_inputs, [y])
141+
matrices, ssys = linearize(model, model_inputs, [y]; op)
141142
A, B, C, D = matrices
142143
obsf = ModelingToolkit.build_explicit_observed_function(ssys,
143144
[y],
@@ -321,7 +322,8 @@ function SystemModel(u = nothing; name = :model)
321322
u
322323
])
323324
end
324-
ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper], name)
325+
ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper],
326+
name, guesses = [spring.flange_a.phi => 0.0])
325327
end
326328

327329
model = SystemModel() # Model with load disturbance
@@ -410,7 +412,8 @@ matrices, ssys = linearize(augmented_sys,
410412
augmented_sys.u,
411413
augmented_sys.input.u[2],
412414
augmented_sys.d
413-
], outs)
415+
], outs;
416+
op = [augmented_sys.u => 0.0, augmented_sys.input.u[2] => 0.0, augmented_sys.d => 0.0])
414417
@test matrices.A [A [1; 0]; zeros(1, 2) -0.001]
415418
@test matrices.B == I
416419
@test matrices.C == [C zeros(2)]

test/split_parameters.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,16 @@ function SystemModel(u = nothing; name = :model)
165165
systems = [torque, inertia1, inertia2, spring, damper, u])
166166
end
167167
ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper],
168-
name)
168+
name, guesses = [spring.flange_a.phi => 0.0])
169169
end
170170

171171
model = SystemModel() # Model with load disturbance
172172
@named d = Step(start_time = 1.0, duration = 10.0, offset = 0.0, height = 1.0) # Disturbance
173173
model_outputs = [model.inertia1.w, model.inertia2.w, model.inertia1.phi, model.inertia2.phi] # This is the state realization we want to control
174174
inputs = [model.torque.tau.u]
175+
op = [model.torque.tau.u => 0.0]
175176
matrices, ssys = ModelingToolkit.linearize(
176-
wr(model), inputs, model_outputs)
177+
wr(model), inputs, model_outputs; op)
177178

178179
# Design state-feedback gain using LQR
179180
# Define cost matrices

0 commit comments

Comments
 (0)