30#ifndef OPM_PTFlash_PARAMETER_CACHE_HPP
31#define OPM_PTFlash_PARAMETER_CACHE_HPP
45template <
class Scalar,
class Flu
idSystem>
53 enum { numPhases = FluidSystem::numPhases };
54 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
55 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
57 static_assert(
static_cast<int>(oilPhaseIdx) >= 0,
"Oil phase index must be non-negative");
58 static_assert(
static_cast<int>(oilPhaseIdx) <
static_cast<int>(numPhases),
59 "Oil phase index must be strictly less than FluidSystem's number of phases");
61 static_assert(
static_cast<int>(gasPhaseIdx) >= 0,
"Gas phase index must be non-negative");
62 static_assert(
static_cast<int>(gasPhaseIdx) <
static_cast<int>(numPhases),
63 "Gas phase index must be strictly less than FluidSystem's number of phases");
73 VmUpToDate_[oilPhaseIdx] =
false;
74 Valgrind::SetUndefined(Vm_[oilPhaseIdx]);
75 VmUpToDate_[gasPhaseIdx] =
false;
76 Valgrind::SetUndefined(Vm_[gasPhaseIdx]);
80 template <
class Flu
idState>
85 assert ((phaseIdx ==
static_cast<unsigned int>(oilPhaseIdx)) ||
86 (phaseIdx ==
static_cast<unsigned int>(gasPhaseIdx)));
91 updateMolarVolume_(fluidState, phaseIdx);
95 template <
class Flu
idState>
100 if (phaseIdx == oilPhaseIdx)
102 if (phaseIdx == gasPhaseIdx)
108 updateMolarVolume_(fluidState, phaseIdx);
116 Scalar
a(
unsigned phaseIdx)
const
120 case oilPhaseIdx:
return oilPhaseParams_.
a();
121 case gasPhaseIdx:
return gasPhaseParams_.
a();
123 throw std::logic_error(
"The a() parameter is only defined for "
124 "oil and gas phases");
133 Scalar
b(
unsigned phaseIdx)
const
137 case oilPhaseIdx:
return oilPhaseParams_.
b();
138 case gasPhaseIdx:
return gasPhaseParams_.
b();
140 throw std::logic_error(
"The b() parameter is only defined for "
141 "oil and gas phase");
153 Scalar
aPure(
unsigned phaseIdx,
unsigned compIdx)
const
157 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
a();
158 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
a();
160 throw std::logic_error(
"The a() parameter is only defined for "
161 "oil and gas phase");
172 Scalar
bPure(
unsigned phaseIdx,
unsigned compIdx)
const
176 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
b();
177 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
b();
179 throw std::logic_error(
"The b() parameter is only defined for "
180 "oil and gas phase");
193 Scalar
aCache(
unsigned phaseIdx,
unsigned compIdx,
unsigned compJIdx)
const
197 case oilPhaseIdx:
return oilPhaseParams_.
getaCache(compIdx,compJIdx);
198 case gasPhaseIdx:
return gasPhaseParams_.
getaCache(compIdx,compJIdx);
200 throw std::logic_error(
"The aCache() parameter is only defined for "
201 "oil and gas phase");
211 { assert(VmUpToDate_[phaseIdx]);
return Vm_[phaseIdx]; }
219 {
return oilPhaseParams_; }
227 {
return gasPhaseParams_; }
237 template <
class Flu
idState>
242 assert ((phaseIdx ==
static_cast<unsigned int>(oilPhaseIdx)) ||
243 (phaseIdx ==
static_cast<unsigned int>(gasPhaseIdx)));
249 VmUpToDate_[phaseIdx] =
false;
254 VmUpToDate_[phaseIdx] =
false;
257 VmUpToDate_[phaseIdx] =
false;
268 template <
class Flu
idState>
271 Scalar T = decay<Scalar>(fluidState.temperature(phaseIdx));
272 Scalar p = decay<Scalar>(fluidState.pressure(phaseIdx));
276 case oilPhaseIdx: oilPhaseParams_.
updatePure(T, p);
break;
277 case gasPhaseIdx: gasPhaseParams_.
updatePure(T, p);
break;
288 template <
class Flu
idState>
289 void updateMix_(
const FluidState& fluidState,
unsigned phaseIdx)
291 Valgrind::CheckDefined(fluidState.averageMolarMass(phaseIdx));
303 template <
class Flu
idState>
304 void updateMolarVolume_(
const FluidState& fluidState,
307 VmUpToDate_[phaseIdx] =
true;
318 Vm_[gasPhaseIdx] = decay<Scalar> (
331 Vm_[oilPhaseIdx] = decay<Scalar> (
342 bool VmUpToDate_[numPhases];
343 Scalar Vm_[numPhases];
The base class of the parameter caches of fluid systems.
The mixing rule for the oil and the gas phases of the SPE5 problem.
Implements the Peng-Robinson equation of state for liquids and gases.
Specifies the parameter cache used by the SPE-5 fluid system.
Definition PTFlashParameterCache.hpp:48
Opm::PengRobinsonParamsMixture< Scalar, FluidSystem, oilPhaseIdx, false > OilPhaseParams
The cached parameters for the oil phase.
Definition PTFlashParameterCache.hpp:67
const OilPhaseParams & oilPhaseParams() const
Returns the Peng-Robinson mixture parameters for the oil phase.
Definition PTFlashParameterCache.hpp:218
void updatePure_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which only depend on temperature and/or pressure.
Definition PTFlashParameterCache.hpp:269
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition PTFlashParameterCache.hpp:210
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:96
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:172
Scalar aCache(unsigned phaseIdx, unsigned compIdx, unsigned compJIdx) const
TODO.
Definition PTFlashParameterCache.hpp:193
Opm::PengRobinsonParamsMixture< Scalar, FluidSystem, gasPhaseIdx, false > GasPhaseParams
The cached parameters for the gas phase.
Definition PTFlashParameterCache.hpp:69
void updateMix_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which depend on the fluid composition.
Definition PTFlashParameterCache.hpp:289
void updatePhase(const FluidState &fluidState, unsigned phaseIdx, int exceptQuantities=ParentType::None)
Update all cached parameters of a specific fluid phase.
Definition PTFlashParameterCache.hpp:81
Scalar a(unsigned phaseIdx) const
The Peng-Robinson attractive parameter for a phase.
Definition PTFlashParameterCache.hpp:116
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:153
Scalar b(unsigned phaseIdx) const
The Peng-Robinson covolume for a phase.
Definition PTFlashParameterCache.hpp:133
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:238
const GasPhaseParams & gasPhaseParams() const
Returns the Peng-Robinson mixture parameters for the gas phase.
Definition PTFlashParameterCache.hpp:225
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
void updateSingleMoleFraction(const FluidState &fs, unsigned)
Calculates the "a" and "b" Peng-Robinson parameters for the mixture provided that only a single mole ...
Definition PengRobinsonParamsMixture.hpp:192
void updatePure(const FluidState &fluidState)
Update Peng-Robinson parameters for the pure components.
Definition PengRobinsonParamsMixture.hpp:82
Scalar getaCache(unsigned compIIdx, unsigned compJIdx) const
TODO.
Definition PengRobinsonParamsMixture.hpp:73
void updateMix(const FluidState &fs)
Calculates the "a" and "b" Peng-Robinson parameters for the mixture.
Definition PengRobinsonParamsMixture.hpp:143
const PureParams & pureParams(unsigned compIdx) const
Return the Peng-Robinson parameters of a pure substance,.
Definition PengRobinsonParamsMixture.hpp:201
Scalar a() const
Returns the attractive parameter 'a' of the Peng-Robinson fluid.
Definition PengRobinsonParams.hpp:50
Scalar b() const
Returns the repulsive parameter 'b' of the Peng-Robinson fluid.
Definition PengRobinsonParams.hpp:57
Implements the Peng-Robinson equation of state for liquids and gases.
Definition PengRobinson.hpp:60
static FluidState::Scalar computeMolarVolume(const FluidState &fs, Params ¶ms, unsigned phaseIdx, bool isGasPhase)
Computes molar volumes where the Peng-Robinson EOS is true.
Definition PengRobinson.hpp:148
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30