-
Notifications
You must be signed in to change notification settings - Fork 97
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
Implementing Explicit Runge Kutta Methods #951
Conversation
@@ -0,0 +1,97 @@ | |||
using Pkg |
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.
The whole my_tests folder should not be pushed to the main gridap project
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.
started clean branch of master fork. my_tests folder is removed
@@ -0,0 +1,97 @@ | |||
using Pkg | |||
|
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.
Are all these tests related to the ExRK dev?
If not, we do not need these tests here.
I do recommend to start from a fresh Gridap fork, add the ExRK dev, and we start again
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.
started clean branch of master fork.
@@ -0,0 +1,206 @@ | |||
using Pkg |
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.
Please try to stick to gridap code style guide, e.g., the way we name files here is not following it
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.
removed in clean version
@@ -52,7 +52,7 @@ function _solve_nr!(x,A,b,dx,ns,nls,op) | |||
|
|||
# Newton-like iterations | |||
for nliter in 1:nls.max_nliters | |||
|
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.
Remove this (better start from scratch as indicated above)
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.
removed in clean version
@@ -11,6 +11,8 @@ end | |||
@publish_gridapodes ODETools ThetaMethod | |||
@publish_gridapodes ODETools RungeKutta | |||
@publish_gridapodes ODETools IMEXRungeKutta | |||
@publish_gridapodes ODETools EXRungeKutta | |||
@publish_gridapodes ODETools DIRungeKutta |
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.
better first EX -> accept
then we start with DI
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.
removed in clean version
ki = [similar(u0) for i in 1:s] | ||
M = allocate_jacobian(op,t0,uf,ode_cache) | ||
get_mass_matrix!(M,op,t0,uf,ode_cache) | ||
nl_cache = nothing |
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.
no need for this cache, we are storing nothing
ode_cache, vi, ki, M, nl_cache = cache | ||
end | ||
|
||
nlop = EXRungeKuttaStageNonlinearOperator(op,t0,dt,u0,ode_cache,vi,ki,0,a,M) |
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.
no nonlinear op here
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.
changed to EXRungeKuttaStageOperator < RungeKuttaNonlinearOperator.
ti = t0 + c[i]*dt | ||
ode_cache = update_cache!(ode_cache,op,ti) | ||
update!(nlop,ti,ki[i],i) | ||
nl_cache = solve!(uf,solver.nls,nlop,nl_cache) |
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.
this is the LinearSolver cache, no nonlinear
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.
changed to l_cache
For other explicit methods, i = 1,…,s -> ui = u0 + dt ∑_{j<i} a_ij * kj | ||
|
||
For EX-RK, the Jacobian is always M. At each solve_step, compute and store M in | ||
nlop |
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.
M is not a nlop, change notation
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.
changed notation in clean version
EX-RK: A(t,u,ki) = M ki + K(ti,u0 + dt ∑_{j<i} a_ij * kj) = 0 -> solve for ki | ||
= M ki + K(ti,ui) = 0 | ||
|
||
For forward euler, i = 1 -> ui = u0 |
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.
don't you think this is just a particular case of the general case in which there is only one stage, I think you can accommodate it in the same implementation / def'on
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.
updated this comment to be more general in clean version
As discussed @tamaratambyah will create a new PR |
In this PR, I have implemented multi-stage, explicit Runge Kutta method in EXRungeKutta.jl. This follows the format and structure of RungeKutta.jl and IMEXRungeKutta.jl.
I have added an additional operator
TransientEXRungeKuttaFEOperator
. However, I think this can be combined withTransientRungeKuttaFEOperator
to have one operator which works for both explicit and diagonally implicit Runge Kutta (IMEX will probably still require its own operator). Once DIRK is working properly, I will look to tidy this up.Note, there are some preliminary implementations of DIRK on this branch. I have created a different branch for this now.
@santiagobadia can you please review this PR.
Thanks