Fix more minor issues based on review

This commit is contained in:
Tor Harald Sandve 2018-07-02 11:06:51 +02:00
parent 6606bb75b2
commit a5f5581441
4 changed files with 27 additions and 34 deletions

View File

@ -350,7 +350,7 @@ namespace Opm {
void updatePerforationIntensiveQuantities();
void wellTesting(const int timeStepIdx,const double simulationTime);
void wellTesting(const int timeStepIdx, const double simulationTime);
};

View File

@ -176,7 +176,7 @@ namespace Opm {
const auto& wellsForTesting = wellTestState_.updateWell(wtest_config, simulationTime);
// Do the well testing if enabled
if (!initial_step_ && wtest_config.size() > 0 && wellsForTesting.size() > 0) {
if (wtest_config.size() > 0 && wellsForTesting.size() > 0) {
// solve the well equation isolated from the reservoir.
const int numComp = numComponents();
std::vector< Scalar > B_avg( numComp, Scalar() );
@ -232,7 +232,7 @@ namespace Opm {
WellTestState wellTestStateForTheWellTest;
WellState wellStateCopy = well_state_;
well->init(&phase_usage_, depth_, gravity_, number_of_cells_);
const std::string well_name = well->name();
const std::string& well_name = well->name();
const WellNode& well_node = wellCollection().findWellNode(well_name);
const double well_efficiency_factor = well_node.getAccumulativeEfficiencyFactor();
well->setWellEfficiencyFactor(well_efficiency_factor);
@ -241,14 +241,19 @@ namespace Opm {
well->initPrimaryVariablesEvaluation();
bool testWell = true;
// if a well is closed because all completions are closed, we need to check each completion
// individually. We first open all completions, then we close one by one by calling updateWellTestState
// untill the number of closed completions do not increase anymore.
while (testWell) {
size_t numberOfClosedCompletions = wellTestStateForTheWellTest.sizeCompletions();
well->solveWellEq(ebosSimulator_, wellStateCopy, /*dt (not relevant for well test) =*/ 1.0, B_avg, terminal_output_);
const size_t numberOfClosedCompletions = wellTestStateForTheWellTest.sizeCompletions();
well->solveWellForTesting(ebosSimulator_, wellStateCopy, B_avg, terminal_output_);
well->updateWellTestState(wellStateCopy, simulationTime, wellTestStateForTheWellTest, /*writeMessageToOPMLog=*/ false);
well->closeWellsAndCompletions(wellTestStateForTheWellTest);
// test completions individually.
if (numberOfClosedCompletions == wellTestStateForTheWellTest.sizeCompletions())
// Stop testing if the well is closed or shut due to all completions shut
// Also check if number of completions has increased. If the number of closed completions do not increased
// we stop the testing.
if (wellTestStateForTheWellTest.sizeWells() > 0 && numberOfClosedCompletions == wellTestStateForTheWellTest.sizeCompletions())
testWell = false;
}

View File

@ -225,7 +225,7 @@ namespace Opm
virtual void addWellContributions(Mat&) const
{}
SimulatorReport solveWellEq(Simulator& ebosSimulator, WellState& well_state, const double dt, const std::vector<double>& B_avg, bool terminal_output);
void solveWellForTesting(Simulator& ebosSimulator, WellState& well_state, const std::vector<double>& B_avg, bool terminal_output);
void closeWellsAndCompletions(WellTestState& wellTestState);
@ -235,7 +235,7 @@ namespace Opm
protected:
// to indicate a invalid completion
static const int INVALIDCOMPLETION = 0;
static const int INVALIDCOMPLETION = INT_MAX;
const Well* well_ecl_;

View File

@ -738,13 +738,13 @@ namespace Opm
if (allCompletionsClosed) {
wellTestState.addClosedWell(well_name, WellTestConfig::Reason::ECONOMIC, simulationTime);
if (writeMessageToOPMLog) {
if (well_ecl_->getAutomaticShutIn()) {
const std::string msg = well_name + std::string(" will be shut due to last completion closed");
OpmLog::info(msg);
} else {
const std::string msg = well_name + std::string(" will be stopped due to last completion closed");
OpmLog::info(msg);
}
if (well_ecl_->getAutomaticShutIn()) {
const std::string msg = well_name + std::string(" will be shut due to last completion closed");
OpmLog::info(msg);
} else {
const std::string msg = well_name + std::string(" will be stopped due to last completion closed");
OpmLog::info(msg);
}
}
}
break;
@ -930,11 +930,12 @@ namespace Opm
}
template<typename TypeTag>
SimulatorReport
WellInterface<TypeTag>::solveWellEq(Simulator& ebosSimulator, WellState& well_state, const double dt, const std::vector<double>& B_avg, bool terminal_output)
void
WellInterface<TypeTag>::solveWellForTesting(Simulator& ebosSimulator, WellState& well_state, const std::vector<double>& B_avg, bool terminal_output)
{
const int max_iter = param_.max_welleq_iter_;
int it = 0;
int it = 0;
const double dt = 1.0; //not used for the well tests
bool converged;
WellState well_state0 = well_state;
do {
@ -958,25 +959,12 @@ namespace Opm
if (converged) {
if ( terminal_output ) {
OpmLog::debug("Well equation for well " + name() + " solution gets converged with " + std::to_string(it) + " iterations");
OpmLog::debug("WellTest: Well equation for well " + name() + " solution gets converged with " + std::to_string(it) + " iterations");
}
} else {
if ( terminal_output ) {
OpmLog::debug("Well equation for well" +name() + " solution failed in getting converged with " + std::to_string(it) + " iterations");
well_state = well_state0;
updatePrimaryVariables(well_state);
// also recover the old well controls
//WellControls* wc = wellControls();
//well_controls_set_current(wc, well_state.currentControls()[indexOfWell()]);
OpmLog::debug("WellTest: Well equation for well" +name() + " solution failed in getting converged with " + std::to_string(it) + " iterations");
}
}
SimulatorReport report;
report.converged = converged;
report.total_well_iterations = it;
return report;
}
}