From 32312bdb34d2c24c396c072e7c2fe373da25466f Mon Sep 17 00:00:00 2001 From: AlexisRenchon Date: Thu, 3 Oct 2024 09:38:01 -0700 Subject: [PATCH] add diagnostics for et, er, lwo, swo --- experiments/long_runs/land.jl | 2 +- src/diagnostics/default_diagnostics.jl | 8 +++- src/diagnostics/define_diagnostics.jl | 58 ++++++++++++++++++++++++- src/diagnostics/land_compute_methods.jl | 45 +++++++++++++++++++ 4 files changed, 109 insertions(+), 4 deletions(-) diff --git a/experiments/long_runs/land.jl b/experiments/long_runs/land.jl index 71310a1643..2374ef92dc 100644 --- a/experiments/long_runs/land.jl +++ b/experiments/long_runs/land.jl @@ -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) diff --git a/src/diagnostics/default_diagnostics.jl b/src/diagnostics/default_diagnostics.jl index c51a90d64e..365a675e49 100644 --- a/src/diagnostics/default_diagnostics.jl +++ b/src/diagnostics/default_diagnostics.jl @@ -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 diff --git a/src/diagnostics/define_diagnostics.jl b/src/diagnostics/define_diagnostics.jl index d93087247b..4eec0f2108 100644 --- a/src/diagnostics/define_diagnostics.jl +++ b/src/diagnostics/define_diagnostics.jl @@ -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", @@ -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", @@ -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 diff --git a/src/diagnostics/land_compute_methods.jl b/src/diagnostics/land_compute_methods.jl index 41d9e33eb7..117cabf472 100644 --- a/src/diagnostics/land_compute_methods.jl +++ b/src/diagnostics/land_compute_methods.jl @@ -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