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

Encapsulate surface conditions setting functionality so it can be reused #2855

Merged
merged 2 commits into from
May 21, 2024
Merged
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
13 changes: 8 additions & 5 deletions regression_tests/ref_counter.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
161
162

# 161:
# 162:
# - Changed the order of operations in surface conditions calculation.

# 161:
# - Change domain top to 55 km in simulations with high top

# 160:
# 160:
# - Introduces initial conditions for the baroclinic-wave
# test case in a deep-atmosphere configuration. Modifies
# existing config to use `deep_atmosphere` mode.
#
# existing config to use `deep_atmosphere` mode.

# 159:
# - Changed the boundary condition of edmf updraft properties
# to be dependent on the surface area
Expand Down
36 changes: 24 additions & 12 deletions src/surface_conditions/surface_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,33 +383,45 @@ function atmos_surface_conditions(
(; ustar, L_MO, buoy_flux, ρτxz, ρτyz, shf, lhf, evaporation) =
surface_conditions

surface_normal = C3(unit_basis_vector_data(C3, surface_local_geometry))
energy_flux = (; ρ_flux_h_tot = (shf + lhf) * surface_normal)
# surface normal
z = surface_normal(surface_local_geometry)

energy_flux = (; ρ_flux_h_tot = vector_from_component(shf + lhf, z))

moisture_flux =
atmos.moisture_model isa DryModel ? (;) :
(; ρ_flux_q_tot = evaporation * surface_normal)
(; ρ_flux_q_tot = vector_from_component(evaporation, z))

return (;
ts,
ustar,
obukhov_length = L_MO,
buoyancy_flux = buoy_flux,
# This drops the C3 component of ρ_flux_u, need to add ρ_flux_u₃
ρ_flux_uₕ = surface_normal ⊗ C12(
ρτxz * CT12(
CT1(unit_basis_vector_data(CT1, surface_local_geometry)),
surface_local_geometry,
) +
ρτyz * CT12(
CT2(unit_basis_vector_data(CT2, surface_local_geometry)),
surface_local_geometry,
),
ρ_flux_uₕ = tensor_from_components(
ρτxz,
ρτyz,
surface_local_geometry,
z,
),
energy_flux...,
moisture_flux...,
)
end

surface_normal(L::Geometry.LocalGeometry) = C3(unit_basis_vector_data(C3, L))

vector_from_component(f₁, n₁) = f₁ * n₁
vector_from_component(f₁, L::Geometry.LocalGeometry) =
vector_from_component(f₁, surface_normal(L))

function tensor_from_components(f₁₃, f₂₃, L, n₃ = surface_normal(L))
xz = CT12(CT1(unit_basis_vector_data(CT1, L)), L)
yz = CT12(CT2(unit_basis_vector_data(CT2, L)), L)
f = C12(f₁₃ * xz + f₂₃ * xz, L)
return n₃ ⊗ f
end

"""
surface_conditions_type(moisture_model, FT)

Expand Down
Loading