File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11import dataclasses
2+ import math
3+
24import pandas as pd
35
46
@@ -19,8 +21,8 @@ class ReservoirParams:
1921 max_generation (float): The maximum power generation capacity (MW).
2022 turbine_factor (float): The efficiency factor of the turbine(s).
2123 inflow_ts (pd.Series): Timeseries of daily natural inflow into the reservoir (m³/day),
22- indexed from 1 to sim_horizon .
23- minflow_ts (pd.Series): Minimum environmental flow (m³/day), indexed from 1 to sim_horizon .
24+ indexed from 1.
25+ minflow_ts (pd.Series): Minimum environmental flow (m³/day), indexed from 1.
2426 upstream_units (list[str]): List of upstream reservoir names that feed into this reservoir.
2527 downstream_flow_fracs (dict[str, float]): Dictionary mapping downstream reservoir names to their
2628 respective flow fractions (0-1).
@@ -45,7 +47,9 @@ def __post_init__(self):
4547 """Perform basic validation after initialization."""
4648 # Flow fractions of downstream units should sum to 1
4749 if self .downstream_flow_fracs :
48- if not 0.999 <= sum (self .downstream_flow_fracs .values ()) <= 1.001 :
50+ if not math .isclose (
51+ sum (self .downstream_flow_fracs .values ()), 1.0 , abs_tol = 1e-4
52+ ):
4953 raise ValueError (
5054 f"Downstream units for { self .name } do not sum to 1: "
5155 f"{ self .downstream_flow_fracs } "
You can’t perform that action at this time.
0 commit comments