27 #ifndef OPM_SPE5_PARAMETER_CACHE_HPP 28 #define OPM_SPE5_PARAMETER_CACHE_HPP 44 template <
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 };
59 static_assert(static_cast<int>(oilPhaseIdx) >= 0,
"Oil phase index must be non-negative");
60 static_assert(static_cast<int>(oilPhaseIdx) < static_cast<int>(numPhases),
61 "Oil phase index must be strictly less than FluidSystem's number of phases");
63 static_assert(static_cast<int>(gasPhaseIdx) >= 0,
"Gas phase index must be non-negative");
64 static_assert(static_cast<int>(gasPhaseIdx) < static_cast<int>(numPhases),
65 "Gas phase index must be strictly less than FluidSystem's number of phases");
67 static_assert(static_cast<int>(waterPhaseIdx) >= 0,
"Water phase index must be non-negative");
68 static_assert(static_cast<int>(waterPhaseIdx) < static_cast<int>(numPhases),
69 "Water phase index must be strictly less than FluidSystem's number of phases");
79 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
80 VmUpToDate_[phaseIdx] =
false;
81 Valgrind::SetUndefined(Vm_[phaseIdx]);
86 template <
class Flu
idState>
91 assert ((phaseIdx == static_cast<unsigned int>(oilPhaseIdx)) ||
92 (phaseIdx == static_cast<unsigned int>(gasPhaseIdx)) ||
93 (phaseIdx == static_cast<unsigned int>(waterPhaseIdx)));
99 if (VmUpToDate_[phaseIdx])
103 updateMolarVolume_(fluidState, phaseIdx);
107 template <
class Flu
idState>
112 assert ((phaseIdx == static_cast<unsigned int>(oilPhaseIdx)) ||
113 (phaseIdx == static_cast<unsigned int>(gasPhaseIdx)) ||
114 (phaseIdx == static_cast<unsigned int>(waterPhaseIdx)));
116 if (phaseIdx == oilPhaseIdx)
118 else if (phaseIdx == gasPhaseIdx)
122 updateMolarVolume_(fluidState, phaseIdx);
130 Scalar
a(
unsigned phaseIdx)
const 134 case oilPhaseIdx:
return oilPhaseParams_.
a();
135 case gasPhaseIdx:
return gasPhaseParams_.
a();
137 throw std::logic_error(
"The a() parameter is only defined for " 138 "oil and gas phases");
147 Scalar
b(
unsigned phaseIdx)
const 151 case oilPhaseIdx:
return oilPhaseParams_.
b();
152 case gasPhaseIdx:
return gasPhaseParams_.
b();
154 throw std::logic_error(
"The b() parameter is only defined for " 155 "oil and gas phases");
167 Scalar
aPure(
unsigned phaseIdx,
unsigned compIdx)
const 171 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
a();
172 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
a();
174 throw std::logic_error(
"The a() parameter is only defined for " 175 "oil and gas phases");
186 Scalar
bPure(
unsigned phaseIdx,
unsigned compIdx)
const 190 case oilPhaseIdx:
return oilPhaseParams_.
pureParams(compIdx).
b();
191 case gasPhaseIdx:
return gasPhaseParams_.
pureParams(compIdx).
b();
193 throw std::logic_error(
"The b() parameter is only defined for " 194 "oil and gas phases");
205 Scalar
aCache(
unsigned phaseIdx,
unsigned compIdx,
unsigned compJIdx)
const 209 case oilPhaseIdx:
return oilPhaseParams_.
getaCache(compIdx,compJIdx);
210 case gasPhaseIdx:
return gasPhaseParams_.
getaCache(compIdx,compJIdx);
212 throw std::logic_error(
"The aCache() parameter is only defined for " 213 "oil and gas phase");
223 { assert(VmUpToDate_[phaseIdx]);
return Vm_[phaseIdx]; }
231 {
return oilPhaseParams_; }
238 {
return gasPhaseParams_; }
248 template <
class Flu
idState>
253 assert ((phaseIdx == static_cast<unsigned int>(oilPhaseIdx)) ||
254 (phaseIdx == static_cast<unsigned int>(gasPhaseIdx)) ||
255 (phaseIdx == static_cast<unsigned int>(waterPhaseIdx)));
261 VmUpToDate_[phaseIdx] =
false;
266 VmUpToDate_[phaseIdx] =
false;
269 VmUpToDate_[phaseIdx] =
false;
280 template <
class Flu
idState>
283 Scalar T = fluidState.temperature(phaseIdx);
284 Scalar p = fluidState.pressure(phaseIdx);
288 case oilPhaseIdx: oilPhaseParams_.
updatePure(T, p);
break;
289 case gasPhaseIdx: gasPhaseParams_.
updatePure(T, p);
break;
301 template <
class Flu
idState>
302 void updateMix_(
const FluidState& fluidState,
unsigned phaseIdx)
304 Valgrind::CheckDefined(fluidState.averageMolarMass(phaseIdx));
318 template <
class Flu
idState>
319 void updateMolarVolume_(
const FluidState& fluidState,
322 VmUpToDate_[phaseIdx] =
true;
354 case waterPhaseIdx: {
358 const Scalar stockTankWaterDensity = 62.4 * 0.45359237 / 0.028316847;
361 Scalar overPressure = fluidState.pressure(waterPhaseIdx) - 1.013e5;
362 Scalar waterDensity =
363 stockTankWaterDensity * (1 + 3.3e-6*overPressure/6894.7573);
366 Vm_[waterPhaseIdx] = fluidState.averageMolarMass(waterPhaseIdx)/waterDensity;
372 bool VmUpToDate_[numPhases];
373 Scalar Vm_[numPhases];
The mixing rule for the oil and the gas phases of the SPE5 problem.
Definition: PengRobinsonParamsMixture.hpp:58
Scalar a(unsigned phaseIdx) const
The Peng-Robinson attractive parameter for a phase.
Definition: Spe5ParameterCache.hpp:130
Implements the Peng-Robinson equation of state for liquids and gases.
Definition: PengRobinson.hpp:59
void updateMix(const FluidState &fs)
Calculates the "a" and "b" Peng-Robinson parameters for the mixture.
Definition: PengRobinsonParamsMixture.hpp:143
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:186
Specifies the parameter cache used by the SPE-5 fluid system.
Definition: Spe5ParameterCache.hpp:45
Scalar b(unsigned phaseIdx) const
The Peng-Robinson covolume for a phase.
Definition: Spe5ParameterCache.hpp:147
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Material properties of pure water .
The temperature has not been modified.
Definition: ParameterCacheBase.hpp:48
const OilPhaseParams & oilPhaseParams() const
Returns the Peng-Robinson mixture parameters for the oil phase.
Definition: Spe5ParameterCache.hpp:230
Implements the Peng-Robinson equation of state for liquids and gases.
The compositions have not been modified.
Definition: ParameterCacheBase.hpp:54
void updatePure(const FluidState &fluidState)
Update Peng-Robinson parameters for the pure components.
Definition: PengRobinsonParamsMixture.hpp:82
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:167
All quantities have been (potentially) modified.
Definition: ParameterCacheBase.hpp:45
The pressures have not been modified.
Definition: ParameterCacheBase.hpp:51
The base class of the parameter caches of fluid systems.
Definition: ParameterCacheBase.hpp:37
void updatePure_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which only depend on temperature and/or pressure.
Definition: Spe5ParameterCache.hpp:281
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:249
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
const GasPhaseParams & gasPhaseParams() const
Returns the Peng-Robinson mixture parameters for the gas phase.
Definition: Spe5ParameterCache.hpp:237
The mixing rule for the oil and the gas phases of the SPE5 problem.
Scalar a() const
Returns the attractive parameter 'a' of the Peng-Robinson fluid.
Definition: PengRobinsonParams.hpp:50
Scalar aCache(unsigned phaseIdx, unsigned compIdx, unsigned compJIdx) const
TODO.
Definition: Spe5ParameterCache.hpp:205
PengRobinsonParamsMixture< Scalar, FluidSystem, oilPhaseIdx, true > OilPhaseParams
The cached parameters for the oil phase.
Definition: Spe5ParameterCache.hpp:59
void updatePhase(const FluidState &fluidState, unsigned phaseIdx, int exceptQuantities=ParentType::None)
Update all cached parameters of a specific fluid phase.
Definition: Spe5ParameterCache.hpp:87
The base class of the parameter caches of fluid systems.
static FluidState::ValueType computeMolarVolume(const FluidState &fs, Params ¶ms, unsigned phaseIdx, bool isGasPhase)
Computes molar volumes where the Peng-Robinson EOS is true.
Definition: PengRobinson.hpp:148
Scalar b() const
Returns the repulsive parameter 'b' of the Peng-Robinson fluid.
Definition: PengRobinsonParams.hpp:57
Scalar getaCache(unsigned compIIdx, unsigned compJIdx) const
TODO.
Definition: PengRobinsonParamsMixture.hpp:73
void updateMix_(const FluidState &fluidState, unsigned phaseIdx)
Update all parameters of a phase which depend on the fluid composition.
Definition: Spe5ParameterCache.hpp:302
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:108
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition: Spe5ParameterCache.hpp:222
const PureParams & pureParams(unsigned compIdx) const
Return the Peng-Robinson parameters of a pure substance,.
Definition: PengRobinsonParamsMixture.hpp:201
PengRobinsonParamsMixture< Scalar, FluidSystem, gasPhaseIdx, true > GasPhaseParams
The cached parameters for the gas phase.
Definition: Spe5ParameterCache.hpp:75