Skip to content

Commit 04effc8

Browse files
authored
clip VPD (#1242)
1 parent 6671527 commit 04effc8

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ weakdeps = ["CUDA", "MPI"]
455455

456456
[[deps.ClimaCore]]
457457
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LazyBroadcast", "LinearAlgebra", "MultiBroadcastFusion", "NVTX", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "StaticArrays", "Statistics", "UnrolledUtilities"]
458-
git-tree-sha1 = "14d3d5810ce1e3c990450a2ce7abc6a1e162855f"
458+
git-tree-sha1 = "a273452127dbb052f2963e3c1095730a996d49a6"
459459
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
460-
version = "0.14.35"
460+
version = "0.14.36"
461461
weakdeps = ["CUDA", "Krylov"]
462462

463463
[deps.ClimaCore.extensions]
@@ -3064,9 +3064,9 @@ version = "1.0.2"
30643064

30653065
[[deps.Thermodynamics]]
30663066
deps = ["DocStringExtensions", "KernelAbstractions", "Random", "RootSolvers"]
3067-
git-tree-sha1 = "94f0e8e3135840568082e62fb69d31669539e627"
3067+
git-tree-sha1 = "bff801ad0a9bbb5c1bf38ffe89a83907a1b145cd"
30683068
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
3069-
version = "0.12.14"
3069+
version = "0.12.15"
30703070
weakdeps = ["ClimaParams"]
30713071

30723072
[deps.Thermodynamics.extensions]

docs/Manifest-v1.11.toml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ version = "0.6.8"
381381

382382
[[deps.ClimaCore]]
383383
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LazyBroadcast", "LinearAlgebra", "MultiBroadcastFusion", "NVTX", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "StaticArrays", "Statistics", "UnrolledUtilities"]
384-
git-tree-sha1 = "14d3d5810ce1e3c990450a2ce7abc6a1e162855f"
384+
git-tree-sha1 = "a273452127dbb052f2963e3c1095730a996d49a6"
385385
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
386-
version = "0.14.35"
386+
version = "0.14.36"
387387

388388
[deps.ClimaCore.extensions]
389389
ClimaCoreCUDAExt = "CUDA"
@@ -735,9 +735,9 @@ version = "1.15.1"
735735

736736
[[deps.DifferentiationInterface]]
737737
deps = ["ADTypes", "LinearAlgebra"]
738-
git-tree-sha1 = "c092fd1dd0d94e609cd0d29e13897b2825c804bb"
738+
git-tree-sha1 = "f620da805b82bec64ab4d5f881c7592c82dbc08a"
739739
uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
740-
version = "0.7.2"
740+
version = "0.7.3"
741741

742742
[deps.DifferentiationInterface.extensions]
743743
DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore"
@@ -1395,9 +1395,9 @@ weakdeps = ["ClimaParams"]
13951395

13961396
[[deps.IntelOpenMP_jll]]
13971397
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"]
1398-
git-tree-sha1 = "0f14a5456bdc6b9731a5682f439a672750a09e48"
1398+
git-tree-sha1 = "ec1debd61c300961f98064cfb21287613ad7f303"
13991399
uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0"
1400-
version = "2025.0.4+0"
1400+
version = "2025.2.0+0"
14011401

14021402
[[deps.InteractiveUtils]]
14031403
deps = ["Markdown"]
@@ -1547,9 +1547,9 @@ version = "0.2.4"
15471547

15481548
[[deps.KernelAbstractions]]
15491549
deps = ["Adapt", "Atomix", "InteractiveUtils", "MacroTools", "PrecompileTools", "Requires", "StaticArrays", "UUIDs"]
1550-
git-tree-sha1 = "4efa9cec6f308e0f492ea635421638bff81cf6f8"
1550+
git-tree-sha1 = "38a03910123867c11af988e8718d12c98bf6a234"
15511551
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
1552-
version = "0.9.36"
1552+
version = "0.9.37"
15531553
weakdeps = ["EnzymeCore", "LinearAlgebra", "SparseArrays"]
15541554

15551555
[deps.KernelAbstractions.extensions]
@@ -1817,9 +1817,9 @@ version = "1.1.0"
18171817

18181818
[[deps.MKL_jll]]
18191819
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"]
1820-
git-tree-sha1 = "5de60bc6cb3899cd318d80d627560fae2e2d99ae"
1820+
git-tree-sha1 = "282cadc186e7b2ae0eeadbd7a4dffed4196ae2aa"
18211821
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
1822-
version = "2025.0.1+1"
1822+
version = "2025.2.0+0"
18231823

18241824
[[deps.MLCore]]
18251825
deps = ["DataAPI", "SimpleTraits", "Tables"]
@@ -1958,9 +1958,9 @@ version = "0.3.2"
19581958

19591959
[[deps.MethodAnalysis]]
19601960
deps = ["AbstractTrees"]
1961-
git-tree-sha1 = "c2ee9b8f036c951f9ed0a47503a7f7dc0905b256"
1961+
git-tree-sha1 = "39277c4f6a771f45613e552a9ae826be1bf873fe"
19621962
uuid = "85b6ec6f-f7df-4429-9514-a64bcd9ee824"
1963-
version = "0.4.13"
1963+
version = "1.0.0"
19641964

19651965
[[deps.MicroCollections]]
19661966
deps = ["Accessors", "BangBang", "InitialValues"]
@@ -2308,9 +2308,9 @@ version = "1.4.3"
23082308

23092309
[[deps.Plots]]
23102310
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"]
2311-
git-tree-sha1 = "55818b50883d7141bd98cdf5fc2f4ced96ee075f"
2311+
git-tree-sha1 = "3db9167c618b290a05d4345ca70de6d95304a32a"
23122312
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2313-
version = "1.40.16"
2313+
version = "1.40.17"
23142314

23152315
[deps.Plots.extensions]
23162316
FileIOExt = "FileIO"
@@ -2654,9 +2654,9 @@ version = "1.7.0"
26542654

26552655
[[deps.ScopedValues]]
26562656
deps = ["HashArrayMappedTries", "Logging"]
2657-
git-tree-sha1 = "1147f140b4c8ddab224c94efa9569fc23d63ab44"
2657+
git-tree-sha1 = "7f44eef6b1d284465fafc66baf4d9bdcc239a15b"
26582658
uuid = "7e506255-f358-4e82-b7e4-beb19740aa63"
2659-
version = "1.3.0"
2659+
version = "1.4.0"
26602660

26612661
[[deps.Scratch]]
26622662
deps = ["Dates"]
@@ -2793,9 +2793,9 @@ weakdeps = ["OffsetArrays", "StaticArrays"]
27932793

27942794
[[deps.StaticArrays]]
27952795
deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"]
2796-
git-tree-sha1 = "0feb6b9031bd5c51f9072393eb5ab3efd31bf9e4"
2796+
git-tree-sha1 = "cbea8a6bd7bed51b1619658dec70035e07b8502f"
27972797
uuid = "90137ffa-7385-5640-81b9-e52037218182"
2798-
version = "1.9.13"
2798+
version = "1.9.14"
27992799
weakdeps = ["ChainRulesCore", "Statistics"]
28002800

28012801
[deps.StaticArrays.extensions]
@@ -2897,9 +2897,9 @@ weakdeps = ["ClimaParams"]
28972897

28982898
[[deps.SymbolicIndexingInterface]]
28992899
deps = ["Accessors", "ArrayInterface", "PrettyTables", "RuntimeGeneratedFunctions", "StaticArraysCore"]
2900-
git-tree-sha1 = "658f6d01bfe68d6bf47915bf5d868228138c7d71"
2900+
git-tree-sha1 = "59ca6eddaaa9849e7de9fd1153b6faf0b1db7b80"
29012901
uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
2902-
version = "0.3.41"
2902+
version = "0.3.42"
29032903

29042904
[[deps.TOML]]
29052905
deps = ["Dates"]
@@ -2960,9 +2960,9 @@ version = "1.11.0"
29602960

29612961
[[deps.Thermodynamics]]
29622962
deps = ["DocStringExtensions", "KernelAbstractions", "Random", "RootSolvers"]
2963-
git-tree-sha1 = "94f0e8e3135840568082e62fb69d31669539e627"
2963+
git-tree-sha1 = "bff801ad0a9bbb5c1bf38ffe89a83907a1b145cd"
29642964
uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
2965-
version = "0.12.14"
2965+
version = "0.12.15"
29662966
weakdeps = ["ClimaParams"]
29672967

29682968
[deps.Thermodynamics.extensions]

src/standalone/Vegetation/canopy_parameterizations.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,13 @@ where `VPD` is the vapor pressure deficit in the atmosphere
946946
(Pa), and `g_1` is a constant with units of `sqrt(Pa)`.
947947
948948
`thermo_params` is the Thermodynamics.jl parameter set.
949+
950+
Note that in supersaturated conditions the vapor pressure deficit will be negative,
951+
which leads to an imaginary Medlyn term `m`. Clipping to zero solves this, but this leads
952+
to division by zero, so we regularize the division by adding a small quantity.
953+
954+
An alternative to consider in the future is to compute the inverse of this quantity
955+
and stomatal resistance instead of conductance.
949956
"""
950957
function medlyn_term(
951958
g1::FT,
@@ -954,8 +961,11 @@ function medlyn_term(
954961
q_air::FT,
955962
thermo_params,
956963
) where {FT}
957-
VPD = ClimaLand.vapor_pressure_deficit(T_air, P_air, q_air, thermo_params)
958-
return 1 + g1 / sqrt(VPD)
964+
VPD = max(
965+
ClimaLand.vapor_pressure_deficit(T_air, P_air, q_air, thermo_params),
966+
FT(0),
967+
) # clip negative values of VPD to zero
968+
return 1 + g1 / sqrt(VPD + sqrt(eps(FT))) # regularize values of VPD which are smaller than sqrt(eps(FT))
959969
end
960970

961971

test/standalone/Vegetation/test_bigleaf_parameterizations.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ for FT in (Float32, Float64)
7575
T = FT(290) # K
7676
P = FT(101250) #Pa
7777
q = FT(0.02)
78-
VPD = ClimaLand.vapor_pressure_deficit(T, P, q, thermo_params)#Pa
78+
VPD =
79+
max(ClimaLand.vapor_pressure_deficit(T, P, q, thermo_params), FT(0))#Pa
7980
p_l = FT(-2e6) # Pa
8081
ca = FT(4.11e-4) # mol/mol
8182
R = FT(LP.gas_constant(earth_param_set))
@@ -140,7 +141,7 @@ for FT in (Float32, Float64)
140141

141142
m_t = medlyn_term(stomatal_g_params.g1, T, P, q, thermo_params)
142143

143-
@test m_t == 1 + stomatal_g_params.g1 / sqrt(VPD)
144+
@test m_t == 1 + stomatal_g_params.g1 / sqrt(sqrt(eps(FT)) + VPD)
144145
ci = intercellular_co2(ca, Γstar, m_t)
145146
@test ci == ca * (1 - 1 / m_t)
146147
@test intercellular_co2(ca, FT(1), m_t) == FT(1)

0 commit comments

Comments
 (0)