30#ifndef OPM_PTFlash_PARAMETER_CACHE_HPP
31#define OPM_PTFlash_PARAMETER_CACHE_HPP
35#include <opm/material/eos/CubicEOS.hpp>
36#include <opm/material/eos/CubicEOSParams.hpp>
38#include <opm/input/eclipse/EclipseState/Compositional/CompositionalConfig.hpp>
48template <
class Scalar,
class Flu
idSystem>
55 using EOSType = CompositionalConfig::EOSType;
57 enum { numPhases = FluidSystem::numPhases };
58 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
59 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
60 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
62 static constexpr bool waterEnabled = FluidSystem::waterEnabled;
64 static_assert(
static_cast<int>(oilPhaseIdx) >= 0,
"Oil phase index must be non-negative");
65 static_assert(
static_cast<int>(oilPhaseIdx) <
static_cast<int>(numPhases),
66 "Oil phase index must be strictly less than FluidSystem's number of phases");
68 static_assert(
static_cast<int>(gasPhaseIdx) >= 0,
"Gas phase index must be non-negative");
69 static_assert(
static_cast<int>(gasPhaseIdx) <
static_cast<int>(numPhases),
70 "Gas phase index must be strictly less than FluidSystem's number of phases");
81 VmUpToDate_[oilPhaseIdx] =
false;
82 Valgrind::SetUndefined(Vm_[oilPhaseIdx]);
83 VmUpToDate_[gasPhaseIdx] =
false;
84 Valgrind::SetUndefined(Vm_[gasPhaseIdx]);
86 oilPhaseParams_.setEOSType(eos_type);
87 gasPhaseParams_.setEOSType(eos_type);
91 template <
class Flu
idState>
96 if (waterEnabled && phaseIdx ==
static_cast<unsigned int>(waterPhaseIdx)) {
100 assert ((phaseIdx ==
static_cast<unsigned int>(oilPhaseIdx)) ||
101 (phaseIdx ==
static_cast<unsigned int>(gasPhaseIdx)));
106 updateMolarVolume_(fluidState, phaseIdx);
110 template <
class Flu
idState>
115 if (phaseIdx == oilPhaseIdx)
116 oilPhaseParams_.updateSingleMoleFraction(fluidState, compIdx);
117 if (phaseIdx == gasPhaseIdx)
118 gasPhaseParams_.updateSingleMoleFraction(fluidState, compIdx);
123 updateMolarVolume_(fluidState, phaseIdx);
126 Scalar A(
unsigned phaseIdx)
const
130 case oilPhaseIdx:
return oilPhaseParams_.A();
131 case gasPhaseIdx:
return gasPhaseParams_.A();
133 throw std::logic_error(
"The A parameter is only defined for "
134 "oil and gas phases");
138 Scalar B(
unsigned phaseIdx)
const
142 case oilPhaseIdx:
return oilPhaseParams_.B();
143 case gasPhaseIdx:
return gasPhaseParams_.B();
145 throw std::logic_error(
"The B parameter is only defined for "
146 "oil and gas phases");
150 Scalar Bi(
unsigned phaseIdx,
unsigned compIdx)
const
154 case oilPhaseIdx:
return oilPhaseParams_.Bi(compIdx);
155 case gasPhaseIdx:
return gasPhaseParams_.Bi(compIdx);
157 throw std::logic_error(
"The Bi parameter is only defined for "
158 "oil and gas phases");
162 Scalar m1(
unsigned phaseIdx)
const
166 case oilPhaseIdx:
return oilPhaseParams_.m1();
167 case gasPhaseIdx:
return gasPhaseParams_.m1();
169 throw std::logic_error(
"The m1 parameter is only defined for "
170 "oil and gas phases");
174 Scalar m2(
unsigned phaseIdx)
const
178 case oilPhaseIdx:
return oilPhaseParams_.m2();
179 case gasPhaseIdx:
return gasPhaseParams_.m2();
181 throw std::logic_error(
"The m2 parameter is only defined for "
182 "oil and gas phases");
191 Scalar
a(
unsigned phaseIdx)
const
195 case oilPhaseIdx:
return oilPhaseParams_.a();
196 case gasPhaseIdx:
return gasPhaseParams_.a();
198 throw std::logic_error(
"The a() parameter is only defined for "
199 "oil and gas phases");
208 Scalar
b(
unsigned phaseIdx)
const
212 case oilPhaseIdx:
return oilPhaseParams_.b();
213 case gasPhaseIdx:
return gasPhaseParams_.b();
215 throw std::logic_error(
"The b() parameter is only defined for "
216 "oil and gas phase");
228 Scalar
aPure(
unsigned phaseIdx,
unsigned compIdx)
const
232 case oilPhaseIdx:
return oilPhaseParams_.pureParams(compIdx).a();
233 case gasPhaseIdx:
return gasPhaseParams_.pureParams(compIdx).a();
235 throw std::logic_error(
"The a() parameter is only defined for "
236 "oil and gas phase");
247 Scalar
bPure(
unsigned phaseIdx,
unsigned compIdx)
const
251 case oilPhaseIdx:
return oilPhaseParams_.pureParams(compIdx).b();
252 case gasPhaseIdx:
return gasPhaseParams_.pureParams(compIdx).b();
254 throw std::logic_error(
"The b() parameter is only defined for "
255 "oil and gas phase");
266 Scalar
aCache(
unsigned phaseIdx,
unsigned compIdx,
unsigned compJIdx)
const
270 case oilPhaseIdx:
return oilPhaseParams_.aCache(compIdx, compJIdx);
271 case gasPhaseIdx:
return gasPhaseParams_.aCache(compIdx, compJIdx);
273 throw std::logic_error(
"The aCache parameter is only defined for "
274 "oil and gas phase");
285 assert(VmUpToDate_[phaseIdx]);
286 return Vm_[phaseIdx];
295 {
return oilPhaseParams_; }
303 {
return gasPhaseParams_; }
313 template <
class Flu
idState>
318 assert ((phaseIdx ==
static_cast<unsigned int>(oilPhaseIdx)) ||
319 (phaseIdx ==
static_cast<unsigned int>(gasPhaseIdx)));
325 VmUpToDate_[phaseIdx] =
false;
330 VmUpToDate_[phaseIdx] =
false;
333 VmUpToDate_[phaseIdx] =
false;
344 template <
class Flu
idState>
347 Scalar T = decay<Scalar>(fluidState.temperature(phaseIdx));
348 Scalar p = decay<Scalar>(fluidState.pressure(phaseIdx));
352 case oilPhaseIdx: oilPhaseParams_.updatePure(T, p);
break;
353 case gasPhaseIdx: gasPhaseParams_.updatePure(T, p);
break;
364 template <
class Flu
idState>
365 void updateMix_(
const FluidState& fluidState,
unsigned phaseIdx)
367 Valgrind::CheckDefined(fluidState.averageMolarMass(phaseIdx));
371 oilPhaseParams_.updateMix(fluidState);
374 gasPhaseParams_.updateMix(fluidState);
379 template <
class Flu
idState>
380 void updateMolarVolume_(
const FluidState& fluidState,
383 VmUpToDate_[phaseIdx] =
true;
394 Vm_[gasPhaseIdx] = decay<Scalar> (
395 CubicEOS::computeMolarVolume(fluidState,
407 Vm_[oilPhaseIdx] = decay<Scalar> (
408 CubicEOS::computeMolarVolume(fluidState,
418 bool VmUpToDate_[numPhases];
419 Scalar Vm_[numPhases];
The base class of the parameter caches of fluid systems.
Some templates to wrap the valgrind client request macros.
Definition CubicEOS.hpp:34
Specifies the parameter cache used by the SPE-5 fluid system.
Definition PTFlashParameterCache.hpp:51
const OilPhaseParams & oilPhaseParams() const
Returns the Peng-Robinson mixture parameters for the oil phase.
Definition PTFlashParameterCache.hpp:294
void updatePure_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which only depend on temperature and/or pressure.
Definition PTFlashParameterCache.hpp:345
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition PTFlashParameterCache.hpp:283
void updateSingleMoleFraction(const FluidState &fluidState, unsigned phaseIdx, unsigned compIdx)
Update all cached parameters of a specific fluid phase which depend on the mole fraction of a single ...
Definition PTFlashParameterCache.hpp:111
Scalar bPure(unsigned phaseIdx, unsigned compIdx) const
The Peng-Robinson covolume for a pure component given the same temperature and pressure of the phase.
Definition PTFlashParameterCache.hpp:247
Scalar aCache(unsigned phaseIdx, unsigned compIdx, unsigned compJIdx) const
TODO.
Definition PTFlashParameterCache.hpp:266
void updateMix_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which depend on the fluid composition.
Definition PTFlashParameterCache.hpp:365
void updatePhase(const FluidState &fluidState, unsigned phaseIdx, int exceptQuantities=ParentType::None)
Update all cached parameters of a specific fluid phase.
Definition PTFlashParameterCache.hpp:92
Scalar a(unsigned phaseIdx) const
The Peng-Robinson attractive parameter for a phase.
Definition PTFlashParameterCache.hpp:191
Scalar aPure(unsigned phaseIdx, unsigned compIdx) const
The Peng-Robinson attractive parameter for a pure component given the same temperature and pressure o...
Definition PTFlashParameterCache.hpp:228
Opm::CubicEOSParams< Scalar, FluidSystem, oilPhaseIdx > OilPhaseParams
The cached parameters for the oil phase.
Definition PTFlashParameterCache.hpp:74
Scalar b(unsigned phaseIdx) const
The Peng-Robinson covolume for a phase.
Definition PTFlashParameterCache.hpp:208
void updateEosParams(const FluidState &fluidState, unsigned phaseIdx, int exceptQuantities=ParentType::None)
Update all parameters required by the equation of state to calculate some quantities for the phase.
Definition PTFlashParameterCache.hpp:314
Opm::CubicEOSParams< Scalar, FluidSystem, gasPhaseIdx > GasPhaseParams
The cached parameters for the gas phase.
Definition PTFlashParameterCache.hpp:77
const GasPhaseParams & gasPhaseParams() const
Returns the Peng-Robinson mixture parameters for the gas phase.
Definition PTFlashParameterCache.hpp:301
The base class of the parameter caches of fluid systems.
Definition ParameterCacheBase.hpp:38
@ Temperature
The temperature has not been modified.
Definition ParameterCacheBase.hpp:48
@ None
All quantities have been (potentially) modified.
Definition ParameterCacheBase.hpp:45
@ Pressure
The pressures have not been modified.
Definition ParameterCacheBase.hpp:51
@ Composition
The compositions have not been modified.
Definition ParameterCacheBase.hpp:54
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30