Solving Linear Systems for Multibody Systems
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Tiago Carvalho
il 21 Lug 2022
Commentato: Tiago Carvalho
il 22 Lug 2022
Good afternoon,
I'm currently coding a Multibody Foward Dynamcis Simulator in MATLAB, for my master thesis, and I am having issues with solving linear systems due to low RCOND values, ill-condition of the matrices.
This problem is expected in this type of problems since each column entry in a line corresponds to the elements of a joint equation for two bodies resulting in a highly sparse matrix and consequently ill-conditioned matrices.
What my algorithm does is it calculates the initial accelerations of bodies in order for them to be integrated through an ode solver for position and velocity. My problems arise in solving the linear system for the initial accelerations that will be integrated. The system I have to solve is the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073105/image.png)
Where: M is a mass matrix, Phiq is a Jacobian, alpha/omega/mu are scalars, Phi, gamma and upsilon are vectors.
For my algorithm I tried using pinv(A)*B or lsqr(A,B), but I am not able to get the correct results (only get constant values from initial time until the last integration). On the other hand I get good results by using mldivide or \, but i get the following message:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.394430e-19.
I wanted to know if there is anyway to avoid this issue, since I know it can cause significant noise in my results, I usually use pinv for this but it seems to not be working this time.
Thank you for your time and attention.
Tiago
(Attached files are the left and right hand side of the linear problem)
4 Commenti
Torsten
il 21 Lug 2022
Modificato: Torsten
il 21 Lug 2022
MATLAB's ODE solvers are designed to solve systems of the form
M(t,y)*y' = f(t,y)
Why do you invert your matrix in the ODE function routine and supply M^(-1)*f and don't let the ODE solver do the job by defining two functions in which you separately define the mass matrix M(t,y) and the right-hand side vector f(t,y) ?
Risposta accettata
Bjorn Gustavsson
il 22 Lug 2022
As best I can interpret your flow-chart it seems that it ought to be "reasonably straightforward" to follow Torsten's advice by converting the equation for
into one for both
and
. If I get it right it should be something like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073745/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073750/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073755/image.png)
function Mout = modified_massmatrix(M)
Mout = [eye(size(M,1)),zeros(size(M));
zeros(size(M)),M];
end
or if the mass-matrix is a function of t, q and
:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073760/image.png)
function Mout = modified_massmatrix(t,qqdot,M)
Mnow = M(t,qqdot);
Mout = [eye(size(Mnow,1)),zeros(size(Mnow));
zeros(size(Mnow)),Mnow];
end
Then you should be good to go with the ODE-integrating functions.
8 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!