def RichardsModel(psi, t, dz, n, p, vg, qTfun, qBot, psiTop, psiBot): # Basic properties: C = vg.CFun(psi, p) # initialize vectors: q = np.zeros(n + 1) # # Upper boundary # if qTop == []: # Fixed value # KTop = vg.KFun(np.zeros(1) + psiTop, p) # q[n] = -KTop * ((psiTop - psi[n - 1]) / dz * 2 + 1) # else: # Fixed flux # q[n] = qTop # if t>10: # q[n] = qTfun(10) # else: # q[n] = qTfun(t) if t > 160920: q[n] = qTfun(160920) else: q[n] = qTfun(t) # Lower boundary if qBot == []: if psiBot == []: # Free drainage: fixed flux: fixed gradient KBot = vg.KFun(np.zeros(1) + psi[0], p) q[0] = -KBot else: # Type 1 boundary: Fixed gradient KBot = vg.KFun(np.zeros(1) + psiBot, p) q[0] = -KBot * ((psi[0] - psiBot) / dz * 2 + 1.0) else: # Type 2 boundary q[0] = qBot # Internal nodes i = np.arange(0, n - 1) Knodes = vg.KFun(psi, p) Kmid = (Knodes[i + 1] + Knodes[i]) / 2.0 j = np.arange(1, n) q[j] = -Kmid * ((psi[i + 1] - psi[i]) / dz + 1.0) if q[n] != 0: if q[n] < q[n - 1]: # because here q is a negative value print('Water accumulated at the top, time = ', t / 60, 'min(s)') KTop = vg.KFun(psiTop, p) dhdz = (psiTop - psi[n - 1]) * 2 / dz + 1 q[n] = -KTop * dhdz # Continuity i = np.arange(0, n) dpsidt = (-(q[i + 1] - q[i]) / dz) / C return dpsidt
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]$')
if q[n] != 0: if q[n] < q[n - 1]: # because here q is a negative value print('Water accumulated at the top, time = ', t / 60, 'min(s)') KTop = vg.KFun(psiTop, p) dhdz = (psiTop - psi[n - 1]) * 2 / dz + 1 q[n] = -KTop * dhdz # Continuity i = np.arange(0, n) dpsidt = (-(q[i + 1] - q[i]) / dz) / C return dpsidt psi = np.linspace(-10, 5) theta = vg.thetaFun(psi, p) C = vg.CFun(psi, p) K = vg.KFun(psi, p) pl.figure() pl.rcParams['figure.figsize'] = (5.0, 10.0) pl.subplot(311) pl.plot(psi, theta) pl.ylabel(r'$\theta$', fontsize=20) pl.subplot(312) pl.plot(psi, C) pl.ylabel(r'$C$', fontsize=20) pl.subplot(313) pl.plot(psi, K) pl.ylabel(r'$K$', fontsize=20) pl.xlabel(r'$\psi$', fontsize=20)