Skip to content

Commit

Permalink
Update water balance error definition (#1767)
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Aug 27, 2024
1 parent 3e70543 commit a8c6832
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 3 additions & 7 deletions core/src/write.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,9 @@ function basin_table(
storage_rate = Δstorage ./ Δtime

for i in 1:nrows
storage_flow = storage_rate[i]
storage_increase = max(storage_flow, 0.0)
storage_decrease = max(-storage_flow, 0.0)

total_in = inflow_rate[i] + precipitation[i] + drainage[i] - storage_increase
total_out = outflow_rate[i] + evaporation[i] + infiltration[i] - storage_decrease
balance_error[i] = total_in - total_out
total_in = inflow_rate[i] + precipitation[i] + drainage[i]
total_out = outflow_rate[i] + evaporation[i] + infiltration[i]
balance_error[i] = storage_rate[i] - (total_in - total_out)
mean_flow_rate = 0.5 * (total_in + total_out)
if mean_flow_rate != 0
relative_error[i] = balance_error[i] / mean_flow_rate
Expand Down
6 changes: 4 additions & 2 deletions docs/reference/usage.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ The Basin table contains:
It will be placed in a separate output state file in the future.
- The `inflow_rate` and `outflow_rate` are the sum of the flows from other nodes into and out of the Basin respectively.
The actual flows determine in which term they are counted, not the edge direction.
- The `storage_rate` is flow that adds to the storage in the Basin, increasing the water level. In the equations below this number is split out into two non-negative numbers, `storage_increase` and `storage_decrease`.
- The `balance_error` is the difference of all Basin inflows (`total_inflow`) and outflows (`total_outflow`), that is (`inflow_rate` + `precipitation` + `drainage` - `storage_increase`) - (`outflow_rate` + `evaporation` + `infiltration` - `storage_decrease`).
- The `storage_rate` is the net mean flow that is needed to achieve the storage change between timesteps.
- The `inflow_rate` consists of the sum of all modelled flows into the basin: `inflow_rate` (horizontal flows into the basin, independent of edge direction) + `precipitation` + `drainage`.
- The `outflow_rate` consists of the sum of all modelled flows out of the basin: `outflow_rate` (horizontal flows out of the basin, idependent of edge direction) + `evaporation` + `infiltration`.
- The `balance_error` is the difference between the `storage_rate` on one side and the `inflow_rate` and `outflow_rate` on the other side: `storage_rate` - (`inflow_rate` - `outflow_rate`).
It can be used to check if the numerical error when solving the water balance is sufficiently small.
- The `relative_error` is the fraction of the `balance_error` over the mean of the `total_inflow` and `total_outflow`.

Expand Down

0 comments on commit a8c6832

Please sign in to comment.