ode45 and rungekutta yield different result
이전 댓글 표시
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
Sam Chak
2022년 7월 10일
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
2022년 7월 10일
haohaoxuexi1
2022년 7월 10일
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
2022년 7월 10일
채택된 답변
추가 답변 (1개)
Jan
2022년 7월 10일
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
haohaoxuexi1
2022년 7월 10일
haohaoxuexi1
2022년 7월 29일
편집: haohaoxuexi1
2022년 7월 29일
Torsten
2022년 7월 29일
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
2022년 7월 30일
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

