using has_wfrac(gfrac)_variable logic, In case of gas-water system GFrac is primary variable index

This commit is contained in:
Paul Egberts 2021-08-01 20:51:28 +02:00
parent 5be63a59e0
commit 70d43fbefc

View File

@ -90,19 +90,19 @@ relaxationFactorFractionsProducer(const std::vector<double>& primary_variables,
double relaxation_factor = 1.0; double relaxation_factor = 1.0;
if (FluidSystem::numActivePhases() > 1) { if (FluidSystem::numActivePhases() > 1) {
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { if (has_wfrac_variable) {
const double relaxation_factor_w = StandardWellGeneric<Scalar>:: const double relaxation_factor_w = StandardWellGeneric<Scalar>::
relaxationFactorFraction(primary_variables[WFrac], dwells[0][WFrac]); relaxationFactorFraction(primary_variables[WFrac], dwells[0][WFrac]);
relaxation_factor = std::min(relaxation_factor, relaxation_factor_w); relaxation_factor = std::min(relaxation_factor, relaxation_factor_w);
} }
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { if (has_gfrac_variable) {
const double relaxation_factor_g = StandardWellGeneric<Scalar>:: const double relaxation_factor_g = StandardWellGeneric<Scalar>::
relaxationFactorFraction(primary_variables[GFrac], dwells[0][GFrac]); relaxationFactorFraction(primary_variables[GFrac], dwells[0][GFrac]);
relaxation_factor = std::min(relaxation_factor, relaxation_factor_g); relaxation_factor = std::min(relaxation_factor, relaxation_factor_g);
} }
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { if (has_wfrac_variable && has_gfrac_variable) {
// We need to make sure the even with the relaxation_factor, the sum of F_w and F_g is below one, so there will // We need to make sure the even with the relaxation_factor, the sum of F_w and F_g is below one, so there will
// not be negative oil fraction later // not be negative oil fraction later
const double original_sum = primary_variables[WFrac] + primary_variables[GFrac]; const double original_sum = primary_variables[WFrac] + primary_variables[GFrac];
@ -132,11 +132,11 @@ wellVolumeFraction(const unsigned compIdx) const
} }
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) { if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx)) { if (has_wfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx)) {
return primary_variables_evaluation_[WFrac]; return primary_variables_evaluation_[WFrac];
} }
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) { if (has_gfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) {
return primary_variables_evaluation_[GFrac]; return primary_variables_evaluation_[GFrac];
} }
@ -145,7 +145,7 @@ wellVolumeFraction(const unsigned compIdx) const
} }
} }
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) { if (has_gfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) {
return primary_variables_evaluation_[GFrac]; return primary_variables_evaluation_[GFrac];
} }
} }
@ -287,10 +287,10 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
} }
if (std::abs(total_well_rate) > 0.) { if (std::abs(total_well_rate) > 0.) {
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { if (has_wfrac_variable) {
primary_variables_[WFrac] = baseif_.scalingFactor(pu.phase_pos[Water]) * well_state.wellRates(well_index)[pu.phase_pos[Water]] / total_well_rate; primary_variables_[WFrac] = baseif_.scalingFactor(pu.phase_pos[Water]) * well_state.wellRates(well_index)[pu.phase_pos[Water]] / total_well_rate;
} }
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { if (has_gfrac_variable) {
primary_variables_[GFrac] = baseif_.scalingFactor(pu.phase_pos[Gas]) * (well_state.wellRates(well_index)[pu.phase_pos[Gas]] primary_variables_[GFrac] = baseif_.scalingFactor(pu.phase_pos[Gas]) * (well_state.wellRates(well_index)[pu.phase_pos[Gas]]
- (Indices::enableSolvent ? well_state.solventWellRate(well_index) : 0.0) ) / total_well_rate ; - (Indices::enableSolvent ? well_state.solventWellRate(well_index) : 0.0) ) / total_well_rate ;
} }
@ -326,10 +326,11 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
// this will happen. // this will happen.
} else if (baseif_.isProducer()) { // producers } else if (baseif_.isProducer()) { // producers
// TODO: the following are not addressed for the solvent case yet // TODO: the following are not addressed for the solvent case yet
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { if (has_wfrac_variable) {
primary_variables_[WFrac] = 1.0 / np; primary_variables_[WFrac] = 1.0 / np;
} }
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
if (has_gfrac_variable) {
primary_variables_[GFrac] = 1.0 / np; primary_variables_[GFrac] = 1.0 / np;
} }
} else { } else {
@ -530,11 +531,12 @@ processFractions() const
F[pu.phase_pos[Oil]] = 0.0; F[pu.phase_pos[Oil]] = 0.0;
} }
} }
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { if (has_wfrac_variable) {
primary_variables_[WFrac] = F[pu.phase_pos[Water]]; primary_variables_[WFrac] = F[pu.phase_pos[Water]];
} }
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
if (has_gfrac_variable) {
primary_variables_[GFrac] = F[pu.phase_pos[Gas]]; primary_variables_[GFrac] = F[pu.phase_pos[Gas]];
} }
if constexpr (Indices::enableSolvent) { if constexpr (Indices::enableSolvent) {
@ -727,14 +729,15 @@ updatePrimaryVariablesNewton(const BVectorWell& dwells,
: 1.0; : 1.0;
// update the second and third well variable (The flux fractions) // update the second and third well variable (The flux fractions)
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
if (has_wfrac_variable) {
const int sign2 = dwells[0][WFrac] > 0 ? 1: -1; const int sign2 = dwells[0][WFrac] > 0 ? 1: -1;
const double dx2_limited = sign2 * std::min(std::abs(dwells[0][WFrac] * relaxation_factor_fractions), dFLimit); const double dx2_limited = sign2 * std::min(std::abs(dwells[0][WFrac] * relaxation_factor_fractions), dFLimit);
// primary_variables_[WFrac] = old_primary_variables[WFrac] - dx2_limited; // primary_variables_[WFrac] = old_primary_variables[WFrac] - dx2_limited;
primary_variables_[WFrac] = old_primary_variables[WFrac] - dx2_limited; primary_variables_[WFrac] = old_primary_variables[WFrac] - dx2_limited;
} }
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { if (has_gfrac_variable) {
const int sign3 = dwells[0][GFrac] > 0 ? 1: -1; const int sign3 = dwells[0][GFrac] > 0 ? 1: -1;
const double dx3_limited = sign3 * std::min(std::abs(dwells[0][GFrac] * relaxation_factor_fractions), dFLimit); const double dx3_limited = sign3 * std::min(std::abs(dwells[0][GFrac] * relaxation_factor_fractions), dFLimit);
primary_variables_[GFrac] = old_primary_variables[GFrac] - dx3_limited; primary_variables_[GFrac] = old_primary_variables[GFrac] - dx3_limited;