mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-27 09:40:59 -06:00
add MultisegmentWellEval
This commit is contained in:
parent
72bd3368e7
commit
68fc2b0bc6
@ -63,6 +63,7 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
opm/simulators/wells/GasLiftStage2.cpp
|
||||
opm/simulators/wells/GlobalWellInfo.cpp
|
||||
opm/simulators/wells/GroupState.cpp
|
||||
opm/simulators/wells/MultisegmentWellEval.cpp
|
||||
opm/simulators/wells/MultisegmentWellGeneric.cpp
|
||||
opm/simulators/wells/ParallelWellInfo.cpp
|
||||
opm/simulators/wells/SegmentState.cpp
|
||||
|
@ -29,7 +29,10 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <string>
|
||||
#include<dune/istl/matrix.hh>
|
||||
#include <dune/istl/preconditioners.hh>
|
||||
#include <dune/istl/solvers.hh>
|
||||
|
||||
#if HAVE_UMFPACK
|
||||
#include <dune/istl/umfpack.hh>
|
||||
#endif // HAVE_UMFPACK
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define OPM_MULTISEGMENTWELL_HEADER_INCLUDED
|
||||
|
||||
#include <opm/simulators/wells/WellInterface.hpp>
|
||||
#include <opm/simulators/wells/MultisegmentWellGeneric.hpp>
|
||||
#include <opm/simulators/wells/MultisegmentWellEval.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
|
||||
@ -33,10 +33,15 @@ namespace Opm
|
||||
|
||||
template<typename TypeTag>
|
||||
class MultisegmentWell : public WellInterface<TypeTag>
|
||||
, public MultisegmentWellGeneric<GetPropType<TypeTag, Properties::Scalar>>
|
||||
, public MultisegmentWellEval<GetPropType<TypeTag, Properties::FluidSystem>,
|
||||
GetPropType<TypeTag, Properties::Indices>,
|
||||
GetPropType<TypeTag, Properties::Scalar>>
|
||||
{
|
||||
public:
|
||||
typedef WellInterface<TypeTag> Base;
|
||||
using Base = WellInterface<TypeTag>;
|
||||
using MSWEval = MultisegmentWellEval<GetPropType<TypeTag, Properties::FluidSystem>,
|
||||
GetPropType<TypeTag, Properties::Indices>,
|
||||
GetPropType<TypeTag, Properties::Scalar>>;
|
||||
|
||||
using typename Base::Simulator;
|
||||
using typename Base::IntensiveQuantities;
|
||||
@ -62,63 +67,21 @@ namespace Opm
|
||||
using Base::Oil;
|
||||
using Base::Gas;
|
||||
|
||||
// TODO: for now, not considering the polymer, solvent and so on to simplify the development process.
|
||||
|
||||
// TODO: we need to have order for the primary variables and also the order for the well equations.
|
||||
// sometimes, they are similar, while sometimes, they can have very different forms.
|
||||
|
||||
// Table showing the primary variable indices, depending on what phases are present:
|
||||
//
|
||||
// WOG OG WG WO W/O/G (single phase)
|
||||
// GTotal 0 0 0 0 0
|
||||
// WFrac 1 -1000 1 1 -1000
|
||||
// GFrac 2 1 -1000 -1000 -1000
|
||||
// Spres 3 2 2 2 1
|
||||
|
||||
static constexpr bool has_water = (Indices::waterSaturationIdx >= 0);
|
||||
static constexpr bool has_gas = (Indices::compositionSwitchIdx >= 0);
|
||||
static constexpr bool has_oil = (numPhases - has_gas - has_water) > 0;
|
||||
|
||||
// In the implementation, one should use has_wfrac_variable
|
||||
// rather than has_water to check if you should do something
|
||||
// with the variable at the WFrac location, similar for GFrac.
|
||||
static constexpr bool has_wfrac_variable = has_water && numPhases > 1;
|
||||
static constexpr bool has_gfrac_variable = has_gas && has_oil;
|
||||
|
||||
static constexpr int GTotal = 0;
|
||||
static constexpr int WFrac = has_wfrac_variable ? 1 : -1000;
|
||||
static constexpr int GFrac = has_gfrac_variable ? has_wfrac_variable + 1 : -1000;
|
||||
static constexpr int SPres = has_wfrac_variable + has_gfrac_variable + 1;
|
||||
|
||||
// the number of well equations TODO: it should have a more general strategy for it
|
||||
static const int numWellEq = numPhases + 1;
|
||||
|
||||
using typename Base::Scalar;
|
||||
|
||||
/// the matrix and vector types for the reservoir
|
||||
using typename Base::BVector;
|
||||
using typename Base::Eval;
|
||||
|
||||
// sparsity pattern for the matrices
|
||||
// [A C^T [x = [ res
|
||||
// B D ] x_well] res_well]
|
||||
|
||||
// the vector type for the res_well and x_well
|
||||
typedef Dune::FieldVector<Scalar, numWellEq> VectorBlockWellType;
|
||||
typedef Dune::BlockVector<VectorBlockWellType> BVectorWell;
|
||||
|
||||
// the matrix type for the diagonal matrix D
|
||||
typedef Dune::FieldMatrix<Scalar, numWellEq, numWellEq > DiagMatrixBlockWellType;
|
||||
typedef Dune::BCRSMatrix <DiagMatrixBlockWellType> DiagMatWell;
|
||||
|
||||
// the matrix type for the non-diagonal matrix B and C^T
|
||||
typedef Dune::FieldMatrix<Scalar, numWellEq, numEq> OffDiagMatrixBlockWellType;
|
||||
typedef Dune::BCRSMatrix<OffDiagMatrixBlockWellType> OffDiagMatWell;
|
||||
|
||||
// TODO: for more efficient implementation, we should have EvalReservoir, EvalWell, and EvalRerservoirAndWell
|
||||
// EvalR (Eval), EvalW, EvalRW
|
||||
// TODO: for now, we only use one type to save some implementation efforts, while improve later.
|
||||
typedef DenseAd::Evaluation<double, /*size=*/numEq + numWellEq> EvalWell;
|
||||
using typename MSWEval::EvalWell;
|
||||
using typename MSWEval::BVectorWell;
|
||||
using typename MSWEval::DiagMatWell;
|
||||
using typename MSWEval::OffDiagMatrixBlockWellType;
|
||||
using MSWEval::GFrac;
|
||||
using MSWEval::WFrac;
|
||||
using MSWEval::GTotal;
|
||||
using MSWEval::SPres;
|
||||
using MSWEval::numWellEq;
|
||||
|
||||
MultisegmentWell(const Well& well,
|
||||
const ParallelWellInfo& pw_info,
|
||||
@ -137,7 +100,6 @@ namespace Opm
|
||||
const int num_cells,
|
||||
const std::vector< Scalar >& B_avg) override;
|
||||
|
||||
|
||||
virtual void initPrimaryVariablesEvaluation() const override;
|
||||
|
||||
virtual void gasLiftOptimizationStage1 (
|
||||
@ -157,18 +119,16 @@ namespace Opm
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
/// check whether the well equations get converged for this well
|
||||
virtual ConvergenceReport getWellConvergence(const WellState& well_state, const std::vector<double>& B_avg, DeferredLogger& deferred_logger, const bool relax_tolerance = false) const override;
|
||||
virtual ConvergenceReport getWellConvergence(const WellState& well_state,
|
||||
const std::vector<double>& B_avg,
|
||||
DeferredLogger& deferred_logger,
|
||||
const bool relax_tolerance = false) const override;
|
||||
|
||||
/// Ax = Ax - C D^-1 B x
|
||||
virtual void apply(const BVector& x, BVector& Ax) const override;
|
||||
/// r = r - C D^-1 Rw
|
||||
virtual void apply(BVector& r) const override;
|
||||
|
||||
#if HAVE_CUDA || HAVE_OPENCL
|
||||
/// add the contribution (C, D, B matrices) of this Well to the WellContributions object
|
||||
void addWellContribution(WellContributions& wellContribs) const;
|
||||
#endif
|
||||
|
||||
/// using the solution x to recover the solution xw for wells and applying
|
||||
/// xw to update Well State
|
||||
virtual void recoverWellSolutionAndUpdateWellState(const BVector& x,
|
||||
@ -260,67 +220,11 @@ namespace Opm
|
||||
using Base::calculateBhpFromThp;
|
||||
using Base::getALQ;
|
||||
|
||||
// TODO, the following should go to a class for computing purpose
|
||||
// two off-diagonal matrices
|
||||
mutable OffDiagMatWell duneB_;
|
||||
mutable OffDiagMatWell duneC_;
|
||||
// "diagonal" matrix for the well. It has offdiagonal entries for inlets and outlets.
|
||||
mutable DiagMatWell duneD_;
|
||||
/// \brief solver for diagonal matrix
|
||||
///
|
||||
/// This is a shared_ptr as MultisegmentWell is copied in computeWellPotentials...
|
||||
mutable std::shared_ptr<Dune::UMFPack<DiagMatWell> > duneDSolver_;
|
||||
|
||||
// residuals of the well equations
|
||||
mutable BVectorWell resWell_;
|
||||
|
||||
// the values for the primary varibles
|
||||
// based on different solutioin strategies, the wells can have different primary variables
|
||||
mutable std::vector<std::array<double, numWellEq> > primary_variables_;
|
||||
|
||||
// the Evaluation for the well primary variables, which contain derivativles and are used in AD calculation
|
||||
mutable std::vector<std::array<EvalWell, numWellEq> > primary_variables_evaluation_;
|
||||
|
||||
// depth difference between perforations and the perforated grid cells
|
||||
std::vector<double> cell_perforation_depth_diffs_;
|
||||
// pressure correction due to the different depth of the perforation and
|
||||
// center depth of the grid block
|
||||
std::vector<double> cell_perforation_pressure_diffs_;
|
||||
|
||||
// the intial amount of fluids in each segment under surface condition
|
||||
std::vector<std::vector<double> > segment_fluid_initial_;
|
||||
|
||||
// the densities of segment fluids
|
||||
// we should not have this member variable
|
||||
std::vector<EvalWell> segment_densities_;
|
||||
|
||||
// the viscosity of the segments
|
||||
std::vector<EvalWell> segment_viscosities_;
|
||||
|
||||
// the mass rate of the segments
|
||||
std::vector<EvalWell> segment_mass_rates_;
|
||||
|
||||
// the upwinding segment for each segment based on the flow direction
|
||||
std::vector<int> upwinding_segments_;
|
||||
|
||||
mutable int debug_cost_counter_ = 0;
|
||||
|
||||
std::vector<std::vector<EvalWell>> segment_phase_fractions_;
|
||||
|
||||
std::vector<std::vector<EvalWell>> segment_phase_viscosities_;
|
||||
|
||||
std::vector<std::vector<EvalWell>> segment_phase_densities_;
|
||||
|
||||
|
||||
void initMatrixAndVectors(const int num_cells) const;
|
||||
|
||||
EvalWell getBhp() const;
|
||||
EvalWell getQs(const int comp_idx) const;
|
||||
EvalWell getWQTotal() const;
|
||||
|
||||
// xw = inv(D)*(rw - C*x)
|
||||
void recoverSolutionWell(const BVector& x, BVectorWell& xw) const;
|
||||
|
||||
// updating the well_state based on well solution dwells
|
||||
void updateWellState(const BVectorWell& dwells,
|
||||
WellState& well_state,
|
||||
@ -334,16 +238,6 @@ namespace Opm
|
||||
// compute the pressure difference between the perforation and cell center
|
||||
void computePerfCellPressDiffs(const Simulator& ebosSimulator);
|
||||
|
||||
// fraction value of the primary variables
|
||||
// should we just use member variables to store them instead of calculating them again and again
|
||||
EvalWell volumeFraction(const int seg, const unsigned comp_idx) const;
|
||||
|
||||
// F_p / g_p, the basic usage of this value is because Q_p = G_t * F_p / G_p
|
||||
EvalWell volumeFractionScaled(const int seg, const int comp_idx) const;
|
||||
|
||||
// basically Q_p / \sigma_p Q_p
|
||||
EvalWell surfaceVolumeFraction(const int seg, const int comp_idx) const;
|
||||
|
||||
void computePerfRatePressure(const IntensiveQuantities& int_quants,
|
||||
const std::vector<EvalWell>& mob_perfcells,
|
||||
const double Tw,
|
||||
@ -357,23 +251,10 @@ namespace Opm
|
||||
double& perf_vap_oil_rate,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
// convert a Eval from reservoir to contain the derivative related to wells
|
||||
EvalWell extendEval(const Eval& in) const;
|
||||
|
||||
void updateThp(WellState& well_state, DeferredLogger& deferred_logger) const;
|
||||
|
||||
// compute the fluid properties, such as densities, viscosities, and so on, in the segments
|
||||
// They will be treated implicitly, so they need to be of Evaluation type
|
||||
void computeSegmentFluidProperties(const Simulator& ebosSimulator);
|
||||
|
||||
EvalWell getSegmentPressure(const int seg) const;
|
||||
|
||||
EvalWell getSegmentRate(const int seg, const int comp_idx) const;
|
||||
|
||||
EvalWell getSegmentRateUpwinding(const int seg, const size_t comp_idx) const;
|
||||
|
||||
EvalWell getSegmentGTotal(const int seg) const;
|
||||
|
||||
// get the mobility for specific perforation
|
||||
void getMobility(const Simulator& ebosSimulator,
|
||||
const int perf,
|
||||
@ -392,32 +273,6 @@ namespace Opm
|
||||
computeWellPotentialWithTHP(const Simulator& ebos_simulator,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void 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,
|
||||
DeferredLogger& deferred_logger);
|
||||
|
||||
void assemblePressureEq(const int seg, const UnitSystem& unit_system,
|
||||
WellState& well_state, DeferredLogger& deferred_logger) const;
|
||||
|
||||
void assembleDefaultPressureEq(const int seg, WellState& well_state) const;
|
||||
|
||||
// hytrostatic pressure loss
|
||||
EvalWell getHydroPressureLoss(const int seg) const;
|
||||
|
||||
// frictinal pressure loss
|
||||
EvalWell getFrictionPressureLoss(const int seg) const;
|
||||
|
||||
void handleAccelerationPressureLoss(const int seg, WellState& well_state) const;
|
||||
|
||||
// handling the overshooting and undershooting of the fractions
|
||||
void processFractions(const int seg) const;
|
||||
|
||||
void updateWellStateFromPrimaryVariables(WellState& well_state, DeferredLogger& deferred_logger) const;
|
||||
|
||||
virtual double getRefDensity() const override;
|
||||
|
||||
virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
||||
@ -440,21 +295,6 @@ namespace Opm
|
||||
|
||||
EvalWell getSegmentSurfaceVolume(const Simulator& ebos_simulator, const int seg_idx) const;
|
||||
|
||||
std::vector<Scalar> getWellResiduals(const std::vector<Scalar>& B_avg,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
double getResidualMeasureValue(const WellState& well_state,
|
||||
const std::vector<double>& residuals,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
double getControlTolerance(const WellState& well_state, DeferredLogger& deferred_logger) const;
|
||||
|
||||
void checkConvergenceControlEq(const WellState& well_state,
|
||||
ConvergenceReport& report,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void updateUpwindingSegments();
|
||||
|
||||
// turn on crossflow to avoid singular well equations
|
||||
// when the well is banned from cross-flow and the BHP is not properly initialized,
|
||||
// we turn on crossflow to avoid singular well equations. It can result in wrong-signed
|
||||
@ -477,19 +317,6 @@ namespace Opm
|
||||
|
||||
double maxPerfPress(const Simulator& ebos_simulator) const;
|
||||
|
||||
// pressure drop for Spiral ICD segment (WSEGSICD)
|
||||
EvalWell pressureDropSpiralICD(const int seg) const;
|
||||
|
||||
// pressure drop for Autonomous ICD segment (WSEGAICD)
|
||||
EvalWell pressureDropAutoICD(const int seg, const UnitSystem& unit_system) const;
|
||||
|
||||
// pressure drop for sub-critical valve (WSEGVALV)
|
||||
EvalWell pressureDropValve(const int seg) const;
|
||||
|
||||
// assemble pressure equation for ICD segments
|
||||
void assembleICDPressureEq(const int seg, const UnitSystem& unit_system,
|
||||
WellState& well_state, DeferredLogger& deferred_logger) const;
|
||||
|
||||
// check whether the well is operable under BHP limit with current reservoir condition
|
||||
virtual void checkOperabilityUnderBHPLimitProducer(const WellState& well_state, const Simulator& ebos_simulator, DeferredLogger& deferred_logger) override;
|
||||
|
||||
@ -498,7 +325,6 @@ namespace Opm
|
||||
|
||||
// updating the inflow based on the current reservoir condition
|
||||
virtual void updateIPR(const Simulator& ebos_simulator, DeferredLogger& deferred_logger) const override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
2017
opm/simulators/wells/MultisegmentWellEval.cpp
Normal file
2017
opm/simulators/wells/MultisegmentWellEval.cpp
Normal file
File diff suppressed because it is too large
Load Diff
318
opm/simulators/wells/MultisegmentWellEval.hpp
Normal file
318
opm/simulators/wells/MultisegmentWellEval.hpp
Normal file
@ -0,0 +1,318 @@
|
||||
/*
|
||||
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
||||
Copyright 2017 Statoil ASA.
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OPM_MULTISEGMENTWELL_EVAL_HEADER_INCLUDED
|
||||
#define OPM_MULTISEGMENTWELL_EVAL_HEADER_INCLUDED
|
||||
|
||||
#include <opm/simulators/wells/MultisegmentWellGeneric.hpp>
|
||||
|
||||
#include <opm/material/densead/Evaluation.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
|
||||
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <dune/common/fvector.hh>
|
||||
#include <dune/istl/bcrsmatrix.hh>
|
||||
#include <dune/istl/bvector.hh>
|
||||
#include <dune/istl/umfpack.hh>
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class ConvergenceReport;
|
||||
class GroupState;
|
||||
class Schedule;
|
||||
class WellContributions;
|
||||
template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices;
|
||||
class WellState;
|
||||
|
||||
template<typename FluidSystem, typename Indices, typename Scalar>
|
||||
class MultisegmentWellEval : public MultisegmentWellGeneric<Scalar>
|
||||
{
|
||||
public:
|
||||
#if HAVE_CUDA || HAVE_OPENCL
|
||||
/// add the contribution (C, D, B matrices) of this Well to the WellContributions object
|
||||
void addWellContribution(WellContributions& wellContribs) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// TODO: for now, not considering the polymer, solvent and so on to simplify the development process.
|
||||
|
||||
// TODO: we need to have order for the primary variables and also the order for the well equations.
|
||||
// sometimes, they are similar, while sometimes, they can have very different forms.
|
||||
|
||||
// Table showing the primary variable indices, depending on what phases are present:
|
||||
//
|
||||
// WOG OG WG WO W/O/G (single phase)
|
||||
// GTotal 0 0 0 0 0
|
||||
// WFrac 1 -1000 1 1 -1000
|
||||
// GFrac 2 1 -1000 -1000 -1000
|
||||
// Spres 3 2 2 2 1
|
||||
|
||||
static constexpr bool has_water = (Indices::waterSaturationIdx >= 0);
|
||||
static constexpr bool has_gas = (Indices::compositionSwitchIdx >= 0);
|
||||
static constexpr bool has_oil = (Indices::numPhases - has_gas - has_water) > 0;
|
||||
|
||||
// In the implementation, one should use has_wfrac_variable
|
||||
// rather than has_water to check if you should do something
|
||||
// with the variable at the WFrac location, similar for GFrac.
|
||||
static constexpr bool has_wfrac_variable = has_water && Indices::numPhases > 1;
|
||||
static constexpr bool has_gfrac_variable = has_gas && has_oil;
|
||||
|
||||
static constexpr int GTotal = 0;
|
||||
static constexpr int WFrac = has_wfrac_variable ? 1 : -1000;
|
||||
static constexpr int GFrac = has_gfrac_variable ? has_wfrac_variable + 1 : -1000;
|
||||
static constexpr int SPres = has_wfrac_variable + has_gfrac_variable + 1;
|
||||
|
||||
// the number of well equations TODO: it should have a more general strategy for it
|
||||
static constexpr int numWellEq = Indices::numPhases + 1;
|
||||
|
||||
// sparsity pattern for the matrices
|
||||
// [A C^T [x = [ res
|
||||
// B D ] x_well] res_well]
|
||||
|
||||
// the vector type for the res_well and x_well
|
||||
using VectorBlockWellType = Dune::FieldVector<Scalar, numWellEq>;
|
||||
using BVectorWell = Dune::BlockVector<VectorBlockWellType>;
|
||||
|
||||
using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
|
||||
using BVector = Dune::BlockVector<VectorBlockType>;
|
||||
|
||||
// the matrix type for the diagonal matrix D
|
||||
using DiagMatrixBlockWellType = Dune::FieldMatrix<Scalar, numWellEq, numWellEq>;
|
||||
using DiagMatWell = Dune::BCRSMatrix<DiagMatrixBlockWellType>;
|
||||
|
||||
// the matrix type for the non-diagonal matrix B and C^T
|
||||
using OffDiagMatrixBlockWellType = Dune::FieldMatrix<Scalar, numWellEq, Indices::numEq>;
|
||||
using OffDiagMatWell = Dune::BCRSMatrix<OffDiagMatrixBlockWellType>;
|
||||
|
||||
// TODO: for more efficient implementation, we should have EvalReservoir, EvalWell, and EvalRerservoirAndWell
|
||||
// EvalR (Eval), EvalW, EvalRW
|
||||
// TODO: for now, we only use one type to save some implementation efforts, while improve later.
|
||||
using EvalWell = DenseAd::Evaluation<double, /*size=*/Indices::numEq + numWellEq>;
|
||||
using Eval = DenseAd::Evaluation<Scalar, /*size=*/Indices::numEq>;
|
||||
|
||||
MultisegmentWellEval(WellInterfaceIndices<FluidSystem,Indices,Scalar>& baseif);
|
||||
|
||||
void initMatrixAndVectors(const int num_cells) const;
|
||||
void initPrimaryVariablesEvaluation() const;
|
||||
|
||||
void 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,
|
||||
DeferredLogger& deferred_logger);
|
||||
|
||||
void assembleDefaultPressureEq(const int seg,
|
||||
WellState& well_state) const;
|
||||
|
||||
|
||||
// assemble pressure equation for ICD segments
|
||||
void assembleICDPressureEq(const int seg,
|
||||
const UnitSystem& unit_system,
|
||||
WellState& well_state,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
|
||||
void assemblePressureEq(const int seg,
|
||||
const UnitSystem& unit_system,
|
||||
WellState& well_state,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void checkConvergenceControlEq(const WellState& well_state,
|
||||
ConvergenceReport& report,
|
||||
const double tolerance_pressure_ms_wells,
|
||||
const double tolerance_wells,
|
||||
const double max_residual_allowed,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void computePerfRatePressure(const EvalWell& pressure_cell,
|
||||
const EvalWell& rs,
|
||||
const EvalWell& rv,
|
||||
const std::vector<EvalWell>& b_perfcells,
|
||||
const std::vector<EvalWell>& mob_perfcells,
|
||||
const double Tw,
|
||||
const int seg,
|
||||
const int perf,
|
||||
const EvalWell& segment_pressure,
|
||||
const bool& allow_cf,
|
||||
std::vector<EvalWell>& cq_s,
|
||||
EvalWell& perf_press,
|
||||
double& perf_dis_gas_rate,
|
||||
double& perf_vap_oil_rate,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
/// check whether the well equations get converged for this well
|
||||
ConvergenceReport getWellConvergence(const WellState& well_state,
|
||||
const std::vector<double>& B_avg,
|
||||
DeferredLogger& deferred_logger,
|
||||
const double max_residual_allowed,
|
||||
const double tolerance_wells,
|
||||
const double relaxed_inner_tolerance_flow_ms_well,
|
||||
const double tolerance_pressure_ms_wells,
|
||||
const double relaxed_inner_tolerance_pressure_ms_well,
|
||||
const bool relax_tolerance) const;
|
||||
|
||||
// handling the overshooting and undershooting of the fractions
|
||||
void processFractions(const int seg) const;
|
||||
|
||||
// xw = inv(D)*(rw - C*x)
|
||||
void recoverSolutionWell(const BVector& x,
|
||||
BVectorWell& xw) const;
|
||||
|
||||
void updatePrimaryVariables(const WellState& well_state) const;
|
||||
|
||||
void updateUpwindingSegments();
|
||||
|
||||
// updating the well_state based on well solution dwells
|
||||
void updateWellState(const BVectorWell& dwells,
|
||||
const double relaxation_factor,
|
||||
const double DFLimit,
|
||||
const double max_pressure_change) const;
|
||||
|
||||
void computeSegmentFluidProperties(const EvalWell& temperature,
|
||||
const EvalWell& saltConcentration,
|
||||
int pvt_region_index);
|
||||
|
||||
EvalWell getBhp() const;
|
||||
EvalWell getFrictionPressureLoss(const int seg) const;
|
||||
EvalWell getHydroPressureLoss(const int seg) const;
|
||||
EvalWell getQs(const int comp_idx) const;
|
||||
EvalWell getSegmentGTotal(const int seg) const;
|
||||
EvalWell getSegmentPressure(const int seg) const;
|
||||
EvalWell getSegmentRate(const int seg, const int comp_idx) const;
|
||||
EvalWell getSegmentRateUpwinding(const int seg,
|
||||
const size_t comp_idx) const;
|
||||
EvalWell getSegmentSurfaceVolume(const EvalWell& temperature,
|
||||
const EvalWell& saltConcentration,
|
||||
const int pvt_region_index,
|
||||
const int seg_idx) const;
|
||||
EvalWell getWQTotal() const;
|
||||
|
||||
|
||||
std::vector<Scalar> getWellResiduals(const std::vector<Scalar>& B_avg,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
double getControlTolerance(const WellState& well_state,
|
||||
const double tolerance_wells,
|
||||
const double tolerance_pressure_ms_wells,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
double getResidualMeasureValue(const WellState& well_state,
|
||||
const std::vector<double>& residuals,
|
||||
const double tolerance_wells,
|
||||
const double tolerance_pressure_ms_wells,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void handleAccelerationPressureLoss(const int seg,
|
||||
WellState& well_state) const;
|
||||
|
||||
// pressure drop for Autonomous ICD segment (WSEGAICD)
|
||||
EvalWell pressureDropAutoICD(const int seg,
|
||||
const UnitSystem& unit_system) const;
|
||||
|
||||
// pressure drop for Spiral ICD segment (WSEGSICD)
|
||||
EvalWell pressureDropSpiralICD(const int seg) const;
|
||||
|
||||
// pressure drop for sub-critical valve (WSEGVALV)
|
||||
EvalWell pressureDropValve(const int seg) const;
|
||||
|
||||
void updateThp(WellState& well_state,
|
||||
const double rho,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void updateWellStateFromPrimaryVariables(WellState& well_state,
|
||||
const double rho,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
// fraction value of the primary variables
|
||||
// should we just use member variables to store them instead of calculating them again and again
|
||||
EvalWell volumeFraction(const int seg,
|
||||
const unsigned compIdx) const;
|
||||
|
||||
// F_p / g_p, the basic usage of this value is because Q_p = G_t * F_p / G_p
|
||||
EvalWell volumeFractionScaled(const int seg,
|
||||
const int comp_idx) const;
|
||||
|
||||
// basically Q_p / \sigma_p Q_p
|
||||
EvalWell surfaceVolumeFraction(const int seg,
|
||||
const int comp_idx) const;
|
||||
|
||||
// convert a Eval from reservoir to contain the derivative related to wells
|
||||
EvalWell extendEval(const Eval& in) const;
|
||||
|
||||
const WellInterfaceIndices<FluidSystem,Indices,Scalar>& baseif_;
|
||||
|
||||
// TODO, the following should go to a class for computing purpose
|
||||
// two off-diagonal matrices
|
||||
mutable OffDiagMatWell duneB_;
|
||||
mutable OffDiagMatWell duneC_;
|
||||
// "diagonal" matrix for the well. It has offdiagonal entries for inlets and outlets.
|
||||
mutable DiagMatWell duneD_;
|
||||
|
||||
/// \brief solver for diagonal matrix
|
||||
///
|
||||
/// This is a shared_ptr as MultisegmentWell is copied in computeWellPotentials...
|
||||
mutable std::shared_ptr<Dune::UMFPack<DiagMatWell> > duneDSolver_;
|
||||
|
||||
// residuals of the well equations
|
||||
mutable BVectorWell resWell_;
|
||||
|
||||
// the values for the primary varibles
|
||||
// based on different solutioin strategies, the wells can have different primary variables
|
||||
mutable std::vector<std::array<double, numWellEq> > primary_variables_;
|
||||
|
||||
// the Evaluation for the well primary variables, which contain derivativles and are used in AD calculation
|
||||
mutable std::vector<std::array<EvalWell, numWellEq> > primary_variables_evaluation_;
|
||||
|
||||
// the upwinding segment for each segment based on the flow direction
|
||||
std::vector<int> upwinding_segments_;
|
||||
|
||||
// the densities of segment fluids
|
||||
// we should not have this member variable
|
||||
std::vector<EvalWell> segment_densities_;
|
||||
|
||||
// the mass rate of the segments
|
||||
std::vector<EvalWell> segment_mass_rates_;
|
||||
|
||||
// the viscosity of the segments
|
||||
std::vector<EvalWell> segment_viscosities_;
|
||||
|
||||
std::vector<std::vector<EvalWell>> segment_phase_densities_;
|
||||
std::vector<std::vector<EvalWell>> segment_phase_fractions_;
|
||||
std::vector<std::vector<EvalWell>> segment_phase_viscosities_;
|
||||
|
||||
// depth difference between perforations and the perforated grid cells
|
||||
std::vector<double> cell_perforation_depth_diffs_;
|
||||
// pressure correction due to the different depth of the perforation and
|
||||
// center depth of the grid block
|
||||
std::vector<double> cell_perforation_pressure_diffs_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
|
File diff suppressed because it is too large
Load Diff
@ -56,6 +56,30 @@ public:
|
||||
const SummaryState& summaryState,
|
||||
const double rho,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
template<class EvalWell>
|
||||
void getGroupInjectionControl(const Group& group,
|
||||
const WellState& well_state,
|
||||
const GroupState& group_state,
|
||||
const Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
const InjectorType& injectorType,
|
||||
const EvalWell& bhp,
|
||||
const EvalWell& injection_rate,
|
||||
EvalWell& control_eq,
|
||||
double efficiencyFactor,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
|
||||
template<class EvalWell>
|
||||
void getGroupProductionControl(const Group& group,
|
||||
const WellState& well_state,
|
||||
const GroupState& group_state,
|
||||
const Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
const EvalWell& bhp,
|
||||
const std::vector<EvalWell>& rates,
|
||||
EvalWell& control_eq,
|
||||
double efficiencyFactor) const;
|
||||
|
||||
template<class EvalWell, class BhpFromThpFunc>
|
||||
void assembleControlEqProd(const WellState& well_state,
|
||||
@ -134,55 +158,6 @@ public:
|
||||
protected:
|
||||
WellInterfaceEval(const WellInterfaceFluidSystem<FluidSystem>& baseif);
|
||||
|
||||
template<class EvalWell>
|
||||
void getGroupInjectionControl(const Group& group,
|
||||
const WellState& well_state,
|
||||
const GroupState& group_state,
|
||||
const Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
const InjectorType& injectorType,
|
||||
const EvalWell& bhp,
|
||||
const EvalWell& injection_rate,
|
||||
EvalWell& control_eq,
|
||||
double efficiencyFactor,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
|
||||
template<class EvalWell>
|
||||
void getGroupProductionControl(const Group& group,
|
||||
const WellState& well_state,
|
||||
const GroupState& group_state,
|
||||
const Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
const EvalWell& bhp,
|
||||
const std::vector<EvalWell>& rates,
|
||||
EvalWell& control_eq,
|
||||
double efficiencyFactor) const;
|
||||
|
||||
template<class EvalWell>
|
||||
void assembleControlEqProd(const WellState& well_state,
|
||||
const GroupState& group_state,
|
||||
const Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
const Well::ProductionControls& controls,
|
||||
const EvalWell& bhp,
|
||||
const std::vector<EvalWell>& rates, // Always 3 canonical rates.
|
||||
const EvalWell& bhp_from_thp,
|
||||
EvalWell& control_eq,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
template<class EvalWell>
|
||||
void assembleControlEqInj_(const WellState& well_state,
|
||||
const GroupState& group_state,
|
||||
const Schedule& schedule,
|
||||
const SummaryState& summaryState,
|
||||
const Well::InjectionControls& controls,
|
||||
const EvalWell& bhp,
|
||||
const EvalWell& injection_rate,
|
||||
const std::function<EvalWell()>& bhp_from_thp,
|
||||
EvalWell& control_eq,
|
||||
DeferredLogger& deferred_logger);
|
||||
|
||||
const WellInterfaceFluidSystem<FluidSystem>& baseif_;
|
||||
};
|
||||
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
return guide_rate_;
|
||||
}
|
||||
|
||||
int numComponents() const{
|
||||
int numComponents() const {
|
||||
return num_components_;
|
||||
}
|
||||
|
||||
|
@ -135,11 +135,13 @@ INSTANCE(BlackOilDefaultIndexTraits,BlackOilTwoPhaseIndices<0u,0u,1u,0u,false,tr
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,0u,false,false,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,0u,true,false,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,0u,false,true,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,0u,false,true,2u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<1u,0u,0u,0u,false,false,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,1u,0u,0u,false,false,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,1u,0u,false,false,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,1u,false,false,0u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,1u,false,false,1u>)
|
||||
INSTANCE(BlackOilDefaultIndexTraits,BlackOilIndices<0u,0u,0u,0u,false,false,1u>)
|
||||
|
||||
// Alternative indices
|
||||
INSTANCE(EclAlternativeBlackOilIndexTraits,BlackOilIndices<0u,0u,0u,0u,false,false,0u>)
|
||||
|
Loading…
Reference in New Issue
Block a user