Skip to content

Commit

Permalink
improves insolation and cos_zenith compatability and enforces choice …
Browse files Browse the repository at this point in the history
…of ode_algorithm
  • Loading branch information
Julians42 committed Jul 26, 2024
1 parent a17f8b7 commit 8a6a223
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ diagnostics:
- reduction_time: max
short_name: tke
period: 10mins
ode_algo: ARS343
4 changes: 2 additions & 2 deletions src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ end
function set_insolation_variables!(Y, p, t, ::GCMDrivenInsolation)
FT = Spaces.undertype(axes(Y.c))
(; rrtmgp_model) = p.radiation
rrtmgp_model.cos_zenith .= p.external_forcing.cos_zenith
rrtmgp_model.weighted_irradiance .= p.external_forcing.insolation
rrtmgp_model.cos_zenith .= Fields.field2array(p.external_forcing.cos_zenith)
rrtmgp_model.weighted_irradiance .= Fields.field2array(p.external_forcing.insolation)
end

function set_insolation_variables!(Y, p, t, ::IdealizedInsolation)
Expand Down
19 changes: 14 additions & 5 deletions src/prognostic_equations/forcing/external_forcing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ function external_forcing_cache(Y, external_forcing::GCMForcing, params)
ᶜinv_τ_wind = similar(Y.c, FT)
ᶜinv_τ_scalar = similar(Y.c, FT)
ᶜls_subsidence = similar(Y.c, FT)
insolation = similar(Fields.level(Y.c.ρ, 1), FT)
cos_zenith = similar(Fields.level(Y.c.ρ, 1), FT)

(; external_forcing_file) = external_forcing

insolation, cos_zenith = [0f1], [0f1]
#insolation, cos_zenith = [0f1], [0f1]
NC.Dataset(external_forcing_file, "r") do ds

function setvar!(cc_field, varname, colidx, zc_gcm, zc_forcing)
Expand All @@ -67,9 +69,6 @@ function external_forcing_cache(Y, external_forcing::GCMForcing, params)
)
end

insolation[1] = mean(ds.group["site23"]["rsdt"][:] ./ ds.group["site23"]["coszen"][:]) #similar(Fields.level(Y.c.ρ, 1), FT) #similar(Spaces.level(Y.c.ρ, 1), FT)
cos_zenith[1] = ds.group["site23"]["coszen"][1]

function setvar_subsidence!(cc_field, varname, colidx, zc_gcm, zc_forcing, params)
parent(cc_field[colidx]) .= interp_vertical_prof(
zc_gcm,
Expand All @@ -80,6 +79,13 @@ function external_forcing_cache(Y, external_forcing::GCMForcing, params)
)
end

function set_insolation!(cc_field)
parent(cc_field) .= mean(ds.group["site23"]["rsdt"][:] ./ ds.group["site23"]["coszen"][:])
end

function set_cos_zenith!(cc_field)
parent(cc_field) .= ds.group["site23"]["coszen"][1]
end

zc_forcing = gcm_height(ds.group["site23"])
Fields.bycolumn(axes(Y.c)) do colidx
Expand All @@ -98,6 +104,9 @@ function external_forcing_cache(Y, external_forcing::GCMForcing, params)
setvar!(ᶜu_nudge, "ua", colidx, zc_gcm, zc_forcing)
setvar!(ᶜv_nudge, "va", colidx, zc_gcm, zc_forcing)

set_insolation!(insolation)
set_cos_zenith!(cos_zenith)

@. ᶜinv_τ_wind[colidx] = 1 / (6 * 3600)
@. ᶜinv_τ_scalar[colidx] = compute_gcm_driven_scalar_inv_τ(zc_gcm)
end
Expand Down Expand Up @@ -155,7 +164,7 @@ function external_forcing_tendency!(Yₜ, Y, p, t, ::GCMForcing)

ᶜdTdt_sum = p.scratch.ᶜtemp_scalar
ᶜdqtdt_sum = p.scratch.ᶜtemp_scalar_2
@. ᶜdTdt_sum = ᶜdTdt_hadv + ᶜdTdt_nudging # + ᶜdTdt_rad + ᶜdTdt_fluc remove nudging for now - TODO add back later
@. ᶜdTdt_sum = ᶜdTdt_hadv + ᶜdTdt_nudging # + ᶜdTdt_fluc remove nudging for now - TODO add back later
@. ᶜdqtdt_sum = ᶜdqtdt_hadv + ᶜdqtdt_nudging # + ᶜdqtdt_fluc remove nudging for now - TODO add back later

T_0 = TD.Parameters.T_0(thermo_params)
Expand Down

0 comments on commit 8a6a223

Please sign in to comment.