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]);
156 static void oilWaterHysteresisParams(Scalar& soMax,
159 const Params& params)
161 soMax = 1.0 - params.oilWaterParams().krnSwMdc();
162 swMax = params.oilWaterParams().krwSwMdc();
163 swMin = params.oilWaterParams().pcSwMdc();
164 Valgrind::CheckDefined(soMax);
165 Valgrind::CheckDefined(swMax);
166 Valgrind::CheckDefined(swMin);
176 static void setOilWaterHysteresisParams(
const Scalar& soMax,
181 params.oilWaterParams().update(swMin, swMax, 1.0 - soMax);
192 static void gasOilHysteresisParams(Scalar& sgMax,
195 const Params& params)
197 const auto Swco = params.Swl();
198 sgMax = 1.0 - params.gasOilParams().krnSwMdc() - Swco;
199 shMax = params.gasOilParams().krwSwMdc();
200 soMin = params.gasOilParams().pcSwMdc();
202 Valgrind::CheckDefined(sgMax);
203 Valgrind::CheckDefined(shMax);
204 Valgrind::CheckDefined(soMin);
214 static void setGasOilHysteresisParams(
const Scalar& sgMax,
219 const auto Swco = params.Swl();
220 params.gasOilParams().update(soMin, shMax, 1.0 - sgMax - Swco);
223 static Scalar trappedGasSaturation(
const Params& params,
bool maximumTrapping)
225 const auto Swco = params.Swl();
226 return params.gasOilParams().SnTrapped(maximumTrapping) - Swco;
229 static Scalar trappedOilSaturation(
const Params& params,
bool maximumTrapping)
231 return params.oilWaterParams().SnTrapped(maximumTrapping) + params.gasOilParams().SwTrapped();
234 static Scalar trappedWaterSaturation(
const Params& params)
236 return params.oilWaterParams().SwTrapped();
238 static Scalar strandedGasSaturation(
const Params& params, Scalar
Sg, Scalar Kg)
240 const auto Swco = params.Swl();
241 return params.gasOilParams().SnStranded(
Sg, Kg) - Swco;
253 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
254 static Evaluation
pcgn(
const Params& params,
255 const FluidState& fs)
258 const auto Sw = 1.0 - params.Swl() - decay<Evaluation>(fs.saturation(gasPhaseIdx));
259 return GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(),
Sw);
271 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
272 static Evaluation
pcnw(
const Params& params,
273 const FluidState& fs)
275 const auto Sw = decay<Evaluation>(fs.saturation(waterPhaseIdx));
276 Valgrind::CheckDefined(
Sw);
278 const auto result = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(),
Sw);
279 Valgrind::CheckDefined(result);
287 template <
class ContainerT,
class Flu
idState>
292 throw std::logic_error(
"Not implemented: saturations()");
298 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
299 static Evaluation
Sg(
const Params& ,
302 throw std::logic_error(
"Not implemented: Sg()");
308 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
309 static Evaluation
Sn(
const Params& ,
312 throw std::logic_error(
"Not implemented: Sn()");
318 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
319 static Evaluation
Sw(
const Params& ,
322 throw std::logic_error(
"Not implemented: Sw()");
340 template <
class ContainerT,
class Flu
idState>
342 const Params& params,
343 const FluidState& fluidState)
345 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
347 values[waterPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
348 values[oilPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
349 values[gasPhaseIdx] = krg<FluidState, Evaluation>(params, fluidState);
355 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
356 static Evaluation
krg(
const Params& params,
357 const FluidState& fluidState)
360 const Evaluation sw = 1 - params.Swl() - decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
361 return GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), sw);
367 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
368 static Evaluation
krw(
const Params& params,
369 const FluidState& fluidState)
371 const Evaluation sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
372 return OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), sw);
378 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
379 static Evaluation
krn(
const Params& params,
380 const FluidState& fluidState)
382 const Scalar Swco = params.Swl();
384 const Evaluation sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
385 const Evaluation sg = decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
387 const Scalar krocw = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), Swco);
388 const Evaluation krow = relpermOilInOilWaterSystem<Evaluation>(params, fluidState);
389 const Evaluation Krw = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), sw);
390 const Evaluation Krg = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), 1 - Swco - sg);
391 const Evaluation krog = relpermOilInOilGasSystem<Evaluation>(params, fluidState);
393 return max(krocw * ((krow / krocw + Krw) * (krog / krocw + Krg) - Krw - Krg), Evaluation{0});
400 template <
class Evaluation,
class Flu
idState>
402 const FluidState& fluidState)
404 const Scalar Swco = params.Swl();
405 const Evaluation sg = decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
407 return GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), 1 - Swco - sg);
414 template <
class Evaluation,
class Flu
idState>
416 const FluidState& fluidState)
418 const Evaluation sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
420 return OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), sw);
430 template <
class Flu
idState>
433 const Scalar Swco = params.Swl();
434 const Scalar sw = clampSaturation(fluidState, waterPhaseIdx);
435 const Scalar So = clampSaturation(fluidState, oilPhaseIdx);
436 const Scalar sg = clampSaturation(fluidState, gasPhaseIdx);
437 bool owChanged = params.oilWaterParams().update(sw, sw, 1 - So);
438 bool gochanged = params.gasOilParams().update( So,
441 return owChanged || gochanged;
444 template <
class Flu
idState>
445 static Scalar clampSaturation(
const FluidState& fluidState,
const int phaseIndex)
447 OPM_TIMEFUNCTION_LOCAL();
448 const auto sat = scalarValue(fluidState.saturation(phaseIndex));
449 return std::clamp(sat, Scalar{0.0}, Scalar{1.0});
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:319
static bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition EclStone2Material.hpp:431
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:254
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:272
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:415
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:299
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition EclStone2Material.hpp:288
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:401
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition EclStone2Material.hpp:309
static Evaluation krn(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition EclStone2Material.hpp:379
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:368
static Evaluation krg(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the gas phase.
Definition EclStone2Material.hpp:356
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition EclStone2Material.hpp:341
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30