Skip to content

Limit temperature Newton update for multisegment wells#6876

Closed
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-temperature-newton-update
Closed

Limit temperature Newton update for multisegment wells#6876
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-temperature-newton-update

Conversation

Copilot AI commented Feb 24, 2026

Copy link
Copy Markdown

PR #6816 adds thermal equation solving for MSW but applies the raw Newton update to temperature without any limiting, causing divergence. Pressure already uses sign-preserving clamping to max_pressure_change; temperature needs the same treatment.

Temperature limiting in updateNewton

Before (PR #6816):

value_[seg][Temperature] = old_primary_variables[seg][Temperature] - relaxation_factor * dwells[seg][Temperature];

After:

const int sign = dwells[seg][Temperature] > 0. ? 1 : -1;
const Scalar dx_limited = sign * std::min(std::abs(dwells[seg][Temperature]) * relaxation_factor, max_temperature_change);
value_[seg][Temperature] = std::max(old_primary_variables[seg][Temperature] - dx_limited, Scalar{0.0});

Changes

  • MultisegmentWellPrimaryVariables.hpp/cpp — Add enable_energy, Temperature index, update numWellEq = numPhases + 1 + enable_energy. Temperature handled in update(), updateNewton(), copyToWellState(), new getSegmentTemperature() accessor.
  • BlackoilModelParameters.hpp/cpp — New MaxTemperatureChangeMsWells parameter (default 5 K, matching the reservoir model's MaxTemperatureChange).
  • MultisegmentWellAssemble.hpp — Derive numWellEq from PrimaryVariables instead of duplicating the formula.
  • MultisegmentWell_impl.hpp — Pass max_temperature_change through to updateNewton.
  • SegmentState.hpp/cpp — Add temperature vector (constructor, serialization, equality).
  • Template instantiations (MSWellHelpers.cpp, MultisegmentWellEquations.cpp, WellHelpers.cpp, WellAssemble.cpp) — Add dimensions for numWellEq=5 when energy is enabled.

When enable_energy = false (all non-thermal configurations), numWellEq and all template dimensions are unchanged — zero behavioral difference.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…wells

Add enable_energy flag and Temperature index to MultisegmentWellPrimaryVariables.
Limit temperature Newton update using max_temperature_change (default 5K),
matching the reservoir model approach. Add temperature to SegmentState.
Add necessary template instantiations for energy-enabled configurations.

Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix large temperature Newton update value Limit temperature Newton update for multisegment wells Feb 24, 2026
Copilot AI requested a review from GitPaean February 24, 2026 13:00
@GitPaean

Copy link
Copy Markdown
Member

It does not look successful experiment and it should not happen in the main repository. Sorry for the noise.

@GitPaean GitPaean closed this Feb 24, 2026
@bska bska deleted the copilot/fix-temperature-newton-update branch February 24, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants