-
Notifications
You must be signed in to change notification settings - Fork 3
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
named_ss & linearization -- strange result #72
Comments
Even stranger... with the following matrices, I get the same transfer function with the two methods ("my" elimination of input derivative -- you suggested this method to me a while ago; the (A = [-0.0075449237853825925 1.6716817118020731e-6 0.0; 1864.7356343162514 -0.4131578457122937 0.0; 0.011864343330426718 -2.6287085638214332e-6 0.0], B = [0.0 0.0; 0.0 52566.418015009294; 0.0 0.3284546792274811], C = [1.4683007399899215e8 0.0 0.0], D = [-9.157636303058283e7 0.0]) |
With the matrices from the first post, these two methods both produce the same transfer function
|
I found that function, but didn't understand how to specify the second input argument. |
The second argument is a map from input indices to the indices of their derivatives, in this case |
Look at the code I posted that calls the function |
Yea, I just saw it. |
OK -- if I run ([224.94741728183658;;], [-5.495512471427165e18;;]) where the first one (the correct one, I think) is from my removal of the input derivative, while the second one is what I get from Maybe I was just lucky? The model from |
The numerics of this system appear to be extremely sensitive, |
By the way, try your best to avoid converting the statespace system to a transfer function, transfer functions are terrible from a numerics perspective. What do you get if you call |
If I just do 1×1 Matrix{Float64}:
-5.495512471427165e18 If I do 1×1 Matrix{Float64}:
224.5610584029963 |
With this PR the zero computation performs a numerical balancing of the statespace system before calling the zero routine in MatrixPencils, this improves the numerics for this system. It also makes possible to compute zeros in BigFloat precision by using GenericSchur # required
tzeros(big(1.0)sys) multiplying by If you look at the statespace matrices and see large coefficients, like the julia> ss(lsys...)
StateSpace{Continuous, Float64}
A =
0.0 2.778983834717109e8 1.4122312296634873e6 0.0
0.0 0.0 0.0 0.037848975765016724
0.0 24.837541148074962 0.12622006230897712 0.0
-0.0 -4.620724819774693 -0.023481719514324866 -0.6841991610512456
B =
-5.042589978197361e8 0.0
-0.0 0.0
-45.068824982602656 -0.0
8.384511049369085 54.98555939873381
C =
0.0 0.0 0.954929658551372 0.0
D =
0.0 0.0
Continuous-time state-space model it's often good for numerics to perform balancing julia> balance_statespace(ss(lsys...))[1]
StateSpace{Continuous, Float64}
A =
0.0 1060.0982035511433 5.387234610227536 0.0
0.0 0.0 0.0 620.117618934034
0.0 24.837541148074962 0.12622006230897712 0.0
0.0 -0.00028202666136320145 -1.4332104195754923e-6 -0.6841991610512456
B =
-60.112356879679695 0.0
0.0 0.0
-1.408400780706333 0.0
1.5992185686815423e-5 0.00010487663154360545
C =
0.0 0.0 30.557749073643905 0.0
D =
0.0 0.0
Continuous-time state-space model this balancing is now done automatically in This PR adds an option to simplify the causality using the With these two PRs merged, your particular system can be robustly handled by lsys = (A = [0.0 2.778983834717109e8 1.4122312296634873e6 0.0; 0.0 0.0 0.0 0.037848975765016724; 0.0 24.837541148074962 0.12622006230897712 0.0; -0.0 -4.620724819774693 -0.023481719514324866 -0.6841991610512456], B = [-5.042589978197361e8 0.0; -0.0 0.0; -45.068824982602656 -0.0; 8.384511049369085 54.98555939873381], C = [0.0 0.0 0.954929658551372 0.0], D = [0.0 0.0])
G = ControlSystemsMTK.causal_simplification(lsys, [1=>2])
Gb = balance_statespace(G)[1]
Gb = minreal(Gb, 1e-8)
julia> dcgain(Gb)
1×1 Matrix{Float64}:
224.94742230326355 |
Another thing you might want to try is to tighten the tolerance used for root finding when linearizing, this might be the source of the numerical issues. Try |
Thanks -- and sorry for slow response. Today is my exercise day (in the morning), and after lunch, the cafes I've been to have had rotten wifi and virtually zero cell phone connection (so no tethering). |
I tried to use with I guess I could replace
with lsys = named_ss(...)
Gb = balance_statespace(lsys)[1]
Gb = minreal(Gb, 1e-8) ? |
If you know the operating point Pluto notebooks can handle long (as in a lot of text and code) documents just fine, but they become awkward when computations in some cells take a long time to run. All cells that are affected by a change anywhere are rerun automatically. This is great for reproducibility, and there are mechanisms to mitigate this, but it's still awkward.
this is slightly annoying sometimes, but it also has upsides, and is quite easy to work around by either
|
I've got a slightly complicated system (a hydro power system from turbine opening angle$\alpha_1$ to grid frequency $f_\mathrm{e}$ ). I'm trying to linearize the system at various opening angles. At the nominal angle, I run a 5 % step increase in $\alpha_1$ , and get an increase in $f_\mathrm{e}$ :
This should indicate a positive steady state gain in the system.
First, I use
linearize
-- the MTK linearization function. I get a linear model (A,B,C,D) with input derivative, so I create a linear model (A_1,B_1,C_1,D_1) from the time derivative of the input to the output:Finally, I use that the input is L(D(u)) = s*u, i.e., I multiply the transfer function above with "s" to get u as input:
which gives the model in zpk form as:
This system has a dcgain of +225.
Next, I try to use
named_ss
fromControlSystemsMTK
-- which is where the weird result comes in:The result in zpk form is:
[The model from MTK had similar false zeros/poles, but these disappeared when I multiplied with
tf("s")
...]Observe here:
If I "guess" that this system really has derivative of u as input and do the same trick as above, I get:
which has a dcgain of ca. -230 -- which has the wrong sign.
Questions:
named_ss
has the derivative of the input as input (my system clearly does not have a true integrator; a steady state is reached)What are the explanations? Is this a bug, or do I do something wrong?
Here is the tuple of matrices that
linearize
returns:I'm on MTK v9.64.1, ControlSystems v1.11.2, ControlSystemsMTK v2.3.1.
The text was updated successfully, but these errors were encountered: