Skip to content
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

Closed
wants to merge 141 commits into from

Conversation

tamaratambyah
Copy link
Collaborator

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 with TransientRungeKuttaFEOperator 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

@@ -0,0 +1,97 @@
using Pkg
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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)

Copy link
Collaborator Author

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
Copy link
Member

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

Copy link
Collaborator Author

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
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no nonlinear op here

Copy link
Collaborator Author

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)
Copy link
Member

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

Copy link
Collaborator Author

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
Copy link
Member

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

Copy link
Collaborator Author

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
Copy link
Member

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

Copy link
Collaborator Author

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

@santiagobadia
Copy link
Member

As discussed @tamaratambyah will create a new PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants