From cb9aaa9a6f33d731ca90d4ef36ede578b319cc2b Mon Sep 17 00:00:00 2001 From: Gabriele Bozzola Date: Tue, 2 Jul 2024 10:14:43 -0700 Subject: [PATCH] Fix allocation in canopy_energy --- src/standalone/Vegetation/canopy_energy.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/standalone/Vegetation/canopy_energy.jl b/src/standalone/Vegetation/canopy_energy.jl index 94dc934d10..c3950225c7 100644 --- a/src/standalone/Vegetation/canopy_energy.jl +++ b/src/standalone/Vegetation/canopy_energy.jl @@ -103,16 +103,19 @@ function make_compute_exp_tendency( # area index on the LHF, as ac_canopy [J/m^2/K] # is per unit area plant. - net_energy_flux = @. -p.canopy.radiative_transfer.LW_n - - p.canopy.radiative_transfer.SW_n + - p.canopy.energy.shf + - p.canopy.energy.lhf - p.canopy.energy.fa_energy_roots - # To prevent dividing by zero, change AI" to # "max(AI, eps(FT))" c_per_ground_area = @. ac_canopy * max(area_index.leaf + area_index.stem, eps(FT)) - @. dY.canopy.energy.T = -net_energy_flux / c_per_ground_area + + # d(energy.T) = - net_energy_flux / specific_heat_capacity + @. dY.canopy.energy.T = + -( + -p.canopy.radiative_transfer.LW_n - + p.canopy.radiative_transfer.SW_n + + p.canopy.energy.shf + + p.canopy.energy.lhf - p.canopy.energy.fa_energy_roots + ) / c_per_ground_area end return compute_exp_tendency! end