From fb8f016690d2f0c5e8149137c43d5db7a94e2e7e Mon Sep 17 00:00:00 2001 From: milankl Date: Tue, 10 Sep 2019 21:37:51 +0100 Subject: [PATCH] to Pkg --- README.md | 4 +- src/Juls.jl | 33 ++++++++++++++ src/RunJuls.jl | 116 +++++++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 6 +++ 4 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 src/Juls.jl create mode 100644 src/RunJuls.jl create mode 100644 test/runtests.jl diff --git a/README.md b/README.md index f12f520..8b08249 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Juls is fully-explicit with a Smagorinsky-like biharmonic diffusion operator, th Forcing is either with a wind-stress applied to the momentum equations, or surface/interface relaxation or forcing of the contuinity equation is possible. Boundary conditions are either periodic (only in x direction) or super-slip/free-slip/partial-slip/no-slip for non-periodic BCs. Output of all prognositc and various diagnostic variables & tendencies is done via NetCDF. -Requires Julia either v0.6, v0.7 or v1.x and NetCDF. +Requires Julia v1.x and NetCDF. # HOW TO USE @@ -40,6 +40,6 @@ The linear shallow water model equivalent is ∂η/∂t = -H*∇⋅u⃗ + γ*(η_ref - η) + Fηt(t)*Fη(x,y) (3) ∂ϕ/∂t = -u⃗⋅∇ϕ (4) -Juls discretises the equation on an equi-distant Arakawa C-grid, with 2nd order finite-difference operators. Boundary conditions are implemented via a ghost-point copy and each variable has a halo of variable size to account for different stencil sizes of various operators. +Juls discretises the equation on an equi-distant Arakawa C-grid, with 2nd order finite-difference operators. Boundary conditions are implemented via a ghost-point copy and each variable has a halo of variable size to account for different stencil sizes of various operators. Juls splits the time steps for various terms: Runge Kutta 4th order scheme for the fast varying terms. The diffusive terms (bottom friction and diffusion) are solved semi-implicitly every n-th time step. The tracer equation is solved with a semi-Lagrangian scheme that uses usually much larger time steps. diff --git a/src/Juls.jl b/src/Juls.jl new file mode 100644 index 0000000..00ac0db --- /dev/null +++ b/src/Juls.jl @@ -0,0 +1,33 @@ +module Juls + +export RunJuls + +using Dates, NetCDF, FileIO, Printf + +# GRID +include("grid.jl") +include("constants.jl") +#include("domain_decomposition.jl") + +# OPERATORS and everything that is needed for the RHS +include("gradients.jl") +include("interpolations.jl") +include("PV_adv.jl") +include("bottom_friction.jl") +include("diffusion.jl") +include("tracer_adv.jl") +include("coriolis.jl") +include("forcing.jl") +include("bottom_topography.jl") +include("rhs.jl") +include("continuity.jl") +include("time_integration.jl") +include("ghost_points.jl") +include("initial_conditions.jl") +include("preallocate.jl") + +# OUTPUT AND FEEDBACK +include("src/feedback.jl") +include("src/output.jl") + +end diff --git a/src/RunJuls.jl b/src/RunJuls.jl new file mode 100644 index 0000000..a894003 --- /dev/null +++ b/src/RunJuls.jl @@ -0,0 +1,116 @@ +function RunJuls(::Type{T}=Float32; # number format + + # DOMAIN RESOLUTION AND RATIO + nx::Int=100, # number of grid cells in x-direction + Lx::Real=1000e3, # length of the domain in x-direction [m] + L_ratio::Real=1, # Domain aspect ratio of Lx/Ly + + # PHYSICAL CONSTANTS + gravity::Real=10., # gravitational acceleration [m/s] + water_depth::Real=500., # layer thickness at rest [m] + ρ::Real=1e3, # density [kg/m^3] + ϕ::Real=15., # central latitue of the domain (for coriolis) [°] + ω::Real=2π/(24*3600), # Earth's angular frequency [s^-1] + R::Real=6.371e6, # Earth's radius [m] + + # WIND FORCING OPTIONS + wind_forcing_x::String="channel", # "channel", "double_gyre", "shear","constant" or "none" + wind_forcing_y::String="none", # "channel", "double_gyre", "shear","constant" or "none" + Fx0::Real=0.12, # wind stress strength [Pa] in x-direction + Fy0::Real=0.0, # wind stress strength [Pa] in y-direction + + # BOTTOM TOPOGRAPHY OPTIONS + topography_feature::String="ridge", # "ridge", "seamount", "flat", "ridges", "bathtub" + topofeat_height::Real=10., # height of seamount [m] + topofeat_width::Real=300e3, # horizontal scale [m] of the seamount + + # SURFACE RELAXATION + surface_relax::Bool=false, # yes? + t_relax::Real=100., # time scale of the relaxation [days] + η_refh::Real=5., # height difference [m] of the interface relaxation profile + η_refw::Real=100e3, # width [m] of the tangent used for the interface relaxation + + # SURFACE FORCING + surface_forcing::Bool=false, # yes? + ωyr::Real=1.0, # (annual) frequency [1/year] + A₀::Real=3e-5, # Amplitude [m/s] + + # TIME STEPPING OPTIONS + RKo::Int=4, # Order of the RK time stepping scheme (3 or 4) + cfl::Real=1.0, # CFL number (1.0 recommended for RK4, 0.6 for RK3) + Ndays::Real=100.0, # number of days to integrate for + nstep_diff::Int=1, # diffusive part every nstep_diff time steps. + nstep_advcor::Int=0, # advection and coriolis update every nstep_advcor time steps. + # 0 means it is included in every RK4 substep + + # BOUNDARY CONDITION OPTIONS + bc_x::String="periodic", # "periodic" or anything else for nonperiodic + lbc::Real=2., # lateral boundary condition parameter + # 0 free-slip, 0