adding function computeWellPotentials to StandardWell

for some similar reasons, this function stays in StandardWell for now.
Eventually, it should go to WellInterface with some refactoring work.
This commit is contained in:
Kai Bao 2017-07-24 15:09:44 +02:00
parent 1d34c9dc6e
commit e6d2b8550b
4 changed files with 55 additions and 51 deletions

View File

@ -146,6 +146,10 @@ namespace Opm
virtual void applySolutionWellState(const BVector& x, const ModelParameters& param,
WellState& well_state) const;
virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const;
using WellInterface<TypeTag>::phaseUsage;
using WellInterface<TypeTag>::active;
using WellInterface<TypeTag>::numberOfPerforations;

View File

@ -2013,7 +2013,7 @@ namespace Opm
double liquid = 0.0;
double vapour = 0.0;
const Opm::PhaseUsage& pu = phase_usage_;
const Opm::PhaseUsage& pu = *phase_usage_;
if (active()[ Water ]) {
aqua = potentials[pu.phase_pos[ Water ] ];
@ -2093,4 +2093,51 @@ namespace Opm
return potentials;
}
template<typename TypeTag>
void
StandardWell<TypeTag>::
computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const
{
const int np = numberOfPhases();
well_potentials.resize(np, 0.0);
// get the bhp value based on the bhp constraints
const double bhp = mostStrictBhpFromBhpLimits();
// does the well have a THP related constraint?
if ( !wellHasTHPConstraints() ) {
assert(std::abs(bhp) != std::numeric_limits<double>::max());
computeWellRatesWithBhp(ebosSimulator, bhp, well_potentials);
} else {
// the well has a THP related constraint
// checking whether a well is newly added, it only happens at the beginning of the report step
if ( !well_state.isNewWell(indexOfWell()) ) {
for (int p = 0; p < np; ++p) {
// This is dangerous for new added well
// since we are not handling the initialization correctly for now
well_potentials[p] = well_state.wellRates()[indexOfWell() * np + p];
}
} else {
// We need to generate a reasonable rates to start the iteration process
computeWellRatesWithBhp(ebosSimulator, bhp, well_potentials);
for (double& value : well_potentials) {
// make the value a little safer in case the BHP limits are default ones
// TODO: a better way should be a better rescaling based on the investigation of the VFP table.
const double rate_safety_scaling_factor = 0.00001;
value *= rate_safety_scaling_factor;
}
}
well_potentials = computeWellPotentialWithTHP(ebosSimulator, bhp, well_potentials);
}
}
}

View File

@ -197,9 +197,9 @@ namespace Opm
virtual void applySolutionWellState(const BVector& x, const ModelParameters& param,
WellState& well_state) const = 0;
void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const;
virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const = 0;
protected:
// TODO: some variables shared by all the wells should be made static

View File

@ -391,53 +391,6 @@ namespace Opm
template<typename TypeTag>
void
WellInterface<TypeTag>::
computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const
{
const int np = numberOfPhases();
well_potentials.resize(np, 0.0);
// get the bhp value based on the bhp constraints
const double bhp = mostStrictBhpFromBhpLimits();
// does the well have a THP related constraint?
if ( !wellHasTHPConstraints() ) {
assert(std::abs(bhp) != std::numeric_limits<double>::max());
computeWellRatesWithBhp(ebosSimulator, bhp, well_potentials);
} else {
// the well has a THP related constraint
// checking whether a well is newly added, it only happens at the beginning of the report step
if ( !well_state.isNewWell(index_of_well_) ) {
for (int p = 0; p < np; ++p) {
// This is dangerous for new added well
// since we are not handling the initialization correctly for now
well_potentials[p] = well_state.wellRates()[index_of_well_ * np + p];
}
} else {
// We need to generate a reasonable rates to start the iteration process
computeWellRatesWithBhp(ebosSimulator, bhp, well_potentials);
for (double& value : well_potentials) {
// make the value a little safer in case the BHP limits are default ones
// TODO: a better way should be a better rescaling based on the investigation of the VFP table.
const double rate_safety_scaling_factor = 0.00001;
value *= rate_safety_scaling_factor;
}
}
// potentials = computeWellPotentialWithTHP(ebosSimulator, w, bhp, potentials);
}
}
template<typename TypeTag>
double
WellInterface<TypeTag>::