28 #ifndef OPM_FLUID_STATE_FUGACITY_MODULES_HPP
29 #define OPM_FLUID_STATE_FUGACITY_MODULES_HPP
31 #include <opm/common/Valgrind.hpp>
33 #include <opm/common/ErrorMacros.hpp>
34 #include <opm/common/Exceptions.hpp>
45 template <
class Scalar,
47 unsigned numComponents,
54 Valgrind::SetUndefined(fugacityCoefficient_);
61 {
return fugacityCoefficient_[phaseIdx][compIdx]; }
66 Scalar
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
67 {
return asImp_().pressure(phaseIdx)*fugacityCoefficient_[phaseIdx][compIdx]*asImp_().moleFraction(phaseIdx, compIdx); }
73 { fugacityCoefficient_[phaseIdx][compIdx] = value; }
79 template <
class Flu
idState>
82 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
83 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
84 fugacityCoefficient_[phaseIdx][compIdx] = fs.fugacityCoefficient(phaseIdx, compIdx);
99 Valgrind::CheckDefined(fugacityCoefficient_);
103 const Implementation& asImp_()
const
104 {
return *
static_cast<const Implementation*
>(
this); }
106 Scalar fugacityCoefficient_[numPhases][numComponents];
113 template <
class Scalar,
115 unsigned numComponents,
116 class Implementation>
119 static_assert(numPhases == numComponents,
120 "The number of phases must be the same as the number of (pseudo-) components if you assume immiscibility");
124 { Valgrind::SetUndefined(fugacityCoefficient_); }
130 {
return (phaseIdx == compIdx)?fugacityCoefficient_[phaseIdx]:std::numeric_limits<Scalar>::infinity(); }
135 Scalar
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
136 {
return asImp_().pressure(phaseIdx)*
fugacityCoefficient(phaseIdx, compIdx)*asImp_().moleFraction(phaseIdx, compIdx); }
142 { fugacityCoefficient_[phaseIdx] = value; }
148 template <
class Flu
idState>
151 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
152 fugacityCoefficient_[phaseIdx] = fs.fugacityCoefficient(phaseIdx, phaseIdx);
166 Valgrind::CheckDefined(fugacityCoefficient_);
170 const Implementation& asImp_()
const
171 {
return *
static_cast<const Implementation*
>(
this); }
173 Scalar fugacityCoefficient_[numPhases];
180 template <
class Scalar>
191 { OPM_THROW(std::logic_error,
"Fugacity coefficients are not provided by this fluid state"); }
197 { OPM_THROW(std::logic_error,
"Fugacities coefficients are not provided by this fluid state"); }
Module for the modular fluid state which stores the phase fugacity coefficients explicitly assuming i...
Definition: FluidStateFugacityModules.hpp:117
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateFugacityModules.hpp:80
Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:129
void setFugacityCoefficient(unsigned phaseIdx, const Scalar &value)
Set the fugacity of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:141
const Scalar & fugacityCoefficient(unsigned, unsigned) const
The fugacity coefficient of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:190
const Scalar & fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:60
const Scalar & fugacity(unsigned, unsigned) const
The fugacity of a component in a phase [Pa].
Definition: FluidStateFugacityModules.hpp:196
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateFugacityModules.hpp:97
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateFugacityModules.hpp:164
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateFugacityModules.hpp:207
Module for the modular fluid state which stores the phase fugacity coefficients explicitly.
Definition: FluidStateFugacityModules.hpp:49
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition: FluidStateFugacityModules.hpp:135
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateFugacityModules.hpp:149
void setFugacityCoefficient(unsigned phaseIdx, unsigned compIdx, const Scalar &value)
Set the fugacity of a component in a phase [].
Definition: FluidStateFugacityModules.hpp:72
Module for the modular fluid state which does not store the fugacities but throws std::logic_error in...
Definition: FluidStateFugacityModules.hpp:181
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition: FluidStateFugacityModules.hpp:66