28 #ifndef OPM_FLUID_STATE_FUGACITY_MODULES_HPP
29 #define OPM_FLUID_STATE_FUGACITY_MODULES_HPP
42 template <
class Scalar,
44 unsigned numComponents,
51 Valgrind::SetUndefined(fugacityCoefficient_);
58 {
return fugacityCoefficient_[phaseIdx][compIdx]; }
63 Scalar
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
64 {
return asImp_().pressure(phaseIdx)*fugacityCoefficient_[phaseIdx][compIdx]*asImp_().moleFraction(phaseIdx, compIdx); }
70 { fugacityCoefficient_[phaseIdx][compIdx] = value; }
76 template <
class Flu
idState>
79 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
80 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
81 fugacityCoefficient_[phaseIdx][compIdx] = fs.fugacityCoefficient(phaseIdx, compIdx);
96 Valgrind::CheckDefined(fugacityCoefficient_);
100 const Implementation& asImp_()
const
101 {
return *
static_cast<const Implementation*
>(
this); }
103 Scalar fugacityCoefficient_[numPhases][numComponents];
110 template <
class Scalar,
112 unsigned numComponents,
113 class Implementation>
116 static_assert(numPhases == numComponents,
117 "The number of phases must be the same as the number of (pseudo-) components if you assume immiscibility");
121 { Valgrind::SetUndefined(fugacityCoefficient_); }
127 {
return (phaseIdx == compIdx)?fugacityCoefficient_[phaseIdx]:std::numeric_limits<Scalar>::infinity(); }
132 Scalar
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
133 {
return asImp_().pressure(phaseIdx)*
fugacityCoefficient(phaseIdx, compIdx)*asImp_().moleFraction(phaseIdx, compIdx); }
139 { fugacityCoefficient_[phaseIdx] = value; }
145 template <
class Flu
idState>
148 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
149 fugacityCoefficient_[phaseIdx] = fs.fugacityCoefficient(phaseIdx, phaseIdx);
163 Valgrind::CheckDefined(fugacityCoefficient_);
167 const Implementation& asImp_()
const
168 {
return *
static_cast<const Implementation*
>(
this); }
170 Scalar fugacityCoefficient_[numPhases];
177 template <
class Scalar>
188 {
throw std::logic_error(
"Fugacity coefficients are not provided by this fluid state"); }
194 {
throw std::logic_error(
"Fugacities coefficients are not provided by this fluid state"); }
Some templates to wrap the valgrind client request macros.
Module for the modular fluid state which stores the phase fugacity coefficients explicitly.
Definition: FluidStateFugacityModules.hpp:47
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateFugacityModules.hpp:77
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateFugacityModules.hpp:94
void setFugacityCoefficient(unsigned phaseIdx, unsigned compIdx, const Scalar &value)
Set the fugacity of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:69
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition: FluidStateFugacityModules.hpp:63
const Scalar & fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:57
Module for the modular fluid state which stores the phase fugacity coefficients explicitly assuming i...
Definition: FluidStateFugacityModules.hpp:115
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateFugacityModules.hpp:146
Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:126
void setFugacityCoefficient(unsigned phaseIdx, const Scalar &value)
Set the fugacity of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:138
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateFugacityModules.hpp:161
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition: FluidStateFugacityModules.hpp:132
Module for the modular fluid state which does not store the fugacities but throws std::logic_error in...
Definition: FluidStateFugacityModules.hpp:179
const Scalar & fugacityCoefficient(unsigned, unsigned) const
The fugacity coefficient of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:187
const Scalar & fugacity(unsigned, unsigned) const
The fugacity of a component in a phase [Pa].
Definition: FluidStateFugacityModules.hpp:193
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateFugacityModules.hpp:204