Skip to content

Commit

Permalink
set sw flux to zero when zenith angle is large
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Feb 12, 2024
1 parent ed67148 commit e37be10
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dt_save_state_to_disk: "100days"
initial_condition: "IsothermalProfile"
hyperdiff: "false"
z_elem: 70
dt: "3hours"
dt: "1hours"
idealized_h2o: true
t_end: "654days"
dz_top: 10000.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"
4 changes: 3 additions & 1 deletion src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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)
min_cos_zenith_angle = FT(cos(Float64(π) / 2 - eps(Float64)))
irradiance = FT(CAP.tot_solar_irrad(params))
au = FT(CAP.astro_unit(params))
date0 = DateTime("2000-01-01T11:58:56.816")
Expand Down Expand Up @@ -132,7 +133,8 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)
bottom_coords.long,
bottom_coords.lat,
) # the tuple is (zenith angle, azimuthal angle, earth-sun distance)
@. cos_zenith = cos(min(first(insolation_tuple), max_zenith_angle))
@. cos_zenith =
max(cos(first(insolation_tuple)), min_cos_zenith_angle)
@. weighted_irradiance =
irradiance * (au / last(insolation_tuple))^2
else
Expand Down
27 changes: 26 additions & 1 deletion src/parameterized_tendencies/radiation/RRTMGPInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1211,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

0 comments on commit e37be10

Please sign in to comment.