Skip to content

Commit

Permalink
Consolidate error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
patnr committed Sep 29, 2023
1 parent b5486e2 commit 6a4d065
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions TPFA_ResSim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ def _set_Q(self, k):
rates = rates[:, 0]
else:
rates = rates[:, k]
assert len(rates) == len(xys), "Mismatch in rate specification"

for xy, q in zip(xys, rates):
# Use += in case of superimposed wells (e.g. by optimzt)
Q[self.xy2ind(*xy)] += sign * q
assert np.isclose(Q.sum(), 0), "(Inj - Prod) does not sum to 0"
self._Q = Q

# Pres() -- listing 5
Expand Down Expand Up @@ -318,6 +316,16 @@ def time_stepper(self, dt, implicit=False):
"""
def integrate(S, k):
self._set_Q(k)

# Catch some common issues, usually due to history matched params.
# For example, mass imblance is insidiously silent (inputs deficit in SW corner)
# but most would cause a (harder to debug) exception further down the line.
assert len(self.inj_rates) == len(self.inj_xy)
assert len(self.prod_rates) == len(self.prod_xy)
assert np.isclose(self._Q.sum(), 0), "(Inj - Prod) does not sum to 0"
assert np.all((0 <= self.K ) & np.isfinite(self.K))
assert np.all((0 <= self.por) & (self.por <= 1))

[P, V] = self.pressure_step(S)
if implicit:
S = self.saturation_step_implicit(S, V, dt)
Expand Down

0 comments on commit 6a4d065

Please sign in to comment.