//OOP Horton Infiltration
//2:28 PM 12/29/2008

function Horton(f1,f2,k)
{
	//Horton Infiltration Equation Object
	//f1=initial infiltration (in/hr)
	//f2=final constant infiltration (in/hr)
	//k=decay rate (per hour)

	this.rate=rate;
	this.depth=depth;
	this.avg_loss_rate=avg_loss_rate;

	function rate(t){
		//infiltration rate in inches per hour
		//t in hours
		return eval(f2+(f1-f2)/Math.exp(t*k));		
	}

	function depth(t1,t2)
	{
		//total infiltration depth in inches
		//the definite integral of horton eqn. bet t=t1 and t=t2 hours
		//do not confuse this:
			//t1 and f1 are not corresponding
			//t2 and f2 are not corresponding
		var depth=(f2-f1)/k*(1/Math.exp(k*t2)-1/Math.exp(k*t1))+f2*(t2-t1);
		return depth;
	}

	function avg_loss_rate(t1,t2,acre)
	{
		//returns average loss rate between time t1 and t2 for acre infiltration area
		//unit cfs
		//t1,t2 in hrs
		return this.depth(t1,t2)/12*acre*43560.0/(t2-t1)/3600
	}

}//end Horton()

