Energy-Pathways-Group / GLOceanKit

Tools for physical oceanography in Matlab and Objective-C
21 stars 11 forks source link

Add adaptive time-stepper #113

Open JeffreyEarly opened 2 months ago

JeffreyEarly commented 2 months ago

This might actually be possible, although I do worry about memory copies.

First, we obviously use ode23 with the syntax sol = ode23(). We then time step to the desired output time, and use deval to get the values at the output time. And finally, odextend to step forward to new output times.

The tricky thing here is that this will save all the y values between output times. So we will have to prevent this from happening by manually forcing small increments internally. Need to test this.

Also, look at the ode options and in particular, Vectorized, which is apparently not enabled by default.

JeffreyEarly commented 2 months ago

Code seems to work great. The relative tolerance is currently set higher than needed (given the current absolute tolerances), and it appears that this is dropping the time step when particles are added. I would like to clean this up a tiny bit more.