-
Notifications
You must be signed in to change notification settings - Fork 85
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
B matrix cannot contain too many zero elements for baltrunc #925
Comments
Could you provide the matrix data ro reproduce the error? It will be hard for me to solve it without being able to reproduce it |
Try calling |
I think the problem is that you request You can also try calling |
test_chain.zip |
After calling the |
Your system is structurally non-minimal
only the first output/state variable is ever affected by the input. Why do you set |
I'll close this issue since I don't believe there's anything wrong in the implementation. #926 adds a more friendly error message. Please feel free to continue the discussion here until you have found a solution to your original problem. To help you, a bit more context would be useful, what is your final goal, what does the model represent and where is it coming from? |
Thanks for you help! I'm trying to make a reduced order model of a fuel burnup of a nuclear reactor. Before I tried the proper orthogonal decomposition, however the timescales in a nuclear reactor vary wildly (10^-20 - 10^40), so it regularly creates unstable models. That is why I'm trying balanced truncation in Julia, with BigFloats. My goal with the decay chain is just to test the methodology, so I'm mainly interested in the impulse response, however in general I would need to make a model that can handle all kinds of initial conditions. If I set B to I, the accuracy of the model seems to suffer and it still gives a similar error to the original error if I set the difference between the decay constants large enough (40 orders of magnitude), only it says that it is trying to access an 8 element vector. |
Do you need to reduce the complete model all at once, or could you keep your time scales separate and reduce the fast and slow parts of the model separately before combining? You can try this PR branch and see if you can retain more modes than 8 |
How do I use the PR branch? But no, I can't separate the time scales, sometimes a slow decaying nuclide comes from a fast decay and vise-versa. |
I think you can add the branch using pkg> add ControlSystemsBase#balrealeps and then restart julia before trying |
Another thing you can try is using RobustAndOptimalControl
sys_fast, sys_slow = stab_unstab(sys, smarg = -100); this splits the system additively into two systems with different time scales, one with poles faster than 100 (you may need to tweak this value) and one with slower. You could then reduce the order of the two models independently, and later combine them again as sys_red = sys_fast_red + sys_slow_red Something like this s1,s2 = stab_unstab(sys, smarg = -1e4);
# Figure out a reasonable time scale to split the systems at
s1r, _ = balreal(s1);
s2r, _ = balreal(s2);
@show s1.nx, s2.nx
@show s1r.nx, s2r.nx
# smarg = -1e4 seems reasonable, now reduce fast and slow dynamics independently
s1r, _ = baltrunc(s1, n=5);
s2r, _ = baltrunc(s2, n=5);
sys_red = s1r + s2r # Final reduced-order system of order 5+5 |
Did you perform the computations above using BigFloats? The model-reduction methods in this package all assume an input-output model, but this does not appear to fit your use case, you don't have any inputs? |
The simulation is done in Python float64 using the scipy ivp solver with BDF method. All the calculations in Julia are done using BigFloats. I'm not entirely sure what my inputs must be, as I'm quite new to control theory. I have two models I'm trying to simulate:
Thanks again for all your help up until now. It means a lot to me :) |
You could perform the simulation in BigFloat in julia to see if that resolves some of these issues. The models you describe are not input-output models, they are autonomous ODEs (no input). The methods in this package mostly assume IO models, in particular, the methods for model reduciton. You can simulate autonomous models just fine though, in which case the initial condition is provided as initial condition and not as input. For such a model, the input matrix is empty |
During balanced truncation of a decay chain model I found certain errors depending on my choice of B. If it contains to many zeros, then I get an bounds error:
The full code is:
As I generate A,B,C using python I will describe them. A is a 50x50 sparse matrix with negatives on the diagonal and same values, but positives just right next to it. B should be the initial condition, which is only element 1 being 1 and the other 49 zero. C is a 50x50 identity matrix.
I found a workaround, by adding a tiny value to every element of B, but I do not feel comfortable doing that. Why does the code 'need' the nonzero elements?
The text was updated successfully, but these errors were encountered: