// Darcy-Weisbach Equation

function DarcyWeisbach(lambda, l, d, rho, v, g){
	this.lambda = lambda; // friction coefficient
	this.l = l; // length of pipe or duct (m)
	this.d = d; // hydraulic diameter (m)
	this.rho = rho; // density of fluid (kg/m3)
	this.v = v; // fluid velocity ((m/s)
	this.g = g; // gravity (m/s2)
}

DarcyWeisbach.prototype.pressureloss = function(){
	var dp = this.lambda * (this.l / this.d) * ((this.rho * Math.pow(this.v,2)) / 2);
	return dp;
}

DarcyWeisbach.prototype.headloss = function(){
	var dp = this.lambda * (this.l / this.d) * ((Math.pow(this.v,2)) / (this.g * 2));
	return dp; // mm H2O
}

DarcyWeisbach.prototype.inputString = function(){
	return this.lambda + " " + this.l + " " + this.d + " " + this.rho + " " + this.v + " " + this.g;
}

// Copyright engineeringtoolbox.com

