2017-08-17 08:49:54 -05:00
|
|
|
/*
|
|
|
|
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_HEADER_INCLUDED
|
|
|
|
#define OPM_MULTISEGMENTWELL_HEADER_INCLUDED
|
|
|
|
|
|
|
|
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/WellInterface.hpp>
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
template<typename TypeTag>
|
|
|
|
class MultisegmentWell: public WellInterface<TypeTag>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef WellInterface<TypeTag> Base;
|
|
|
|
|
|
|
|
using typename Base::WellState;
|
2017-09-01 10:37:51 -05:00
|
|
|
using typename Base::Simulator;
|
2017-09-08 04:09:54 -05:00
|
|
|
using typename Base::IntensiveQuantities;
|
|
|
|
using typename Base::FluidSystem;
|
2017-09-01 10:37:51 -05:00
|
|
|
using typename Base::ModelParameters;
|
2017-09-08 07:58:57 -05:00
|
|
|
using typename Base::MaterialLaw;
|
2017-12-04 02:14:08 -06:00
|
|
|
using typename Base::Indices;
|
2017-11-23 01:37:30 -06:00
|
|
|
using typename Base::RateConverterType;
|
2019-10-02 05:48:29 -05:00
|
|
|
using typename Base::SparseMatrixAdapter;
|
2017-11-23 01:37:30 -06:00
|
|
|
|
2017-09-26 03:07:06 -05:00
|
|
|
|
|
|
|
/// the number of reservior equations
|
|
|
|
using Base::numEq;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2017-10-13 03:16:44 -05:00
|
|
|
using Base::has_solvent;
|
|
|
|
using Base::has_polymer;
|
2017-11-08 06:57:36 -06:00
|
|
|
using Base::Water;
|
|
|
|
using Base::Oil;
|
|
|
|
using Base::Gas;
|
2017-10-13 03:16:44 -05:00
|
|
|
|
2017-08-17 08:49:54 -05:00
|
|
|
// TODO: for now, not considering the polymer, solvent and so on to simplify the development process.
|
2017-10-16 09:46:28 -05:00
|
|
|
|
2017-09-12 06:16:57 -05:00
|
|
|
// 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.
|
2017-09-26 03:07:06 -05:00
|
|
|
|
|
|
|
// TODO: the following system looks not rather flexible. Looking into all kinds of possibilities
|
|
|
|
// TODO: gas is always there? how about oil water case?
|
|
|
|
// Is it gas oil two phase case?
|
2017-12-04 02:14:08 -06:00
|
|
|
static const bool gasoil = numEq == 2 && (Indices::compositionSwitchIdx >= 0);
|
2017-09-26 03:07:06 -05:00
|
|
|
static const int GTotal = 0;
|
|
|
|
static const int WFrac = gasoil? -1000: 1;
|
|
|
|
static const int GFrac = gasoil? 1 : 2;
|
|
|
|
static const int SPres = gasoil? 2 : 3;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
/// the number of well equations // TODO: it should have a more general strategy for it
|
2017-09-26 03:07:06 -05:00
|
|
|
static const int numWellEq = GET_PROP_VALUE(TypeTag, EnablePolymer)? numEq : numEq + 1;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-10-23 02:09:45 -05:00
|
|
|
MultisegmentWell(const Well& well, const int time_step,
|
2017-11-23 01:37:30 -06:00
|
|
|
const ModelParameters& param,
|
|
|
|
const RateConverterType& rate_converter,
|
2017-11-30 09:31:48 -06:00
|
|
|
const int pvtRegionIdx,
|
2019-10-23 02:09:45 -05:00
|
|
|
const int num_components,
|
|
|
|
const int num_phases,
|
|
|
|
const int index_of_well,
|
|
|
|
const int first_perf_index,
|
|
|
|
const std::vector<PerforationData>& perf_data);
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
virtual void init(const PhaseUsage* phase_usage_arg,
|
|
|
|
const std::vector<double>& depth_arg,
|
|
|
|
const double gravity_arg,
|
2018-08-16 04:51:36 -05:00
|
|
|
const int num_cells) override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void initPrimaryVariablesEvaluation() const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void assembleWellEq(const Simulator& ebosSimulator,
|
2019-02-27 07:47:31 -06:00
|
|
|
const std::vector<Scalar>& B_avg,
|
2017-08-17 08:49:54 -05:00
|
|
|
const double dt,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2018-11-15 03:08:03 -06:00
|
|
|
/// updating the well state based the current control mode
|
2018-11-23 06:11:48 -06:00
|
|
|
virtual void updateWellStateWithTarget(const Simulator& ebos_simulator,
|
2019-02-03 01:13:11 -06:00
|
|
|
WellState& well_state,
|
2019-05-24 09:45:27 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
/// check whether the well equations get converged for this well
|
2020-05-12 05:05:30 -05:00
|
|
|
virtual ConvergenceReport getWellConvergence(const WellState& well_state, const std::vector<double>& B_avg, Opm::DeferredLogger& deferred_logger, const bool relax_tolerance = false) const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
/// Ax = Ax - C D^-1 B x
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void apply(const BVector& x, BVector& Ax) const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
/// r = r - C D^-1 Rw
|
2018-08-16 04:51:36 -05:00
|
|
|
virtual void apply(BVector& r) const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2020-06-25 11:44:49 -05:00
|
|
|
#if HAVE_CUDA || HAVE_OPENCL
|
2020-05-15 09:00:09 -05:00
|
|
|
/// add the contribution (C, D, B matrices) of this Well to the WellContributions object
|
|
|
|
void addWellContribution(WellContributions& wellContribs) const;
|
|
|
|
#endif
|
|
|
|
|
2017-08-17 08:49:54 -05:00
|
|
|
/// using the solution x to recover the solution xw for wells and applying
|
|
|
|
/// xw to update Well State
|
2017-10-16 09:46:28 -05:00
|
|
|
virtual void recoverWellSolutionAndUpdateWellState(const BVector& x,
|
2019-02-07 07:43:17 -06:00
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
/// computing the well potentials for group control
|
|
|
|
virtual void computeWellPotentials(const Simulator& ebosSimulator,
|
2019-04-23 06:30:12 -05:00
|
|
|
const std::vector<Scalar>& B_avg,
|
2017-08-17 08:49:54 -05:00
|
|
|
const WellState& well_state,
|
2019-02-03 01:13:11 -06:00
|
|
|
std::vector<double>& well_potentials,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual void updatePrimaryVariables(const WellState& well_state, Opm::DeferredLogger& deferred_logger) const override;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
virtual void solveEqAndUpdateWellState(WellState& well_state, Opm::DeferredLogger& deferred_logger) override; // const?
|
2017-08-29 10:26:36 -05:00
|
|
|
|
2017-09-05 04:20:43 -05:00
|
|
|
virtual void calculateExplicitQuantities(const Simulator& ebosSimulator,
|
2019-02-07 07:43:17 -06:00
|
|
|
const WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override; // should be const?
|
2017-09-05 04:09:58 -05:00
|
|
|
|
2019-10-02 05:48:29 -05:00
|
|
|
virtual void addWellContributions(SparseMatrixAdapter& jacobian) const override;
|
2019-08-15 04:29:30 -05:00
|
|
|
|
2017-08-28 10:30:22 -05:00
|
|
|
/// number of segments for this well
|
|
|
|
/// int number_of_segments_;
|
|
|
|
int numberOfSegments() const;
|
|
|
|
|
|
|
|
int numberOfPerforations() const;
|
|
|
|
|
2017-08-17 08:49:54 -05:00
|
|
|
protected:
|
|
|
|
int number_segments_;
|
|
|
|
|
|
|
|
// components of the pressure drop to be included
|
2019-08-27 17:30:12 -05:00
|
|
|
WellSegments::CompPressureDrop compPressureDrop() const;
|
2017-08-17 08:49:54 -05:00
|
|
|
// multi-phase flow model
|
2019-08-27 17:30:12 -05:00
|
|
|
WellSegments::MultiPhaseModel multiphaseModel() const;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2018-06-17 07:42:14 -05:00
|
|
|
// get the WellSegments from the well_ecl_
|
|
|
|
const WellSegments& segmentSet() const;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2017-09-04 05:42:23 -05:00
|
|
|
// protected member variables from the Base class
|
2017-08-17 08:49:54 -05:00
|
|
|
using Base::well_ecl_;
|
2019-11-01 04:04:44 -05:00
|
|
|
using Base::vfp_properties_;
|
|
|
|
using Base::ref_depth_;
|
2017-08-17 08:49:54 -05:00
|
|
|
using Base::number_of_perforations_; // TODO: can use well_ecl_?
|
2017-09-01 10:37:51 -05:00
|
|
|
using Base::current_step_;
|
2017-09-04 05:42:23 -05:00
|
|
|
using Base::index_of_well_;
|
|
|
|
using Base::number_of_phases_;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2017-10-03 09:25:51 -05:00
|
|
|
// TODO: the current implementation really relies on the order of the
|
|
|
|
// perforation does not change from the parser to Wells structure.
|
|
|
|
using Base::well_cells_;
|
2017-10-16 09:46:28 -05:00
|
|
|
using Base::param_;
|
2017-08-17 08:49:54 -05:00
|
|
|
using Base::well_index_;
|
2017-09-04 07:47:27 -05:00
|
|
|
using Base::first_perf_;
|
2017-09-08 07:58:57 -05:00
|
|
|
using Base::saturation_table_number_;
|
|
|
|
using Base::well_efficiency_factor_;
|
2017-09-12 07:26:32 -05:00
|
|
|
using Base::gravity_;
|
2017-09-28 09:01:11 -05:00
|
|
|
using Base::perf_depth_;
|
2017-11-30 09:31:48 -06:00
|
|
|
using Base::num_components_;
|
2018-11-15 07:37:01 -06:00
|
|
|
using Base::connectionRates_;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
2017-09-04 05:42:23 -05:00
|
|
|
// protected functions from the Base class
|
2017-09-04 07:47:27 -05:00
|
|
|
using Base::phaseUsage;
|
2017-09-04 10:58:37 -05:00
|
|
|
using Base::name;
|
2017-09-08 07:58:57 -05:00
|
|
|
using Base::flowPhaseToEbosCompIdx;
|
2017-12-04 02:14:08 -06:00
|
|
|
using Base::ebosCompIdxToFlowCompIdx;
|
2017-09-08 07:58:57 -05:00
|
|
|
using Base::getAllowCrossFlow;
|
2017-11-23 01:37:30 -06:00
|
|
|
using Base::scalingFactor;
|
2019-08-07 07:13:11 -05:00
|
|
|
using Base::wellIsStopped_;
|
|
|
|
|
2017-09-04 05:42:23 -05:00
|
|
|
|
2017-08-17 08:49:54 -05:00
|
|
|
// TODO: trying to use the information from the Well opm-parser as much
|
|
|
|
// as possible, it will possibly be re-implemented later for efficiency reason.
|
|
|
|
|
2017-08-31 11:22:48 -05:00
|
|
|
// the completions that is related to each segment
|
2017-10-16 07:39:07 -05:00
|
|
|
// the completions's ids are their index in the vector well_index_, well_cell_
|
2017-08-31 11:22:48 -05:00
|
|
|
// This is also assuming the order of the completions in Well is the same with
|
|
|
|
// the order of the completions in wells.
|
|
|
|
// it is for convinience reason. we can just calcuate the inforation for segment once then using it for all the perofrations
|
|
|
|
// belonging to this segment
|
2017-09-01 10:37:51 -05:00
|
|
|
std::vector<std::vector<int> > segment_perforations_;
|
|
|
|
|
|
|
|
// the inlet segments for each segment. It is for convinience and efficiency reason
|
|
|
|
std::vector<std::vector<int> > segment_inlets_;
|
2017-08-31 11:22:48 -05:00
|
|
|
|
2017-08-17 08:49:54 -05:00
|
|
|
// segment number is an ID of the segment, it is specified in the deck
|
|
|
|
// get the loation of the segment with a segment number in the segmentSet
|
2017-10-16 07:39:07 -05:00
|
|
|
int segmentNumberToIndex(const int segment_number) const;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
// 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
|
2017-09-13 10:48:08 -05:00
|
|
|
mutable DiagMatWell duneD_;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
// residuals of the well equations
|
2017-09-01 10:37:51 -05:00
|
|
|
mutable BVectorWell resWell_;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
// the values for the primary varibles
|
|
|
|
// based on different solutioin strategies, the wells can have different primary variables
|
2017-08-29 10:26:36 -05:00
|
|
|
mutable std::vector<std::array<double, numWellEq> > primary_variables_;
|
2017-08-17 08:49:54 -05:00
|
|
|
|
|
|
|
// the Evaluation for the well primary variables, which contain derivativles and are used in AD calculation
|
2017-08-29 10:26:36 -05:00
|
|
|
mutable std::vector<std::array<EvalWell, numWellEq> > primary_variables_evaluation_;
|
|
|
|
|
2017-09-28 09:01:11 -05:00
|
|
|
// depth difference between perforations and the perforated grid cells
|
2017-10-02 11:29:03 -05:00
|
|
|
std::vector<double> cell_perforation_depth_diffs_;
|
2017-09-05 08:16:04 -05:00
|
|
|
// pressure correction due to the different depth of the perforation and
|
|
|
|
// center depth of the grid block
|
2017-10-02 11:29:03 -05:00
|
|
|
std::vector<double> cell_perforation_pressure_diffs_;
|
2017-09-05 08:16:04 -05:00
|
|
|
|
2017-09-08 04:09:54 -05:00
|
|
|
// depth difference between the segment and the peforation
|
|
|
|
// or in another way, the depth difference between the perforation and
|
|
|
|
// the segment the perforation belongs to
|
2017-10-02 11:29:03 -05:00
|
|
|
std::vector<double> perforation_segment_depth_diffs_;
|
2017-09-08 04:09:54 -05:00
|
|
|
|
2019-02-12 05:48:51 -06:00
|
|
|
// the intial amount of fluids in each segment under surface condition
|
|
|
|
std::vector<std::vector<double> > segment_fluid_initial_;
|
2017-09-05 08:16:04 -05:00
|
|
|
|
2017-09-08 04:09:54 -05:00
|
|
|
// the densities of segment fluids
|
|
|
|
// we should not have this member variable
|
|
|
|
std::vector<EvalWell> segment_densities_;
|
|
|
|
|
2017-09-28 04:00:10 -05:00
|
|
|
// the viscosity of the segments
|
2017-09-28 03:04:04 -05:00
|
|
|
std::vector<EvalWell> segment_viscosities_;
|
|
|
|
|
2017-09-28 06:11:35 -05:00
|
|
|
// the mass rate of the segments
|
|
|
|
std::vector<EvalWell> segment_mass_rates_;
|
|
|
|
|
2017-09-12 07:26:32 -05:00
|
|
|
std::vector<double> segment_depth_diffs_;
|
|
|
|
|
2019-04-12 08:43:39 -05:00
|
|
|
// the upwinding segment for each segment based on the flow direction
|
|
|
|
std::vector<int> upwinding_segments_;
|
|
|
|
|
2019-11-18 09:33:10 -06:00
|
|
|
mutable int debug_cost_counter_ = 0;
|
|
|
|
|
2019-11-24 04:11:50 -06:00
|
|
|
std::vector<std::vector<EvalWell>> segment_phase_fractions_;
|
|
|
|
|
|
|
|
std::vector<std::vector<EvalWell>> segment_phase_viscosities_;
|
|
|
|
|
|
|
|
|
2017-09-01 10:37:51 -05:00
|
|
|
void initMatrixAndVectors(const int num_cells) const;
|
|
|
|
|
2020-03-24 05:07:14 -05:00
|
|
|
EvalWell getBhp() const;
|
|
|
|
EvalWell getQs(const int comp_idx) const;
|
|
|
|
EvalWell getWQTotal() const;
|
|
|
|
|
2017-08-29 10:26:36 -05:00
|
|
|
// 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,
|
2019-02-07 07:43:17 -06:00
|
|
|
WellState& well_state,
|
2019-11-01 04:04:44 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger,
|
2019-03-08 06:50:34 -06:00
|
|
|
const double relaxation_factor=1.0) const;
|
|
|
|
|
2017-08-29 10:26:36 -05:00
|
|
|
|
2017-10-12 05:01:48 -05:00
|
|
|
// initialize the segment rates with well rates
|
|
|
|
// when there is no more accurate way to initialize the segment rates, we initialize
|
|
|
|
// the segment rates based on well rates with a simple strategy
|
|
|
|
void initSegmentRatesWithWellRates(WellState& well_state) const;
|
|
|
|
|
2017-09-05 04:20:43 -05:00
|
|
|
// computing the accumulation term for later use in well mass equations
|
2019-02-12 05:48:51 -06:00
|
|
|
void computeInitialSegmentFluids(const Simulator& ebos_simulator);
|
2017-09-05 08:16:04 -05:00
|
|
|
|
|
|
|
// 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
|
2017-12-04 02:14:08 -06:00
|
|
|
EvalWell volumeFraction(const int seg, const unsigned comp_idx) const;
|
2017-09-05 08:16:04 -05:00
|
|
|
|
|
|
|
// 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;
|
2017-09-05 04:20:43 -05:00
|
|
|
|
2019-04-05 03:01:16 -05:00
|
|
|
void computePerfRatePressure(const IntensiveQuantities& int_quants,
|
|
|
|
const std::vector<EvalWell>& mob_perfcells,
|
|
|
|
const int seg,
|
|
|
|
const int perf,
|
|
|
|
const EvalWell& segment_pressure,
|
|
|
|
const bool& allow_cf,
|
|
|
|
std::vector<EvalWell>& cq_s,
|
|
|
|
EvalWell& perf_press,
|
2019-04-23 06:30:12 -05:00
|
|
|
double& perf_dis_gas_rate,
|
|
|
|
double& perf_vap_oil_rate,
|
2019-04-05 03:01:16 -05:00
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2017-09-08 04:09:54 -05:00
|
|
|
|
|
|
|
// convert a Eval from reservoir to contain the derivative related to wells
|
|
|
|
EvalWell extendEval(const Eval& in) const;
|
|
|
|
|
2019-11-01 04:04:44 -05:00
|
|
|
|
|
|
|
template <class ValueType>
|
2019-11-13 16:16:11 -06:00
|
|
|
ValueType calculateBhpFromThp(const std::vector<ValueType>& rates, const Well& well, const SummaryState& summaryState, Opm::DeferredLogger& deferred_logger) const;
|
2019-11-01 04:04:44 -05:00
|
|
|
|
|
|
|
double calculateThpFromBhp(const std::vector<double>& rates, const double bhp, Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
void updateThp(WellState& well_state, Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
2017-10-03 09:25:51 -05:00
|
|
|
// compute the fluid properties, such as densities, viscosities, and so on, in the segments
|
2017-09-08 04:09:54 -05:00
|
|
|
// They will be treated implicitly, so they need to be of Evaluation type
|
2017-09-21 08:58:01 -05:00
|
|
|
void computeSegmentFluidProperties(const Simulator& ebosSimulator);
|
2017-09-08 04:09:54 -05:00
|
|
|
|
|
|
|
EvalWell getSegmentPressure(const int seg) const;
|
|
|
|
|
2017-09-08 07:58:57 -05:00
|
|
|
EvalWell getSegmentRate(const int seg, const int comp_idx) const;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
EvalWell getSegmentRateUpwinding(const int seg, const size_t comp_idx) const;
|
2019-04-08 04:40:37 -05:00
|
|
|
|
2017-09-11 10:31:42 -05:00
|
|
|
EvalWell getSegmentGTotal(const int seg) const;
|
|
|
|
|
2017-09-08 07:58:57 -05:00
|
|
|
// get the mobility for specific perforation
|
|
|
|
void getMobility(const Simulator& ebosSimulator,
|
|
|
|
const int perf,
|
|
|
|
std::vector<EvalWell>& mob) const;
|
2017-09-11 10:31:42 -05:00
|
|
|
|
2019-11-18 09:33:10 -06:00
|
|
|
void computeWellRatesAtBhpLimit(const Simulator& ebosSimulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
std::vector<double>& well_flux,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
void computeWellRatesWithBhp(const Simulator& ebosSimulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
const Scalar bhp,
|
|
|
|
std::vector<double>& well_flux,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
std::vector<double>
|
|
|
|
computeWellPotentialWithTHP(const Simulator& ebos_simulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
2019-04-23 06:30:12 -05:00
|
|
|
|
2019-12-05 05:40:35 -06:00
|
|
|
void assembleControlEq(const WellState& well_state,
|
|
|
|
const Opm::Schedule& schedule,
|
|
|
|
const SummaryState& summaryState,
|
|
|
|
const Well::InjectionControls& inj_controls,
|
|
|
|
const Well::ProductionControls& prod_controls,
|
|
|
|
Opm::DeferredLogger& deferred_logger);
|
|
|
|
|
2020-03-29 17:35:42 -05:00
|
|
|
void assemblePressureEq(const int seg, WellState& well_state) const;
|
2017-09-12 07:26:32 -05:00
|
|
|
|
|
|
|
// hytrostatic pressure loss
|
2017-09-18 07:10:09 -05:00
|
|
|
EvalWell getHydroPressureLoss(const int seg) const;
|
2017-09-12 10:13:30 -05:00
|
|
|
|
2017-09-28 04:00:10 -05:00
|
|
|
// frictinal pressure loss
|
|
|
|
EvalWell getFrictionPressureLoss(const int seg) const;
|
|
|
|
|
2020-03-29 17:35:42 -05:00
|
|
|
void handleAccelerationPressureLoss(const int seg, WellState& well_state) const;
|
2017-09-28 08:12:09 -05:00
|
|
|
|
2017-09-12 10:13:30 -05:00
|
|
|
// handling the overshooting and undershooting of the fractions
|
2017-09-12 10:32:27 -05:00
|
|
|
void processFractions(const int seg) const;
|
|
|
|
|
2018-11-15 07:31:41 -06:00
|
|
|
// checking the operability of the well based on current reservoir condition
|
|
|
|
// it is not implemented for multisegment well yet
|
2018-11-22 00:02:29 -06:00
|
|
|
virtual void checkWellOperability(const Simulator& ebos_simulator,
|
2019-02-03 01:13:11 -06:00
|
|
|
const WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2018-11-15 07:31:41 -06:00
|
|
|
|
2019-11-01 04:04:44 -05:00
|
|
|
void updateWellStateFromPrimaryVariables(WellState& well_state, Opm::DeferredLogger& deferred_logger) const;
|
2017-09-26 03:07:06 -05:00
|
|
|
|
2017-09-28 08:12:09 -05:00
|
|
|
bool frictionalPressureLossConsidered() const;
|
|
|
|
|
|
|
|
bool accelerationalPressureLossConsidered() const;
|
2017-10-10 07:30:23 -05:00
|
|
|
|
2020-06-09 16:35:58 -05:00
|
|
|
virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
const double dt,
|
|
|
|
const Well::InjectionControls& inj_controls,
|
|
|
|
const Well::ProductionControls& prod_controls,
|
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
2018-11-30 05:15:51 -06:00
|
|
|
|
2020-01-29 02:13:25 -06:00
|
|
|
virtual void assembleWellEqWithoutIteration(const Simulator& ebosSimulator,
|
|
|
|
const double dt,
|
|
|
|
const Well::InjectionControls& inj_controls,
|
|
|
|
const Well::ProductionControls& prod_controls,
|
|
|
|
WellState& well_state,
|
|
|
|
Opm::DeferredLogger& deferred_logger) override;
|
|
|
|
|
2020-06-09 16:35:58 -05:00
|
|
|
virtual void wellTestingPhysical(const Simulator& simulator, const std::vector<double>& B_avg,
|
|
|
|
const double simulation_time, const int report_step,
|
|
|
|
WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger) override;
|
|
|
|
|
2018-11-30 05:15:51 -06:00
|
|
|
virtual void updateWaterThroughput(const double dt, WellState& well_state) const override;
|
2019-02-12 05:48:51 -06:00
|
|
|
|
|
|
|
EvalWell getSegmentSurfaceVolume(const Simulator& ebos_simulator, const int seg_idx) const;
|
|
|
|
|
2019-03-08 06:50:34 -06:00
|
|
|
std::vector<Scalar> getWellResiduals(const std::vector<Scalar>& B_avg) const;
|
|
|
|
|
|
|
|
void detectOscillations(const std::vector<double>& measure_history,
|
|
|
|
const int it, bool& oscillate, bool& stagnate) const;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
double getResidualMeasureValue(const WellState& well_state,
|
|
|
|
const std::vector<double>& residuals,
|
2019-05-09 06:12:32 -05:00
|
|
|
DeferredLogger& deferred_logger) const;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
double getControlTolerance(const WellState& well_state, DeferredLogger& deferred_logger) const;
|
2019-05-09 06:12:32 -05:00
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
void checkConvergenceControlEq(const WellState& well_state,
|
|
|
|
ConvergenceReport& report,
|
2019-05-09 06:12:32 -05:00
|
|
|
DeferredLogger& deferred_logger) const;
|
2019-03-08 06:50:34 -06:00
|
|
|
|
2019-04-12 08:43:39 -05:00
|
|
|
void updateUpwindingSegments();
|
|
|
|
|
2019-11-07 07:01:21 -06:00
|
|
|
// 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
|
|
|
|
// well rates, it can cause problem for THP calculation
|
|
|
|
// TODO: looking for better alternative to avoid wrong-signed well rates
|
|
|
|
bool openCrossFlowAvoidSingularity(const Simulator& ebos_simulator) const;
|
|
|
|
|
|
|
|
// for a well, when all drawdown are in the wrong direction, then this well will not
|
|
|
|
// be able to produce/inject .
|
|
|
|
bool allDrawDownWrongDirection(const Simulator& ebos_simulator) const;
|
|
|
|
|
2019-11-24 04:11:50 -06:00
|
|
|
|
2020-02-19 04:02:13 -06:00
|
|
|
std::optional<double> computeBhpAtThpLimitProd(const Simulator& ebos_simulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
const SummaryState& summary_state,
|
|
|
|
DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
std::optional<double> computeBhpAtThpLimitInj(const Simulator& ebos_simulator,
|
|
|
|
const std::vector<Scalar>& B_avg,
|
|
|
|
const SummaryState& summary_state,
|
|
|
|
DeferredLogger& deferred_logger) const;
|
2019-11-18 09:33:10 -06:00
|
|
|
|
|
|
|
double maxPerfPress(const Simulator& ebos_simulator) const;
|
2019-11-24 04:11:50 -06:00
|
|
|
|
2020-03-29 17:35:42 -05:00
|
|
|
void assembleSICDPressureEq(const int seg, WellState& well_state) const;
|
2019-11-24 04:11:50 -06:00
|
|
|
|
|
|
|
EvalWell pressureDropSpiralICD(const int seg) const;
|
|
|
|
|
2019-11-29 10:23:26 -06:00
|
|
|
// assemble the pressure equation for sub-critical valve (WSEGVALV)
|
2020-03-29 17:35:42 -05:00
|
|
|
void assembleValvePressureEq(const int seg, WellState& well_state) const;
|
2019-11-29 10:23:26 -06:00
|
|
|
|
|
|
|
EvalWell pressureDropValve(const int seg) const;
|
2017-09-27 11:16:45 -05:00
|
|
|
};
|
2017-09-13 10:10:34 -05:00
|
|
|
|
2017-08-17 08:49:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "MultisegmentWell_impl.hpp"
|
|
|
|
|
|
|
|
#endif // OPM_MULTISEGMENTWELL_HEADER_INCLUDED
|