63 :
protected BaseFluidState
66 enum { numPhases = FluidSystem::numPhases };
67 enum { numComponents = FluidSystem::numComponents };
69 typedef ScalarT Scalar;
74 allowTemperature(
false);
76 allowComposition(
false);
80 restrictToPhase(1000);
83 void allowTemperature(
bool yesno)
84 { allowTemperature_ = yesno; }
86 void allowPressure(
bool yesno)
87 { allowPressure_ = yesno; }
89 void allowComposition(
bool yesno)
90 { allowComposition_ = yesno; }
92 void allowDensity(
bool yesno)
93 { allowDensity_ = yesno; }
95 void restrictToPhase(
int phaseIdx)
96 { restrictPhaseIdx_ = phaseIdx; }
98 BaseFluidState& base()
99 {
return *
static_cast<BaseFluidState*
>(
this); }
101 const BaseFluidState& base()
const
102 {
return *
static_cast<const BaseFluidState*
>(
this); }
104 auto temperature(
unsigned phaseIdx)
const
105 ->
decltype(this->base().temperature(phaseIdx))
107 assert(allowTemperature_);
108 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
109 return this->base().temperature(phaseIdx);
112 auto pressure(
unsigned phaseIdx)
const
113 ->
decltype(this->base().pressure(phaseIdx))
115 assert(allowPressure_);
116 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
117 return this->base().pressure(phaseIdx);
120 auto moleFraction(
unsigned phaseIdx,
unsigned compIdx)
const
121 ->
decltype(this->base().moleFraction(phaseIdx, compIdx))
123 assert(allowComposition_);
124 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
125 return this->base().moleFraction(phaseIdx, compIdx);
128 auto massFraction(
unsigned phaseIdx,
unsigned compIdx)
const
129 ->
decltype(this->base().massFraction(phaseIdx, compIdx))
131 assert(allowComposition_);
132 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
133 return this->base().massFraction(phaseIdx, compIdx);
136 auto averageMolarMass(
unsigned phaseIdx)
const
137 ->
decltype(this->base().averageMolarMass(phaseIdx))
139 assert(allowComposition_);
140 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
141 return this->base().averageMolarMass(phaseIdx);
144 auto molarity(
unsigned phaseIdx,
unsigned compIdx)
const
145 ->
decltype(this->base().molarity(phaseIdx, compIdx))
147 assert(allowDensity_ && allowComposition_);
148 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
149 return this->base().molarity(phaseIdx, compIdx);
152 auto molarDensity(
unsigned phaseIdx)
const
153 ->
decltype(this->base().molarDensity(phaseIdx))
155 assert(allowDensity_);
156 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
157 return this->base().molarDensity(phaseIdx);
160 auto molarVolume(
unsigned phaseIdx)
const
161 ->
decltype(this->base().molarVolume(phaseIdx))
163 assert(allowDensity_);
164 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
165 return this->base().molarVolume(phaseIdx);
168 auto density(
unsigned phaseIdx)
const
169 ->
decltype(this->base().density(phaseIdx))
171 assert(allowDensity_);
172 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
173 return this->base().density(phaseIdx);
176 auto saturation(
unsigned phaseIdx)
const
177 ->
decltype(this->base().saturation(phaseIdx))
180 return this->base().saturation(phaseIdx);
183 auto fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
184 ->
decltype(this->base().fugacity(phaseIdx, compIdx))
187 return this->base().fugacity(phaseIdx, compIdx);
190 auto fugacityCoefficient(
unsigned phaseIdx,
unsigned compIdx)
const
191 ->
decltype(this->base().fugacityCoefficient(phaseIdx, compIdx))
194 return this->base().fugacityCoefficient(phaseIdx, compIdx);
197 auto enthalpy(
unsigned phaseIdx)
const
198 ->
decltype(this->base().enthalpy(phaseIdx))
201 return this->base().enthalpy(phaseIdx);
204 auto internalEnergy(
unsigned phaseIdx)
const
205 ->
decltype(this->base().internalEnergy(phaseIdx))
208 return this->base().internalEnergy(phaseIdx);
211 auto viscosity(
unsigned phaseIdx)
const
212 ->
decltype(this->base().viscosity(phaseIdx))
215 return this->base().viscosity(phaseIdx);
218 auto compressFactor(
unsigned phaseIdx)
const
219 ->
decltype(this->base().compressFactor(phaseIdx))
221 return this->base().compressFactor(phaseIdx);
225 bool allowSaturation_;
226 bool allowTemperature_;
228 bool allowComposition_;
230 int restrictPhaseIdx_;
278 std::cout <<
"Testing fluid system '"
281 <<
", LhsEval = " <<
Opm::demangle(
typeid(LhsEval).name()) <<
"'\n";
285 enum { numPhases = FluidSystem::numPhases };
286 enum { numComponents = FluidSystem::numComponents };
290 fs.allowTemperature(
true);
291 fs.allowPressure(
true);
292 fs.allowComposition(
true);
293 fs.restrictToPhase(-1);
296 fs.base().setTemperature(273.15 + 20.0);
297 for (
int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
298 fs.base().setPressure(phaseIdx, 1e5);
299 fs.base().setSaturation(phaseIdx, 1.0/numPhases);
300 for (
int compIdx = 0; compIdx < numComponents; ++ compIdx) {
301 fs.base().setMoleFraction(phaseIdx, compIdx, 1.0/numComponents);
305 static_assert(std::is_same<typename FluidSystem::Scalar, Scalar>::value,
306 "The type used for floating point used by the fluid system must be the same"
307 " as the one passed to the checkFluidSystem() function");
310 typedef typename FluidSystem::template ParameterCache<LhsEval> ParameterCache;
312 ParameterCache paramCache;
313 try { paramCache.updateAll(fs); }
catch (...) {};
314 try { paramCache.updateAll(fs, ParameterCache::None); }
catch (...) {};
315 try { paramCache.updateAll(fs, ParameterCache::Temperature | ParameterCache::Pressure | ParameterCache::Composition); }
catch (...) {};
316 try { paramCache.updateAllPressures(fs); }
catch (...) {};
318 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
319 fs.restrictToPhase(
static_cast<int>(phaseIdx));
320 try { paramCache.updatePhase(fs, phaseIdx); }
catch (...) {};
321 try { paramCache.updatePhase(fs, phaseIdx, ParameterCache::None); }
catch (...) {};
322 try { paramCache.updatePhase(fs, phaseIdx, ParameterCache::Temperature | ParameterCache::Pressure | ParameterCache::Composition); }
catch (...) {};
323 try { paramCache.updateTemperature(fs, phaseIdx); }
catch (...) {};
324 try { paramCache.updatePressure(fs, phaseIdx); }
catch (...) {};
325 try { paramCache.updateComposition(fs, phaseIdx); }
catch (...) {};
326 try { paramCache.updateSingleMoleFraction(fs, phaseIdx, 0); }
catch (...) {};
332 Scalar scalarVal = 0.0;
334 scalarVal = 2*scalarVal;
338 try { FluidSystem::init(); }
catch (...) {};
339 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
340 fs.restrictToPhase(
static_cast<int>(phaseIdx));
341 fs.allowPressure(FluidSystem::isCompressible(phaseIdx));
342 fs.allowComposition(
true);
343 fs.allowDensity(
false);
344 try { [[maybe_unused]]
auto tmpVal = FluidSystem::density(fs, paramCache, phaseIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
345 try { val = FluidSystem::template density<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
346 try { scalarVal = FluidSystem::template density<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
348 fs.allowPressure(
true);
349 fs.allowDensity(
true);
350 try { [[maybe_unused]]
auto tmpVal = FluidSystem::viscosity(fs, paramCache, phaseIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
351 try { [[maybe_unused]]
auto tmpVal = FluidSystem::enthalpy(fs, paramCache, phaseIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
352 try { [[maybe_unused]]
auto tmpVal = FluidSystem::heatCapacity(fs, paramCache, phaseIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
353 try { [[maybe_unused]]
auto tmpVal = FluidSystem::thermalConductivity(fs, paramCache, phaseIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
354 try { val = FluidSystem::template viscosity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
355 try { val = FluidSystem::template enthalpy<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
356 try { val = FluidSystem::template heatCapacity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
357 try { val = FluidSystem::template thermalConductivity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
358 try { scalarVal = FluidSystem::template viscosity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
359 try { scalarVal = FluidSystem::template enthalpy<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
360 try { scalarVal = FluidSystem::template heatCapacity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
361 try { scalarVal = FluidSystem::template thermalConductivity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
363 for (
unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
364 fs.allowComposition(!FluidSystem::isIdealMixture(phaseIdx));
365 try { [[maybe_unused]]
auto tmpVal = FluidSystem::fugacityCoefficient(fs, paramCache, phaseIdx, compIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
366 try { val = FluidSystem::template fugacityCoefficient<FluidState, LhsEval>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
367 try { scalarVal = FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
368 fs.allowComposition(
true);
369 try { [[maybe_unused]]
auto tmpVal = FluidSystem::diffusionCoefficient(fs, paramCache, phaseIdx, compIdx);
static_assert(std::is_same<
decltype(tmpVal), RhsEval>::value,
"The default return value must be the scalar used by the fluid state!"); }
catch (...) {};
370 try { val = FluidSystem::template diffusionCoefficient<FluidState, LhsEval>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
371 try { scalarVal = FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
376 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
377 [[maybe_unused]] std::string name{FluidSystem::phaseName(phaseIdx)};
378 bool bVal = FluidSystem::isLiquid(phaseIdx);
379 bVal = FluidSystem::isIdealGas(phaseIdx);
384 for (
unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
385 val = FluidSystem::molarMass(compIdx);
386 std::string{FluidSystem::componentName(compIdx)};