[petsc-users] [EXT] Re: TSAdapt minimum step and exact final time

Phlipot, Greg Greg.Phlipot at jhuapl.edu
Thu Apr 21 07:32:32 CDT 2022


That may work -- I'm just a little apprehensive about letting it step
past max time. 

One reason is because I have a forcing function that isn't defined past
the max time. I would need to find some way of extrapolating the
function past the max time (e.g. just use the value at the max time?
linearly extrapolate? etc.) which wouldn't be my first choice.

There are some other (not very good) reasons that are related to the
specifics of the legacy code I am using to compute the residual. But
having it stop at max time is most convenient so I'm trying to see if I
can get that to work.

The very hacky work around that I have right now is to add in logic to
my function (set with TSetIFunction) to "skip" steps that start within
dt_min of the max time by just filling the residual vector with zero.
I'm using a BDF method so I would think this just use the extrapolated
state from the previous steps at the max time which may not be too
terrible since the time step is so tiny.

But this obviously isn't ideal (among the reasons is the adaptive time
stepper now picks the next step that is also tiny since it doesn't
increase the time step by too much in subsequent iterations). 

Thank you,

On Wed, 2022-04-20 at 17:22 -0400, Matthew Knepley wrote:
> APL external email warning: Verify sender knepley at gmail.com before
> clicking links or attachments
> On Wed, Apr 20, 2022 at 5:13 PM Phlipot, Greg <
> Greg.Phlipot at jhuapl.edu> wrote:
> > Hello,
> > 
> > When using TS with the option TS_EXACT_FINALTIME_MATCHSTEP to force
> > TS
> > to stop at the final time, I'm seeing the adaptive step controller
> > choose smaller time steps than the minimum time step that is set
> > with
> > TSAdaptGetStepLimits. For my problems, this leads to solutions that
> > won't converge due to numerical issues.
> > 
> > It seems like this might be due to the fact that TSAdaptChoose (
> > https://petsc.org/main/src/ts/adapt/interface/tsadapt.c.html#TSAdaptChoose
> > ) uses a tolerance of 10*PETSC_MACHINE_EPSILON to compare whether
> > the
> > candidate time step is close to the final time. For me,
> > 10*PETSC_MACHINE_EPSILON is much smaller than my smallest time step
> > so
> > the adaptation scheme occasionally chooses a time step that results
> > in
> > a time much closer to the max time than the minimum time step. The
> > subsequent time step is therefore forced to be smaller than the
> > minimum
> > time step.
> > 
> > Does anyone have an idea of a workaround (without changing the
> > source
> > code) where I would be able to modify this logic to use the minimum
> > time step instead of 10*PETSC_MACHINE_EPSILON? E.g. with Pre/Post
> > stage
> > callbacks and manually modifying the time step?
> It seems that if you want to disallow small timesteps, but also match
> accurately a final time,
> then the best choice is interpolation
> want to be as accurate as your timestep, shouldn't you just let it
> step over?
>   Thanks,
>     Matt
> > Thank you,
> > Greg

More information about the petsc-users mailing list