28#ifndef OPM_FLUID_STATE_FUGACITY_MODULES_HPP
29#define OPM_FLUID_STATE_FUGACITY_MODULES_HPP
43template <
class ValueType,
45 unsigned numComponents,
47class FluidStateExplicitFugacityModule
50 FluidStateExplicitFugacityModule()
59 {
return fugacityCoefficient_[phaseIdx][compIdx]; }
64 ValueType
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
65 {
return asImp_().pressure(phaseIdx)*fugacityCoefficient_[phaseIdx][compIdx]*asImp_().moleFraction(phaseIdx, compIdx); }
71 { fugacityCoefficient_[phaseIdx][compIdx] = value; }
77 template <
class Flu
idState>
80 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
81 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
82 fugacityCoefficient_[phaseIdx][compIdx] = fs.fugacityCoefficient(phaseIdx, compIdx);
101 const Implementation& asImp_()
const
102 {
return *
static_cast<const Implementation*
>(
this); }
104 std::array<std::array<ValueType, numComponents>, numPhases> fugacityCoefficient_{};
111template <
class ValueT,
113 unsigned numComponents,
114 class Implementation>
115class FluidStateImmiscibleFugacityModule
117 static_assert(numPhases == numComponents,
118 "The number of phases must be the same as the number of (pseudo-) components if you assume immiscibility");
121 FluidStateImmiscibleFugacityModule()
128 {
return (phaseIdx == compIdx)?fugacityCoefficient_[phaseIdx]:std::numeric_limits<ValueT>::infinity(); }
133 ValueT
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
134 {
return asImp_().pressure(phaseIdx)*
fugacityCoefficient(phaseIdx, compIdx)*asImp_().moleFraction(phaseIdx, compIdx); }
140 { fugacityCoefficient_[phaseIdx] = value; }
146 template <
class Flu
idState>
149 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
150 fugacityCoefficient_[phaseIdx] = fs.fugacityCoefficient(phaseIdx, phaseIdx);
168 const Implementation& asImp_()
const
169 {
return *
static_cast<const Implementation*
>(
this); }
171 std::array<ValueT, numPhases> fugacityCoefficient_{};
178template <
class ValueT>
179class FluidStateNullFugacityModule
182 FluidStateNullFugacityModule()
189 {
throw std::logic_error(
"Fugacity coefficients are not provided by this fluid state"); }
195 {
throw std::logic_error(
"Fugacities coefficients are not provided by this fluid state"); }
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE void SetUndefined(const T &value)
Make the memory on which an object resides undefined in valgrind runs.
Definition Valgrind.hpp:174
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
ValueType fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition FluidStateFugacityModules.hpp:64
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateFugacityModules.hpp:78
void setFugacityCoefficient(unsigned phaseIdx, unsigned compIdx, const ValueType &value)
Set the fugacity of a component in a phase [].
Definition FluidStateFugacityModules.hpp:70
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateFugacityModules.hpp:95
const ValueType & fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition FluidStateFugacityModules.hpp:58
ValueT fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition FluidStateFugacityModules.hpp:127
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateFugacityModules.hpp:162
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateFugacityModules.hpp:147
void setFugacityCoefficient(unsigned phaseIdx, const ValueT &value)
Set the fugacity of a component in a phase [].
Definition FluidStateFugacityModules.hpp:139
ValueT fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition FluidStateFugacityModules.hpp:133
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateFugacityModules.hpp:205
const ValueT & fugacity(unsigned, unsigned) const
The fugacity of a component in a phase [Pa].
Definition FluidStateFugacityModules.hpp:194
const ValueT & fugacityCoefficient(unsigned, unsigned) const
The fugacity coefficient of a component in a phase [].
Definition FluidStateFugacityModules.hpp:188
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30