Skip to content

Commit

Permalink
Add relaxation timescale for deep convection in gcmdriven SCM setup
Browse files Browse the repository at this point in the history
  • Loading branch information
costachris committed Oct 4, 2024
1 parent d4cb583 commit 0ff34b7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
3 changes: 3 additions & 0 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ external_forcing:
external_forcing_file:
help: "External forcing file containing large-scale forcings, initial conditions, and boundary conditions [`nothing` (default), `path/to/file`]"
value: ~
external_forcing_type:
help: "External forcing type [`shallow` (default), `shallow`, `deep`]"
value: "shallow"
cfsite_number:
help: "cfsite identifier for single column forcing from `external_forcing_file`, specified as siteN. For site details see Shen et al. 2022 `https://doi.org/10.1029/2021MS002631`. [`site23` (default), `siteN`]"
value: "site23"
Expand Down
60 changes: 38 additions & 22 deletions src/prognostic_equations/forcing/external_forcing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,45 @@ function interp_vertical_prof(x, xp, fp)
return spl(vec(x))
end

"""
Calculate height-dependent scalar relaxation timescale following from eqn. 11, Shen et al., 2022.
"""
function compute_gcm_driven_scalar_inv_τ(z::FT) where {FT}

# TODO add to ClimaParameters
τᵣ = FT(24.0 * 3600.0)
zᵢ = FT(3000.0)
zᵣ = FT(3500.0)
if z < zᵢ
return FT(0)
elseif zᵢ <= z <= zᵣ
cos_arg = pi * ((z - zᵢ) / (zᵣ - zᵢ))
return (FT(0.5) / τᵣ) * (1 - cos(cos_arg))
elseif z > zᵣ
return (1 / τᵣ)
end
end

# following PyCLES https://github.com/CliMA/pycles/blob/71c1752a1ef1b43bb90e5817de9126468b4eeba9/ForcingGCMFixed.pyx#L260
function eddy_vert_fluctuation!(ᶜρχₜ, ᶜχ, ᶜls_subsidence)
@. ᶜρχₜ +=
Geometry.WVector(ᶜgradᵥ(ᶠinterp(ᶜχ))).components.data.:1 *
ᶜls_subsidence
end


"""
Calculate height-dependent scalar relaxation timescale following eqn. 11, Shen et al., 2022.
"""
function compute_gcm_driven_scalar_inv_τ(z::FT, forcing_type::String) where {FT}
if forcing_type == "shallow"
zᵢ = FT(3000.0)
zᵣ = FT(3500.0)
τᵣ = FT(24.0 * 3600.0)
elseif forcing_type == "deep"
zᵢ = FT(16000.0)
zᵣ = FT(20000.0)
τᵣ = FT(2.0 * 3600.0)
end
return compute_gcm_driven_scalar_inv_τ(z; τᵣ, zᵢ, zᵣ)
end

"""
Calculate height-dependent momentum relaxation timescale following eqn. 11, Shen et al., 2022.
"""
function compute_gcm_driven_momentum_inv_τ(
z::FT,
forcing_type::String,
) where {FT}
if forcing_type == "shallow"
τᵣ = FT(6.0 * 3600.0)
elseif forcing_type == "deep"
τᵣ = FT(3600.0)
end
return FT(1) / τᵣ
end

external_forcing_cache(Y, atmos::AtmosModel, params) =
external_forcing_cache(Y, atmos.external_forcing, params)

Expand All @@ -63,7 +76,8 @@ function external_forcing_cache(Y, external_forcing::GCMForcing, params)
insolation = similar(Fields.level(Y.c.ρ, 1), FT)
cos_zenith = similar(Fields.level(Y.c.ρ, 1), FT)

(; external_forcing_file, cfsite_number) = external_forcing
(; external_forcing_file, external_forcing_type, cfsite_number) =
external_forcing

NC.Dataset(external_forcing_file, "r") do ds

Expand Down Expand Up @@ -136,8 +150,10 @@ function external_forcing_cache(Y, external_forcing::GCMForcing, params)
set_insolation!(insolation)
set_cos_zenith!(cos_zenith)

@. ᶜinv_τ_wind[colidx] = 1 / (6 * 3600)
@. ᶜinv_τ_scalar[colidx] = compute_gcm_driven_scalar_inv_τ(zc_gcm)
@. ᶜinv_τ_wind[colidx] =
compute_gcm_driven_momentum_inv_τ(zc_gcm, external_forcing_type)
@. ᶜinv_τ_scalar[colidx] =
compute_gcm_driven_scalar_inv_τ(zc_gcm, external_forcing_type)
end
end

Expand Down
1 change: 1 addition & 0 deletions src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ function get_external_forcing_model(parsed_args)
DType = Float64 # TODO: Read from `parsed_args`
GCMForcing{DType}(
parsed_args["external_forcing_file"],
parsed_args["external_forcing_type"],
parsed_args["cfsite_number"],
)
elseif external_forcing == "ISDAC"
Expand Down
1 change: 1 addition & 0 deletions src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ end
# maybe need to <: AbstractForcing
struct GCMForcing{FT}
external_forcing_file::String
external_forcing_type::String
cfsite_number::String
end

Expand Down

0 comments on commit 0ff34b7

Please sign in to comment.