Skip to content

Commit

Permalink
Merge pull request #900 from CliMA/js/bonan-artifact
Browse files Browse the repository at this point in the history
use updated Bonan comparison artifact
  • Loading branch information
juliasloan25 authored Nov 1, 2024
2 parents f6da5da + 8c0a334 commit f3e8648
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 39 deletions.
6 changes: 6 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ git-tree-sha1 = "b849eb95c09190095e7bf021494ddeda8858af01"
[[modis_clumping_index.download]]
sha256 = "e4c766a93a673e5dc22540687ef5616416d65bb13a0f4a67789b95d49ccbb158"
url = "https://caltech.box.com/shared/static/ec2y3k5kqpl9wjvtsx3584wgkp5q8dyw.gz"

[bonan_richards_eqn]
git-tree-sha1 = "043f9354b961fd3ef6ac4cf71d0c99930e177a92"
[[bonan_richards_eqn.download]]
sha256 = "50f1739dfd8193742488f249bd1ba8a157dfc7c1d8a27392ba7edbe9b4c0db03"
url = "https://caltech.box.com/shared/static/4jcz9c1lp6rt750q28kx3qvihi8393tv.gz"
11 changes: 7 additions & 4 deletions experiments/standalone/Soil/richards_comparison.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import ClimaUtilities.OutputPathGenerator: generate_output_path
import ClimaLand
import ClimaLand.Parameters as LP

clay_datapath, sand_datapath =
ClimaLand.Artifacts.richards_eqn_bonan_data_path()
bonan_data_folder = ClimaLand.Artifacts.richards_eqn_bonan_data_path()
clay_datapath = joinpath(bonan_data_folder, "bonan_data_clay.txt")
sand_datapath = joinpath(bonan_data_folder, "bonan_data_sand.txt")

context = ClimaComms.context()
device_suffix =
Expand Down Expand Up @@ -138,7 +139,9 @@ end
S_s = FT(1e-3) #inverse meters
vg_n = FT(3.96)
vg_α = FT(2.7) # inverse meters
hcm = vanGenuchten{FT}(; α = vg_α, n = vg_n)
vg_m = FT(1)
S_c = ν + 1
hcm = vanGenuchten(vg_α, vg_n, vg_m, S_c)
θ_r = FT(0.075)
zmax = FT(0)
zmin = FT(-1.5)
Expand Down Expand Up @@ -205,7 +208,7 @@ end
if FT == Float64 && context.device isa ClimaComms.CPUSingleThreaded
N = length(sol.t)
ϑ_l = parent(sol.u[N].soil.ϑ_l)
ds_bonan = readdlm(sand_datapath, ',')
ds_bonan = readdlm(sand_datapath)
bonan_moisture = reverse(ds_bonan[:, 1])
bonan_z = reverse(ds_bonan[:, 2]) ./ 100.0
@test sqrt.(mean((bonan_moisture .- ϑ_l) .^ 2.0)) < FT(1e-3)
Expand Down
28 changes: 3 additions & 25 deletions src/Artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ end
Returns the file path for data created solving Richards equation
with G. Bonan's matlab code, found here:
https://github.com/gbonan/bonanmodeling/tree/master/sp_08_01
This folder contains two data files: bonan_data_clay.txt and
bonan_data_sand.txt.
The data files correspond to the clay and sand data set described in
that code and in G. Bonan's book,
Expand All @@ -162,31 +164,7 @@ Publisher: Cambridge University Press
Print publication year: 2019
"""
function richards_eqn_bonan_data_path(; context = nothing)
dir = joinpath(@__DIR__, "../")
bonan_clay_dataset = ArtifactWrapper(
dir,
"richards_clay_bonan_ref_soln",
ArtifactFile[ArtifactFile(
url = "https://caltech.box.com/shared/static/nk89znth59gcsdb65lnywnzjnuno3h6k.txt",
filename = "clay_bonan_sp801_22323.txt",
),],
)
clay_datapath = joinpath(
get_data_folder(bonan_clay_dataset),
"clay_bonan_sp801_22323.txt",
)

bonan_sand_dataset = ArtifactWrapper(
dir,
"richards_sand_bonan_ref_soln",
ArtifactFile[ArtifactFile(
url = "https://caltech.box.com/shared/static/2vk7bvyjah8xd5b7wxcqy72yfd2myjss.csv",
filename = "sand_bonan_sp801.csv",
),],
)
sand_datapath =
joinpath(get_data_folder(bonan_sand_dataset), "sand_bonan_sp801.csv")
return clay_datapath, sand_datapath
return @clima_artifact("bonan_richards_eqn", context)
end

"""
Expand Down
19 changes: 9 additions & 10 deletions src/standalone/Soil/retention_models.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export AbstractSoilHydrologyClosure, vanGenuchten, BrooksCorey

"""
AbstractSoilHydrologyClosure{FT <: AbstractFloat}
AbstractSoilHydrologyClosure{FT <: AbstractFloat}
The abstract type of soil hydrology closure, of which
vanGenuchten{FT} and BrooksCorey{FT} are the two supported
vanGenuchten{FT} and BrooksCorey{FT} are the two supported
concrete types.
To add a new parameterization, methods are required for:
Expand All @@ -20,7 +20,7 @@ Base.broadcastable(x::AbstractSoilHydrologyClosure) = tuple(x)
"""
vanGenuchten{FT} <: AbstractSoilHydrologyClosure{FT}
The van Genuchten soil hydrology closure, chosen when the
The van Genuchten soil hydrology closure, chosen when the
hydraulic conductivity and matric potential are modeled
using the van Genuchten parameterization (van Genuchten 1980;
see also Table 8.2 of G. Bonan 2019).
Expand All @@ -36,18 +36,17 @@ struct vanGenuchten{FT} <: AbstractSoilHydrologyClosure{FT}
m::FT
"A derived parameter: the critical saturation at which capillary flow no longer replenishes the surface"
S_c::FT
function vanGenuchten{FT}(; α::FT, n::FT) where {FT}
m = 1 - 1 / n
S_c = (1 + ((n - 1) / n)^(1 - 2 * n))^(-m)
return new{FT}(α, n, m, S_c)
end

end
function vanGenuchten{FT}(; α::FT, n::FT) where {FT}
m = 1 - 1 / n
S_c = (1 + ((n - 1) / n)^(1 - 2 * n))^(-m)
return vanGenuchten{FT}(α, n, m, S_c)
end

"""
BrooksCorey{FT} <: AbstractSoilHydrologyClosure{FT}
The Brooks and Corey soil hydrology closure, chosen when the
The Brooks and Corey soil hydrology closure, chosen when the
hydraulic conductivity and matric potential are modeled
using the Brooks and Corey parameterization (Brooks and Corey,
1964, 1966; see also Table 8.2 of G. Bonan 2019).
Expand Down

0 comments on commit f3e8648

Please sign in to comment.