【发布时间】:2019-07-05 23:33:07
【问题描述】:
我正在尝试实施一种迭代方法来使用 Horton 入渗方程计算径流降雨量。下面描述的代码实现了第一行 (time = 0)。
#Entrance
f0=6
f1=1
k=2
dt=0.25
f=0
time= seq(from=0, to=2, by=dt)
inc_rainfall=c(0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.4, 0.6, 0.6)
rainfall_int=inc_rainfall/dt
#fc
gfc = function(fc) {
f - ((f0 - fc) / k) + ((f1 / k) * log((fc - f1) / (f0 - f1)))}
fc=uniroot(gfc, interval = c(f0, f1))
fc=fc$root
#F'
fl=if(fc>rainfall_int[1]) sum(f,inc_rainfall[1]) else 0
#fc'
gfcl = function(fcl) {
fl - ((f0 - fcl) / k) + ((f1 / k) * log((fcl - f1) / (f0 - f1)))}
fcl=uniroot(gfcl, interval = c(f0, f1))
fcl=fcl$root
#Fp ou Fs
fporfs=ifelse(fc<rainfall_int[1],f,
ifelse(fcl<rainfall_int[1],
(f0-rainfall_int[1])/k-
f1/k*log((rainfall_int[1]-f1)/(f0-f1)), 0))
#dt'
dtl=ifelse((fc>rainfall_int[1]),
ifelse(fcl<rainfall_int[1],
(fporfs-f)/rainfall_int[1],0),0)
#ts
ts=ifelse(fc<rainfall_int[1],time[1],
ifelse(fcl<rainfall_int[1],dtl+time[1], 0))
#to
hto = function(to) {
fporfs-f1*(ts-to)-(f0-f1)/k*(1-exp(-k*(ts-to)))}
to=uniroot(hto, interval = c(0, 1))
to=to$root
#Ft+Dt
ftdt=ifelse(to==0, fl, f1*(time[1]-to)+(f0-f1)/k*(1-exp(-k*(time[1]-to)))) #This value will be the "f" on next row
#Infiltration
infiltr=ftdt+f
#Runoff in line 1
runoff1=inc_rainfall[1]-(ftdt)
#Runoff in line 2 to n
runoffn=inc_rainfall[1]-(ftdt[2]-ftdt[1])
out=as.data.frame(cbind(time[1], inc_rainfall, rainfall_int, f, fc, fl, fcl,
fporfs, dtl, ts, to, ftdt, infiltr, runoff1))
colnames(out)= c("Time", "Incremental Rainfall", "Rainfall Intensity", "F", "fc", "Fl", "Fcl", "Fp or Fs", "dt", "ts", "to", "Ftdt", "Infiltration", "Runoff" )
out
如何继续使用前一行的ftdt 值作为初始值 (f) 来计算下一行?
请注意,在最后一列 (runoff) 中,第一行的功能也发生了变化。除此之外,可能还需要添加一个额外的点time (2.25),以便计算最后一行的变量ftdt。
可在此处查看预期结果:http://hydrology.usu.edu/RRP/userdata/4/87/RainfallRunoffProcesses.pdf,第 109 页。
【问题讨论】:
-
您是否尝试过将所有内容都放在一个函数中,然后在循环中迭代变量?