Minor convergence improvments

- set current control when initializing the wellstate
- re calculate wellVariable after well control has changed.
This commit is contained in:
Tor Harald Sandve 2016-08-18 08:58:07 +02:00
parent 49f478480d
commit f60e26faf7
3 changed files with 140 additions and 132 deletions

View File

@ -287,7 +287,7 @@ namespace Opm {
// get reasonable initial conditions for the wells
wellModel().updateWellControls(well_state);
// Create the primary variables.
// Set the primary variables for the wells
setWellVariables(well_state);
//SolutionState state(/*numPhases=*/3);

View File

@ -74,7 +74,6 @@ namespace Opm
StandardWellsDense::StandardWellsDense(const Wells* wells_arg)
: wells_active_(wells_arg!=nullptr)
, wells_(wells_arg)
@ -1240,11 +1239,12 @@ namespace Opm
OpmLog::info(ss.str());
xw.currentControls()[w] = ctrl_index;
current = xw.currentControls()[w];
}
well_controls_set_current( wc, current);
// Updating well state and primary variables.
// Updating well state and primary variables if constraint is broken
// Target values are used as initial conditions for BHP, THP, and SURFACE_RATE
const double target = well_controls_iget_target(wc, current);
const double* distr = well_controls_iget_distr(wc, current);
@ -1311,9 +1311,9 @@ namespace Opm
if (well_type == INJECTOR) {
for (int phase = 0; phase < np; ++phase) {
const double& compi = wells().comp_frac[np * w + phase];
if (compi > 0.0) {
//if (compi > 0.0) {
xw.wellRates()[np*w + phase] = target * compi;
}
//}
}
} else if (well_type == PRODUCER) {
@ -1339,7 +1339,12 @@ namespace Opm
break;
}
std::vector<double> g = {1,1,0.01};
if (true) {
if (well_controls_iget_type(wc, current) == RESERVOIR_RATE) {
const double* distr = well_controls_iget_distr(wc, current);
for (int phase = 0; phase < np; ++phase) {
g[phase] = distr[phase];
}
}
switch (well_controls_iget_type(wc, current)) {
case BHP:
{
@ -1362,23 +1367,23 @@ namespace Opm
case SURFACE_RATE:
{
xw.wellSolutions()[w] = xw.bhp()[w];
}
break;
}
}
// const WellType& well_type = wells().type[w];
// double tot_well_rate = 0.0;
// for (int p = 0; p < np; ++p) {
// tot_well_rate += g[p] * xw.wellRates()[np*w + p];
// }
// if (well_type == INJECTOR && tot_well_rate == 0) {
// xw.wellSolutions()[nw + w] = wells().comp_frac[np*w + Water];
// xw.wellSolutions()[2 * nw + w] = wells().comp_frac[np*w + Gas];
// }
double tot_well_rate = 0.0;
for (int p = 0; p < np; ++p) {
tot_well_rate += g[p] * xw.wellRates()[np*w + p];
}
if(std::abs(tot_well_rate) > 0) {
xw.wellSolutions()[nw + w] = g[Water] * xw.wellRates()[np*w + Water] / tot_well_rate; //wells->comp_frac[np*w + Water]; // Water;
xw.wellSolutions()[2*nw + w] = g[Gas] * xw.wellRates()[np*w + Gas] / tot_well_rate ; //wells->comp_frac[np*w + Gas]; //Gas
} else {
//xw.wellSolutions()[nw + w] = wells().comp_frac[np*w + Water];
//xw.wellSolutions()[2 * nw + w] = wells().comp_frac[np*w + Gas];
}
}
}
}

View File

@ -193,16 +193,16 @@ namespace Opm
}
// wellSolutions
if (wells->type[w] == PRODUCER && std::abs(total_well_rates) > 0.0) {
for( int i=0; i<np; ++i)
//if (std::abs(total_well_rates) > 0.0) {
//wellSolutions()[ 0*nw + newIndex ] = prevState.wellSolutions()[0 * nw_old + oldIndex ];
//if (wells->type[w] == PRODUCER) {
for( int i = 0; i < np; ++i)
{
wellSolutions()[ i*nw + newIndex ] = prevState.wellSolutions()[i * nw_old + oldIndex ];
}
}
//}
//}
// perfPhaseRates
int oldPerf_idx = (*it).second[ 1 ];
@ -242,6 +242,9 @@ namespace Opm
// If the set of controls have changed, this may not be identical
// to the last control, but it must be a valid control.
currentControls()[ newIndex ] = old_control_index;
WellControls* wc = wells->ctrls[newIndex];
well_controls_set_current( wc, old_control_index);
}
}