Store well potential in well_state and pass it for output if asked for

A zero well potential is passed if the computation fails or
if it is a multisegmented well.
This commit is contained in:
Tor Harald Sandve
2018-11-07 14:53:43 +01:00
parent 8f62670c1e
commit 3bc292d168
3 changed files with 69 additions and 7 deletions

View File

@@ -235,6 +235,19 @@ namespace Opm {
well->calculateReservoirRates(well_state_);
}
updateWellTestState(simulationTime, wellTestState_);
// calculate the well potentials for output
// TODO: when necessary
try
{
std::vector<double> well_potentials;
computeWellPotentials(well_potentials);
}
catch ( std::runtime_error& e )
{
const std::string msg = "A zero well potential is returned for output purposes. ";
OpmLog::warning("WELL_POTENTIAL_CALCULATION_FAILED", msg);
}
previous_well_state_ = well_state_;
}
@@ -770,15 +783,31 @@ namespace Opm {
const int np = numPhases();
well_potentials.resize(nw * np, 0.0);
const Opm::SummaryConfig summaryConfig = ebosSimulator_.vanguard().summaryConfig();
for (const auto& well : well_container_) {
std::vector<double> potentials;
well->computeWellPotentials(ebosSimulator_, well_state_, potentials);
// Only compute the well potential when asked for
bool needed_for_output = ((summaryConfig.hasSummaryKey( "WWPI:" + well->name()) ||
summaryConfig.hasSummaryKey( "WOPI:" + well->name()) ||
summaryConfig.hasSummaryKey( "WGPI:" + well->name())) && well->wellType() == INJECTOR) ||
((summaryConfig.hasSummaryKey( "WWPP:" + well->name()) ||
summaryConfig.hasSummaryKey( "WOPP:" + well->name()) ||
summaryConfig.hasSummaryKey( "WGPP:" + well->name())) && well->wellType() == PRODUCER);
// putting the sucessfully calculated potentials to the well_potentials
for (int p = 0; p < np; ++p) {
well_potentials[well->indexOfWell() * np + p] = std::abs(potentials[p]);
if (needed_for_output || wellCollection().requireWellPotentials())
{
std::vector<double> potentials;
well->computeWellPotentials(ebosSimulator_, well_state_, potentials);
// putting the sucessfully calculated potentials to the well_potentials
for (int p = 0; p < np; ++p) {
well_potentials[well->indexOfWell() * np + p] = std::abs(potentials[p]);
}
}
} // end of for (int w = 0; w < nw; ++w)
// Store it in the well state
well_state_.wellPotentials() = well_potentials;
}