// Pipe bends and thrust block forces 

function BendForce(rho, d, v, beta, p){
	this.rho = rho;
	this.d = d;
	this.v = v;
	this.beta = beta;
	this.p = p;
}

// returns forces
BendForce.prototype.forces = function(){
	var msg = "Forces due to mass flow and flow velocity: \n\n";
	var betaRad = this.beta / 180 * Math.PI;
	// Mass flow
	var m = Math.round(this.rho * this.v * Math.PI * Math.pow(this.d/2,2));
	msg += "Mass flow: " + m + " (kg/s) \n\n";
	// Rx due to flow
	var rx = Math.round(this.rho * Math.PI * Math.pow(this.d/2,2) * Math.pow(this.v,2) * (1 - Math.cos(betaRad)));
	msg += "Force in x-direction: " + rx + " (N) \n";
	// Ry due to flow
	var ry = Math.round(this.rho * Math.PI * Math.pow(this.d/2,2) * Math.pow(this.v,2) * (Math.sin(betaRad))); 
	msg += "Force in y-direction: " + ry + " (N) \n";
	// R due to flow
	var r = Math.round(Math.pow((Math.pow(rx,2) + Math.pow(ry,2)),0.5)); 
	msg += "Resulting force flow: " + r + " (N) \n\n\n";

	msg += "Forces due to pressure: \n";
	// Rpx due to pressure
	var rpx = Math.round(this.p * 1000 * Math.PI * Math.pow(this.d/2,2) * (1 - Math.cos(betaRad))); 
	msg += "Force in x-direction: " + rpx + " (N) \n";
	// Rpy due to pressure
	var rpy = Math.round(this.p * 1000 * Math.PI * Math.pow(this.d/2,2) * Math.sin(betaRad)); 
	msg += "Force in y-direction: " + rpy + " (N) \n";
	// Rp due to flow
	var rp = Math.round(Math.pow((Math.pow(rpx,2) + Math.pow(rpy,2)),0.5)); 
	msg += "Resulting force pressure: " + rp + " (N) \n\n\n";

	var rt = r + rp;
	msg += "Resulting force flow and pressure: " + rt + " (N) \n\n\n";
	return msg;
}

// returns input values
BendForce.prototype.inputValues = function(){
	var msg = this.rho + " " + this.d + " " + this.v + " " + this.beta + " " + this.p;
	return msg;
}

// Copyright engineeringtoolbox.com

