Skip to content

Commit b9e6d6d

Browse files
committed
changed: initstate!(::SimModel) more robust to integrators
1 parent 823fd78 commit b9e6d6d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/model/linmodel.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ disturbances ``\mathbf{d_0 = d - d_{op}}``. The Moore-Penrose pseudo-inverse com
229229
``\mathbf{(I - A)^{-1}}`` to support integrating `model` (integrator states will be 0).
230230
"""
231231
function steadystate!(model::LinModel, u, d)
232-
model.x .= pinv(I - model.A)*(model.Bu*(u - model.uop) + model.Bd*(d - model.dop))
232+
M = I - model.A
233+
rtol = sqrt(eps(real(float(oneunit(eltype(M)))))) # pinv docstring recommendation
234+
model.x .= pinv(M; rtol)*(model.Bu*(u - model.uop) + model.Bd*(d - model.dop))
233235
return nothing
234236
end
235237

0 commit comments

Comments
 (0)