Skip to content

Compositional rate producer: a BHP Newton update above the completion pressures makes the rate row singular (SPE3 failed attempts) #163

Done

Description

@sergeyfarin

Outcome

A rate-controlled compositional producer whose Newton BHP update overshoots above its completion cells' pressures does not end the attempt with a singular rate row. Either the update is bounded, or the iterate is handled as the control law intends. SPE3's monthly reports then stop paying one to three failed attempts each.

Current behavior and evidence

Found in #157's SPE3 full-horizon replay, after #162's Schur fix (branch test/157-spe3-full-horizon-replay, release build). From month 11 (304 d) onward, many reports fail their first one or two attempts at Newton iteration 3 with:

assembly failed: well PROD: its rate-control row has d(rate)/d(bhp) = 0e0, so the BHP unknown cannot be eliminated

An instrumented scratch run, which prints the well when that derivative is exactly zero, shows the iterate. The producer's BHP had moved to 238.85, 235.85 and 245.78 bar, above both completion cells, while the accepted BHP was about 233 bar against a 6,200 Mscf/d target. Both completions (cells 222 and 303) then report zero component rates and zero bhp_derivative. The surface-rate gradient is all zero, achieved = 0 against target −175,564 m³/d, and reduce_well_unknowns (compositional/assembly.rs, WellConstraintSingular) rejects the row. The timestep halves (30.4 → 15.2 → 7.6 d, or 22.8 → 11.4 d), and the shorter attempt converges in 5–6 iterations. Months 11–18 cost 3 accepted steps and 3 failed attempts each. Later months mostly cost 1 failed attempt or none.

So a producer connection with a reversed potential contributes zero flow (no crossflow error), which makes the rate's derivative with respect to BHP vanish exactly. The Newton BHP update, recovered from the Schur row as dx_w = J_ww^-1 (-R_w - J_wc dx_c), is not bounded, so a single overshoot ends the attempt.

Scope

  • compositional/newton.rs (BHP update and its step bound) and compositional/wells.rs / assembly.rs (the rate row at a no-flow iterate).
  • Options for the owner:
    • (a) Bound a producer's BHP update so it stays below its highest connection-cell pressure, and an injector's above its lowest, with the same appliance as the cell update's fraction-to-boundary.
    • (b) At a no-flow iterate, drop to the control's BHP-limit or connection-pressure bound for that iteration rather than failing.
    • (c) A BHP-update damping rule like OPM's StandardWell (dBHP limit per iteration).
  • A failing named comp_well_ or comp_newton_ test: a two-completion rate producer whose first Newton update overshoots, from the frozen month-11 state or a small synthetic column.

Out of scope: crossflow policy, tolerances, the timestep ladder.

Acceptance

  • The named test fails today and passes after the change.
  • The SPE3 replay (comp_spe3_full_horizon_replay) records fewer failed attempts, with the numbers before and after recorded in docs/SPE3_VALIDATION.md.
  • Cases that never overshoot are bit-identical: the SPE5 shut-in replay still stops at 6285.34375 d with water cut 0.8344920492842325.

Validation gate

bash scripts/validate-compositional.sh all
cargo test --release --manifest-path src/lib/ressim/Cargo.toml --lib comp_spe3_full_horizon_replay -- --ignored --nocapture
cargo test --release --manifest-path src/lib/ressim/Cargo.toml --lib comp_spe5_case1_stops_at_the_published_shut_in -- --ignored --nocapture
bash scripts/validate-cross-solver.sh
bash scripts/benchmarks.sh check

Found in #157. Related: #162, #155 (runtime), #52.


Generated by Claude Code

Activity

  1. added
    bug
    priority:P2
    area:engine
    on Nov 29, 2026
  2. sergeyfarin commented on Nov 29, 2026

    @sergeyfarin
    OwnerAuthor

    Classification of every failed attempt in SPE3 years 1–3 (attempt-level trace on a scratch copy of the #157 branch, with the #162 fix; the counts match the recorded run's 6 / 26 / 14): 41 of 46 are this singular rate row. The others are 3 separator stability failures (#164; a shorter step recovered from them here) and 2 producer completion crossflow rejections. Months 1–10 have no failed attempt at all. So this one mechanism is most of SPE3's retry cost before the blowdown.


    Generated by Claude Code

  3. sergeyfarin commented on Dec 2, 2026

    @sergeyfarin
    OwnerAuthor

    A one-cell reproduction, found while probing #175 for #176 on 22a5aff4 (uncommitted probe, default NewtonOptions):

    • ternary at 100 bar, z = [0, 0.3];
    • one producer, PI 1, MolarRate { target_mol_per_day: -0.02 * total, bhp_limit_bar: 10 }, dt = 1.

    The first step is a full one (step_scale_history = [1.0]). The next assembly then fails with well PROD: its rate-control row has d(rate)/d(bhp) = 0e0, so the BHP unknown cannot be eliminated. The well bound has no constraint keeping a producer's BHP below its completion pressures, which matches this issue's diagnosis. In a sweep of 1944 one-cell default-start solves, 101 ended this way, mostly at small targets (0.01–0.05 × total/day).

  4. sergeyfarin commented on Dec 2, 2026

    @sergeyfarin
    OwnerAuthor

    Acceptance note for PR #178: the item "the SPE5 shut-in replay still stops at 6285.34375 d with water cut 0.8344920492842325" is met on the stop (6285.34375 d, report 1239, water cut) but not bit for bit on the water cut, which is now 0.8344891317395606. This is a deliberate, recorded exception. SPE5 never overshot a completion, but its BHP limit bound was active: that was the #175 creep behind its four former halvings. Every iteration where that bound activated now takes a different step. "Unchanged" is now defined by which bounds activate (compositional/newton.rs module docs; docs/COMPOSITIONAL_WELL_DESIGN.md, "The BHP update"; docs/SPE5_VALIDATION.md). Reproduced on acda250c: 1,239 steps / 0 failed / 6,226 Newton.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:enginebugpriority:P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions