ODE solver-using initial conditions in events function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to solve a second-order ODE (time derivatives on x) using numerical solver like ode45:
mx''+cx'+kx+F1=0
where F1 is a nonlinear function of x and it's initial value x(0). But when x becomes x(0)-5, I want F1 to stop functioning and switch the ODE to
mx''+cx'+kx+F2=0
where F2 is just a constant and I will simulate it until x' is zero.
I know how to set event functions to make the integration stop at x'=0, but how can I switch between F1 and F2? Event functions seem not to support using initial conditions in the event describing.
One background is that F1 and F2 can be merged. When x becomes x(0)-5 and further, F1 will be a complex number while it's real part is just F2, so I can solve one equation
mx''+cx'+kx+real(F1)=0
until x' is zero. But then the simulation will not give a fine resolution at the switching point of F1 and F2. So if anyone can suggest a way to make fine resolution near the switching point of F1 and F2, that also solves my issue. Thank you!
0 commentaires
Réponse acceptée
Torsten
le 28 Fév 2022
Modifié(e) : Torsten
le 28 Fév 2022
If you want to use the event option, you can pass x(0) as an additional argument to the event function function and return control to the calling program when x(0)-5 is reached.
I suggest you just use mx''+cx'+kx+real(F1)=0 and choose tspan fine enough to resolve the switching point.
3 commentaires
Torsten
le 1 Mar 2022
options=odeset('Events',@(t,x)onedof_events(t,x,x_initial)
instead of
options=odeset('Events',@onedof_events)
But you don't need to care how long the tspan vector is - the steps the solver takes are independent from how many elements tspan comprises.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
