Skip to content

Commit

Permalink
change water vapor saturation
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-silvestri committed Nov 27, 2024
1 parent d2f3fea commit 552fd53
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,11 @@ end
radiative_properties = local_radiation_properties(i, j, 1, grid, radiation, time)

turbulent_fluxes, surface_temperature = compute_similarity_theory_fluxes(similarity_theory,
dynamic_ocean_state,
dynamic_atmos_state,
dynamic_ocean_state,
dynamic_atmos_state,
prescribed_heat_fluxes,
radiative_properties,
Sₒ,
ocean_density,
ocean_heat_capacity,
atmosphere_boundary_layer_height,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function SimilarityTheoryTurbulentFluxes(grid::AbstractGrid; surface_temperature

fields = (; latent_heat, sensible_heat, water_vapor, x_momentum, y_momentum, T_surface)

surface_temperature_type = regularize_surface_temperature(surface_temperature_type, grid)
surface_temperature_type = regularize_surface_temperature_type(surface_temperature_type, grid)

return SimilarityTheoryTurbulentFluxes(eltype(grid); surface_temperature_type, kw..., fields)
end
Expand Down Expand Up @@ -241,6 +241,7 @@ struct COARELogarithmicSimilarityProfile end
atmos_state,
prescribed_heat_fluxes, # Possibly use in state_differences
radiative_properties,
ocean_salinity,
ocean_density,
ocean_heat_capacity,
atmos_boundary_layer_height,
Expand Down Expand Up @@ -285,6 +286,7 @@ struct COARELogarithmicSimilarityProfile end
similarity_theory,
atmos_state,
surface_state,
ocean_salinity,
ocean_density,
ocean_heat_capacity,
atmos_boundary_layer_height,
Expand Down Expand Up @@ -377,7 +379,10 @@ end
@inline velocity_differences(𝒰₁, 𝒰₀, ::RelativeVelocity) = @inbounds 𝒰₁.u[1] - 𝒰₀.u[1], 𝒰₁.u[2] - 𝒰₀.u[2]
@inline velocity_differences(𝒰₁, 𝒰₀, ::WindVelocity) = @inbounds 𝒰₁.u[1], 𝒰₁.u[2]

@inline function state_differences(ℂ, 𝒰₁, 𝒰₀, θ₀, Σ★, g, ρₒ, cpₒ, surface_temperature_type,
@inline function state_differences(ℂ, 𝒰₁, 𝒰₀, θ₀, S₀, Σ★, g, ρₒ, cpₒ,
water_mole_fraction,
water_vapor_saturation,
surface_temperature_type,
prescribed_heat_fluxes,
radiative_properties,
bulk_velocity)
Expand All @@ -394,17 +399,22 @@ end
cₚ = AtmosphericThermodynamics.cp_m(ℂ, 𝒬₁) # moist heat capacity
ℰv = AtmosphericThermodynamics.latent_heat_vapor(ℂ, 𝒬₁)

θ₀ = retrieve_temperature(surface_temperature_type, θ₀, ℂ, 𝒬₀, ρₐ, cₚ, ℰv, Σ★, ρₒ, cpₒ, g,
prescribed_heat_fluxes,
radiative_properties)
θ₀ = compute_surface_temperature(surface_temperature_type, θ₀, ℂ, 𝒬₀, ρₐ, cₚ, ℰv, Σ★, ρₒ, cpₒ, g,
prescribed_heat_fluxes,
radiative_properties)

θ₁ = AtmosphericThermodynamics.air_temperature(ℂ, 𝒬₁)

# Temperature difference including the ``lapse rate'' `α = g / cₚ`
Δθ = θ₁ - θ₀ + g / cₚ * Δh


T₀ = θ₀ - celsius_to_kelvin
q₁ = AtmosphericThermodynamics.vapor_specific_humidity(ℂ, 𝒬₁)
q₀ = AtmosphericThermodynamics.vapor_specific_humidity(ℂ, 𝒬₀)
q₀ = seawater_saturation_specific_humidity(ℂ, T₀, S₀, 𝒬ₐ,
water_mole_fraction,
water_vapor_saturation,
AtmosphericThermodynamics.Liquid())

Δq = q₁ - q₀

return Δh, Δu, Δv, Δθ, Δq, θ₀
Expand All @@ -416,6 +426,7 @@ end
similarity_theory,
atmos_state,
surface_state,
surface_salinity,
ocean_density,
ocean_heat_capacity,
atmos_boundary_layer_height,
Expand All @@ -429,10 +440,13 @@ end
atmos_state,
surface_state,
surface_temperature,
surface_salinity,
estimated_characteristic_scales,
gravitational_acceleration,
ocean_density,
ocean_heat_capacity,
similarity_theory.water_mole_fraction,
similarity_theory.water_vapor_saturation,
similarity_theory.surface_temperature_type,
prescribed_heat_fluxes,
radiative_properties,
Expand Down
28 changes: 15 additions & 13 deletions src/OceanSeaIceModels/CrossRealmFluxes/surface_temperature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Thermodynamics as AtmosphericThermodynamics
@inline upwelling_radiation(θ₀, r) = r.σ * r.ϵ * θ₀^4

# For any surface temperture type that does not depend on the grid
regularize_surface_temperature(surface_temperature_type, grid) = surface_temperature_type
regularize_surface_temperature_type(surface_temperature_type, grid) = surface_temperature_type

####
#### Prescribed surface temperature (the easiest case)
Expand All @@ -18,7 +18,7 @@ regularize_surface_temperature(surface_temperature_type, grid) = surface_tempera
struct PrescribedSurfaceTemperature end

# Do nothing (just copy the temperature)
@inline retrieve_temperature(::PrescribedSurfaceTemperature, θ₀, args...) = θ₀
@inline compute_surface_temperature(::PrescribedSurfaceTemperature, θ₀, args...) = θ₀

####
#### Diagnostic surface temperature calculated as a flux balance
Expand All @@ -34,20 +34,22 @@ struct DiffusiveFlux{Z, K}
end

# A default constructor for DiagnosticSurfaceTemperature
function DiagnosticSurfaceTemperature(; κ = 0.1)
internal_flux = DiffusiveFlux(; κ)
function DiagnosticSurfaceTemperature(; κ = 0.1, δ = nothing)
internal_flux = DiffusiveFlux(; κ, δ)
return DiagnosticSurfaceTemperature(internal_flux)
end

DiffusiveFlux(; κ = 1e-2) = DiffusiveFlux(nothing, κ)
DiffusiveFlux(; κ = 1e-2, δ = nothing) = DiffusiveFlux(δ, κ)

function DiffusiveFlux(grid; κ = 0.1)
δ = @allowscalar Δzᶜᶜᶜ(1, 1, grid.Nz, grid)
function DiffusiveFlux(grid; κ = 0.1, δ = nothing)
if isnothing(δ)
δ = @allowscalar Δzᶜᶜᶜ(1, 1, grid.Nz, grid)
end
return DiffusiveFlux(δ, κ)
end

regularize_surface_temperature(T::DiagnosticSurfaceTemperature{<:DiffusiveFlux}, grid) =
DiagnosticSurfaceTemperature(DiffusiveFlux(grid; κ = T.internal_flux.κ))
regularize_surface_temperature_type(T::DiagnosticSurfaceTemperature{<:DiffusiveFlux}, grid) =
DiagnosticSurfaceTemperature(DiffusiveFlux(grid; κ = T.internal_flux.κ, δ = T.internal_flux.δ))

# The flux balance could be solved either
#
Expand All @@ -69,10 +71,10 @@ regularize_surface_temperature(T::DiagnosticSurfaceTemperature{<:DiffusiveFlux},

# he flaw here is that the ocean emissivity and albedo are fixed, but they might be a function of the
# surface temperature, so we might need to pass the radiation and the albedo and emissivity as arguments.
@inline function retrieve_temperature(st::DiagnosticSurfaceTemperature, θ₀, ℂ, 𝒬₀,
ρₐ, cₚ, ℰv, Σ★, ρₒ, cpₒ, g,
prescribed_heat_fluxes,
radiation_properties)
@inline function compute_surface_temperature(st::DiagnosticSurfaceTemperature, θ₀, ℂ, 𝒬₀,
ρₐ, cₚ, ℰv, Σ★, ρₒ, cpₒ, g,
prescribed_heat_fluxes,
radiation_properties)

Rd = prescribed_heat_fluxes # net downwelling radiation (positive out of the ocean)

Expand Down

0 comments on commit 552fd53

Please sign in to comment.