Skip to content

Commit 7c1dc07

Browse files
committed
rk2 coefficients
1 parent 0c5bf03 commit 7c1dc07

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Constants.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ end
2525
"""Generator function for the mutable struct Constants."""
2626
function Constants{T,Tprog}(P::Parameter,G::Grid) where {T<:AbstractFloat,Tprog<:AbstractFloat}
2727

28-
# Runge-Kutta 3rd/4th order coefficients including time step Δt
29-
# (which includes the grid spacing Δ too)
30-
if P.RKo == 3 # version 2
28+
# Runge-Kutta 2nd/3rd/4th order coefficients including time step Δt and grid spacing Δ
29+
# a are the coefficents to sum the rhs on the fly, such that sum=1
30+
# b are the coefficents for the update that used for a new evaluation of the RHS
31+
if P.RKo == 2 # Heun's method
32+
RKaΔt = Tprog.([1/2,1/2]*G.dtint/G.Δ)
33+
RKbΔt = Tprog.([1]*G.dtint/G.Δ)
34+
elseif P.RKo == 3 # version 2 / Heun's 3rd order
3135
RKaΔt = Tprog.([1/4,0.,3/4]*G.dtint/G.Δ)
3236
RKbΔt = Tprog.([1/3,2/3]*G.dtint/G.Δ)
3337
elseif P.RKo == 4

src/DefaultParameters.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
@assert topo_width > 0.0 "topo_width has to be >0, $topo_width given."
119119
@assert t_relax > 0.0 "t_relax has to be >0, $t_relax given."
120120
@assert η_refw > 0.0 "η_refw has to be >0, $η_refw given."
121-
@assert RKo in [3,4] "RKo has to be 3 or 4, $RKo given."
121+
@assert RKo in [2,3,4] "RKo has to be 2,3 or 4, $RKo given."
122122
@assert Ndays > 0.0 "Ndays has to be >0, $Ndays given."
123123
@assert nstep_diff > 0 "nstep_diff has to be >0, $nstep_diff given."
124124
@assert nstep_advcor >= 0 "nstep_advcor has to be >=0, $nstep_advcor given."
@@ -191,8 +191,8 @@ Creates a Parameter struct with following options and default values
191191
wk::Real=10e3 # width [m] in y of Gaussian used for surface forcing
192192
193193
# TIME STEPPING OPTIONS
194-
RKo::Int=4 # Order of the RK time stepping scheme (3 or 4)
195-
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3)
194+
RKo::Int=4 # Order of the RK time stepping scheme (2,3 or 4)
195+
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3, 0.1 for RK2)
196196
Ndays::Real=10.0 # number of days to integrate for
197197
nstep_diff::Int=1 # diffusive part every nstep_diff time steps.
198198
nstep_advcor::Int=0 # advection and coriolis update every nstep_advcor time steps.

0 commit comments

Comments
 (0)