44Boundary condition type for soil models that provides boundary conditions for each
55of the relevant internal processes, i.e. energy, hydrology, ...
66"""
7- struct SoilBC{EnergyBC, WaterBC} <: AbstractBoundaryConditions
7+ @kwdef struct SoilBC{EnergyBC, WaterBC} <: AbstractBoundaryConditions
88 " Boundary condition for the soil energy balance"
9- energy:: EnergyBC
9+ energy:: EnergyBC = GroundHeatFlux ()
1010
1111 " Boundary condition for the soil water balance"
12- hydrology:: WaterBC
12+ hydrology:: WaterBC = ImpermeableBoundary ()
1313end
1414
1515variables (bc:: SoilBC ) = tuplejoin (variables (bc. hydrology), variables (bc. energy))
@@ -19,23 +19,38 @@ function compute_auxiliary!(state, model, bc::SoilBC)
1919 compute_auxiliary! (state, model, bc. energy)
2020end
2121
22+ function compute_tendencies! (state, model, bc:: SoilBC )
23+ compute_tendencies! (state, model, bc. hydrology)
24+ compute_tendencies! (state, model, bc. energy)
25+ end
26+
2227function get_field_boundary_conditions (bcs:: SoilBC , grid:: AbstractLandGrid )
2328 water_bc = get_field_boundary_conditions (bcs. hydrology, grid)
2429 energy_bc = get_field_boundary_conditions (bcs. energy, grid)
2530 return merge (water_bc, energy_bc)
2631end
2732
33+ # Energy BCs
34+
2835"""
29- Alias for `PrescribedFlux` with name `ground_heat_flux` representing the net ground heat flux at the soil surface.
36+ Alias for `PrescribedFlux` on `internal_energy` with name `ground_heat_flux` representing the net ground heat flux at the soil surface.
3037"""
3138GroundHeatFlux (init= nothing ) = PrescribedFlux (:internal_energy , Input (:ground_heat_flux , init, units= u " W/m^2" ))
3239
3340"""
34- Alias for `PrescribedFlux` with name `Q_geo ` representing the geothermal heat flux at the bottom
41+ Alias for `PrescribedFlux` on `internal_energy` with name `geothermal_heat_flux ` representing the geothermal heat flux at the bottom
3542boundary of the soil column.
3643"""
3744GeothermalHeatFlux (init= nothing ) = PrescribedFlux (:internal_energy , Input (:geothermal_heat_flux , init, units= u " W/m^2" ))
3845
46+ """
47+ Alias for `PrescribedValue` on `temperature` with the given name.
48+ """
49+ PrescribedTemperature (name:: Symbol , init= nothing ) = PrescribedValue (:temperature , Input (name, init, units= u " °C" ))
50+ PrescribedTemperature (condition) = PrescribedValue (:temperature , condition)
51+
52+ # Hydrology BCs
53+
3954"""
4055Alias for `PrescribedFlux` with name `infiltration` representing liquid water infiltration at the soil surface.
4156"""
@@ -52,10 +67,25 @@ column, thereby allowing free drainage of water.
5267"""
5368FreeDrainage (:: Type{NF} ) where {NF} = PrescribedGradient (:pressure_head , zero (NF))
5469
70+ # SoilBoundaryConditions constructor
71+
5572"""
56- Alias for `ColumnBoundaryConditions` with defaults suitable for `SoilModel`s .
73+ Creates `ColumnBoundaryConditions` with defaults suitable for the given soil process configurations .
5774"""
58- SoilBoundaryConditions (:: Type{NF} ; top= default_soil_upperbc (NF), bottom= default_soil_lowerbc (NF)) where {NF} = ColumnBoundaryConditions (; top, bottom)
75+ SoilBoundaryConditions (
76+ :: Type{NF} ,
77+ energy:: SoilEnergyBalance = SoilEnergyBalance (NF),
78+ hydrology:: SoilHydrology = SoilHydrology (NF);
79+ top= SoilBC (energy = default_upperbc (energy), hydrology = default_upperbc (hydrology)),
80+ bottom= SoilBC (energy = default_lowerbc (energy), hydrology = default_lowerbc (hydrology))
81+ ) where {NF} = ColumnBoundaryConditions (; top, bottom)
82+
83+ # Default boundary conditions for various soil process configurations
84+
85+ default_upperbc (:: SoilEnergyBalance ) = GroundHeatFlux ()
86+ default_upperbc (:: SoilHydrology{NF, NoFlow} ) where {NF} = nothing
87+ default_upperbc (:: SoilHydrology ) = InfiltrationFlux ()
5988
60- default_soil_upperbc (:: Type{NF} , energy= GroundHeatFlux (zero (NF)), hydrology= InfiltrationFlux (zero (NF))) where {NF} = SoilBC (energy, hydrology)
61- default_soil_lowerbc (:: Type{NF} , energy= GeothermalHeatFlux (zero (NF)), hydrology= ImpermeableBoundary ()) where {NF} = SoilBC (energy, hydrology)
89+ default_lowerbc (:: SoilEnergyBalance ) = GeothermalHeatFlux ()
90+ default_lowerbc (:: SoilHydrology{NF, NoFlow} ) where {NF} = nothing
91+ default_lowerbc (:: SoilHydrology ) = ImpermeableBoundary ()
0 commit comments