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

Zs/ft radiation #2666

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ hyperdiff: "false"
z_elem: 70
dt: "3hours"
idealized_h2o: true
t_end: "654days"
t_end: "100days"
dz_top: 10000.0
idealized_clouds: true
dz_bottom: 100.0
Expand All @@ -14,3 +14,5 @@ z_max: 70000.0
dt_save_to_sol: "30hours"
job_id: "single_column_radiative_equilibrium_allsky_idealized_clouds"
rad: "allskywithclear"
netcdf_interpolation_num_points: [2, 2, 70]
FLOAT_TYPE: "Float32"
2 changes: 1 addition & 1 deletion src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)

if !idealized_insolation
current_datetime = p.start_date + Dates.Second(round(Int, t)) # current time
max_zenith_angle = FT(π) / 2 - eps(FT)
max_zenith_angle = FT(π) / 2 - 1000*eps(FT)
irradiance = FT(CAP.tot_solar_irrad(params))
au = FT(CAP.astro_unit(params))
date0 = DateTime("2000-01-01T11:58:56.816")
Expand Down
44 changes: 33 additions & 11 deletions src/parameterized_tendencies/radiation/RRTMGPInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ function extrap!(::BestFit, p, T, z, p⁺, T⁺, z⁺, p⁺⁺, T⁺⁺, z⁺⁺
@. p = best_fit_p(T, z, p⁺, T⁺, z⁺, p⁺⁺, T⁺⁺, z⁺⁺)
end
function extrap!(::UseSurfaceTempAtBottom, p, T, p⁺, T⁺, p⁺⁺, T⁺⁺, Tₛ, params)
FT = eltype(p)
cₚ = FT(RRTMGP.Parameters.cp_d(params))
R = FT(RRTMGP.Parameters.R_d(params))
cₚ = RRTMGP.Parameters.cp_d(params)
R = RRTMGP.Parameters.R_d(params)
@. T = Tₛ
@. p = p⁺ * (T / T⁺)^(cₚ / R)
end
Expand All @@ -305,10 +304,9 @@ function extrap!(
Tₛ,
params,
)
FT = eltype(p)
g = FT(RRTMGP.Parameters.grav(params))
cₚ = FT(RRTMGP.Parameters.cp_d(params))
R = FT(RRTMGP.Parameters.R_d(params))
g = RRTMGP.Parameters.grav(params)
cₚ = RRTMGP.Parameters.cp_d(params)
R = RRTMGP.Parameters.R_d(params)
@. T = T⁺ + g / cₚ * (z⁺ - z)
@. p = p⁺ * (T / T⁺)^(cₚ / R)
end
Expand Down Expand Up @@ -382,7 +380,6 @@ array.
- `lookup_tables/cloudysky_lw.nc`
- `lookup_tables/clearsky_sw.nc`
- `lookup_tables/cloudysky_sw.nc`
- `FT`: floating-point number type (performance with `Float32` is questionable)
- `DA`: array type (defaults to `CuArray` when a compatible GPU is available)

# Keyword Arguments
Expand Down Expand Up @@ -482,7 +479,6 @@ array.
function RRTMGPModel(
params::RRTMGP.Parameters.ARP,
data_loader::Function,
::Type{FT},
context;
ncol::Int,
domain_nlay::Int,
Expand All @@ -498,9 +494,10 @@ function RRTMGPModel(
add_isothermal_boundary_layer::Bool = false,
max_threads::Int = 256,
kwargs...,
) where {FT <: AbstractFloat}
)
device = ClimaComms.device(context)
DA = ClimaComms.array_type(device)
FT = typeof(params.grav)
# turn kwargs into a Dict, so that values can be dynamically popped from it
dict = Dict(kwargs)

Expand Down Expand Up @@ -1214,11 +1211,36 @@ end

# TODO: Change these methods back to using face_sw_flux/face_clear_sw_flux
# instead of face_sw_flux_up - face_sw_flux_dn
update_net_fluxes!(radiation_mode, model) =
function update_net_fluxes!(radiation_mode, model)
parent(model.face_sw_flux_up) .=
ifelse.(
parent(model.cos_zenith) .> Float32(7.54979f-8),
parent(model.face_sw_flux_up),
0,
)
parent(model.face_sw_flux_dn) .=
ifelse.(
parent(model.cos_zenith) .> Float32(7.54979f-8),
parent(model.face_sw_flux_dn),
0,
)
parent(model.face_flux) .=
parent(model.face_lw_flux) .+ parent(model.face_sw_flux_up) .-
parent(model.face_sw_flux_dn)
end
function update_net_fluxes!(::AllSkyRadiationWithClearSkyDiagnostics, model)
# parent(model.face_sw_flux_up) .=
# ifelse.(
# parent(model.cos_zenith) .> Float32(7.54979f-8),
# parent(model.face_sw_flux_up),
# 0,
# )
# parent(model.face_sw_flux_dn) .=
# ifelse.(
# parent(model.cos_zenith) .> Float32(7.54979f-8),
# parent(model.face_sw_flux_dn),
# 0,
# )
parent(model.face_clear_flux) .=
parent(model.face_clear_lw_flux) .+
parent(model.face_clear_sw_flux_up) .-
Expand Down
2 changes: 0 additions & 2 deletions src/parameterized_tendencies/radiation/radiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ function radiation_model_cache(
radiation_model = RRTMGPI.RRTMGPModel(
rrtmgp_params,
data_loader,
# TODO: pass FT through so that it can be controlled at the top-level
Float64,
context;
ncol = length(Spaces.all_nodes(axes(Spaces.level(Y.c, 1)))),
domain_nlay = Spaces.nlevels(axes(Y.c)),
Expand Down
Loading