Skip to content

Commit 63f8adb

Browse files
authored
Refactor PrescribedGroundConditions; use time varying input (#1240)
1 parent a5b3951 commit 63f8adb

File tree

20 files changed

+373
-397
lines changed

20 files changed

+373
-397
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ClimaLand.jl Release Notes
33

44
main
55
-------
6+
- Remove root_depths from the PrescribeGroundConditions struct, and treat these ground ``drivers" consistently with how we handle atmospheric forcing PR[#1199](https://github.com/CliMA/ClimaLand.jl/pull/1240)
67
- Add constructors with default values for Canopy components PR[#1233](https://github.com/CliMA/ClimaLand.jl/pull/1233)
78

89
v0.17.2

docs/src/tutorials/standalone/Canopy/canopy_tutorial.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,14 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
139139
# For this canopy, we are running in standalone mode, which means we need to
140140
# use a prescribed soil driver, defined as follows:
141141

142-
ψ_soil0 = FT(0.0)
143-
142+
ψ_soil = FT(0.0)
143+
T_soil = FT(298.0)
144144
soil_driver = PrescribedGroundConditions(
145145
FT;
146-
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
147-
ψ = t -> ψ_soil0,
148146
α_PAR = FT(0.2),
149147
α_NIR = FT(0.4),
150-
T = t -> 298.0,
148+
T = TimeVaryingInput(t -> T_soil),
149+
ψ = TimeVaryingInput(t -> ψ_soil),
151150
ϵ = FT(0.99),
152151
);
153152

experiments/standalone/Vegetation/no_vegetation.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
5353
z0_b,
5454
earth_param_set,
5555
);
56-
ψ_soil0 = FT(0.0)
5756

5857
soil_driver = PrescribedGroundConditions(
5958
FT;
60-
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
61-
ψ = t -> ψ_soil0,
6259
α_PAR = FT(0.2),
6360
α_NIR = FT(0.4),
64-
T = t -> 298.0,
6561
ϵ = FT(0.99),
6662
);
6763

experiments/standalone/Vegetation/timestep_test.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,11 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
9292
z0_b,
9393
earth_param_set,
9494
);
95-
ψ_soil0 = FT(0.0)
9695

9796
soil_driver = PrescribedGroundConditions(
9897
FT;
99-
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
100-
ψ = t -> ψ_soil0,
10198
α_PAR = FT(0.2),
10299
α_NIR = FT(0.4),
103-
T = t -> 298.0,
104100
ϵ = FT(0.99),
105101
);
106102

experiments/standalone/Vegetation/varying_lai.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
5353
z0_b,
5454
earth_param_set,
5555
);
56-
ψ_soil0 = FT(0.0)
5756

5857
soil_driver = PrescribedGroundConditions(
5958
FT;
60-
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
61-
ψ = t -> ψ_soil0,
6259
α_PAR = FT(0.2),
6360
α_NIR = FT(0.4),
64-
T = t -> 298.0,
6561
ϵ = FT(0.99),
6662
);
6763

experiments/standalone/Vegetation/varying_lai_with_stem.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
5353
z0_b,
5454
earth_param_set,
5555
);
56-
ψ_soil0 = FT(0.0)
5756

5857
soil_driver = PrescribedGroundConditions(
5958
FT;
60-
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
61-
ψ = t -> ψ_soil0,
6259
α_PAR = FT(0.2),
6360
α_NIR = FT(0.4),
64-
T = t -> 298.0,
6561
ϵ = FT(0.99),
6662
);
6763

src/ClimaLand.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ import .Canopy:
407407
ground_albedo_PAR,
408408
ground_albedo_NIR,
409409
canopy_radiant_energy_fluxes!,
410-
root_energy_flux_per_ground_area!,
411-
AbstractGroundConditions
410+
root_energy_flux_per_ground_area!
412411
### Concrete types of AbstractLandModels
413412
### and associated methods
414413
include("integrated/soil_energy_hydrology_biogeochemistry.jl")

