// Reynolds Number 

function Colebrook(d, k, re){
	this.lambda = 0.08;
	this.d = d; // hydraulic diameter
	this.k = k; // roughness coefficient
	this.re = re; // reynoldsnumber
}

Colebrook.prototype.frictionCoefficient = function(){
	do {
		leftL = 1 / Math.sqrt(this.lambda);
		rightL = - 2 * Math.LOG10E * Math.log(2.51/(this.re * Math.sqrt(this.lambda)) + this.k/this.d/3.72);
		this.lambda = this.lambda - 0.0005;
	} while (rightL - leftL >= 0)
	return this.lambda;
}

Colebrook.prototype.relativeRoughness = function(){
	return this.k / this.d;
}

Colebrook.prototype.inputString = function(){
	return this.d + " " + this.k + " " + this.re;
}

// Copyright engineeringtoolbox.com