Skip to content

Commit

Permalink
Prescribed surface heat and evaporative fluxes
Browse files Browse the repository at this point in the history
  • Loading branch information
milankl committed Jan 14, 2025
1 parent 98614a1 commit 85aba87
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
48 changes: 45 additions & 3 deletions src/physics/surface_fluxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ abstract type AbstractSurfaceWind <: AbstractParameterization end
abstract type AbstractSurfaceHeatFlux <: AbstractParameterization end
abstract type AbstractSurfaceEvaporation <: AbstractParameterization end

# skip the diagnostic variables if not defined (needed to read in prescribed fluxes)
surface_heat_flux!(c::ColumnVariables, f::AbstractSurfaceHeatFlux,
d::DiagnosticVariables, m::PrimitiveEquation) = surface_heat_flux!(c, f, m)

surface_evaporation!(c::ColumnVariables, f::AbstractSurfaceEvaporation,
d::DiagnosticVariables, m::PrimitiveEquation) = surface_heat_flux!(c, f, m)

# defines the order in which they are called und unpacks to dispatch
function surface_fluxes!(column::ColumnVariables, model::PrimitiveEquation)
function surface_fluxes!(
column::ColumnVariables,
diagn::DiagnosticVariables,
model::PrimitiveEquation)

# get temperature, humidity and density at surface
surface_thermodynamics!(column, model.surface_thermodynamics, model)
Expand All @@ -13,8 +23,8 @@ function surface_fluxes!(column::ColumnVariables, model::PrimitiveEquation)
surface_wind_stress!(column, model.surface_wind, model)

# now call other heat (wet and dry) and humidity fluxes (PrimitiveWet only)
surface_heat_flux!(column, model.surface_heat_flux, model)
model isa PrimitiveWet && surface_evaporation!(column, model.surface_evaporation, model)
surface_heat_flux!(column, model.surface_heat_flux, diagn, model)
model isa PrimitiveWet && surface_evaporation!(column, model.surface_evaporation, diagn, model)
end

## SURFACE THERMODYNAMICS
Expand Down Expand Up @@ -168,6 +178,22 @@ function surface_heat_flux!(
return nothing
end

export PrescribedSurfaceHeatFlux
struct PrescribedSurfaceHeatFlux <: AbstractSurfaceHeatFlux end
PrescribedSurfaceHeatFlux(::SpectralGrid) = PrescribedSurfaceHeatFlux()
initialize!(::PrescribedSurfaceHeatFlux, ::PrimitiveEquation) = nothing
function surface_heat_flux!(
column::ColumnVariables,
::PrescribedSurfaceHeatFlux,
diagn::DiagnosticVariables,
model::PrimitiveEquation)

# read in a prescribed flux
flux = diagn.physics.sensible_heat_flux[column.ij]
column.flux_temp_upward[end] += flux
column.sensible_heat_flux = flux
end

## SURFACE EVAPORATION
export NoSurfaceEvaporation
struct NoSurfaceEvaporation <: AbstractSurfaceEvaporation end
Expand Down Expand Up @@ -234,4 +260,20 @@ function surface_evaporation!( column::ColumnVariables,
column.evaporative_flux = flux

return nothing
end

export PrescribedSurfaceEvaporation
struct PrescribedSurfaceEvaporation <: AbstractSurfaceEvaporation end
PrescribedSurfaceEvaporation(::SpectralGrid) = PrescribedSurfaceEvaporation()
initialize!(::PrescribedSurfaceEvaporation, ::PrimitiveEquation) = nothing
function surface_evaporation!(
column::ColumnVariables,
::PrescribedSurfaceEvaporation,
diagn::DiagnosticVariables,
model::PrimitiveEquation)

# read in a prescribed flux
flux = diagn.physics.evaporative_flux[column.ij]
column.flux_humid_upward[end] += flux
column.evaporative_flux = flux
end
5 changes: 3 additions & 2 deletions src/physics/tendencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function parameterization_tendencies!(

# calculate parameterizations
perturb_parameterization_inputs!(column, model) # possibly perturb inputs to parameterizations?
parameterization_tendencies!(column, model) # execute all parameterizations
parameterization_tendencies!(column, diagn, model) # execute all parameterizations
perturb_parameterization_tendencies!(column, model) # possibly perturb tendencies from parameterizations

# write tendencies from parametrizations back into horizontal fields
Expand All @@ -39,6 +39,7 @@ Calls for `column` one physics parameterization after another
and convert fluxes to tendencies."""
function parameterization_tendencies!(
column::ColumnVariables,
diagn::DiagnosticVariables,
model::PrimitiveEquation,
)
get_thermodynamics!(column, model)
Expand All @@ -50,7 +51,7 @@ function parameterization_tendencies!(
optical_depth!(column, model)
shortwave_radiation!(column, model)
longwave_radiation!(column, model)
surface_fluxes!(column, model)
surface_fluxes!(column, diagn, model) # pass on diagnostic variables for prescribed fluxes

# sum fluxes on half levels up and down for every layer
fluxes_to_tendencies!(column, model.geometry, model.planet, model.atmosphere)
Expand Down

0 comments on commit 85aba87

Please sign in to comment.