https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowBrooksCoreyTest.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "gtest/gtest.h"
11
13
14const Real eps = 1.0e-8;
15const Real tol = 1.0e-6;
16
17TEST(PorousFlowBrooksCoreyTest, sat)
18{
19 EXPECT_NEAR(1.0, PorousFlowBrooksCorey::effectiveSaturation(0.99, 1.0, 2.0), tol);
20 EXPECT_NEAR(1.0, PorousFlowBrooksCorey::effectiveSaturation(1.0, 1.0, 2.0), tol);
21
22 const Real seff = std::pow(2.5 / 1.2, -2.0);
23 EXPECT_NEAR(seff, PorousFlowBrooksCorey::effectiveSaturation(2.5, 1.2, 2.0), tol);
24 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::effectiveSaturation(1.0e9, 1.2, 2.0), tol);
25}
26
27TEST(PorousFlowBrooksCoreyTest, dsat)
28{
29 Real fd;
30 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dEffectiveSaturation(0.99, 1.0, 2.0), tol);
31
32 fd = (PorousFlowBrooksCorey::effectiveSaturation(2.5 + eps, 1.2, 2.0) -
34 eps;
35 EXPECT_NEAR(fd, PorousFlowBrooksCorey::dEffectiveSaturation(2.5, 1.2, 2.0), tol);
36
37 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dEffectiveSaturation(1.0e9, 1.2, 2.0), tol);
38}
39
40TEST(PorousFlowBrooksCoreyTest, d2sat)
41{
42 Real fd;
43 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::d2EffectiveSaturation(0.99, 1.0, 2.0), tol);
44
47 eps;
48 EXPECT_NEAR(fd, PorousFlowBrooksCorey::d2EffectiveSaturation(2.5, 1.2, 2.0), tol);
49
50 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::d2EffectiveSaturation(1.0e9, 1.2, 2.0), tol);
51}
52
53TEST(PorousFlowBrooksCoreyTest, cap)
54{
55 EXPECT_NEAR(1.2, PorousFlowBrooksCorey::capillaryPressure(1.3, 1.2, 2.0, 1.0e9), tol);
56 const Real pc = 1.2 * std::pow(0.3, -1.0 / 2.0);
57 EXPECT_NEAR(pc, PorousFlowBrooksCorey::capillaryPressure(0.3, 1.2, 2.0, 1.0e9), tol);
58 EXPECT_NEAR(1000.0, PorousFlowBrooksCorey::capillaryPressure(0.0, 1.2, 2.0, 1000.0), tol);
59 EXPECT_NEAR(1.2, PorousFlowBrooksCorey::capillaryPressure(1.0, 1.2, 2.0, 1000.0), tol);
60}
61
62TEST(PorousFlowBrooksCoreyTest, dcap)
63{
64 Real fd;
65 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dCapillaryPressure(1.3, 1.2, 2.0, 1.0e9), tol);
66 fd = (PorousFlowBrooksCorey::capillaryPressure(0.3 + eps, 1.2, 2.0, 1.0e9) -
67 PorousFlowBrooksCorey::capillaryPressure(0.3, 1.2, 2.0, 1.0e9)) /
68 eps;
69 EXPECT_NEAR(fd, PorousFlowBrooksCorey::dCapillaryPressure(0.3, 1.2, 2.0, 1.0e9), tol);
70 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dCapillaryPressure(1.01, 1.2, 2.0, 1.0e9), tol);
71}
72
73TEST(PorousFlowBrooksCoreyTest, d2cap)
74{
75 Real fd;
76 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::d2CapillaryPressure(1.3, 1.2, 2.0, 1.0e9), tol);
77 fd = (PorousFlowBrooksCorey::dCapillaryPressure(0.3 + eps, 1.2, 2.0, 1.0e9) -
78 PorousFlowBrooksCorey::dCapillaryPressure(0.3, 1.2, 2.0, 1.0e9)) /
79 eps;
80 EXPECT_NEAR(fd, PorousFlowBrooksCorey::d2CapillaryPressure(0.3, 1.2, 2.0, 1.0e9), tol);
81 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::d2CapillaryPressure(1.01, 1.2, 2.0, 1.0e9), tol);
82}
83
84TEST(PorousFlowBrooksCoreyTest, relpermw)
85{
86 EXPECT_NEAR(1.0, PorousFlowBrooksCorey::relativePermeabilityW(1.1, 2.5), tol);
87 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::relativePermeabilityW(-1.0, 2.5), tol);
88 const Real relperm = std::pow(0.3, (2.0 + 3.0 * 2.5) / 2.5);
89 EXPECT_NEAR(relperm, PorousFlowBrooksCorey::relativePermeabilityW(0.3, 2.5), tol);
90}
91
92TEST(PorousFlowBrooksCoreyTest, drelpermw)
93{
94 Real fd;
95 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dRelativePermeabilityW(1.1, 2.5), tol);
96 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dRelativePermeabilityW(-1.0, 2.5), tol);
99 eps;
100 EXPECT_NEAR(fd, PorousFlowBrooksCorey::dRelativePermeabilityW(0.3, 2.5), tol);
101}
102
103TEST(PorousFlowBrooksCoreyTest, relpermnw)
104{
105 EXPECT_NEAR(1.0, PorousFlowBrooksCorey::relativePermeabilityNW(1.1, 2.5), tol);
106 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::relativePermeabilityNW(-1.0, 2.5), tol);
107 const Real relperm = 0.3 * 0.3 * (1.0 - std::pow(1.0 - 0.3, (2.0 + 2.5) / 2.5));
108 EXPECT_NEAR(relperm, PorousFlowBrooksCorey::relativePermeabilityNW(0.3, 2.5), tol);
109}
110
111TEST(PorousFlowBrooksCoreyTest, drelpermnw)
112{
113 Real fd;
114 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dRelativePermeabilityNW(1.1, 2.5), tol);
115 EXPECT_NEAR(0.0, PorousFlowBrooksCorey::dRelativePermeabilityNW(-1.0, 2.5), tol);
118 eps;
119 EXPECT_NEAR(fd, PorousFlowBrooksCorey::dRelativePermeabilityNW(0.3, 2.5), tol);
120}
121
122TEST(PorousFlowBrooksCoreyTest, adrelpermw)
123{
124 ADReal sat = 0.3;
125 Moose::derivInsert(sat.derivatives(), 0, 1.0);
126
127 const auto adrelperm = PorousFlowBrooksCorey::relativePermeabilityW(sat, 2.5);
128
129 const auto relperm = PorousFlowBrooksCorey::relativePermeabilityW(sat.value(), 2.5);
130 const auto drelperm = PorousFlowBrooksCorey::dRelativePermeabilityW(sat.value(), 2.5);
131
132 EXPECT_NEAR(adrelperm.value(), relperm, tol);
133 EXPECT_NEAR(adrelperm.derivatives()[0], drelperm, tol);
134}
135
136TEST(PorousFlowBrooksCoreyTest, adrelpermnw)
137{
138 ADReal sat = 0.3;
139 Moose::derivInsert(sat.derivatives(), 0, 1.0);
140
141 const auto adrelperm = PorousFlowBrooksCorey::relativePermeabilityNW(sat, 2.5);
142
143 const auto relperm = PorousFlowBrooksCorey::relativePermeabilityNW(sat.value(), 2.5);
144 const auto drelperm = PorousFlowBrooksCorey::dRelativePermeabilityNW(sat.value(), 2.5);
145
146 EXPECT_NEAR(adrelperm.value(), relperm, tol);
147 EXPECT_NEAR(adrelperm.derivatives()[0], drelperm, tol);
148}
DualNumber< Real, DNDerivativeType, true > ADReal
TEST(PorousFlowBrooksCoreyTest, sat)
const Real eps
const Real tol
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)
Real dRelativePermeabilityNW(Real seff, Real lambda)
Derivative of relative permeability of the non-wetting phase wrt to effective saturation.
T relativePermeabilityW(const T &seff, Real lambda)
Relative permeability of the wetting phase as a function of effective saturation.
Real capillaryPressure(Real seff, Real pe, Real lambda, Real pc_max)
Capillary pressure as a function of effective saturation.
Real d2EffectiveSaturation(Real pc, Real pe, Real lambda)
Second derivative of effective saturation wrt porepressure.
Real dCapillaryPressure(Real seff, Real pe, Real lambda, Real pc_max)
Derivative of capillary pressure wrt effective saturation.
Real dRelativePermeabilityW(Real seff, Real lambda)
Derivative of relative permeability of the wetting phase wrt to effective saturation.
Real dEffectiveSaturation(Real pc, Real pe, Real lambda)
Derivative of effective saturation wrt porepressure.
Real d2CapillaryPressure(Real seff, Real pe, Real lambda, Real pc_max)
Second derivative of capillary pressure wrt effective saturation.
Real effectiveSaturation(Real pc, Real pe, Real lambda)
Effective saturation as a function of capillary pressure Note: seff = 1 for p >= 0.
T relativePermeabilityNW(const T &seff, Real lambda)
Relative permeability of the non-wetting phase as a function of effective saturation.