Index: wflow-py/wflow/wflow_lib.py =================================================================== diff -u -r74c9106bc711c80b9496353805ce09ae7e90f317 -r1ac2ebed745d166f0cb0b082c0dc883b2078f0ce --- wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision 74c9106bc711c80b9496353805ce09ae7e90f317) +++ wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision 1ac2ebed745d166f0cb0b082c0dc883b2078f0ce) @@ -175,6 +175,63 @@ return storage, outflow, percfull, prec_av, pet_av, demandRelease / timestepsecs +def simplereservoir_routing( + storage, + inflow, + ResArea, + maxstorage, + target_perc_full, + maximum_Q, + demand, + minimum_full_perc, + ReserVoirLocs, + ReservoirSimpleAreas, + timestepsecs=86400, +): + """ + Adjusted simplereservoirs function for routing + (or when precip and evap are not available as input) + + :param storage: initial storage m^3 + :param inflow: inflow m^3/s + :param maxstorage: maximum storage (above which water is spilled) m^3 + :param target_perc_full: target fraction full (of max storage) - + :param maximum_Q: maximum Q to release m^3/s if below spillway + :param demand: water demand (all combined) m^3/s + :param minimum_full_perc: target minimum full fraction (of max storage) - + :param ReserVoirLocs: map with reservoir locations + :param timestepsecs: timestep of the model in seconds (default = 86400) + :return: storage (m^3), outflow (m^3/s), PercentageFull (0-1), Release (m^3/sec) + """ + + inflow = ifthen(boolean(ReserVoirLocs), inflow) + + oldstorage = storage + storage = ( + storage + + (inflow * timestepsecs) + ) + + percfull = ((storage + oldstorage) * 0.5) / maxstorage + # first determine minimum (environmental) flow using a simple sigmoid curve to scale for target level + fac = sCurve(percfull, a=minimum_full_perc, c=30.0) + demandRelease = min(fac * demand * timestepsecs, storage) + storage = storage - demandRelease + + # Re-determine percfull + percfull = ((storage + oldstorage) * 0.5) / maxstorage + + wantrel = max(0.0, storage - (maxstorage * target_perc_full)) + # Assume extra maximum Q if spilling + overflowQ = (percfull - 1.0) * (storage - maxstorage) + torelease = min(wantrel, overflowQ + maximum_Q * timestepsecs) + storage = storage - torelease + outflow = (torelease + demandRelease) / timestepsecs + percfull = storage / maxstorage + + return storage, outflow, percfull, demandRelease / timestepsecs + + def lookupResRegMatr(ReserVoirLocs, values, hq, JDOY): np_res_ids = pcr2numpy(ReserVoirLocs, 0)