Solver for nonlinear second order ODE has large residuals when mass matrix becomes state dependent

3 Ansichten (letzte 30 Tage)
Hi all,
I currently have a nonlinear second order ODE that when I try to solve with any of MATLAB's ODE solvers, I get unacceptably large residuals when the mass matrix becomes state dependent. Therefore I was wondering weather anyone would have any advice on the numerical integration side of things that could help in bringing down the residuals.
So let me be more specific and show you the following:
  1. The equation
  2. What I mean by residuals
  3. What term of the equation causes the residuals to be high (if that term is set as a constant then residuals are really low)
The equation is the one seen below:
where J, C,,,K are all matrices for a 4 degree of freedom system and , , are functions of theta.
What I mean by residuals is the process where after I have obtained the numerical solution to the above ODE from my code, I shift everything to the left hand side and check if its indeed equal to zero. The amount by which the expression below is not equal to zero, is the residuals:
When I solve the above system, but with set as a constant, the residuals are practically zero (1e-13). However when I make the mass matrix state dependent by introducing the aforementioned function, the residuals fluctuate at very large values (1e5) in comparison to what I am trying to model.
I have looked at the state dependent mass matrix examples of MATLAB, however I don't seem to be doing anything different from those examples. In addition I have tried changing the tolerances as well as the solvers but nothing promising is happening.
Attached you can also find my code together with the .mat file that it needs to run.
Thanks for all your help in advance!
KMT.
  1 Kommentar
Ayat
Ayat am 23 Mai 2024
dxcyt/ dt = kimp*xcyt + kexp*xnuc
dxnuc/ dt = kimp*xcyt kexp*xnuc ðxnuc + xpnucÞ 4 K4 + ðxnuc + xpnucÞ 4xnuc + kdephosxpnuc dxpnuc dt = ðxnuc + xpnucÞ 4 K4 + ðxnuc + xpnucÞ 4xnuc kdephosxpnuc
: kimp = 0:25; kexp = 1; kphos = 100; kdephos = 0:2; and, for the Hill function, K = 1 and n = 4. The steady-state responses were solved numerically with Mathematica 7.0 (Wolfram). (H) Dynamical response of the model. The ODEs were solved numerically with Mathematica 7.0. The dashed line is xtotðtÞ = 1:5=1 + et=t , with t = 7:2 min.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KostasK
KostasK am 16 Okt. 2019
Bearbeitet: KostasK am 16 Okt. 2019
I ended up solving the above equation with sufficiently low residuals, by choosing a sufficiently small tspan and running the ode solver in a loop where the initial conditions of the i+1 iteration are the last point of the solution of the i iteration. In addition, I treated the term as constant for every iteration. The drawback to this is that it takes a tremendous amount of time to solve a system with only 4x4 matrices (about 20-30mins). Will post again if I find a better way.

Weitere Antworten (1)

darova
darova am 14 Okt. 2019
Where is this part?
321.png
B = -K * th(1:N) - (C + CC) * th(m:n) + T_G + T_M1 - T_L ;
dydt(m:n) = (J-T_m1)\B; % solve matrix inv(A)*B
  1 Kommentar
KostasK
KostasK am 14 Okt. 2019
Bearbeitet: KostasK am 14 Okt. 2019
This part I have introduced as part of the mass function that is declared through the options of the ode solver. I found that it makes the algorithm work way faster if I do it this way rather than putting it in the odefcn.
So if you scroll down to the end of the code on the 'mass' function you will see this part.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by