Skip to content

Commit eda4470

Browse files
committed
global simulations
1 parent f379719 commit eda4470

File tree

3 files changed

+186
-18
lines changed

3 files changed

+186
-18
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function GlobalDomain(...)
2+
return SphericalShell()
3+
end
4+
5+
context = ;
6+
FT = ;
7+
param_set = ...earth_param_set(FT)
8+
parameter_maps = spatially_varying_maps(FT, ...)
9+
10+
domain = GlobalDomain(context, )
11+
land = LandModel(FT, domain, params, component_choices; parameter_maps)
12+
# if hires fails to download, use lowres (era5 forcing?)
13+
14+
15+
#set_ic!(Y, land, t0)
16+
timestepper = (alg::ImEx = ARS111, t0, dt, tf; start_date = nothing) # handled internally with itime, e.g. pass in seconds
17+
timestepper = (alg::ImEx = ARS111, t0::DateTime, dt::Seconds, duration::Period) # handled internally with itime
18+
user_callbacks # all SciML callbacks, but we provide helper functions for specific instances (nancheck, report, checkpoint)
19+
diagnostics # Tuple of scheduled diagnostics, diagnostics handler is constructed internally
20+
# driver is combine with user_callbacks and diagnostics callback internally to make the CB set
21+
output_dir # will have default
22+
#context # will have default, this includes the device, or take the device and create the context
23+
config = # specifies a default postprocessing/plots to make
24+
simulation = Simulation(land, set_ic!, domain, timestepper, user_callbacks, diagnostics, config)
25+
26+
27+
28+
29+

src/simulations/model_setup.jl

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
function LandModel(
2+
domain,
3+
start_date,
4+
params,
5+
FT;
6+
forcing = ClimaLand.prescribed_forcing_era5(
7+
ClimaLand.Artifacts.era5_land_forcing_data2008_folder_path(; context),# get context from domain
8+
domain.space.surface,
9+
start_date,
10+
params,
11+
FT;
12+
time_interpolation_method = LinearInterpolation(PeriodicCalendar()),
13+
),
14+
LAI = ClimaLand.prescribed_lai_modis(
15+
joinpath(
16+
ClimaLand.Artifacts.modis_lai_forcing_data_path(; context),
17+
"Yuan_et_al_2008_1x1.nc",
18+
),
19+
domain.space.surface,
20+
start_date;
21+
time_interpolation_method = LinearInterpolation(PeriodicCalendar()),
22+
),
23+
soil_model = (
24+
type = Soil.EnergyHydrology{FT},
25+
spatially_varying_parameters = ClimaLand.default_spatially_varying_soil_parameters(
26+
domain.space.subsurface,
27+
domain.space.surface,
28+
FT,
29+
),
30+
runoff_scheme = (
31+
type = ClimaLand.Soil.Runoff.TOPMODELRunoff{FT},
32+
parameters = (;
33+
f_over = FT(3.28),
34+
R_sb = FT(1.484e-4 / 1000),
35+
f_max = ClimaLand.default_spatially_varying_topmodel_fmax(
36+
surface_space,
37+
FT,
38+
),
39+
),
40+
),
41+
),
42+
soilco2_model = (
43+
type = Soil.Biogeochemistry.SoilCO2Model{FT},
44+
parameters = Soil.Biogeochemistry.SoilCO2ModelParameters(FT),
45+
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(
46+
TimeVaryingInput((t) -> 5),
47+
),
48+
),
49+
snow_model = (
50+
type = Snow.SnowModel,
51+
parameters = SnowParameters{FT}(Δt; earth_param_set = params),
52+
),
53+
canopy_model = (;
54+
component_types = (;
55+
autotrophic_respiration = Canopy.AutotrophicRespirationModel{FT},
56+
radiative_transfer = Canopy.TwoStreamModel{FT},
57+
photosynthesis = Canopy.FarquharModel{FT},
58+
conductance = Canopy.MedlynConductanceModel{FT},
59+
hydraulics = Canopy.PlantHydraulicsModel{FT},
60+
energy = Canopy.BigLeafEnergyModel{FT},
61+
),
62+
component_args = (; # needs lots of work
63+
autotrophic_respiration = Canopy.AutotrophicRespirationParameters(
64+
FT,
65+
),
66+
radiative_transfer = Canopy.TwoStreamParameters(FT;),
67+
photosynthesis = Canopy.FarquharParameters(
68+
FT,
69+
is_c3;
70+
Vcmax25 = Vcmax25,
71+
),
72+
conductance = Canopy.MedlynConductanceParameters(FT; g1),
73+
hydraulics = Canopy.PlantHydraulics.PlantHydraulicsParameters(;),
74+
energy = Canopy.BigLeafEnergyParameters{FT}(ac_canopy),
75+
),
76+
parameters = Canopy.SharedCanopyParameters{FT, typeof(params)}(
77+
z0_m,
78+
z0_b,
79+
params,
80+
),
81+
),
82+
)
83+
# Create land model - Sketch
84+
85+
# Soil Model
86+
runoff_model =
87+
soil_model.runoff_scheme.type(; soil_model.runoff_scheme.parameters...)
88+
soil_params = Soil.EnergyHydrologyParameters(
89+
FT;
90+
soil_model.spatially_varying_parameters...,
91+
)
92+
soil_args = (parameters = soil_params, domain = domain)
93+
94+
# Soil CO2 - easy
95+
soilco2_args = (parameters = soilco2_model.parameters, domain = domain)
96+
97+
# Snow - also easy given defaults
98+
snow_args = (
99+
parameters = snow_model.parameters,
100+
domain = ClimaLand.obtain_surface_domain(domain),
101+
)
102+
103+
# Canopy
104+
canopy_model_args = (;
105+
parameters = canopy_model.parameters,
106+
domain = ClimaLand.obtain_surface_domain(domain),
107+
)
108+
land_input = (
109+
atmos = forcing[1],
110+
radiation = forcing[2],
111+
runoff = runoff_model,
112+
soil_organic_carbon = soilco2_model.Csom,
113+
)
114+
land = LandModel{FT}(;
115+
soilco2_type = soilco2_model.type,
116+
soilco2_args = soilco2_args,
117+
soil_model_type = soil_model.type,
118+
soil_args = soil_args,
119+
canopy_component_types = canopy_model.component_types,
120+
canopy_component_args = canopy_model.component_args,
121+
canopy_model_args = canopy_model_args,
122+
snow_args = snow_args,
123+
snow_model_type = snow_model.type,
124+
land_args = land_input,
125+
)
126+
return land
127+
end

