From 35279cc5a988090c4053a8cab60530a24b022f2c Mon Sep 17 00:00:00 2001 From: kmdeck Date: Wed, 13 Nov 2024 10:44:49 -0800 Subject: [PATCH] fixing bugs --- src/diagnostics/land_compute_methods.jl | 40 ++++++++++++++++----- src/integrated/land.jl | 47 ++++++++++--------------- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/diagnostics/land_compute_methods.jl b/src/diagnostics/land_compute_methods.jl index 8a5db9220f..793b2ed3dc 100644 --- a/src/diagnostics/land_compute_methods.jl +++ b/src/diagnostics/land_compute_methods.jl @@ -111,14 +111,38 @@ end @diagnostic_compute "vcmax25" Union{SoilCanopyModel, LandModel} p.canopy.photosynthesis.Vcmax25 # Canopy - Radiative Transfer -@diagnostic_compute "near_infrared_radiation_down" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.nir_d -@diagnostic_compute "near_infrared_radiation_absorbed" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.nir.abs -@diagnostic_compute "near_infrared_radiation_reflected" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.nir.refl -@diagnostic_compute "near_infrared_radiation_transmitted" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.nir.trans -@diagnostic_compute "photosynthetically_active_radiation_down" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.par_d -@diagnostic_compute "photosynthetically_active_radiation_absorbed" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.par.abs -@diagnostic_compute "photosynthetically_active_radiation_reflected" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.par.refl -@diagnostic_compute "photosynthetically_active_radiation_transmitted" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.par.trans +@diagnostic_compute "near_infrared_radiation_down" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.nir_d +@diagnostic_compute "near_infrared_radiation_absorbed" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.nir.abs +@diagnostic_compute "near_infrared_radiation_reflected" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.nir.refl +@diagnostic_compute "near_infrared_radiation_transmitted" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.nir.trans +@diagnostic_compute "photosynthetically_active_radiation_down" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.par_d +@diagnostic_compute "photosynthetically_active_radiation_absorbed" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.par.abs +@diagnostic_compute "photosynthetically_active_radiation_reflected" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.par.refl +@diagnostic_compute "photosynthetically_active_radiation_transmitted" Union{ + SoilCanopyModel, + LandModel, +} p.canopy.radiative_transfer.par.trans @diagnostic_compute "radiation_longwave_net" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.LW_n @diagnostic_compute "radiation_shortwave_net" Union{SoilCanopyModel, LandModel} p.canopy.radiative_transfer.SW_n diff --git a/src/integrated/land.jl b/src/integrated/land.jl index 24796e7879..9734c5b59b 100644 --- a/src/integrated/land.jl +++ b/src/integrated/land.jl @@ -385,12 +385,7 @@ function lsm_radiant_energy_fluxes!( _σ = LP.Stefan(earth_param_set) LW_d = p.drivers.LW_d SW_d = p.drivers.SW_d - c = LP.light_speed(earth_param_set) - h = LP.planck_constant(earth_param_set) - N_a = LP.avogadro_constant(earth_param_set) - (; λ_γ_PAR, λ_γ_NIR) = canopy_radiation.parameters - energy_per_photon_PAR = h * c / λ_γ_PAR - energy_per_photon_NIR = h * c / λ_γ_NIR + T_canopy = ClimaLand.Canopy.canopy_temperature(canopy.energy, canopy, Y, p, t) @@ -398,10 +393,12 @@ function lsm_radiant_energy_fluxes!( α_soil_NIR = p.soil.NIR_albedo ϵ_soil = land.soil.parameters.emissivity T_soil = ClimaLand.Domains.top_center_to_surface(p.soil.T) + α_snow_NIR = land.snow.parameters.α_snow α_snow_PAR = land.snow.parameters.α_snow ϵ_snow = land.snow.parameters.ϵ_snow T_snow = p.snow.T_sfc + # in W/m^2 LW_d_canopy = p.scratch1 LW_u_soil = p.scratch2 @@ -412,40 +409,32 @@ function lsm_radiant_energy_fluxes!( R_net_snow = p.snow.R_n LW_u = p.LW_u SW_u = p.SW_u + par_d = p.canopy.radiative_transfer.par_d + nir_d = p.canopy.radiative_transfer.nir_d + f_abs_par = p.canopy.radiative_transfer.par.abs + f_abs_nir = p.canopy.radiative_transfer.nir.abs + f_refl_par = p.canopy.radiative_transfer.par.refl + f_refl_nir = p.canopy.radiative_transfer.nir.refl + f_trans_par = p.canopy.radiative_transfer.par.trans + f_trans_nir = p.canopy.radiative_transfer.nir.trans # in total: d - u = CANOPY_ABS + (1-α_ground)*CANOPY_TRANS # SW_u = reflected par + reflected nir - @. SW_u = - energy_per_photon_NIR * N_a * p.canopy.radiative_transfer.nir.refl + - energy_per_photon_PAR * N_a * p.canopy.radiative_transfer.par.refl + @. SW_u = par_d * f_refl_par + f_refl_nir * nir_d # net canopy - @. SW_net_canopy = - energy_per_photon_NIR * N_a * p.canopy.radiative_transfer.nir.abs + - energy_per_photon_PAR * N_a * p.canopy.radiative_transfer.par.abs - + @. SW_net_canopy = f_abs_par * par_d + f_abs_nir * nir_d # net radiative flux for soil = -((1-α)*trans for par and nir) @. R_net_soil .= -( - energy_per_photon_NIR * - N_a * - p.canopy.radiative_transfer.nir.trans * - (1 - α_soil_NIR) + - energy_per_photon_PAR * - N_a * - p.canopy.radiative_transfer.par.trans * - (1 - α_soil_PAR) + f_trans_nir * nir_d * (1 - α_soil_NIR) + + f_trans_par * par_d * (1 - α_soil_PAR) ) @. R_net_snow .= -( - energy_per_photon_NIR * - N_a * - p.canopy.radiative_transfer.nir.trans * - (1 - α_snow_NIR) + - energy_per_photon_PAR * - N_a * - p.canopy.radiative_transfer.par.trans * - (1 - α_snow_PAR) + f_trans_nir * nir_d * (1 - α_snow_NIR) + + f_trans_par * par_d * (1 - α_snow_PAR) ) + ϵ_canopy = p.canopy.radiative_transfer.ϵ # this takes into account LAI/SAI # Working through the math, this satisfies: LW_d - LW_u = LW_c + LW_soil + LW_snow