2017-06-15 04:34:07 -05:00
|
|
|
/*
|
|
|
|
Copyright 2017 SINTEF ICT, Applied Mathematics.
|
|
|
|
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_WELLINTERFACE_HEADER_INCLUDED
|
|
|
|
#define OPM_WELLINTERFACE_HEADER_INCLUDED
|
|
|
|
|
2017-06-20 03:54:33 -05:00
|
|
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
|
|
|
#include <opm/core/wells.h>
|
|
|
|
#include <opm/core/well_controls.h>
|
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
|
|
|
|
|
|
|
#include <opm/autodiff/VFPProperties.hpp>
|
|
|
|
#include <opm/autodiff/VFPInjProperties.hpp>
|
|
|
|
#include <opm/autodiff/VFPProdProperties.hpp>
|
|
|
|
#include <opm/autodiff/WellHelpers.hpp>
|
|
|
|
#include <opm/autodiff/WellStateFullyImplicitBlackoilDense.hpp>
|
2017-06-22 08:37:54 -05:00
|
|
|
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
2017-06-15 04:34:07 -05:00
|
|
|
|
2017-06-27 09:04:04 -05:00
|
|
|
#include <opm/simulators/WellSwitchingLogger.hpp>
|
|
|
|
|
2017-07-21 07:21:17 -05:00
|
|
|
#include<dune/common/fmatrix.hh>
|
|
|
|
#include<dune/istl/bcrsmatrix.hh>
|
|
|
|
#include<dune/istl/matrixmatrix.hh>
|
|
|
|
|
|
|
|
#include <opm/material/densead/Math.hpp>
|
|
|
|
#include <opm/material/densead/Evaluation.hpp>
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
template<typename TypeTag>
|
2017-06-15 04:34:07 -05:00
|
|
|
class WellInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
using WellState = WellStateFullyImplicitBlackoilDense;
|
|
|
|
|
2017-06-26 07:35:43 -05:00
|
|
|
typedef BlackoilModelParameters ModelParameters;
|
2017-06-19 08:05:15 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Indices) BlackoilIndices;
|
2017-06-19 09:46:06 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, IntensiveQuantities) IntensiveQuantities;
|
2017-06-21 07:07:11 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
|
2017-06-19 08:05:15 -05:00
|
|
|
|
2017-07-21 07:21:17 -05:00
|
|
|
static const int numEq = BlackoilIndices::numEq;
|
|
|
|
typedef double Scalar;
|
|
|
|
|
|
|
|
typedef Dune::FieldVector<Scalar, numEq > VectorBlockType;
|
|
|
|
typedef Dune::FieldMatrix<Scalar, numEq, numEq > MatrixBlockType;
|
|
|
|
typedef Dune::BCRSMatrix <MatrixBlockType> Mat;
|
|
|
|
typedef Dune::BlockVector<VectorBlockType> BVector;
|
|
|
|
typedef DenseAd::Evaluation<double, /*size=*/numEq> Eval;
|
|
|
|
|
2017-06-19 09:46:06 -05:00
|
|
|
static const bool has_solvent = GET_PROP_VALUE(TypeTag, EnableSolvent);
|
2017-06-19 08:05:15 -05:00
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
/// Constructor
|
2017-06-27 05:17:36 -05:00
|
|
|
// TODO: Wel can be reference.
|
2017-06-15 10:19:49 -05:00
|
|
|
WellInterface(const Well* well, const int time_step, const Wells* wells);
|
2017-06-15 04:34:07 -05:00
|
|
|
|
|
|
|
/// Well name.
|
|
|
|
const std::string& name() const;
|
|
|
|
|
|
|
|
/// The index of the well in Wells struct
|
|
|
|
// It is used to locate the inforation in Wells and also WellState for now.
|
|
|
|
int indexOfWell() const;
|
|
|
|
|
|
|
|
/// Well type, INJECTOR or PRODUCER.
|
|
|
|
WellType wellType() const;
|
|
|
|
|
|
|
|
/// number of phases
|
|
|
|
int numberOfPhases() const;
|
|
|
|
|
|
|
|
/// Component fractions for each phase for the well
|
|
|
|
const std::vector<double>& compFrac() const;
|
|
|
|
|
|
|
|
/// Well controls
|
|
|
|
// TODO: later to see whether we need to return const.
|
|
|
|
WellControls* wellControls() const;
|
|
|
|
|
|
|
|
/// Number of the perforations
|
|
|
|
int numberOfPerforations() const;
|
|
|
|
|
|
|
|
/// Well productivity index for each perforation.
|
|
|
|
const std::vector<double>& wellIndex() const;
|
|
|
|
|
|
|
|
/// Depth of perforations
|
|
|
|
const std::vector<double>& perfDepth() const;
|
|
|
|
|
|
|
|
/// Indices of the grid cells/blocks that perforations are completed within.
|
|
|
|
const std::vector<int>& wellCells() const;
|
|
|
|
|
|
|
|
// TODO: the following function should be able to be removed by refactoring the well class
|
|
|
|
// It is probably only needed for StandardWell
|
|
|
|
/// the densities of the fluid in each perforation
|
|
|
|
virtual const std::vector<double>& perfDensities() const = 0;
|
|
|
|
virtual std::vector<double>& perfDensities() = 0;
|
|
|
|
|
|
|
|
/// the pressure difference between different perforations
|
|
|
|
virtual const std::vector<double>& perfPressureDiffs() const = 0;
|
|
|
|
virtual std::vector<double>& perfPressureDiffs() = 0;
|
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
// TODO: the parameters need to be optimized/adjusted
|
2017-06-28 08:20:25 -05:00
|
|
|
virtual void init(const PhaseUsage* phase_usage_arg,
|
|
|
|
const std::vector<bool>* active_arg,
|
|
|
|
const VFPProperties* vfp_properties_arg,
|
|
|
|
const double gravity_arg,
|
|
|
|
const int num_cells);
|
2017-06-15 04:34:07 -05:00
|
|
|
|
|
|
|
// TODO: temporary
|
|
|
|
virtual void setWellVariables(const WellState& well_state) = 0;
|
|
|
|
|
|
|
|
const std::vector<bool>& active() const;
|
|
|
|
|
|
|
|
const PhaseUsage& phaseUsage() const;
|
|
|
|
|
2017-06-19 08:05:15 -05:00
|
|
|
int flowPhaseToEbosCompIdx( const int phaseIdx ) const;
|
|
|
|
|
|
|
|
int flowToEbosPvIdx( const int flowPv ) const;
|
|
|
|
|
|
|
|
int flowPhaseToEbosPhaseIdx( const int phaseIdx ) const;
|
|
|
|
|
2017-06-19 09:46:06 -05:00
|
|
|
int numPhases() const;
|
|
|
|
|
|
|
|
int numComponents() const;
|
|
|
|
|
2017-06-28 07:22:16 -05:00
|
|
|
// simply returning allow_cf_
|
|
|
|
// TODO: to check whether needed, it causes name problem with the crossFlowAllowed
|
2017-06-21 07:07:11 -05:00
|
|
|
bool allowCrossFlow() const;
|
|
|
|
|
2017-06-28 07:22:16 -05:00
|
|
|
virtual bool crossFlowAllowed(const Simulator& ebosSimulator) const = 0;
|
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
// TODO: for this kind of function, maybe can make a function with parameter perf
|
|
|
|
const std::vector<int>& saturationTableNumber() const;
|
|
|
|
|
2017-07-24 07:48:57 -05:00
|
|
|
double wsolvent() const;
|
2017-06-23 03:58:46 -05:00
|
|
|
|
2017-06-26 07:35:43 -05:00
|
|
|
virtual bool getWellConvergence(Simulator& ebosSimulator,
|
2017-06-26 09:01:45 -05:00
|
|
|
const std::vector<double>& B_avg,
|
2017-06-26 07:35:43 -05:00
|
|
|
const ModelParameters& param) const = 0;
|
|
|
|
|
2017-06-26 09:01:45 -05:00
|
|
|
virtual void wellEqIteration(Simulator& ebosSimulator,
|
|
|
|
const ModelParameters& param,
|
|
|
|
WellState& well_state) = 0;
|
|
|
|
|
2017-06-27 05:17:36 -05:00
|
|
|
virtual void assembleWellEq(Simulator& ebosSimulator,
|
|
|
|
const double dt,
|
|
|
|
WellState& well_state,
|
|
|
|
bool only_wells) = 0;
|
|
|
|
|
2017-06-28 04:15:04 -05:00
|
|
|
virtual void updateWellStateWithTarget(const int current,
|
|
|
|
WellState& xw) const = 0;
|
|
|
|
|
|
|
|
virtual void updateWellControl(WellState& xw) const = 0;
|
|
|
|
|
2017-06-29 06:52:31 -05:00
|
|
|
virtual void computeAccumWell() = 0;
|
|
|
|
|
|
|
|
// TODO: it should come with a different name
|
|
|
|
// for MS well, the definition is different and should not use this name anymore
|
|
|
|
virtual void computeWellConnectionPressures(const Simulator& ebosSimulator,
|
|
|
|
const WellState& xw) = 0;
|
|
|
|
|
2017-07-21 07:21:17 -05:00
|
|
|
// Ax = Ax - C D^-1 B x
|
|
|
|
virtual void apply(const BVector& x, BVector& Ax) const = 0;
|
|
|
|
|
|
|
|
// r = r - C D^-1 Rw
|
|
|
|
virtual void apply(BVector& r) const = 0;
|
|
|
|
|
2017-07-21 08:30:34 -05:00
|
|
|
// using the solution x to recover the solution xw for wells and applying
|
|
|
|
// xw to update Well State
|
|
|
|
virtual void applySolutionWellState(const BVector& x, const ModelParameters& param,
|
|
|
|
WellState& well_state) const = 0;
|
|
|
|
|
2017-07-24 07:48:57 -05:00
|
|
|
void computeWellPotentials(const Simulator& ebosSimulator,
|
|
|
|
const WellState& well_state,
|
|
|
|
std::vector<double>& well_potentials) const;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
protected:
|
2017-06-19 09:46:06 -05:00
|
|
|
// TODO: some variables shared by all the wells should be made static
|
2017-06-15 04:34:07 -05:00
|
|
|
// well name
|
|
|
|
std::string name_;
|
|
|
|
|
|
|
|
// the index of well in Wells struct
|
|
|
|
int index_of_well_;
|
|
|
|
|
|
|
|
// well type
|
|
|
|
// INJECTOR or PRODUCER
|
|
|
|
enum WellType well_type_;
|
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
// whether the well allows crossflow
|
|
|
|
bool allow_cf_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// number of phases
|
|
|
|
int number_of_phases_;
|
|
|
|
|
|
|
|
// component fractions for each well
|
|
|
|
// typically, it should apply to injection wells
|
|
|
|
std::vector<double> comp_frac_;
|
|
|
|
|
|
|
|
// controls for this well
|
|
|
|
// TODO: later will check whehter to let it stay with pointer
|
|
|
|
struct WellControls* well_controls_;
|
|
|
|
|
|
|
|
// number of the perforations for this well
|
|
|
|
int number_of_perforations_;
|
|
|
|
|
2017-06-23 07:55:56 -05:00
|
|
|
// record the index of the first perforation
|
|
|
|
// TODO: it might not be needed if we refactor WellState to be a vector
|
|
|
|
// of states of individual well.
|
|
|
|
int first_perf_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// well index for each perforation
|
|
|
|
std::vector<double> well_index_;
|
|
|
|
|
|
|
|
// depth for each perforation
|
|
|
|
std::vector<double> perf_depth_;
|
|
|
|
|
2017-06-23 09:32:43 -05:00
|
|
|
// reference depth for the BHP
|
2017-07-19 04:51:19 -05:00
|
|
|
double ref_depth_;
|
2017-06-23 09:32:43 -05:00
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
double well_efficiency_factor_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
// cell index for each well perforation
|
|
|
|
std::vector<int> well_cell_;
|
|
|
|
|
2017-06-21 07:07:11 -05:00
|
|
|
// saturation table nubmer for each well perforation
|
|
|
|
std::vector<int> saturation_table_number_;
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
const PhaseUsage* phase_usage_;
|
|
|
|
|
|
|
|
const std::vector<bool>* active_;
|
|
|
|
|
|
|
|
const VFPProperties* vfp_properties_;
|
|
|
|
|
|
|
|
double gravity_;
|
2017-07-24 07:48:57 -05:00
|
|
|
|
|
|
|
bool wellHasTHPConstraints() const;
|
|
|
|
|
|
|
|
double mostStrictBhpFromBhpLimits() const;
|
2017-06-15 04:34:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-06-19 07:49:49 -05:00
|
|
|
#include "WellInterface_impl.hpp"
|
|
|
|
|
2017-06-15 04:34:07 -05:00
|
|
|
#endif // OPM_WELLINTERFACE_HEADER_INCLUDED
|