Discritizing an ODE Solution

Hello, I have a conceptual question to ask. Say I want to utilize the ode15s function to solve a system of coupled differential equations given a specific set of initial conditions, however, instead of just imputing the initial and final time span and allowing the program to workout the optimal time step, in the back end, I want to discritize the time span into specified time steps and format this into a time for loop.
The reason I ask is because I already tried implementing the ode15s function in the for loop and set the time span to be equivalent to the for loop time step, however this significantly increases the run time. Moreover, I am doing this because there is a separate process I want the program to run at every single time step which is why I want to dicritize in the first place.
I believe the issue arises from the fact that although I am discriticizing the time span in the for loop, the ode solver is calculating all the solutions in between each define time step. I already tried searching online in the forums and resources but the only parameter that is related to the time step that one may specify is the MaxStep size. There is no way to define a minimum step size. What should one do in this scenario?
PS - May it have something to do with defining a Jacobian for my system of odes? Or is that completely unrelated?
If you are interested in looking at the for loop with the nested ode solver I link it here: Code

4 comentarios

John D'Errico
John D'Errico el 2 de Nov. de 2018
So you are asking to NOT use an adaptive ODE solver, one designed for a stiff ODE system, but want to solve the problem using essentially a fixed time step. But you still want to use ODE15s, probably because you really do have a stiff ODE system.
No, the Jacobian will not solve your problem.
I'll argue the issue really arises from the fact that your problem is apparently not solvable using the method you really want to use.
Tom Keaton
Tom Keaton el 2 de Nov. de 2018
Editada: Tom Keaton el 2 de Nov. de 2018
It is not a requirement to use the ode15s function, however I do believe that the ode set is a stiff system. If it helps, I am solving the Lorentz force equations of motion and because the initial conditions can vary drastically and the magnetic field is a little non-trivial, I think these may be considered "stiff" in a few scenarios. Is there a function in Matlab that may handle these requirements or will I need to create a whole new ODE solver on my own for this?
Caglar
Caglar el 2 de Nov. de 2018
Editada: Caglar el 2 de Nov. de 2018
Dont odes accept time input as a vector? Like, t=[t0:dt:tf] ?
Tom Keaton
Tom Keaton el 4 de Nov. de 2018
@Caglar I just tried this and it works! Just need to do a little more manipulation for this specific application!

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 2 de Nov. de 2018

Comentada:

el 4 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by