diff --git a/TPFA_ResSim/__init__.py b/TPFA_ResSim/__init__.py index eb50d2c..12d3432 100644 --- a/TPFA_ResSim/__init__.py +++ b/TPFA_ResSim/__init__.py @@ -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 @@ -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)