ode45 and rungekutta yield different result
Afficher commentaires plus anciens
I am using ode45 and rungekutta script to solve some piecewise differential equations. But the result is a bit different.
Can anyone help me to solve the problem? I am hoping to get a similar result as ode45.
Thanks,
5 commentaires
Sam Chak
le 10 Juil 2022
Didn't check your dynamical equations due to code clutter issue.
Is it a piecewise smooth dynamical system, or a piecewise discontinuous system?
If your rungekutta code is 100% correct and is expected to return output similar to the ode45 solver, then I guess something is missing in the dynamical system.
haohaoxuexi1
le 10 Juil 2022
haohaoxuexi1
le 10 Juil 2022
First change your Runge-Kutta code such that both ODE45 and your code can use the same function "SDOFFriction" to compute the derivatives.
Then someone might invest the effort to compare the codes.
haohaoxuexi1
le 10 Juil 2022
Réponse acceptée
Plus de réponses (1)
Jan
le 10 Juil 2022
The function to be integrated contains:
if abs(vrel)/v_band<0.001
...
if abs(faply)<uS*Fn
This looks like this function is not smooth. Matlab's ODE integrators are designed to handle smooth functions only. Otherwise the step size controller drives mad and the final value is not a "result" anymore but can be dominated by accumulated rounding errors.
A fixed step solver runs brutally over the discontuinuities. It depends on the function and stepsize, if the calculated trajectory is "better" or "worse" than the trajectory calculated with a step size controller. From a scientific point of view, both methods, fixed step RK and ODE45 without detection of discontinuities are expensive random number generators with a weak entropy.
Don't do this for scientific work. Use a stepsize controlled integrator and stop/restart the integration at each discontinuitiy to recondition the controller.
4 commentaires
haohaoxuexi1
le 10 Juil 2022
haohaoxuexi1
le 29 Juil 2022
Modifié(e) : haohaoxuexi1
le 29 Juil 2022
Torsten
le 29 Juil 2022
All deterministic ODE integrators assume that the function to be integrated is at least differentiable. They can't cope with stochastic inputs.
Look up "Stochastic Differential Equations" if you want to define some inputs as random variables.
haohaoxuexi1
le 30 Juil 2022
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

