27#ifndef OPM_SPE5_PARAMETER_CACHE_HPP
28#define OPM_SPE5_PARAMETER_CACHE_HPP
44template <
class Scalar,
class Flu
idSystem>
53 enum { numPhases = FluidSystem::numPhases };
55 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
56 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
57 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
67 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
68 VmUpToDate_[phaseIdx] =
false;
69 Valgrind::SetUndefined(Vm_[phaseIdx]);
74 template <
class Flu
idState>
83 if (VmUpToDate_[phaseIdx])
87 updateMolarVolume_(fluidState, phaseIdx);
91 template <
class Flu
idState>
96 if (phaseIdx == oilPhaseIdx)
98 else if (phaseIdx == gasPhaseIdx)
102 updateMolarVolume_(fluidState, phaseIdx);
110 Scalar
a(
unsigned phaseIdx)
const
114 case oilPhaseIdx:
return oilPhaseParams_.
a();
115 case gasPhaseIdx:
return gasPhaseParams_.
a();
117 throw std::logic_error(
"The a() parameter is only defined for "
118 "oil and gas phases");
127 Scalar
b(
unsigned phaseIdx)
const
131 case oilPhaseIdx:
return oilPhaseParams_.
b();
132 case gasPhaseIdx:
return gasPhaseParams_.
b();
134 throw std::logic_error(
"The b() parameter is only defined for "
135 "oil and gas phases");
147 Scalar
aPure(
unsigned phaseIdx,
unsigned compIdx)
const
151 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
a();
152 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
a();
154 throw std::logic_error(
"The a() parameter is only defined for "
155 "oil and gas phases");
166 Scalar
bPure(
unsigned phaseIdx,
unsigned compIdx)
const
170 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
b();
171 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
b();
173 throw std::logic_error(
"The b() parameter is only defined for "
174 "oil and gas phases");
185 Scalar
aCache(
unsigned phaseIdx,
unsigned compIdx,
unsigned compJIdx)
const
189 case oilPhaseIdx:
return oilPhaseParams_.
getaCache(compIdx,compJIdx);
190 case gasPhaseIdx:
return gasPhaseParams_.
getaCache(compIdx,compJIdx);
192 throw std::logic_error(
"The aCache() parameter is only defined for "
193 "oil and gas phase");
203 { assert(VmUpToDate_[phaseIdx]);
return Vm_[phaseIdx]; }
211 {
return oilPhaseParams_; }
218 {
return gasPhaseParams_; }
228 template <
class Flu
idState>
237 VmUpToDate_[phaseIdx] =
false;
242 VmUpToDate_[phaseIdx] =
false;
245 VmUpToDate_[phaseIdx] =
false;
256 template <
class Flu
idState>
259 Scalar T = fluidState.temperature(phaseIdx);
260 Scalar p = fluidState.pressure(phaseIdx);
264 case oilPhaseIdx: oilPhaseParams_.
updatePure(T, p);
break;
265 case gasPhaseIdx: gasPhaseParams_.
updatePure(T, p);
break;
277 template <
class Flu
idState>
278 void updateMix_(
const FluidState& fluidState,
unsigned phaseIdx)
280 Valgrind::CheckDefined(fluidState.averageMolarMass(phaseIdx));
294 template <
class Flu
idState>
295 void updateMolarVolume_(
const FluidState& fluidState,
298 VmUpToDate_[phaseIdx] =
true;
330 case waterPhaseIdx: {
334 const Scalar stockTankWaterDensity = 62.4 * 0.45359237 / 0.028316847;
337 Scalar overPressure = fluidState.pressure(waterPhaseIdx) - 1.013e5;
338 Scalar waterDensity =
339 stockTankWaterDensity * (1 + 3.3e-6*overPressure/6894.7573);
342 Vm_[waterPhaseIdx] = fluidState.averageMolarMass(waterPhaseIdx)/waterDensity;
348 bool VmUpToDate_[numPhases];
349 Scalar Vm_[numPhases];
Material properties of pure water .
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.
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
The mixing rule for the oil and the gas phases of the SPE5 problem.
Definition PengRobinsonParamsMixture.hpp:60
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:59
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:147
Specifies the parameter cache used by the SPE-5 fluid system.
Definition Spe5ParameterCache.hpp:47
void updatePhase(const FluidState &fluidState, unsigned phaseIdx, int exceptQuantities=ParentType::None)
Update all cached parameters of a specific fluid phase.
Definition Spe5ParameterCache.hpp:75
Scalar aPure(unsigned phaseIdx, unsigned compIdx) const
The Peng-Robinson attractive parameter for a pure component given the same temperature and pressure o...
Definition Spe5ParameterCache.hpp:147
void updatePure_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which only depend on temperature and/or pressure.
Definition Spe5ParameterCache.hpp:257
const GasPhaseParams & gasPhaseParams() const
Returns the Peng-Robinson mixture parameters for the gas phase.
Definition Spe5ParameterCache.hpp:217
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 Spe5ParameterCache.hpp:166
const OilPhaseParams & oilPhaseParams() const
Returns the Peng-Robinson mixture parameters for the oil phase.
Definition Spe5ParameterCache.hpp:210
PengRobinsonParamsMixture< Scalar, FluidSystem, gasPhaseIdx, true > GasPhaseParams
The cached parameters for the gas phase.
Definition Spe5ParameterCache.hpp:63
void updateMix_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which depend on the fluid composition.
Definition Spe5ParameterCache.hpp:278
Scalar aCache(unsigned phaseIdx, unsigned compIdx, unsigned compJIdx) const
TODO.
Definition Spe5ParameterCache.hpp:185
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition Spe5ParameterCache.hpp:202
Scalar a(unsigned phaseIdx) const
The Peng-Robinson attractive parameter for a phase.
Definition Spe5ParameterCache.hpp:110
Scalar b(unsigned phaseIdx) const
The Peng-Robinson covolume for a phase.
Definition Spe5ParameterCache.hpp:127
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 Spe5ParameterCache.hpp:229
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 Spe5ParameterCache.hpp:92
PengRobinsonParamsMixture< Scalar, FluidSystem, oilPhaseIdx, true > OilPhaseParams
The cached parameters for the oil phase.
Definition Spe5ParameterCache.hpp:61
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30