PROGRAM IN C++ TO FIND THE HEIGHT AND DIAMETER OF COOLING TOWER
#include<iostream>
#include<conio.h>
#include<math.h>
#include<fstream.h>
using namespace std;
float H,i,h2,h3;
void PrintHeader()////////// Result printing routine
ofstream myfile ("Result.csv");
if (myfile.is_open())
{ myfile<<"t"<<","<<"H"<<endl<<endl;
myfile.close();
else cout << "Unable to open file";
void PrintValues()
{
ofstream myfile;
myfile.open("Result.csv", ios::out | ios::app);
if (myfile.is_open())
myfile <<i<<","<<H<<","<<endl;
myfile.close();
else cout << "Unable to open file";
void PrintHeader1()////////// Result printing routine
ofstream myfile ("Result1.csv");
if (myfile.is_open())
{ myfile<<"t"<<","<<","<<"H"<<","<<"h2"<<","<<"h3"<<endl<<endl;
myfile.close();
else cout << "Unable to open file";
void PrintValues1()
{
ofstream myfile;
myfile.open("Result1.csv", ios::out | ios::app);
if (myfile.is_open())
myfile<<i<<","<<","<<H<<","<<h2<<","<<h3<<endl;
myfile.close();
else cout << "Unable to open file";
int main(void){ float tl1,tl2,rh,ta1,k,pv,Y,p,to,H1,p1,m,cs,l,Gs,Vs,D,n,ar,t,s=0,h21,h22,NTOG,KYa,HT,x;
cout<<"\n ENTER THE INLET WATER TEMPERATURE IN DEGREE CELSIUS \n";
cin>>tl1;
cout<<"\nENTER THE OUTLET WATER TEMPERATURE IN DEGREE CELSIUS\n";
cin>>tl2;
cout<<"\n THE COOLING RANGE IS GIVEN AS\n";
cout<<(tl1-tl2);
cout<<" \nENTER THE VALUE OF REFERENCE TEMPERATURE IN DEGREE CELSIUS\n";
cin>>to;
cout<<"\n ENTER THE VALUE OF ATMOSHPHERIC PRESSURE IN BAR\n";
cin>>p;
PrintHeader();
for(i=tl2;i<=tl1+10;i++)
{ k=i+273;
pv=exp(13.8573-(5160.2/k));
Y=(pv/(p-pv))*(18.02/28.97);
H=2500*Y+(1.005+1.88*Y)*(i-to);
PrintValues();
cout<<"\nENTER THE PERCENTAGE SATURATION OF INLET AIR \n";
cin>>rh;
cout<<" \nENTER THE DRY BULB TEMPERATURE OF INLET AIR IN DEGREE CELSIUS\n";
cin>>ta1;
pv=exp(13.8573-(5160.2/(273+ta1)));
p1=rh*pv;
Y=(p1/(p-p1))*(18.02/28.97);
cs=4.187;
H1=2500*Y+(1.005+1.88*Y)*(ta1-to);
cout<<" \nHumidity of inlet air is \n";
cout<<Y<<"(kg water vapour)/(kg dry air)";
cout<<" \n The enthalpy of inlet air is\n";
cout<<H1<<"kJ/(kg dry air)";
cout<<"\n THE slope for minimum flow rate is given as from graph\n";
m=(163.044-H1)/(40-tl2);
cout<<"\n the minimum value of slope is\n"<<m;
/*IT is given that the flow rate is 1.45 times the minimum flowrate*/
cout<<" Enter the value of factor for actual gas flow rate\n";
cin>>n;
cout<<"\n the actual slope of the operating line is given as\n";
m=m/n;
cout<<m<<"\n";
cout<<"\n Enter the water flowrate value in m^3/(hr)\n";
cin>>l;
l=(l*1000)/3600;
Gs=(l*cs)/m;
cout<<" \n The Gas mass flow rate is\n";
cout<<Gs<<"kg/sec\n";
cout<<"\n Enter the superficial velocity of air in kg/(m^2sec)\n";
cin>>Vs;
ar=(Gs/Vs);
D=sqrt((4*ar)/3.14);
cout<<"\n The diameter of the tower is \n";
cout<<D<<" metre"<<endl;
PrintHeader1();
for(i=tl2;i<=tl1;i++)
{k=i+273;
pv=exp(13.8573-(5160.2/k));
Y=(pv/(p-pv))*(18.02/28.97);
H=2500*Y+(1.005+1.88*Y)*(i-to);
h2=m*(i-tl2)+H1;
cout<<h2<<endl;
h3=1/(H-h2);
PrintValues1();
if(i==tl2)
x=h3;
else
s=s+2*h3;
/* Using trapezoidal method of integration we have */
s=s-h3-x;
h21=m*(i-tl2)+H1;
h22=m*(i-(tl2+1))+H1;
NTOG=s*(h21-h22)/2;
cout<<"\n the number of transfer units are \n";
cout<<NTOG;
KYa=1.727*pow((Gs/ar),0.5);
cout<<" \n OVERALL GAS PHASE TRANSFER coefficient\n";
cout<<KYa<<"kg/(m^3.sec.delY)" ;
HT=Gs/(KYa*ar);
cout<<" \n the height of transfer unit is\n";
cout<<HT<<"metre"<<endl;
cout<<"\n Total height of tower is\n";
cout<<HT*NTOG<<"metre";
getch();
return 0;