Skip to content

Commit 0419607

Browse files
test: fix initialization of model in tests
1 parent 5728c74 commit 0419607

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

test/input_output_handling.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ 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 => 1.0])
132132
model_outputs = [inertia1.w, inertia2.w, inertia1.phi, inertia2.phi]
133133
model_inputs = [torque.tau.u]
134-
matrices, ssys = linearize(model, model_inputs, model_outputs);
134+
matrices, ssys = linearize(
135+
model, model_inputs, model_outputs; op = Dict(torque.tau.u => 0.0));
135136
@test length(ModelingToolkit.outputs(ssys)) == 4
136137

137138
if VERSION >= v"1.8" # :opaque_closure not supported before

test/split_parameters.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,16 @@ function SystemModel(u = nothing; name = :model)
164164
t;
165165
systems = [torque, inertia1, inertia2, spring, damper, u])
166166
end
167-
ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper], name)
167+
ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper],
168+
name, guesses = [spring.flange_a.phi => 1.0])
168169
end
169170

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

176178
# Design state-feedback gain using LQR
177179
# Define cost matrices

0 commit comments

Comments
 (0)