forked from amireson/RichardsEquation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vanGenuchten.py
135 lines (121 loc) · 3.16 KB
/
vanGenuchten.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# These are the van Genuchten (1980) equations
# The input is matric potential, psi and the hydraulic parameters.
# psi must be sent in as a numpy array.
# The pars variable is like a MATLAB structure.
import numpy as np
def thetaFun(psi,pars):
if psi>=0.:
Se = 1.
else:
Se=(1+abs(psi*pars['alpha'])**pars['n'])**(-pars['m'])
return pars['thetaR']+(pars['thetaS']-pars['thetaR'])*Se
thetaFun=np.vectorize(thetaFun)
def CFun(psi,pars):
if psi>=0.:
Se=1.
else:
Se=(1+abs(psi*pars['alpha'])**pars['n'])**(-pars['m'])
dSedh=pars['alpha']*pars['m']/(1-pars['m'])*Se**(1/pars['m'])*(1-Se**(1/pars['m']))**pars['m']
return Se*pars['Ss']+(pars['thetaS']-pars['thetaR'])*dSedh
CFun = np.vectorize(CFun)
def KFun(psi,pars):
if psi>=0.:
Se=1.
else:
Se=(1+abs(psi*pars['alpha'])**pars['n'])**(-pars['m'])
return pars['Ks']*Se**pars['neta']*(1-(1-Se**(1/pars['m']))**pars['m'])**2
KFun = np.vectorize(KFun)
def setpars():
pars={}
pars['thetaR']=float(raw_input("thetaR = "))
pars['thetaS']=float(raw_input("thetaS = "))
pars['alpha']=float(raw_input("alpha = "))
pars['n']=float(raw_input("n = "))
pars['m']=1-1/pars['n']
pars['Ks']=float(raw_input("Ks = "))
pars['neta']=float(raw_input("neta = "))
pars['Ss']=float(raw_input("Ss = "))
return pars
def PlotProps(pars):
import numpy as np
import pylab as pl
import vanGenuchten as vg
psi=np.linspace(-10,2,200)
pl.figure
pl.subplot(3,1,1)
pl.plot(psi,vg.thetaFun(psi,pars))
pl.ylabel(r'$\theta(\psi) [-]$')
pl.subplot(3,1,2)
pl.plot(psi,vg.CFun(psi,pars))
pl.ylabel(r'$C(\psi) [1/m]$')
pl.subplot(3,1,3)
pl.plot(psi,vg.KFun(psi,pars))
pl.xlabel(r'$\psi [m]$')
pl.ylabel(r'$K(\psi) [m/d]$')
#pl.show()
def HygieneSandstone():
pars={}
pars['thetaR']=0.153
pars['thetaS']=0.25
pars['alpha']=0.79
pars['n']=10.4
pars['m']=1-1/pars['n']
pars['Ks']=1.08
pars['neta']=0.5
pars['Ss']=0.000001
return pars
def TouchetSiltLoam():
pars={}
pars['thetaR']=0.19
pars['thetaS']=0.469
pars['alpha']=0.5
pars['n']=7.09
pars['m']=1-1/pars['n']
pars['Ks']=3.03
pars['neta']=0.5
pars['Ss']=0.000001
return pars
def SiltLoamGE3():
pars={}
pars['thetaR']=0.131
pars['thetaS']=0.396
pars['alpha']=0.423
pars['n']=2.06
pars['m']=1-1/pars['n']
pars['Ks']=0.0496
pars['neta']=0.5
pars['Ss']=0.000001
return pars
def GuelphLoamDrying():
pars={}
pars['thetaR']=0.218
pars['thetaS']=0.520
pars['alpha']=1.15
pars['n']=2.03
pars['m']=1-1/pars['n']
pars['Ks']=0.316
pars['neta']=0.5
pars['Ss']=0.000001
return pars
def GuelphLoamWetting():
pars={}
pars['thetaR']=0.218
pars['thetaS']=0.434
pars['alpha']=2.0
pars['n']=2.76
pars['m']=1-1/pars['n']
pars['Ks']=0.316
pars['neta']=0.5
pars['Ss']=0.000001
return pars
def BeitNetofaClay():
pars={}
pars['thetaR']=0.
pars['thetaS']=0.446
pars['alpha']=0.152
pars['n']=1.17
pars['m']=1-1/pars['n']
pars['Ks']=0.00082
pars['neta']=0.5
pars['Ss']=0.000001
return pars