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 Material law for a surfactant model. | ||
11 | */ | ||
12 | #ifndef DUMUX_TEST_2P3C_SURFACTANT_MATERIALLAW_HH | ||
13 | #define DUMUX_TEST_2P3C_SURFACTANT_MATERIALLAW_HH | ||
14 | |||
15 | #include <algorithm> | ||
16 | #include <dune/common/math.hh> | ||
17 | |||
18 | namespace Dumux::FluidMatrix { | ||
19 | |||
20 | /*! | ||
21 | * \brief Material law for a surfactant model.This is based on the surfactant model described | ||
22 | * in K. Jørgensen's master thesis (NTNU, 2013) http://hdl.handle.net/11250/240038 | ||
23 | */ | ||
24 | template <class Scalar> | ||
25 | class SurfactantPcKrSw | ||
26 | { | ||
27 | // surfactant-related values | ||
28 | struct SurfactantParams { double srw, sro, ww, wo; }; | ||
29 | |||
30 | public: | ||
31 | 18138484 | SurfactantPcKrSw(const Scalar Ncv, const Scalar sMinKr, const Scalar sMaxKr, const Scalar srwSurf, const Scalar sroSurf) | |
32 | 18138484 | : sMinKr_(sMinKr), sMaxKr_(sMaxKr), srwSurf_(srwSurf), sroSurf_(sroSurf) | |
33 | { | ||
34 | using std::clamp; using std::log; | ||
35 |
2/2✓ Branch 0 taken 18039326 times.
✓ Branch 1 taken 99158 times.
|
18138484 | params_.ww = 1.0 - clamp(log(Ncv / 1e-3) / log(8e-7 / 1e-3), 0.0, 1.0); |
36 |
2/2✓ Branch 0 taken 17765758 times.
✓ Branch 1 taken 372726 times.
|
18138484 | params_.wo = 1.0 - clamp(log(Ncv / 1e-4) / log(2e-6 / 1e-4), 0.0, 1.0); |
37 | |||
38 | 18138484 | const Scalar srwNoSurf = sMinKr; | |
39 | 18138484 | const Scalar sroNoSurf = 1.0 - sMaxKr; | |
40 | 18138484 | params_.srw = (1 - params_.ww) * srwNoSurf + params_.ww * srwSurf; | |
41 | 18138484 | params_.sro = (1 - params_.wo) * sroNoSurf + params_.wo * sroSurf; | |
42 | 18138484 | } | |
43 | |||
44 | ✗ | Scalar pc(Scalar sw) const | |
45 | { | ||
46 | ✗ | return 0.0; | |
47 | } | ||
48 | |||
49 | 9069242 | Scalar krw(Scalar sw) const | |
50 | { | ||
51 | using std::clamp; | ||
52 | |||
53 | 9069242 | const auto swStar = (sw - params_.srw) / (1.0 - params_.sro - params_.srw); | |
54 | 9069242 | const auto swMapped = sMinKr_ + (sMaxKr_ - sMinKr_) * swStar; | |
55 |
1/2✓ Branch 0 taken 9069242 times.
✗ Branch 1 not taken.
|
18138484 | const auto krwSurf = Dune::power(clamp(swStar, 0.0, 1.0), 2); |
56 | |||
57 |
1/2✓ Branch 0 taken 9069242 times.
✗ Branch 1 not taken.
|
9069242 | return params_.ww * krwSurf + (1.0 - params_.ww) * krwNoSurfactant_(clamp(swMapped, sMinKr_, sMaxKr_)); |
58 | } | ||
59 | |||
60 | 9069242 | Scalar krn(Scalar sw) const | |
61 | { | ||
62 | using std::clamp; | ||
63 | |||
64 | 9069242 | const auto swStar = (sw - params_.srw) / (1.0 - params_.sro - params_.srw); | |
65 | 9069242 | const auto swMapped = sMinKr_ + (sMaxKr_ - sMinKr_) * swStar; | |
66 |
2/2✓ Branch 0 taken 9063730 times.
✓ Branch 1 taken 5512 times.
|
18132972 | const auto kroSurf = Dune::power(clamp(1.0 - swStar, 0.0, 1.0), 2); |
67 | |||
68 |
1/2✓ Branch 0 taken 9069242 times.
✗ Branch 1 not taken.
|
9069242 | return params_.wo * kroSurf + (1.0 - params_.wo) * krnNoSurfactant_(clamp(swMapped, sMinKr_, sMaxKr_)); |
69 | } | ||
70 | |||
71 | private: | ||
72 | ✗ | Scalar krnNoSurfactant_(Scalar sw) const | |
73 | { | ||
74 | using std::clamp; | ||
75 | |||
76 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9069242 times.
✗ Branch 3 not taken.
|
9069242 | const auto clampedS = std::clamp((sw - sMinKr_)/(sMaxKr_ - sMinKr_), 0.0, 1.0); |
77 | 9069242 | return 0.14 * Dune::power(1.0 - clampedS, 2); | |
78 | } | ||
79 | |||
80 | ✗ | Scalar krwNoSurfactant_ (Scalar sw) const | |
81 | { | ||
82 | using std::clamp; | ||
83 | |||
84 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9069242 times.
✗ Branch 3 not taken.
|
18138484 | return 0.02 * Dune::power(clamp((sw - sMinKr_) / (sMaxKr_ - sMinKr_), 0.0, 1.0), 2); |
85 | } | ||
86 | |||
87 | SurfactantParams params_; | ||
88 | Scalar sMinKr_, sMaxKr_; | ||
89 | Scalar srwSurf_, sroSurf_; | ||
90 | }; | ||
91 | |||
92 | } // end namespace Dumux::FluidMatrix | ||
93 | |||
94 | #endif | ||
95 |