62 :
protected BaseFluidState
65 enum { numPhases = FluidSystem::numPhases };
66 enum { numComponents = FluidSystem::numComponents };
68 typedef ScalarT Scalar;
73 allowTemperature(
false);
75 allowComposition(
false);
79 restrictToPhase(1000);
82 void allowTemperature(
bool yesno)
83 { allowTemperature_ = yesno; }
85 void allowPressure(
bool yesno)
86 { allowPressure_ = yesno; }
88 void allowComposition(
bool yesno)
89 { allowComposition_ = yesno; }
91 void allowDensity(
bool yesno)
92 { allowDensity_ = yesno; }
94 void restrictToPhase(
int phaseIdx)
95 { restrictPhaseIdx_ = phaseIdx; }
97 BaseFluidState& base()
98 {
return *
static_cast<BaseFluidState*
>(
this); }
100 const BaseFluidState& base()
const
101 {
return *
static_cast<const BaseFluidState*
>(
this); }
103 auto temperature(
unsigned phaseIdx)
const
104 ->
decltype(this->base().temperature(phaseIdx))
106 assert(allowTemperature_);
107 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
108 return this->base().temperature(phaseIdx);
111 auto pressure(
unsigned phaseIdx)
const
112 ->
decltype(this->base().pressure(phaseIdx))
114 assert(allowPressure_);
115 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
116 return this->base().pressure(phaseIdx);
119 auto moleFraction(
unsigned phaseIdx,
unsigned compIdx)
const
120 ->
decltype(this->base().moleFraction(phaseIdx, compIdx))
122 assert(allowComposition_);
123 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
124 return this->base().moleFraction(phaseIdx, compIdx);
127 auto massFraction(
unsigned phaseIdx,
unsigned compIdx)
const
128 ->
decltype(this->base().massFraction(phaseIdx, compIdx))
130 assert(allowComposition_);
131 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
132 return this->base().massFraction(phaseIdx, compIdx);
135 auto averageMolarMass(
unsigned phaseIdx)
const
136 ->
decltype(this->base().averageMolarMass(phaseIdx))
138 assert(allowComposition_);
139 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
140 return this->base().averageMolarMass(phaseIdx);
143 auto molarity(
unsigned phaseIdx,
unsigned compIdx)
const
144 ->
decltype(this->base().molarity(phaseIdx, compIdx))
146 assert(allowDensity_ && allowComposition_);
147 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
148 return this->base().molarity(phaseIdx, compIdx);
151 auto molarDensity(
unsigned phaseIdx)
const
152 ->
decltype(this->base().molarDensity(phaseIdx))
154 assert(allowDensity_);
155 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
156 return this->base().molarDensity(phaseIdx);
159 auto molarVolume(
unsigned phaseIdx)
const
160 ->
decltype(this->base().molarVolume(phaseIdx))
162 assert(allowDensity_);
163 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
164 return this->base().molarVolume(phaseIdx);
167 auto density(
unsigned phaseIdx)
const
168 ->
decltype(this->base().density(phaseIdx))
170 assert(allowDensity_);
171 assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ ==
static_cast<int>(phaseIdx));
172 return this->base().density(phaseIdx);
175 auto saturation(
unsigned phaseIdx)
const
176 ->
decltype(this->base().saturation(phaseIdx))
179 return this->base().saturation(phaseIdx);
182 auto fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
183 ->
decltype(this->base().fugacity(phaseIdx, compIdx))
186 return this->base().fugacity(phaseIdx, compIdx);
189 auto fugacityCoefficient(
unsigned phaseIdx,
unsigned compIdx)
const
190 ->
decltype(this->base().fugacityCoefficient(phaseIdx, compIdx))
193 return this->base().fugacityCoefficient(phaseIdx, compIdx);
196 auto enthalpy(
unsigned phaseIdx)
const
197 ->
decltype(this->base().enthalpy(phaseIdx))
200 return this->base().enthalpy(phaseIdx);
203 auto internalEnergy(
unsigned phaseIdx)
const
204 ->
decltype(this->base().internalEnergy(phaseIdx))
207 return this->base().internalEnergy(phaseIdx);
210 auto viscosity(
unsigned phaseIdx)
const
211 ->
decltype(this->base().viscosity(phaseIdx))
214 return this->base().viscosity(phaseIdx);
217 auto compressFactor(
unsigned phaseIdx)
const
218 ->
decltype(this->base().compressFactor(phaseIdx))
220 return this->base().compressFactor(phaseIdx);
224 bool allowSaturation_{
false};
225 bool allowTemperature_{
false};
226 bool allowPressure_{
false};
227 bool allowComposition_{
false};
228 bool allowDensity_{
false};
229 int restrictPhaseIdx_{};
273 std::cout <<
"Testing fluid system '"
274 << Opm::getDemangledType<FluidSystem>()
275 <<
", RhsEval = " << Opm::getDemangledType<RhsEval>()
276 <<
", LhsEval = " << Opm::getDemangledType<LhsEval>() <<
"'\n";
280 enum { numPhases = FluidSystem::numPhases };
281 enum { numComponents = FluidSystem::numComponents };
285 fs.allowTemperature(
true);
286 fs.allowPressure(
true);
287 fs.allowComposition(
true);
288 fs.restrictToPhase(-1);
291 fs.base().setTemperature(273.15 + 20.0);
292 for (
int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
293 fs.base().setPressure(phaseIdx, 1e5);
294 fs.base().setSaturation(phaseIdx, 1.0/numPhases);
295 for (
int compIdx = 0; compIdx < numComponents; ++ compIdx) {
296 fs.base().setMoleFraction(phaseIdx, compIdx, 1.0/numComponents);
300 static_assert(std::is_same<typename FluidSystem::Scalar, Scalar>::value,
301 "The type used for floating point used by the fluid system must be the same"
302 " as the one passed to the checkFluidSystem() function");
305 typedef typename FluidSystem::template ParameterCache<LhsEval> ParameterCache;
307 ParameterCache paramCache;
308 try { paramCache.updateAll(fs); }
catch (...) {};
309 try { paramCache.updateAll(fs, ParameterCache::None); }
catch (...) {};
310 try { paramCache.updateAll(fs, ParameterCache::Temperature | ParameterCache::Pressure | ParameterCache::Composition); }
catch (...) {};
311 try { paramCache.updateAllPressures(fs); }
catch (...) {};
313 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
314 fs.restrictToPhase(
static_cast<int>(phaseIdx));
315 try { paramCache.updatePhase(fs, phaseIdx); }
catch (...) {};
316 try { paramCache.updatePhase(fs, phaseIdx, ParameterCache::None); }
catch (...) {};
317 try { paramCache.updatePhase(fs, phaseIdx, ParameterCache::Temperature | ParameterCache::Pressure | ParameterCache::Composition); }
catch (...) {};
318 try { paramCache.updateTemperature(fs, phaseIdx); }
catch (...) {};
319 try { paramCache.updatePressure(fs, phaseIdx); }
catch (...) {};
320 try { paramCache.updateComposition(fs, phaseIdx); }
catch (...) {};
321 try { paramCache.updateSingleMoleFraction(fs, phaseIdx, 0); }
catch (...) {};
327 Scalar scalarVal = 0.0;
329 scalarVal = 2*scalarVal;
333 try { FluidSystem::init(); }
catch (...) {};
334 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
335 fs.restrictToPhase(
static_cast<int>(phaseIdx));
336 fs.allowPressure(FluidSystem::isCompressible(phaseIdx));
337 fs.allowComposition(
true);
338 fs.allowDensity(
false);
339 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 (...) {};
340 try { val = FluidSystem::template density<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
341 try { scalarVal = FluidSystem::template density<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
343 fs.allowPressure(
true);
344 fs.allowDensity(
true);
345 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 (...) {};
346 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 (...) {};
347 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 (...) {};
348 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 (...) {};
349 try { val = FluidSystem::template viscosity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
350 try { val = FluidSystem::template enthalpy<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
351 try { val = FluidSystem::template heatCapacity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
352 try { val = FluidSystem::template thermalConductivity<FluidState, LhsEval>(fs, paramCache, phaseIdx); }
catch (...) {};
353 try { scalarVal = FluidSystem::template viscosity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
354 try { scalarVal = FluidSystem::template enthalpy<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
355 try { scalarVal = FluidSystem::template heatCapacity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
356 try { scalarVal = FluidSystem::template thermalConductivity<FluidState, Scalar>(fs, paramCache, phaseIdx); }
catch (...) {};
358 for (
unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
359 fs.allowComposition(!FluidSystem::isIdealMixture(phaseIdx));
360 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 (...) {};
361 try { val = FluidSystem::template fugacityCoefficient<FluidState, LhsEval>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
362 try { scalarVal = FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
363 fs.allowComposition(
true);
364 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 (...) {};
365 try { val = FluidSystem::template diffusionCoefficient<FluidState, LhsEval>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
366 try { scalarVal = FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fs, paramCache, phaseIdx, compIdx); }
catch (...) {};
371 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
372 [[maybe_unused]] std::string name{FluidSystem::phaseName(phaseIdx)};
373 std::ignore = FluidSystem::isLiquid(phaseIdx);
374 std::ignore = FluidSystem::isIdealGas(phaseIdx);
378 for (
unsigned compIdx = 0; compIdx < numComponents; ++ compIdx) {
379 std::ignore = FluidSystem::molarMass(compIdx);
380 std::string{FluidSystem::componentName(compIdx)};