src/integrated/land.jl

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function LandModel{FT}(;
123123
)
124124

125125
transpiration = Canopy.PlantHydraulics.DiagnosticTranspiration{FT}()
126-
ground_conditions = PrognosticGroundConditions()
126+
ground_conditions = PrognosticGroundConditions{FT}()
127127
if :energy in propertynames(canopy_component_args)
128128
energy_model = canopy_component_types.energy(
129129
canopy_component_args.energy.parameters,
@@ -635,68 +635,6 @@ function ClimaLand.Soil.sublimation_source(
635635
return SoilSublimationwithSnow{FT}()
636636
end
637637

638-
"""
639-
PrognosticGroundConditions <: Canopy.AbstractGroundConditions
640-
641-
A type of Canopy.AbstractGroundConditions to use when the soil model is prognostic and
642-
of type `EnergyHydrology`, and the snow model is prognostic and included.
643-
644-
Note that this struct is linked with the EnergyHydrology/SnowModel model. If we ever had a different
645-
soil model, we might need to construct a different `PrognosticGroundConditions` because
646-
the fields may be stored in different places.
647-
"""
648-
struct PrognosticGroundConditions <: Canopy.AbstractGroundConditions end
649-
650-
"""
651-
Canopy.ground_albedo_PAR(
652-
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
653-
ground::PrognosticGroundConditions,
654-
Y,
655-
p,
656-
t,
657-
)
658-
659-
A method of Canopy.ground_albedo_PAR for a prognostic soil/snow. This function is called in
660-
the Canopy update_aux! function.
661-
"""
662-
function Canopy.ground_albedo_PAR(
663-
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
664-
ground::PrognosticGroundConditions,
665-
Y,
666-
p,
667-
t,
668-
)
669-
@. p.α_ground.PAR =
670-
(1 - p.snow.snow_cover_fraction) * p.soil.PAR_albedo +
671-
p.snow.snow_cover_fraction * p.snow.α_snow
672-
return p.α_ground.PAR
673-
end
674-
675-
"""
676-
Canopy.ground_albedo_NIR(
677-
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
678-
ground::PrognosticGroundConditions,
679-
Y,
680-
p,
681-
t,
682-
)
683-
684-
A method of Canopy.ground_albedo_NIR for a prognostic soil/snow. This function is called in
685-
the Canopy update_aux! function.
686-
"""
687-
function Canopy.ground_albedo_NIR(
688-
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
689-
ground::PrognosticGroundConditions,
690-
Y,
691-
p,
692-
t,
693-
)
694-
@. p.α_ground.NIR =
695-
(1 - p.snow.snow_cover_fraction) * p.soil.NIR_albedo +
696-
p.snow.snow_cover_fraction * p.snow.α_snow
697-
return p.α_ground.NIR
698-
end
699-
700638
"""
701639
ClimaLand.get_drivers(model::LandModel)
702640

src/integrated/land_radiation.jl

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,96 @@ function Canopy.canopy_radiant_energy_fluxes!(
4646
) where {PSE}
4747
nothing
4848
end
49+
50+
"""
51+
Canopy.ground_albedo_PAR(
52+
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
53+
ground::PrognosticSoilConditions,
54+
Y,
55+
p,
56+
t,
57+
)
58+
59+
A method of Canopy.Canopy.ground_albedo_PAR for a prognostic soil.
60+
"""
61+
function Canopy.ground_albedo_PAR(
62+
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
63+
ground::PrognosticSoilConditions,
64+
Y,
65+
p,
66+
t,
67+
)
68+
return p.soil.PAR_albedo
69+
end
70+
71+
"""
72+
Canopy.ground_albedo_NIR(
73+
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
74+
ground::PrognosticSoilConditions,
75+
Y,
76+
p,
77+
t,
78+
)
79+
80+
A method of Canopy.ground_albedo_NIR for a prognostic soil.
81+
"""
82+
function Canopy.ground_albedo_NIR(
83+
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
84+
ground::PrognosticSoilConditions,
85+
Y,
86+
p,
87+
t,
88+
)
89+
return p.soil.NIR_albedo
90+
end
91+
92+
93+
"""
94+
Canopy.ground_albedo_PAR(
95+
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
96+
ground::PrognosticGroundConditions,
97+
Y,
98+
p,
99+
t,
100+
)
101+
102+
A method of Canopy.ground_albedo_PAR for a prognostic soil/snow. This function is called in
103+
the Canopy update_aux! function.
104+
"""
105+
function Canopy.ground_albedo_PAR(
106+
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
107+
ground::PrognosticGroundConditions,
108+
Y,
109+
p,
110+
t,
111+
)
112+
@. p.α_ground.PAR =
113+
(1 - p.snow.snow_cover_fraction) * p.soil.PAR_albedo +
114+
p.snow.snow_cover_fraction * p.snow.α_snow
115+
return p.α_ground.PAR
116+
end
117+
118+
"""
119+
Canopy.ground_albedo_NIR(
120+
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
121+
ground::PrognosticGroundConditions,
122+
Y,
123+
p,
124+
t,
125+
)
126+
127+
A method of Canopy.ground_albedo_NIR for a prognostic soil/snow. This function is called in
128+
the Canopy update_aux! function.
129+
"""
130+
function Canopy.ground_albedo_NIR(
131+
prognostic_land_components::Val{(:canopy, :snow, :soil, :soilco2)},
132+
ground::PrognosticGroundConditions,
133+
Y,
134+
p,
135+
t,
136+
)
137+
@. p.α_ground.NIR =
138+
(1 - p.snow.snow_cover_fraction) * p.soil.NIR_albedo +
139+
p.snow.snow_cover_fraction * p.snow.α_snow
140+
return p.α_ground.NIR
141+
end

src/integrated/soil_canopy_model.jl

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function SoilCanopyModel{FT}(;
9898
)
9999

100100
transpiration = Canopy.PlantHydraulics.DiagnosticTranspiration{FT}()
101-
ground_conditions = PrognosticSoilConditions()
101+
ground_conditions = PrognosticSoilConditions{FT}()
102102
if :energy in propertynames(canopy_component_args)
103103
energy_model = canopy_component_types.energy(
104104
canopy_component_args.energy.parameters,
@@ -464,56 +464,6 @@ function Soil.compute_liquid_influx(
464464
return p.drivers.P_liq
465465
end
466466

467-
"""
468-
PrognosticSoilConditions <: Canopy.AbstractGroundConditions
469-
470-
A type of Canopy.AbstractGroundConditions to use when the soil model is prognostic and
471-
of type `EnergyHydrology`. `PrognosticSoilConditions` functions as a flag and is used for dispatch
472-
"""
473-
struct PrognosticSoilConditions <: Canopy.AbstractGroundConditions end
474-
475-
"""
476-
Canopy.ground_albedo_PAR(
477-
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
478-
ground::PrognosticSoilConditions,
479-
Y,
480-
p,
481-
t,
482-
)
483-
484-
A method of Canopy.ground_albedo_PAR for a prognostic soil.
485-
"""
486-
function Canopy.ground_albedo_PAR(
487-
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
488-
ground::PrognosticSoilConditions,
489-
Y,
490-
p,
491-
t,
492-
)
493-
return p.soil.PAR_albedo
494-
end
495-
496-
"""
497-
Canopy.ground_albedo_NIR(
498-
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
499-
ground::PrognosticSoilConditions,
500-
Y,
501-
p,
502-
t,
503-
)
504-
505-
A method of Canopy.ground_albedo_NIR for a prognostic soil.
506-
"""
507-
function Canopy.ground_albedo_NIR(
508-
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
509-
ground::PrognosticSoilConditions,
510-
Y,
511-
p,
512-
t,
513-
)
514-
return p.soil.NIR_albedo
515-
end
516-
517467
function ClimaLand.Soil.sublimation_source(
518468
prognostic_land_components::Val{(:canopy, :soil, :soilco2)},
519469
FT,

0 commit comments

Comments
 (0)