opm-simulators
WellInterfaceFluidSystem.hpp
1 /*
2  Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3  Copyright 2017 Statoil ASA.
4  Copyright 2017 IRIS
5  Copyright 2019 Norce
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 
24 #ifndef OPM_WELLINTERFACE_FLUID_SYSTEM_HEADER_INCLUDED
25 #define OPM_WELLINTERFACE_FLUID_SYSTEM_HEADER_INCLUDED
26 
27 #include <opm/simulators/wells/WellInterfaceGeneric.hpp>
28 
29 #include <limits>
30 #include <optional>
31 #include <vector>
32 
33 namespace Opm
34 {
35 namespace RateConverter
36 {
37  template <class FluidSystem, class Region> class SurfaceToReservoirVoidage;
38 }
39 
40 class Group;
41 template<class Scalar> class GroupState;
42 class Schedule;
43 struct RatioLimitCheckReport;
44 template<typename Scalar, typename IndexTraits> class SingleWellState;
45 template<typename Scalar, typename IndexTraits> class WellState;
46 template<typename Scalar, typename IndexTraits> class GroupStateHelper;
47 
48 template<class FluidSystem>
49 class WellInterfaceFluidSystem : public WellInterfaceGeneric<typename FluidSystem::Scalar, typename FluidSystem::IndexTraitsType>
50 {
51 protected:
52  using RateConverterType = RateConverter::
53  SurfaceToReservoirVoidage<FluidSystem, std::vector<int>>;
54  // to indicate a invalid completion
55  static constexpr int INVALIDCOMPLETION = std::numeric_limits<int>::max();
56 
57 public:
58  using Scalar = typename FluidSystem::Scalar;
59  using IndexTraits = typename FluidSystem::IndexTraitsType;
60  using ModelParameters = typename WellInterfaceGeneric<Scalar, IndexTraits>::ModelParameters;
61  using GroupStateHelperType = GroupStateHelper<Scalar, IndexTraits>;
62  using WellStateType = WellState<Scalar, IndexTraits>;
63 
64  static constexpr int Water = IndexTraits::waterPhaseIdx;
65  static constexpr int Oil = IndexTraits::oilPhaseIdx;
66  static constexpr int Gas = IndexTraits::gasPhaseIdx;
67 
68  const RateConverterType& rateConverter() const
69  {
70  return rateConverter_;
71  }
72 
73 protected:
74  WellInterfaceFluidSystem(const Well& well,
75  const ParallelWellInfo<Scalar>& parallel_well_info,
76  const int time_step,
77  const ModelParameters& param,
78  const RateConverterType& rate_converter,
79  const int pvtRegionIdx,
80  const int num_conservation_quantities,
81  const int num_phases,
82  const int index_of_well,
83  const std::vector<PerforationData<Scalar>>& perf_data);
84 
85  // updating the voidage rates in well_state when requested
86  void calculateReservoirRates(const bool use_well_bhp_temperature, SingleWellState<Scalar, IndexTraits>& ws) const;
87 
88  bool checkIndividualConstraints(SingleWellState<Scalar, IndexTraits>& ws,
89  const SummaryState& summaryState,
90  DeferredLogger& deferred_logger,
91  const std::optional<Well::InjectionControls>& inj_controls = std::nullopt,
92  const std::optional<Well::ProductionControls>& prod_controls = std::nullopt) const;
93 
94  bool checkGroupConstraints(const GroupStateHelperType& groupStateHelper,
95  const Schedule& schedule,
96  const SummaryState& summaryState,
97  const bool check_guide_rate,
98  WellStateType& well_state) const;
99 
100  bool checkConstraints(const GroupStateHelperType& groupStateHelper,
101  const Schedule& schedule,
102  const SummaryState& summaryState,
103  WellStateType& well_state) const;
104 
105  std::optional<Scalar>
106  getGroupInjectionTargetRate(const Group& group,
107  const GroupStateHelperType& groupStateHelper,
108  const InjectorType& injectorType,
109  Scalar efficiencyFactor) const;
110 
111  Scalar
112  getGroupProductionTargetRate(const Group& group,
113  const GroupStateHelperType& groupStateHelper,
114  Scalar efficiencyFactor) const;
115 
116  bool zeroGroupRateTarget(const GroupStateHelperType& groupStateHelper) const;
117 
118  // For the conversion between the surface volume rate and reservoir voidage rate
119  const RateConverterType& rateConverter_;
120 };
121 
122 }
123 
124 #endif // OPM_WELLINTERFACE_FLUID_SYSTEM_HEADER_INCLUDED
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45