// Cv calculator 

function Cv(q, sg, dp, pi, po, T){
	this.q = q*1; // flow 
	this.sg = sg*1; // specific gravity
	this.dp = dp*1; // pressure difference
	this.pi = pi*1; // inlet or upstream pressure
	this.po = po*1; // outlet or downstream pressure
	this.T = T*1; // temperature 

}

// liquid - flow volume - impererial
Cv.prototype.liq1 = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(this.q * Math.sqrt(this.sg/this.dp));
}
// liquid - flow volume - SI
Cv.prototype.liq1SI = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(11.7 * this.q * Math.sqrt(this.sg/this.dp));
}
// liquid - flow weight - impererial
Cv.prototype.liq2 = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(this.q /(500 * Math.sqrt(this.dp * this.sg)));
}
// liquid - flow weight - SI
Cv.prototype.liq2SI = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(5.32 * this.q /(500 * Math.sqrt(this.dp * this.sg)));
}
// steam - critical flow - imperial
Cv.prototype.steam1 = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(this.q /(1.61 * this.pi));
}
// steam - non critical flow - imperial
Cv.prototype.steam2 = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(this.q / (2.1 * Math.sqrt((this.pi + this.po) * (this.pi - this.po))));
}
// gas - critical flow - imperial
Cv.prototype.gas1 = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(this.q * Math.sqrt(this.sg * (this.T + 460)) / (660 * this.pi));
}
// gas - critical flow - imperial
Cv.prototype.gas2 = function(){
	Box.ajaxReq('/docs/scripts/conv.js',false);
	return Conv.rounding(this.q * Math.sqrt(this.sg * (this.T + 460))/(1360 * Math.sqrt((this.pi - this.po) * this.po)));
}
// returns values for all units
Cv.prototype.values = function(){
	var msg = this.q + " " 
		+ this.sg + " "
		+ this.dp + " "
		+ this.pi + " "
		+ this.po + " "
		+ this.T;
	return msg;
}

// Copyright engineeringtoolbox.com

