Skip to content

Replace trueimpes' hard-coded pressure_scale with row equilibration - #7285

Draft
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:pr/trueimpes-row-equilibration
Draft

hnil wants to merge 1 commit into
OPM:masterfrom
hnil:pr/trueimpes-row-equilibration

Conversation

@hnil

@hnil hnil commented Aug 6, 2026

Copy link
Copy Markdown
Member

The 50e5 factor on the pressure row of the local trueimpes solve is a no-op in exact arithmetic: the rhs is a unit vector, so any row scaling cancels in the abs_max normalisation. Replace it with a power-of-two equilibration of all rows, which conditions the small dense solve without a magic constant.

Shows the effect (weights unchanged, so iteration counts move only at pivoting-noise level):

flow SPE1CASE1.DATA --linear-solver=cprw

SPE1CASE1 cprw 443 -> 437 and SPE9_CP unchanged at 439; the trueimpes CPR path via an explicit JSON gives 383/322/445 -> 376/317/440.

🤖 Generated with Claude Code

@hnil hnil added the manual:enhancement This is an enhancement/improvent that needs to be documented in the manual label Aug 7, 2026
@hnil
hnil marked this pull request as draft August 7, 2026 15:35
@hnil
hnil force-pushed the pr/trueimpes-row-equilibration branch 2 times, most recently from 4459366 to 7b958f9 Compare August 11, 2026 12:06
The 50e5 factor on the pressure row of block_transpose was a no-op in exact
arithmetic: the rhs of the local solve is a unit vector, so scaling row p by
s yields w = B^-T e_p / s, and the subsequent abs_max normalisation divides
the factor straight back out. Its only effect was to condition the small
dense solve, since the pressure row of a storage derivative is tiny relative
to the others.

Equilibrate all rows to unit max magnitude instead, with power-of-two
factors so the scaling introduces no rounding. Same cancellation argument,
no magic constant, and every row is conditioned rather than just the
pressure one. Verified behaviour-neutral on SPE1CASE1 (trueimpes
383/322/445 -> 376/317/440; default cprw 443 -> 437 - pivoting noise).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hnil

hnil commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

jenkins build this please

@hnil
hnil force-pushed the pr/trueimpes-row-equilibration branch from 7b958f9 to 400d4d9 Compare September 18, 2026 07:26
for (int jj = 0; jj < numEq; ++jj) {
double rowmax = 0.0;
for (int ii = 0; ii < numEq; ++ii) {
rowmax = std::max(rowmax, std::fabs(block_transpose[jj][ii]));

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.

Note: rowmax is a double here, whereas block_transpose[jj][ii] is the element type of a MatrixBlockType. If those two are not the same, then this statement will fail to compile since there is no overload of std::max() that accepts inputs of different types.

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

Labels

manual:enhancement This is an enhancement/improvent that needs to be documented in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants