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-FileCopyrightText: 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 185 times.
✓ Branch 1 taken 75 times.
|
520 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
77 | 370 | BaseFluidState::setMoleFraction(phaseIdx, compIdx, 1.0 / numComponents); | |
78 | } | ||
79 | |||
80 | // initially, do not allow anything | ||
81 | 78 | allowTemperature(false); | |
82 | 78 | allowPressure(false); | |
83 | 78 | allowComposition(false); | |
84 | 78 | allowDensity(false); | |
85 | |||
86 | // do not allow accessing any phase | ||
87 | 78 | restrictToPhase(1000); | |
88 | 78 | } | |
89 | |||
90 | 78 | void allowTemperature(bool yesno) | |
91 | { | ||
92 | 78 | allowTemperature_ = yesno; | |
93 | } | ||
94 | |||
95 | 180 | void allowPressure(bool yesno) | |
96 | { | ||
97 | 180 | allowPressure_ = yesno; | |
98 | } | ||
99 | |||
100 | 523 | void allowComposition(bool yesno) | |
101 | { | ||
102 | 523 | allowComposition_ = yesno; | |
103 | } | ||
104 | |||
105 | 189 | void allowDensity(bool yesno) | |
106 | { | ||
107 | 189 | allowDensity_ = yesno; | |
108 | } | ||
109 | |||
110 | 196 | void restrictToPhase(int phaseIdx) | |
111 | { | ||
112 | 196 | restrictPhaseIdx_ = phaseIdx; | |
113 | 118 | } | |
114 | |||
115 | 1972 | Scalar temperature(int phaseIdx) const | |
116 | { | ||
117 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 986 times.
|
1972 | assert(allowTemperature_); |
118 |
3/4✓ Branch 0 taken 690 times.
✓ Branch 1 taken 296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 690 times.
|
1972 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
119 | 1972 | 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 | 36 | 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 | 1894 | return BaseFluidState::pressure(phaseIdx); | |
143 | } | ||
144 | |||
145 | 3554 | Scalar moleFraction(int phaseIdx, int compIdx) const | |
146 | { | ||
147 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1777 times.
|
3554 | assert(allowComposition_); |
148 |
3/4✓ Branch 0 taken 1229 times.
✓ Branch 1 taken 548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1229 times.
|
3554 | assert(restrictPhaseIdx_ < 0 || restrictPhaseIdx_ == phaseIdx); |
149 | 3554 | 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 | 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 | 58 | 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 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 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 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
16 | tmpFs = fs; |
247 | |||
248 | // output strings | ||
249 | 16 | std::string collectedErrors; | |
250 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
16 | 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 1 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.
|
12 | val = fs.moleFraction(/*phaseIdx=*/0, /*compIdx=*/0); |
272 | } catch (...) | ||
273 | { | ||
274 | collectedErrors += "error: fluidState.moleFraction() throws exception!\n"; | ||
275 | } | ||
276 | try | ||
277 | { | ||
278 |
2/3✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 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 4 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 6 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 4 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 6 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/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | } catch (Dune::NotImplemented&) |
343 | { | ||
344 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 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/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | } catch (Dune::NotImplemented&) |
353 | { | ||
354 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 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 0 taken 8 times.
✗ Branch 1 not taken.
|
16 | std::cout << collectedErrors; |
368 | // std::cout << collectedWarnings; | ||
369 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
16 | if (collectedErrors.empty()) // success |
370 | { | ||
371 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
16 | std::cout << "... successful" << std::endl; |
372 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | std::cout << "----------------------------------" << std::endl; |
373 | return 0; | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | ✗ | std::cout << "... failed" << std::endl; | |
378 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
16 | std::cout << "----------------------------------" << std::endl; |
379 | return 1; | ||
380 | } | ||
381 | 16 | } | |
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 | 78 | int checkFluidSystem(bool enablePhaseRestriction = true) | |
394 | { | ||
395 | 78 | int success = 0; | |
396 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
210 | std::cout << "Testing fluid system '" << Dune::className<FluidSystem>() << "'\n"; |
397 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
24 | FluidSystem::init(); |
398 | |||
399 | // output strings | ||
400 | 78 | std::string collectedErrors; | |
401 | 78 | 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 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
78 | 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 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
8 | PC paramCache; |
423 | try | ||
424 | { | ||
425 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
8 | paramCache.updateAll(fs); |
426 | ✗ | } catch (...) | |
427 | { | ||
428 | ✗ | collectedErrors += "error: paramCache.updateAll() throws exception!\n"; | |
429 | } | ||
430 | try | ||
431 | { | ||
432 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
8 | paramCache.updateAll(fs, /*except=*/PC::None); |
433 | ✗ | } catch (...) | |
434 | { | ||
435 | ✗ | collectedErrors += "error: paramCache.updateAll(none) throws exception!\n"; | |
436 | } | ||
437 | try | ||
438 | { | ||
439 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
8 | 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 | 8 | paramCache.updateAllPressures(fs); | |
447 | ✗ | } catch (...) | |
448 | { | ||
449 | ✗ | collectedErrors += "error: paramCache.updateAllPressures() throws exception!\n"; | |
450 | } | ||
451 | |||
452 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 39 times.
|
244 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) |
453 | { | ||
454 |
2/2✓ Branch 0 taken 59 times.
✓ Branch 1 taken 16 times.
|
150 | if (enablePhaseRestriction) |
455 | 118 | fs.restrictToPhase(phaseIdx); | |
456 | try | ||
457 | { | ||
458 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
134 | paramCache.updatePhase(fs, phaseIdx); |
459 | ✗ | } catch (...) | |
460 | { | ||
461 | ✗ | collectedErrors += "error: paramCache.updatePhase() throws exception!\n"; | |
462 | } | ||
463 | try | ||
464 | { | ||
465 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
134 | paramCache.updatePhase(fs, phaseIdx, /*except=*/PC::None); |
466 | ✗ | } catch (...) | |
467 | { | ||
468 | ✗ | collectedErrors += "error: paramCache.updatePhase(none) throws exception!\n"; | |
469 | } | ||
470 | try | ||
471 | { | ||
472 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | 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 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | paramCache.updateTemperature(fs, phaseIdx); |
480 | ✗ | } catch (...) | |
481 | { | ||
482 | ✗ | collectedErrors += "error: paramCache.updateTemperature() throws exception!\n"; | |
483 | } | ||
484 | try | ||
485 | { | ||
486 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | paramCache.updatePressure(fs, phaseIdx); |
487 | ✗ | } catch (...) | |
488 | { | ||
489 | ✗ | collectedErrors += "error: paramCache.updatePressure() throws exception!\n"; | |
490 | } | ||
491 | try | ||
492 | { | ||
493 | 6 | paramCache.updateComposition(fs, phaseIdx); | |
494 | ✗ | } catch (...) | |
495 | { | ||
496 | ✗ | collectedErrors += "error: paramCache.updateComposition() throws exception!\n"; | |
497 | } | ||
498 | try | ||
499 | { | ||
500 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | 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 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 39 times.
|
228 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) |
513 | { | ||
514 | 150 | fs.allowPressure(FluidSystem::isCompressible(phaseIdx)); | |
515 | 150 | fs.allowComposition(true); | |
516 | 150 | fs.allowDensity(false); | |
517 |
2/2✓ Branch 0 taken 59 times.
✓ Branch 1 taken 16 times.
|
150 | if (enablePhaseRestriction) |
518 | 118 | fs.restrictToPhase(phaseIdx); | |
519 | try | ||
520 | { | ||
521 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 2 taken 3 times.
|
150 | 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 | 150 | 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 | 150 | fs.allowPressure(true); | |
534 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
150 | fs.allowDensity(true); |
535 | try | ||
536 | { | ||
537 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
150 | 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 |
1/2✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
|
150 | val = FluidSystem::enthalpy(fs, paramCache, phaseIdx); |
545 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
|
6 | } catch (Dune::NotImplemented&) |
546 | { | ||
547 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | 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 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 2 taken 42 times.
|
132 | val = FluidSystem::heatCapacity(fs, paramCache, phaseIdx); |
555 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
|
24 | } catch (Dune::NotImplemented&) |
556 | { | ||
557 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
24 | 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 | 478 | val = FluidSystem::thermalConductivity(fs, paramCache, phaseIdx); | |
565 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
|
6 | } catch (Dune::NotImplemented&) |
566 | { | ||
567 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | 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 |
2/2✓ Branch 0 taken 185 times.
✓ Branch 1 taken 75 times.
|
520 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
574 | { | ||
575 |
1/2✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
|
370 | fs.allowComposition(!FluidSystem::isIdealMixture(phaseIdx)); |
576 | try | ||
577 | { | ||
578 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
358 | val = FluidSystem::fugacityCoefficient(fs, paramCache, phaseIdx, compIdx); |
579 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
|
12 | } catch (Dune::NotImplemented&) |
580 | { | ||
581 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
12 | 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 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 14 times.
|
370 | fs.allowComposition(true); |
587 | try | ||
588 | { | ||
589 | 186 | val = FluidSystem::diffusionCoefficient(fs, paramCache, phaseIdx, compIdx); | |
590 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
|
342 | } catch (Dune::NotImplemented&) |
591 | { | ||
592 |
1/2✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
|
280 | collectedWarnings += "warning: FluidSystem::diffusionCoefficient() is not implemented\n"; |
593 |
1/2✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
|
62 | } catch (Dune::InvalidStateException&) |
594 | { | ||
595 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
62 | 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 |
2/2✓ Branch 0 taken 547 times.
✓ Branch 1 taken 185 times.
|
1464 | for (int comp2Idx = 0; comp2Idx < numComponents; ++comp2Idx) |
601 | { | ||
602 | try | ||
603 | { | ||
604 | 872 | val = FluidSystem::binaryDiffusionCoefficient(fs, paramCache, phaseIdx, compIdx, comp2Idx); | |
605 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 280 times.
✗ Branch 7 not taken.
|
800 | } catch (Dune::NotImplemented&) |
606 | { | ||
607 |
1/2✓ Branch 1 taken 280 times.
✗ Branch 2 not taken.
|
560 | collectedWarnings += "warning: FluidSystem::binaryDiffusionCoefficient() is not implemented\n"; |
608 |
1/2✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
|
240 | } catch (Dune::InvalidStateException&) |
609 | { | ||
610 |
1/2✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
|
240 | 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 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 39 times.
|
228 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) |
621 | { | ||
622 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
150 | [[maybe_unused]] std::string name = FluidSystem::phaseName(phaseIdx); |
623 | 136 | [[maybe_unused]] bool bVal = FluidSystem::isGas(phaseIdx); | |
624 | 150 | bVal = FluidSystem::isIdealGas(phaseIdx); | |
625 | } | ||
626 | |||
627 | // test for componentName() | ||
628 |
2/2✓ Branch 0 taken 90 times.
✓ Branch 1 taken 39 times.
|
258 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
629 | { | ||
630 |
2/3✓ Branch 1 taken 49 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
180 | val = FluidSystem::molarMass(compIdx); |
631 |
1/2✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
|
180 | [[maybe_unused]] std::string name = FluidSystem::componentName(compIdx); |
632 | } | ||
633 | |||
634 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
78 | std::cout << collectedErrors; |
635 | // std::cout << collectedWarnings; | ||
636 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
78 | if (collectedErrors.empty()) // success |
637 | { | ||
638 |
2/4✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
|
78 | std::cout << "... successful" << std::endl; |
639 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
78 | std::cout << "----------------------------------" << std::endl; |
640 | return 0; | ||
641 | } | ||
642 | else | ||
643 | { | ||
644 | ✗ | std::cout << "... failed" << std::endl; | |
645 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
78 | std::cout << "----------------------------------" << std::endl; |
646 | return 1; | ||
647 | } | ||
648 | std::cout << "----------------------------------\n"; | ||
649 | return success; | ||
650 | 78 | } | |
651 | |||
652 | } // end namespace Dumux | ||
653 | |||
654 | #endif | ||
655 |