Skip to content

Commit

Permalink
Change reservoir parameters to standard names
Browse files Browse the repository at this point in the history
  • Loading branch information
vers-w committed Dec 11, 2024
1 parent dcf33a1 commit 6273378
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 69 deletions.
19 changes: 9 additions & 10 deletions server/test/sbm_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ river_bank_water__elevation = "RiverZ"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_areas__number = "wflow_reservoirareas"
reservoir_locations__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
reservoir_water__max_volume = "ResMaxVolume"
"reservoir_water~full-target__volume_fraction" = "ResTargetFullFrac"
"reservoir_water~min-target__volume_fraction" = "ResTargetMinFrac"

# specify the internal IDs of the parameters which vary over time
# the external name mapping needs to be below together with the other mappings
forcing = [
Expand All @@ -115,16 +124,6 @@ netcdf.variable.name = "KsatVer"
scale = 1.0
offset = 0.0

[input.lateral.river.reservoir]
area = "ResSimpleArea"
areas = "wflow_reservoirareas"
demand = "ResDemand"
locs = "wflow_reservoirlocs"
maxrelease = "ResMaxRelease"
maxvolume = "ResMaxVolume"
targetfullfrac = "ResTargetFullFrac"
targetminfrac = "ResTargetMinFrac"

[input.lateral.subsurface]
ksathorfrac = "KsatHorFrac"

Expand Down
16 changes: 8 additions & 8 deletions src/routing/reservoir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
reslocs = ncread(
dataset,
config,
"lateral.river.reservoir.locs";
"reservoir_locations__number";
optional = false,
sel = indices_river,
type = Int,
Expand All @@ -27,7 +27,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
rescoverage_2d = ncread(
dataset,
config,
"lateral.river.reservoir.areas";
"reservoir_areas__number";
optional = false,
allow_missing = true,
)
Expand Down Expand Up @@ -60,7 +60,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
resdemand = ncread(
dataset,
config,
"lateral.river.reservoir.demand";
"reservoir_water_demand~required~downstream__volume_flow_rate";
optional = false,
sel = inds_res,
type = Float,
Expand All @@ -69,7 +69,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
resmaxrelease = ncread(
dataset,
config,
"lateral.river.reservoir.maxrelease";
"reservoir_water_release-below-spillway__max_volume_flow_rate";
optional = false,
sel = inds_res,
type = Float,
Expand All @@ -78,7 +78,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
resmaxvolume = ncread(
dataset,
config,
"lateral.river.reservoir.maxvolume";
"reservoir_water__max_volume";
optional = false,
sel = inds_res,
type = Float,
Expand All @@ -87,7 +87,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
resarea = ncread(
dataset,
config,
"lateral.river.reservoir.area";
"reservoir_surface__area";
optional = false,
sel = inds_res,
type = Float,
Expand All @@ -96,7 +96,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
res_targetfullfrac = ncread(
dataset,
config,
"lateral.river.reservoir.targetfullfrac";
"reservoir_water~full-target__volume_fraction";
optional = false,
sel = inds_res,
type = Float,
Expand All @@ -105,7 +105,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
res_targetminfrac = ncread(
dataset,
config,
"lateral.river.reservoir.targetminfrac";
"reservoir_water~min-target__volume_fraction";
optional = false,
sel = inds_res,
type = Float,
Expand Down
2 changes: 1 addition & 1 deletion src/routing/surface_local_inertial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ function FloodPlainProfile(dataset, config, indices; river_width, river_length,
volume = ncread(
dataset,
config,
"lateral.river.floodplain.volume";
"floodplain_water__sum_of_volume-per-depth";
sel = indices,
type = Float,
dimname = :flood_depth,
Expand Down
14 changes: 7 additions & 7 deletions src/sbm_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function initialize_sbm_model(config::Config)
do_reservoirs = get(config.model, "reservoirs", false)::Bool
do_lakes = get(config.model, "lakes", false)::Bool
do_pits = get(config.model, "pits", false)::Bool
do_subsurface_flow = get(config.model, "kinematic-wave_subsurface", true)::Bool

routing_options = ("kinematic-wave", "local-inertial")
river_routing = get_options(
Expand Down Expand Up @@ -131,10 +132,9 @@ function initialize_sbm_model(config::Config)
flow_length = map(get_flow_length, ldd, x_length, y_length)
flow_width = (x_length .* y_length) ./ flow_length

# check if lateral subsurface flow component is defined for the SBM model, when coupled
# to another groundwater model, this component is not defined in the TOML file.
do_lateral_ssf = haskey(config.input.lateral, "subsurface")
if do_lateral_ssf
# check if lateral subsurface flow is included, when coupled to another groundwater
# model, this component is not defined in the TOML file.
if do_subsurface_flow
subsurface_flow = LateralSSF(
dataset,
config,
Expand Down Expand Up @@ -259,10 +259,10 @@ function initialize_sbm_model(config::Config)
toposort = topological_sort_by_dfs(graph)
if land_routing == "kinematic-wave" ||
river_routing == "kinematic-wave" ||
do_lateral_ssf
do_subsurface_flow
streamorder = stream_order(graph, toposort)
end
if land_routing == "kinematic-wave" || do_lateral_ssf
if land_routing == "kinematic-wave" || do_subsurface_flow
toposort = topological_sort_by_dfs(graph)
land_pit_inds = findall(x -> x == 5, ldd)
min_streamorder_land = get(config.model, "min_streamorder_land", 5)
Expand Down Expand Up @@ -291,7 +291,7 @@ function initialize_sbm_model(config::Config)
if nthreads() > 1
if river_routing == "kinematic-wave"
@info "Parallel execution of kinematic wave" min_streamorder_land min_streamorder_river
elseif land_routing == "kinematic-wave" || do_lateral_ssf
elseif land_routing == "kinematic-wave" || do_subsurface_flow
@info "Parallel execution of kinematic wave" min_streamorder_land
end
end
Expand Down
5 changes: 4 additions & 1 deletion src/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ function extract_required_states(config::Config)
# Subsurface states
if model_type == "sbm_gwf"
ssf_states = (:head,)
elseif model_type == "sediment"
ssf_states = nothing
else
ssf_states = haskey(config.input.lateral, "subsurface") ? (:ssf,) : nothing
do_subsurface_flow = get(config.model, "kinematic-wave_subsurface", true)::Bool
ssf_states = do_subsurface_flow ? (:ssf,) : nothing
end

# Land states
Expand Down
2 changes: 1 addition & 1 deletion test/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ end

# Final run to test error handling during simulation
tomlpath_error = joinpath(@__DIR__, "sbm_simple-error.toml")
config.input.lateral.river.width = Dict(
config.input.river__width = Dict(
"scale" => 0.0,
"offset" => 0.0,
"netcdf" => Dict("variable" => Dict("name" => "wflow_riverwidth")),
Expand Down
2 changes: 1 addition & 1 deletion test/run_sbm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ config = Wflow.Config(tomlpath)
config.model.floodplain_1d = true
config.model.river_routing = "local-inertial"
config.model.land_routing = "kinematic-wave"
Dict(config.input.lateral.river)["floodplain"] = Dict("volume" => "floodplain_volume")
config.input["floodplain_water__sum_of_volume-per-depth"] = "floodplain_volume"
Dict(config.state.lateral.river)["floodplain.variables"] =
Dict("q" => "q_floodplain", "h" => "h_floodplain")

Expand Down
19 changes: 9 additions & 10 deletions test/sbm_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ river_bank_water__elevation = "RiverZ"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_areas__number = "wflow_reservoirareas"
reservoir_locations__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
reservoir_water__max_volume = "ResMaxVolume"
"reservoir_water~full-target__volume_fraction" = "ResTargetFullFrac"
"reservoir_water~min-target__volume_fraction" = "ResTargetMinFrac"

# specify the internal IDs of the parameters which vary over time
# the external name mapping needs to be below together with the other mappings
forcing = [
Expand All @@ -115,16 +124,6 @@ netcdf.variable.name = "KsatVer"
scale = 1.0
offset = 0.0

[input.lateral.river.reservoir]
area = "ResSimpleArea"
areas = "wflow_reservoirareas"
demand = "ResDemand"
locs = "wflow_reservoirlocs"
maxrelease = "ResMaxRelease"
maxvolume = "ResMaxVolume"
targetfullfrac = "ResTargetFullFrac"
targetminfrac = "ResTargetMinFrac"

[input.lateral.subsurface]
ksathorfrac = "KsatHorFrac"

Expand Down
20 changes: 10 additions & 10 deletions test/sbm_gw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ river__width = "wflow_riverwidth"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_areas__number = "wflow_reservoirareas"
reservoir_locations__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
reservoir_water__max_volume = "ResMaxVolume"
"reservoir_water~full-target__volume_fraction" = "ResTargetFullFrac"
"reservoir_water~min-target__volume_fraction" = "ResTargetMinFrac"

# specify the internal IDs of the parameters which vary over time
# the external name mapping needs to be below together with the other mappings
forcing = [
Expand All @@ -103,22 +112,13 @@ potential_evaporation = "pet"
precipitation = "precip"
temperature = "temp"

[input.lateral.river.reservoir]
area = "ResSimpleArea"
areas = "wflow_reservoirareas"
demand = "ResDemand"
locs = "wflow_reservoirlocs"
maxrelease = "ResMaxRelease"
maxvolume = "ResMaxVolume"
targetfullfrac = "ResTargetFullFrac"
targetminfrac = "ResTargetMinFrac"

[model]
kin_wave_iteration = true
masswasting = true
reinit = true
reservoirs = true
snow = true
kinematic-wave_subsurface = false
thicknesslayers = [100, 300, 800]
type = "sbm"

Expand Down
19 changes: 9 additions & 10 deletions test/sbm_simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ river__width = "wflow_riverwidth"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_areas__number = "wflow_reservoirareas"
reservoir_locations__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
reservoir_water__max_volume = "ResMaxVolume"
"reservoir_water~full-target__volume_fraction" = "ResTargetFullFrac"
"reservoir_water~min-target__volume_fraction" = "ResTargetMinFrac"

# specify the internal IDs of the parameters which vary over time
# the external name mapping needs to be below together with the other mappings
forcing = [
Expand All @@ -75,16 +84,6 @@ potential_evaporation = "pet"
precipitation = "precip"
temperature = "temp"

[input.lateral.river.reservoir]
area = "ResSimpleArea"
areas = "wflow_reservoirareas"
demand = "ResDemand"
locs = "wflow_reservoirlocs"
maxrelease = "ResMaxRelease"
maxvolume = "ResMaxVolume"
targetfullfrac = "ResTargetFullFrac"
targetminfrac = "ResTargetMinFrac"

[input.lateral.subsurface]
ksathorfrac = "KsatHorFrac"

Expand Down
19 changes: 9 additions & 10 deletions test/sbm_swf_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ land_surface_water_flow__manning_n_parameter = "N"
land_surface_water_flow__ground_elevation = "FloodplainZ"
land_surface__slope = "Slope"

reservoir_areas__number = "wflow_reservoirareas"
reservoir_locations__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
reservoir_water__max_volume = "ResMaxVolume"
"reservoir_water~full-target__volume_fraction" = "ResTargetFullFrac"
"reservoir_water~min-target__volume_fraction" = "ResTargetMinFrac"

# specify the internal IDs of the parameters which vary over time
# the external name mapping needs to be below together with the other mappings
forcing = [
Expand All @@ -107,16 +116,6 @@ potential_evaporation = "pet"
precipitation = "precip"
temperature = "temp"

[input.lateral.river.reservoir]
area = "ResSimpleArea"
areas = "wflow_reservoirareas"
demand = "ResDemand"
locs = "wflow_reservoirlocs"
maxrelease = "ResMaxRelease"
maxvolume = "ResMaxVolume"
targetfullfrac = "ResTargetFullFrac"
targetminfrac = "ResTargetMinFrac"

[input.lateral.subsurface]
ksathorfrac = "KsatHorFrac"

Expand Down

0 comments on commit 6273378

Please sign in to comment.