more bug fixing

mainly to recover the runnign related to group control example
This commit is contained in:
Kai Bao 2018-05-11 14:21:53 +02:00
parent 1d218d2fe4
commit 179a03144f
2 changed files with 28 additions and 26 deletions

View File

@ -64,24 +64,22 @@ namespace Opm
static const int numWellEq = numEq + 1 - numPolymerEq - numEnergyEq;
// the positions of the primary variables for StandardWell
// there are four primary variables, the second and the third ones are F_w and F_g
// the first one is the weighted total rate (G_t), the second and the third ones are F_w and F_g
// the last one is the BHP.
// the fraction of the solvent, as an extension of the blackoil model, is behind the BHP
// the first one is the weighted total rate (G_t), the second and the third ones are F_w and F_g,
// which represent the fraction of Water and Gas based on the weighted total rate, the last one is BHP.
// correspondingly, we have four well equations for blackoil model, the first three are mass
// converstation equations, and the last one is the well control equation.
// primary variables related to other components, will be before the Bhp and after F_g.
// well control equation is always the last well equation, other equations will be before the
// well control equation and are conservation equations for components involved.
// TODO: in the current implementation, we use the well rate as the first primary variables for injectors
// TODO: not sure we should change it.
// well control equation is always the last well equation.
// TODO: in the current implementation, we use the well rate as the first primary variables for injectors,
// instead of G_t.
static const bool gasoil = numEq == 2 && (Indices::compositionSwitchIdx >= 0);
static const int GTotal = 0;
static const int WFrac = gasoil? -1000: 1;
static const int GFrac = gasoil? 1: 2;
static const int SFrac = !has_solvent ? -1000 : 3;
// the index for Bhp in primary variables and also the index of well control equation
// they both will be the last one in their system.
// they both will be the last one in their respective system.
// TODO: we should have indices for the well equations and well primary variables separately
static const int Bhp = numWellEq - 1;
using typename Base::Scalar;
@ -239,12 +237,8 @@ namespace Opm
// the saturations in the well bore under surface conditions at the beginning of the time step
std::vector<double> F0_;
// TODO: this function should be moved to the base class.
// while it faces chanllenges for MSWell later, since the calculation of bhp
// based on THP is never implemented for MSWell yet.
const EvalWell& getBhp() const;
// TODO: it is also possible to be moved to the base class.
EvalWell getQs(const int comp_idx) const;
const EvalWell& getGTotal() const;
@ -291,7 +285,7 @@ namespace Opm
const std::vector<double>& rvmax_perf,
const std::vector<double>& surf_dens_perf);
// computing the accumulation term for later use in well mass equations
void computeAccumWell();
void computeWellConnectionPressures(const Simulator& ebosSimulator,

View File

@ -147,17 +147,15 @@ namespace Opm
StandardWell<TypeTag>::
getQs(const int comp_idx) const
{
// TODO: not sure the best way to handle solvent injection
// TODO: we need to come back to handle the solvent case here, the following implementation does not
// TODO: consider solvent injection yet.
// TODO: currently, the GTotal definition is still depends on Injector/Producer.
// Note: currently, the GTotal definition is still depends on Injector/Producer.
assert(comp_idx < num_components_);
if (well_type_ == INJECTOR) { // only single phase injection
// TODO: using comp_frac here is dangerous, it should be changed later
// Most likely, it should be changed to use distr, or at least, we need to update comp_frac_ based on distr
// while solvent might complicate the situation
//
// TODO: it is possible that the RESV for the injector is not well handled here.
const auto pu = phaseUsage();
const int legacyCompIdx = ebosCompIdxToFlowCompIdx(comp_idx);
double comp_frac = 0.0;
@ -171,8 +169,14 @@ namespace Opm
} else {
comp_frac = comp_frac_[legacyCompIdx];
}
// testing code
if (comp_frac > 0.) {
const double target_rate = well_controls_get_current_target(well_controls_);
}
// testing code end
return comp_frac * primary_variables_evaluation_[GTotal];
} else {
} else { // producers
return primary_variables_evaluation_[GTotal] * wellVolumeFractionScaled(comp_idx);
}
}
@ -664,6 +668,8 @@ namespace Opm
if (well_type_ == INJECTOR) {
assert(number_phases_under_control == 1); // only handles single phase injection now
// TODO: considering the solvent part here
// Better way to cover solvent part will be getQs() - target_rate, while it turned out not correct
// for the solvent case.
control_eq = getGTotal() - target_rate;
} else if (well_type_ == PRODUCER) {
EvalWell rate_for_control(0.);
@ -1023,8 +1029,7 @@ namespace Opm
for (int p = 0; p < number_of_phases_; ++p) {
well_state.wellRates()[index_of_well_ * number_of_phases_ + p] = g_total * F[p];
}
// injectors
} else {
} else { // injectors
// TODO: using comp_frac_ here is very dangerous, since we do not update it based on the injection phase
// Either we use distr (might conflict with RESV related) or we update comp_frac_ based on the injection phase
for (int p = 0; p < number_of_phases_; ++p) {
@ -1158,12 +1163,12 @@ namespace Opm
}
if (original_rates_under_phase_control != 0.0 ) {
double scaling_factor = target / original_rates_under_phase_control;
const double scaling_factor = target / original_rates_under_phase_control;
for (int phase = 0; phase < np; ++phase) {
well_state.wellRates()[np * well_index + phase] *= scaling_factor;
}
} else { // scaling factor is not well defied when original_rates_under_phase_control is zero
} else { // scaling factor is not well defined when original_rates_under_phase_control is zero
// separating targets equally between phases under control
const double target_rate_divided = target / numPhasesWithTargetsUnderThisControl;
for (int phase = 0; phase < np; ++phase) {
@ -1897,10 +1902,13 @@ namespace Opm
total_well_rate += scalingFactor(p) * well_state.wellRates()[np * well_index + p];
}
// TODO: not sure whether we should distinguish the firs primary variable based on Producer/Injector
// it will be determined based on testing as a separate issue.
// Not: for the moment, the first primary variable for the injectors is not G_total. The injection rate
// under surface condition is used here
if (well_type_ == INJECTOR) {
primary_variables_[GTotal] = 0.;
for (int p = 0; p < np; ++p) {
// TODO: the use of comp_frac_ here is dangerous, since the injection phase can be different from
// prefered phasse in WELSPECS, while comp_frac_ only reflect the one specified in WELSPECS
primary_variables_[GTotal] += well_state.wellRates()[np * well_index + p] * comp_frac_[p];
}
} else {