Line | Branch | Exec | Source |
---|---|---|---|
1 | // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
2 | // vi: set et ts=4 sw=4 sts=4: | ||
3 | // | ||
4 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup MaterialTests | ||
10 | * \brief This file provides the actual code for the fluid systems test. | ||
11 | * | ||
12 | * It is not directly in test_fluidsystems.cc so that external modules | ||
13 | * like dumux-devel can use it easily. | ||
14 | */ | ||
15 | |||
16 | #ifndef DUMUX_CHECK_FLUIDSYSTEM_HH | ||
17 | #define DUMUX_CHECK_FLUIDSYSTEM_HH | ||
18 | |||
19 | #include <exception> | ||
20 | #include <string> | ||
21 | |||
22 | #include <dune/common/classname.hh> | ||
23 | |||
24 | // include all fluid systems in dumux-stable | ||
25 | #include <dumux/material/fluidsystems/2pimmiscible.hh> | ||
26 | #include <dumux/material/fluidsystems/base.hh> | ||
27 | #include <dumux/material/fluidsystems/brineair.hh> | ||
28 | #include <dumux/material/fluidsystems/brineco2.hh> | ||
29 | #include <dumux/material/fluidsystems/1pgas.hh> | ||
30 | #include <dumux/material/fluidsystems/h2oair.hh> | ||
31 | #include <dumux/material/fluidsystems/h2oairmesitylene.hh> | ||
32 | #include <dumux/material/fluidsystems/h2oairxylene.hh> | ||
33 | #include <dumux/material/fluidsystems/h2on2.hh> | ||
34 | #include <dumux/material/fluidsystems/h2on2kinetic.hh> | ||
35 | #include <dumux/material/fluidsystems/h2on2o2.hh> | ||
36 | #include <dumux/material/fluidsystems/1pliquid.hh> | ||
37 | #include <dumux/material/fluidsystems/spe5.hh> | ||
38 | |||
39 | // include all fluid states | ||
40 | #include <dumux/material/fluidstates/compositional.hh> | ||
41 | #include <dumux/material/fluidstates/immiscible.hh> | ||
42 | #include <dumux/material/fluidstates/isothermalimmiscible.hh> | ||
43 | #include <dumux/material/fluidstates/nonequilibrium.hh> | ||
44 | #include <dumux/material/fluidstates/nonequilibriummass.hh> | ||
45 | #include <dumux/material/fluidstates/pressureoverlay.hh> | ||
46 | #include <dumux/material/fluidstates/pseudo1p2c.hh> | ||
47 | #include <dumux/material/fluidstates/saturationoverlay.hh> | ||
48 | #include <dumux/material/fluidstates/temperatureoverlay.hh> | ||
49 | |||
50 | namespace Dumux { | ||
51 | |||
52 | /*! | ||
53 | * \brief This fluid state ensures that only the allowed quantities are accessed. | ||
54 | */ | ||
55 | template<class ScalarType, class FluidSystem, class BaseFluidState = CompositionalFluidState<ScalarType, FluidSystem> > | ||
56 | class HairSplittingFluidState: protected BaseFluidState | ||
57 | { | ||
58 | public: | ||
59 | //! Export the type used for scalars | ||
60 | using typename BaseFluidState::Scalar; | ||
61 | |||
62 | static constexpr int numPhases = FluidSystem::numPhases; | ||
63 | static constexpr int numComponents = FluidSystem::numComponents; | ||
64 | |||
65 | 78 | HairSplittingFluidState() | |
66 | 78 | { | |
67 | // set some fake values | ||
68 | 78 | BaseFluidState::setTemperature(293.15); | |
69 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 39 times.
|
228 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) |
70 | { | ||
71 | 150 | BaseFluidState::setSaturation(phaseIdx, 1.0 / numPhases); | |
72 | 150 | BaseFluidState::setPressure(phaseIdx, 1e5); | |
73 | 150 | BaseFluidState::setDensity(phaseIdx, 1.0); | |
74 | 150 | BaseFluidState::setMolarDensity(phaseIdx, 1.0); | |
75 | |||
76 |
2/2✓ Branch 0 taken 180 times.
✓ Branch 1 taken 80 times.
|
520 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
77 | 500 | BaseFluidState::setMoleFraction(phaseIdx, compIdx, 1.0 / numComponents); | |
78 | } | ||
79 | |||
80 | // initially, do not allow anything | ||
81 | 156 | allowTemperature(false); | |
82 | 156 | allowPressure(false); | |
83 | 156 | allowComposition(false); | |
84 | 156 | allowDensity(false); | |
85 | |||
86 | // do not allow accessing any phase | ||
87 | 156 | restrictToPhase(1000); | |
88 | 78 | } | |
89 | |||
90 | void allowTemperature(bool yesno) | ||
91 | { | ||
92 | 78 | allowTemperature_ = yesno; | |
93 | } | ||
94 | |||
95 | void allowPressure(bool yesno) | ||
96 | { | ||
97 | 225 | allowPressure_ = yesno; | |
98 | } | ||
99 | |||
100 | void allowComposition(bool yesno) | ||
101 | { | ||
102 | 523 | allowComposition_ = yesno; | |
103 | } | ||
104 | |||
105 | void allowDensity(bool yesno) | ||
106 | { | ||
107 | 189 | allowDensity_ = yesno; | |
108 | } | ||
109 | |||
110 | ✗ | void restrictToPhase(int phaseIdx) | |
111 | { | ||
112 | 196 | restrictPhaseIdx_ = phaseIdx; | |
113 | ✗ | } | |
114 | |||
115 | 1976 | Scalar temperature(int phaseIdx) const | |
116 | { | ||
117 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 988 times.
|
1976 | assert(allowTemperature_); |
118 |
3/4✓ Branch 0 taken 692 times.
✓ Branch 1 taken 296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
|
1976 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
119 | 3952 | return BaseFluidState::temperature(phaseIdx); | |
120 | } | ||
121 | |||
122 | Scalar wettingPhase() const | ||
123 | { | ||
124 | assert(allowComposition_); | ||
125 | return BaseFluidState::wettingPhase(); | ||
126 | } | ||
127 | |||
128 | 124 | Scalar partialPressure(int phaseIdx, int compIdx) const | |
129 | { | ||
130 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
|
124 | assert(allowComposition_); |
131 |
3/4✓ Branch 0 taken 38 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
|
124 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
132 | 124 | return BaseFluidState::partialPressure(phaseIdx, compIdx); | |
133 | } | ||
134 | |||
135 | 1894 | Scalar pressure(int phaseIdx) const | |
136 | { | ||
137 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 929 times.
|
1894 | if (!allowPressure_) |
138 | { | ||
139 | 72 | std::cout << "HairSplittingFluidState: pressure called but not allowed" << std::endl; | |
140 | } | ||
141 |
3/4✓ Branch 0 taken 679 times.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 679 times.
|
1894 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
142 | 3788 | return BaseFluidState::pressure(phaseIdx); | |
143 | } | ||
144 | |||
145 | 3592 | Scalar moleFraction(int phaseIdx, int compIdx) const | |
146 | { | ||
147 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1796 times.
|
3592 | assert(allowComposition_); |
148 |
3/4✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 560 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1236 times.
|
3592 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
149 | 7184 | return BaseFluidState::moleFraction(phaseIdx, compIdx); | |
150 | } | ||
151 | |||
152 | 468 | Scalar massFraction(int phaseIdx, int compIdx) const | |
153 | { | ||
154 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
|
468 | assert(allowComposition_); |
155 |
3/4✓ Branch 0 taken 126 times.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
|
468 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
156 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
468 | return BaseFluidState::massFraction(phaseIdx, compIdx); |
157 | } | ||
158 | |||
159 | 58 | Scalar averageMolarMass(int phaseIdx) const | |
160 | { | ||
161 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
|
58 | assert(allowComposition_); |
162 |
3/4✓ Branch 0 taken 17 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
|
58 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
163 | 116 | return BaseFluidState::averageMolarMass(phaseIdx); | |
164 | } | ||
165 | |||
166 | Scalar molarity(int phaseIdx, int compIdx) const | ||
167 | { | ||
168 | assert(allowDensity_ && allowComposition_); | ||
169 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); | ||
170 | return BaseFluidState::molarity(phaseIdx, compIdx); | ||
171 | } | ||
172 | |||
173 | Scalar molarDensity(int phaseIdx) const | ||
174 | { | ||
175 | assert(allowDensity_); | ||
176 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); | ||
177 | return BaseFluidState::molarDensity(phaseIdx); | ||
178 | } | ||
179 | |||
180 | Scalar molarVolume(int phaseIdx) const | ||
181 | { | ||
182 | assert(allowDensity_); | ||
183 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); | ||
184 | return BaseFluidState::molarVolume(phaseIdx); | ||
185 | } | ||
186 | |||
187 | Scalar density(int phaseIdx) const | ||
188 | { | ||
189 | assert(allowDensity_); | ||
190 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); | ||
191 | return BaseFluidState::density(phaseIdx); | ||
192 | } | ||
193 | |||
194 | Scalar saturation(int phaseIdx) const | ||
195 | { | ||
196 | assert(false); | ||
197 | return BaseFluidState::saturation(phaseIdx); | ||
198 | } | ||
199 | |||
200 | Scalar fugacity(int phaseIdx, int compIdx) const | ||
201 | { | ||
202 | assert(false); | ||
203 | return BaseFluidState::fugacity(phaseIdx, compIdx); | ||
204 | } | ||
205 | |||
206 | Scalar fugacityCoefficient(int phaseIdx, int compIdx) const | ||
207 | { | ||
208 | assert(false); | ||
209 | return BaseFluidState::fugacityCoefficient(phaseIdx, compIdx); | ||
210 | } | ||
211 | |||
212 | Scalar enthalpy(int phaseIdx) const | ||
213 | { | ||
214 | assert(false); | ||
215 | return BaseFluidState::enthalpy(phaseIdx); | ||
216 | } | ||
217 | |||
218 | Scalar internalEnergy(int phaseIdx) const | ||
219 | { | ||
220 | assert(false); | ||
221 | return BaseFluidState::internalEnergy(phaseIdx); | ||
222 | } | ||
223 | |||
224 | Scalar viscosity(int phaseIdx) const | ||
225 | { | ||
226 | assert(false); | ||
227 | return BaseFluidState::viscosity(phaseIdx); | ||
228 | } | ||
229 | |||
230 | private: | ||
231 | bool allowSaturation_; | ||
232 | bool allowTemperature_; | ||
233 | bool allowPressure_; | ||
234 | bool allowComposition_; | ||
235 | bool allowDensity_; | ||
236 | int restrictPhaseIdx_; | ||
237 | }; | ||
238 | |||
239 | template<class Scalar, class BaseFluidState> | ||
240 | 16 | int checkFluidState(const BaseFluidState &fs) | |
241 | { | ||
242 |
3/8✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
32 | std::cout << "Testing fluid state '" << Dune::className<BaseFluidState>() << "'\n"; |
243 | |||
244 | // fluid states must be copy-able | ||
245 | BaseFluidState tmpFs(fs); | ||
246 | 16 | tmpFs = fs; | |
247 | |||
248 | // output strings | ||
249 |
1/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
32 | std::string collectedErrors; |
250 |
4/8✓ Branch 1 taken 3 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
34 | std::string collectedWarnings; |
251 | |||
252 | // make sure the fluid state provides all mandatory methods | ||
253 | [[maybe_unused]] Scalar val; | ||
254 | |||
255 | try | ||
256 | { | ||
257 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
16 | val = fs.temperature(/*phaseIdx=*/0); |
258 | } catch (...) | ||
259 | { | ||
260 | collectedErrors += "error: fluidState.temperature() throws exception!\n"; | ||
261 | } | ||
262 | try | ||
263 | { | ||
264 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
16 | val = fs.pressure(/*phaseIdx=*/0); |
265 | } catch (...) | ||
266 | { | ||
267 | collectedErrors += "error: fluidState.pressure() throws exception!\n"; | ||
268 | } | ||
269 | try | ||
270 | { | ||
271 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
16 | val = fs.moleFraction(/*phaseIdx=*/0, /*compIdx=*/0); |
272 | } catch (...) | ||
273 | { | ||
274 | collectedErrors += "error: fluidState.moleFraction() throws exception!\n"; | ||
275 | } | ||
276 | try | ||
277 | { | ||
278 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
16 | val = fs.massFraction(/*phaseIdx=*/0, /*compIdx=*/0); |
279 | } catch (...) | ||
280 | { | ||
281 | collectedErrors += "error: fluidState.massFraction() throws exception!\n"; | ||
282 | } | ||
283 | try | ||
284 | { | ||
285 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.averageMolarMass(/*phaseIdx=*/0); |
286 | } catch (...) | ||
287 | { | ||
288 | collectedErrors += "error: fluidState.averageMolarMass() throws exception!\n"; | ||
289 | } | ||
290 | try | ||
291 | { | ||
292 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.molarity(/*phaseIdx=*/0, /*compIdx=*/0); |
293 | } catch (...) | ||
294 | { | ||
295 | collectedErrors += "error: fluidState.molarity() throws exception!\n"; | ||
296 | } | ||
297 | try | ||
298 | { | ||
299 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
16 | val = fs.molarDensity(/*phaseIdx=*/0); |
300 | } catch (...) | ||
301 | { | ||
302 | collectedErrors += "error: fluidState.molarDensity() throws exception!\n"; | ||
303 | } | ||
304 | try | ||
305 | { | ||
306 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.molarVolume(/*phaseIdx=*/0); |
307 | } catch (...) | ||
308 | { | ||
309 | collectedErrors += "error: fluidState.molarVolume() throws exception!\n"; | ||
310 | } | ||
311 | try | ||
312 | { | ||
313 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.density(/*phaseIdx=*/0); |
314 | } catch (...) | ||
315 | { | ||
316 | collectedErrors += "error: fluidState.density() throws exception!\n"; | ||
317 | } | ||
318 | try | ||
319 | { | ||
320 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.saturation(/*phaseIdx=*/0); |
321 | } catch (...) | ||
322 | { | ||
323 | collectedErrors += "error: fluidState.saturation() throws exception!\n"; | ||
324 | } | ||
325 | try | ||
326 | { | ||
327 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.fugacity(/*phaseIdx=*/0, /*compIdx=*/0); |
328 | } catch (...) | ||
329 | { | ||
330 | collectedErrors += "error: fluidState.fugacity() throws exception!\n"; | ||
331 | } | ||
332 | try | ||
333 | { | ||
334 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
16 | val = fs.fugacityCoefficient(/*phaseIdx=*/0, /*compIdx=*/0); |
335 | } catch (...) | ||
336 | { | ||
337 | collectedErrors += "error: fluidState.fugacityCoefficient() throws exception!\n"; | ||
338 | } | ||
339 | try | ||
340 | { | ||
341 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.enthalpy(/*phaseIdx=*/0); |
342 | 2 | } catch (Dune::NotImplemented&) | |
343 | { | ||
344 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | collectedWarnings += "warning: fluidState.enthalpy() is not implemented\n"; |
345 | ✗ | } catch (...) | |
346 | { | ||
347 | ✗ | collectedErrors += "error: fluidState.enthalpy() throws exception!\n"; | |
348 | } | ||
349 | try | ||
350 | { | ||
351 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
16 | val = fs.internalEnergy(/*phaseIdx=*/0); |
352 | 2 | } catch (Dune::NotImplemented&) | |
353 | { | ||
354 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | collectedWarnings += "warning: fluidState.internalEnergy() is not implemented\n"; |
355 | ✗ | } catch (...) | |
356 | { | ||
357 | ✗ | collectedErrors += "error: fluidState.internalEnergy() throws exception!\n"; | |
358 | } | ||
359 | try | ||
360 | { | ||
361 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | val = fs.viscosity(/*phaseIdx=*/0); |
362 | } catch (...) | ||
363 | { | ||
364 | collectedErrors += "error: fluidState.viscosity() throws exception!\n"; | ||
365 | } | ||
366 | |||
367 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | std::cout << collectedErrors; |
368 | // std::cout << collectedWarnings; | ||
369 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
32 | if (collectedErrors.empty()) // success |
370 | { | ||
371 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
32 | std::cout << "... successful" << std::endl; |
372 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
32 | std::cout << "----------------------------------" << std::endl; |
373 | return 0; | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | ✗ | std::cout << "... failed" << std::endl; | |
378 | ✗ | std::cout << "----------------------------------" << std::endl; | |
379 | return 1; | ||
380 | } | ||
381 | } | ||
382 | |||
383 | /*! | ||
384 | * \brief This is a consistency check for FluidSystems. | ||
385 | * | ||
386 | * \param enablePhaseRestriction Parameter passed to the fluidState. If set to true, | ||
387 | * the fluidState will only allow calls to properties of the current phase. | ||
388 | * \note While this is very common, it is not necessarily the case for all FluidSystems. | ||
389 | * We keep this, because it might help finding mistakes in FluidSystems that have this invariant. | ||
390 | * If you verified that a fluid system does not have this invariant you can set this option to false. | ||
391 | */ | ||
392 | template<class Scalar, class FluidSystem> | ||
393 | 39 | int checkFluidSystem(bool enablePhaseRestriction = true) | |
394 | { | ||
395 | 39 | int success = 0; | |
396 | 78 | std::cout << "Testing fluid system '" << Dune::className<FluidSystem>() << "'\n"; | |
397 | 38 | FluidSystem::init(); | |
398 | |||
399 | // output strings | ||
400 | 78 | std::string collectedErrors; | |
401 | 117 | std::string collectedWarnings; | |
402 | |||
403 | // make sure the fluid system provides the number of phases and | ||
404 | // the number of components | ||
405 | enum | ||
406 | { | ||
407 | numPhases = FluidSystem::numPhases | ||
408 | }; | ||
409 | enum | ||
410 | { | ||
411 | numComponents = FluidSystem::numComponents | ||
412 | }; | ||
413 | |||
414 | 39 | HairSplittingFluidState<Scalar, FluidSystem> fs; | |
415 | 78 | fs.allowTemperature(true); | |
416 | 78 | fs.allowPressure(true); | |
417 | 78 | fs.allowComposition(true); | |
418 | 78 | fs.restrictToPhase(-1); | |
419 | |||
420 | // check whether the parameter cache adheres to the API | ||
421 | using PC = typename FluidSystem::ParameterCache; | ||
422 | 1 | PC paramCache; | |
423 | try | ||
424 | { | ||
425 | 38 | paramCache.updateAll(fs); | |
426 | ✗ | } catch (...) | |
427 | { | ||
428 | ✗ | collectedErrors += "error: paramCache.updateAll() throws exception!\n"; | |
429 | } | ||
430 | try | ||
431 | { | ||
432 | 38 | paramCache.updateAll(fs, /*except=*/PC::None); | |
433 | ✗ | } catch (...) | |
434 | { | ||
435 | ✗ | collectedErrors += "error: paramCache.updateAll(none) throws exception!\n"; | |
436 | } | ||
437 | try | ||
438 | { | ||
439 | 38 | paramCache.updateAll(fs, /*except=*/PC::Temperature | PC::Pressure | PC::Composition); | |
440 | ✗ | } catch (...) | |
441 | { | ||
442 | ✗ | collectedErrors += "error: paramCache.updateAll(T, p, x) throws exception!\n"; | |
443 | } | ||
444 | try | ||
445 | { | ||
446 | 38 | paramCache.updateAllPressures(fs); | |
447 | ✗ | } catch (...) | |
448 | { | ||
449 | ✗ | collectedErrors += "error: paramCache.updateAllPressures() throws exception!\n"; | |
450 | } | ||
451 | |||
452 | 122 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) | |
453 | { | ||
454 | 75 | if (enablePhaseRestriction) | |
455 | 59 | fs.restrictToPhase(phaseIdx); | |
456 | try | ||
457 | { | ||
458 | 67 | paramCache.updatePhase(fs, phaseIdx); | |
459 | ✗ | } catch (...) | |
460 | { | ||
461 | ✗ | collectedErrors += "error: paramCache.updatePhase() throws exception!\n"; | |
462 | } | ||
463 | try | ||
464 | { | ||
465 | 67 | paramCache.updatePhase(fs, phaseIdx, /*except=*/PC::None); | |
466 | ✗ | } catch (...) | |
467 | { | ||
468 | ✗ | collectedErrors += "error: paramCache.updatePhase(none) throws exception!\n"; | |
469 | } | ||
470 | try | ||
471 | { | ||
472 | 67 | paramCache.updatePhase(fs, phaseIdx, /*except=*/PC::Temperature | PC::Pressure | PC::Composition); | |
473 | ✗ | } catch (...) | |
474 | { | ||
475 | ✗ | collectedErrors += "error: paramCache.updatePhase(T, p , x) throws exception!\n"; | |
476 | } | ||
477 | try | ||
478 | { | ||
479 | 67 | paramCache.updateTemperature(fs, phaseIdx); | |
480 | ✗ | } catch (...) | |
481 | { | ||
482 | ✗ | collectedErrors += "error: paramCache.updateTemperature() throws exception!\n"; | |
483 | } | ||
484 | try | ||
485 | { | ||
486 | 67 | paramCache.updatePressure(fs, phaseIdx); | |
487 | ✗ | } catch (...) | |
488 | { | ||
489 | ✗ | collectedErrors += "error: paramCache.updatePressure() throws exception!\n"; | |
490 | } | ||
491 | try | ||
492 | { | ||
493 | 67 | paramCache.updateComposition(fs, phaseIdx); | |
494 | ✗ | } catch (...) | |
495 | { | ||
496 | ✗ | collectedErrors += "error: paramCache.updateComposition() throws exception!\n"; | |
497 | } | ||
498 | try | ||
499 | { | ||
500 | 67 | paramCache.updateSingleMoleFraction(fs, phaseIdx, /*compIdx=*/0); | |
501 | ✗ | } catch (...) | |
502 | { | ||
503 | ✗ | collectedErrors += "error: paramCache.updateSingleMoleFraction() throws exception!\n"; | |
504 | } | ||
505 | } | ||
506 | |||
507 | // some value to make sure the return values of the fluid system | ||
508 | // are convertible to scalars | ||
509 | [[maybe_unused]] Scalar val; | ||
510 | |||
511 | // actually check the fluid system API | ||
512 | 114 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) | |
513 | { | ||
514 | 134 | fs.allowPressure(FluidSystem::isCompressible(phaseIdx)); | |
515 | 150 | fs.allowComposition(true); | |
516 | 150 | fs.allowDensity(false); | |
517 | 75 | if (enablePhaseRestriction) | |
518 | 59 | fs.restrictToPhase(phaseIdx); | |
519 | try | ||
520 | { | ||
521 | 75 | val = FluidSystem::density(fs, paramCache, phaseIdx); | |
522 | ✗ | } catch (const std::exception& e) | |
523 | { | ||
524 | ✗ | collectedErrors += "error: FluidSystem::density() throws exception: " + std::string(e.what()) + "\n"; | |
525 | } | ||
526 | try | ||
527 | { | ||
528 | 75 | val = FluidSystem::molarDensity(fs, paramCache, phaseIdx); | |
529 | ✗ | } catch (const std::exception& e) | |
530 | { | ||
531 | ✗ | collectedErrors += "error: FluidSystem::molarDensity() throws exception: " + std::string(e.what()) + "\n"; | |
532 | } | ||
533 | 147 | fs.allowPressure(true); | |
534 | 150 | fs.allowDensity(true); | |
535 | try | ||
536 | { | ||
537 | 75 | val = FluidSystem::viscosity(fs, paramCache, phaseIdx); | |
538 | ✗ | } catch (const std::exception& e) | |
539 | { | ||
540 | ✗ | collectedErrors += "error: FluidSystem::viscosity() throws exception: " + std::string(e.what()) + "\n"; | |
541 | } | ||
542 | try | ||
543 | { | ||
544 | 75 | val = FluidSystem::enthalpy(fs, paramCache, phaseIdx); | |
545 | 3 | } catch (Dune::NotImplemented&) | |
546 | { | ||
547 | 3 | collectedWarnings += "warning: FluidSystem::enthalpy() is not implemented\n"; | |
548 | ✗ | } catch (const std::exception& e) | |
549 | { | ||
550 | ✗ | collectedErrors += "error: FluidSystem::enthalpy() throws exception: " + std::string(e.what()) + "\n"; | |
551 | } | ||
552 | try | ||
553 | { | ||
554 | 75 | val = FluidSystem::heatCapacity(fs, paramCache, phaseIdx); | |
555 | 12 | } catch (Dune::NotImplemented&) | |
556 | { | ||
557 | 12 | collectedWarnings += "warning: FluidSystem::heatCapacity() is not implemented\n"; | |
558 | ✗ | } catch (const std::exception& e) | |
559 | { | ||
560 | ✗ | collectedErrors += "error: FluidSystem::heatCapacity() throws exception: " + std::string(e.what()) + "\n"; | |
561 | } | ||
562 | try | ||
563 | { | ||
564 | 75 | val = FluidSystem::thermalConductivity(fs, paramCache, phaseIdx); | |
565 | 3 | } catch (Dune::NotImplemented&) | |
566 | { | ||
567 | 3 | collectedWarnings += "warning: FluidSystem::thermalConductivity() is not implemented\n"; | |
568 | ✗ | } catch (const std::exception& e) | |
569 | { | ||
570 | ✗ | collectedErrors += "error: FluidSystem::thermalConductivity() throws exception: " + std::string(e.what()) + "\n"; | |
571 | } | ||
572 | |||
573 | 260 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) | |
574 | { | ||
575 | 325 | fs.allowComposition(!FluidSystem::isIdealMixture(phaseIdx)); | |
576 | try | ||
577 | { | ||
578 | 185 | val = FluidSystem::fugacityCoefficient(fs, paramCache, phaseIdx, compIdx); | |
579 | 6 | } catch (Dune::NotImplemented&) | |
580 | { | ||
581 | 6 | collectedWarnings += "warning: FluidSystem::fugacityCoefficient() is not implemented\n"; | |
582 | ✗ | } catch (const std::exception& e) | |
583 | { | ||
584 | ✗ | collectedErrors += "error: FluidSystem::fugacityCoefficient() throws exception: " + std::string(e.what()) + "\n"; | |
585 | } | ||
586 | 370 | fs.allowComposition(true); | |
587 | try | ||
588 | { | ||
589 | 185 | val = FluidSystem::diffusionCoefficient(fs, paramCache, phaseIdx, compIdx); | |
590 | 140 | } catch (Dune::NotImplemented&) | |
591 | { | ||
592 | 140 | collectedWarnings += "warning: FluidSystem::diffusionCoefficient() is not implemented\n"; | |
593 | 31 | } catch (Dune::InvalidStateException&) | |
594 | { | ||
595 | 31 | collectedWarnings += "warning: FluidSystem::diffusionCoefficient() gives invalid state exception\n"; | |
596 | ✗ | } catch (const std::exception& e) | |
597 | { | ||
598 | ✗ | collectedErrors += "error: FluidSystem::diffusionCoefficient() throws exception: " + std::string(e.what()) + "\n"; | |
599 | } | ||
600 | 732 | for (int comp2Idx = 0; comp2Idx < numComponents; ++comp2Idx) | |
601 | { | ||
602 | try | ||
603 | { | ||
604 | 547 | val = FluidSystem::binaryDiffusionCoefficient(fs, paramCache, phaseIdx, compIdx, comp2Idx); | |
605 | 280 | } catch (Dune::NotImplemented&) | |
606 | { | ||
607 | 280 | collectedWarnings += "warning: FluidSystem::binaryDiffusionCoefficient() is not implemented\n"; | |
608 | 120 | } catch (Dune::InvalidStateException&) | |
609 | { | ||
610 | 120 | collectedWarnings += "warning: FluidSystem::binaryDiffusionCoefficient() gives invalid state exception\n"; | |
611 | ✗ | } catch (const std::exception& e) | |
612 | { | ||
613 | ✗ | collectedErrors += "error: FluidSystem::binaryDiffusionCoefficient() throws exception: " + std::string(e.what()) + "\n"; | |
614 | } | ||
615 | } | ||
616 | } | ||
617 | } | ||
618 | |||
619 | // test for phaseName(), isGas() and isIdealGas() | ||
620 | 114 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) | |
621 | { | ||
622 | 150 | [[maybe_unused]] std::string name = FluidSystem::phaseName(phaseIdx); | |
623 | 75 | [[maybe_unused]] bool bVal = FluidSystem::isGas(phaseIdx); | |
624 | 76 | bVal = FluidSystem::isIdealGas(phaseIdx); | |
625 | } | ||
626 | |||
627 | // test for componentName() | ||
628 | 129 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) | |
629 | { | ||
630 | 90 | val = FluidSystem::molarMass(compIdx); | |
631 | 93 | [[maybe_unused]] std::string name = FluidSystem::componentName(compIdx); | |
632 | } | ||
633 | |||
634 | 39 | std::cout << collectedErrors; | |
635 | // std::cout << collectedWarnings; | ||
636 | 78 | if (collectedErrors.empty()) // success | |
637 | { | ||
638 | 78 | std::cout << "... successful" << std::endl; | |
639 | 78 | std::cout << "----------------------------------" << std::endl; | |
640 | return 0; | ||
641 | } | ||
642 | else | ||
643 | { | ||
644 | ✗ | std::cout << "... failed" << std::endl; | |
645 | ✗ | std::cout << "----------------------------------" << std::endl; | |
646 | return 1; | ||
647 | } | ||
648 | std::cout << "----------------------------------\n"; | ||
649 | return success; | ||
650 | } | ||
651 | |||
652 | } // end namespace Dumux | ||
653 | |||
654 | #endif | ||
655 |