opm-simulators
EquilibrationHelpers.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
29 #ifndef OPM_EQUILIBRATION_HELPERS_HPP
30 #define OPM_EQUILIBRATION_HELPERS_HPP
31 
32 #include <opm/material/common/Tabulated1DFunction.hpp>
33 
34 #include <opm/input/eclipse/EclipseState/InitConfig/Equil.hpp>
35 
36 #include <memory>
37 #include <vector>
38 
39 /*
40  ---- synopsis of EquilibrationHelpers.hpp ----
41 
42  namespace Opm
43  {
44  namespace EQUIL {
45 
46  namespace Miscibility {
47  class RsFunction;
48  class NoMixing;
49  template <class FluidSystem>
50  class RsVD;
51  template <class FluidSystem>
52  class RsSatAtContact;
53  }
54 
55  class EquilReg;
56 
57 
58  template <class FluidSystem, class MaterialLawManager>
59  struct PcEq;
60 
61  template <class FluidSystem, class MaterialLawManager>
62  double satFromPc(const MaterialLawManager& materialLawManager,
63  const int phase,
64  const int cell,
65  const double targetPc,
66  const bool increasing = false)
67  template <class FluidSystem, class MaterialLawManager>
68  double satFromSumOfPcs(const MaterialLawManager& materialLawManager,
69  const int phase1,
70  const int phase2,
71  const int cell,
72  const double targetPc)
73  } // namespace Equil
74  } // namespace Opm
75 
76  ---- end of synopsis of EquilibrationHelpers.hpp ----
77 */
78 
79 namespace Opm {
80 
88 namespace EQUIL {
89 
94 namespace Miscibility {
95 
99 template<class Scalar>
101 {
102 public:
103  virtual ~RsFunction() = default;
104 
123  virtual Scalar operator()(const Scalar depth,
124  const Scalar press,
125  const Scalar temp,
126  const Scalar sat = 0.0) const = 0;
127 };
128 
129 
133 template<class Scalar>
134 class NoMixing : public RsFunction<Scalar>
135 {
136 public:
144  Scalar
145  operator()(const Scalar /* depth */,
146  const Scalar /* press */,
147  const Scalar /* temp */,
148  const Scalar /* sat */ = 0.0) const override
149  {
150  return 0.0;
151  }
152 };
153 
154 
160 template <class FluidSystem>
161 class RsVD : public RsFunction<typename FluidSystem::Scalar>
162 {
163 public:
164  using Scalar = typename FluidSystem::Scalar;
172  RsVD(const int pvtRegionIdx,
173  const std::vector<Scalar>& depth,
174  const std::vector<Scalar>& rs);
175 
194  Scalar operator()(const Scalar depth,
195  const Scalar press,
196  const Scalar temp,
197  const Scalar satGas = 0.0) const override;
198 
199 private:
200  using RsVsDepthFunc = Tabulated1DFunction<Scalar>;
201 
202  const int pvtRegionIdx_;
203  RsVsDepthFunc rsVsDepth_;
204 
205  Scalar satRs(const Scalar press, const Scalar temp) const;
206 };
207 
208 
214 template <class FluidSystem>
215 class PBVD : public RsFunction<typename FluidSystem::Scalar>
216 {
217 public:
218  using Scalar = typename FluidSystem::Scalar;
226  PBVD(const int pvtRegionIdx,
227  const std::vector<Scalar>& depth,
228  const std::vector<Scalar>& pbub);
229 
247  Scalar operator()(const Scalar depth,
248  const Scalar cellPress,
249  const Scalar temp,
250  const Scalar satGas = 0.0) const override;
251 
252 private:
253  using PbubVsDepthFunc = Tabulated1DFunction<Scalar>;
254 
255  const int pvtRegionIdx_;
256  PbubVsDepthFunc pbubVsDepth_;
257 
258  Scalar satRs(const Scalar press, const Scalar temp) const;
259 };
260 
261 
267 template <class FluidSystem>
268 class PDVD : public RsFunction<typename FluidSystem::Scalar>
269 {
270  using Scalar = typename FluidSystem::Scalar;
271 public:
279  PDVD(const int pvtRegionIdx,
280  const std::vector<Scalar>& depth,
281  const std::vector<Scalar>& pdew);
282 
300  Scalar operator()(const Scalar depth,
301  const Scalar cellPress,
302  const Scalar temp,
303  const Scalar satOil = 0.0) const override;
304 
305 private:
306  using PdewVsDepthFunc = Tabulated1DFunction<Scalar>;
307 
308  const int pvtRegionIdx_;
309  PdewVsDepthFunc pdewVsDepth_;
310 
311  Scalar satRv(const Scalar press, const Scalar temp) const;
312 };
313 
314 
320 template <class FluidSystem>
321 class RvVD : public RsFunction<typename FluidSystem::Scalar>
322 {
323  using Scalar = typename FluidSystem::Scalar;
324 public:
332  RvVD(const int pvtRegionIdx,
333  const std::vector<Scalar>& depth,
334  const std::vector<Scalar>& rv);
335 
354  Scalar operator()(const Scalar depth,
355  const Scalar press,
356  const Scalar temp,
357  const Scalar satOil = 0.0) const override;
358 
359 private:
360  using RvVsDepthFunc = Tabulated1DFunction<Scalar>;
361 
362  const int pvtRegionIdx_;
363  RvVsDepthFunc rvVsDepth_;
364 
365  Scalar satRv(const Scalar press, const Scalar temp) const;
366 };
367 
368 
374 template <class FluidSystem>
375 class RvwVD : public RsFunction<typename FluidSystem::Scalar>
376 {
377  using Scalar = typename FluidSystem::Scalar;
378 public:
386  RvwVD(const int pvtRegionIdx,
387  const std::vector<Scalar>& depth,
388  const std::vector<Scalar>& rvw);
389 
408  Scalar operator()(const Scalar depth,
409  const Scalar press,
410  const Scalar temp,
411  const Scalar satWat = 0.0) const override;
412 
413 private:
414  using RvwVsDepthFunc = Tabulated1DFunction<Scalar>;
415 
416  const int pvtRegionIdx_;
417  RvwVsDepthFunc rvwVsDepth_;
418 
419  Scalar satRvw(const Scalar press, const Scalar temp) const;
420 };
421 
422 
437 template <class FluidSystem>
438 class RsSatAtContact : public RsFunction<typename FluidSystem::Scalar>
439 {
440  using Scalar = typename FluidSystem::Scalar;
441 public:
449  RsSatAtContact(const int pvtRegionIdx,
450  const Scalar pContact,
451  const Scalar T_contact);
452 
471  Scalar operator()(const Scalar depth,
472  const Scalar press,
473  const Scalar temp,
474  const Scalar satGas = 0.0) const override;
475 
476 private:
477  const int pvtRegionIdx_;
478  Scalar rsSatContact_;
479 
480  Scalar satRs(const Scalar press, const Scalar temp) const;
481 };
482 
483 
498 template <class FluidSystem>
499 class RvSatAtContact : public RsFunction<typename FluidSystem::Scalar>
500 {
501  using Scalar = typename FluidSystem::Scalar;
502 public:
510  RvSatAtContact(const int pvtRegionIdx,
511  const Scalar pContact,
512  const Scalar T_contact);
513 
532  Scalar operator()(const Scalar depth,
533  const Scalar press,
534  const Scalar temp,
535  const Scalar satOil = 0.0) const override;
536 
537 private:
538  const int pvtRegionIdx_;
539  Scalar rvSatContact_;
540 
541  Scalar satRv(const Scalar press, const Scalar temp) const;
542 };
543 
558 template <class FluidSystem>
559 class RvwSatAtContact : public RsFunction<typename FluidSystem::Scalar>
560 {
561  using Scalar = typename FluidSystem::Scalar;
562 public:
570  RvwSatAtContact(const int pvtRegionIdx,
571  const Scalar pContact,
572  const Scalar T_contact);
573 
592  Scalar operator()(const Scalar depth,
593  const Scalar press,
594  const Scalar temp,
595  const Scalar satWat = 0.0) const override;
596 
597 private:
598  const int pvtRegionIdx_;
599  Scalar rvwSatContact_;
600 
601  Scalar satRvw(const Scalar press, const Scalar temp) const;
602 };
603 
610 template <class FluidSystem>
611 class RsConst : public RsFunction<typename FluidSystem::Scalar>
612 {
613 public:
614  using Scalar = typename FluidSystem::Scalar;
615 
622  RsConst(const Scalar rs_constant,
623  const Scalar pb_constant);
624 
629  Scalar operator()(const Scalar depth,
630  const Scalar press,
631  const Scalar temp,
632  const Scalar satGas = 0.0) const override;
633 
637  Scalar bubblePoint() const { return pb_constant_; }
638 
642  Scalar constantRs() const { return rs_constant_; }
643 
644  bool isConstantRs() const { return true; }
645 
646  Scalar satRs(const Scalar press, const Scalar temp) const;
647 
648 private:
649  Scalar rs_constant_{};
650  Scalar pb_constant_{};
651 };
652 
653 } // namespace Miscibility
654 
674 template<class Scalar>
675 class EquilReg
676 {
677  using TabulatedFunction = Tabulated1DFunction<Scalar>;
678 
679 public:
691  EquilReg(const EquilRecord& rec,
692  std::shared_ptr<Miscibility::RsFunction<Scalar>> rs,
693  std::shared_ptr<Miscibility::RsFunction<Scalar>> rv,
694  std::shared_ptr<Miscibility::RsFunction<Scalar>> rvw,
695  const TabulatedFunction& tempVdTable,
696  const TabulatedFunction& saltVdTable,
697  const int pvtIdx);
698 
703 
708 
713 
714 
718  Scalar datum() const;
719 
723  Scalar pressure() const;
724 
728  Scalar zwoc() const;
729 
735  Scalar pcowWoc() const;
736 
740  Scalar zgoc() const;
741 
747  Scalar pcgoGoc() const;
748 
756  int equilibrationAccuracy() const;
757 
762  const CalcDissolution& dissolutionCalculator() const;
763 
768  const CalcEvaporation& evaporationCalculator() const;
769 
775 
776  const TabulatedFunction& saltVdTable() const;
777  const TabulatedFunction& tempVdTable() const;
778 
782  int pvtIdx() const;
783 
784 private:
785  EquilRecord rec_;
786  std::shared_ptr<Miscibility::RsFunction<Scalar>> rs_;
787  std::shared_ptr<Miscibility::RsFunction<Scalar>> rv_;
788  std::shared_ptr<Miscibility::RsFunction<Scalar>> rvw_;
789  const TabulatedFunction& tempVdTable_;
790  const TabulatedFunction& saltVdTable_;
791  const int pvtIdx_;
792 };
793 
794 
795 
799 template <class FluidSystem, class MaterialLawManager>
800 struct PcEq
801 {
802  using Scalar = typename FluidSystem::Scalar;
803  PcEq(const MaterialLawManager& materialLawManager,
804  const int phase,
805  const int cell,
806  const Scalar targetPc);
807 
808  Scalar operator()(Scalar s) const;
809 
810 private:
811  const MaterialLawManager& materialLawManager_;
812  const int phase_;
813  const int cell_;
814  const Scalar targetPc_;
815 };
816 
817 template <class FluidSystem, class MaterialLawManager>
818 typename FluidSystem::Scalar
819 minSaturations(const MaterialLawManager& materialLawManager,
820  const int phase, const int cell);
821 
822 template <class FluidSystem, class MaterialLawManager>
823 typename FluidSystem::Scalar
824 maxSaturations(const MaterialLawManager& materialLawManager,
825  const int phase, const int cell);
826 
829 template <class FluidSystem, class MaterialLawManager>
830 typename FluidSystem::Scalar
831 satFromPc(const MaterialLawManager& materialLawManager,
832  const int phase,
833  const int cell,
834  const typename FluidSystem::Scalar targetPc,
835  const bool increasing = false);
836 
840 template <class FluidSystem, class MaterialLawManager>
841 struct PcEqSum
842 {
843  using Scalar = typename FluidSystem::Scalar;
844  PcEqSum(const MaterialLawManager& materialLawManager,
845  const int phase1,
846  const int phase2,
847  const int cell,
848  const Scalar targetPc);
849 
850  Scalar operator()(Scalar s) const;
851 
852 private:
853  const MaterialLawManager& materialLawManager_;
854  const int phase1_;
855  const int phase2_;
856  const int cell_;
857  const Scalar targetPc_;
858 };
859 
863 template <class FluidSystem, class MaterialLawManager>
864 typename FluidSystem::Scalar
865 satFromSumOfPcs(const MaterialLawManager& materialLawManager,
866  const int phase1,
867  const int phase2,
868  const int cell,
869  const typename FluidSystem::Scalar targetPc);
870 
872 template <class FluidSystem, class MaterialLawManager>
873 typename FluidSystem::Scalar
874 satFromDepth(const MaterialLawManager& materialLawManager,
875  const typename FluidSystem::Scalar cellDepth,
876  const typename FluidSystem::Scalar contactDepth,
877  const int phase,
878  const int cell,
879  const bool increasing = false);
880 
882 template <class FluidSystem, class MaterialLawManager>
883 bool isConstPc(const MaterialLawManager& materialLawManager,
884  const int phase,
885  const int cell);
886 
887 } // namespace Equil
888 } // namespace Opm
889 
890 #endif // OPM_EQUILIBRATION_HELPERS_HPP
Scalar zgoc() const
Depth of gas-oil contact.
Definition: EquilibrationHelpers_impl.hpp:450
RsConst(const Scalar rs_constant, const Scalar pb_constant)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:359
const CalcEvaporation & evaporationCalculator() const
Retrieve vapourised oil-gas ratio calculator of current region.
Definition: EquilibrationHelpers_impl.hpp:476
Aggregate information base of an equilibration region.
Definition: EquilibrationHelpers.hpp:675
Scalar bubblePoint() const
Get the constant bubble point pressure.
Definition: EquilibrationHelpers.hpp:637
int pvtIdx() const
Retrieve pvtIdx of the region.
Definition: EquilibrationHelpers_impl.hpp:503
const CalcDissolution & dissolutionCalculator() const
Retrieve dissolved gas-oil ratio calculator of current region.
Definition: EquilibrationHelpers_impl.hpp:469
RvVD(const int pvtRegionIdx, const std::vector< Scalar > &depth, const std::vector< Scalar > &rv)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:176
Scalar datum() const
Datum depth in current region.
Definition: EquilibrationHelpers_impl.hpp:426
Scalar constantRs() const
Get the constant Rs value.
Definition: EquilibrationHelpers.hpp:642
Type that implements "dissolved gas-oil ratio" tabulated as a function of depth policy.
Definition: EquilibrationHelpers.hpp:215
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satGas=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:75
Type that implements "vaporized oil-gas ratio" tabulated as a function of depth policy.
Definition: EquilibrationHelpers.hpp:268
RvSatAtContact(const int pvtRegionIdx, const Scalar pContact, const Scalar T_contact)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:296
FluidSystem::Scalar satFromPc(const MaterialLawManager &materialLawManager, const int phase, const int cell, const typename FluidSystem::Scalar targetPc, const bool increasing=false)
Compute saturation of some phase corresponding to a given capillary pressure.
Definition: EquilibrationHelpers_impl.hpp:639
int equilibrationAccuracy() const
Accuracy/strategy for initial fluid-in-place calculation.
Definition: EquilibrationHelpers_impl.hpp:462
Class that implements "vaporized oil-gas ratio" (Rv) as function of depth and pressure as follows: ...
Definition: EquilibrationHelpers.hpp:499
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satWat=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:337
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satOil=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:187
Functor for inverting a sum of capillary pressure functions.
Definition: EquilibrationHelpers.hpp:841
Scalar operator()(const Scalar depth, const Scalar cellPress, const Scalar temp, const Scalar satGas=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:113
virtual Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar sat=0.0) const =0
Function call operator.
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satWat=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:230
PBVD(const int pvtRegionIdx, const std::vector< Scalar > &depth, const std::vector< Scalar > &pbub)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:102
RvwSatAtContact(const int pvtRegionIdx, const Scalar pContact, const Scalar T_contact)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:328
Functor for inverting capillary pressure function.
Definition: EquilibrationHelpers.hpp:800
Class that implements "vaporized water-gas ratio" (Rvw) as function of depth and pressure as follows:...
Definition: EquilibrationHelpers.hpp:559
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satOil=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:305
bool isConstPc(const MaterialLawManager &materialLawManager, const int phase, const int cell)
Return true if capillary pressure function is constant.
Definition: EquilibrationHelpers_impl.hpp:723
Scalar pcgoGoc() const
Gas-oil capillary pressure at gas-oil contact.
Definition: EquilibrationHelpers_impl.hpp:456
Scalar operator()(const Scalar depth, const Scalar cellPress, const Scalar temp, const Scalar satOil=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:150
RvwVD(const int pvtRegionIdx, const std::vector< Scalar > &depth, const std::vector< Scalar > &rvw)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:219
Scalar pressure() const
Pressure at datum depth in current region.
Definition: EquilibrationHelpers_impl.hpp:432
RsVD(const int pvtRegionIdx, const std::vector< Scalar > &depth, const std::vector< Scalar > &rs)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:64
FluidSystem::Scalar satFromSumOfPcs(const MaterialLawManager &materialLawManager, const int phase1, const int phase2, const int cell, const typename FluidSystem::Scalar targetPc)
Compute saturation of some phase corresponding to a given capillary pressure, where the capillary pre...
Definition: EquilibrationHelpers_impl.hpp:672
FluidSystem::Scalar satFromDepth(const MaterialLawManager &materialLawManager, const typename FluidSystem::Scalar cellDepth, const typename FluidSystem::Scalar contactDepth, const int phase, const int cell, const bool increasing=false)
Compute saturation from depth. Used for constant capillary pressure function.
Definition: EquilibrationHelpers_impl.hpp:703
Scalar zwoc() const
Depth of water-oil contact.
Definition: EquilibrationHelpers_impl.hpp:438
Type that implements "constant dissolved gas-oil ratio" (Rs) from RSCONST keyword.
Definition: EquilibrationHelpers.hpp:611
PDVD(const int pvtRegionIdx, const std::vector< Scalar > &depth, const std::vector< Scalar > &pdew)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:139
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satGas=0.0) const override
Function call - returns constant Rs if pressure above bubble point.
Definition: EquilibrationHelpers_impl.hpp:385
Type that implements "vaporized water-gas ratio" tabulated as a function of depth policy...
Definition: EquilibrationHelpers.hpp:375
Base class for phase mixing functions.
Definition: EquilibrationHelpers.hpp:100
EquilReg(const EquilRecord &rec, std::shared_ptr< Miscibility::RsFunction< Scalar >> rs, std::shared_ptr< Miscibility::RsFunction< Scalar >> rv, std::shared_ptr< Miscibility::RsFunction< Scalar >> rvw, const TabulatedFunction &tempVdTable, const TabulatedFunction &saltVdTable, const int pvtIdx)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:408
const CalcWaterEvaporation & waterEvaporationCalculator() const
Retrieve vapourised water-gas ratio calculator of current region.
Definition: EquilibrationHelpers_impl.hpp:483
Scalar pcowWoc() const
water-oil capillary pressure at water-oil contact.
Definition: EquilibrationHelpers_impl.hpp:444
Type that implements "vaporized oil-gas ratio" tabulated as a function of depth policy.
Definition: EquilibrationHelpers.hpp:321
Type that implements "dissolved gas-oil ratio" tabulated as a function of depth policy.
Definition: EquilibrationHelpers.hpp:161
RsSatAtContact(const int pvtRegionIdx, const Scalar pContact, const Scalar T_contact)
Constructor.
Definition: EquilibrationHelpers_impl.hpp:264
Scalar operator()(const Scalar depth, const Scalar press, const Scalar temp, const Scalar satGas=0.0) const override
Function call.
Definition: EquilibrationHelpers_impl.hpp:273
Type that implements "no phase mixing" policy.
Definition: EquilibrationHelpers.hpp:134
Class that implements "dissolved gas-oil ratio" (Rs) as function of depth and pressure as follows: ...
Definition: EquilibrationHelpers.hpp:438
Scalar operator()(const Scalar, const Scalar, const Scalar, const Scalar=0.0) const override
Function call.
Definition: EquilibrationHelpers.hpp:145