Skip to content

Allow n-band radiative transfer #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b70965f
WIP 2/2
Espeer5 Feb 3, 2025
f705f0a
ClimaLand compiles
Espeer5 Feb 5, 2025
fda77c8
Resolve overwrite during precompile
Espeer5 Feb 5, 2025
3510f34
resolve createParametersExt
Espeer5 Feb 5, 2025
5053cc9
Repair unused typevar in ext
Espeer5 Feb 5, 2025
2465383
Static tuple allocations
Espeer5 Feb 10, 2025
21370d5
Repair spectral type sharing
Espeer5 Feb 10, 2025
70fcd09
Fixup climate drivers test
Espeer5 Feb 10, 2025
c082e75
Fixup EnergyHydrology broadcasting
Espeer5 Feb 10, 2025
b30d052
Repair explicit EnergyHydrology constructors
Espeer5 Feb 11, 2025
6827637
Repair soil canopy tutorial
Espeer5 Feb 11, 2025
91025de
Resolve type issues for radiation parameters structs
Espeer5 Feb 11, 2025
d681a25
Repair a ton of issues
Espeer5 Feb 12, 2025
ffdef9a
Format
Espeer5 Feb 12, 2025
2359ce6
Fixup EnergyHydrology parameter prescriptions
Espeer5 Feb 12, 2025
415e620
Repair spatial parameters for EHM
Espeer5 Feb 12, 2025
b044cd1
Fix more issues
Espeer5 Feb 12, 2025
8caa8df
Fix hydraulics test
Espeer5 Feb 12, 2025
856f69d
repair bigleaf tests
Espeer5 Feb 12, 2025
5d41ec4
Repair broadcast inference
Espeer5 Feb 16, 2025
2eec93b
Fixup implicit regression
Espeer5 Feb 16, 2025
0271baa
lsm albedo kwargs
Espeer5 Feb 16, 2025
884a27d
Fixup ground albedo soil/canopy ground albedo methods
Espeer5 Feb 16, 2025
94eec54
WIP broadcast fixup
Espeer5 Feb 16, 2025
b0bbd8e
Fix test field indexing
Espeer5 Feb 16, 2025
6f655da
Update soil/snow test
Espeer5 Feb 16, 2025
e9e0561
Fixup expected spatially varying types
Espeer5 Feb 16, 2025
f27d2ee
WIP fixup experiments
Espeer5 Feb 17, 2025
f92d7a2
Fixup diagnostics
Espeer5 Feb 17, 2025
ed2e3d0
WIP spatially varying param construction issue
Espeer5 Feb 17, 2025
e50f25b
Fix evaporation docs
Espeer5 Feb 17, 2025
2bef3be
Change CLS TS contructors to kwargs
Espeer5 Feb 18, 2025
e09fa9a
WIP fix reading of CLM params
Espeer5 Feb 18, 2025
84f62da
clm parameters to tuples
Espeer5 Feb 18, 2025
5e1960d
Remove superfluous broadcasting
Espeer5 Feb 18, 2025
bd470d1
re-enable windows CI
Espeer5 Feb 19, 2025
b3d7aa8
Remove closure in broadcast
Espeer5 Feb 19, 2025
79864f3
WIP GPU compat
Espeer5 Feb 19, 2025
af998e8
Add additional hyperspectral software pipe test
Espeer5 Feb 19, 2025
732bc23
Repair NTuple construction
Espeer5 Feb 19, 2025
9e56042
WIP GPU Compat
Espeer5 Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/tutorials/integrated/soil_canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ include(
# [tutorial](https://clima.github.io/ClimaLand.jl/dev/generated/Soil/soil_energy_hydrology/)
# on the model for a more detailed explanation of the soil model.

# Define the discretization of the radiation spectrum used in the model:
spectral_discretization = TwoBandSpectralDiscretization{FT}()

# Define the parameters for the soil model and provide them to the model
# parameters struct:

Expand All @@ -143,8 +146,7 @@ soil_vg_α = FT(0.04) # inverse meters
z_0m_soil = FT(0.1)
z_0b_soil = FT(0.1)
soil_ϵ = FT(0.98)
soil_α_PAR = FT(0.2)
soil_α_NIR = FT(0.4)
soil_α = FT.((0.2, 0.4))

soil_domain = land_domain
soil_ps = Soil.EnergyHydrologyParameters(
Expand All @@ -161,8 +163,7 @@ soil_ps = Soil.EnergyHydrologyParameters(
z_0m = z_0m_soil,
z_0b = z_0b_soil,
emissivity = soil_ϵ,
PAR_albedo = soil_α_PAR,
NIR_albedo = soil_α_NIR,
albedo = soil_α,
);

soil_args = (domain = soil_domain, parameters = soil_ps)
Expand Down Expand Up @@ -220,12 +221,11 @@ autotrophic_respiration_args =
radiative_transfer_args = (;
parameters = TwoStreamParameters(
FT;
spectral_discretization = spectral_discretization,
G_Function = ConstantGFunction(FT(0.5)),
α_PAR_leaf = 0.1,
α_NIR_leaf = 0.45,
τ_PAR_leaf = 0.05,
τ_NIR_leaf = 0.25,
Ω = 0.69,
ρ_leaf = FT.((0.1, 0.45)),
τ_leaf = FT.((0.05, 0.25)),
Ω = FT(0.69),
)
)

Expand Down
11 changes: 5 additions & 6 deletions docs/tutorials/standalone/Canopy/canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ soil_driver = PrescribedGroundConditions(
FT;
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
ψ = t -> ψ_soil0,
α_PAR = FT(0.2),
α_NIR = FT(0.4),
spectral_discretization = TwoBandSpectralDiscretization{FT}(),
α_ground = FT.((0.2, 0.4)),
T = t -> 298.0,
ϵ = FT(0.99),
);
Expand All @@ -156,11 +156,10 @@ soil_driver = PrescribedGroundConditions(

rt_params = TwoStreamParameters(
FT;
spectral_discretization = TwoBandSpectralDiscretization{FT}(),
G_Function = ConstantGFunction(FT(0.5)),
α_PAR_leaf = FT(0.1),
α_NIR_leaf = FT(0.45),
τ_PAR_leaf = FT(0.05),
τ_NIR_leaf = FT(0.25),
ρ_leaf = FT.((0.1, 0.45)),
τ_leaf = FT.((0.05, 0.25)),
Ω = FT(0.69),
λ_γ_PAR = FT(5e-7),
)
Expand Down
6 changes: 2 additions & 4 deletions docs/tutorials/standalone/Soil/evaporation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ S_s = FT(1e-3)
ν_ss_quartz = FT(1.0)
ν_ss_gravel = FT(0.0)
emissivity = FT(1.0)
PAR_albedo = FT(0.2)
NIR_albedo = FT(0.4)
albedo = FT.((0.2, 0.4))
z_0m = FT(1e-3)
z_0b = FT(1e-4)
d_ds = FT(0.01)
Expand All @@ -117,8 +116,7 @@ params = ClimaLand.Soil.EnergyHydrologyParameters(
K_sat,
S_s,
θ_r,
PAR_albedo,
NIR_albedo,
albedo,
emissivity,
z_0m,
z_0b,
Expand Down
6 changes: 2 additions & 4 deletions docs/tutorials/standalone/Soil/evaporation_gilat_loess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ S_s = FT(1e-3)
ν_ss_quartz = FT(0.3)
ν_ss_gravel = FT(0.0)
emissivity = FT(1.0)
PAR_albedo = FT(0.2)
NIR_albedo = FT(0.4)
albedo = FT.((0.2, 0.4))
z_0m = FT(1e-3)
z_0b = FT(1e-4)
d_ds = FT(0.01)# 10mm
Expand All @@ -62,8 +61,7 @@ params = ClimaLand.Soil.EnergyHydrologyParameters(
K_sat,
S_s,
θ_r,
PAR_albedo,
NIR_albedo,
albedo,
emissivity,
z_0m,
z_0b,
Expand Down
6 changes: 2 additions & 4 deletions docs/tutorials/standalone/Soil/sublimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ S_s = FT(1e-3)
ν_ss_quartz = FT(1.0)
ν_ss_gravel = FT(0.0)
emissivity = FT(1.0)
PAR_albedo = FT(0.2)
NIR_albedo = FT(0.4)
albedo = FT.((0.2, 0.4))
z_0m = FT(1e-3)
z_0b = FT(1e-4)
d_ds = FT(0.01)
Expand All @@ -103,8 +102,7 @@ params = ClimaLand.Soil.EnergyHydrologyParameters(
K_sat,
S_s,
θ_r,
PAR_albedo,
NIR_albedo,
albedo,
emissivity,
z_0m,
z_0b,
Expand Down
36 changes: 12 additions & 24 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))

start_date = DateTime(2008)

spectral_discretization = Canopy.TwoBandSpectralDiscretization{FT}()

# Forcing data
era5_artifact_path =
ClimaLand.Artifacts.era5_land_forcing_data2008_folder_path(; context)
Expand Down Expand Up @@ -99,10 +101,8 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
K_sat,
S_s,
θ_r,
PAR_albedo_dry,
NIR_albedo_dry,
PAR_albedo_wet,
NIR_albedo_wet,
albedo_dry,
albedo_wet,
f_max,
) = spatially_varying_soil_params
soil_params = Soil.EnergyHydrologyParameters(
Expand All @@ -115,10 +115,9 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
K_sat,
S_s,
θ_r,
PAR_albedo_dry = PAR_albedo_dry,
NIR_albedo_dry = NIR_albedo_dry,
PAR_albedo_wet = PAR_albedo_wet,
NIR_albedo_wet = NIR_albedo_wet,
spectral_discretization,
albedo_dry,
albedo_wet,
)

f_over = FT(3.28) # 1/m
Expand All @@ -130,18 +129,8 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
)
# Spatially varying canopy parameters from CLM
clm_parameters = ClimaLand.clm_canopy_parameters(surface_space)
(;
Ω,
rooting_depth,
is_c3,
Vcmax25,
g1,
G_Function,
α_PAR_leaf,
τ_PAR_leaf,
α_NIR_leaf,
τ_NIR_leaf,
) = clm_parameters
(; Ω, rooting_depth, is_c3, Vcmax25, g1, G_Function, ρ_leaf, τ_leaf) =
clm_parameters

# Energy Balance model
ac_canopy = FT(2.5e3)
Expand Down Expand Up @@ -218,11 +207,10 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
radiative_transfer_args = (;
parameters = Canopy.TwoStreamParameters(
FT;
spectral_discretization,
Ω,
α_PAR_leaf,
τ_PAR_leaf,
α_NIR_leaf,
τ_NIR_leaf,
ρ_leaf,
τ_leaf,
G_Function,
)
)
Expand Down
27 changes: 12 additions & 15 deletions experiments/benchmarks/snowy_land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
surface_space = domain.space.surface
subsurface_space = domain.space.subsurface

spectral_discretization = Canopy.TwoBandSpectralDiscretization{FT}()

start_date = DateTime(2008)
# Forcing data
era5_artifact_path =
Expand Down Expand Up @@ -99,10 +101,8 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
K_sat,
S_s,
θ_r,
PAR_albedo_dry,
NIR_albedo_dry,
PAR_albedo_wet,
NIR_albedo_wet,
albedo_dry,
albedo_wet,
f_max,
) = spatially_varying_soil_params
soil_params = Soil.EnergyHydrologyParameters(
Expand All @@ -115,10 +115,9 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
K_sat,
S_s,
θ_r,
PAR_albedo_dry = PAR_albedo_dry,
NIR_albedo_dry = NIR_albedo_dry,
PAR_albedo_wet = PAR_albedo_wet,
NIR_albedo_wet = NIR_albedo_wet,
spectral_discretization,
albedo_dry,
albedo_wet,
)
f_over = FT(3.28) # 1/m
R_sb = FT(1.484e-4 / 1000) # m/s
Expand All @@ -137,9 +136,8 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
Vcmax25,
g1,
G_Function,
α_PAR_leaf,
τ_PAR_leaf,
α_NIR_leaf,
ρ_leaf,
ρ_leaf,
τ_NIR_leaf,
) = clm_parameters

