64 :
protected BaseFluidState
67 static constexpr int numPhases = FluidSystem::numPhases;
68 static constexpr int numComponents = FluidSystem::numComponents;
70 typedef ScalarT Scalar;
75 allowTemperature(
false);
77 allowComposition(
false);
81 restrictToPhase(1000);
84 void allowTemperature(
bool yesno)
85 { allowTemperature_ = yesno; }
87 void allowPressure(
bool yesno)
88 { allowPressure_ = yesno; }
90 void allowComposition(
bool yesno)
91 { allowComposition_ = yesno; }
93 void allowDensity(
bool yesno)
94 { allowDensity_ = yesno; }
96 void restrictToPhase(
int phaseIdx)
97 { restrictPhaseIdx_ = phaseIdx; }
99 BaseFluidState& base()
100 {
return *
static_cast<BaseFluidState*
>(
this); }
102 const BaseFluidState& base()
const
103 {
return *
static_cast<const BaseFluidState*
>(
this); }
105 auto temperature(
unsigned phaseIdx)
const
106 ->
decltype(this->base().temperature(phaseIdx))
108 assert(allowTemperature_);
109 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
110 return this->base().temperature(phaseIdx);
113 auto pressure(
unsigned phaseIdx)
const
114 ->
decltype(this->base().pressure(phaseIdx))
116 assert(allowPressure_);
117 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
118 return this->base().pressure(phaseIdx);
121 auto moleFraction(
unsigned phaseIdx,
unsigned compIdx)
const
122 ->
decltype(this->base().moleFraction(phaseIdx, compIdx))
124 assert(allowComposition_);
125 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
126 return this->base().moleFraction(phaseIdx, compIdx);
129 auto massFraction(
unsigned phaseIdx,
unsigned compIdx)
const
130 ->
decltype(this->base().massFraction(phaseIdx, compIdx))
132 assert(allowComposition_);
133 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
134 return this->base().massFraction(phaseIdx, compIdx);
137 auto averageMolarMass(
unsigned phaseIdx)
const
138 ->
decltype(this->base().averageMolarMass(phaseIdx))
140 assert(allowComposition_);
141 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
142 return this->base().averageMolarMass(phaseIdx);
145 auto molarity(
unsigned phaseIdx,
unsigned compIdx)
const
146 ->
decltype(this->base().molarity(phaseIdx, compIdx))
148 assert(allowDensity_ && allowComposition_);
149 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
150 return this->base().molarity(phaseIdx, compIdx);
153 auto molarDensity(
unsigned phaseIdx)
const
154 ->
decltype(this->base().molarDensity(phaseIdx))
156 assert(allowDensity_);
157 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
158 return this->base().molarDensity(phaseIdx);
161 auto molarVolume(
unsigned phaseIdx)
const
162 ->
decltype(this->base().molarVolume(phaseIdx))
164 assert(allowDensity_);
165 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
166 return this->base().molarVolume(phaseIdx);
169 auto density(
unsigned phaseIdx)
const
170 ->
decltype(this->base().density(phaseIdx))
172 assert(allowDensity_);
173 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
174 return this->base().density(phaseIdx);
177 auto saturation(
unsigned phaseIdx)
const
178 ->
decltype(this->base().saturation(phaseIdx))
181 return this->base().saturation(phaseIdx);
184 auto fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
185 ->
decltype(this->base().fugacity(phaseIdx, compIdx))
188 return this->base().fugacity(phaseIdx, compIdx);
191 auto fugacityCoefficient(
unsigned phaseIdx,
unsigned compIdx)
const
192 ->
decltype(this->base().fugacityCoefficient(phaseIdx, compIdx))
195 return this->base().fugacityCoefficient(phaseIdx, compIdx);
198 auto enthalpy(
unsigned phaseIdx)
const
199 ->
decltype(this->base().enthalpy(phaseIdx))
202 return this->base().enthalpy(phaseIdx);
205 auto internalEnergy(
unsigned phaseIdx)
const
206 ->
decltype(this->base().internalEnergy(phaseIdx))
209 return this->base().internalEnergy(phaseIdx);
212 auto viscosity(
unsigned phaseIdx)
const
213 ->
decltype(this->base().viscosity(phaseIdx))
216 return this->base().viscosity(phaseIdx);
219 auto compressFactor(
unsigned phaseIdx)
const
220 ->
decltype(this->base().compressFactor(phaseIdx))
222 return this->base().compressFactor(phaseIdx);
226 bool allowSaturation_{
false};
227 bool allowTemperature_{
false};
228 bool allowPressure_{
false};
229 bool allowComposition_{
false};
230 bool allowDensity_{
false};
231 int restrictPhaseIdx_{};
290 std::cout <<
"Testing fluid system '"
291 << Opm::getDemangledType<FluidSystem>()
292 <<
", RhsEval = " << Opm::getDemangledType<RhsEval>()
293 <<
", LhsEval = " << Opm::getDemangledType<LhsEval>() <<
"'\n";
297 static constexpr int numPhases = FluidSystem::numPhases;
298 static constexpr int numComponents = FluidSystem::numComponents;
302 fs.allowTemperature(
true);
303 fs.allowPressure(
true);
304 fs.allowComposition(
true);
305 fs.restrictToPhase(-1);
308 fs.base().setTemperature(273.15 + 20.0);
309 for (
int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
310 fs.base().setPressure(phaseIdx, 1e5);
311 fs.base().setSaturation(phaseIdx, 1.0/numPhases);
312 for (
int compIdx = 0; compIdx < numComponents; ++ compIdx) {
313 fs.base().setMoleFraction(phaseIdx, compIdx, 1.0/numComponents);
317 static_assert(std::is_same<typename FluidSystem::Scalar, Scalar>::value,
318 "The type used for floating point used by the fluid system must be the same"
319 " as the one passed to the checkFluidSystem() function");
322 typedef typename FluidSystem::template ParameterCache<LhsEval> ParameterCache;
324 ParameterCache paramCache = initParamCache<ParameterCache, LhsEval, FluidSystem>();
325 try { paramCache.updateAll(fs); }
catch (...) {};
326 try { paramCache.updateAll(fs, ParameterCache::None); }
catch (...) {};
327 try { paramCache.updateAll(fs, ParameterCache::Temperature | ParameterCache::Pressure | ParameterCache::Composition); }
catch (...) {};
328 try { paramCache.updateAllPressures(fs); }
catch (...) {};
330 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
331 fs.restrictToPhase(
static_cast<int>(phaseIdx));
332 try { paramCache.updatePhase(fs, phaseIdx); }
catch (...) {};
333 try { paramCache.updatePhase(fs, phaseIdx, ParameterCache::None); }
catch (...) {};
334 try { paramCache.updatePhase(fs, phaseIdx, ParameterCache::Temperature | ParameterCache::Pressure | ParameterCache::Composition); }
catch (...) {};
335 try { paramCache.updateTemperature(fs, phaseIdx); }
catch (...) {};
336 try { paramCache.updatePressure(fs, phaseIdx); }
catch (...) {};
337 try { paramCache.updateComposition(fs, phaseIdx); }
catch (...) {};
338 try { paramCache.updateSingleMoleFraction(fs, phaseIdx, 0); }
catch (...) {};
344 Scalar scalarVal = 0.0;
346 scalarVal = 2*scalarVal;
350 try { FluidSystem::init(); }
catch (...) {};
351 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
352 fs.restrictToPhase(
static_cast<int>(phaseIdx));
353 fs.allowPressure(FluidSystem::isCompressible(phaseIdx));
354 fs.allowComposition(
true);
355 fs.allowDensity(
false);
356 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 (...) {};
357 try { val = FluidSystem::template density<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
358 try { scalarVal = FluidSystem::template density<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
360 fs.allowPressure(
true);
361 fs.allowDensity(
true);
362 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 (...) {};
363 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 (...) {};
364 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 (...) {};
365 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 (...) {};
366 try { val = FluidSystem::template viscosity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
367 try { val = FluidSystem::template enthalpy<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
368 try { val = FluidSystem::template heatCapacity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
369 try { val = FluidSystem::template thermalConductivity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
370 try { scalarVal = FluidSystem::template viscosity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
371 try { scalarVal = FluidSystem::template enthalpy<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
372 try { scalarVal = FluidSystem::template heatCapacity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
373 try { scalarVal = FluidSystem::template thermalConductivity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
375 for (
unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
376 fs.allowComposition(!FluidSystem::isIdealMixture(phaseIdx));
377 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 (...) {};
378 try { val = FluidSystem::template fugacityCoefficient<FluidState, LhsEval>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
379 try { scalarVal = FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
380 fs.allowComposition(
true);
381 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 (...) {};
382 try { val = FluidSystem::template diffusionCoefficient<FluidState, LhsEval>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
383 try { scalarVal = FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
388 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
389 [[maybe_unused]] std::string name{FluidSystem::phaseName(phaseIdx)};
390 std::ignore = FluidSystem::isLiquid(phaseIdx);
391 std::ignore = FluidSystem::isIdealGas(phaseIdx);
395 for (
unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
396 std::ignore = FluidSystem::molarMass(compIdx);
397 std::string{FluidSystem::componentName(compIdx)};