src/simulations/spatial_parameters.jl

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ function clm_canopy_parameters(
183183
)
184184
end
185185

186+
masked_to_value(field, mask, value) =
187+
mask == 1.0 ? field : eltype(field)(value)
188+
189+
190+
186191
"""
187192
default_spatially_varying_soil_parameters(
188193
surface_space,
@@ -282,9 +287,6 @@ function default_spatially_varying_soil_parameters(
282287
# If the parameter mask = 0, set to physical value
283288
# This function in applied in **simulation mask** aware
284289
# manner.
285-
masked_to_value(field, mask, value) =
286-
mask == 1.0 ? field : eltype(field)(value)
287-
288290
μ = FT(0.27)
289291
vg_α .= masked_to_value.(vg_α, soil_params_mask, 10.0^μ)
290292
μ = FT(1.65)
@@ -377,20 +379,6 @@ function default_spatially_varying_soil_parameters(
377379
@. ν_ss_om = ν_ss_om / max(texture_norm, eps(FT))
378380
@. ν_ss_quartz = ν_ss_quartz / max(texture_norm, eps(FT))
379381

380-
# Read in f_max data and topmodel params land sea mask
381-
infile_path = ClimaLand.Artifacts.topmodel_data_path()
382-
f_max =
383-
SpaceVaryingInput(infile_path, "fmax", surface_space; regridder_type)
384-
topmodel_params_mask = SpaceVaryingInput(
385-
infile_path,
386-
"landsea_mask",
387-
surface_space;
388-
regridder_type,
389-
)
390-
soil_params_mask_sfc =
391-
ClimaLand.Domains.top_center_to_surface(soil_params_mask)
392-
f_max = masked_to_value.(f_max, topmodel_params_mask, FT(0))
393-
f_max = masked_to_value.(f_max, soil_params_mask_sfc, FT(0))
394382
PAR_albedo_dry, NIR_albedo_dry, PAR_albedo_wet, NIR_albedo_wet = map(
395383
s -> SpaceVaryingInput(
396384
joinpath(
@@ -423,6 +411,30 @@ function default_spatially_varying_soil_parameters(
423411
NIR_albedo_wet = NIR_albedo_wet,
424412
PAR_albedo_dry = PAR_albedo_dry,
425413
NIR_albedo_dry = NIR_albedo_dry,
426-
f_max = f_max,
427414
)
428415
end
416+
417+
function default_spatially_varying_topmodel_fmax(
418+
surface_space,
419+
FT;
420+
regridder_type = :InterpolationsRegridder,
421+
extrapolation_bc = (
422+
Interpolations.Periodic(),
423+
Interpolations.Flat(),
424+
Interpolations.Flat(),
425+
),
426+
lowres = use_lowres_clm(surface_space),
427+
)
428+
# Read in f_max data and topmodel params land sea mask
429+
infile_path = ClimaLand.Artifacts.topmodel_data_path()
430+
f_max =
431+
SpaceVaryingInput(infile_path, "fmax", surface_space; regridder_type)
432+
topmodel_params_mask = SpaceVaryingInput(
433+
infile_path,
434+
"landsea_mask",
435+
surface_space;
436+
regridder_type,
437+
)
438+
f_max = masked_to_value.(f_max, topmodel_params_mask, FT(0))
439+
return f_max
440+
end

0 commit comments

Comments
 (0)