import java.io.*;

public class brayton
{
Gmix g;
double Wturbin,Wkompresor,Wnet,Q,eta;
public brayton(double m,double T1,double P1, double P2, double T3,double etakompresor,double etaturbin) throws IOException
{
g=new Gmix("air");
g.base("mass");
// 1 noktası
double P3=P2;
double a1[]=g.property(T1,P1);
double h1=a1[3];
double s1=a1[5];
double pr1=a1[17];
System.out.println("t1="+T1+"h1="+h1+"s1="+s1);
// 2i noktası
double pr2=P2/P1*pr1;
double T2i=g.Ti(pr2,P2);
double a2i[]=g.property(T2i,P2);
double h2i=a2i[3];
double Cp2i=a2i[9];
System.out.println("t2i="+T2i+"h2i="+h2i+"pr2="+pr2);
// 2 noktası
double h2=(h2i-h1)/etakompresor+h1;
double T2=(h2i-h2)/Cp2i+T2i;
double a2[]=g.property(T2,P2);
double s2=a2[5];
System.out.println("t2="+T2+"h2="+h2+"s2="+s2);
//3 noktası
double a3[]=g.property(T3,P3);
double h3=a3[3];
double s3=a3[5];
double pr3=a3[17];
System.out.println("pr3="+g.pr(T3));
double pr4=P1/P2*pr3;
System.out.println("t3="+T3+"h3="+h3+"s3="+s3+"pr3="+pr3+"pr4="+pr4);
//4i noktası
double T4i=g.Ti(pr4,P1);
double a4i[]=g.property(T4i,P1);
double h4i=a4i[3];
double Cp4i=a4i[9];
System.out.println("t4i="+T4i+"h4i="+h4i+"Cp4i="+Cp4i);
//4 noktası
double h4=h3-etaturbin*(h3-h4i);
double T4=(h4-h4i)/Cp4i+T4i;
double a4[]=g.property(T4,P1);
double s4=a4[5];
System.out.println("t4="+T4+"h4="+h4+"s4="+s4);
Wturbin=m*(h3-h4);
Wkompresor=m*(h2-h1);
Q=m*(h3-h2);
Wnet=Wturbin-Wkompresor;
eta=Wnet/Q;
}
public String toString()
{
String s=" Brayton çevrimi \n";
s+="Wturbin = "+Wturbin+"\n";
s+="Wkompresor = "+Wkompresor+"\n";	
s+="Wnet = "+Wnet+"\n";
s+="Q = "+Q+"\n";
s+="eta = "+eta+"\n";
return s;
}

}