GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p3c_1p3c/h2n2co2fluidsystem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 12 23 52.2%
Functions: 2 7 28.6%
Branches: 15 62 24.2%

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 BoundaryTests
10 * \brief A fluid system for one phase with the components h2, n2 and co2.
11 */
12
13 #ifndef DUMUX_THREE_GAS_COMPONENT_FLUID_SYSTEM_HH
14 #define DUMUX_THREE_GAS_COMPONENT_FLUID_SYSTEM_HH
15
16 #include <dumux/material/fluidsystems/base.hh>
17
18 namespace Dumux {
19 namespace FluidSystems {
20 /*!
21 * \ingroup BoundaryTests
22 * \brief A simple fluid system with one Maxwell-Stefan component.
23 */
24 template<class Scalar>
25 class H2N2CO2FluidSystem: public Base<Scalar, H2N2CO2FluidSystem<Scalar>>
26
27 {
28 using ThisType = H2N2CO2FluidSystem<Scalar>;
29 using Base = FluidSystems::Base<Scalar, ThisType>;
30
31 public:
32 //! The number of phases
33 static constexpr int numPhases = 1;
34 static constexpr int numComponents = 3;
35
36 static constexpr int H2Idx = 0;//first major component
37 static constexpr int N2Idx = 1;//second major component
38 static constexpr int CO2Idx = 2;//secondary component
39
40 //! Human readable component name (index compIdx) (for vtk output)
41 209262 static std::string componentName(int compIdx)
42 {
43
3/4
✓ Branch 0 taken 104628 times.
✓ Branch 1 taken 104629 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
209262 switch (compIdx)
44 {
45 209256 case H2Idx: return "H2";
46 209258 case N2Idx: return "N2";
47 10 case CO2Idx: return "CO2";
48 }
49 DUNE_THROW(Dune::InvalidStateException, "Invalid compIdx index " << compIdx);
50 }
51
52 //! Human readable phase name (index phaseIdx) (for velocity vtk output)
53 static std::string phaseName(int phaseIdx = 0)
54
2/8
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
60 { return "Gas"; }
55
56 //! Molar mass in kg/mol of the component with index compIdx
57 static Scalar molarMass(unsigned int compIdx)
58 { return 0.02896; }
59
60
61 using Base::binaryDiffusionCoefficient;
62 /*!
63 * \brief Given a phase's composition, temperature and pressure,
64 * returns the binary diffusion coefficient \f$\mathrm{[m^2/s]}\f$ for components
65 * \f$i\f$ and \f$j\f$ in this phase.
66 *
67 * \param fluidState An arbitrary fluid state
68 * \param phaseIdx The index of the fluid phase to consider
69 * \param compIIdx The index of the first component to consider
70 * \param compJIdx The index of the second component to consider
71 */
72 template <class FluidState>
73 3796560 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
74 int phaseIdx,
75 int compIIdx,
76 int compJIdx)
77 {
78
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3796560 times.
3796560 if (compIIdx > compJIdx)
79 {
80 using std::swap;
81 swap(compIIdx, compJIdx);
82 }
83
84
4/4
✓ Branch 0 taken 2531040 times.
✓ Branch 1 taken 1265520 times.
✓ Branch 2 taken 1265520 times.
✓ Branch 3 taken 1265520 times.
3796560 if (compIIdx == H2Idx && compJIdx == N2Idx)
85 return 83.3e-6;
86
3/4
✓ Branch 0 taken 1265520 times.
✓ Branch 1 taken 1265520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1265520 times.
2531040 if (compIIdx == H2Idx && compJIdx == CO2Idx)
87 return 68.0e-6;
88
2/4
✓ Branch 0 taken 1265520 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1265520 times.
1265520 if (compIIdx == N2Idx && compJIdx == CO2Idx)
89 return 16.8e-6;
90 DUNE_THROW(Dune::InvalidStateException,
91 "Binary diffusion coefficient of components "
92 << compIIdx << " and " << compJIdx << " is undefined!\n");
93 }
94 using Base::density;
95 /*!
96 * \brief Given a phase's composition, temperature, pressure, and
97 * the partial pressures of all components, returns its
98 * density \f$\mathrm{[kg/m^3]}\f$.
99 * \param phaseIdx index of the phase
100 * \param fluidState the fluid state
101 *
102 */
103 template <class FluidState>
104 static Scalar density(const FluidState &fluidState,
105 const int phaseIdx)
106 {
107 return 1;
108 }
109
110 using Base::viscosity;
111 /*!
112 * \brief Calculates the dynamic viscosity of a fluid phase \f$\mathrm{[Pa*s]}\f$
113 *
114 * \param fluidState An arbitrary fluid state
115 * \param phaseIdx The index of the fluid phase to consider
116 */
117 template <class FluidState>
118 static Scalar viscosity(const FluidState &fluidState,
119 int phaseIdx)
120 {
121 return 1e-6;
122 }
123
124 using Base::molarDensity;
125 /*!
126 * \brief The molar density \f$\rho_{mol,\alpha}\f$
127 * of a fluid phase \f$\alpha\f$ in \f$\mathrm{[mol/m^3]}\f$
128 *
129 * The molar density for the simple relation is defined by the
130 * mass density \f$\rho_\alpha\f$ and the molar mass of the main component \f$M_\kappa\f$:
131 *
132 * \f[\rho_{mol,\alpha} = \frac{\rho_\alpha}{M_\kappa} \;.\f]
133 */
134 template <class FluidState>
135 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
136 {
137 1265520 return density(fluidState, phaseIdx)/molarMass(0);
138 }
139 };
140
141 } // end namespace FluidSystems
142 } // end namespace Dumux
143
144
145 #endif
146