Skip to content

Commit 345c605

Browse files
committed
test: NonLinModel linearization with non zero op. points
1 parent 8d0dfb8 commit 345c605

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/1_test_sim_model.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,22 @@ end
371371
h2!(y0, x0, _, _) = (y0 .= x0)
372372
nonlinmodel4 = NonLinModel(f2!,h2!,Ts,1,1,1,0,solver=nothing,jacobian=AutoFiniteDiff())
373373
@test_nowarn linearize(nonlinmodel4, x=[1], u=[2])
374+
375+
# test linearization with nonzero operating points in the NonLinModel object:
376+
linmodel_op = LinModel(tf(2, [10, 1]),1)
377+
linmodel_op = setop!(linmodel_op, uop=[10], yop=[20], xop=[-2], fop=[5])
378+
f3!(xnext, x, u, _, p) = (xnext .= p.A*x .+ p.Bu*u)
379+
h3!(y, x, _, p) = (y .= p.C*x)
380+
nonlinmodel_op = NonLinModel(f3!, h3!, 1.0, 1, 1, 1, p=linmodel_op, solver=nothing)
381+
nonlinmodel_op = setop!(linmodel_op, uop=[10], yop=[20], xop=[-2], fop=[5])
382+
linmodel_op_2 = linearize(nonlinmodel_op)
383+
@test linmodel_op.A linmodel_op_2.A
384+
@test linmodel_op.Bu linmodel_op_2.Bu
385+
@test linmodel_op.C linmodel_op_2.C
386+
@test linmodel_op.uop linmodel_op_2.uop
387+
@test linmodel_op.yop linmodel_op_2.yop
388+
@test linmodel_op.xop linmodel_op_2.xop
389+
@test linmodel_op.fop linmodel_op_2.fop
374390
end
375391

376392
@testitem "NonLinModel real time simulations" setup=[SetupMPCtests] begin

0 commit comments

Comments
 (0)