// Fan and Pumps Affinity Laws 

function AffinityLaw(q1, dp1, P1, d1, n1){
	this.q1 = q1; // initial volume capacity
	this.dp1 = dp1; // initial head or pressure lift
	this.P1 = P1; // initial power consumption
	this.n1 = n1; // initial velocity - rpm
	this.d1 = d1; // initial diameter
}


// returns final volume capacity
AffinityLaw.prototype.q2 = function(v){
	var q2;
	if (this.n1 > 0) q2 = this.q1 * v/this.n1;
	if (this.d1 > 0) q2 = this.q1 * Math.pow(v/this.d1, 3);
	return q2;
}

// returns final volume capacity
AffinityLaw.prototype.dp2 = function(v){
	var dp2;
	if (this.n1 > 0) dp2 = this.dp1 * Math.pow(v/this.n1, 2);
	if (this.d1 > 0) dp2 = this.dp1 * Math.pow(v/this.d1, 2);
	return dp2;
}

// returns final volume capacity
AffinityLaw.prototype.P2 = function(v){
	var P2;
	if (this.n1 > 0) P2 = this.P1 * Math.pow(v/this.n1, 3);
	if (this.d1 > 0) P2 = this.P1 * Math.pow(v/this.d1, 5);
	return P2;
}

// returns input values
AffinityLaw.prototype.inputString = function(){
	return (this.q1 + " - " + this.dp1 + " - " + this.P1 + " - " + this.n1 + " - " + this.d1);
}


// Copyright engineeringtoolbox.com