Skip to content

Commit

Permalink
Fix inference in surface conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Sep 11, 2024
1 parent a22b643 commit 59f91bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
9 changes: 5 additions & 4 deletions src/surface_conditions/surface_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ end
surface_state(sfc_setup_wrapper::SurfaceState, _, _, _) = sfc_setup_wrapper

surface_state(
wrapped_sfc_setup::Function,
wrapped_sfc_setup::F,
sfc_local_geometry_values,
int_z_values,
t,
) = wrapped_sfc_setup(sfc_local_geometry_values.coordinates, int_z_values, t)
) where {F <: Function} =
wrapped_sfc_setup(sfc_local_geometry_values.coordinates, int_z_values, t)

# This is a hack for meeting the August 7th deadline. It is to ensure that the
# coupler will be able to construct an integrator before overwriting its surface
Expand Down Expand Up @@ -149,7 +150,7 @@ Computes the surface conditions, given information about the surface and the
first interior point. Implements the assumptions listed for `SurfaceState`.
"""
function surface_state_to_conditions(
wrapped_sfc_setup,
wrapped_sfc_setup::WSS,
surface_local_geometry,
interior_ts,
interior_u,
Expand All @@ -161,7 +162,7 @@ function surface_state_to_conditions(
atmos,
sfc_prognostic_temp,
t,
)
) where {WSS}
surf_state =
surface_state(wrapped_sfc_setup, surface_local_geometry, interior_z, t)
parameterization = surf_state.parameterization
Expand Down
25 changes: 15 additions & 10 deletions src/surface_conditions/surface_setups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ function (::GABLS)(params)
q_vap = FT(0)
z0 = FT(0.1)
parameterization = MoninObukhov(; z0)
surface_state(surface_coordinates, interior_z, t) = SurfaceState(;
parameterization,
T = 265 - FT(0.25) * FT(t) / 3600,
p,
q_vap,
)
function surface_state(surface_coordinates, interior_z, t)
_FT = eltype(surface_coordinates) # do not capture FT
SurfaceState(;
parameterization,
T = 265 - _FT(0.25) * _FT(t) / 3600,
p,
q_vap,
)
end
return surface_state
end

Expand Down Expand Up @@ -119,7 +122,8 @@ function (::LifeCycleTan2018)(params)
z0 = FT(1e-4)
ustar = FT(0.28)
function surface_state(surface_coordinates, interior_z, t)
weight = FT(0.01) + FT(0.99) * (cos(2 * FT(π) * t / 3600) + 1) / 2
_FT = eltype(surface_coordinates) # do not capture FT
weight = _FT(0.01) + _FT(0.99) * (cos(2 * _FT(π) * t / 3600) + 1) / 2
fluxes =
θAndQFluxes(; θ_flux = θ_flux0 * weight, q_flux = q_flux0 * weight)
parameterization = MoninObukhov(; z0, fluxes, ustar)
Expand Down Expand Up @@ -226,9 +230,10 @@ function (::TRMM_LBA)(params)
z0 = FT(1e-4)
ustar = FT(0.28) # 0.28 is taken from Bomex. TODO: Approximate from LES TKE.
function surface_state(surface_coordinates, interior_z, t)
value = cos(FT(π) / 2 * (1 - FT(t) / (FT(5.25) * 3600)))
shf = 270 * max(0, value)^FT(1.5)
lhf = 554 * max(0, value)^FT(1.3)
_FT = eltype(surface_coordinates) # do not capture FT
value = cos(_FT(π) / 2 * (1 - _FT(t) / (_FT(5.25) * 3600)))
shf = 270 * max(0, value)^_FT(1.5)
lhf = 554 * max(0, value)^_FT(1.3)
fluxes = HeatFluxes(; shf, lhf)
parameterization = MoninObukhov(; z0, fluxes, ustar)
return SurfaceState(; parameterization, T, p, q_vap)
Expand Down

0 comments on commit 59f91bd

Please sign in to comment.