27 #ifndef OPM_ECL_STONE1_MATERIAL_HPP
28 #define OPM_ECL_STONE1_MATERIAL_HPP
38 #include <type_traits>
55 template <
class TraitsT,
56 class GasOilMaterialLawT,
57 class OilWaterMaterialLawT,
58 class ParamsT = EclStone1MaterialParams<TraitsT, GasOilMaterialLawT, OilWaterMaterialLawT> >
62 using GasOilMaterialLaw = GasOilMaterialLawT;
63 using OilWaterMaterialLaw = OilWaterMaterialLawT;
66 static_assert(TraitsT::numPhases == 3,
67 "The number of phases considered by this capillary pressure "
68 "law is always three!");
69 static_assert(GasOilMaterialLaw::numPhases == 2,
70 "The number of phases considered by the gas-oil capillary "
71 "pressure law must be two!");
72 static_assert(OilWaterMaterialLaw::numPhases == 2,
73 "The number of phases considered by the oil-water capillary "
74 "pressure law must be two!");
75 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
76 typename OilWaterMaterialLaw::Scalar>::value,
77 "The two two-phase capillary pressure laws must use the same "
78 "type of floating point values.");
80 static_assert(GasOilMaterialLaw::implementsTwoPhaseSatApi,
81 "The gas-oil material law must implement the two-phase saturation "
82 "only API to for the default Ecl capillary pressure law!");
83 static_assert(OilWaterMaterialLaw::implementsTwoPhaseSatApi,
84 "The oil-water material law must implement the two-phase saturation "
85 "only API to for the default Ecl capillary pressure law!");
87 using Traits = TraitsT;
88 using Params = ParamsT;
89 using Scalar =
typename Traits::Scalar;
91 static constexpr
int numPhases = 3;
92 static constexpr
int waterPhaseIdx = Traits::wettingPhaseIdx;
93 static constexpr
int oilPhaseIdx = Traits::nonWettingPhaseIdx;
94 static constexpr
int gasPhaseIdx = Traits::gasPhaseIdx;
134 template <
class ContainerT,
class Flu
idState>
136 const Params& params,
137 const FluidState& state)
139 using Evaluation =
typename std::remove_reference<decltype(values[0])>::type;
140 values[gasPhaseIdx] = pcgn<FluidState, Evaluation>(params, state);
141 values[oilPhaseIdx] = 0;
142 values[waterPhaseIdx] = - pcnw<FluidState, Evaluation>(params, state);
143 Valgrind::CheckDefined(values[gasPhaseIdx]);
144 Valgrind::CheckDefined(values[oilPhaseIdx]);
145 Valgrind::CheckDefined(values[waterPhaseIdx]);
154 static void oilWaterHysteresisParams(Scalar& pcSwMdc,
156 const Params& params)
158 pcSwMdc = params.oilWaterParams().pcSwMdc();
159 krnSwMdc = params.oilWaterParams().krnSwMdc();
161 Valgrind::CheckDefined(pcSwMdc);
162 Valgrind::CheckDefined(krnSwMdc);
171 static void setOilWaterHysteresisParams(
const Scalar& pcSwMdc,
172 const Scalar& krnSwMdc,
175 constexpr
const double krwSw = 2.0;
176 params.oilWaterParams().update(pcSwMdc, krwSw, krnSwMdc);
185 static void gasOilHysteresisParams(Scalar& pcSwMdc,
187 const Params& params)
189 const auto Swco = params.Swl();
193 pcSwMdc = std::min(params.gasOilParams().pcSwMdc() + Swco, Scalar{2.0});
194 krnSwMdc = std::min(params.gasOilParams().krnSwMdc() + Swco, Scalar{2.0});
196 Valgrind::CheckDefined(pcSwMdc);
197 Valgrind::CheckDefined(krnSwMdc);
206 static void setGasOilHysteresisParams(
const Scalar& pcSwMdc,
207 const Scalar& krnSwMdc,
211 const auto Swco = params.Swl();
212 constexpr
const double krwSw = 2.0;
213 params.gasOilParams().update(pcSwMdc - Swco, krwSw, krnSwMdc - Swco);
225 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
226 static Evaluation
pcgn(
const Params& params,
227 const FluidState& fs)
230 const auto Sw = 1.0 - params.Swl() - decay<Evaluation>(fs.saturation(gasPhaseIdx));
231 return GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(),
Sw);
243 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
244 static Evaluation
pcnw(
const Params& params,
245 const FluidState& fs)
247 const auto Sw = decay<Evaluation>(fs.saturation(waterPhaseIdx));
248 Valgrind::CheckDefined(
Sw);
250 const auto result = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(),
Sw);
251 Valgrind::CheckDefined(result);
259 template <
class ContainerT,
class Flu
idState>
264 throw std::logic_error(
"Not implemented: saturations()");
270 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
271 static Evaluation
Sg(
const Params& ,
274 throw std::logic_error(
"Not implemented: Sg()");
280 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
281 static Evaluation
Sn(
const Params& ,
284 throw std::logic_error(
"Not implemented: Sn()");
290 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
291 static Evaluation
Sw(
const Params& ,
294 throw std::logic_error(
"Not implemented: Sw()");
312 template <
class ContainerT,
class Flu
idState>
314 const Params& params,
315 const FluidState& fluidState)
317 using Evaluation =
typename std::remove_reference<decltype(values[0])>::type;
319 values[waterPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
320 values[oilPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
321 values[gasPhaseIdx] = krg<FluidState, Evaluation>(params, fluidState);
327 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
328 static Evaluation
krg(
const Params& params,
329 const FluidState& fluidState)
332 const Evaluation
Sw = 1 - params.Swl() - decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
333 return GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(),
Sw);
339 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
340 static Evaluation
krw(
const Params& params,
341 const FluidState& fluidState)
343 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
344 return OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
350 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
351 static Evaluation
krn(
const Params& params,
352 const FluidState& fluidState)
357 const Scalar Swco = params.Swl();
360 const Scalar krocw = params.krocw();
362 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
363 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
365 const Evaluation kro_ow = relpermOilInOilWaterSystem<Evaluation>(params, fluidState);
366 const Evaluation kro_go = relpermOilInOilGasSystem<Evaluation>(params, fluidState);
375 const Evaluation SSw = (
Sw - Swco)/(1.0 - Swco);
376 const Evaluation SSg =
Sg/(1.0 - Swco);
377 const Evaluation SSo = 1.0 - SSw - SSg;
379 if (SSw >= 1.0 || SSg >= 1.0)
382 beta = pow( SSo/((1 - SSw)*(1 - SSg)), params.eta());
385 return max(0.0, min(1.0, beta*kro_ow*kro_go/krocw));
391 template <
class Evaluation,
class Flu
idState>
393 const FluidState& fluidState)
395 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(gasPhaseIdx));
397 return GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), 1 -
Sg - params.Swl());
403 template <
class Evaluation,
class Flu
idState>
405 const FluidState& fluidState)
407 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
409 return OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(),
Sw);
419 template <
class Flu
idState>
422 const Scalar Swco = params.Swl();
423 const Scalar
Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
424 const Scalar
Sg = scalarValue(fluidState.saturation(gasPhaseIdx));
426 params.oilWaterParams().update(
Sw,
Sw,
Sw);
427 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: EclStone1Material.hpp:60
static constexpr bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: EclStone1Material.hpp:106
static constexpr bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: EclStone1Material.hpp:102
static constexpr bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition: EclStone1Material.hpp:118
static Evaluation krw(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the wetting phase.
Definition: EclStone1Material.hpp:340
static Evaluation krn(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition: EclStone1Material.hpp:351
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclStone1Material.hpp:313
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: EclStone1Material.hpp:135
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclStone1Material.hpp:260
static constexpr bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition: EclStone1Material.hpp:114
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclStone1Material.hpp:271
static Evaluation krg(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the gas phase.
Definition: EclStone1Material.hpp:328
static constexpr bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: EclStone1Material.hpp:98
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition: EclStone1Material.hpp:291
static Evaluation pcgn(const Params ¶ms, const FluidState &fs)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclStone1Material.hpp:226
static constexpr bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition: EclStone1Material.hpp:110
static Evaluation relpermOilInOilWaterSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/water system.
Definition: EclStone1Material.hpp:404
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: EclStone1Material.hpp:244
static Evaluation relpermOilInOilGasSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/gas system.
Definition: EclStone1Material.hpp:392
static void updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclStone1Material.hpp:420
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclStone1Material.hpp:281