MSW: derive the shut-valve trivial-equation Jacobian entry from the rate - #7314
Draft
hnil wants to merge 1 commit into
Draft
MSW: derive the shut-valve trivial-equation Jacobian entry from the rate#7314hnil wants to merge 1 commit into
hnil wants to merge 1 commit into
Conversation
assembleTrivialEq, the zero-rate equation for a SHUT valve, wrote a physical rate as the residual but hard-coded its Jacobian entry as 1. The linear system solves for the scaled primary variable, so the entry has to be d(q)/d(q/s) = s; with a hard-coded 1 the Newton step for that segment comes back a factor s too small and is then multiplied by s on update. Pass the rate as an Evaluation and take the derivative from it, so the entry is correct by construction rather than by remembering to multiply. This was the only hard-coded derivative in either well assembler; every other entry already comes from an EvalWell and scales automatically. Latent until now because --well-rate-scaling defaults to 1 and every measurement so far used the default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A SHUT valve segment gets the trivial equation q = 0 in place of its pressure-drop relation, written into the segment pressure row.
assembleTrivialEqset the residual from the rate but hard-coded the Jacobian entry as1., i.e. dq/dq. That is only right while the rate primary variable is unscaled; with--well-rate-scaling=sthe primary variable is q/s and the entry must be s. Take it from the rate Evaluation instead, so it is correct by construction. This was the only hard-coded derivative in either well assembler.Effect: the linear solve returns an increment a factor s too small,
updateNewtonmultiplies by s, and the shut segment rate is multiplied by (1-s) every iteration instead of being zeroed.Reproducing needs a shut valve, which no deck in opm-tests currently has. Take
wsegvalv/BASE_MSW_WSEGVALV.DATAand set the status of one valve:then
The shut segment rate reads -3.86e-4, 1.16e-3, -3.48e-3, ... growing by (1-s) = -3 per iteration and reaching 9.96e+131 over the run; with this change it converges to zero in one iteration (max 3.9e-4 over the run). Summary output differs between the two.
Two related observations, not addressed here:
MultisegmentWellEval::getWellConvergencetests onlyisnan/isinf, with nomax_residual_allowedcomparison of the kind the mass-balance and energy branches have, so a finite 1e131 is reportedSeverity::Normalrather thanTooLarge- no timestep cut, no warning.tolerance_pressure_ms_wells(0.01 bar), so the trivial equation is never enforced tightly.🤖 Generated with Claude Code