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 d73fd6a
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 4 deletions.
2 changes: 1 addition & 1 deletion experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ setup_and_solve_problem(; greet = true);
# read in diagnostics and make some plots!
#### ClimaAnalysis ####
simdir = ClimaAnalysis.SimDir(outdir)
short_names = ["gpp", "ct", "lai", "swc", "si"]
short_names = ["gpp", "ct", "lai", "swc", "si", "swo", "lwo", "et", "er", "sr"]
for short_name in short_names
var = get(simdir; short_name)
times = ClimaAnalysis.times(var)
Expand Down
8 changes: 7 additions & 1 deletion src/diagnostics/default_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,15 @@ function default_diagnostics(
# "pwc", # return a Tuple
"si",
"sie",
"swo",
"lwo",
"er",
"et",
"sr",
]
elseif output_vars == :short
soilcanopy_diagnostics = ["gpp", "ct", "lai", "swc", "si"]
soilcanopy_diagnostics =
["gpp", "ct", "lai", "swc", "si", "swo", "lwo", "et", "er", "sr"]
end

if average_period == :hourly
Expand Down
58 changes: 56 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,60 @@ 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 CO2 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),
)

# Surface runoff
add_diagnostic_variable!(
short_name = "sr",
long_name = "Surface Runoff",
standard_name = "surface runoff",
units = "m s^-1",
comments = "Water runoff at the surface, this is the water flowing horizontally above the ground.",
compute! = (out, Y, p, t) ->
compute_surface_runoff!(out, Y, p, t, land_model),
)

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

# Canopy temperature
Expand Down
45 changes: 45 additions & 0 deletions src/diagnostics/land_compute_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,51 @@ 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 "surface_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) .+ # [3.664 kg CO2/ kg C] x [10^3 g CO2/ kg CO2] x [1 mol CO2/44.009 g CO2] = 83.26 mol CO2/kg C
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 Down

0 comments on commit d73fd6a

Please sign in to comment.