27#ifndef OPM_ECL_STONE2_MATERIAL_HPP
28#define OPM_ECL_STONE2_MATERIAL_HPP
54template <
class TraitsT,
55 class GasOilMaterialLawT,
56 class OilWaterMaterialLawT,
57 class ParamsT = EclStone2MaterialParams<TraitsT,
58 typename GasOilMaterialLawT::Params,
59 typename OilWaterMaterialLawT::Params> >
63 using GasOilMaterialLaw = GasOilMaterialLawT;
64 using OilWaterMaterialLaw = OilWaterMaterialLawT;
67 static_assert(TraitsT::numPhases == 3,
68 "The number of phases considered by this capillary pressure "
69 "law is always three!");
70 static_assert(GasOilMaterialLaw::numPhases == 2,
71 "The number of phases considered by the gas-oil capillary "
72 "pressure law must be two!");
73 static_assert(OilWaterMaterialLaw::numPhases == 2,
74 "The number of phases considered by the oil-water capillary "
75 "pressure law must be two!");
76 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
77 typename OilWaterMaterialLaw::Scalar>::value,
78 "The two two-phase capillary pressure laws must use the same "
79 "type of floating point values.");
81 static_assert(GasOilMaterialLaw::implementsTwoPhaseSatApi,
82 "The gas-oil material law must implement the two-phase saturation "
83 "only API to for the default Ecl capillary pressure law!");
84 static_assert(OilWaterMaterialLaw::implementsTwoPhaseSatApi,
85 "The oil-water material law must implement the two-phase saturation "
86 "only API to for the default Ecl capillary pressure law!");
88 using Traits = TraitsT;
89 using Params = ParamsT;
90 using Scalar =
typename Traits::Scalar;
92 static constexpr int numPhases = 3;
93 static constexpr int waterPhaseIdx = Traits::wettingPhaseIdx;
94 static constexpr int oilPhaseIdx = Traits::nonWettingPhaseIdx;
95 static constexpr int gasPhaseIdx = Traits::gasPhaseIdx;
135 template <
class ContainerT,
class Flu
idState>
137 const Params& params,
138 const FluidState& state)
140 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
141 values[gasPhaseIdx] = pcgn<FluidState, Evaluation>(params, state);
142 values[oilPhaseIdx] = 0;
143 values[waterPhaseIdx] = - pcnw<FluidState, Evaluation>(params, state);
144 Valgrind::CheckDefined(values[gasPhaseIdx]);
145 Valgrind::CheckDefined(values[oilPhaseIdx]);
146 Valgrind::CheckDefined(values[waterPhaseIdx]);
155 static void oilWaterHysteresisParams(Scalar& pcSwMdc,
157 const Params& params)
159 pcSwMdc = params.oilWaterParams().pcSwMdc();
160 krnSwMdc = params.oilWaterParams().krnSwMdc();
162 Valgrind::CheckDefined(pcSwMdc);
163 Valgrind::CheckDefined(krnSwMdc);
172 static void setOilWaterHysteresisParams(
const Scalar& pcSwMdc,
173 const Scalar& krnSwMdc,
176 constexpr const double krwSw = 2.0;
177 params.oilWaterParams().update(pcSwMdc, krwSw, krnSwMdc);
186 static void gasOilHysteresisParams(Scalar& pcSwMdc,
188 const Params& params)
190 const auto Swco = params.Swl();
194 pcSwMdc = std::min(params.gasOilParams().pcSwMdc() + Swco, Scalar{2.0});
195 krnSwMdc = std::min(params.gasOilParams().krnSwMdc() + Swco, Scalar{2.0});
197 Valgrind::CheckDefined(pcSwMdc);
198 Valgrind::CheckDefined(krnSwMdc);
207 static void setGasOilHysteresisParams(
const Scalar& pcSwMdc,
208 const Scalar& krnSwMdc,
212 const auto Swco = params.Swl();
213 constexpr const double krwSw = 2.0;
214 params.gasOilParams().update(pcSwMdc - Swco, krwSw, krnSwMdc - Swco);
226 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
227 static Evaluation
pcgn(
const Params& params,
228 const FluidState& fs)
231 const auto Sw = 1.0 - params.Swl() - decay<Evaluation>(fs.saturation(gasPhaseIdx));
232 return GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(),
Sw);
244 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
245 static Evaluation
pcnw(
const Params& params,
246 const FluidState& fs)
248 const auto Sw = decay<Evaluation>(fs.saturation(waterPhaseIdx));
249 Valgrind::CheckDefined(
Sw);
251 const auto result = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(),
Sw);
252 Valgrind::CheckDefined(result);
260 template <
class ContainerT,
class Flu
idState>
265 throw std::logic_error(
"Not implemented: saturations()");
271 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
272 static Evaluation
Sg(
const Params& ,
275 throw std::logic_error(
"Not implemented: Sg()");
281 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
282 static Evaluation
Sn(
const Params& ,
285 throw std::logic_error(
"Not implemented: Sn()");
291 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
292 static Evaluation
Sw(
const Params& ,
295 throw std::logic_error(
"Not implemented: Sw()");
313 template <
class ContainerT,
class Flu
idState>
315 const Params& params,
316 const FluidState& fluidState)
318 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
320 values[waterPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
321 values[oilPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
322 values[gasPhaseIdx] = krg<FluidState, Evaluation>(params, fluidState);
328 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
329 static Evaluation
krg(
const Params& params,
330 const FluidState& fluidState)
333 const Evaluation
Sw = 1 - params.Swl() - decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
334 return GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(),
Sw);
340 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
341 static Evaluation
krw(
const Params& params,
342 const FluidState& fluidState)
344 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
345 return OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
351 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
352 static Evaluation
krn(
const Params& params,
353 const FluidState& fluidState)
355 const Scalar Swco = params.Swl();
357 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
358 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
360 const Scalar krocw = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), Swco);
361 const Evaluation krow = relpermOilInOilWaterSystem<Evaluation>(params, fluidState);
362 const Evaluation
krw = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
363 const Evaluation
krg = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), 1 - Swco -
Sg);
364 const Evaluation krog = relpermOilInOilGasSystem<Evaluation>(params, fluidState);
366 return max(krocw * ((krow/krocw +
krw) * (krog/krocw +
krg) -
krw -
krg), Evaluation{0});
373 template <
class Evaluation,
class Flu
idState>
375 const FluidState& fluidState)
377 const Scalar Swco = params.Swl();
378 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
380 return GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), 1 - Swco -
Sg);
387 template <
class Evaluation,
class Flu
idState>
389 const FluidState& fluidState)
391 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
393 return OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(),
Sw);
403 template <
class Flu
idState>
406 const Scalar Swco = params.Swl();
407 const Scalar
Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
408 const Scalar
Sg = scalarValue(fluidState.saturation(gasPhaseIdx));
409 bool changed =
false;
410 changed = changed || params.oilWaterParams().update(
Sw,
Sw,
Sw);
411 changed = changed || params.gasOilParams().update( 1.0 - Swco -
Sg,
Default implementation for the parameters required by the three-phase capillary pressure/relperm Ston...
Some templates to wrap the valgrind client request macros.
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition EclStone2Material.hpp:61
static constexpr bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition EclStone2Material.hpp:111
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition EclStone2Material.hpp:292
static bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition EclStone2Material.hpp:404
static Evaluation pcgn(const Params ¶ms, const FluidState &fs)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition EclStone2Material.hpp:227
static Evaluation pcnw(const Params ¶ms, const FluidState &fs)
Capillary pressure between the non-wetting liquid (i.e., oil) and the wetting liquid (i....
Definition EclStone2Material.hpp:245
static void capillaryPressures(ContainerT &values, const Params ¶ms, const FluidState &state)
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition EclStone2Material.hpp:136
static Evaluation relpermOilInOilWaterSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/water system.
Definition EclStone2Material.hpp:388
static constexpr bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition EclStone2Material.hpp:103
static constexpr bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition EclStone2Material.hpp:115
static constexpr bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition EclStone2Material.hpp:119
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition EclStone2Material.hpp:272
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition EclStone2Material.hpp:261
static constexpr bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition EclStone2Material.hpp:99
static Evaluation relpermOilInOilGasSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/gas system.
Definition EclStone2Material.hpp:374
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition EclStone2Material.hpp:282
static Evaluation krn(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition EclStone2Material.hpp:352
static constexpr bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition EclStone2Material.hpp:107
static Evaluation krw(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the wetting phase.
Definition EclStone2Material.hpp:341
static Evaluation krg(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the gas phase.
Definition EclStone2Material.hpp:329
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition EclStone2Material.hpp:314
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30