Skip to content

Name the cell when the IMPES storage matrix is singular - #7264

Open
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:bugfix/impes-weights-singular-cell
Open

Name the cell when the IMPES storage matrix is singular#7264
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:bugfix/impes-weights-singular-cell

Conversation

@hnil

@hnil hnil commented Jul 31, 2026

Copy link
Copy Markdown
Member

A cell whose storage-derivative matrix is singular makes getTrueImpesWeights() throw, and since solver setup is wrapped in OPM_CATCH_AND_RETHROW_AS_CRITICAL_ERROR the run dies pointing at the linear-solver JSON, which is not the problem:

Original error: getTrueImpesWeights() failed: FMatrixError [luDecomposition]: matrix is singular
Error hint: This is likely due to a faulty linear solver JSON specification.

Now:

Original error: getTrueImpesWeights() failed: Singular storage matrix when forming the CPR
pressure weights for cell 688 (Cartesian index 688).  The storage derivatives of that cell
are rank deficient, so the pressure equation cannot be formed there.

Diagnostic only — it still fails, but says where. Reproduced on spe1_precsalt/GASCONDENSATE_VAPWAT_PRECSALT; why that cell is rank deficient is still open.

An earlier version substituted bweights = rhs instead of throwing. That was wrong: bweights is indexed by equation and rhs by primary variable, so it put unit weight on whichever equation shares the pressure variable index — and that fed a singular pressure system into the CPR setup, which is exactly the follow-on failure the first version ran into.

Separately: the "faulty linear solver JSON specification" hint is misleading for every non-configuration failure caught by that macro — worth revisiting, not touched here.

@hnil
hnil requested a review from akva2 July 31, 2026 14:09
@hnil hnil added the manual:bugfix This PR is a bug fix and should be noted in the manual label Jul 31, 2026
@hnil
hnil marked this pull request as ready for review July 31, 2026 14:09
// The storage derivatives of this cell carry no
// information about how to combine the mass balances -
// seen on gas condensate with vaporised water and
// precipitated salt. Weight the pressure equation alone

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand this sentence, what is meant by "Weight the pressure equation alone"? And it seems this would not throw and thereby chop the step, also what does that have to do with degenerate cells?

@hnil
hnil force-pushed the bugfix/impes-weights-singular-cell branch from ad2baf9 to a6b19f4 Compare August 4, 2026 09:34
@hnil

hnil commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Fair — two of the three claims in that comment were wrong. Catching the exception means nothing throws, so the step is not chopped, and the "degenerate cell" framing was hand-waving.

Cut it back to what the code does: on a singular storage matrix, fall back to rhs, which is the unit vector at pressureVarIndex — the unweighted pressure equation. Warning text matches now.

I do not have a real explanation for why the storage matrix is singular on that deck, so I have not tried to write one.

A cell whose storage-derivative matrix is singular makes
getTrueImpesWeights() throw, and since solver setup is wrapped in
OPM_CATCH_AND_RETHROW_AS_CRITICAL_ERROR the run dies pointing at the
linear-solver JSON, which is not the problem:

  Original error: getTrueImpesWeights() failed:
      FMatrixError [luDecomposition]: matrix is singular

Catch the FMatrixError and rethrow with the offending cell identified,
so the deck can be investigated:

  Original error: getTrueImpesWeights() failed: Singular storage matrix
      when forming the CPR pressure weights for cell 688 (Cartesian
      index 688).  The storage derivatives of that cell are rank
      deficient, so the pressure equation cannot be formed there.

No fallback weight is substituted.  bweights is indexed by equation
while rhs is indexed by primary variable, so copying rhs would put unit
weight on whichever equation happens to share the pressure variable's
index -- an arbitrary choice, and one that goes on to make the CPR
pressure system itself singular.

Reproduced on spe1_precsalt/GASCONDENSATE_VAPWAT_PRECSALT, which is
where the singular matrix was found.  Why the storage derivatives are
rank deficient on that deck is still open; this only makes the failure
say where to look.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hnil
hnil force-pushed the bugfix/impes-weights-singular-cell branch from a6b19f4 to 82d2263 Compare August 4, 2026 10:12
@hnil hnil changed the title Survive a singular local storage matrix in the IMPES weights Name the cell when the IMPES storage matrix is singular Aug 4, 2026
@hnil

hnil commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Reworked: it now throws with the cell identified instead of substituting a weight.

The fallback was wrong, not just badly commented — bweights is indexed by equation and rhs by primary variable, so bweights = rhs put unit weight on whichever equation happens to share the pressure variable's index. That is what made the pressure system singular further down, which is the follow-on failure the first version hit.

So this is diagnostic only now: same failure, but it names the cell rather than blaming the solver JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:bugfix This PR is a bug fix and should be noted in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants