mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 20:24:48 -06:00
Merge pull request #3418 from totto82/iterStwPot
iterate to get more accurate potentials for stw wells
This commit is contained in:
commit
a1aafa08ce
@ -383,7 +383,7 @@ namespace Opm
|
||||
void computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
||||
const double& bhp,
|
||||
std::vector<double>& well_flux,
|
||||
DeferredLogger& deferred_logger);
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
std::vector<double> computeWellPotentialWithTHP(
|
||||
const Simulator& ebosSimulator,
|
||||
|
@ -1677,7 +1677,7 @@ namespace Opm
|
||||
computeWellRatesWithBhpPotential(const Simulator& ebosSimulator,
|
||||
const double& bhp,
|
||||
std::vector<double>& well_flux,
|
||||
DeferredLogger& deferred_logger)
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
|
||||
// iterate to get a more accurate well density
|
||||
@ -1695,20 +1695,29 @@ namespace Opm
|
||||
}
|
||||
ws.bhp = bhp;
|
||||
|
||||
// initialized the well rates with the potentials i.e. the well rates based on bhp
|
||||
const int np = number_of_phases_;
|
||||
const double sign = well_ecl_.isInjector() ? 1.0 : -1.0;
|
||||
for (int phase = 0; phase < np; ++phase){
|
||||
well_state_copy.wellRates(index_of_well_)[phase]
|
||||
= sign * ws.well_potentials[phase];
|
||||
}
|
||||
// creating a copy of the well itself, to avoid messing up the explicit informations
|
||||
// during this copy, the only information not copied properly is the well controls
|
||||
StandardWell<TypeTag> well(*this);
|
||||
well.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger);
|
||||
|
||||
const double dt = ebosSimulator.timeStepSize();
|
||||
bool converged = this->iterateWellEquations(ebosSimulator, dt, well_state_copy, group_state, deferred_logger);
|
||||
bool converged = well.iterateWellEquations(ebosSimulator, dt, well_state_copy, group_state, deferred_logger);
|
||||
if (!converged) {
|
||||
const std::string msg = " well " + name() + " did not get converged during well potential calculations "
|
||||
"returning zero values for the potential";
|
||||
" potentials are computed based on unconverged solution";
|
||||
deferred_logger.debug(msg);
|
||||
return;
|
||||
}
|
||||
updatePrimaryVariables(well_state_copy, deferred_logger);
|
||||
computeWellConnectionPressures(ebosSimulator, well_state_copy);
|
||||
initPrimaryVariablesEvaluation();
|
||||
|
||||
|
||||
computeWellRatesWithBhp(ebosSimulator, bhp, well_flux, deferred_logger);
|
||||
well.updatePrimaryVariables(well_state_copy, deferred_logger);
|
||||
well.computeWellConnectionPressures(ebosSimulator, well_state_copy);
|
||||
well.initPrimaryVariablesEvaluation();
|
||||
well.computeWellRatesWithBhp(ebosSimulator, bhp, well_flux, deferred_logger);
|
||||
}
|
||||
|
||||
|
||||
@ -1730,13 +1739,13 @@ namespace Opm
|
||||
auto bhp_at_thp_limit = computeBhpAtThpLimitInj(ebos_simulator, summary_state, deferred_logger);
|
||||
if (bhp_at_thp_limit) {
|
||||
const double bhp = std::min(*bhp_at_thp_limit, controls.bhp_limit);
|
||||
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
computeWellRatesWithBhpPotential(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
} else {
|
||||
deferred_logger.warning("FAILURE_GETTING_CONVERGED_POTENTIAL",
|
||||
"Failed in getting converged thp based potential calculation for well "
|
||||
+ name() + ". Instead the bhp based value is used");
|
||||
const double bhp = controls.bhp_limit;
|
||||
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
computeWellRatesWithBhpPotential(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
}
|
||||
} else {
|
||||
computeWellRatesWithThpAlqProd(
|
||||
@ -1763,7 +1772,7 @@ namespace Opm
|
||||
if (bhp_at_thp_limit) {
|
||||
const auto& controls = well_ecl_.productionControls(summary_state);
|
||||
bhp = std::max(*bhp_at_thp_limit, controls.bhp_limit);
|
||||
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
computeWellRatesWithBhpPotential(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
}
|
||||
else {
|
||||
deferred_logger.warning("FAILURE_GETTING_CONVERGED_POTENTIAL",
|
||||
@ -1771,7 +1780,7 @@ namespace Opm
|
||||
+ name() + ". Instead the bhp based value is used");
|
||||
const auto& controls = well_ecl_.productionControls(summary_state);
|
||||
bhp = controls.bhp_limit;
|
||||
computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
computeWellRatesWithBhpPotential(ebos_simulator, bhp, potentials, deferred_logger);
|
||||
}
|
||||
return bhp;
|
||||
}
|
||||
@ -1876,21 +1885,16 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
// creating a copy of the well itself, to avoid messing up the explicit informations
|
||||
// during this copy, the only information not copied properly is the well controls
|
||||
StandardWell<TypeTag> well(*this);
|
||||
well.calculateExplicitQuantities(ebosSimulator, well_state, deferred_logger);
|
||||
|
||||
// does the well have a THP related constraint?
|
||||
const auto& summaryState = ebosSimulator.vanguard().summaryState();
|
||||
if (!well.Base::wellHasTHPConstraints(summaryState) || bhp_controlled_well) {
|
||||
if (!Base::wellHasTHPConstraints(summaryState) || bhp_controlled_well) {
|
||||
// get the bhp value based on the bhp constraints
|
||||
const double bhp = well.mostStrictBhpFromBhpLimits(summaryState);
|
||||
const double bhp = mostStrictBhpFromBhpLimits(summaryState);
|
||||
assert(std::abs(bhp) != std::numeric_limits<double>::max());
|
||||
well.computeWellRatesWithBhpPotential(ebosSimulator, bhp, well_potentials, deferred_logger);
|
||||
computeWellRatesWithBhpPotential(ebosSimulator, bhp, well_potentials, deferred_logger);
|
||||
} else {
|
||||
// the well has a THP related constraint
|
||||
well_potentials = well.computeWellPotentialWithTHP(ebosSimulator, deferred_logger, well_state);
|
||||
well_potentials = computeWellPotentialWithTHP(ebosSimulator, deferred_logger, well_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user