GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2pnc/surfactant/fluidsystem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 31 38 81.6%
Functions: 4 7 57.1%
Branches: 78 210 37.1%

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 TwoPNCTests
10 * \brief Fluidsystem for a surfactant model.
11 */
12 #ifndef DUMUX_TEST_2P3C_SURFACTANT_FLUIDSYSTEM_HH
13 #define DUMUX_TEST_2P3C_SURFACTANT_FLUIDSYSTEM_HH
14
15 #include <cassert>
16 #include <limits>
17 #include <dune/common/exceptions.hh>
18 #include <dumux/common/parameters.hh>
19 #include <dumux/material/fluidsystems/base.hh>
20
21 namespace Dumux::FluidSystems {
22
23 template <class Scalar>
24 class TestSurfactant
25 : public Base<Scalar, TestSurfactant<Scalar>>
26 {
27 using ThisType = TestSurfactant<Scalar>;
28 using Base = FluidSystems::Base<Scalar, ThisType>;
29
30 public:
31 // Two phases: wetting (0) and oil/nonwetting (1)
32 static constexpr int numPhases = 2;
33
34 static constexpr int wettingPhaseIdx = 0;
35 static constexpr int nonwettingPhaseIdx = 1;
36
37 static constexpr int phase0Idx = 0;
38 static constexpr int phase1Idx = 1;
39
40 static constexpr int numComponents = 3;
41
42 static constexpr int waterCompIdx = 0;
43 static constexpr int oilCompIdx = 1;
44 static constexpr int surfactantCompIdx = 2;
45
46 static constexpr int comp0Idx = 0;
47 static constexpr int comp1Idx = 1;
48 static constexpr int comp2Idx = 2;
49
50
51 /****************************************
52 * Fluid phase related static parameters
53 ****************************************/
54 /*!
55 * \brief Return the human readable name of a fluid phase
56 * \param phaseIdx The index of the fluid phase to consider
57 */
58 static std::string phaseName(int phaseIdx)
59 {
60
24/76
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✓ Branch 85 taken 1 times.
✓ Branch 86 taken 1 times.
✓ Branch 87 taken 1 times.
✓ Branch 88 taken 1 times.
✓ Branch 92 taken 1 times.
✓ Branch 93 taken 1 times.
✓ Branch 94 taken 1 times.
✓ Branch 95 taken 1 times.
✓ Branch 99 taken 1 times.
✓ Branch 100 taken 1 times.
✓ Branch 101 taken 1 times.
✓ Branch 102 taken 1 times.
✓ Branch 106 taken 1 times.
✓ Branch 107 taken 1 times.
✓ Branch 108 taken 1 times.
✓ Branch 109 taken 1 times.
✓ Branch 113 taken 1 times.
✓ Branch 114 taken 1 times.
✓ Branch 115 taken 1 times.
✓ Branch 116 taken 1 times.
✓ Branch 120 taken 3 times.
✓ Branch 121 taken 3 times.
✓ Branch 122 taken 3 times.
✓ Branch 123 taken 3 times.
40 return phaseIdx == wettingPhaseIdx ? "w" : "n";
61 }
62
63 static constexpr bool isMiscible()
64 { return false; }
65
66 static constexpr bool isGas(int phaseIdx)
67 { return false; }
68
69 static constexpr bool isIdealMixture(int phaseIdx)
70 { return true; }
71
72 static constexpr bool isCompressible(int phaseIdx)
73 { return false; }
74
75 static constexpr bool viscosityIsConstant(int phaseIdx)
76 { return true; }
77
78 /****************************************
79 * Component related static parameters
80 ****************************************/
81 /*!
82 * \brief Return the human readable name of a component
83 *
84 * \param compIdx index of the component
85 */
86 6 static std::string componentName(int compIdx)
87 {
88
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (compIdx == waterCompIdx)
89 4 return "water";
90
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if (compIdx == surfactantCompIdx)
91 4 return "surfactant";
92 else
93 4 return "oil";
94 }
95
96 /*!
97 * \brief Return the molar mass of a component in \f$\mathrm{[kg/mol]}\f$.
98 * \param compIdx index of the component
99 */
100 static Scalar molarMass(int compIdx)
101 {
102
10/22
✓ Branch 0 taken 25376400 times.
✓ Branch 1 taken 8458800 times.
✓ Branch 2 taken 16917600 times.
✓ Branch 3 taken 8458800 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 108830904 times.
✓ Branch 15 taken 54415452 times.
✓ Branch 16 taken 18138484 times.
✓ Branch 17 taken 9069242 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
249665685 if (compIdx == waterCompIdx)
103 return 18e-3;
104
10/22
✓ Branch 0 taken 8458800 times.
✓ Branch 1 taken 16917600 times.
✓ Branch 2 taken 8458800 times.
✓ Branch 3 taken 8458800 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 54415452 times.
✓ Branch 15 taken 54415452 times.
✓ Branch 16 taken 9069242 times.
✓ Branch 17 taken 9069242 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
169263390 else if (compIdx == surfactantCompIdx)
105 return 18e-3;
106 else // oil
107 return 0.350;
108 }
109
110 using Base::density;
111 /*!
112 * \brief Calculate the density \f$\mathrm{[kg/m^3]}\f$ of a fluid phase
113 */
114 template <class FluidState>
115 36319262 static Scalar density(const FluidState& fluidState, int phaseIdx)
116 {
117
2/2
✓ Branch 0 taken 18180778 times.
✓ Branch 1 taken 18138484 times.
36319262 if (phaseIdx == wettingPhaseIdx)
118 {
119
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 18180777 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
18180778 static const Scalar wettingPhaseDensity = getParam<Scalar>("FluidSystem.WettingPhaseDensity");
120 18180778 return wettingPhaseDensity;
121 }
122 else
123 {
124
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 18138483 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
18138484 static const Scalar nonwettingPhaseDensity = getParam<Scalar>("FluidSystem.NonwettingPhaseDensity");
125 18138484 return nonwettingPhaseDensity;
126 }
127 }
128
129 using Base::molarDensity;
130 /*!
131 * \brief The molar density \f$\rho_{mol,\alpha}\f$
132 * of a fluid phase \f$\alpha\f$ in \f$\mathrm{[mol/m^3]}\f$
133 *
134 * The molar density is defined by the
135 * mass density \f$\rho_\alpha\f$ and the component molar mass \f$M_\alpha\f$:
136 *
137 * \f[\rho_{mol,\alpha} = \frac{\rho_\alpha}{M_\alpha} \;.\f]
138 */
139 template <class FluidState>
140 18138484 static Scalar molarDensity(const FluidState& fluidState, int phaseIdx)
141 {
142
2/2
✓ Branch 0 taken 9069242 times.
✓ Branch 1 taken 9069242 times.
18138484 if (phaseIdx == wettingPhaseIdx)
143 9111536 return density(fluidState, phaseIdx) / molarMass(waterCompIdx);
144 else
145 9069242 return density(fluidState, phaseIdx) / molarMass(oilCompIdx);
146 }
147
148 using Base::viscosity;
149 /*!
150 * \brief Return the viscosity of a phase \f$\mathrm{[Pa*s]}\f$.
151 * \param fluidState The fluid state of the two-phase model
152 * \param phaseIdx Index of the fluid phase
153 */
154 template <class FluidState>
155 18180778 static Scalar viscosity(const FluidState& fluidState, int phaseIdx)
156 {
157
2/2
✓ Branch 0 taken 9111536 times.
✓ Branch 1 taken 9069242 times.
18180778 if (phaseIdx == wettingPhaseIdx)
158 {
159
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9111535 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
9111537 static const Scalar wettingPhaseViscosity
160
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 = getParam<Scalar>("FluidSystem.WettingPhaseViscosity");
161 9111536 return wettingPhaseViscosity;
162 }
163 else
164 {
165
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9069241 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
9069243 static const Scalar nonwettingPhaseViscosity
166
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 = getParam<Scalar>("FluidSystem.NonwettingPhaseViscosity");
167 9069242 return nonwettingPhaseViscosity;
168 }
169 }
170
171 using Base::fugacityCoefficient;
172 /*!
173 * \brief Calculate the fugacity coefficient \f$\mathrm{[-]}\f$ of an individual
174 * component in a fluid phase
175 *
176 * The fugacity coefficient \f$\mathrm{\phi^\kappa_\alpha}\f$ is connected to the
177 * fugacity \f$\mathrm{f^\kappa_\alpha}\f$ and the component's mole
178 * fraction \f$\mathrm{x^\kappa_\alpha}\f$ by means of the relation
179 *
180 * \f[
181 f^\kappa_\alpha = \phi^\kappa_\alpha\;x^\kappa_\alpha\;p_\alpha
182 * \f]
183 *
184 * \param fluidState The fluid state of the two-phase model
185 * \param phaseIdx Index of the fluid phase
186 * \param compIdx index of the component
187 */
188 template <class FluidState>
189 static Scalar fugacityCoefficient(const FluidState& fluidState, int phaseIdx, int compIdx)
190 {
191
2/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 27207726 times.
✓ Branch 13 taken 27207726 times.
54415452 if (phaseIdx == wettingPhaseIdx)
192
2/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 9069242 times.
✓ Branch 13 taken 18138484 times.
27207726 if (compIdx == waterCompIdx || compIdx == surfactantCompIdx)
193 return 0.0; // water and solubles stay in water phase
194
195
2/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 27207726 times.
✓ Branch 13 taken 9069242 times.
36276968 if (phaseIdx == nonwettingPhaseIdx)
196
2/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 9069242 times.
✓ Branch 13 taken 18138484 times.
27207726 if (compIdx == oilCompIdx)
197 return 0.0; // oil stays in oil phase
198
199 // this will always be multiplied with zero since all components stay in the respective phase
200 return std::numeric_limits<Scalar>::max();
201 }
202
203 using Base::binaryDiffusionCoefficient;
204 template <class FluidState>
205 static Scalar binaryDiffusionCoefficient(const FluidState& fluidState, int phaseIdx, int compIIdx, int compJIdx)
206 { return 0.0; }
207 };
208
209 } // end namespace Dumux::FluidSystems
210
211 #endif
212