-
Notifications
You must be signed in to change notification settings - Fork 8
/
Soil.jl
182 lines (154 loc) · 5.69 KB
/
Soil.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
module Soil
#=
Soil
This module contains everything needed to run a soil model
in standalone mode.
The soil model is assumed to have a set of prognostic `Y` and
auxiliary `p` variables, which describe the state of the
soil system. The system is evolved in time by solving
equations of the form
```
\frac{\partial Y}{\partial t} = D(Y, t, p(Y, t; \ldots);\ldots),
```
i.e. partial (or ordinary) differential equations depending
on state `Y`,
auxiliary functions of the state `p`, and other parameters
represented by the ellipses. The operator `D` indicates a generic
nonlinear differential operator. Not every model
requires auxilary variables, but these are useful for storing
quantities that are needed multiple times per right hand side
evaluation. An example would be the temperature, which is computed
from the prognostic variables of water content and internal
energy.
Currently, both the Richardson Richards Equation (RRE; hydrology alone)
and an integrated soil energy and hydrology model are supported.
Addition of additional versions of soil
models requires defining a model type (of super type
`AbstractSoilModel`), and extending the methods
imported by Models.jl, as needed, for computing the
right hand side functions of the ordinary differential equations
and the functions which update auxiliary variables whenever
the right hand side is evaluated.
This code base assumes that DifferentialEquations.jl
will be used for evolving the system in time,
and that the array-like objected being stepped forward
is a `ClimaCore.Fields.FieldVector`.
The `FieldVector` type is used in order to make use of
`ClimaCore` functionality when solving PDEs (`ClimaCore` handles
all of the spatial discretization and operator functionality)
and for ease of handling multi-column models.
To simulate land surfaces with multiple components (vegetation,
soil, rivers, etc), the ClimaLand.jl package should be used.
That package will use the methods of this function for advancing
the system forward in time, extending methods as needed to account
for interactions between components.
=#
using ClimaLand
using DocStringExtensions
using LinearAlgebra
using ClimaCore
import ..Parameters as LP
import ClimaCore: Fields, Operators, Geometry, Spaces
using Thermodynamics
import ClimaLand.Domains: Column, HybridBox, SphericalShell
using ClimaLand: AbstractTridiagonalW
import ClimaLand:
AbstractImExModel,
make_update_aux,
make_compute_exp_tendency,
make_compute_imp_tendency,
make_update_boundary_fluxes,
make_update_jacobian,
prognostic_vars,
auxiliary_vars,
prognostic_domain_names,
auxiliary_domain_names,
name,
prognostic_types,
auxiliary_types,
AbstractSource,
source!,
heaviside,
surface_temperature,
surface_specific_humidity,
surface_albedo,
surface_emissivity,
surface_height,
surface_resistance,
get_drivers
export RichardsModel,
RichardsParameters,
RichardsTridiagonalW,
EnergyHydrology,
EnergyHydrologyParameters,
AbstractSoilModel,
AbstractSoilSource,
PhaseChange
"""
AbstractSoilSource{FT} <: ClimaLand.AbstractSource{FT}
An abstract type for types of source terms for the soil equations.
In standalone mode, the only supported source type is freezing and
thawing. ClimaLand.jl creates additional sources to include as
necessary e.g. root extraction (not available in stand alone mode).
"""
abstract type AbstractSoilSource{FT} <: ClimaLand.AbstractSource{FT} end
"""
AbstractSoilModel{FT} <: ClimaLand.AbstractImExModel{FT}
The abstract type for all soil models.
Currently, we only have plans to support a RichardsModel, simulating
the flow of liquid water through soil via the Richardson-Richards equation,
and a fully integrated soil heat and water model, with phase change.
"""
abstract type AbstractSoilModel{FT} <: ClimaLand.AbstractImExModel{FT} end
ClimaLand.name(::AbstractSoilModel) = :soil
"""
horizontal_components!(dY::ClimaCore.Fields.FieldVector,
domain::Column, _...)
Updates dY in place by adding in the tendency terms resulting from
horizontal derivative operators.
In the case of a column domain, there are no horizontal
contributions to the right hand side.
"""
function horizontal_components!(
dY::ClimaCore.Fields.FieldVector,
domain::Column,
_...,
) end
"""
horizontal_components!(dY::ClimaCore.Fields.FieldVector,
domain::Union{HybridBox, SphericalShell},
lateral_flow::Val{false},
_...)
Updates dY in place by adding in the tendency terms resulting from
horizontal derivative operators.
In the case of a 3D domain, for either the `RichardsModel` or the
`EnergyHydrology` model, if the `lateral_flow` flag is set to false,
there are no horizontal contributions to the right hand side.
"""
function horizontal_components!(
dY::ClimaCore.Fields.FieldVector,
domain::Union{HybridBox, SphericalShell},
lateral_flow::Val{false},
_...,
) end
"""
append_source(src::AbstractSoilSource, srcs::Tuple)::Tuple
Appends `src` to the tuple of sources `srcs` if `src` is of type `AbstractSoilSource`.
"""
append_source(src::AbstractSoilSource, srcs::Tuple)::Tuple = (srcs..., src)
"""
append_source(src::Nothing , srcs::Tuple)::Tuple
Appends `src` to the tuple of sources `srcs` if `src` is of type `AbstractSoilSource`.
"""
append_source(src::Nothing, srcs::Tuple)::Tuple = srcs
include("./retention_models.jl")
include("./rre.jl")
include("./energy_hydrology.jl")
include("Runoff/Runoff.jl")
using .Runoff
include("./boundary_conditions.jl")
include("./soil_hydrology_parameterizations.jl")
include("./soil_heat_parameterizations.jl")
include("Biogeochemistry/Biogeochemistry.jl")
using .Biogeochemistry
end