Skip to content

Commit

Permalink
add diagnostics for et, er, lwo, swo
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisRenchon committed Oct 3, 2024
1 parent 5fe41f6 commit d93ff3e
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/diagnostics/default_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ function default_diagnostics(
# "pwc", # return a Tuple
"si",
"sie",
"swo",
"lwo",
]
elseif output_vars == :short
soilcanopy_diagnostics = ["gpp", "ct", "lai", "swc", "si"]
soilcanopy_diagnostics = ["gpp", "ct", "lai", "swc", "si", "swo", "lwo", "et", "er"]
end

if average_period == :hourly
Expand Down
49 changes: 47 additions & 2 deletions src/diagnostics/define_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function define_diagnostics!(land_model)

## Canopy Module ##

### Canopy - Solar Induced Fluorescence
### Canopy - Solar Induced Fluorescence
# Solar Induced Fluorescence
add_diagnostic_variable!(
short_name = "sif",
Expand Down Expand Up @@ -256,7 +256,7 @@ function define_diagnostics!(land_model)
)
=#

# Root flux per ground area
# Root flux per ground area
add_diagnostic_variable!(
short_name = "far",
long_name = "Root flux per ground area",
Expand Down Expand Up @@ -726,6 +726,51 @@ function define_diagnostics!(land_model)
compute_soilco2_source_microbe!(out, Y, p, t, land_model),
)

## Other ##
# Longwave out
add_diagnostic_variable!(
short_name = "lwo",
long_name = "Longwave Radiation Out",
standard_name = "longwave radiation out",
units = "W m^-2",
comments = "Longwave radiation going out of the land surface.",
compute! = (out, Y, p, t) ->
compute_lw_out!(out, Y, p, t, land_model),
)

# Shortwave out
add_diagnostic_variable!(
short_name = "swo",
long_name = "Shortwave Radiation Out",
standard_name = "shortwave radiation out",
units = "W m^-2",
comments = "Shortwave radiation going out of the land surface.",
compute! = (out, Y, p, t) ->
compute_sw_out!(out, Y, p, t, land_model),
)

# Evapotranspiration
add_diagnostic_variable!(
short_name = "et",
long_name = "Evapotranspiration",
standard_name = "evapotranspiration",
units = "kg m^-2 s^-1",
comments = "Total flux of water mass out of the surface.",
compute! = (out, Y, p, t) ->
compute_evapotranspiration!(out, Y, p, t, land_model),
)

# Ecosystem respiration
add_diagnostic_variable!(
short_name = "er",
long_name = "Ecosystem Respiration",
standard_name = "ecosystem respiration",
units = "mol m^-2 s^-1",
comments = "Total respiration flux out of the surface.",
compute! = (out, Y, p, t) ->
compute_total_respiration!(out, Y, p, t, land_model),
)

## Stored in Y (prognostic or state variables) ##

# Canopy temperature
Expand Down
35 changes: 35 additions & 0 deletions src/diagnostics/land_compute_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,40 @@ end # Convert from kg C to mol CO2.
@diagnostic_compute "soilco2_diffusivity" SoilCanopyModel p.soilco2.D
@diagnostic_compute "soilco2_source_microbe" SoilCanopyModel p.soilco2.Sm

## Other ##

@diagnostic_compute "lw_out" SoilCanopyModel p.LW_out
@diagnostic_compute "sw_out" SoilCanopyModel p.SW_out
@diagnostic_compute "runoff" SoilCanopyModel p.soil.R_s

function compute_evapotranspiration!(
out,
Y,
p,
t,
land_model::SoilCanopyModel{FT},
) where {FT}
if isnothing(out)
return (p.soil.turbulent_fluxes.vapor_flux_liq .+ p.soil.turbulent_fluxes.vapor_flux_ice .+ p.canopy.conductance.transpiration) .* 1000 # density of liquid water (1000kg/m^3)
else
out .= (p.soil.turbulent_fluxes.vapor_flux_liq .+ p.soil.turbulent_fluxes.vapor_flux_ice .+ p.canopy.conductance.transpiration) .* 1000 # density of liquid water (1000kg/m^3)
end
end

function compute_total_respiration!(
out,
Y,
p,
t,
land_model::SoilCanopyModel{FT},
) where {FT}
if isnothing(out)
return p.soilco2.top_bc .* FT(83.26) .+ p.canopy.autotrophic_respiration.Ra
else
out .= p.soilco2.top_bc .* FT(83.26) .+ p.canopy.autotrophic_respiration.Ra
end
end

# variables stored in Y (prognostic or state variables)

@diagnostic_compute "canopy_temperature" SoilCanopyModel Y.canopy.energy.T
Expand All @@ -173,3 +207,4 @@ end # Convert from kg C to mol CO2.
@diagnostic_compute "soil_ice_content" EnergyHydrology Y.soil.θ_i
@diagnostic_compute "soil_internal_energy" EnergyHydrology Y.soil.ρe_int
@diagnostic_compute "soil_temperature" EnergyHydrology p.soil.T

0 comments on commit d93ff3e

Please sign in to comment.