import java.io.*;
import javax.swing.*;

class LeeKeslerTest4
{
 public static void main(String s[]) throws IOException
 {
   //Text cin=new Text();
   String gasname;
   //System.out.print("gasname = ");
   //gasname=JOptionPane.showInputDialog("gasname = ");
   LeeKesler x=new LeeKesler("H2",1);
   //cubicEquationofState x=new cubicEquationofState(gasname,1,"Peng Robinson");
    System.out.println("equation of state name   = "+x.GasEquation);
   System.out.println("gas name   = "+x.Name);
   double T[]=new double[20];
   double P[]=new double[500];
   double V[]=new double[500];
   double Tr[]=new double[20];
   double Pr[]=new double[500];
   double Vr[]=new double[500];
   double Z[]=new double[500];
   double pp1=0;
   double R=8314.5e-5;
    double tr[]={1.0,1.05,1.10,1.15,1.2,1.3,1.4,1.5,1.6,1.8,2.0,2.5,3.0,3.5};
    int m=tr.length;
    int i=0;
    int n=500;
    T[i]=x.Tc*tr[0];
    Tr[i]=T[i]/x.Tc;
    //System.out.println( T[i]);
      for(int j=0;j<n;j++)
      {  pp1=1.0/100*j+0.01;
	   P[j]=pp1*x.Pc;
	   Pr[j]=pp1;
	   //System.out.println( P[j]);
       V[j]=x.V_TP_LK_V(T[i],P[j]);
       Z[j]=P[j]*V[j]/(R*T[i]);
       Vr[j]=V[j]/x.Vc;
       System.out.println( Z[j]+" "+Tr[i]+" "+Pr[j]+" "+V[j]);
       }
    Plot pp=new Plot(Pr,Z);
      //pp.addData(Vr,Z,1,0,0,255);
    for(i=1;i<m;i++)
      {T[i]=x.Tc*tr[i];
       Tr[i]=T[i]/x.Tc;
      for(int j=0;j<n;j++)
      {  pp1=1.0/100*j+0.01;
	   P[j]=pp1*x.Pc;
	   Pr[j]=P[j]/x.Pc;
	   //System.out.println( P[j]);
       V[j]=x.V_TP_LK_V(T[i],P[j]);
       Vr[j]=V[j]/x.Vc;
       Z[j]=P[j]*V[j]/(R*T[i]);
       System.out.println( Z[j]+" "+Tr[i]+" "+Pr[j]+" "+Vr[j]);
       }
      pp.addData(Pr,Z); 
      //pp.addData(Vr,Z,1,0,0,255);
      }
   pp.plot();
 }
}
