// Duct Pressure Loss Imperial Units

function DuctVelocity(q, d, a, b){
	this.q = q; // volume flow
	this.d = d; // diameter rectangular duct
	this.a = a; // length a rectangular duct
	this.b = b; // length b rectangular duct
}

DuctVelocity.prototype.velocity = function(){
	var area = -1;
	if (this.d && !this.a && !this.b) area = Math.PI * Math.pow(this.d/2, 2);
	if (!this.d && this.a && this.b) area = this.a * this.b;
	if (area == - 1) return -1;
	return this.q/area;
}

DuctVelocity.prototype.inputString = function(){
	return this.q + " " + this.d + " " + this.a + " " + this.b;
}

// Copyright engineeringtoolbox.com