30 #ifndef OPM_PTFlash_PARAMETER_CACHE_HPP
31 #define OPM_PTFlash_PARAMETER_CACHE_HPP
45 template <
class Scalar,
class Flu
idSystem>
53 enum { numPhases = FluidSystem::numPhases };
54 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
55 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx};
65 VmUpToDate_[oilPhaseIdx] =
false;
66 Valgrind::SetUndefined(Vm_[oilPhaseIdx]);
67 VmUpToDate_[gasPhaseIdx] =
false;
68 Valgrind::SetUndefined(Vm_[gasPhaseIdx]);
72 template <
class Flu
idState>
80 updateMolarVolume_(fluidState, phaseIdx);
84 template <
class Flu
idState>
89 if (phaseIdx == oilPhaseIdx)
91 if (phaseIdx == gasPhaseIdx)
97 updateMolarVolume_(fluidState, phaseIdx);
105 Scalar
a(
unsigned phaseIdx)
const
109 case oilPhaseIdx:
return oilPhaseParams_.
a();
110 case gasPhaseIdx:
return gasPhaseParams_.
a();
112 throw std::logic_error(
"The a() parameter is only defined for "
113 "oil and gas phases");
122 Scalar
b(
unsigned phaseIdx)
const
126 case oilPhaseIdx:
return oilPhaseParams_.
b();
127 case gasPhaseIdx:
return gasPhaseParams_.
b();
129 throw std::logic_error(
"The b() parameter is only defined for "
130 "oil and gas phase");
142 Scalar
aPure(
unsigned phaseIdx,
unsigned compIdx)
const
146 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
a();
147 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
a();
149 throw std::logic_error(
"The a() parameter is only defined for "
150 "oil and gas phase");
161 Scalar
bPure(
unsigned phaseIdx,
unsigned compIdx)
const
165 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
b();
166 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
b();
168 throw std::logic_error(
"The b() parameter is only defined for "
169 "oil and gas phase");
182 Scalar
aCache(
unsigned phaseIdx,
unsigned compIdx,
unsigned compJIdx)
const
186 case oilPhaseIdx:
return oilPhaseParams_.
getaCache(compIdx,compJIdx);
187 case gasPhaseIdx:
return gasPhaseParams_.
getaCache(compIdx,compJIdx);
189 throw std::logic_error(
"The aCache() parameter is only defined for "
190 "oil and gas phase");
200 { assert(VmUpToDate_[phaseIdx]);
return Vm_[phaseIdx]; }
208 {
return oilPhaseParams_; }
216 {
return gasPhaseParams_; }
226 template <
class Flu
idState>
235 VmUpToDate_[phaseIdx] =
false;
240 VmUpToDate_[phaseIdx] =
false;
243 VmUpToDate_[phaseIdx] =
false;
254 template <
class Flu
idState>
257 Scalar T = fluidState.temperature(phaseIdx);
258 Scalar p = fluidState.pressure(phaseIdx);
262 case oilPhaseIdx: oilPhaseParams_.
updatePure(T, p);
break;
263 case gasPhaseIdx: gasPhaseParams_.
updatePure(T, p);
break;
274 template <
class Flu
idState>
275 void updateMix_(
const FluidState& fluidState,
unsigned phaseIdx)
277 Valgrind::CheckDefined(fluidState.averageMolarMass(phaseIdx));
289 template <
class Flu
idState>
290 void updateMolarVolume_(
const FluidState& fluidState,
293 VmUpToDate_[phaseIdx] =
true;
328 bool VmUpToDate_[numPhases];
329 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:59
const GasPhaseParams & gasPhaseParams() const
Returns the Peng-Robinson mixture parameters for the gas phase.
Definition: PTFlashParameterCache.hpp:214
void updatePure_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which only depend on temperature and/or pressure.
Definition: PTFlashParameterCache.hpp:255
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition: PTFlashParameterCache.hpp:199
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:85
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:161
Scalar aCache(unsigned phaseIdx, unsigned compIdx, unsigned compJIdx) const
TODO.
Definition: PTFlashParameterCache.hpp:182
Opm::PengRobinsonParamsMixture< Scalar, FluidSystem, gasPhaseIdx, false > GasPhaseParams
The cached parameters for the gas phase.
Definition: PTFlashParameterCache.hpp:61
void updateMix_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which depend on the fluid composition.
Definition: PTFlashParameterCache.hpp:275
void updatePhase(const FluidState &fluidState, unsigned phaseIdx, int exceptQuantities=ParentType::None)
Update all cached parameters of a specific fluid phase.
Definition: PTFlashParameterCache.hpp:73
Scalar a(unsigned phaseIdx) const
The Peng-Robinson attractive parameter for a phase.
Definition: PTFlashParameterCache.hpp:105
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:142
Scalar b(unsigned phaseIdx) const
The Peng-Robinson covolume for a phase.
Definition: PTFlashParameterCache.hpp:122
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:227
const OilPhaseParams & oilPhaseParams() const
Returns the Peng-Robinson mixture parameters for the oil phase.
Definition: PTFlashParameterCache.hpp:207
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:196
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:205
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:56
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:144