├── GreenAmpt.py ├── README.md ├── VarUnitCSNMap.txt └── test.py /GreenAmpt.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015, Peishi Jiang 3 | 4 | #-------------------------------------------------------- 5 | # class GreenAmpt 6 | # 7 | # __init__() 8 | # Fp 9 | # f 10 | # F 11 | # __EqnF 12 | # F_f 13 | # 14 | #-------------------------------------------------------- 15 | # This model is based on the Green-Ampt method described 16 | # in , pp110. 17 | # 18 | # Ref: 19 | # Chow, Ven T., David R. Maidment, and Larry W. Mays. 20 | # Applied hydrology. 1988. 21 | #-------------------------------------------------------- 22 | 23 | from scipy.optimize import newton 24 | from pprint import pprint 25 | from json import dump 26 | from math import log 27 | import numpy as np 28 | 29 | class GreenAmpt(object): 30 | ''' 31 | Green-Ampt Cumulative Infiltration 32 | ''' 33 | 34 | def __init__(self, K, dt, theta_i, theta_s, psi, i): 35 | """ 36 | Constructor 37 | """ 38 | self.K = K # hydraulic conductivity 39 | self.dt = dt # time resolution 40 | self.theta_i = theta_i # initial water content 41 | self.theta_s = theta_s # saturated water content 42 | self.dtheta = theta_s - theta_i # the change in the moisture content 43 | self.psi = psi # wetting front soil suction head 44 | if type(i) == list: 45 | self.i = i # rainfall intensity 46 | else: 47 | self.i = [i] 48 | 49 | def Fp(self, i): 50 | """ 51 | Cumulative infiltration at the ponding time tp 52 | """ 53 | return self.K * self.psi * self.dtheta / (i - self.K) 54 | 55 | def F(self, F_t, dt_t): 56 | """ 57 | Solve Equation of Green-Ampt Cumulative Infiltration __EqnF 58 | """ 59 | F_t_next = lambda F: self.__EqnF(F_t, dt_t, F) 60 | return newton(F_t_next, 3) 61 | 62 | def f(self, F): 63 | """ 64 | Generate Green-Ampt Infiltration Rate at time t 65 | """ 66 | if F == 0: 67 | return -9999 68 | else: 69 | return self.K * (self.psi * self.dtheta / F + 1) 70 | 71 | def __EqnF(self, F_t, dt_t, F): 72 | """ 73 | Equation of Green-Ampt Cumulative Infiltration after ponding 74 | F: Green-Ampt Cumulative Infiltration variable 75 | """ 76 | return F - F_t - self.K*dt_t - self.psi*self.dtheta*log((self.psi*self.dtheta+F)/(self.psi*self.dtheta+F_t)) 77 | 78 | def F_f(self): 79 | """ 80 | Generate the time series of cumulative infiltration and infiltration rate 81 | given the time series of rainfall intensity i 82 | """ 83 | t_len = len(self.i) 84 | F_all = []; f_all = []; t_all = [] 85 | # initial 86 | F_all.append(0) 87 | f_all.append(-9999) 88 | t_all.append(0) 89 | for ind in range(1, t_len+1): 90 | i_t = self.i[ind-1] 91 | f_t = f_all[ind-1] 92 | F_t = F_all[ind-1] 93 | if abs(f_t) <= i_t: 94 | # ponding occurs throught interval 95 | F_t_next = self.F(F_t, self.dt) 96 | f_t_next = self.f(F_t_next) 97 | elif abs(f_t) > i_t: 98 | # no ponding at the beginning of the interval 99 | F_t_next_temp = F_t + i_t*self.dt 100 | f_t_next_temp = self.f(F_t_next_temp) 101 | if abs(f_t_next_temp) > i_t: 102 | # no ponding throughout interval 103 | f_t_next = f_t_next_temp 104 | F_t_next = F_t_next_temp 105 | elif abs(f_t_next_temp) <= i_t: 106 | # ponding occurs during interval 107 | Fp_t = self.Fp(i_t) 108 | print i_t 109 | dt_p = (Fp_t - F_t) / i_t 110 | F_t_next = self.F(Fp_t, self.dt - dt_p) 111 | f_t_next = self.f(F_t_next) 112 | F_all.append(F_t_next) 113 | f_all.append(f_t_next) 114 | t_all.append(self.dt*(ind)) 115 | return F_all, f_all, t_all -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GreenAmptInfiltrationModel 2 | The Green-Ampt method of infiltration estimation 3 | 4 | ##Obtain first release 5 | The first release, 0.1, is deposited in Zenodo (http://dx.doi.org/10.5281/zenodo.18772). 6 | 7 | [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.18772.svg)](http://dx.doi.org/10.5281/zenodo.18772) 8 | -------------------------------------------------------------------------------- /VarUnitCSNMap.txt: -------------------------------------------------------------------------------- 1 | { 2 | "var_input": [ 3 | { 4 | "soil_water__initial_hydraulic_conductivity": "K" 5 | }, 6 | { 7 | "atmosphere_water__rainfall_volume_flux": "i" 8 | }, 9 | { 10 | "model__time_step": "dt" 11 | }, 12 | { 13 | "soil_water_wetting-front__suction_head": "psi" 14 | }, 15 | { 16 | "soil_water__initial_volume_fraction": "theta_i" 17 | }, 18 | { 19 | "soil_water__saturated_volume_fraction": "theta_s" 20 | } 21 | ] 22 | }, 23 | { 24 | "var_output": [ 25 | { 26 | "soil_surface_water__infiltration_volume_flux": "f" 27 | }, 28 | { 29 | "soil_surface_water__time_integral_of_infiltration_volume_flux": "F" 30 | } 31 | ] 32 | }, 33 | { 34 | "var_unit": [ 35 | { 36 | "soil_water__initial_hydraulic_conductivity": "cm/h" 37 | }, 38 | { 39 | "atmosphere_water__rainfall_volume_flux": "cm/h" 40 | }, 41 | { 42 | "model__time_step": "h" 43 | }, 44 | { 45 | "soil_water_wetting-front__suction_head": "cm" 46 | }, 47 | { 48 | "soil_water__initial_volume_fraction": "1" 49 | }, 50 | { 51 | "soil_water__saturated_volume_fraction": "1" 52 | }, 53 | { 54 | "soil_surface_water__infiltration_volume_flux": "cm/h" 55 | }, 56 | { 57 | "soil_surface_water__time_integral_of_infiltration_volume_flux": "cm" 58 | } 59 | ] 60 | } -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015, Peishi Jiang 3 | 4 | import GreenAmpt 5 | 6 | def main(): 7 | """ 8 | test 9 | """ 10 | K = 1.09; psi = 11.01; dtheta = 0.247; dt = 0.166 11 | i = [1.08, 1.26, 1.56, 1.92, 2.22, 2.58, 3.84, 6.84, 19.08, \ 12 | 9.90, 4.86, 3.12, 2.52, 2.16, 1.68, 1.44, 1.14, 1.02] 13 | a = GreenAmpt(K, dt, dtheta, psi, i) 14 | F, f, t =a.F_f() 15 | 16 | if __name__ == "__main__": 17 | main() --------------------------------------------------------------------------------