2022-11-18 04:57:37 -06:00
|
|
|
/*
|
|
|
|
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
|
|
|
Copyright 2017 Statoil ASA.
|
|
|
|
Copyright 2016 - 2017 IRIS AS.
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <opm/simulators/wells/MultisegmentWellAssemble.hpp>
|
|
|
|
|
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
|
|
|
|
|
|
|
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
|
|
|
|
|
|
|
#include <opm/models/blackoil/blackoilindices.hh>
|
|
|
|
#include <opm/models/blackoil/blackoilonephaseindices.hh>
|
|
|
|
#include <opm/models/blackoil/blackoiltwophaseindices.hh>
|
|
|
|
|
|
|
|
#include <opm/simulators/wells/MultisegmentWellEquations.hpp>
|
2022-12-19 04:49:00 -06:00
|
|
|
#include <opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp>
|
2022-11-18 04:57:37 -06:00
|
|
|
#include <opm/simulators/wells/WellAssemble.hpp>
|
|
|
|
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
|
2023-03-22 09:10:00 -05:00
|
|
|
#include <opm/simulators/wells/WellHelpers.hpp>
|
2022-11-18 04:57:37 -06:00
|
|
|
#include <opm/simulators/wells/WellInterfaceIndices.hpp>
|
2023-03-08 08:32:55 -06:00
|
|
|
#include <opm/simulators/wells/WellState.hpp>
|
2022-11-18 04:57:37 -06:00
|
|
|
|
|
|
|
namespace Opm {
|
|
|
|
|
2022-11-18 05:50:19 -06:00
|
|
|
//! \brief Class administering assembler access to equation system.
|
|
|
|
template<class Scalar, int numWellEq, int numEq>
|
|
|
|
class MultisegmentWellEquationAccess {
|
|
|
|
public:
|
|
|
|
//! \brief Constructor initializes reference to the equation system.
|
|
|
|
MultisegmentWellEquationAccess(MultisegmentWellEquations<Scalar,numWellEq,numEq>& eqns)
|
|
|
|
: eqns_(eqns)
|
|
|
|
{}
|
|
|
|
|
|
|
|
using BVectorWell = typename MultisegmentWellEquations<Scalar,numWellEq,numEq>::BVectorWell;
|
|
|
|
using DiagMatWell = typename MultisegmentWellEquations<Scalar,numWellEq,numEq>::DiagMatWell;
|
|
|
|
using OffDiatMatWell = typename MultisegmentWellEquations<Scalar,numWellEq,numEq>::OffDiagMatWell;
|
|
|
|
|
|
|
|
//! \brief Returns a reference to residual vector.
|
|
|
|
BVectorWell& residual()
|
|
|
|
{
|
|
|
|
return eqns_.resWell_;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Returns a reference to B matrix.
|
|
|
|
OffDiatMatWell& B()
|
|
|
|
{
|
|
|
|
return eqns_.duneB_;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Returns a reference to C matrix.
|
|
|
|
OffDiatMatWell& C()
|
|
|
|
{
|
|
|
|
return eqns_.duneC_;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Returns a reference to D matrix.
|
|
|
|
DiagMatWell& D()
|
|
|
|
{
|
|
|
|
return eqns_.duneD_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MultisegmentWellEquations<Scalar,numWellEq,numEq>& eqns_; //!< Reference to equation system
|
|
|
|
};
|
|
|
|
|
2022-11-18 04:57:37 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assembleControlEq(const WellState& well_state,
|
|
|
|
const GroupState& group_state,
|
|
|
|
const Schedule& schedule,
|
|
|
|
const SummaryState& summaryState,
|
|
|
|
const Well::InjectionControls& inj_controls,
|
|
|
|
const Well::ProductionControls& prod_controls,
|
|
|
|
const double rho,
|
2022-12-19 04:49:00 -06:00
|
|
|
const PrimaryVariables& primary_variables,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1,
|
2022-11-18 04:57:37 -06:00
|
|
|
DeferredLogger& deferred_logger) const
|
|
|
|
{
|
|
|
|
static constexpr int Gas = BlackoilPhases::Vapour;
|
|
|
|
static constexpr int Oil = BlackoilPhases::Liquid;
|
|
|
|
static constexpr int Water = BlackoilPhases::Aqua;
|
|
|
|
|
|
|
|
EvalWell control_eq(0.0);
|
|
|
|
|
|
|
|
const auto& well = well_.wellEcl();
|
|
|
|
|
|
|
|
auto getRates = [&]() {
|
|
|
|
std::vector<EvalWell> rates(3, 0.0);
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
2022-12-19 04:49:00 -06:00
|
|
|
rates[Water] = primary_variables.getQs(Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx));
|
2022-11-18 04:57:37 -06:00
|
|
|
}
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
2022-12-19 04:49:00 -06:00
|
|
|
rates[Oil] = primary_variables.getQs(Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx));
|
2022-11-18 04:57:37 -06:00
|
|
|
}
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
2022-12-19 04:49:00 -06:00
|
|
|
rates[Gas] = primary_variables.getQs(Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx));
|
2022-11-18 04:57:37 -06:00
|
|
|
}
|
|
|
|
return rates;
|
|
|
|
};
|
|
|
|
|
2023-03-29 07:33:05 -05:00
|
|
|
if (well_.stopppedOrZeroRateTarget(summaryState, well_state)) {
|
2022-12-19 04:49:00 -06:00
|
|
|
control_eq = primary_variables.getWQTotal();
|
2022-11-18 04:57:37 -06:00
|
|
|
} else if (well_.isInjector() ) {
|
|
|
|
// Find scaling factor to get injection rate,
|
|
|
|
const InjectorType injectorType = inj_controls.injector_type;
|
|
|
|
double scaling = 1.0;
|
|
|
|
const auto& pu = well_.phaseUsage();
|
|
|
|
switch (injectorType) {
|
|
|
|
case InjectorType::WATER:
|
|
|
|
{
|
|
|
|
scaling = well_.scalingFactor(pu.phase_pos[BlackoilPhases::Aqua]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InjectorType::OIL:
|
|
|
|
{
|
|
|
|
scaling = well_.scalingFactor(pu.phase_pos[BlackoilPhases::Liquid]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InjectorType::GAS:
|
|
|
|
{
|
|
|
|
scaling = well_.scalingFactor(pu.phase_pos[BlackoilPhases::Vapour]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw("Expected WATER, OIL or GAS as type for injectors " + well.name());
|
|
|
|
}
|
2022-12-19 04:49:00 -06:00
|
|
|
const EvalWell injection_rate = primary_variables.getWQTotal() / scaling;
|
2022-11-18 04:57:37 -06:00
|
|
|
// Setup function for evaluation of BHP from THP (used only if needed).
|
|
|
|
std::function<EvalWell()> bhp_from_thp = [&]() {
|
|
|
|
const auto rates = getRates();
|
|
|
|
return WellBhpThpCalculator(well_).calculateBhpFromThp(well_state,
|
|
|
|
rates,
|
|
|
|
well,
|
|
|
|
summaryState,
|
|
|
|
rho,
|
|
|
|
deferred_logger);
|
|
|
|
};
|
|
|
|
// Call generic implementation.
|
|
|
|
WellAssemble(well_).assembleControlEqInj(well_state,
|
|
|
|
group_state,
|
|
|
|
schedule,
|
|
|
|
summaryState,
|
|
|
|
inj_controls,
|
2022-12-19 04:49:00 -06:00
|
|
|
primary_variables.getBhp(),
|
2022-11-18 04:57:37 -06:00
|
|
|
injection_rate,
|
|
|
|
bhp_from_thp,
|
|
|
|
control_eq,
|
|
|
|
deferred_logger);
|
|
|
|
} else {
|
|
|
|
// Find rates.
|
|
|
|
const auto rates = getRates();
|
|
|
|
// Setup function for evaluation of BHP from THP (used only if needed).
|
|
|
|
std::function<EvalWell()> bhp_from_thp = [&]() {
|
|
|
|
return WellBhpThpCalculator(well_).calculateBhpFromThp(well_state,
|
|
|
|
rates,
|
|
|
|
well,
|
|
|
|
summaryState,
|
|
|
|
rho,
|
|
|
|
deferred_logger);
|
|
|
|
};
|
|
|
|
// Call generic implementation.
|
|
|
|
WellAssemble(well_).assembleControlEqProd(well_state,
|
|
|
|
group_state,
|
|
|
|
schedule,
|
|
|
|
summaryState,
|
|
|
|
prod_controls,
|
2022-12-19 04:49:00 -06:00
|
|
|
primary_variables.getBhp(),
|
2022-11-18 04:57:37 -06:00
|
|
|
rates,
|
|
|
|
bhp_from_thp,
|
|
|
|
control_eq,
|
|
|
|
deferred_logger);
|
|
|
|
}
|
|
|
|
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
2022-11-18 04:57:37 -06:00
|
|
|
// using control_eq to update the matrix and residuals
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.residual()[0][SPres] = control_eq.value();
|
2022-11-18 04:57:37 -06:00
|
|
|
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[0][0][SPres][pv_idx] = control_eq.derivative(pv_idx + Indices::numEq);
|
2022-11-18 04:57:37 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assemblePressureLoss(const int seg,
|
|
|
|
const int seg_upwind,
|
|
|
|
const EvalWell& accelerationPressureLoss,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1) const
|
2022-11-18 05:09:43 -06:00
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
|
|
|
eqns.residual()[seg][SPres] -= accelerationPressureLoss.value();
|
|
|
|
eqns.D()[seg][seg][SPres][SPres] -= accelerationPressureLoss.derivative(SPres + Indices::numEq);
|
|
|
|
eqns.D()[seg][seg][SPres][WQTotal] -= accelerationPressureLoss.derivative(WQTotal + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
if constexpr (has_wfrac_variable) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg_upwind][SPres][WFrac] -= accelerationPressureLoss.derivative(WFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
if constexpr (has_gfrac_variable) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg_upwind][SPres][GFrac] -= accelerationPressureLoss.derivative(GFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-09 15:54:24 -05:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assembleHydroPressureLoss(const int seg,
|
2023-05-23 05:44:06 -05:00
|
|
|
const int seg_density,
|
2023-05-10 03:31:49 -05:00
|
|
|
const EvalWell& hydro_pressure_drop_seg,
|
2023-05-09 15:54:24 -05:00
|
|
|
Equations& eqns1) const
|
|
|
|
{
|
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
2023-05-23 05:44:06 -05:00
|
|
|
eqns.residual()[seg][SPres] -= hydro_pressure_drop_seg.value();
|
2023-05-09 15:54:24 -05:00
|
|
|
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
2023-05-23 05:44:06 -05:00
|
|
|
eqns.D()[seg][seg_density][SPres][pv_idx] -= hydro_pressure_drop_seg.derivative(pv_idx + Indices::numEq);
|
2023-05-09 15:54:24 -05:00
|
|
|
}
|
2023-05-23 05:44:06 -05:00
|
|
|
|
2023-05-09 15:54:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assemblePressureEqExtraDerivatives(const int seg,
|
|
|
|
const int seg_upwind,
|
|
|
|
const EvalWell& extra_derivatives,
|
|
|
|
Equations& eqns1) const
|
|
|
|
{
|
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
|
|
|
// diregard residual
|
|
|
|
// Frac - derivatives are zero (they belong to upwind^2)
|
|
|
|
eqns.D()[seg][seg_upwind][SPres][SPres] += extra_derivatives.derivative(SPres + Indices::numEq);
|
|
|
|
eqns.D()[seg][seg_upwind][SPres][WQTotal] += extra_derivatives.derivative(WQTotal + Indices::numEq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assemblePressureEq(const int seg,
|
|
|
|
const int seg_upwind,
|
|
|
|
const int outlet_segment_index,
|
|
|
|
const EvalWell& pressure_equation,
|
|
|
|
const EvalWell& outlet_pressure,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1,
|
2022-11-18 05:09:43 -06:00
|
|
|
bool wfrac,
|
|
|
|
bool gfrac) const
|
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
2023-05-15 07:34:10 -05:00
|
|
|
eqns.residual()[seg][SPres] += pressure_equation.value();
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg][SPres][SPres] += pressure_equation.derivative(SPres + Indices::numEq);
|
|
|
|
eqns.D()[seg][seg][SPres][WQTotal] += pressure_equation.derivative(WQTotal + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
if (wfrac) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg_upwind][SPres][WFrac] += pressure_equation.derivative(WFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
if (gfrac) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg_upwind][SPres][GFrac] += pressure_equation.derivative(GFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// contribution from the outlet segment
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.residual()[seg][SPres] -= outlet_pressure.value();
|
2022-11-18 05:09:43 -06:00
|
|
|
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
2023-03-20 07:15:59 -05:00
|
|
|
eqns.D()[seg][outlet_segment_index][SPres][pv_idx] -= outlet_pressure.derivative(pv_idx + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assembleTrivialEq(const int seg,
|
|
|
|
const Scalar value,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1) const
|
2022-11-18 05:09:43 -06:00
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
|
|
|
eqns.residual()[seg][SPres] = value;
|
|
|
|
eqns.D()[seg][seg][SPres][WQTotal] = 1.;
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assembleAccumulationTerm(const int seg,
|
|
|
|
const int comp_idx,
|
|
|
|
const EvalWell& accumulation_term,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1) const
|
2022-11-18 05:09:43 -06:00
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
|
|
|
eqns.residual()[seg][comp_idx] += accumulation_term.value();
|
2022-11-18 05:09:43 -06:00
|
|
|
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg][comp_idx][pv_idx] += accumulation_term.derivative(pv_idx + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assembleOutflowTerm(const int seg,
|
|
|
|
const int seg_upwind,
|
|
|
|
const int comp_idx,
|
|
|
|
const EvalWell& segment_rate,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1) const
|
2022-11-18 05:09:43 -06:00
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
|
|
|
eqns.residual()[seg][comp_idx] -= segment_rate.value();
|
|
|
|
eqns.D()[seg][seg][comp_idx][WQTotal] -= segment_rate.derivative(WQTotal + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg_upwind][comp_idx][WFrac] -= segment_rate.derivative(WFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg_upwind][comp_idx][GFrac] -= segment_rate.derivative(GFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
// pressure derivative should be zero
|
|
|
|
}
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assembleInflowTerm(const int seg,
|
|
|
|
const int inlet,
|
|
|
|
const int inlet_upwind,
|
|
|
|
const int comp_idx,
|
|
|
|
const EvalWell& inlet_rate,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1) const
|
2022-11-18 05:09:43 -06:00
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
|
|
|
eqns.residual()[seg][comp_idx] += inlet_rate.value();
|
|
|
|
eqns.D()[seg][inlet][comp_idx][WQTotal] += inlet_rate.derivative(WQTotal + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][inlet_upwind][comp_idx][WFrac] += inlet_rate.derivative(WFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][inlet_upwind][comp_idx][GFrac] += inlet_rate.derivative(GFrac + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
// pressure derivative should be zero
|
|
|
|
}
|
|
|
|
|
2022-11-18 05:09:43 -06:00
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
|
|
|
|
assemblePerforationEq(const int seg,
|
|
|
|
const int cell_idx,
|
|
|
|
const int comp_idx,
|
|
|
|
const EvalWell& cq_s_effective,
|
2022-11-18 05:50:19 -06:00
|
|
|
Equations& eqns1) const
|
2022-11-18 05:09:43 -06:00
|
|
|
{
|
2022-11-18 05:50:19 -06:00
|
|
|
MultisegmentWellEquationAccess<Scalar,numWellEq,Indices::numEq> eqns(eqns1);
|
2022-11-18 05:09:43 -06:00
|
|
|
// subtract sum of phase fluxes in the well equations.
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.residual()[seg][comp_idx] += cq_s_effective.value();
|
2022-11-18 05:09:43 -06:00
|
|
|
|
|
|
|
// assemble the jacobians
|
|
|
|
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
|
|
|
// also need to consider the efficiency factor when manipulating the jacobians.
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.C()[seg][cell_idx][pv_idx][comp_idx] -= cq_s_effective.derivative(pv_idx + Indices::numEq); // input in transformed matrix
|
2022-11-18 05:09:43 -06:00
|
|
|
|
|
|
|
// the index name for the D should be eq_idx / pv_idx
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.D()[seg][seg][comp_idx][pv_idx] += cq_s_effective.derivative(pv_idx + Indices::numEq);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int pv_idx = 0; pv_idx < Indices::numEq; ++pv_idx) {
|
|
|
|
// also need to consider the efficiency factor when manipulating the jacobians.
|
2022-11-18 05:50:19 -06:00
|
|
|
eqns.B()[seg][cell_idx][comp_idx][pv_idx] += cq_s_effective.derivative(pv_idx);
|
2022-11-18 05:09:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 04:57:37 -06:00
|
|
|
#define INSTANCE(...) \
|
|
|
|
template class MultisegmentWellAssemble<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;
|
|
|
|
|
|
|
|
// One phase
|
|
|
|
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>)
|
|
|
|
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>)
|
|
|
|
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,5u>)
|
|
|
|
|
|
|
|
// Two phase
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,2u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,false,0u,2u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,2u,0u,false,false,0u,2u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,2u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,true,0u,0u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>)
|
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>)
|
2023-02-23 01:42:25 -06:00
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>)
|
2023-05-04 03:25:58 -05:00
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>)
|
2023-03-29 01:21:54 -05:00
|
|
|
INSTANCE(BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>)
|
|
|
|
|
2022-11-18 04:57:37 -06:00
|
|
|
// Blackoil
|
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>)
|
2022-11-18 05:09:43 -06:00
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,1u,0u>)
|
2022-11-18 04:57:37 -06:00
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>)
|
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>)
|
2022-11-18 05:09:43 -06:00
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,2u,0u>)
|
2022-11-18 04:57:37 -06:00
|
|
|
INSTANCE(BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>)
|
|
|
|
INSTANCE(BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>)
|
|
|
|
INSTANCE(BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>)
|
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,false,0u,0u>)
|
|
|
|
INSTANCE(BlackOilIndices<0u,0u,0u,1u,false,true,0u,0u>)
|
2023-05-02 08:41:07 -05:00
|
|
|
INSTANCE(BlackOilIndices<1u,0u,0u,0u,true,false,0u,0u>)
|
2022-11-18 04:57:37 -06:00
|
|
|
}
|