-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with Minimal Realization in ControlSystems.jl
package...
#12
Comments
Hm. Fredrik Bagge Carlson made me aware of that there probably is a pole-zero cancellation, so that the minimal realization probably should have 3 states. I now notice that:
|
Here's the original discussion |
For context, using ControlSystemsBase, Plots
A = [-6.537773175952662 0.0 0.0 0.0 -9.892378564622923e-9 0.0; 0.0 -6.537773175952662 0.0 0.0 0.0 -9.892378564622923e-9; 2.0163803998106024e8 2.0163803998106024e8 -0.006223894167415392 -1.551620418759878e8 0.002358202548321148 0.002358202548321148; 0.0 0.0 5.063545034365582e-9 -0.4479539754649166 0.0 0.0; -2.824060629317756e8 2.0198389074625736e8 -0.006234569427701143 -1.5542817673286995e8 -0.7305736722226711 0.0023622473513548576; 2.0198389074625736e8 -2.824060629317756e8 -0.006234569427701143 -1.5542817673286995e8 0.0023622473513548576 -0.7305736722226711]
B = [0.004019511633336128; 0.004019511633336128; 0.0; 0.0; 297809.51426114445; 297809.51426114445]
C = [0.0 0.0 0.0 1.0 0.0 0.0]
D = [0.0]
linsys = ss(A,B,C,D)
bsys, T = balance_statespace(linsys)
rsys = minreal(bsys) but calling rsys = minreal(linsys) results in an inaccurate result. Full reproducing code follows. Note how the Bode curve of the "original" unbalanced model is inaccurate as well using ControlSystemsBase, Plots
A = [-6.537773175952662 0.0 0.0 0.0 -9.892378564622923e-9 0.0; 0.0 -6.537773175952662 0.0 0.0 0.0 -9.892378564622923e-9; 2.0163803998106024e8 2.0163803998106024e8 -0.006223894167415392 -1.551620418759878e8 0.002358202548321148 0.002358202548321148; 0.0 0.0 5.063545034365582e-9 -0.4479539754649166 0.0 0.0; -2.824060629317756e8 2.0198389074625736e8 -0.006234569427701143 -1.5542817673286995e8 -0.7305736722226711 0.0023622473513548576; 2.0198389074625736e8 -2.824060629317756e8 -0.006234569427701143 -1.5542817673286995e8 0.0023622473513548576 -0.7305736722226711]
B = [0.004019511633336128; 0.004019511633336128; 0.0; 0.0; 297809.51426114445; 297809.51426114445]
C = [0.0 0.0 0.0 1.0 0.0 0.0]
D = [0.0]
linsys = ss(A,B,C,D)
rsys = minreal(linsys)
bsys, T = balance_statespace(linsys)
brsys = minreal(bsys)
w = exp10.(LinRange(-2, 2, 200))
bodeplot(linsys, w, l=4, lab="Original")
bodeplot!(rsys, w, l=2, lab="Minimal of original")
bodeplot!(bsys, w, l=4, lab="Balanced")
bodeplot!(brsys, w, l=2, lab="Minimal of balanced") |
With doing I find it puzzling that there is a difference in the bodeplot of the original system
I would have guessed that these should be identical more or less.
|
I think that the problem is simply explained by poor conditioning of the problem matrices, the coefficients are huge julia> norm(linsys.A, Inf), norm(linsys.B, Inf), norm(linsys.C, Inf)
(2.824060629317756e8, 297809.51426114445, 1.0) whereas after balancing
|
Many computations in
So, the preliminary scaling of model data may be an escape for badly scaled models. |
A fourth order model can be also computed using an additive spectral decomposition applied to the already scaled model (here is an example using
We have
|
I implemented some functions addressing the scaling issues for both standard and descriptor systems. With these functions, the above problems can be appropriately addressed. Functions supporting scaling of system models, will be soon available in the DescriptorSystems package too. So, I will close this issue being solved. |
Today, minreal works on Windows 11/ Julia v1.9. THANKS!
The result from minreal is, however, "wrong" -- or perhaps extremely sensitive to tolerances...
Here is my system eigenvalues -- I insert copyable matrices for the system below:
From physics, there should be 4 states (independent differential equations) and 2 algebraic equations.
The text was updated successfully, but these errors were encountered: