import javax.swing.*;
public class rankinecycle
{
// steam sınıfını kullanır
// çağrı
// steam b=new steam();
// double a[]=b.property("tp",30.0,1.01325);
// girdi parametreleri
// termodinamik set "tv" "tp" "th" "tu" "ts"tx"
//                  "pv" "pt" "ph" "pu" "ps" "px"
// çıkış parametreleri(a) 
// a[0]=P a[1]=T a[2]=V a[3]=h
// a[4]u a[5]=s a[6]=x
// double a1[]=b.property("tp",T[1],P[1]);
double T[];//derece C
double P[];//bar
double h[];//kJ/kg
double s[];//kJ/kgK
double v[];//m^3/kg
double x[];//kg buhar/kg toopklam

double etait,etaip;//pompa ve türbin verimleri
double etacevrim,etaisi,etatoplam;
double m;//kg/s
double Wt,Wp,W;//iş
double Qkazan,Qyogusturucu;
steam b;
public rankinecycle(double mi,double T1,double P1,double P2,double etaiti,double etaipi)
{etait=etaiti;
 etaip=etaipi;
 T=new double[6];
 P=new double[6];
 h=new double[6];
 s=new double[6];
 x=new double[6];
 v=new double[6];
 T[1]=T1;
 P[1]=P1;
 m=mi;
 b=new steam();
 double a1[]=b.property("tp",T[1],P[1]);
 h[1]=a1[3];
 s[1]=a1[5];
 s[0]=s[1];
 P[0]=P2;
 double a0[]=b.property("ps",P[0],s[0]);
 T[0]=a0[1];
 h[0]=a0[3];
 h[2]=h[1]-(h[1]-h[0])*etait;
 System.out.println("h2="+h[2]+"h0="+h[0]+"h1="+h[1]);
 P[2]=P2;
 double a2[]=b.property("ph",P[2],h[2]);
 T[2]=a2[1];
 s[2]=a0[5];
  P[3]=P2;
  x[3]=0.0;
 double a3[]=b.property("px",P[3],x[3]);
 T[3]=a3[1];
 s[3]=a3[5];
 s[5]=s[3];
 P[5]=P1;
 v[3]=a3[2];
 double a5[]=b.property("ps",P[5],s[5]);
 T[5]=a5[1];
 h[5]=a5[3];
 h[4]=h[3]+(h[5]-h[3])/etaip;
 P[4]=P1;
 double a4[]=b.property("ph",P[4],h[4]);
 T[4]=a4[1];
 Wt=m*(h[1]-h[2]);
 Wp=m*(h[4]-h[3]);
 W=Wt-Wp;
 Qkazan=m*(h[1]-h[4]);
 etacevrim=W/Qkazan;
}
public String toString()
{String s1="Simple Rankine Cycle\n";
 s1+="etait="+etait+"etaip="+etaip+"\n";
 s1+="T1="+T[1]+"derece C"+"P1="+P[1]+"bar h = "+h[1]+"s="+s[1]+"\n";
 s1+="T2="+T[2]+"derece C"+"P2="+P[2]+"bar h = "+h[2]+"s="+s[2]+"\n";
 s1+="T3="+T[3]+"derece C"+"P3="+P[3]+"bar h = "+h[3]+"s="+s[3]+"\n";
 s1+="T4="+T[4]+"derece C"+"P4="+P[4]+"bar h = "+h[4]+"s="+s[4]+"\n";
 s1+="etacavrim="+etacevrim+"\n";
 s1+="Wnet="+W+"\n";
 s1+="Wturbine="+Wt+"\n";
 s1+="Wpompa="+Wp+"\n";
 s1+="Qkazan="+Qkazan+"\n";
 return s1; 
}
public static void main(String arg[])
{rankinecycle r=new rankinecycle(1.0,900.0,50.0,0.1,0.9,0.9);
System.out.println(r.toString());
}
}