Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Changed MeanFlow objective to minimizing mass balance error
Browse files Browse the repository at this point in the history
  • Loading branch information
kandread committed Sep 23, 2019
1 parent 8026247 commit 5cd281b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions confluence/integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ def objective(self, x):
for r in range(self.nreaches)]).T
else:
dA = np.mean(dA, axis=0)
Q0 = 1 / self.n * (self.A0 + dA)**(5 / 3) * w**(-2 / 3) * np.mean(
S, axis=0)**(1 / 2)
Q = 1 / n * (A0 + dA)**(5 / 3) * w**(-2 / 3) * np.mean(S,
axis=0)**(1 / 2)
return np.sum((Q - np.mean(Q0))**2)
error = [np.sqrt((Q[i] - np.sum(Q[j] for j in self.rivs[i]))**2) for i in self.rivs]
return np.sum(error)

def constraint(self, i, x):
"""Constrain discharge to increase downstream."""
Expand All @@ -67,7 +66,7 @@ def constraint(self, i, x):
dA = np.mean(dA, axis=0)
Q = 1 / n * (A0 + dA)**(5 / 3) * w**(-2 / 3) * np.mean(S,
axis=0)**(1 / 2)
return Q[i] - Q[i + 1]
return Q[i] - np.sum([Q[j] for j in self.rivs[i]])

def integrate(self):
"""Integrate discharge by forcing mean annual
Expand Down

0 comments on commit 5cd281b

Please sign in to comment.