Expand Down Expand Up @@ -216,11 +214,10 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
radiative_transfer_args = (;
parameters = Canopy.TwoStreamParameters(
FT;
spectral_discretization,
Ω,
α_PAR_leaf,
τ_PAR_leaf,
α_NIR_leaf,
τ_NIR_leaf,
ρ_leaf,
τ_leaf,
G_Function,
)
)
Expand Down
4 changes: 2 additions & 2 deletions experiments/integrated/fluxnet/US-Ha1/US-Ha1_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ soil_α_NIR = FT(0.2)
Ω = FT(0.69)
ld = FT(0.5)
G_Function = ConstantGFunction(ld)
α_PAR_leaf = FT(0.1)
ρ_PAR_leaf = FT(0.1)
λ_γ_PAR = FT(5e-7)
τ_PAR_leaf = FT(0.05)
α_NIR_leaf = FT(0.45)
ρ_NIR_leaf = FT(0.45)
τ_NIR_leaf = FT(0.25)
ϵ_canopy = FT(0.97)

Expand Down
4 changes: 2 additions & 2 deletions experiments/integrated/fluxnet/US-MOz/US-MOz_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ soil_α_NIR = FT(0.2)
Ω = FT(0.69)
χl = FT(0.1)
G_Function = CLMGFunction(χl)
α_PAR_leaf = FT(0.1)
ρ_PAR_leaf = FT(0.1)
λ_γ_PAR = FT(5e-7)
τ_PAR_leaf = FT(0.05)
α_NIR_leaf = FT(0.45)
ρ_NIR_leaf = FT(0.45)
τ_NIR_leaf = FT(0.25)
ϵ_canopy = FT(0.97)

Expand Down
4 changes: 2 additions & 2 deletions experiments/integrated/fluxnet/US-NR1/US-NR1_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ soil_α_NIR = FT(0.2)
Ω = FT(0.71)
ld = FT(0.5)
G_Function = ConstantGFunction(ld)
α_PAR_leaf = FT(0.1)
ρ_PAR_leaf = FT(0.1)
λ_γ_PAR = FT(5e-7)
τ_PAR_leaf = FT(0.05)
α_NIR_leaf = FT(0.35)
ρ_NIR_leaf = FT(0.35)
τ_NIR_leaf = FT(0.25)
ϵ_canopy = FT(0.97)

Expand Down
4 changes: 2 additions & 2 deletions experiments/integrated/fluxnet/US-Var/US-Var_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ soil_α_NIR = FT(0.2)
Ω = FT(1.0)
ld = FT(0.5)
G_Function = ConstantGFunction(ld)
α_PAR_leaf = FT(0.11)
ρ_PAR_leaf = FT(0.11)
λ_γ_PAR = FT(5e-7)
τ_PAR_leaf = FT(0.05)
α_NIR_leaf = FT(0.35)
ρ_NIR_leaf = FT(0.35)
τ_NIR_leaf = FT(0.34)
ϵ_canopy = FT(0.97)

