// Logarithmic Mean Temperature Difference 
// Aritmetic Mean Temperature Difference 

function TemperatureDifference(tpi, tpo, tsi, tso, f){
	this.tpi = tpi; // entering temperature primary fluid
	this.tpo = tpo; // exit temperature primary fluid
	this.tsi = tsi; // entering temperature secondary fluid
	this.tso = tso; // exit temperature secondary fluid
	this.dto; // exit primary secondary fluid temperature differance
	this.dti; // inlet primary secondary fluid temperature differance
	if (f == "c") {
		this.dto = tpo - tsi; 
		this.dti = tpi - tso; 
	} 
	if (f == "p") {
		this.dto = tpo - tso; 
		this.dti = tpi - tsi; 
	}
}

// returns Logarithmic Mean Temperature Difference LMTD
TemperatureDifference.prototype.lmtd = function(){
	return (this.dto - this.dti)/Math.log(this.dto/this.dti);
}
// returns Aritmetic Mean Temperature Difference AMTD 
TemperatureDifference.prototype.amtd = function(){
	return ((this.tpi + this.tpo)/2 - (this.tsi + this.tso)/2);
}

// returns input values
TemperatureDifference.prototype.inputString = function(){
	return (this.tpi + " - " + this.tpo + " - " + this.tsi + " - " + this.tso + " - " + this.f);
}


// Copyright engineeringtoolbox.com