Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add floodplain discharge to inflow reservoirs and lakes #368

Merged
merged 9 commits into from
Mar 13, 2024
2 changes: 2 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
lake storage. The variable `actevap` has also been added to the reservoir module.
- The `set_states` function for model type `sbm` with local inertial routing for river and
land component.
- Inflow to reservoir and lake locations for local inertial routing with floodplain routing,
the floodplain discharge was not added to the inflow of these locations.

### Changed
- Stop exposing scalar variables through BMI. The `BMI.get_value_ptr` function was
Expand Down
25 changes: 12 additions & 13 deletions src/flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -688,24 +688,23 @@ function shallowwater_river_update(
# local inertial model (fixed h).
for v in eachindex(sw.reservoir_index)
i = sw.reservoir_index[v]
update(
sw.reservoir,
v,
sum_at(sw.q0, links_at_node.src[i]) + inflow_wb[i] + sw.inflow_wb[i],
Δt,
)

q_in = sum_at(sw.q0, links_at_node.src[i])
if !isnothing(sw.floodplain)
q_in = q_in + sum_at(sw.floodplain.q0, links_at_node.src[i])
end
update(sw.reservoir, v, q_in + inflow_wb[i] + sw.inflow_wb[i], Δt)
sw.q[i] = sw.reservoir.outflow[v]
sw.q_av[i] += sw.q[i] * Δt
end
for v in eachindex(sw.lake_index)
i = sw.lake_index[v]
update(
sw.lake,
v,
sum_at(sw.q0, links_at_node.src[i]) + inflow_wb[i] + sw.inflow_wb[i],
doy,
Δt,
)

q_in = sum_at(sw.q0, links_at_node.src[i])
if !isnothing(sw.floodplain)
q_in = q_in + sum_at(sw.floodplain.q0, links_at_node.src[i])
end
update(sw.lake, v, q_in + inflow_wb[i] + sw.inflow_wb[i], doy, Δt)
sw.q[i] = sw.lake.outflow[v]
sw.q_av[i] += sw.q[i] * Δt
end
Expand Down
Loading