-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Relaxation Runge-Kutta #2227
Conversation
Modif file : - integrators\type.jl + solve.jl: add u_propose, u_changed, dt_has_changed, dt_changed + initialisation - OrdinaryDiffEq.jl : add file and method - add cache - add a new file for performstep - add alg_order in alg.utils
Alerting @ranocha who may be interested in keeping on top of this. |
Two comments on the current implementation :
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting development. If you want to achieve best performance with step size control, you can have a look at our recent preprint https://arxiv.org/abs/2311.14050
Feel free to ask me if you have any specific questions while working on this
Regarding the step
in your TODO list above, I have an implementation of the relaxation step (there it is implemented as a callback) in https://github.com/JoshuaLampert/DispersiveShallowWater.jl/blob/a7eb1307169d1278f0c4e1afeae55b3e9a8cea64/src/callbacks_step/relaxation.jl, which might or might not help you. |
Ok, thanks to both of you, I will take a look! |
Update on my work :
|
@ChrisRackauckas, @ranocha I have a small question if someone can help me. I compare my implementation Tsit5_for_relaxtion with the existing Tsit5 on a simple problem without relaxation such that results must be the same. I encounter a small problem of interpolation which could be due to my code, but I wonder if it could be due to the fact I do not define _ode_interpolant for Tsit5_for_relaxation. |
that is the reason. |
exponential entropy doesn't work
Relaxation new version
all last modif I forgot
@@ -77,6 +77,8 @@ import DiffEqBase: resize!, deleteat!, addat!, full_cache, user_cache, u_cache, | |||
add_saveat!, set_reltol!, | |||
set_abstol!, postamble!, last_step_failed, | |||
isautodifferentiable | |||
|
|||
export change_u!, change_dt!, apriori_bounds_dt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these need to be exported?
thread::Thread = False() | ||
end | ||
|
||
# for backwards compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backwards compatibility with what?
@@ -448,6 +448,44 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, :silence!) | |||
Base.Experimental.silence!(Tsit5Cache) | |||
end | |||
|
|||
@cache struct Tsit5Cache_for_relaxation{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this just use the Tsit5Cache
?
integrator.dt_changed = dt | ||
end | ||
|
||
function change_u!(integrator::ODEIntegrator, u) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this set integrator.umodified
?
end | ||
|
||
# Calculate f(uₙ₊₁) if the aglortihm has the FSAL property | ||
if isfsal(integrator.alg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this always be true?
@@ -0,0 +1,255 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the benchmark be in SciMLBenchmarks rather than OrdinaryDiffEq?
The fact that this requires ~1000 lines to add relaxation to a single algorithm seems like it should be improved. It seems like we should be able to duplicate less of the steps between the regular solvers and the relaxation ones. Currently, it seems like the chance of us making improvements to the regular and those changes not getting reflected in the relaxation solver is pretty high. |
Thanks for your review. In fact, it does not require as many lines at all. I have replicated the Tsit5 solver as Tsit5_for_relaxation so as not to "break" the initial solver and make comparisons. But what I had in mind would be to modify the perform_step! function for all the methods for which we can do relaxations, into a general perform_step! function for all the methods. Instead, each method would have a computation! function and other functions such as the calculation of error estimates. I am aware that this is a big change to the general solver, but I can't see any other way of including relaxation before the loopfooter! function. (So we wouldn't be able to use all the variants of relaxation, including the R-FSAL method). The other solution would be to add a condtion like "if relaxation do relaxation end" In the 1000 lines, there are several test files that I have made so that you can test them and see that the code works with relaxation, as well as a jupiter notebook that I should remove that shows that the code is not slowed down by the new perform_step! structure. For the tests, I have taken the examples I found in the https://arxiv.org/abs/2311.14050 article. |
Closing in favor of #2283 |
Start of the implementation of relaxation Runge-Kutta methods (see #1029)
Instead of writing things with a callback as suggested in the issue, I prefer to propose, I think, a more suitable solution by decoupling perform_step! into several steps one of which will allow the user to do modifications on the computations of the method. I think the problem with the callback is when it occurs : in the loopfooter function where things that have already modified have been registered as dtnew, t, tprev and others things related to tstops, which could be changed by the relaxation methods.
For the moment, to test the new structure, I copy the Tsit5 method with another name Tsit5_for_relaxation. I will certainly change some parts of the code and its structure. I am not sure yet if the idea is good, but I think it is a good starting point.
To do
From the relaxation method point of view :
From an interface point of view :