www.mooseframework.org
PorousFlowVanGenuchten.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "PorousFlowVanGenuchten.h"
11 #include "libmesh/utility.h"
12 
13 namespace PorousFlowVanGenuchten
14 {
15 Real
16 effectiveSaturation(Real p, Real alpha, Real m)
17 {
18  Real n, seff;
19 
20  if (p >= 0.0)
21  return 1.0;
22  else
23  {
24  n = 1.0 / (1.0 - m);
25  seff = 1.0 + std::pow(-alpha * p, n);
26  return std::pow(seff, -m);
27  }
28 }
29 
30 Real
31 dEffectiveSaturation(Real p, Real alpha, Real m)
32 {
33  if (p >= 0.0)
34  return 0.0;
35  else
36  {
37  Real n = 1.0 / (1.0 - m);
38  Real inner = 1.0 + std::pow(-alpha * p, n);
39  Real dinner_dp = -n * alpha * std::pow(-alpha * p, n - 1.0);
40  Real dseff_dp = -m * std::pow(inner, -m - 1) * dinner_dp;
41  return dseff_dp;
42  }
43 }
44 
45 Real
46 d2EffectiveSaturation(Real p, Real alpha, Real m)
47 {
48  if (p >= 0.0)
49  return 0.0;
50  else
51  {
52  Real n = 1.0 / (1.0 - m);
53  Real inner = 1.0 + std::pow(-alpha * p, n);
54  Real dinner_dp = -n * alpha * std::pow(-alpha * p, n - 1.0);
55  Real d2inner_dp2 = n * (n - 1.0) * alpha * alpha * std::pow(-alpha * p, n - 2.0);
56  Real d2seff_dp2 = m * (m + 1.0) * std::pow(inner, -m - 2.0) * std::pow(dinner_dp, 2.0) -
57  m * std::pow(inner, -m - 1.0) * d2inner_dp2;
58  return d2seff_dp2;
59  }
60 }
61 
62 Real
63 capillaryPressure(Real seff, Real alpha, Real m, Real pc_max)
64 {
65  if (seff >= 1.0)
66  return 0.0;
67  else if (seff <= 0.0)
68  return pc_max;
69  else
70  {
71  Real a = std::pow(seff, -1.0 / m) - 1.0;
72  return std::min(std::pow(a, 1.0 - m) / alpha, pc_max);
73  }
74 }
75 
76 Real
77 dCapillaryPressure(Real seff, Real alpha, Real m, Real pc_max)
78 {
79  if (seff <= 0.0 || seff >= 1.0)
80  return 0.0;
81  else
82  {
83  Real a = std::pow(seff, -1.0 / m) - 1.0;
84  // Return 0 if pc > pc_max
85  if (std::pow(a, 1.0 - m) / alpha > pc_max)
86  return 0.0;
87  else
88  return (m - 1.0) * std::pow(a, -m) * std::pow(seff, -1.0 - 1.0 / m) / m / alpha;
89  }
90 }
91 
92 Real
93 d2CapillaryPressure(Real seff, Real alpha, Real m, Real pc_max)
94 {
95  if (seff <= 0.0 || seff >= 1.0)
96  return 0.0;
97  else
98  {
99  Real a = std::pow(seff, -1.0 / m) - 1.0;
100  // Return 0 if pc > pc_max
101  if (std::pow(a, 1.0 - m) / alpha > pc_max)
102  return 0.0;
103  else
104  {
105  Real d2pc = -std::pow(a, -1.0 - m) * std::pow(seff, -2.0 - 2.0 / m) +
106  ((1.0 + m) / m) * std::pow(a, -m) * std::pow(seff, -1.0 / m - 2.0);
107  d2pc *= (1.0 - m) / m / alpha;
108  return d2pc;
109  }
110  }
111 }
112 
113 Real
114 relativePermeability(Real seff, Real m)
115 {
116  if (seff <= 0.0)
117  return 0.0;
118  else if (seff >= 1.0)
119  return 1.0;
120 
121  const Real a = 1.0 - std::pow(seff, 1.0 / m);
122  const Real b = 1.0 - std::pow(a, m);
123 
124  return std::sqrt(seff) * Utility::pow<2>(b);
125 }
126 
127 Real
128 dRelativePermeability(Real seff, Real m)
129 {
130  // Guard against division by zero
131  if (seff <= 0.0 || seff >= 1.0)
132  return 0.0;
133 
134  const Real a = 1.0 - std::pow(seff, 1.0 / m);
135  const Real da = -1.0 / m * std::pow(seff, 1.0 / m - 1.0);
136  const Real b = 1.0 - std::pow(a, m);
137  const Real db = -m * std::pow(a, m - 1.0) * da;
138 
139  return 0.5 * std::pow(seff, -0.5) * Utility::pow<2>(b) + 2.0 * std::sqrt(seff) * b * db;
140 }
141 
142 Real
143 d2RelativePermeability(Real seff, Real m)
144 {
145  // Guard against division by zero
146  if (seff <= 0.0 || seff >= 1.0)
147  return 0.0;
148 
149  const Real a = 1.0 - std::pow(seff, 1.0 / m);
150  const Real da = -1.0 / m * std::pow(seff, 1.0 / m - 1.0);
151  const Real d2a = -(1.0 / m) * (1.0 / m - 1.0) * std::pow(seff, 1.0 / m - 2.0);
152  const Real b = 1.0 - std::pow(a, m);
153  const Real db = -m * std::pow(a, m - 1.0) * da;
154  const Real d2b = -m * (m - 1.0) * std::pow(a, m - 2.0) * da * da - m * std::pow(a, m - 1.0) * d2a;
155 
156  return -0.25 * std::pow(seff, -1.5) * Utility::pow<2>(b) + 2.0 * std::pow(seff, -0.5) * b * db +
157  2.0 * std::sqrt(seff) * db * db + 2.0 * std::sqrt(seff) * b * d2b;
158 }
159 
160 Real
161 relativePermeabilityNW(Real seff, Real m)
162 {
163  if (seff <= 0.0)
164  return 0.0;
165  else if (seff >= 1.0)
166  return 1.0;
167 
168  const Real a = std::pow(1.0 - seff, 1.0 / m);
169  const Real b = std::pow(1.0 - a, 2.0 * m);
170 
171  return std::sqrt(seff) * b;
172 }
173 
174 Real
175 dRelativePermeabilityNW(Real seff, Real m)
176 {
177  // Guard against division by zero
178  if (seff <= 0.0 || seff >= 1.0)
179  return 0.0;
180 
181  const Real a = std::pow(1.0 - seff, 1.0 / m);
182  const Real da = -1.0 / m * a / (1.0 - seff);
183  const Real b = std::pow(1.0 - a, 2.0 * m);
184  const Real db = -2.0 * m * b / (1.0 - a) * da;
185 
186  return 0.5 * std::pow(seff, -0.5) * b + std::sqrt(seff) * db;
187 }
188 
189 Real
190 d2RelativePermeabilityNW(Real seff, Real m)
191 {
192  // Guard against division by zero
193  if (seff <= 0.0 || seff >= 1.0)
194  return 0.0;
195 
196  const Real a = std::pow(1.0 - seff, 1.0 / m);
197  const Real da = -1.0 / m * a / (1.0 - seff);
198  const Real d2a = 1.0 / m * (1.0 / m - 1) * std::pow(1.0 - seff, 1.0 / m - 2.0);
199  const Real b = std::pow(1.0 - a, 2.0 * m);
200  const Real db = -2.0 * m * b / (1.0 - a) * da;
201  const Real d2b =
202  -2.0 * m * (db / (1.0 - a) * da + b * Utility::pow<2>(da / (1.0 - a)) + b / (1.0 - a) * d2a);
203 
204  return -0.25 * std::pow(seff, -1.5) * b + std::pow(seff, -0.5) * db + std::sqrt(seff) * d2b;
205 }
206 }
PorousFlowVanGenuchten::relativePermeability
Real relativePermeability(Real seff, Real m)
Relative permeability as a function of effective saturation.
Definition: PorousFlowVanGenuchten.C:114
pow
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Definition: ExpressionBuilder.h:673
PorousFlowVanGenuchten.h
PorousFlowVanGenuchten::relativePermeabilityNW
Real relativePermeabilityNW(Real seff, Real m)
Relative permeability for a non-wetting phase as a function of effective saturation.
Definition: PorousFlowVanGenuchten.C:161
PorousFlowVanGenuchten::d2RelativePermeabilityNW
Real d2RelativePermeabilityNW(Real seff, Real m)
Second derivative of relative permeability for a non-wetting phase with respect to effective saturati...
Definition: PorousFlowVanGenuchten.C:190
PorousFlowVanGenuchten::effectiveSaturation
Real effectiveSaturation(Real p, Real alpha, Real m)
Effective saturation as a function of porepressure.
Definition: PorousFlowVanGenuchten.C:16
PorousFlowVanGenuchten
van Genuchten effective saturation, capillary pressure and relative permeability functions.
Definition: PorousFlowVanGenuchten.h:29
PorousFlowVanGenuchten::d2CapillaryPressure
Real d2CapillaryPressure(Real seff, Real alpha, Real m, Real pc_max)
Second derivative of capillary pressure wrt effective saturation.
Definition: PorousFlowVanGenuchten.C:93
PorousFlowVanGenuchten::dRelativePermeability
Real dRelativePermeability(Real seff, Real m)
Derivative of relative permeability with respect to effective saturation.
Definition: PorousFlowVanGenuchten.C:128
PorousFlowVanGenuchten::d2RelativePermeability
Real d2RelativePermeability(Real seff, Real m)
Second derivative of relative permeability with respect to effective saturation.
Definition: PorousFlowVanGenuchten.C:143
PorousFlowVanGenuchten::dCapillaryPressure
Real dCapillaryPressure(Real seff, Real alpha, Real m, Real pc_max)
Derivative of capillary pressure wrt effective saturation.
Definition: PorousFlowVanGenuchten.C:77
PorousFlowVanGenuchten::capillaryPressure
Real capillaryPressure(Real seff, Real alpha, Real m, Real pc_max)
Capillary pressure as a function of effective saturation.
Definition: PorousFlowVanGenuchten.C:63
PorousFlowVanGenuchten::dEffectiveSaturation
Real dEffectiveSaturation(Real p, Real alpha, Real m)
Derivative of effective saturation wrt porepressure.
Definition: PorousFlowVanGenuchten.C:31
PorousFlowVanGenuchten::dRelativePermeabilityNW
Real dRelativePermeabilityNW(Real seff, Real m)
Derivative of relative permeability for a non-wetting phase with respect to effective saturation.
Definition: PorousFlowVanGenuchten.C:175
PorousFlowVanGenuchten::d2EffectiveSaturation
Real d2EffectiveSaturation(Real p, Real alpha, Real m)
Second derivative of effective saturation wrt porepressure.
Definition: PorousFlowVanGenuchten.C:46