Expand Down
21 changes: 13 additions & 8 deletions experiments/integrated/fluxnet/ozark_pft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pft_pcts = [
# Load the PFT parameters into the namespace
(
Ω,
α_PAR_leaf,
α_NIR_leaf,
ρ_PAR_leaf,
ρ_NIR_leaf,
τ_PAR_leaf,
τ_NIR_leaf,
ϵ_canopy,
Expand Down Expand Up @@ -111,6 +111,10 @@ include(
"experiments/integrated/fluxnet/met_drivers_FLUXNET.jl",
),
)

# Discretization of radiation
spectral_discretization = ClimaLand.TwoBandSpectralDiscretization{FT}()

# Now we set up the model. For the soil model, we pick
# a model type and model args:
soil_domain = land_domain
Expand All @@ -128,8 +132,8 @@ soil_ps = Soil.EnergyHydrologyParameters(
z_0m = z_0m_soil,
z_0b = z_0b_soil,
emissivity = soil_ϵ,
PAR_albedo = soil_α_PAR,
NIR_albedo = soil_α_NIR,
spectral_discretization = spectral_discretization,
albedo = (soil_α_PAR, soil_α_NIR),
);

soil_args = (domain = soil_domain, parameters = soil_ps)
Expand Down Expand Up @@ -172,15 +176,16 @@ autotrophic_respiration_args =
(; parameters = AutotrophicRespirationParameters(FT))
# Set up radiative transfer
G_Function = CLMGFunction(χl)
ρ_leaf = (ρ_PAR_leaf, ρ_NIR_leaf)
τ_leaf = (τ_PAR_leaf, τ_NIR_leaf)
radiative_transfer_args = (;
parameters = TwoStreamParameters(
FT;
spectral_discretization,
Ω,
G_Function,
α_PAR_leaf,
τ_PAR_leaf,
α_NIR_leaf,
τ_NIR_leaf,
ρ_leaf,
τ_leaf,
)
)
# Set up conductance
Expand Down
Loading
Loading