Created
March 30, 2024 23:54
-
-
Save ramseyboy/b01ab53134157bc692accc083d0f15db to your computer and use it in GitHub Desktop.
Partial Stream Discharge Calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L = [.075, .225, .375, .525, .675] | |
d = [.1, .14, .13, .03, 0] | |
V = [.88, .75, .35, .07, 0] | |
i = 0 | |
partials = [] | |
def discharge(L: list[float], d: list[float], V: list[float], i: int, partials: list[float]): | |
if len(L) != len(d) != len(V): | |
raise ValueError("not same lengths") | |
if i == len(L): | |
print(partials) | |
return sum(partials) | |
print(f"i {i+1}") | |
Wi = width(L, i) | |
print(f"Wi {Wi}") | |
Ai = Wi * d[i] | |
print(f"Ai {Ai}") | |
Qi = V[i] * Ai | |
print(f"Qi {Qi}") | |
partials.append(Qi) | |
print("\n") | |
return discharge(L, d, V, i + 1, partials) | |
def width(L: list[float], i: int): | |
def check_index(to_check: int): | |
return to_check if 0 <= to_check < len(L) else i | |
return (L[check_index(i + 1)] - L[check_index(i - 1)]) / 2 | |
discharge(L, d, V, i, partials) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment