From a0a4f58146d88db8471eea650f9e5fc99eb217d9 Mon Sep 17 00:00:00 2001 From: "Katherine M. Deck" Date: Fri, 13 Sep 2024 11:03:44 -0700 Subject: [PATCH] lai clip --- experiments/long_runs/land.jl | 2 +- experiments/long_runs/land_region.jl | 4 ++-- src/standalone/Vegetation/PlantHydraulics.jl | 6 +++++- test/shared_utilities/domains.jl | 8 +++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/experiments/long_runs/land.jl b/experiments/long_runs/land.jl index d044ff25dc..3ce5f6056f 100644 --- a/experiments/long_runs/land.jl +++ b/experiments/long_runs/land.jl @@ -68,7 +68,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15)) depth = depth, nelements = nelements, npolynomial = 1, - dz_tuple = FT.((10.0, 0.05)),# top layer should ideally be only a few cm! + dz_tuple = FT.((10.0, 0.05)), ) surface_space = domain.space.surface subsurface_space = domain.space.subsurface diff --git a/experiments/long_runs/land_region.jl b/experiments/long_runs/land_region.jl index 92fa8afa87..ca80b58753 100644 --- a/experiments/long_runs/land_region.jl +++ b/experiments/long_runs/land_region.jl @@ -623,7 +623,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (10, 10, 15)) start_date; output_writer = nc_writer, output_vars = :short, - average_period = :monthly, + average_period = :daily, ) diagnostic_handler = @@ -638,7 +638,7 @@ end function setup_and_solve_problem(; greet = false) t0 = 0.0 - tf = 60 * 60.0 * 24 * 365 + tf = 60 * 60.0 * 24 * 30 Δt = 900.0 nelements = (10, 10, 15) if greet diff --git a/src/standalone/Vegetation/PlantHydraulics.jl b/src/standalone/Vegetation/PlantHydraulics.jl index 47ae13a88a..55552f648b 100644 --- a/src/standalone/Vegetation/PlantHydraulics.jl +++ b/src/standalone/Vegetation/PlantHydraulics.jl @@ -304,7 +304,9 @@ ClimaLand.auxiliary_types(model::PlantHydraulicsModel{FT}) where {FT} = ( ClimaLand.auxiliary_domain_names(::PlantHydraulicsModel) = (:surface, :surface, :surface, :surface, :surface) - +function clip(x::FT, threshold::FT) where {FT} + x > threshold ? x : FT(0) +end """ set_canopy_prescribed_field!(component::PlantHydraulics{FT}, p, @@ -322,6 +324,8 @@ function ClimaLand.Canopy.set_canopy_prescribed_field!( ) where {FT} (; LAIfunction, SAI, RAI) = component.parameters.ai_parameterization evaluate!(p.canopy.hydraulics.area_index.leaf, LAIfunction, floor(t)) + p.canopy.hydraulics.area_index.leaf .= + clip.(p.canopy.hydraulics.area_index.leaf, FT(0.05)) @. p.canopy.hydraulics.area_index.stem = SAI @. p.canopy.hydraulics.area_index.root = RAI end diff --git a/test/shared_utilities/domains.jl b/test/shared_utilities/domains.jl index 1b44f5258b..b27f7e1c9c 100644 --- a/test/shared_utilities/domains.jl +++ b/test/shared_utilities/domains.jl @@ -43,7 +43,7 @@ FT = Float32 face_space = obtain_face_space(shell.space.subsurface) z_face = ClimaCore.Fields.coordinate_field(face_space).z @test shell.fields.z_sfc == top_face_to_surface(z_face, shell.space.surface) - Δz_top, Δz_bottom, Δz = get_Δz(shell.fields.z) + Δz_top, Δz_bottom = get_Δz(shell.fields.z) @test shell.fields.Δz_top == Δz_top @test shell.fields.Δz_bottom == Δz_bottom @test shell.radius == radius @@ -109,7 +109,7 @@ FT = Float32 face_space = obtain_face_space(box.space.subsurface) z_face = ClimaCore.Fields.coordinate_field(face_space).z @test box.fields.z_sfc == top_face_to_surface(z_face, box.space.surface) - Δz_top, Δz_bottom, Δz = get_Δz(box.fields.z) + Δz_top, Δz_bottom = get_Δz(box.fields.z) @test box.fields.Δz_top == Δz_top @test box.fields.Δz_bottom == Δz_bottom box_coords = coordinates(box).subsurface @@ -260,9 +260,7 @@ FT = Float32 z_face = ClimaCore.Fields.coordinate_field(face_space).z @test z_column.fields.z_sfc == top_face_to_surface(z_face, z_column.space.surface) - Δz_top, Δz_bottom, Δz = get_Δz(z_column.fields.z) - z = ClimaCore.Fields.coordinate_field(z_column.space.subsurface).z - @test z_column.fields.z == z + Δz_top, Δz_bottom = get_Δz(z_column.fields.z) @test z_column.fields.Δz_top == Δz_top @test z_column.fields.Δz_bottom == Δz_bottom column_coords = coordinates(z_column).subsurface