Skip to content

Commit

Permalink
Use one struct for non-irrigation demand
Browse files Browse the repository at this point in the history
  • Loading branch information
vers-w committed May 15, 2024
1 parent 6b06b96 commit 3b1aa36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/sbm.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@get_units @exchange @grid_type @grid_location @with_kw struct SBM{T,N,M,P,NP,D,L,I,W}
@get_units @exchange @grid_type @grid_location @with_kw struct SBM{T,N,M,P,NP,NI,W}
# Model time step [s]
dt::T | "s" | 0 | "none" | "none"
# Maximum number of soil layers
Expand Down Expand Up @@ -227,13 +227,13 @@
# Water demand structs (of arrays)
paddy::P | "-" | 0
nonpaddy::NP | "-" | 0
domestic::D | "-" | 0
livestock::L | "-" | 0
industry::I | "-" | 0
domestic::NI | "-" | 0
livestock::NI | "-" | 0
industry::NI | "-" | 0
waterallocation::W | "-" | 0


function SBM{T,N,M,P,NP,D,L,I,W}(args...) where {T,N,M,P,NP,D,L,I,W}
function SBM{T,N,M,P,NP,NI,W}(args...) where {T,N,M,P,NP,NI,W}
equal_size_vectors(args)
return new(args...)
end
Expand Down
26 changes: 6 additions & 20 deletions src/water_demand.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
@get_units @exchange @grid_type @grid_location @with_kw struct Industry{T}
demand_gross::Vector{T} # gross industry water demand [mm Δt⁻¹]
demand_net::Vector{T} # net industry water demand [mm Δt⁻¹]
returnflow_fraction::Vector{T} | "-" # return flow fraction [-]
returnflow::Vector{T} # return flow [mm Δt⁻¹]
end

@get_units @exchange @grid_type @grid_location @with_kw struct Domestic{T}
demand_gross::Vector{T} # gross domestic water demand [mm Δt⁻¹]
demand_net::Vector{T} # net domestic water demand [mm Δt⁻¹]
returnflow_fraction::Vector{T} | "-" # return flow fraction [-]
returnflow::Vector{T} # return flow [mm Δt⁻¹]
end

@get_units @exchange @grid_type @grid_location @with_kw struct Livestock{T}
demand_gross::Vector{T} # gross livestock water demand [mm Δt⁻¹]
demand_net::Vector{T} # net livestock water demand [mm Δt⁻¹]
@get_units @exchange @grid_type @grid_location @with_kw struct NonIrrigationDemand{T}
demand_gross::Vector{T} # gross water demand [mm Δt⁻¹]
demand_net::Vector{T} # net water demand [mm Δt⁻¹]
returnflow_fraction::Vector{T} | "-" # return flow fraction [-]
returnflow::Vector{T} # return flow [mm Δt⁻¹]
end
Expand Down Expand Up @@ -95,7 +81,7 @@ function initialize_domestic_demand(nc, config, inds, dt)
n = length(inds)
returnflow_fraction = set_returnflow_fraction(fill(mv, n), demand_gross, demand_net)

domestic = Domestic{Float}(
domestic = NonIrrigationDemand{Float}(
demand_gross = demand_gross,
demand_net = demand_net,
returnflow_fraction = returnflow_fraction,
Expand Down Expand Up @@ -128,7 +114,7 @@ function initialize_industry_demand(nc, config, inds, dt)
n = length(inds)
returnflow_fraction = set_returnflow_fraction(fill(mv, n), demand_gross, demand_net)

industry = Industry{Float}(
industry = NonIrrigationDemand{Float}(
demand_gross = demand_gross,
demand_net = demand_net,
returnflow_fraction = returnflow_fraction,
Expand Down Expand Up @@ -161,7 +147,7 @@ function initialize_livestock_demand(nc, config, inds, dt)
n = length(inds)
returnflow_fraction = set_returnflow_fraction(fill(mv, n), demand_gross, demand_net)

livestock = Livestock{Float}(
livestock = NonIrrigationDemand{Float}(
demand_gross = demand_gross,
demand_net = demand_net,
returnflow_fraction = returnflow_fraction,
Expand Down

0 comments on commit 3b1aa36

Please sign in to comment.