Closed bennibolm closed 2 months ago
This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.
NEWS.md
.Created with :heart: by the Trixi.jl community.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 96.10%. Comparing base (
cd097fc
) to head (9f0d930
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
You confirmed that one can now set the time step manually, right?
You confirmed that one can now set the time step manually, right?
Basically yes. The time step set was just ignored after https://github.com/trixi-framework/Trixi.jl/pull/1677.
I just tested all setups again and found a new bug I created when actually using the SaveSolutionCallback
with a fixed dt
interval. I'll take a look at it and hopefully fix it.
Okay, feel free to notify me when you think this is ready!
I'm a little bit lost right now. The first problem was that if we want to use a fixed time step (so with disabled stepsize callback), the time step is set to tspan[1]-t
(or tstop-t
when the savesolution callback saves every fixed time interval).
The overwriting process is done in modify_dt_for_tstops!
.
So, I added the current dt
to each minimum calculation in there (which is by the way not done in OrdinaryDiffEq's modify_dt_for_tstops!
).
But now, if we are close to one of these tstops
the time step is set to the needed minimum. So, it works to get the correct time step. But after this timestep, dt
stays at this small values. This is of course expected since I added the minimum of dt and something bigger the calculation.
For instance: using a fixes dt of dt = 1.0e-3
, tspan = (0.0, 1.0)
and
save_solution = SaveSolutionCallback(dt = 0.1+1.0e-6,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)
The timesteps are
#timesteps: 1 │ Δt: 1.0000e-03 │ sim. time: 1.0000e-03 (0.100%) │ run time: 8.6168e-03 s
#timesteps: 2 │ Δt: 1.0000e-03 │ sim. time: 2.0000e-03 (0.200%) │ run time: 1.5407e-02 s
#timesteps: 3 │ Δt: 1.0000e-03 │ sim. time: 3.0000e-03 (0.300%) │ run time: 2.2556e-02 s
...
#timesteps: 99 │ Δt: 1.0000e-03 │ sim. time: 9.9000e-02 (9.900%) │ run time: 7.0780e-01 s
#timesteps: 100 │ Δt: 1.0000e-03 │ sim. time: 1.0000e-01 (10.000%) │ run time: 7.1488e-01 s
#timesteps: 101 │ Δt: 1.0000e-06 │ sim. time: 1.0000e-01 (10.000%) │ run time: 7.2227e-01 s
#timesteps: 102 │ Δt: 1.0000e-06 │ sim. time: 1.0000e-01 (10.000%) │ run time: 7.3212e-01 s
#timesteps: 103 │ Δt: 1.0000e-06 │ sim. time: 1.0000e-01 (10.000%) │ run time: 7.3887e-01 s
#timesteps: 104 │ Δt: 1.0000e-06 │ sim. time: 1.0000e-01 (10.000%) │ run time: 7.5214e-01 s
#timesteps: 105 │ Δt: 1.0000e-06 │ sim. time: 1.0000e-01 (10.000%) │ run time: 7.7050e-01 s
#timesteps: 106 │ Δt: 1.0000e-06 │ sim. time: 1.0001e-01 (10.001%) │ run time: 7.9454e-01 s
....
@ranocha Do you have an idea how to fix this or how it is done in OrdinaryDiffEq (as I said, OrdinaryDiffEq uses the same version of modify_dt_for_tstops!
as in our main right now, see here).
EDIT: An idea would be to add a variable to the integrator which saves the set time step for the whole simulation and reset dt
with it for instance after every time step. But this seems to be a bit ugly. Maybe OrdinaryDiffEq has a better solution for this. Unfortunately, I can't find anything right now.
OrdinaryDiffEq.jl has a working implementation:
julia> using OrdinaryDiffEq
julia> ode = ODEProblem((du, u, p, t) -> du .= u, [1.0], (0.0, 1.0))
ODEProblem with uType Vector{Float64} and tType Float64. In-place: true
timespan: (0.0, 1.0)
u0: 1-element Vector{Float64}:
1.0
julia> sol = solve(ode, Euler(); adaptive = false, dt = 0.11, tstops = (0.5))
retcode: Success
Interpolation: 3rd order Hermite
t: 11-element Vector{Float64}:
0.0
0.11
0.22
0.33
0.44
0.5
0.61
0.72
0.83
0.94
1.0
u: 11-element Vector{Vector{Float64}}:
[1.0]
[1.11]
[1.2321000000000002]
[1.3676310000000003]
[1.5180704100000002]
[1.6091546346000003]
[1.7861616444060002]
[1.9826394252906603]
[2.200729762072633]
[2.4428100359006226]
[2.58937863805466]
Note the dtcache
in the code you linked above
Note the
dtcache
in the code you linked above
Oh yes. Thanks a lot
Save the manually set time step to allow simulations without a stepsize callback. Before it was overwritten within
modify_dt_for_tstops!
.