2021-06-01 08:49:24 -05: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPM_STANDARDWELL_EVAL_HEADER_INCLUDED
|
|
|
|
#define OPM_STANDARDWELL_EVAL_HEADER_INCLUDED
|
|
|
|
|
2022-11-11 14:37:08 -06:00
|
|
|
#include <opm/simulators/wells/StandardWellEquations.hpp>
|
2021-06-01 08:49:24 -05:00
|
|
|
#include <opm/simulators/wells/StandardWellGeneric.hpp>
|
2022-11-07 23:38:12 -06:00
|
|
|
#include <opm/simulators/wells/StandardWellPrimaryVariables.hpp>
|
2021-06-01 08:49:24 -05:00
|
|
|
|
|
|
|
#include <opm/material/densead/DynamicEvaluation.hpp>
|
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
class ConvergenceReport;
|
|
|
|
class DeferredLogger;
|
|
|
|
class GroupState;
|
|
|
|
class Schedule;
|
|
|
|
class SummaryState;
|
|
|
|
class WellContributions;
|
|
|
|
template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices;
|
|
|
|
class WellState;
|
|
|
|
|
|
|
|
template<class FluidSystem, class Indices, class Scalar>
|
|
|
|
class StandardWellEval : public StandardWellGeneric<Scalar>
|
|
|
|
{
|
|
|
|
protected:
|
2022-11-07 23:38:12 -06:00
|
|
|
using PrimaryVariables = StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>;
|
|
|
|
static constexpr int Bhp = PrimaryVariables::Bhp;
|
|
|
|
static constexpr int WQTotal= PrimaryVariables::WQTotal;
|
|
|
|
static constexpr int numWellConservationEq = PrimaryVariables::numWellConservationEq;
|
2022-11-11 14:41:24 -06:00
|
|
|
|
2022-11-07 23:38:12 -06:00
|
|
|
static constexpr bool has_wfrac_variable = PrimaryVariables::has_wfrac_variable;
|
|
|
|
static constexpr bool has_gfrac_variable = PrimaryVariables::has_gfrac_variable;
|
|
|
|
static constexpr int WFrac = PrimaryVariables::WFrac;
|
|
|
|
static constexpr int GFrac = PrimaryVariables::GFrac;
|
|
|
|
static constexpr int SFrac = PrimaryVariables::SFrac;
|
2021-06-01 08:49:24 -05:00
|
|
|
|
|
|
|
public:
|
2022-11-07 23:38:12 -06:00
|
|
|
using EvalWell = typename PrimaryVariables::EvalWell;
|
2021-06-01 08:49:24 -05:00
|
|
|
using Eval = DenseAd::Evaluation<Scalar, Indices::numEq>;
|
|
|
|
using BVectorWell = typename StandardWellGeneric<Scalar>::BVectorWell;
|
|
|
|
|
2022-11-11 14:37:08 -06:00
|
|
|
//! \brief Returns a const reference to equation system.
|
|
|
|
const StandardWellEquations<Scalar,Indices::numEq>& linSys() const
|
|
|
|
{ return linSys_; }
|
2021-06-01 08:49:24 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
StandardWellEval(const WellInterfaceIndices<FluidSystem,Indices,Scalar>& baseif);
|
|
|
|
|
|
|
|
const WellInterfaceIndices<FluidSystem,Indices,Scalar>& baseif_;
|
|
|
|
|
|
|
|
const EvalWell& getBhp() const
|
|
|
|
{
|
2022-11-07 23:38:12 -06:00
|
|
|
return primary_variables_.evaluation_[Bhp];
|
2021-06-01 08:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const EvalWell& getWQTotal() const
|
|
|
|
{
|
2022-11-07 23:38:12 -06:00
|
|
|
return primary_variables_.evaluation_[WQTotal];
|
2021-06-01 08:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
EvalWell extendEval(const Eval& in) const;
|
|
|
|
EvalWell getQs(const int compIdx) const;
|
|
|
|
EvalWell wellSurfaceVolumeFraction(const int compIdx) const;
|
|
|
|
EvalWell wellVolumeFraction(const unsigned compIdx) const;
|
|
|
|
EvalWell wellVolumeFractionScaled(const int phase) const;
|
|
|
|
|
|
|
|
// calculate a relaxation factor to avoid overshoot of the fractions for producers
|
|
|
|
// which might result in negative rates
|
|
|
|
static double relaxationFactorFractionsProducer(const std::vector<double>& primary_variables,
|
|
|
|
const BVectorWell& dwells);
|
|
|
|
|
|
|
|
// computing the accumulation term for later use in well mass equations
|
|
|
|
void computeAccumWell();
|
|
|
|
|
|
|
|
// TODO: not total sure whether it is a good idea to put this function here
|
|
|
|
// the major reason to put here is to avoid the usage of Wells struct
|
|
|
|
void computeConnectionDensities(const std::vector<double>& perfComponentRates,
|
|
|
|
const std::vector<double>& b_perf,
|
|
|
|
const std::vector<double>& rsmax_perf,
|
|
|
|
const std::vector<double>& rvmax_perf,
|
2022-05-03 04:54:41 -05:00
|
|
|
const std::vector<double>& rvwmax_perf,
|
2022-04-01 01:35:31 -05:00
|
|
|
const std::vector<double>& surf_dens_perf,
|
|
|
|
DeferredLogger& deferred_logger);
|
2021-06-01 08:49:24 -05:00
|
|
|
|
|
|
|
ConvergenceReport getWellConvergence(const WellState& well_state,
|
|
|
|
const std::vector<double>& B_avg,
|
|
|
|
const double maxResidualAllowed,
|
2021-09-06 03:08:28 -05:00
|
|
|
const double tol_wells,
|
|
|
|
const double relaxed_tolerance_flow,
|
|
|
|
const bool relax_tolerance,
|
2021-06-01 08:49:24 -05:00
|
|
|
std::vector<double>& res,
|
|
|
|
DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
void init(std::vector<double>& perf_depth,
|
|
|
|
const std::vector<double>& depth_arg,
|
|
|
|
const int num_cells,
|
|
|
|
const bool has_polymermw);
|
|
|
|
|
|
|
|
// handle the non reasonable fractions due to numerical overshoot
|
|
|
|
void processFractions() const;
|
|
|
|
|
|
|
|
void updatePrimaryVariables(const WellState& well_state,
|
|
|
|
DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
void updateWellStateFromPrimaryVariables(WellState& well_state,
|
|
|
|
DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
|
|
void updatePrimaryVariablesNewton(const BVectorWell& dwells,
|
|
|
|
const double dFLimit,
|
|
|
|
const double dBHPLimit) const;
|
|
|
|
|
2022-11-07 23:38:12 -06:00
|
|
|
mutable PrimaryVariables primary_variables_; //!< Primary variables for well
|
2021-06-01 08:49:24 -05:00
|
|
|
|
|
|
|
// the saturations in the well bore under surface conditions at the beginning of the time step
|
|
|
|
std::vector<double> F0_;
|
2022-11-11 14:37:08 -06:00
|
|
|
|
|
|
|
StandardWellEquations<Scalar,Indices::numEq> linSys_; //!< Linear equation system
|
2021-06-01 08:49:24 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPM_STANDARDWELL_EVAL_HEADER_INCLUDED
|