public class brayton_refrigeration
{
Gas1 g;
double P1,P2,P3,P4;
double T1,T2,T3,T4,T2i,T4i;
double h1,h2,h3,h4,h2i,h4i;
double s1,s2,s3,s4;
double Wturbin,Wkompresor,Wnet,Q_isitma,Q_sogutma,COP_isitma,COP_sogutma,etakompresor,etaturbin;
double m;
public brayton_refrigeration(double mi,double T1i,double P1i, double P2i, double T3i,double etakompresori,double etaturbini)
{
m=mi;
g=new Gas1("air");
g.mole=false;
etakompresor=etakompresori;
etaturbin=etaturbini;
T3=T3i;
// 1 noktası
T1=T1i;
P1=P1i;
P2=P2i;
P3=P2;
P4=P1;
double a1[]=g.property(T1,P1);
h1=a1[3];
s1=a1[5];
double pr1=a1[17];
System.out.println("t1="+T1+"h1="+h1+"s1="+s1);
// 2i noktası
double pr2=P2/P1*pr1;
T2i=g.Ti(pr2,P2);
double a2i[]=g.property(T2i,P2);
h2i=a2i[3];
double Cp2i=a2i[9];
System.out.println("t2i="+T2i+"h2i="+h2i+"pr2="+pr2);
// 2 noktası
h2=(h2i-h1)/etakompresor+h1;
T2=(h2i-h2)/Cp2i+T2i;
double a2[]=g.property(T2,P2);
s2=a2[5];
System.out.println("t2="+T2+"h2="+h2+"s2="+s2);
//3 noktası
double a3[]=g.property(T3,P3);
h3=a3[3];
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ı
T4i=g.Ti(pr4,P1);
double a4i[]=g.property(T4i,P1);
h4i=a4i[3];
double Cp4i=a4i[9];
System.out.println("t4i="+T4i+"h4i="+h4i+"Cp4i="+Cp4i);
//4 noktası
h4=h3-etaturbin*(h3-h4i);
T4=(h4-h4i)/Cp4i+T4i;
double a4[]=g.property(T4,P1);
s4=a4[5];
System.out.println("t4="+T4+"h4="+h4+"s4="+s4);
Wturbin=m*(h3-h4);
Wkompresor=m*(h2-h1);
Q_sogutma=m*(h1-h4);
Q_isitma=m*(h2-h3);
Wnet=Wkompresor-Wturbin;
COP_sogutma=Q_sogutma/Wnet;
COP_isitma=Q_isitma/Wnet;
}

public String toString()
{
String s=" Brayton soğutma çevrimi \n";
s+="Wturbin = "+Wturbin+"\n";
s+="Wkompresor = "+Wkompresor+"\n";	
s+="Wnet = "+Wnet+"\n";
s+="Q sogutma = "+Q_sogutma+"\n";
s+="Q ısıtma = "+Q_isitma+"\n";
s+="COP sogutma = "+COP_sogutma+"\n";
s+="COP ısıtma = "+COP_isitma+"\n";
s+="T1="+T1+" K\n";
s+="T2="+T2+" K\n";
s+="T2 isentropik="+T2i+" K\n";
s+="T3="+T3+" K\n";
s+="T4="+T4+" K\n";
s+="T4 isentropik="+T4i+" K\n";
s+="h1="+h1+" K\n";
s+="h2="+h2+" K\n";
s+="h2 isentropik="+h2i+" K\n";
s+="h3="+h3+" K\n";
s+="h4="+h4+" K\n";
s+="h4 isentropik="+h4i+" K\n";
s+="s1="+s1+" K\n";
s+="s2="+s2+" K\n";
s+="s3="+s3+" K\n";
s+="s4="+s4+" K\n";
return s;
}

}