EclHysteresisTwoPhaseLawParams.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  Copyright (C) 2015 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef OPM_ECL_HYSTERESIS_TWO_PHASE_LAW_PARAMS_HPP
26 #define OPM_ECL_HYSTERESIS_TWO_PHASE_LAW_PARAMS_HPP
27 
28 #include "EclHysteresisConfig.hpp"
29 #include "EclEpsScalingPoints.hpp"
30 
31 #if HAVE_OPM_PARSER
32 #include <opm/parser/eclipse/Deck/Deck.hpp>
33 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
34 #endif
35 
36 #include <string>
37 #include <memory>
38 #include <cassert>
39 #include <algorithm>
40 
41 namespace Opm {
48 template <class EffLawT>
50 {
51  typedef typename EffLawT::Params EffLawParams;
52  typedef typename EffLawParams::Traits::Scalar Scalar;
53 
54 public:
55  typedef typename EffLawParams::Traits Traits;
56 
58  {
59  pcSwMdc_ = 2.0;
60  krnSwMdc_ = 2.0;
61  // krwSwMdc_ = 2.0;
62 
63  deltaSwImbKrn_ = 0.0;
64  // deltaSwImbKrw_ = 0.0;
65 
66 #ifndef NDEBUG
67  finalized_ = false;
68 #endif
69  }
70 
75  void finalize()
76  {
77  if (config().enableHysteresis()) {
78  //C_ = 1.0/(Sncri_ - Sncrd_) + 1.0/(Snmaxd_ - Sncrd_);
79 
80  updateDynamicParams_();
81  }
82 
83 #ifndef NDEBUG
84  finalized_ = true;
85 #endif
86  }
87 
91  void setConfig(std::shared_ptr<EclHysteresisConfig> value)
92  { config_ = value; }
93 
97  const EclHysteresisConfig& config() const
98  { return *config_; }
99 
103  void setDrainageParams(std::shared_ptr<EffLawParams> value,
104  const EclEpsScalingPointsInfo<Scalar>& /* info */,
105  EclTwoPhaseSystemType /* twoPhaseSystem */)
106 
107  {
108  drainageParams_ = *value;
109  }
110 
114  const EffLawParams& drainageParams() const
115  { return drainageParams_; }
116 
117  EffLawParams& drainageParams()
118  { return drainageParams_; }
119 
123  void setImbibitionParams(std::shared_ptr<EffLawParams> value,
124  const EclEpsScalingPointsInfo<Scalar>& /* info */,
125  EclTwoPhaseSystemType /* twoPhaseSystem */)
126  {
127  imbibitionParams_ = *value;
128 
129 /*
130  if (twoPhaseSystem == EclGasOilSystem) {
131  Sncri_ = info.Sgcr;
132  }
133  else {
134  assert(twoPhaseSystem == EclOilWaterSystem);
135  Sncri_ = info.Sowcr;
136  }
137 */
138  }
139 
143  const EffLawParams& imbibitionParams() const
144  { return imbibitionParams_; }
145 
146  EffLawParams& imbibitionParams()
147  { return imbibitionParams_; }
148 
153  void setPcSwMdc(Scalar value)
154  { pcSwMdc_ = value; }
155 
160  Scalar pcSwMdc() const
161  { return pcSwMdc_; }
162 
168  void setKrwSwMdc(Scalar /* value */)
169  {}
170  // { krwSwMdc_ = value; };
171 
177  Scalar krwSwMdc() const
178  { return 2.0; }
179  // { return krwSwMdc_; };
180 
186  void setKrnSwMdc(Scalar value)
187  { krnSwMdc_ = value; }
188 
194  Scalar krnSwMdc() const
195  { return krnSwMdc_; }
196 
204  void setDeltaSwImbKrw(Scalar /* value */)
205  {}
206  // { deltaSwImbKrw_ = value; }
207 
215  Scalar deltaSwImbKrw() const
216  { return 0.0; }
217 // { return deltaSwImbKrw_; }
218 
226  void setDeltaSwImbKrn(Scalar value)
227  { deltaSwImbKrn_ = value; }
228 
236  Scalar deltaSwImbKrn() const
237  { return deltaSwImbKrn_; }
238 
245  void update(Scalar pcSw, Scalar /* krwSw */, Scalar krnSw)
246  {
247  bool updateParams = false;
248  if (pcSw < pcSwMdc_) {
249  pcSwMdc_ = pcSw;
250  updateParams = true;
251  }
252 
253 /*
254  // This is quite hacky: Eclipse says that it only uses relperm hysteresis for the
255  // wetting phase (indicated by '0' for the second item of the EHYSTER keyword),
256  // even though this makes about zero sense: one would expect that hysteresis can
257  // be limited to the oil phase, but the oil phase is the wetting phase of the
258  // gas-oil twophase system whilst it is non-wetting for water-oil.
259  if (krwSw < krwSwMdc_)
260  {
261  krwSwMdc_ = krwSw;
262  updateParams = true;
263  }
264 */
265 
266  if (krnSw < krnSwMdc_) {
267  krnSwMdc_ = krnSw;
268  updateParams = true;
269  }
270 
271  if (updateParams)
272  updateDynamicParams_();
273  }
274 
275 private:
276 
277 #ifndef NDEBUG
278  void assertFinalized_() const
279  { assert(finalized_); }
280 
281  bool finalized_;
282 #else
283  void assertFinalized_() const
284  { }
285 #endif
286 
287  void updateDynamicParams_()
288  {
289  // HACK: Eclipse seems to disable the wetting-phase relperm even though this is
290  // quite pointless from the physical POV. (see comment above)
291 /*
292  // calculate the saturation deltas for the relative permeabilities
293  Scalar krwMdcDrainage = EffLawT::twoPhaseSatKrw(drainageParams(), krwSwMdc_);
294  Scalar SwKrwMdcImbibition = EffLawT::twoPhaseSatKrwInv(imbibitionParams(), krwMdcDrainage);
295  deltaSwImbKrw_ = SwKrwMdcImbibition - krwSwMdc_;
296 */
297 
298  Scalar krnMdcDrainage = EffLawT::twoPhaseSatKrn(drainageParams(), krnSwMdc_);
299  Scalar SwKrnMdcImbibition = EffLawT::twoPhaseSatKrnInv(imbibitionParams(), krnMdcDrainage);
300  deltaSwImbKrn_ = SwKrnMdcImbibition - krnSwMdc_;
301 
302  Scalar pcMdcDrainage = EffLawT::twoPhaseSatPcnw(drainageParams(), pcSwMdc_);
303  Scalar SwPcMdcImbibition = EffLawT::twoPhaseSatPcnwInv(imbibitionParams(), pcMdcDrainage);
304  deltaSwImbPc_ = SwPcMdcImbibition - pcSwMdc_;
305 
306 // assert(std::abs(EffLawT::twoPhaseSatPcnw(imbibitionParams(), pcSwMdc_ + deltaSwImbPc_)
307 // - EffLawT::twoPhaseSatPcnw(drainageParams(), pcSwMdc_)) < 1e-8);
308  assert(std::abs(EffLawT::twoPhaseSatKrn(imbibitionParams(), krnSwMdc_ + deltaSwImbKrn_)
309  - EffLawT::twoPhaseSatKrn(drainageParams(), krnSwMdc_)) < 1e-8);
310 // assert(std::abs(EffLawT::twoPhaseSatKrw(imbibitionParams(), krwSwMdc_ + deltaSwImbKrw_)
311 // - EffLawT::twoPhaseSatKrw(drainageParams(), krwSwMdc_)) < 1e-8);
312 
313 #if 0
314  Scalar Snhy = 1.0 - SwMdc_;
315 
316  Sncrt_ = Sncrd_ + (Snhy - Sncrd_)/(1 + C_*(Snhy - Sncrd_));
317 #endif
318  }
319 
320  std::shared_ptr<EclHysteresisConfig> config_;
321  EffLawParams imbibitionParams_;
322  EffLawParams drainageParams_;
323 
324  // largest wettinging phase saturation which is on the main-drainage curve. These are
325  // three different values because the sourounding code can choose to use different
326  // definitions for the saturations for different quantities
327 // Scalar krwSwMdc_;
328  Scalar krnSwMdc_;
329  Scalar pcSwMdc_;
330 
331  // offsets added to wetting phase saturation uf using the imbibition curves need to
332  // be used to calculate the wetting phase relperm, the non-wetting phase relperm and
333  // the capillary pressure
334 // Scalar deltaSwImbKrw_;
335  Scalar deltaSwImbKrn_;
336  Scalar deltaSwImbPc_;
337 
338  // trapped non-wetting phase saturation
339  //Scalar Sncrt_;
340 
341  // the following uses the conventions of the Eclipse technical description:
342  //
343  // Sncrd_: critical non-wetting phase saturation for the drainage curve
344  // Sncri_: critical non-wetting phase saturation for the imbibition curve
345  // Snmaxd_: non-wetting phase saturation where the non-wetting relperm reaches its
346  // maximum on the drainage curve
347  // C_: factor required to calculate the trapped non-wetting phase saturation using
348  // the Killough approach
349  //Scalar Sncrd_;
350  //Scalar Sncri_;
351  //Scalar Snmaxd_;
352  //Scalar C_;
353 };
354 
355 } // namespace Opm
356 
357 #endif
EclHysteresisTwoPhaseLawParams()
Definition: EclHysteresisTwoPhaseLawParams.hpp:57
EclTwoPhaseSystemType
Specified which fluids are involved in a given twophase material law for endpoint scaling...
Definition: EclEpsConfig.hpp:42
void setDeltaSwImbKrw(Scalar)
Sets the saturation value which must be added if krw is calculated using the imbibition curve...
Definition: EclHysteresisTwoPhaseLawParams.hpp:204
Specifies the configuration used by the ECL kr/pC hysteresis code.
Scalar pcSwMdc() const
Set the saturation of the wetting phase where the last switch from the main drainage curve to imbibit...
Definition: EclHysteresisTwoPhaseLawParams.hpp:160
void setKrwSwMdc(Scalar)
Set the saturation of the wetting phase where the last switch from the main drainage curve (MDC) to i...
Definition: EclHysteresisTwoPhaseLawParams.hpp:168
Definition: Air_Mesitylene.hpp:31
EffLawParams::Traits Traits
Definition: EclHysteresisTwoPhaseLawParams.hpp:55
Scalar deltaSwImbKrw() const
Returns the saturation value which must be added if krw is calculated using the imbibition curve...
Definition: EclHysteresisTwoPhaseLawParams.hpp:215
Scalar krwSwMdc() const
Set the saturation of the wetting phase where the last switch from the main drainage curve to imbibit...
Definition: EclHysteresisTwoPhaseLawParams.hpp:177
const EffLawParams & drainageParams() const
Returns the parameters used for the drainage curve.
Definition: EclHysteresisTwoPhaseLawParams.hpp:114
void setDeltaSwImbKrn(Scalar value)
Sets the saturation value which must be added if krn is calculated using the imbibition curve...
Definition: EclHysteresisTwoPhaseLawParams.hpp:226
void setConfig(std::shared_ptr< EclHysteresisConfig > value)
Set the endpoint scaling configuration object.
Definition: EclHysteresisTwoPhaseLawParams.hpp:91
void setImbibitionParams(std::shared_ptr< EffLawParams > value, const EclEpsScalingPointsInfo< Scalar > &, EclTwoPhaseSystemType)
Sets the parameters used for the imbibition curve.
Definition: EclHysteresisTwoPhaseLawParams.hpp:123
This structure represents all values which can be possibly used as scaling points in the endpoint sca...
Definition: EclEpsScalingPoints.hpp:122
const EffLawParams & imbibitionParams() const
Returns the parameters used for the imbibition curve.
Definition: EclHysteresisTwoPhaseLawParams.hpp:143
A default implementation of the parameters for the material law which implements the ECL relative per...
Definition: EclHysteresisTwoPhaseLawParams.hpp:49
const EclHysteresisConfig & config() const
Returns the endpoint scaling configuration object.
Definition: EclHysteresisTwoPhaseLawParams.hpp:97
void setDrainageParams(std::shared_ptr< EffLawParams > value, const EclEpsScalingPointsInfo< Scalar > &, EclTwoPhaseSystemType)
Sets the parameters used for the drainage curve.
Definition: EclHysteresisTwoPhaseLawParams.hpp:103
Evaluation< Scalar, VarSetTag, numVars > abs(const Evaluation< Scalar, VarSetTag, numVars > &)
Definition: Math.hpp:41
EffLawParams & drainageParams()
Definition: EclHysteresisTwoPhaseLawParams.hpp:117
Specifies the configuration used by the ECL kr/pC hysteresis code.
Definition: EclHysteresisConfig.hpp:45
void setKrnSwMdc(Scalar value)
Set the saturation of the wetting phase where the last switch from the main drainage curve (MDC) to i...
Definition: EclHysteresisTwoPhaseLawParams.hpp:186
void setPcSwMdc(Scalar value)
Set the saturation of the wetting phase where the last switch from the main drainage curve (MDC) to i...
Definition: EclHysteresisTwoPhaseLawParams.hpp:153
Scalar krnSwMdc() const
Set the saturation of the wetting phase where the last switch from the main drainage curve to imbibit...
Definition: EclHysteresisTwoPhaseLawParams.hpp:194
Scalar deltaSwImbKrn() const
Returns the saturation value which must be added if krn is calculated using the imbibition curve...
Definition: EclHysteresisTwoPhaseLawParams.hpp:236
void finalize()
Calculate all dependent quantities once the independent quantities of the parameter object have been ...
Definition: EclHysteresisTwoPhaseLawParams.hpp:75
void update(Scalar pcSw, Scalar, Scalar krnSw)
Notify the hysteresis law that a given wetting-phase saturation has been seen.
Definition: EclHysteresisTwoPhaseLawParams.hpp:245
EffLawParams & imbibitionParams()
Definition: EclHysteresisTwoPhaseLawParams.hpp:146