-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy patherosion.jl
More file actions
79 lines (70 loc) · 2.42 KB
/
Copy patherosion.jl
File metadata and controls
79 lines (70 loc) · 2.42 KB
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
"Soil loss model"
@kwdef struct SoilLossModel{
RE <: AbstractRainfallErosionModel,
OFE <: AbstractOverlandFlowErosionModel,
SE <: AbstractSoilErosionModel,
} <: AbstractLandModel
atmospheric_forcing::AtmosphericForcing
hydrological_forcing::HydrologicalForcing
rainfall_erosion::RE
overland_flow_erosion::OFE
soil_erosion::SE
end
"Initialize soil loss model"
function SoilLossModel(
dataset::NCDataset,
config::Config,
indices::Vector{CartesianIndex{2}},
)
(; rainfall_erosion, overland_flow_erosion) = config.model
n = length(indices)
atmospheric_forcing = AtmosphericForcing(; n)
hydrological_forcing = HydrologicalForcing(; n)
# Rainfall erosion
if rainfall_erosion == RainfallErosionType.answers
rainfall_erosion = RainfallErosionAnswersModel(dataset, config, indices)
elseif rainfall_erosion == RainfallErosionType.eurosem
rainfall_erosion = RainfallErosionEurosemModel(dataset, config, indices)
end
# Overland flow erosion
overland_flow_erosion = OverlandFlowErosionAnswersModel(dataset, config, indices)
# Total soil erosion and particle differentiation
soil_erosion = SoilErosionModel(dataset, config, indices)
soil_loss = SoilLossModel(;
atmospheric_forcing,
hydrological_forcing,
rainfall_erosion,
overland_flow_erosion,
soil_erosion,
)
return soil_loss
end
"Update soil loss model for a single timestep"
function update_soil_loss_model!(
soil_loss_model::SoilLossModel,
parameters::LandParameters,
dt::Float64,
)
(;
atmospheric_forcing,
hydrological_forcing,
rainfall_erosion,
overland_flow_erosion,
soil_erosion,
) = soil_loss_model
#TODO add interception/canopy_gap_fraction calculation here for eurosem
#need SBM refactor
# Rainfall erosion
update_bc_rainfall_erosion_model!(
rainfall_erosion,
atmospheric_forcing,
hydrological_forcing,
)
update_rainfall_erosion_model!(rainfall_erosion, parameters, dt)
# Overland flow erosion
update_bc_overland_flow_erosion_model!(overland_flow_erosion, hydrological_forcing)
update_overland_flow_erosion_model!(overland_flow_erosion, parameters, dt)
# Total soil erosion and particle differentiation
update_bc_soil_erosion_model!(soil_erosion, rainfall_erosion, overland_flow_erosion)
update_soil_erosion_model!(soil_erosion)
end