-
-
Notifications
You must be signed in to change notification settings - Fork 231
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When using the function returned by linearization_function
, passing a new operating point no longer has any effect. The tests for linearizing the saturation function has been extended below with some new tests, the last one indicating the problem. The code for handling the operating points in linearization_function
has become very complex, so I'm assigning you @AayushSabharwal since I think you're the only one who knows what's supposed to happen there
# The saturation has no dynamics
function saturation(; y_max, y_min = y_max > 0 ? -y_max : -Inf, name)
@variables u(t)=0 y(t)=0
@parameters y_max=y_max y_min=y_min
ie = ifelse
eqs = [
y ~ ie(u > y_max, y_max, ie((y_min < u) & (u < y_max), u, y_min))
]
ODESystem(eqs, t, name = name)
end
@named sat = saturation(; y_max = 1)
# inside the linear region, the function is identity
@unpack u, y = sat
lsys, ssys = linearize(sat, [u], [y])
@test isempty(lsys.A) # there are no differential variables in this system
@test isempty(lsys.B)
@test isempty(lsys.C)
@test lsys.D[] == 1
# outside the linear region the derivative is 0
lsys, ssys = linearize(sat, [u], [y]; op = Dict(u => 2))
@test isempty(lsys.A) # there are no differential variables in this system
@test isempty(lsys.B)
@test isempty(lsys.C)
@test lsys.D[] == 0
## === NEW TESTS BELOW =======
lin_fun, ssys = linearization_function(sat, [u], [y]; op = Dict(u => 0))
lsys = linearize(ssys, lin_fun; op = Dict(u => 0))
@test isempty(lsys.A) # there are no differential variables in this system
@test isempty(lsys.B)
@test isempty(lsys.C)
@test lsys.D[] == 1
lsys = linearize(ssys, lin_fun; op = Dict(u => 2))
@test isempty(lsys.A) # there are no differential variables in this system
@test isempty(lsys.B)
@test isempty(lsys.C)
@test lsys.D[] == 0 # THIS TEST FAILS, it should produce the same result as when linearize is called with op = Dict(u => 2) above
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working