//package Lee_Kesler_Mix;
// ==============================================================
// File Name    : LeeKeslerMix.java
// Author       : Dr. Turhan Coban
// TUBİTAK Marmara Research Center
// Energy Systems and Environmental Research Institute
// email : Turhan.Coban@posta.mam.gov.tr
// Description  : This file contains class LeeKeslerMix which  calculates
// thermophysical properties of mixture of real fluids.

// DATA FILE DEFINATION
// gas mixture definations are given the data file "RealGasMix.txt"
// if gas mixture data is not given in the RealGasMix.txt user can be add
// his own data to the file which has the following format
//------------------
// gmixName
// ngas
// gname_0 N_0
// .........
// gname_ngas-1 N_ngas-1
//-------------------
//============================================================
//  VARIABLE IDENTIFICATION

import java.io.*;
import java.util.*;
//import Lee_Kesler_Base.*;

// ==============================================================

class LeeKeslerMix extends absfluid
{
// this class calculates real fluid thermodynamic
// properties when the real fluid constitutes of
// several single gases
        public int ngas;          // number of simple fluids inside of the fluid mixture
        LeeKesler  gasList[];     //list of the component real fluids
        BufferedReader cfin;
        double Tb_start,Tb_end;
        double N;        
        int natom;           
        public String GasEquation;  
        public Atom atomList[];   
        public  String Formula,Name;   
        public double M,MolWt,Tfp,Tb,Tc,Pc,Vc,Zc,Omega,Dipm;//Tb normal bolilng point  
        public double pro[]=new double[16]; 
        //public Object prop[]=new double[10];
        public double CPC[]=new double[4];  
        public double VPC[]=new double[4];   
        public double DELHF,DELGF,DELS0,DELHO;  
        public int VPEq;  
        public double Tmin,Tmax,LDEN,TDEN;  
        public  int ierror;
        public double R=8314.5; //(J/kmolK)
//=======================================================================
// constructor methods :
//========definations of class LeeKeslerMix =============================

	
        public LeeKeslerMix(String name) throws IOException{  
// class mixed real fluid construction function  
// this function reads the initial real fluids	
// the mixture and their molar weight from  
// the file RealGasMix.txt and construct mixed gas
        int i,j;
        try{
       // cfin=new BufferedReader(new FileReader("data"+File.separator+ "RealGasMix.txt"));
        cfin=new BufferedReader(new FileReader("RealGasMix.txt"));
	      int ierror=1;
	      N=0;
	      M=0;
        natom=0;
        ngas=0;
      	try{
      	   while(cfin!=null){
      	      Name=Text.readString(cfin);
       	      if(Name.equals(name)) { ierror=0; break;}
           } //end of while
           }catch(EOFException e_eof)
              {
              System.out.println("errori required gas mixture "+name+" is not found");
              cfin.close();
              return;
              }
           ngas=Text.readInt(cfin);
           gasList=new LeeKesler[ngas];
           String pgasName;
           double ppercent;
      	   for(i=0;i<ngas;i++)
           {
              try {
              pgasName=Text.readString(cfin);
              ppercent=Text.readDouble(cfin);
              gasList[i]=new LeeKesler(pgasName,ppercent);
              N+=gasList[i].N;
              M+=gasList[i].N*gasList[i].M;
                 }  catch(IOException ioe)
                 { System.out.println("IOException");
                   ierror=gasList[i].ierror;
                  } //end of for block
           }
      M=M/N;
      arrange_atoms();
      double Vcij[][]=new double[ngas][ngas];
      double Tcij[][]=new double[ngas][ngas];
      double kij;
      for(i=0;i<ngas;i++)
      {
        for(j=0;j<ngas;j++)
        {
         if(i==j)
         {
         Vcij[i][j]=gasList[i].Vc;
         Tcij[i][j]=gasList[i].Tc;
          }
         else
         {
         Vcij[i][j]=Math.pow((Math.pow(gasList[i].Vc,(1.0/3.0))+Math.pow(gasList[j].Vc,(1.0/3.0))),3.0)/8.0;
         kij=Math.sqrt(gasList[i].Vc*gasList[j].Vc)/Vcij[i][j];
         Tcij[i][j]=kij*Math.sqrt(gasList[i].Tc*gasList[j].Tc);
         }
         //System.out.println("kij "+kij+"i="+i+"j="+j+"Vcij="+Vcij[i][j]+"Tcij="+Tcij[i][j]);
        }
        //System.out.println(" ");
      }
      Tc=0;
      Vc=0;
      Omega=0;
      Pc=0;
      Tb=0;
      Tfp=0;
      for(i=0;i<ngas;i++)
      {
        for(j=0;j<ngas;j++)
        {
         Tc+=gasList[i].N*gasList[j].N/(N*N)*Math.pow(Vcij[i][j],(1.0/4.0))*Tcij[i][j];
         Vc+=gasList[i].N*gasList[j].N/(N*N)*Vcij[i][j];
         }
      }
      DELHF=0;
      DELGF=0;
      DELS0=0;
      LDEN=0;
      TDEN=0;
      for(i=0;i<ngas;i++)
      {
      Omega+=gasList[i].N/N*gasList[i].Omega;
      Tb+=gasList[i].N/N*gasList[i].Tb;
      Tfp+=gasList[i].N/N*gasList[i].Tfp;
      DELHF+=gasList[i].N/N*gasList[i].DELHF;
      DELGF+=gasList[i].N/N*gasList[i].DELGF;
      DELS0+=gasList[i].N/N*gasList[i].DELS0;
      LDEN+=gasList[i].N/N*gasList[i].LDEN;
      TDEN+=gasList[i].N/N*gasList[i].TDEN;
      }
      Tc/=Math.pow(Vc,(1.0/4.0));
      Pc=(0.2905-0.085*Omega)*R*Tc/Vc*1e-2;
      Zc=(Pc*1e5)*(Vc*1e-3)/(R*Tc);
      //System.out.println("Tc = "+Tc+"Pc = "+Pc+"Vc = "+Vc+"Omega = "+Omega+"Zc="+Zc);
      name=toString("name");
      Formula=toString("composition");
       } catch(FileNotFoundException fnfe) {System.out.println("File not found");}
      MolWt=M;
      Dipm=0;
      CPC[0]=CPC[1]=CPC[2]=CPC[3]=0;
      VPC[0]=VPC[1]=VPC[2]=VPC[3]=0;
      VPEq=4;
      // sort data
      for(int top=gasList.length-1;top>0;top--)
      {
        for(i=0;i<top;i++)
        {
        if(gasList[i+1].Tb < gasList[i].Tb)
           swap(i+1,i);
        }
      }
      Tb_start=gasList[0].Tb;
      Tb_end=gasList[ngas-1].Tb;
}

// ==============================================================



public String readGmixNames() throws IOException
{
    String temp=new String("");
    String pgasName;
    double ppercent;
    try{
      //cfin=new BufferedReader(new FileReader("data"+File.separator+ "RealGasMix.txt"));
      cfin=new BufferedReader(new FileReader("RealGasMix.txt"));
               try {
               while(cfin!=null)
	       {
	       temp=temp+Text.readString(cfin)+" ";
           ngas=Text.readInt(cfin);
                 for(int i=0;i<ngas;i++)
                 {
                 pgasName=Text.readString(cfin);
                 ppercent=Text.readDouble(cfin);
                 } //end of while
               }
               }  catch(EOFException e_eof)  {cfin.close();}
       }
       catch(FileNotFoundException fnfe) {System.out.println("File RealGasMix.txt not found");}
    return temp;
}



        public void swap(int i,int j){
// this method is used the swap two LeeKesler fluid with each other
            LeeKesler temp=new LeeKesler(gasList[i]);
            gasList[i]=new LeeKesler(gasList[j]);
            gasList[j]=new LeeKesler(temp);
}
        public void arrange_atoms() throws IOException{   
            int i,j;      
            for(i=0;i<ngas;i++) {
                for(j=0;j<gasList[i].natom;j++){ add_atom(i,j);}
            }
}
        public int  add_atom(int i,int j) throws IOException{
            int k;
            for(k=0;k<natom;k++){
                if(gasList[i].atomList[j].symbol.equals(atomList[k].symbol))
                {
                    atomList[k]=new Atom(atomList[k].symbol,atomList[k].N+gasList[i].atomList[j].N*gasList[i].N/N); 
                    return 1;  
                }
            }
            Atom atomL[];
            atomL=new Atom[natom+1];
            for(k=0;k<natom;k++)
                atomL[k]=new Atom(atomList[k]);
            atomL[natom]=new Atom(gasList[i].atomList[j].symbol,gasList[i].atomList[j].N*gasList[i].N/N);
            atomList=atomL;
            natom+=1;
            return 2;
}    
        
        
        /**
     * 
     * @param T =Tempreture  @K
     * @return x[0]=saturation temparature of  gas that start boiling last
     *              x[1]=index of this gas 
     */
        public double[] Tb_max(double P){
//maximum boiling point   
            //System.out.println("Tb_max :"+" P= "+P); 
            double x[]=new double[2]; 
            double Tbx;
            x[0]=0;   
            for(int k=0;k<ngas;k++){        
                if(P==gasList[k].Pc) Tbx=gasList[k].Tc;
                else if(P<gasList[k].Pc) Tbx= gasList[k].T_P_LK_SV(P);
                else Tbx=-1;  //GT-->LK       
                //System.out.println("k="+gasList[k].toString()+" "+Tbx+" Pc= "+gasList[k].Pc);        
                if(Tbx>x[0] && Tbx!=-1) {
                    x[0]=Tbx;
                    x[1]=k;
                }   
            } 
            //System.out.println("Tb_max bitti x[0]= "+x[0]+" x[1]= "+x[1]);  
            x[0]=x[0]==0 ? x[0]=-1 : x[0];
            return x;
}      
 		public double[] Tb_max(double P,LeeKesler[] igasList){
			//maximum boiling point  of array og gasses 
            //System.out.println("Tb_max :"+" P= "+P); 
            double x[]=new double[2]; 
            double Tbx;
            x[0]=0;   
            for(int k=0;k<ngas;k++){        
                if(P==igasList[k].Pc) Tbx=igasList[k].Tc;
                else if(P<igasList[k].Pc) Tbx= igasList[k].T_P_LK_SV(P);
                else Tbx=-1;  //GT-->LK       
                //System.out.println("k="+gasList[k].toString()+" "+Tbx+" Pc= "+gasList[k].Pc);        
                if(Tbx>x[0] && Tbx!=-1) {
                    x[0]=Tbx;
                    x[1]=k;
                }   
            } 
            //System.out.println("Tb_max bitti x[0]= "+x[0]+" x[1]= "+x[1]);  
            x[0]=x[0]==0 ? x[0]=-1 : x[0];
            return x;
}      
        /**
     * 
     * @param P =Pressure  @bar
     * @return x[0]=saturation temparature of  gas that start boiling first
     *              x[1]=index of this gas 
     */
        public double[] Tb_min(double P){
	//minimum boiling point
	//System.out.println("Tb_min :"+" P= "+P);
            double x[]=new double[2]; 
            double Tbx;
            x[0]=3000;
            for(int k=0;k<ngas;k++){ 
                   if(P==gasList[k].Pc) Tbx=gasList[k].Tc;
                else if(P<gasList[k].Pc) Tbx= gasList[k].T_P_LK_SV(P);
                else Tbx=-1;  //GT-->LK    
                //System.out.println("k="+gasList[k].toString()+" "+Tbx+" Pc= "+gasList[k].Pc);     
                if(Tbx<x[0] && Tbx!=-1){
                    x[0]=Tbx;
                    x[1]=k;
                }
            }
            //System.out.println("Tb_min bitti  x[0]= "+x[0]+" x[1]= "+x[1]);
            x[0]=x[0]==3000 ? x[0]=-1 : x[0];
            return x;
         
}  
		public double Tb_minA(double P){
			double x[]=new double[2];
			x=Tb_min(P);
			return x[0];
			
		}  
		public double Tb_maxA(double P){
			double x[]=new double[2];
			x=Tb_max(P);
			return x[0];
			
		} 
        /**
     * 
     * @param T =Tempreture  @K
     * @return x[0]=saturation pressure of  gas that start boiling first
     *             x[1]=index of this gas 
     */
        public double[] Pb_max(double T){
            double x[]=new double[2]; 
            x[0]=0;   
            double Pbx;
            for(int k=0;k<ngas;k++){       
                if(T==gasList[k].Tc) Pbx=gasList[k].Pc;
                else if(T<gasList[k].Tc) Pbx= gasList[k].P_T_LK_SV(T);
                else Pbx=-1;  //GT-->LK  
                //System.out.println("k="+gasList[k].toString()+" "+Pbx+" Tc= "+gasList[k].Tc+" T= "+T);                            
                if(Pbx>x[0] && Pbx!=-1 ) {
                    x[0]=Pbx;
                    x[1]=k;
                }  
            }   
            x[0]=x[0]==0 ? x[0]=-1 : x[0]; 
            return x;
}   
        /**
     * 
     * @param T =Tempreture  @K
     * @return x[0]=saturation pressure of  gas that start boiling last
     *              x[1]=index of this gas 
     */
        public double[] Pb_min(double T){            
            double x[]=new double[2];            
            x[0]=1000;           
            double Pbx;           
            for(int k=0;k<ngas;k++){                 
                if(T==gasList[k].Tc) Pbx=gasList[k].Pc;                
                else if(T<gasList[k].Tc) Pbx= gasList[k].P_T_LK_SV(T);
                else Pbx=-1;  //GT-->LK  
                //System.out.println("k="+gasList[k].toString()+" "+Pbx+" Tc= "+gasList[k].Tc);             
                if(Pbx<x[0] && Pbx!=-1 && Pbx!=0){
                    x[0]=Pbx;
                    x[1]=k;
                }
            }
            x[0]=x[0]==1000 ? x[0]=-1 : x[0]; 
            return x;
         
		}
		
		public double Pb_minA(double T){
			double x[]=new double[2];
			x=Pb_min(T);
			return x[0];
			
		}  
		public double Pb_maxA(double T){
			double x[]=new double[2];
			x=Pb_max(T);
			return x[0];
			
		}
		       
        public double Tc_max(){            
            double Tcx;
            Tc=0;   
            for(int k=0;k<ngas;k++){        
               Tcx=gasList[k].Tc;
                if(Tcx>Tc) {
                    Tc=Tcx;
                }   
            }   
            return Tc;
         }          
        public double Pc_max( ){            
            double Pcx;
            Pc=0;   
            for(int k=0;k<ngas;k++){        
               Pcx=gasList[k].Pc;
                if(Pcx>Pc) {
                    Pc=Pcx;
                }   
            }   
            return Pc;
         }
        //PvT properties of mixture              
    
        /**
     * 
     * @param T =Tempareture @K
     * @param P =ressure @bar
     * @return v=specific volume calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */      
        public double V_TP_LK_MV(double T,double P){
            double vm=0;              
            for(int i=0;i<ngas;i++)	 
                vm+=gasList[i].V_TP_LK_V(T,P)*gasList[i].N;                  
            return vm/N;
        }          
        /**
     * 
     * @param T =Tempareture @K
     * @param v =specific volume @m3/kmol
     * @return P=pressure calculated by using Lee-Kesler method for each gas in mixture @bar
     */       
        public double P_TV_LK_MV(double T,double V){
            double Pm=0;  
            for(int i=0;i<ngas;i++)	 
                Pm+=gasList[i].P_TV_LK_V(T,V)*gasList[i].N;                  
            return Pm/N;
        }     
        /**
     * 
     * @param T=Temperature @K 
     * @param P =Pressure @bar
     * @return Z compressibility factor
     */
        public double Z_TP_LK_MV(double T,double P){
            return V_TP_LK_MV(T,P)*P*1e5/(R*T);            
        }        
        /**
     * 
     * @param T=Temperature @K 
     * @param V =volume  @m3/kg
     * @return Z compressibility factor
     */
        public double Z_TV_LK_MV(double T,double V){
            return P_TV_LK_MV(T,V)*V*1e5/(R*T);         
        }
        /**
     * 
     * @param T =Tempareture @K
     * @param P =ressure @bar
     * @return v=specific volume calculated by using Lee-Kesler method for each liquid in mixture @kj/kmol
     */      
        public double V_TP_LK_ML(double T,double P){
            double vm=0;  
            for(int i=0;i<ngas;i++)	 
                vm+=T<gasList[i].Tc ? gasList[i].V_TP_LK_L(T,P)*gasList[i].N: gasList[i].V_TP_LK_V(T,P)*gasList[i].N ;                  
            return vm/N;
        }          
        /**
     * 
     * @param T =Tempareture @K
     * @param v =specific volume @m3/kmol
     * @return P=pressure calculated by using Lee-Kesler method for each liquid in mixture @bar
     */       
        public double P_TV_LK_ML(double T,double V){
            double Pm=0;
            double P=0;  
            double Vi=0;
            //System.out.println("T= "+T+ " V= "+V);
            //for(int i=0;i<ngas;i++) System.out.println(gasList[i].Formula);
            for(int i=0;i<ngas;i++){	
	            Vi=V*gasList[i].N/N; 
	            //System.out.println(gasList[i].Formula+" "+" Vi= "+Vi);
	            ///System.out.println("gasList[i].P_TV_LK_L("+T+","+Vi+")");
                P= T<gasList[i].Tc ? gasList[i].P_TV_LK_L(T,Vi)*gasList[i].N:0;//gasList[i].P_TV_LK_V(T,V)*gasList[i].N;                 
                //System.out.println("gasList[i].P_TV_LK_L("+T+","+Vi+")= "+gasList[i].P_TV_LK_L(T,V)+" P= "+P+"  "+gasList[i].Formula+" "+gasList[i].Tc);
                Pm+=P;
            }
            return Pm/N;
        }                   
        /**
     * 
     * @param T=Temperature @K 
     * @param P =Pressure @bar
     * @return Z compressibility factor for liquid phase
     */
        public double Z_TP_LK_ML(double T,double P){
            return V_TP_LK_ML(T,P)*P*1e5/(R*T);
            
        }        
        /**
     * 
     * @param T=Temperature @K 
     * @param V =volume  @m3/kg
     * @return Z compressibility factor for liquid phase
     */
        public double Z_TV_LK_ML(double T,double V){
            return P_TV_LK_ML(T,V)*V*1e5/(R*T);            
        }        
        public double V_TP_LK_MLV(double T,double P){
           double V=0;
           for(int i=0;i<ngas;i++){
               V+=T<gasList[i].T_P_LK_SV(P) ? gasList[i].V_TP_LK_L(T,P)*gasList[i].N: 0;
              // V+=T==gasList[i].T_P_LK_SV(P) ? 0:0;
               V+=T>=gasList[i].T_P_LK_SV(P) ? gasList[i].V_TP_LK_V(T,P)*gasList[i].N: 0;
           }      
           return V/N;
        }           
        public double P_TV_LK_MLV(double T,double Vi){
           double P=0;
           for(int i=0;i<ngas;i++){
               if(Vi > gasList[i].V_T_LK_SL(T))   P+=gasList[i].P_TV_LK_L(T,Vi);
               else if(Vi>gasList[i].V_T_LK_SV(T) && Vi<gasList[i].V_T_LK_SL(T)) P+=gasList[i].P_T_LK_SV(T);
               else if(Vi<gasList[i].V_T_LK_SV(T)) P+=gasList[i].P_TV_LK_V(T,Vi);              
           }      
           return P;
        }         
        public double V_T_LK_MSL(double T){              
            double xi[]=new double[2];
            xi=Pb_max(T);
            double P=xi[0];
            double VV=0;  
            double v=0;     
            for(int i=0;i<ngas;i++) {                   
                   v= i==xi[1] ? gasList[i].V_P_LK_SL(P)*gasList[i].N : gasList[i].V_TP_LK_L(T,P)*gasList[i].N;  
                   //System.out.println(gasList[i].Formula+" "+" v= "+v);
                   VV+=v; 
            }                           
            return VV/N;           
        }             
        public double V_T_LK_MSV(double T){                              
            double xi[]=new double[2];
            xi=Pb_min(T);
            double P=xi[0];
            double VV=0; 
	        double v=0;     
            for(int i=0;i<ngas;i++) {                   
                   v= i==xi[1] ? gasList[i].V_P_LK_SV(P)*gasList[i].N : gasList[i].V_TP_LK_V(T,P)*gasList[i].N;  
                    //System.out.println(gasList[i].Formula+" "+" v= "+v);
                   VV+=v;                
            }                           
            return VV/N;           
        }   
        
        public double P_T_LK_MSL(double T){              
            double xi[]=new double[2];
            xi=Pb_max(T);
            double P=xi[0];
            double PP=0;
            int q=(int)xi[1];
            double V=gasList[q].V_T_LK_SL(T);             
            for(int i=0;i<ngas;i++) {                   
                   PP+= i==xi[1] ? gasList[i].P_T_LK_SV(T)*gasList[i].N : gasList[i].P_TV_LK_L(T,V)*gasList[i].N;   
            }                           
            return PP/N;           
        } 
        
                   
        public double P_T_LK_MSV(double T){              
            double xi[]=new double[2];
            xi=Pb_min(T);
            double P=xi[0];
            double PP=0;
            int q=(int)xi[1];
            double V=gasList[q].V_T_LK_SV(T);             
            for(int i=0;i<ngas;i++) {                   
                   PP+= i==xi[1] ? gasList[i].P_T_LK_SV(T)*gasList[i].N : gasList[i].P_TV_LK_V(T,V)*gasList[i].N;   
            }                           
            return PP/N;           
        }
        public double T_P_LK_MSL(double P){              
            double xi[]=new double[2];
            xi=Tb_min(P);
            double T=xi[0];
            double TT=0;            
            return T;           
        }            
        public double T_P_LK_MSV(double P){              
            double xi[]=new double[2];
            xi=Tb_max(P);
            double T=xi[0];
            double TT=0;            
            return T;           
        }
         
        //Thermodynamic properties        
        //Boiling starting point and ending point properties     
        
        public double h_P_LK_MSL(double P){              
            double xi[]=new double[2];
            xi=Tb_min(P);           
            double T=xi[0];
            double HH=0; 
            double h=0;      
            for(int i=0;i<ngas;i++) {                   
                   /*h= i==xi[1] ? gasList[i].h_P_LK_SL(P)*gasList[i].N :(T<gasList[i].Tc ?gasList[i].h_TP_LK_L(T,P)*
                   gasList[i].N :gasList[i].h_TP_LK_V(T,P)*gasList[i].N )   ;     */
                   if(i==xi[1]){
	                	h=gasList[i].h_P_LK_SL(P)*gasList[i].N ;
	                	//System.out.println(gasList[i].Formula+" h_P_LK_SL("+P+")= "+gasList[i].h_P_LK_SL(P));   
                   }     
                   else{
	                	if(T<gasList[i].Tc){
		                	h=gasList[i].h_TP_LK_L(T,P)*gasList[i].N;
		                	//System.out.println(gasList[i].Formula+" h_TP_LK_L("+T+","+P+")= "+gasList[i].h_TP_LK_L(T,P));	
	                	}
	                	else{
		                	h=gasList[i].h_TP_LK_V(T,P)*gasList[i].N;
		                	//System.out.println(gasList[i].Formula+" h_TP_LK_V("+T+","+P+")= "+gasList[i].h_TP_LK_V(T,P));	
	                	}
	                	   
                   }          
                   HH+=h;
            }                           
            return HH/N;            
        }        
        public double h_P_LK_MSV(double P){              
            double xi[]=new double[2];
            xi=Tb_max(P);
            double T=xi[0];
            double HH=0;       
            for(int i=0;i<ngas;i++) {                   
                   HH+= i==xi[1] ? gasList[i].h_P_LK_SV(P)*gasList[i].N : gasList[i].h_TP_LK_V(T,P)*gasList[i].N;   
            }                           
            return HH/N;            
        }         
        public double h_T_LK_MSL(double T){              
            double xi[]=new double[2];
            xi=Pb_max(T);            
            double P=xi[0];
            //System.out.println("P="+P+"  "+xi[1]);
            double HH=0;  
            double h=0; 
            //System.out.println(" h_T_LK_MSL("+T+")=");        
            for(int i=0;i<ngas;i++) {                
                   /*h= i==xi[1] ? gasList[i].h_P_LK_SL(P)*
                   gasList[i].N : (T<gasList[i].Tc ? gasList[i].h_TP_LK_L(T,P)*
                   gasList[i].N :gasList[i].h_TP_LK_V(T,P)*gasList[i].N ); */
                   //System.out.println(gasList[i].Formula);
                   if(i==xi[1]){
	               		h=gasList[i].h_P_LK_SL(P)*gasList[i].N; 
	               		//System.out.println("gasList[i].h_P_LK_SL(P)= "+gasList[i].h_P_LK_SL(P));
                   } 
                   else{
	               		if(T<gasList[i].Tc){
		               		h=gasList[i].h_TP_LK_L(T,P)*gasList[i].N;
		               		//System.out.println("gasList[i].h_TP_LK_L(T,P)= "+gasList[i].h_TP_LK_L(T,P));	
	               		}
	               		else{
		               		h=gasList[i].h_TP_LK_V(T,P)*gasList[i].N;	
		               		//System.out.println("gasList[i].h_TP_LK_V(T,P)= "+gasList[i].h_TP_LK_V(T,P));
	               		}   
                   }
                   System.out.println(gasList[i].Formula+"  h= "+h+" "+i);
                   HH+=h; 
            }                           
            return HH/N;            
        }       
        public double h_T_LK_MSV(double T){              
            double xi[]=new double[2];
            xi=Pb_min(T);
            double P=xi[0];
            double HH=0; 
            double h=0;
            //System.out.println(" h_T_LK_MSV("+T+")=");      
            for(int i=0;i<ngas;i++) {                   
                   h= i==xi[1] ? gasList[i].h_P_LK_SV(P)*gasList[i].N : gasList[i].h_TP_LK_V(T,P)*gasList[i].N;  
                   //System.out.println("h= "+h+" "+i);
                   HH+=h;  
            }                           
            return HH/N;            
        }
        public double h_TP_LK_MLV(double T,double P){            
           int ngasOverC=0;         
           int ngasSubC=0;
           LeeKesler[] gasOverCList;
           LeeKesler[] gasSubCList;
           for(int i=0;i<ngas;i++){
	        	if(T<gasList[i].Tc){
		        	ngasSubC++;		
	        	} 
	        	else{
		        	ngasOverC++;	
	        	}  
           }
           gasOverCList=new LeeKesler[ngasOverC];
           gasSubCList=new LeeKesler[ngasSubC];
           int j=0,k=0;
           for(int i=0;i<ngas;i++){
	        	if(T<gasList[i].Tc){		        	
		        	gasSubCList[j]=new LeeKesler(gasList[i].Name);
		        	gasSubCList[j].N=gasList[i].N;	
		        	j++;
	        	} 
	        	else{
		        	gasOverCList[k]=new LeeKesler(gasList[i].Name);	
		        	gasOverCList[j].N=gasList[i].N;
		        	k++;	
	        	}  
           }   
           double H=0;
           double[] xi=Tb_max(P);
           for(int i=0;i<ngasOverC;i++){
	        	H+=gasOverCList[i].h_TP_LK_V(T,P)*gasOverCList[i].N;   
           }   
           for(int i=0;i<ngasSubC;i++){
	        	if(i==xi[1]){
	               		H=gasList[i].h_P_LK_SL(P)*gasSubCList[i].N; 
	               		//System.out.println("gasList[i].h_P_LK_SL(P)= "+gasList[i].h_P_LK_SL(P));
                   } 
                   else{               		
		               	H=gasList[i].h_TP_LK_L(T,P)*gasSubCList[i].N;		               	
                   }
           }              
           return H/N;
        }         
        public double s_T_LK_MSL(double T){              
            double xi[]=new double[2];
            xi=Pb_max(T);
            double P=xi[0];
            double SS=0;       
            for(int i=0;i<ngas;i++) {                   
                   SS+= i==xi[1] ? gasList[i].s_P_K_SL(P)*gasList[i].N : (T<gasList[i].Tc ? gasList[i].s_TP_LK_L(T,P)*gasList[i].N :gasList[i].s_TP_LK_V(T,P)*gasList[i].N);   
            }                           
            return SS/N;            
        }               
        public double s_P_LK_MSL(double P){              
            double xi[]=new double[2];
            xi=Tb_min(P);
            double T=xi[0];
            double HH=0;       
            for(int i=0;i<ngas;i++) {                   
                   HH+= i==xi[1] ? gasList[i].s_P_K_SL(P)*gasList[i].N :  (T<gasList[i].Tc ? gasList[i].s_TP_LK_L(T,P)*gasList[i].N :gasList[i].s_TP_LK_V(T,P)*gasList[i].N)   ;   
            }                           
            return HH/N;            
        }        
        public double s_T_LK_MSV(double T){              
            double xi[]=new double[2];
            xi=Pb_min(T);
            double P=xi[0];
            double SS=0;       
            for(int i=0;i<ngas;i++) {                   
                   SS+= i==xi[1] ? gasList[i].s_P_K_SV(P)*gasList[i].N : gasList[i].s_TP_LK_V(T,P)*gasList[i].N;   
            }                           
            return SS/N;            
        }               
        public double s_P_LK_MSV(double P){              
            double xi[]=new double[2];
            xi=Tb_max(P);
            double T=xi[0];
            double SS=0;       
            for(int i=0;i<ngas;i++) {                   
                   SS+= i==xi[1] ? gasList[i].s_P_K_SV(P)*gasList[i].N : gasList[i].s_TP_LK_V(T,P)*gasList[i].N;   
            }                           
            return SS/N;            
        }
         public double s_TP_LK_MLV(double T,double P){            
           double SS=0;
           for(int i=0;i<ngas;i++){
               SS+=T<gasList[i].T_P_LK_SV(P) ? gasList[i].s_TP_LK_L(T,P)*gasList[i].N: 0;
              // V+=T==gasList[i].T_P_LK_SV(P) ? 0:0;
               SS+=T>=gasList[i].T_P_LK_SV(P) ? gasList[i].s_TP_LK_V(T,P)*gasList[i].N: 0;
           }      
           return SS/N;
        }
        //Gas phase        
          
         /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  h=Enthalpy calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */        
         public double  h_TP_LK_MV(double T,double P){    
              double HH=0;                
              for(int i=0;i<ngas;i++)	             
              HH+=gasList[i].h_TP_LK_V(T,P)*gasList[i].N;
              return HH/N;
   }             
         public double  h_TV_LK_MV(double T,double V){    
              double HH=0;
              double P=P_TV_LK_MV(T,V);
              for(int i=0;i<ngas;i++)	             
              HH+=gasList[i].h_TP_LK_V(T,P)*gasList[i].N;
              return HH/N;
   }      
         
             
         /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  ht= chemical enthalpy  calculated by using Lee-Kesler method for each gas in mixture @kj/kmo
     */          
          public double ht_TP_LK_MV(double T,double P){
              double HHt=0;  
              for(int i=0;i<ngas;i++)	
              HHt+=(gasList[i].h_TP_LK_V(T,P)+gasList[i].DELHF)*gasList[i].N;
              return HHt/N;
          }      
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  H= enthalpy  of mixture @Kj
     */
          public double  H_TP_LK_MV(double T,double P) {     
              return h_TP_LK_MV(T,P)*N;
          }       
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  H=chemical enthalpy  of mixture @Kj
     */
          public double  Ht_TP_LK_MV(double T,double P) {     
              return ht_TP_LK_MV(T,P)*N;
          }
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  u=internal energy  per mole @Kj/kmol
     */          
          public double  u_TP_LK_MV(double T,double P){    
              double UU=0;                
              for(int i=0;i<ngas;i++)	             
              UU+=gasList[i].u_TP_LK_V(T,P)*gasList[i].N;
              return UU/N;
   }       
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  s=Entropy calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */
          public double  s_TP_LK_MV(double T,double P){    
              double Sm=0;                
              for(int i=0;i<ngas;i++)	             
              Sm+=gasList[i].s_TP_LK_V(T,P)*gasList[i].N;
              return Sm/N;
   }   
          public double  s_TV_LK_MV(double T,double V){    
              double Sm=0;   
              double P=P_TV_LK_MV(T,V);
              for(int i=0;i<ngas;i++)	             
              Sm+=gasList[i].s_TP_LK_V(T,P)*gasList[i].N;
              return Sm/N;
   }  
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  S=Entropy of mixture @kj/kmol
     */
          public double  S_TP_LK_MV(double T,double P){    
           return s_TP_LK_MV(T,P);
   }   
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  g=Gibbs energy calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */        
          public double  g_TP_LK_MV(double T,double P){    
              double G=0;                
              for(int i=0;i<ngas;i++)	             
              G+=(gasList[i].h_TP_LK_V(T,P)-T*gasList[i].s_TP_LK_V(T,P))*gasList[i].N;
              return G/N;
   }        
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  g=Chemical Gibbs energy calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */
          public double  gt_TP_LK_MV(double T,double P){    
              double Gt=0;                
              for(int i=0;i<ngas;i++)	             
              Gt+=(gasList[i].h_TP_LK_V(T,P)+gasList[i].DELHF-T*gasList[i].s_TP_LK_V(T,P))*gasList[i].N;
              return Gt/N;
   }   
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  g=Chemical Gibbs energy calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */         
          public double  G_TP_LK_MV(double T,double P){                
              return g_TP_LK_MV(T,P)*N;
   }               
          
          //Liquid phase     
        
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  h=Enthalpy calculated by using Lee-Kesler method for each liquid in mixture @kj/kmol
     */
          public double  h_TP_LK_ML(double T,double P){    
              double HH=0;  
              double h=0;              
              for(int i=0;i<ngas;i++){	             
              h=gasList[i].h_TP_LK_L(T,P)*gasList[i].N;              
              HH+=h;
          }
              return HH/N;
   }   
          public double  h_TV_LK_ML(double T,double V){    
              double HH=0;    
              double P=P_TV_LK_ML(T,V);
              for(int i=0;i<ngas;i++)	             
              HH+=gasList[i].h_TP_LK_L(T,P)*gasList[i].N;
              return HH/N;
   }   
     public double  u_TV_LK_ML(double T,double V){    
              double HH=0;    
              double P=P_TV_LK_ML(T,V);
              for(int i=0;i<ngas;i++)	             
              HH+=gasList[i].u_TP_LK_L(T,P)*gasList[i].N;
              return HH/N;
   }   
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  ht= chemical enthalpy  calculated by using Lee-Kesler method for each liquid in mixture @kj/kmo
     */
          public double ht_TP_LK_ML(double T,double P){
              double HHt=0;  
              for(int i=0;i<ngas;i++)	
              HHt+=(gasList[i].h_TP_LK_L(T,P)+gasList[i].DELHF)*gasList[i].N;
              return HHt/N;
          }      
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  H= enthalpy  of mixture @Kj
     */
          public double  H_TP_LK_ML(double T,double P) {     
              return h_TP_LK_ML(T,P)*N;
          }       
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  H=chemical enthalpy  of mixture @Kj
     */
          public double  Ht_TP_LK_ML(double T,double P) {     
              return ht_TP_LK_ML(T,P)*N;
          }
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  u=internal energy  per mole @Kj/kmol
     */          
          public double  u_TP_LK_ML(double T,double P){    
              double UU=0;   
              for(int i=0;i<ngas;i++){
                  UU+=(gasList[i].h_TP_LK_L(T,P)-P*gasList[i].V_TP_LK_L(T,P))*gasList[i].N; 
              }  
              return UU/N;
   }
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  s=Entropy calculated by using Lee-Kesler method for each liquid in mixture @kj/kmol
     */
          public double  s_TP_LK_ML(double T,double P){    
              double Sm=0;                
              for(int i=0;i<ngas;i++)	             
              Sm+=gasList[i].s_TP_LK_L(T,P)*gasList[i].N;
              return Sm/N;
   }   
          public double  s_TV_LK_ML(double T,double V){    
              double Sm=0;              
              double P=P_TV_LK_ML(T,V);
              for(int i=0;i<ngas;i++)	             
              Sm+=gasList[i].s_TP_LK_L(T,P)*gasList[i].N;
              return Sm/N;
   }  
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  S=Entropy of mixture @kj/kmol
     */
          public double  S_TP_LK_ML(double T,double P){    
           return s_TP_LK_ML(T,P);
   }   
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  g=Gibbs energy calculated by using Lee-Kesler method for each liquid in mixture @kj/kmol
     */        
          public double  g_TP_LK_ML(double T,double P){    
              double G=0;                
              for(int i=0;i<ngas;i++)	             
              G+=(gasList[i].h_TP_LK_L(T,P)-T*gasList[i].s_TP_LK_L(T,P))*gasList[i].N;
              return G/N;
   }        
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  g=Chemical Gibbs energy calculated by using Lee-Kesler method for each liquid in mixture @kj/kmol
     */
          public double  gt_TP_LK_ML(double T,double P){    
              double Gt=0;                
              for(int i=0;i<ngas;i++)	             
              Gt+=(gasList[i].h_TP_LK_L(T,P)+gasList[i].DELHF-T*gasList[i].s_TP_LK_L(T,P))*gasList[i].N;
              return Gt/N;
   }   
          /**
     * 
     * @param T=Tempareture @K
     * @param P =Pressure @bar
     * @return  g=Chemical Gibbs energy calculated by using Lee-Kesler method for each gas in mixture @kj/kmol
     */         
          public double  G_TP_LK_ML(double T,double P){                
              return g_TP_LK_ML(T,P)*N;
   }         
          
          //vaporization properties
          
          /**
     * 
     * @param P=pressure @bar 
     * @return delH= Enthalpy of vaporization of mixture @Kj/kmol
     */
          public double dH_P_LK_MSVL(double P){           
            return h_T_LK_MSV(Tb_maxA(P))-h_T_LK_MSL(Tb_minA(P));
        }          
          public double dH_T_LK_MSVL(double T){            
            return h_P_LK_MSV(Pb_maxA(T))-h_P_LK_MSL(Pb_minA(T));
        }
          /**
     * 
     * @param P=pressure @bar 
     * @return delS= Entropy of vaporization of mixture @Kj/kmol
     */
          public double dS_P_LK_MSVL(double P){
           return s_T_LK_MSV(Tb_maxA(P))-s_T_LK_MSL(Tb_minA(P));
        }          
          public double dS_T_LK_MSVL(double T){
            return s_P_LK_MSV(Pb_maxA(T))-s_P_LK_MSL(Pb_minA(T));
        }
          
          
          //_____________________________________________________________________________________
        public double dH_P_TS_SVL1(double P){
            double dh=0;
            for(int k=0;k<ngas;k++){  
                dh+=gasList[k].N*gasList[k].dH_P_TS_SVL(P);
            }
            dh/=N;
            return dh;
        }

public double dH_TP_SV_V1(double P)
{
    double x[]=new double[2];
    x=Tb_max(P);
double dh=0;
double Tmax=x[0];
double Tboil;
for(int k=0;k<ngas;k++)
{
  Tboil=gasList[k].T_P_LK_SV(P);
  //System.out.println(gasList[k].toString()+" "+Tboil);
  dh+=gasList[k].N*
  (
  gasList[k].h_TP_LK_V(Tmax,P)-
  gasList[k].h_TP_LK_V(Tboil,P)
  );
}
dh/=N;
return dh;
}

public double dH_P_VE_SVL1(double P)
{
double dh=0;
double dhi;
for(int k=0;k<ngas;k++)
{
  dhi=gasList[k].dH_P_VE_SVL(P);
  //System.out.println(gasList[k].toString()+" dh = "+dhi);
  dh+=gasList[k].N*dhi;
}
dh/=N;
return dh;
}

public double dH_P_WE_SVL1(double P)
{
double dh=0;
for(int k=0;k<ngas;k++)
{
  dh+=gasList[k].N*gasList[k].dH_P_WE_SVL(P);
}
dh/=N;
return dh;
}

public double dH_P_LK_SVL1(double P)
{
	// kaynama entalpisi
double dh=0;
for(int k=0;k<ngas;k++)
{
  dh+=gasList[k].N*gasList[k].dH_P_LK_SVL(P);
}
dh/=N;
return dh;
}

public double dH_P_GT_SVL1(double P)
{
double dh=0;
for(int k=0;k<ngas;k++)
{
  dh+=gasList[k].N*gasList[k].dH_P_GT_SVL(P);
}
dh/=N;
return dh;
}

public String toString(String ch)
{
String s="";
int i,j;
if(ch.equals("name"))
   s=s+Name+"\n";
else if(ch.equals("formula"))
{
  for(i=0;i<ngas;i++)
  { s=s+" "+gasList[i].toString()+" "+gasList[i].N+"\n"; }
}
else if(ch.equals("composition"))
{
for(i=0;i<natom;i++)
  s=s+atomList[i].toString()+"\n";
}
return s;
}

public double h_T_IG_V(double T)
{
//enthalpy of ideal gas
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].h_T_IG_V(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].h_T_IG_V(T)+"h = "+h);
  }
  h/=N;
  return h;
}

public double dH_T_GT_SVL1(double T)
{
//
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].dH_T_GT_SVL(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].dh_T_GT_SVL(T)+"h = "+h);
  }
  h/=N;
  return h;
}

public double dH_T_LK_SVL1(double T)
{
//
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].dH_T_LK_SVL(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].dH_T_LK_SVL(T)+"h = "+h);
  }
  h/=N;
  return h;
}

public double dH_T_TS_SVL1(double T)
{
//enthalpy of ideal gas
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].dH_T_TS_SVL(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].dH_T_TS_SVL(T)+"h = "+h);
  }
  h/=N;
  return h;
}

public double dH_T_VE_SVL1(double T)
{
//enthalpy of ideal gas
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].dH_T_VE_SVL(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].dH_T_VE_SVL(T)+"h = "+h);
  }
  h/=N;
  return h;
}

public double dH_T_WE_SVL1(double T)
{
//enthalpy of ideal gas
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].dH_T_WE_SVL(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].dH_T_WE_SVL(T)+"h = "+h);
  }
  h/=N;
  return h;
}

public double Cp_T_IG_V(double T)
{
//ideal gas Cp
  double Cp=0;
  for(int i=0;i<ngas;i++)
  {
  Cp+=gasList[i].N*gasList[i].Cp_T_IG_V(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].N+" "+gasList[i].Cp_T_IG_V(T)+"Cp = "+Cp);
  }
  Cp/=N;
  return Cp;
}

public double Cp_TP_BR_L(double T, double P)
{
//liquid Cp
  double Cp=0;
  for(int i=0;i<ngas;i++)
  {
  Cp+=gasList[i].N*gasList[i].Cp_TP_BR_L(T,P);
  //System.out.println(gasList[i].toString()+" "+gasList[i].N+" "+gasList[i].Cp_T_IG_V(T)+"Cp = "+Cp);
  }
  Cp/=N;
  return Cp;
}

public double Cp_T_BR_SL(double T)
{
//saturated liquid Cp
  double Cp=0;
  for(int i=0;i<ngas;i++)
  {
  Cp+=gasList[i].N*gasList[i].Cp_T_BR_SL(T);
  //System.out.println(gasList[i].toString()+" "+gasList[i].N+" "+gasList[i].Cs_T_IG_V(T)+"Cp = "+Cp);
  }
  Cp/=N;
  return Cp;
}

public double h_T_BR_SL(double T)
{
//saturated vapor h
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].h_T_BR_SL(T);
  }
  h/=N;
  return h;
}

public double h_P_BR_SL(double P)
{
//saturated vapor h
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  h+=gasList[i].N*gasList[i].h_P_BR_SL(P);
  }
  h/=N;
  return h;
}


public double dhsh_TP_V(double T, double P)
{
//superheated vapor h
  double h=0;
  for(int i=0;i<ngas;i++)
  {
  //h+=gasList[i].N*gasList[i].dhsh_TP_V(T,P);
  }
  h/=N;
  return h;
}

public double[][] distilation(double P)
{
  //generates saturated liquid distilation list
  double Ni=0;
  double[][] x=new double[ngas][2];
  for(int i=0;i<ngas;i++)
  {
   Ni+=gasList[i].N;
   x[i][0]=Ni;
   x[i][1]=gasList[i].T_P_LK_SV(P);
  }
  return x;
}

public double[][] distilationGT(double P)
{
  //generates saturated liquid distilation list
  double Ni=0;
  double[][] x=new double[ngas][2];
  for(int i=0;i<ngas;i++)
  {
   Ni+=gasList[i].N;
   x[i][0]=Ni;
   x[i][1]=gasList[i].T_P_GT_SV(P);
  }
  return x;
}
/*
*Thermophysşical properties
*/
public double STensionM(double T){
	double sm=0;
	if(T>Tc_max()) return 0;
	for(int i=0;i<gasList.length;i++){
		//System.out.println(gasList[i].Name+" surface tension  "+gasList[i].STension(T));
			sm+= gasList[i].STension(T)*gasList[i].N/N;
		}
		return sm;	
}
public double cp_TP_LK_MV(double T,double P){ 
	    double h=1.0e-3;
  		double hh=1.0/h;   	
  		double fp2h,fph,fm2h,fmh;          		 
  		fp2h=h_TP_LK_MV(T+2.0*h,P);
  		fph=h_TP_LK_MV(T+h,P);
  		fm2h=h_TP_LK_MV(T-2.0*h,P);
  		fmh=h_TP_LK_MV(T-h,P);
  		return (-fp2h+8.0*fph-8.0*fmh+fm2h)/12.0*hh;
	}
public double cp_TP_LK_ML(double T,double P){ 
	    double h=1.0e-3;
  		double hh=1.0/h;   	
  		double fp2h,fph,fm2h,fmh;          		 
  		fp2h=h_TP_LK_ML(T+2.0*h,P);
  		fph=h_TP_LK_ML(T+h,P);
  		fm2h=h_TP_LK_ML(T-2.0*h,P);
  		fmh=h_TP_LK_ML(T-h,P);
  		return (-fp2h+8.0*fph-8.0*fmh+fm2h)/12.0*hh;
	}
	public double cp_T_LK_MSL(double T){ 
	   return cp_TP_LK_ML(T,Pb_maxA(T));
	}
	public double cp_T_LK_MSV(double T){ 
	   return cp_TP_LK_MV(T,Pb_maxA(T));
	}
	public double cv_TP_LK_MV(double T,double P){
		double h=1.0e-3;
  		double hh=1.0/h;   	
  		double fp2h,fph,fm2h,fmh;          		 
  		fp2h=u_TP_LK_MV(T+2.0*h,P);
  		fph=u_TP_LK_MV(T+h,P);
  		fm2h=u_TP_LK_MV(T-2.0*h,P);
  		fmh=u_TP_LK_MV(T-h,P);
  		return (-fp2h+8.0*fph-8.0*fmh+fm2h)/12.0*hh;
	}
	public double cv_TP_LK_ML(double T,double P){
		double h=1.0e-3;
  		double hh=1.0/h;   	
  		double fp2h,fph,fm2h,fmh;          		 
  		fp2h=u_TP_LK_ML(T+2.0*h,P);
  		fph=u_TP_LK_ML(T+h,P);
  		fm2h=u_TP_LK_ML(T-2.0*h,P);
  		fmh=u_TP_LK_ML(T-h,P);
  		return (-fp2h+8.0*fph-8.0*fmh+fm2h)/12.0*hh;
	}
	public double kv_TP_LK_MV(double T,double P){
		  double kv=0;                
          for(int i=0;i<ngas;i++)	             
          	kv+=gasList[i].kv_TP_LK_V(T,P)*gasList[i].N;
          return kv/N;
	}
	public double kl_T_LK_ML(double T){
		 double kv=0;                
          for(int i=0;i<ngas;i++)	             
          	kv+=gasList[i].kl_T_LK_L(T)*gasList[i].N;
          return kv/N;		
	}
	public double vis_T_L_MLPV(double T){
		  double vis=0;                
          for(int i=0;i<ngas;i++)	             
          	vis+=gasList[i].vis_T_L_LPV(T)*gasList[i].N;
          return vis/N;
	}
	public double vis_T_PS_MLTL(double T){
		  double vis=0;                
          for(int i=0;i<ngas;i++)	             
          	vis+=gasList[i].vis_T_PS_LTL(T)*gasList[i].N;
          return vis/N;
	}
	

//_____________________________________________________________________________________


    public int zone(double T,double P){
/*
1 : supercritical fluid
2 : critical point
3 : superheated vapour
4 : saturated mixture
5 : liquid
6 : saturated vapour
7 : saturated liquid
*/
int z=0;
double x[]=new double[2];
x=Tb_min(P);
double Tsl= x[0];
x=Tb_max(P);
double Tsv= x[0];
double Tc=Tc_max();
double Pc=Pc_max();
//System.out.println("Tsl= "+Tsl+" Tsv= "+Tsv);
//System.out.println("Tc= "+Tc+" Pc= "+Pc+" T= "+T);
//System.out.println("Tvapour=  "+Tvapour);
if(P>=Pc || T>Tc) z=1;
else if(T==Tc) z=2;
else if(Tc>T && T>Tsv) z=3;
else if(Tc>T && T<Tsl) z=5;
else if(T<Tsv && T>Tsl)z=4;
else if(T==Tsv) z=6;
else if(T==Tsl) z=7;
return z;
}
    public int zonev(double T,double V){
/*
1 : supercritical fluid
2 : critical point
3 : superheated vapour
4 : saturated mixture
5 : liquid
6 : saturated vapour
7 : saturated liquid
*/
        double x[]=new double[2];
        int z=0;
        double vl,vv;
        x=Pb_min(T);
        if(x[0]==-1) return  1;
        //System.out.println("x= "+x[0]);
        double Psv=x[0];
        vv=V_TP_LK_MV(T,Psv);
        x=Pb_max(T);
        //System.out.println("x= "+x[0]);
        double Psl=x[0];
        vl=V_TP_LK_ML(T,Psl);
        //System.out.println("vl= "+vl+" vv= "+vv+" V= "+V +" T= "+T);
        if(T>=Tc) z=1;        
        else if(V==vl) z=7;
        else if(V==vv) z=6;
        else if(Tc>T && V>vv) z=3;        
        else if(V>vl && V<vv) z=4;
        else if(V<vl) z=5;
        return z;

    }    
    public double v_x_tveq(double T,double iP){
	    double x=(T-Tb_minA(iP))/(Tb_maxA(iP)-Tb_minA(iP));
	    double vsl=V_T_LK_MSL(Tb_minA(iP));
	    double vsv=V_T_LK_MSV(Tb_maxA(iP));
	    //System.out.println("P= "+iP);
	    //System.out.println("V_T_LK_MSL("+Tb_minA(iP)+")= "+vsl);
	    //System.out.println("V_T_LK_MSV("+Tb_maxA(iP)+")= "+vsv);
	    //System.out.println("vsl+x*(vsv-vsl)= "+(vsl+x*(vsv-vsl)));
	    return vsl+x*(vsv-vsl);
    }
    public  double[][] x_tvBracket(double T,double v){			
			// koklerin yer aldığı alt bölgeleri saptar
			// n : verilen bölgeyi böldüğümüz alt bölge sayısı
			// x1,x2 : sınır değerleri
			// nbb = aranan bölgedeki köksayısı	
			//System.out.println("---------------x_tvBracket basladi-----------------");
			double x1=1;
			double x2=Pc_max();
			int n=200;
			int nbb=1; 
			int nb;			
			int i;
			double x,fp,fc,dx;
			double xb[][]=new double[2][nbb];
			nb=0;
			dx=(x2-x1)/n;
			x=x1;
			fp=v_x_tveq(T,x)-v;
			//System.out.println("x1= "+x1+" fp= "+fp);
			for (i=1;i<=n;i++) 
			{
				x+=dx;
				fc=v_x_tveq(T,x)-v;
				//System.out.println("x= "+x+" fc= "+fc);
				// eğer kök olan bölge bulunduysa.....
				if (fc*fp < 0.0 || fp==0) {
					xb[0][nb]=x-dx;
					xb[1][nb]=x;
					nb++;
				}
				fp=fc;
				
				if (nbb == nb){
					//System.out.println("---------------x_tvBracket bitti-----------------");
					 return xb;
					 }
			}	
		if( nb == 0)
		System.out.println("arama tamamlandı kök olan bölge bulunamadı");			
		else if(nb<nbb){
			System.out.println("arama tamamlandı sadece "+nb+" adet kök bulundu \n"+
		    "siz "+nbb+" adet kök için arama yaptırdınız");			
		   double xc[][]=new double[2][nb];
		   for (i=0;i<nb;i++) {xc[0][i]=xb[0][i];xc[1][i]=xb[1][i];}
		   return xc;
		  }
		return xb;
	}
   public double p_x_tv(double T,double v){			
				 // Ridder Metodu ile lineer olmayan denklemlerin köklerinin bulunması
		         //referans : Numerical Recipes in C, second edition, William H. Press, 
		         //Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery
		         //cambridge university press	
		  double[][] x_bracket=new double[2][1]; 
		  x_bracket=x_tvBracket(T,v);	
		  double x1=x_bracket[0][0];
		  double x2=x_bracket[1][0];
		  //System.out.println("x1= "+x1+" x2= "+x2);
		  int MAXIT=50;
		    double xacc=1.0e-4;int j;
			double fl,fh,xl,xh,swap,dx,del,ff;
			double rtf=x1;
			fl=v_x_tveq(T,x1)-v;
			fh=v_x_tveq(T,x2)-v;
			//System.out.println("fl= "+fl+" fh= "+fh);
		    if (fl*fh > 0.0)System.out.println("Kök sınırları doğru olarak seçilmemiş \n sonuç hatalı olabilir"); 
			if (fl < 0.0) {
				xl=x1;
				xh=x2;
			} else {
				xl=x2;
				xh=x1;
				swap=fl;
				fl=fh;
				fh=swap;
			}
			//System.out.println("xl= "+xl+" xh= "+xh);
			//System.out.println("fl= "+fl+" fh= "+fh);
			dx=xh-xl;
			for (j=1;j<=MAXIT;j++) {
				//System.out.println("-----"+j+" . iterasyon basladi------------");
				rtf=xl+dx*fl/(fl-fh);
				ff=v_x_tveq(T,rtf)-v;
				if (ff < 0.0) {
					del=xl-rtf;
					xl=rtf;
					fl=ff;
				} else {
					del=xh-rtf;
					xh=rtf;
					fh=ff;
				}
				//System.out.println("rtf= "+rtf);
				dx=xh-xl;
				//System.out.println("xl= "+xl+" xh= "+xh);
			//System.out.println("fl= "+fl+" fh= "+fh);
				if (Math.abs(del) < xacc || ff == 0.0) return rtf;
			}
			System.out.println("Uyarı maximum iterasyon sayısı aşıldı \n"+
		   " çözüm geçerli olmıyabilir");			
		    return rtf; 	
					
		} 
	public double x_tv(double T,double V){
		double P=p_x_tv(T,V);
		return x_tp(T,P);
	}
	public double[] x_tvA(double T,double V){
	 	double P[]=new double[2];
	 	P[0]=p_x_tv(T,V);
	 	P[1]=x_tp(T,P[0]);
	 	return P;	
	}	
    public double  x_tp(double T,double P){        
        double Tsl=Tb_minA(P);
        double Tsv=Tb_maxA(P);        
        System.out.println("T= "+T+" Tsl= "+Tsl+" Tsv= "+Tsv); 
        //System.out.println("V_T_LK_MSL("+Tsl+")= "+V_T_LK_MSL(Tsl));         
        //System.out.println("V_T_LK_MSV("+Tsv+")= "+V_T_LK_MSV(Tsv));
        System.out.println("V_T_LK_MSV("+T+")= "+V_T_LK_MSV(T));
        System.out.println("V_T_LK_MSL("+T+")= "+V_T_LK_MSL(T));
        return (T-Tsl)/(Tsv-Tsl);
    } 
    public double T_pxeq(double T,double iP,double ix){
	    return (iP-Pb_maxA(T))+ix*(Pb_maxA(T)-Pb_minA(T));
    }
    public  double[][] T_pxBracket(double iP,double ix){			
			// koklerin yer aldığı alt bölgeleri saptar
			// n : verilen bölgeyi böldüğümüz alt bölge sayısı
			// x1,x2 : sınır değerleri
			// nbb = aranan bölgedeki köksayısı	
			//System.out.println("---------brackaet");
			double x1=20;
			double x2=3000;
			int n=200;
			int nbb=1; 
			int nb;			
			int i;
			double x,fp,fc,dx;
			double xb[][]=new double[2][nbb];
			nb=0;
			dx=(x2-x1)/n;
			x=x1;
			fp=T_pxeq(x1,iP,ix);
			//System.out.println("x1= "+x1+" fp= "+fp);
			for (i=1;i<=n;i++) 
			{
				x+=dx;
				fc=T_pxeq(x,iP,ix);
				//System.out.println("x= "+x+" fc= "+fc);
				// eğer kök olan bölge bulunduysa.....
				if (fc*fp < 0.0 || fp==0) {
					xb[0][nb]=x-dx;
					xb[1][nb]=x;
					nb++;
				}
				fp=fc;
				if (nbb == nb){
					//System.out.println("---------brackaet");
				    return xb;
				 }
			}	
		if( nb == 0)
		System.out.println("arama tamamlandı kök olan bölge bulunamadı");			
		else if(nb<nbb){
			System.out.println("arama tamamlandı sadece "+nb+" adet kök bulundu \n"+
		    "siz "+nbb+" adet kök için arama yaptırdınız");			
		   double xc[][]=new double[2][nb];
		   for (i=0;i<nb;i++) {xc[0][i]=xb[0][i];xc[1][i]=xb[1][i];}
		   return xc;
		  }
		return xb;
	}
   public double T_px(double P,double x){			
				 // Ridder Metodu ile lineer olmayan denklemlerin köklerinin bulunması
		         //referans : Numerical Recipes in C, second edition, William H. Press, 
		         //Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery
		         //cambridge university press	
		  double[][] x_bracket=new double[2][1]; 
		  x_bracket=T_pxBracket(P,x);	
		  double x1=x_bracket[0][0];
		  double x2=x_bracket[1][0];
		  //System.out.println("x1= "+x1+" x2= "+x2);
		  int MAXIT=50;
		    double xacc=1.0e-4;int j;
			double fl,fh,xl,xh,swap,dx,del,ff;
			double rtf=x1;
			fl=T_pxeq(x1,P,x);
			fh=T_pxeq(x2,P,x);
			//System.out.println("fl= "+fl+" fh= "+fh);
		    if (fl*fh > 0.0)System.out.println("Kök sınırları doğru olarak seçilmemiş \n sonuç hatalı olabilir"); 
			if (fl < 0.0) {
				xl=x1;
				xh=x2;
			} else {
				xl=x2;
				xh=x1;
				swap=fl;
				fl=fh;
				fh=swap;
			}
			//System.out.println("xl= "+xl+" xh= "+xh);
			//System.out.println("fl= "+fl+" fh= "+fh);
			dx=xh-xl;
			for (j=1;j<=MAXIT;j++) {
				rtf=xl+dx*fl/(fl-fh);
				ff=T_pxeq(rtf,P,x);
				if (ff < 0.0) {
					del=xl-rtf;
					xl=rtf;
					fl=ff;
				} else {
					del=xh-rtf;
					xh=rtf;
					fh=ff;
				}
				//System.out.println("rtf= "+rtf);
				dx=xh-xl;
				//System.out.println("xl= "+xl+" xh= "+xh);
			//System.out.println("fl= "+fl+" fh= "+fh);
				if (Math.abs(del) < xacc || ff == 0.0) return rtf;
			}
			System.out.println("Uyarı maximum iterasyon sayısı aşıldı \n"+
		   " çözüm geçerli olmıyabilir");			
		    return rtf; 	
					
		}  
		 public double P_txeq(double P,double iT,double ix){
			// System.out.println("Tb_minA(P= "+Tb_minA(P)+" Tb_maxA(P)= "+Tb_maxA(P));
	    return (iT-Tb_minA(P))-ix*(Tb_maxA(P)-Tb_minA(P));
    }
    public  double[][] P_txBracket(double iT,double ix){			
			// koklerin yer aldığı alt bölgeleri saptar
			// n : verilen bölgeyi böldüğümüz alt bölge sayısı
			// x1,x2 : sınır değerleri
			// nbb = aranan bölgedeki köksayısı	
			//System.out.println("---bracket başladı--------");
			double x1=0.001;
			double x2=2000;
			int n=200;
			int nbb=1; 
			int nb;			
			int i;
			double x,fp,fc,dx;
			double xb[][]=new double[2][nbb];
			nb=0;
			dx=(x2-x1)/n;
			x=x1;
			fp=P_txeq(x1,iT,ix);
			//System.out.println("x1= "+x1+" fp= "+fp);
			for (i=1;i<=n;i++) 
			{
				x+=dx;
				fc=P_txeq(x,iT,ix);
				//System.out.println("x= "+x+" fc= "+fc);
				// eğer kök olan bölge bulunduysa.....
				if (fc*fp < 0.0 || fp==0) {
					xb[0][nb]=x-dx;
					xb[1][nb]=x;
					nb++;
				}
				fp=fc;
				if (nbb == nb){					
				 //System.out.println("---bracket bitti--------");	
				 return xb;}
			}	
		if( nb == 0)
		System.out.println("arama tamamlandı kök olan bölge bulunamadı");			
		else if(nb<nbb){
			System.out.println("arama tamamlandı sadece "+nb+" adet kök bulundu \n"+
		    "siz "+nbb+" adet kök için arama yaptırdınız");			
		   double xc[][]=new double[2][nb];
		   for (i=0;i<nb;i++) {xc[0][i]=xb[0][i];xc[1][i]=xb[1][i];}
		   //System.out.println("---bracket bitti--------");
		   return xc;
		  }//System.out.println("---bracket bitti--------");
		return xb;
	}
   public double P_tx(double T,double x){			
				 // Ridder Metodu ile lineer olmayan denklemlerin köklerinin bulunması
		         //referans : Numerical Recipes in C, second edition, William H. Press, 
		         //Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery
		         //cambridge university press	
		        // System.out.println("T= "+T+" x= "+x);
		  double[][] x_bracket=new double[2][1]; 
		  x_bracket=P_txBracket(T,x);	
		  double x1=x_bracket[0][0];
		  double x2=x_bracket[1][0];
		  //System.out.println("x1= "+x1+" x2= "+x2);
		  int MAXIT=50;
		    double xacc=1.0e-4;int j;
			double fl,fh,xl,xh,swap,dx,del,ff;
			double rtf=x1;
			fl=P_txeq(x1,T,x);
			fh=P_txeq(x2,T,x);
			//System.out.println("fl= "+fl+" fh= "+fh);
		    if (fl*fh > 0.0)System.out.println("Kök sınırları doğru olarak seçilmemiş \n sonuç hatalı olabilir"); 
			if (fl < 0.0) {
				xl=x1;
				xh=x2;
			} else {
				xl=x2;
				xh=x1;
				swap=fl;
				fl=fh;
				fh=swap;
			}
			//System.out.println("xl= "+xl+" xh= "+xh);
			//System.out.println("fl= "+fl+" fh= "+fh);
			dx=xh-xl;
			for (j=1;j<=MAXIT;j++) {
				rtf=xl+dx*fl/(fl-fh);
				ff=P_txeq(rtf,T,x);
				if (ff < 0.0) {
					del=xl-rtf;
					xl=rtf;
					fl=ff;
				} else {
					del=xh-rtf;
					xh=rtf;
					fh=ff;
				}
				//System.out.println("rtf= "+rtf);
				dx=xh-xl;
				//System.out.println("xl= "+xl+" xh= "+xh);
			//System.out.println("fl= "+fl+" fh= "+fh);
				if (Math.abs(del) < xacc || ff == 0.0) return rtf;
			}
			System.out.println("Uyarı maximum iterasyon sayısı aşıldı \n"+
		   " çözüm geçerli olmıyabilir");			
		    return rtf; 	
					
		} 
    String zoneName(double T,double V){
    String s="";
    int z=zone(T,V);	
	if(z==1) s="supercritical fluid";
	else if(z==2) s="critical point";
	else if(z==3) s="superheated vapour";
	else if (z==6) s="saturated vapour";
	else if (z==7) s="saturated liquid";
	else if(z==4) s="saturated mixture";
	else if(z==5) s="liquid";
	return s;
}
 String zoneName(int z){
    String s="";    
	if(z==1) s="supercritical fluid";
	else if(z==2) s="critical point";
	else if(z==3) s="superheated vapour";
	else if (z==6) s="saturated vapour";
	else if (z==7) s="saturated liquid";
	else if(z==4) s="saturated mixture";
	else if(z==5) s="liquid";
	return s;
}

   public double[] property_SI(String knownpro,double iv1,double iv2) {             
       double protemp1,protemp2;
       double tempA[];	
       //T,P are known properties		
       if(knownpro.equals("tp")){		
           pro[1]=iv1+273.15;		
           pro[0]=iv2;  
           //System.out.println("T= "+pro[1]+" P= "+pro[0]);             
           //System.out.println("hsl="+h_T_LK_MSL(pro[1])+"   hsv="+h_T_LK_MSV(pro[1]));		
           double v1=0,v2=0;		
           int z=zone(pro[1],pro[0]);		
           //System.out.println("z=  "+z);		      
           if(z==1 ||z==3 || z==6 || z==2) {
               //vapor , supercritical fluid , superheated vapor                      
               pro[2]=V_TP_LK_MV(pro[1],pro[0]); 
               //System.out.println("V_TP_LK_MV(pro[1],pro[0])= "+V_TP_LK_MV(pro[1],pro[0]));		       
               pro[8]=pro[2]*pro[0]*1e5/(pro[1]*R);	    
               pro[6]=2;		       
               pro[7]=zonev(pro[1],pro[2]);	
               //System.out.println("pro[7]= "+pro[7]);	       
               pro[3]=h_TP_LK_MV(pro[1],pro[0]);		       
               pro[4]=pro[3]-pro[0]*pro[2]*1e2;		       
               pro[5]=s_TP_LK_MV(pro[1],pro[0]);		       
               pro[9]=pro[3]-pro[1]*pro[5];
               pro[10]=STensionM(pro[1]);
               pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
               pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
               pro[13]=MolWt;
               pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
               pro[15]=vis_T_L_MLPV(pro[1]);		      
           }
		      
           else if(z==7){
               //saturated liquid                 
               pro[2]=V_TP_LK_ML(pro[1],pro[0]); 
               if(Double.isNaN(pro[2])) return putproZero();               
               pro[8]=pro[2]*pro[0]*1e5/(pro[1]*R);    
               pro[6]=0; 
               pro[7]=7;		       
               pro[3]=h_T_LK_MSL(pro[1]);		       
               pro[4]=pro[3]-pro[0]*pro[2]*1e2;		       
               pro[5]=s_TP_LK_ML(pro[1],pro[0]);		       
               pro[9]=pro[3]-pro[1]*pro[5];		       
               pro[10]=STensionM(pro[1]);
               pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);
           }    
           
           else if(z==5){
               //liquid          
               pro[2]=V_TP_LK_ML(pro[1],pro[0]);
               if(Double.isNaN(pro[2])) return putproZero(); 
               pro[8]=pro[2]*pro[0]*1e5/(pro[1]*R);	 
               pro[6]=-1;		       
               pro[7]=5;
               pro[3]=h_TP_LK_ML(pro[1],pro[0]);		      
               pro[4]=pro[3]-pro[0]*pro[2]*1e2;		       
               pro[5]=s_TP_LK_ML(pro[1],pro[0]);		       
               pro[9]=pro[3]-pro[1]*pro[5];
               pro[10]=STensionM(pro[1]);
               pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);     
       }
		       
       else if(z==4){
           //vapor-liquid mixture
           pro[6]=x_tp(pro[1],pro[0]);	
           System.out.println("pro[6]= "+pro[6]);
           if(Double.isNaN(pro[6])) return putproZero();       	       
           pro[2]=V_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(V_T_LK_MSV(Tb_maxA(pro[0]))-V_T_LK_MSL(Tb_minA(pro[0])));
           System.out.println("pro[2]= "+pro[2]);
           if(Double.isNaN(pro[2])) return putproZero();                      
           pro[8]=pro[2]*pro[0]*1e5/(pro[1]*R);            
           pro[7]=4;		       
           pro[3]=h_P_LK_MSL(pro[0])+pro[6]*(h_P_LK_MSV(pro[0])-h_P_LK_MSL(pro[0])); 
           System.out.println("h_P_LK_MSL(pro[0])= "+h_P_LK_MSL(pro[0]));
           System.out.println("h_P_LK_MSV(pro[0])= "+h_P_LK_MSV(pro[0]));
           System.out.println("pro[3]= "+pro[3]);             	       
           pro[4]=pro[3]-pro[0]*pro[2]*1e2;		       
           pro[5]=s_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(s_T_LK_MSV(Tb_maxA(pro[0]))-s_T_LK_MSL(Tb_minA(pro[0])));           		       
           pro[9]=pro[3]-pro[1]*pro[5]; 
           pro[10]=STensionM(pro[1]); 
           if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1])); 
            }  
         
                   
     }  		
		//T,V are known properties	    
	    if(knownpro.equals("tv"))
	    {	    
		    pro[1]=iv1+273.15;
		    pro[2]=iv2;
		    int z=zonev(pro[1],pro[2]);
                    //int z=7;
		    System.out.println("z=  "+z);		    
		    if(z==1 ||z==3 || z==6 || z==2)
		    {//vapor , supercritical fluid , superheated vapor              
		    pro[0]=P_TV_LK_MV(pro[1],pro[2]);   
		    pro[8]=pro[0]*1e5*pro[2]/(pro[1]*R);
		    pro[6]=2;
		    pro[7]=zonev(pro[1],pro[2]);
		    pro[3]=h_TP_LK_MV(pro[1],pro[0]);
		    pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		    pro[5]=s_TP_LK_MV(pro[1],pro[0]);
		    pro[9]=pro[3]-pro[1]*pro[5];
		    pro[10]=STensionM(pro[1]);
		    pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
            pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
            pro[13]=MolWt;
            pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
            pro[15]=vis_T_L_MLPV(pro[1]);	
		    }		
		else if(z==7)
		{//saturated liquid	                     
			 pro[0]=P_T_LK_MSL(pro[1]);
			 if(Double.isNaN(pro[0])) return putproZero(); 
			 pro[8]=pro[0]*1e5*pro[2]/(pro[1]*R);			 
			 pro[6]=0;
			 pro[7]=7;
			 pro[3]=h_T_LK_MSL(pro[1]);                  
			 pro[4]=pro[3]-pro[0]*pro[2]*1e2;
			 pro[5]=s_T_LK_MSL(pro[1]);                        
			 pro[9]=pro[3]-pro[1]*pro[5]; 
			 pro[10]=STensionM(pro[1]); 
			 pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
             pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
             pro[13]=MolWt;	
             pro[14]=kl_T_LK_ML(pro[1]);
             pro[15]=vis_T_PS_MLTL(pro[1]);                       
		}
		else if(z==5) 
		{//liquid
			System.out.println("At this region P can be false please try \"tp\" properties");	                       
			pro[0]=P_TV_LK_ML(pro[1],pro[2]);
			if(Double.isNaN(pro[0])) return putproZero(); 			
			pro[8]=pro[0]*1e5*pro[2]/(pro[1]*R);
			//System.out.println("pro[0]= "+pro[0]);			
            pro[6]=x_tv(pro[1],pro[2]);			 
            pro[7]=5;			 
            pro[3]=h_TP_LK_ML(pro[1],pro[0]);			 
            pro[4]=pro[3]-pro[0]*pro[2]*1e2;			 
            pro[5]=s_TP_LK_ML(pro[1],pro[0]);			 
            pro[9]=pro[3]-pro[1]*pro[5];
            pro[10]=STensionM(pro[1]);
            pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
            pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            pro[13]=MolWt;	
            pro[14]=kl_T_LK_ML(pro[1]);
            pro[15]=vis_T_PS_MLTL(pro[1]);	                        
		}				
		else if(z==4)
		{//vapor-liquid mixture	
			 tempA= x_tvA(pro[1],pro[2]);
			 if(Double.isNaN(tempA[0]) || Double.isNaN(tempA[1]) ) return putproZero(); 
		     pro[6]=tempA[1];
		     pro[0]=tempA[0];	
		     //System.out.println("x= "+pro[6]);			     	    
             pro[8]=pro[0]*pro[2]*1e5/R/pro[1];			                     
		     pro[7]=4;
		     pro[3]=h_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(h_T_LK_MSV(Tb_maxA(pro[0]))-h_T_LK_MSL(Tb_minA(pro[0])));                   
		     pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		     pro[5]=s_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(s_T_LK_MSV(Tb_maxA(pro[0]))-s_T_LK_MSL(Tb_minA(pro[0])));       
		     pro[9]=pro[3]-pro[1]*pro[5];
		     pro[10]=STensionM(pro[1]);
		     pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
             pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
             pro[13]=MolWt;	
             pro[14]=kl_T_LK_ML(pro[1]);
             pro[15]=vis_T_PS_MLTL(pro[1]);	
              if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1]));                         

		   
		}		
		  }		  
		
		//T,h are known properties
                 if(knownpro.equals("th_l"))
		{
		pro[1]=iv1+273.15;		
		pro[3]=iv2;               
                double hcheck;
		double hsl=h_T_LK_MSL(pro[1]);                                
		double hsv=h_T_LK_MSV(pro[1]);		
                protemp1=0;
                protemp2=0;                     
		       pro[0]=P_hT_LK_ML(pro[3],pro[1]);
		       if(Double.isNaN(pro[0])) return putproZero(); 		     
		       pro[8]=Z_TP_LK_ML(pro[1],pro[0]);        
		       pro[2]=R*pro[8]*pro[1]/(pro[0]*1e5);		      		       
		       pro[6]=-1;
		       pro[7]=5;		       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_TP_LK_ML(pro[1],pro[0]);
		       pro[9]=pro[3]-pro[1]*pro[5];	
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);
                 }          
		if(knownpro.equals("th"))
		{
		pro[1]=iv1+273.15;		
		pro[3]=iv2;               
                double hcheck;
                //System.out.println("Tc="+Tc_max());
		double hsl=h_T_LK_MSL(pro[1]);            
		double hsv=h_T_LK_MSV(pro[1]);	
                protemp1=0;
                protemp2=0;
		//System.out.println("hsv= "+hsv+"  hsl= "+hsl+" h="+pro[3]);				
		       if(pro[3]>=hsv || pro[1]>Tc) 
		       {//vapor , supercritical fluid , superheated vapor,saturated vapour
		       System.out.println("vapor");		       	       
		       pro[2]=V_hT_LK_MV(pro[3],pro[1]);		                        
		       pro[8]=Z_TV_LK_MV(pro[1],pro[2]);         
		       pro[0]=pro[8]*R*pro[1]/(pro[2]*1e5);
		       pro[6]=x_tv(pro[1],pro[2]);
		       pro[7]=zonev(pro[1],pro[2]);		      
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_TV_LK_MV(pro[1],pro[2]);
		       pro[9]=pro[3]-pro[1]*pro[5];
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
               pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
               pro[13]=MolWt;
               pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
               pro[15]=vis_T_L_MLPV(pro[1]);	
		       }
		       else if(pro[3]==hsl)
		       {//saturated liquid	       
		       System.out.println("saturated liquid");
		       pro[2]=V_T_LK_MSL(pro[1]);
		       if(Double.isNaN(pro[2])) return putproZero(); 
		       pro[8]=Z_TV_LK_ML(pro[1],pro[2]);
		       pro[0]=pro[8]*R*pro[1]/(pro[2]*1e5);
		       pro[6]=0;
		       pro[7]=7;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_T_LK_MSL(pro[1]);
		       pro[9]=pro[3]-pro[1]*pro[5];
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);
		       }
		       else if(pro[3]<hsl)
		       {//liquid
		       System.out.println("liquid");                       
		       pro[0]=P_hT_LK_ML(pro[3],pro[1]);
		       if(Double.isNaN(pro[0])) return putproZero(); 		       
		       pro[8]=Z_TP_LK_ML(pro[1],pro[0]);        
		       pro[2]=R*pro[8]/(pro[0]*1e5);		      		       
		       pro[6]=-1;
		       pro[7]=5;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_TP_LK_ML(pro[1],pro[0]);
		       pro[9]=pro[3]-pro[1]*pro[5];	
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);		 
		       }
		       else if(pro[3]<hsv || pro[3]>hsl)
		       {//vapor-liquid mixture
		       	   //System.out.println("mixture");
               	   pro[0]=P_T_LK_MSV(pro[1]);  
               	   if(Double.isNaN(pro[0])) return putproZero();                  
               	   hcheck=  dH_P_LK_MSVL(pro[0]);      
               	   pro[6]=(pro[3]-h_T_LK_MSL(pro[1]))/hcheck;
               	   protemp1=V_TP_LK_ML(pro[1],pro[0]);
               	   protemp2=V_TP_LK_MV(pro[1],pro[0]);                     
	               pro[2]=protemp1+pro[6]*(protemp2-protemp1);		       
			       pro[8]=pro[2]*pro[9]*1e5/(pro[1]*R);	       
			       pro[7]=3;	       
			       pro[4]=pro[3]-pro[0]*pro[2]*1e2;                       
			       pro[5]=s_T_LK_MSL(pro[1])+pro[6]*dS_P_LK_MSVL(pro[0]);
			       pro[9]=pro[3]-pro[1]*pro[5];	
			       pro[10]=STensionM(pro[1]);
			        if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1])); 	   
		       }
		}                
                if(knownpro.equals("tx")){
                    pro[1]=iv1+273.15;
                    pro[6]=iv2;
                    protemp1=0;
                    protemp2=0;
                    if(pro[6]<0){
                        System.out.println("x de?eri 0 dan küçük olamaz");
                    }
                     else if(pro[6]>1){
                        System.out.println("x de?eri 0 dan büyük olamaz");
                    }
                    else{
                        pro[0]=P_tx(pro[1],pro[6]); 
                        if(Double.isNaN(pro[0])) return putproZero(); 
                        System.out.println("P= "+pro[0]);                      
                        protemp1=V_T_LK_MSL(Tb_minA(pro[0]));                        
                        protemp2=V_T_LK_MSV(Tb_maxA(pro[0])); 
                        //System.out.println("protemp1= "+protemp1);                      
                        //System.out.println("protemp2= "+protemp2);
                        pro[2]=protemp1+pro[6]*(protemp2-protemp1);                       
                        pro[8]=pro[0]*pro[2]*1e5/R/pro[1];                       
                        pro[7]=4;                      
                        pro[3]=h_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(h_T_LK_MSV(Tb_maxA(pro[0]))-
                        h_T_LK_MSL(Tb_minA(pro[0])));                                          
                        pro[4]=pro[3]-pro[0]*pro[2]*1e2;                                             
		        		pro[5]=s_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(s_T_LK_MSV(Tb_maxA(pro[0]))-
		        		s_T_LK_MSL(Tb_minA(pro[0])));          
		        		pro[9]=pro[3]-pro[1]*pro[5]; 
		        		pro[10]=STensionM(pro[1]); 
		        		 if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1]));                       
                     }
                }
                
                          
                if(knownpro.equals("px")){
                    pro[0]=iv1;
                    pro[6]=iv2;
                    protemp1=0;
                    protemp2=0;
                    if(pro[6]<0){
                        System.out.println("x de?eri 0 dan küçük olamaz");
                    }
                     else if(pro[6]>1){
                        System.out.println("x de?eri 0 dan büyük olamaz");
                    }
                    else{
                        pro[1]=T_px(pro[0],pro[6]);
                        if(Double.isNaN(pro[1])) return putproZero(); 
                        //System.out.println("x= "+pro[6]);
                        protemp1=V_T_LK_MSL(Tb_minA(pro[0])); 
                        //System.out.println("protemp1= "+protemp1);                       
                        protemp2=V_T_LK_MSV(Tb_maxA(pro[0])); 
                        //System.out.println("protemp2= "+protemp2);                       
                        pro[2]=protemp1+pro[6]*(protemp2-protemp1); 
                        pro[8]=pro[0]*pro[2]*1e5/R/pro[1];                       
                        pro[7]=4;                      
                        pro[3]=h_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(h_T_LK_MSV(Tb_maxA(pro[0]))-h_T_LK_MSL(Tb_minA(pro[0])));                                            
                        pro[4]=pro[3]-pro[0]*pro[2]*1e2;                                             
		        		pro[5]=s_T_LK_MSL(Tb_minA(pro[0]))+pro[6]*(s_T_LK_MSV(Tb_maxA(pro[0]))-s_T_LK_MSL(Tb_minA(pro[0])));          
		        		pro[9]=pro[3]-pro[1]*pro[5]; 
		        		pro[10]=STensionM(pro[1]); 
		        		 if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1]));                    
                     }
                }
                
                 if(knownpro.equals("ts")){
                     pro[1]=iv1+273.15;
                     pro[5]=iv2;
                     protemp1=0;
                     protemp2=0;                     
                     double ssv=s_T_LK_MSV(pro[1]);
                     double ssl=s_T_LK_MSL(pro[1]);                     
                     if(pro[5]>ssv){
                         pro[0]=P_sT_LK_MV(pro[5],pro[1]); 
                         pro[2]=V_TP_LK_MV(pro[1],pro[0]);		               
                         pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
                         pro[3]=h_TP_LK_MV(pro[1],pro[0]);
                         pro[4]=pro[3]-pro[0]*pro[2]*1e2;
                         pro[6]=2;
                         pro[7]=zonev(pro[1],pro[2]);
                         pro[9]=pro[3]-pro[1]*pro[5];
                         pro[10]=STensionM(pro[1]);
                         pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
               			 pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
               			 pro[13]=MolWt;
               			 pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
               			 pro[15]=vis_T_L_MLPV(pro[1]);	 
                     }
                     else if(pro[5]<ssv && pro[5]>ssl){
                         pro[6]=(pro[5]-s_T_LK_MSL(pro[1]))/dS_T_LK_MSVL(pro[1]);
                         if(Double.isNaN(pro[6])) return putproZero(); 
                         pro[0]=P_T_LK_MSV(pro[1]);
                         if(Double.isNaN(pro[0])) return putproZero(); 
                         protemp1=V_T_LK_MSL(pro[1]);
                         protemp2=V_T_LK_MSV(pro[1]);
                         pro[2]=protemp1+pro[6]*(protemp2-protemp1);
                         pro[8]=pro[0]*pro[2]*1e5/R/pro[1];
                         pro[7]=3;
                         pro[3]=h_T_LK_MSL(pro[1])+pro[6]*dH_T_LK_MSVL(pro[1]);
                         pro[4]=pro[3]-pro[0]*pro[2]*1e2;		        
		         		 pro[9]=pro[3]-pro[1]*pro[5];
		                 pro[10]=STensionM(pro[1]); 
		                 pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                         pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
                         pro[13]=MolWt;	
                         pro[14]=kl_T_LK_ML(pro[1]);
                         pro[15]=vis_T_PS_MLTL(pro[1]);
                          if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1]));  
                     }
                     else if(pro[5]==ssl){
                       System.out.println("saturated liquid");
		       pro[2]=V_T_LK_MSL(pro[1]);
		       if(Double.isNaN(pro[2])) return putproZero(); 
		       pro[0]=P_TV_LK_ML(pro[1],pro[2]);
                       pro[3]=h_T_LK_MSL(pro[1]);
		       pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
		       pro[6]=0;
		       pro[7]=7;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;		    
		       pro[9]=pro[3]-pro[1]*pro[5]; 
		       pro[10]=STensionM(pro[1]); 
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);                       
                     }
                     else if(pro[5]==ssv){
                       System.out.println("saturated liquid");
		       pro[2]=V_T_LK_MSV(pro[1]);
		       if(Double.isNaN(pro[2])) return putproZero(); 
		       pro[0]=P_TV_LK_MV(pro[1],pro[2]);
                       pro[3]=h_T_LK_MSV(pro[1]);
		       pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
		       pro[6]=2;
		       pro[7]=6;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;		    
		       pro[9]=pro[3]-pro[1]*pro[5]; 
		       pro[10]=STensionM(pro[1]); 
		       pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
               pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
               pro[13]=MolWt;
               pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
               pro[15]=vis_T_L_MLPV(pro[1]);	                       
                     } 
                     else if(pro[5]<ssl){
                         System.out.println("liquid");
                         pro[0]=P_sT_LK_ML(pro[5],pro[1]); 
                         if(Double.isNaN(pro[0])) return putproZero();                     
		         pro[2]=V_TP_LK_ML(pro[1],pro[0]);           
                         pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
                         pro[3]=h_TP_LK_ML(pro[1],pro[0]);
                         pro[4]=pro[3]-pro[0]*pro[2]*1e2;
                         pro[6]=-1;
                         pro[7]=5;
                         pro[9]=pro[3]-pro[1]*pro[5];
                         pro[10]=STensionM(pro[1]); 
                         pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);    
                     }
                 }
                	
                     if(knownpro.equals("ph"))
		{
		pro[0]=iv1;		
		pro[3]=iv2;               
                double hcheck;
		double hsl=h_P_LK_MSL(pro[0]);                
                
		double hsv=h_P_LK_MSV(pro[0]);
		//pro[3]=hsl;
                protemp1=0;
                protemp2=0;						
		       if(pro[3]>=hsv || pro[0]>Pc) 
		       {//vapor , supercritical fluid , superheated vapor,saturated vapour
		       System.out.println("vapor");		       	       
		       pro[1]=T_hP_LK_MV(pro[3],pro[0]);	                  
		       pro[2]=V_TP_LK_MV(pro[1],pro[0]);         
		       pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
		       pro[6]=x_tv(pro[1],pro[2]);
		       pro[7]=zonev(pro[1],pro[2]);		      
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_TP_LK_MV(pro[1],pro[0]);
		       pro[9]=pro[3]-pro[1]*pro[5];
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
               pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
               pro[13]=MolWt;
               pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
               pro[15]=vis_T_L_MLPV(pro[1]);	
		       }
		       else if(pro[3]==hsl)
		       {//saturated liquid	       
		       System.out.println("saturated liquid");
		       pro[2]=V_T_LK_MSL(pro[1]);
		       if(Double.isNaN(pro[2])) return putproZero(); 
		       pro[0]=P_TV_LK_ML(pro[1],pro[2]);
		       pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
		       pro[6]=0;
		       pro[7]=7;		       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_T_LK_MSL(pro[1]);
		       pro[9]=pro[3]-pro[1]*pro[5];
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);
		       }
		       else if(pro[3]<hsl)
		       {//liquid
		       System.out.println("liquid");                      
		       pro[1]=T_hP_LK_ML(pro[3],pro[0]);
		       if(Double.isNaN(pro[1])) return putproZero(); 
		       System.out.println("P pro[0]="+pro[0]);	
		       pro[2]=V_TP_LK_ML(pro[1],pro[0]);        
		       pro[8]=pro[2]*1e5*pro[0]/(pro[1]*R);
		       pro[6]=-1;
		       pro[7]=5;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;
		       pro[5]=s_TP_LK_ML(pro[1],pro[0]);
		       pro[9]=pro[3]-pro[1]*pro[5];	
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);		 
		       }
		       else if(pro[3]<hsv || pro[3]>hsl)
		       {//vapor-liquid mixture
		       System.out.println("mixture");
                       pro[1]=T_P_LK_MSV(pro[0]);  
                       if(Double.isNaN(pro[1])) return putproZero();                  
                       hcheck=dH_P_LK_MSVL(pro[0]);                 
                       pro[6]=(pro[3]-h_T_LK_MSL(pro[1]))/hcheck;
                       protemp1=V_TP_LK_ML(pro[1],pro[0]);
                       protemp2=V_TP_LK_MV(pro[1],pro[0]);                     
                       pro[2]=protemp1+pro[6]*(protemp2-protemp1);		       
		       pro[8]=pro[2]*pro[9]*1e5/(pro[1]*R);	       
		       pro[7]=3;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;                       
		       pro[5]=s_T_LK_MSL(pro[1])+pro[6]*dS_T_LK_MSVL(pro[1]);
		       pro[9]=pro[3]-pro[1]*pro[5];	
		       pro[10]=STensionM(pro[1]);
		        if(pro[6]==0){
                	pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
            	}
                else if(pro[6]==1){
	                pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                	pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                }
                else{
	             	pro[11]=0;
                	pro[12]=0;   
                }          
                pro[13]=MolWt;
                pro[14]=kl_T_LK_ML(pro[1])+pro[6]*(kv_TP_LK_MV(pro[1],pro[0])-kl_T_LK_ML(pro[1]));
                pro[15]=vis_T_PS_MLTL(pro[1])+pro[6]*(vis_T_L_MLPV(pro[1])-vis_T_PS_MLTL(pro[1])); 	   
		       }
                     }
                  if(knownpro.equals("ps")){
                     pro[0]=iv1;
                     pro[5]=iv2;
                     protemp1=0;
                     protemp2=0;                     
                     double ssv=s_P_LK_MSV(pro[0]);
                     double ssl=s_P_LK_MSL(pro[0]);                    
                     if(pro[5]>ssv){
                         System.out.println("vapour");
                         pro[1]=T_sP_LK_MV(pro[5],pro[0]);                     
		         		 pro[8]=Z_TP_LK_MV(pro[1],pro[0]);           
                         pro[2]=pro[8]*R*pro[1]/(pro[0]*1e5);
                         pro[3]=h_TV_LK_MV(pro[1],pro[2]);
                         pro[4]=pro[3]-pro[0]*pro[2]*1e2;
                         pro[6]=x_tv(pro[1],pro[2]);
                         pro[7]=zonev(pro[1],pro[2]);
                         pro[9]=pro[3]-pro[1]*pro[5];
                         pro[10]=STensionM(pro[1]);
                         pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
                         pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
                         pro[13]=MolWt;
                         pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
                         pro[15]=vis_T_L_MLPV(pro[1]);	 
                     }
                     else if(pro[5]<ssv && pro[5]>ssl){
                         System.out.println("mixture");
                         pro[1]=T_P_LK_MSV(pro[0]);
                         if(Double.isNaN(pro[1])) return putproZero(); 
                         pro[6]=(pro[5]-s_T_LK_MSL(pro[1]))/dS_T_LK_MSVL(pro[1]);                        
                         protemp1=V_T_LK_MSL(pro[1]);
                         protemp2=V_T_LK_MSV(pro[1]);
                         pro[2]=protemp1+pro[6]*(protemp2-protemp1);
                         pro[8]=pro[0]*pro[2]*1e5/R/pro[1];
                         pro[7]=3;
                         pro[3]=h_T_LK_MSL(pro[1])+pro[6]*dH_T_LK_MSVL(pro[1]);
                         pro[4]=pro[3]-pro[0]*pro[2]*1e2;		        
		         pro[9]=pro[3]-pro[1]*pro[5]; 
		         pro[10]=STensionM(pro[1]);
		          
                     }
                     else if(pro[5]==ssl){
                       System.out.println("saturated liquid");
		       pro[1]=T_P_LK_MSL(pro[0]);
		       if(Double.isNaN(pro[1])) return putproZero(); 
                       pro[2]=V_T_LK_MSL(pro[0]);
		       pro[8]=pro[0]*pro[2]*1e5/pro[1]/R;
                       pro[3]=h_T_LK_MSL(pro[1]);		       
		       pro[6]=0;
		       pro[7]=7;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;		    
		       pro[9]=pro[3]-pro[1]*pro[5];
		       pro[10]=STensionM(pro[1]);
		       pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);                         
                     }
                     else if(pro[5]==ssv){
                       System.out.println("saturated vapour");
		       pro[1]=T_P_LK_MSL(pro[0]);
                       pro[2]=V_T_LK_MSV(pro[0]);
                       pro[8]=pro[0]*pro[2]*1e5/pro[1]/R;
                       pro[3]=h_T_LK_MSV(pro[1]);		      
		       pro[6]=1;
		       pro[7]=6;	       
		       pro[4]=pro[3]-pro[0]*pro[2]*1e2;		    
		       pro[9]=pro[3]-pro[1]*pro[5]; 
		       pro[10]=STensionM(pro[1]);   
		       pro[11]=cp_TP_LK_MV(pro[1],pro[0]);
               pro[12]=cv_TP_LK_MV(pro[1],pro[0]);
               pro[13]=MolWt;
               pro[14]=kv_TP_LK_MV(pro[1],pro[0]);
               pro[15]=vis_T_L_MLPV(pro[1]);	                     
                     } 
                        else if(pro[5]<ssl){
                         System.out.println("liquid");
                         pro[0]=T_sP_LK_ML(pro[5],pro[0]); 
                         if(Double.isNaN(pro[0])) return putproZero();                     
		         		pro[8]=Z_TP_LK_ML(pro[1],pro[0]);           
                         pro[2]=pro[8]*R*pro[1]/(pro[0]*1e5);
                         pro[3]=h_TP_LK_ML(pro[1],pro[0]);
                         pro[4]=pro[3]-pro[0]*pro[2]*1e2;
                         pro[6]=-1;
                         pro[7]=5;
                         pro[9]=pro[3]-pro[1]*pro[5]; 
                         pro[10]=STensionM(pro[1]);
                         pro[11]=cp_TP_LK_ML(pro[1],pro[0]);
               pro[12]=cv_TP_LK_ML(pro[1],pro[0]);
               pro[13]=MolWt;	
               pro[14]=kl_T_LK_ML(pro[1]);
               pro[15]=vis_T_PS_MLTL(pro[1]);    
                     }
                  }
                 return pro;
                  }	
public Object[] property_SIO(String knownpro,double iv1,double iv2) { 
    double ipro[]=property_SI(knownpro,iv1,iv2);
    Object[] opro=new Object[ipro.length];
	for(int i=0;i<ipro.length;i++){
			opro[i]= i==7 ? zoneName((int)ipro[7]) : ipro[i];
	}	
	return opro;
} 
public double[] putproZero(){
   for(int i=0;i<pro.length;i++)pro[i]=(double)Double.NaN;
	   	return pro;
}   
   //--------------------------------------------------------------------     
   
   public double[][]  T_sP_LK_ML_reversebracket(double x1,double x2,double P,double s){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
            // System.out.println("-----------------------baracket----------------------");
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=s_TP_LK_ML(x1,P)-s;
      //  System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=s_TP_LK_ML(x,P)-s;
                //System.out.println("x="+x+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb){
                     // System.out.println("-----------------------baracket bitti----------------------");
                    return xb;
                }
	}
        if( nb == 0)	
        {  System.out.println("arama tamamland? kök olan bölge bulunamad? ----sonuç hatal?----");
        System.exit(1);}
else if(nb<nbb)
  System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
          // System.out.println("-----------------------baracket bitti----------------------");
return xb;     
          
   }          
   public double T_sP_LK_ML(double s,double P){
                int MAXIT=40;
		double xacc=1.0e-6;		
		double x2=Tc;
		double x1=x2*0.1;	
                double[][] x=new double[2][1];
                x=T_sP_LK_ML_reversebracket(x1,x2,P,s);
		x1=x[0][0];
                x2=x[1][0];
                int i=2;			
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		xh=0;
		xl=0;
		double rtf=x1;
		fl=s_TP_LK_ML(x1,P)-s;
		fh=s_TP_LK_ML(x2,P)-s;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		//System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir  P_sT_LK_V" );
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);		  
		    ff=s_TP_LK_ML(rtf,P)-s;
		   // System.out.println("rtf= "+rtf+"  ff= "+ff);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
                //System.out.println("del="+del);
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
            
        }            
   public double[][]  T_sP_LK_MV_reversebracket(double x1,double x2,double P,double s){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
            // System.out.println("-----------------------baracket----------------------");
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=s_TP_LK_MV(x1,P)-s;
      //  System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=s_TP_LK_MV(x,P)-s;
                System.out.println("x="+x+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb){
                     // System.out.println("-----------------------baracket bitti----------------------");
                    return xb;
                }
	}
        if( nb == 0)	
        {  System.out.println("arama tamamland? kök olan bölge bulunamad? ----sonuç hatal?----");
        System.exit(1);}
else if(nb<nbb)
  System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
          // System.out.println("-----------------------baracket bitti----------------------");
return xb;     
          
   }         
   public double T_sP_LK_MV(double s,double P){
                int MAXIT=40;
		double xacc=1.0e-6;		
		double x2=Tc*6;
		double x1=x2*0.1;	
                double[][] x=new double[2][1];
                x=T_sP_LK_MV_reversebracket(x1,x2,P,s);
		x1=x[0][0];
                x2=x[1][0];
                int i=2;			
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=s_TP_LK_MV(x1,P)-s;
		fh=s_TP_LK_MV(x2,P)-s;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir  P_sT_LK_V" );
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);		  
		    ff=s_TP_LK_MV(rtf,P)-s;
		   // System.out.println("rtf= "+rtf+"  ff= "+ff);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
                //System.out.println("del="+del);
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
            
        }          
   public double[][]  P_sT_LK_MV_reversebracket(double x1,double x2,double T,double s){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
            // System.out.println("-----------------------baracket----------------------");
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=s_TP_LK_MV(T,x1)-s;
      //  System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=s_TP_LK_MV(T,x)-s;
                System.out.println("x="+x+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb){
                     // System.out.println("-----------------------baracket bitti----------------------");
                    return xb;
                }
	}
        if( nb == 0)	
        {  System.out.println("arama tamamland? kök olan bölge bulunamad? ----sonuç hatal?----");
        System.exit(1);}
else if(nb<nbb)
  System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
          // System.out.println("-----------------------baracket bitti----------------------");
return xb;     
          
   }           
   public double P_sT_LK_MV(double s,double T){
                int MAXIT=40;
		double xacc=1.0e-6;		
		double x2=Pc*10;
		double x1=0.01*Pc;	
                double[][] x=new double[2][1];
                x=P_sT_LK_MV_reversebracket(x1,x2,T,s);
		x1=x[0][0];
                x2=x[1][0];
                int i=2;
		double s1=s;		
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=s_TP_LK_MV(T,x1)-s1;
		fh=s_TP_LK_MV(T,x2)-s1;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir  P_sT_LK_V" );
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);		  
		    ff=s_TP_LK_MV(T,rtf)-s1;
		   // System.out.println("rtf= "+rtf+"  ff= "+ff);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
                //System.out.println("del="+del);
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
            
        }           
   public double[][]  T_hP_LK_ML_reversebracket(double x1,double x2,double P,double h){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=h_TP_LK_ML(x,P)-h;
       // System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=h_TP_LK_ML(x,P)-h;
              //  System.out.println("x="+x+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb) {
                    //   System.out.println("-----------------------baracket bitti----------------------");
                    return xb;                      
                }
	}
        if( nb == 0)	{
       System.out.println("arama tamamland? kök olan bölge bulunamad?");
        System.exit(1);
        }
else if(nb<nbb)
 System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
           //System.out.println("-----------------------baracket bitti----------------------");
        
    return xb;     
      
   }        
   public double T_hP_LK_ML(double h,double P){
		double[][] x=new double[2][1];             
                int MAXIT=40;
		double xacc=1.0e-8;		
		double x2=Tc;
		double x1=x2*0.1;		
		int i=2;
		double h1=h;
		//System.out.println("h1=  "+h1);
		//System.out.println("x1= "+x1+" x2= "+x2);
                x=T_hP_LK_ML_reversebracket(x1,x2,P,h);	
	    x1=x[0][0];
            x2=x[1][0];
            if(x1==0 && x2==0) return 0.1;
           // System.out.println("x1= "+x1+" x2= "+x2);
	    //System.out.println("a");
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_TP_LK_ML(x1,P)-h1;
		fh=h_TP_LK_ML(x2,P)-h1;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);
		   // System.out.println("rtf="+rtf+" xl="+xl+" dx*fl="+(dx*fl)+"  (fl-fh)="+(fl-fh));
		    ff=h_TP_LK_ML(rtf,P)-h1;
		    //System.out.println("ff= "+ff+" rtf= "+rtf);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
	}           
   public double[][]  T_hP_LK_MV_reversebracket(double x1,double x2,double P,double h){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=h_TP_LK_MV(x,P)-h;
        //System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=h_TP_LK_MV(x,P)-h;
              // System.out.println("x="+x+"   x+dx"+(x+dx)+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb) {
                       //System.out.println("-----------------------baracket bitti----------------------");
                    return xb;                      
                }
	}
        if( nb == 0)	{
     //  System.out.println("arama tamamland? kök olan bölge bulunamad?");
        System.exit(1);
        }
else if(nb<nbb)
 System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
           //System.out.println("-----------------------baracket bitti----------------------");
        
    return xb;     
      
   }           
   public double T_hP_LK_MV(double h,double P){
		double[][] x=new double[2][1];             
                int MAXIT=40;
		double xacc=1.0e-7;		
		double x2=Tc*6;
		double x1=Tc*0.1;		
		int i=2;		
		//System.out.println("h1=  "+h1);
		//System.out.println("x1= "+x1+" x2= "+x2);
                x=T_hP_LK_MV_reversebracket(x1,x2,P,h);	
	    x1=x[0][0];
            x2=x[1][0];
            if(x1==0 && x2==0) return 0.1;
           //System.out.println("x1= "+x1+" x2= "+x2);
	    //System.out.println("a");
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_TP_LK_MV(x1,P)-h;
		fh=h_TP_LK_MV(x2,P)-h;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);
		   // System.out.println("rtf="+rtf+" xl="+xl+" dx*fl="+(dx*fl)+"  (fl-fh)="+(fl-fh));
		    ff=h_TP_LK_MV(rtf,P)-h;
		    //System.out.println("ff= "+ff+" rtf= "+rtf);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
	}         
   public double[][]  P_sT_LK_ML_reversebracket(double x1,double x2,double T,double s){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
            // System.out.println("-----------------------baracket----------------------");
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=s_TP_LK_ML(T,x1)-s;
      //  System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=s_TP_LK_ML(T,x)-s;
                //System.out.println("x="+x+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb){
                     // System.out.println("-----------------------baracket bitti----------------------");
                    return xb;
                }
	}
        if( nb == 0)	
        {  System.out.println("arama tamamland? kök olan bölge bulunamad? ----sonuç hatal?----");
        System.exit(1);}
else if(nb<nbb)
  System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
          // System.out.println("-----------------------baracket bitti----------------------");
return xb;     
          
   }           
   public double P_sT_LK_ML(double s,double T){
                int MAXIT=40;
		double xacc=1.0e-6;		
		double x2=Pc;
		double x1=0.01*x2;	
                double[][] x=new double[2][1];
                x=P_sT_LK_MV_reversebracket(x1,x2,T,s);
		x1=x[0][0];
                x2=x[1][0];
                int i=2;
		double s1=s;		
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=s_TP_LK_ML(T,x1)-s1;
		fh=s_TP_LK_ML(T,x2)-s1;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir  P_sT_LK_V" );
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);		  
		    ff=s_TP_LK_ML(T,rtf)-s1;
		   // System.out.println("rtf= "+rtf+"  ff= "+ff);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
                //System.out.println("del="+del);
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
            
        }       
   public double[][]  P_hT_LK_ML_reversebracket(double x1,double x2,double T,double h){
       // n : verilen bölgeyi böldü?ümüz alt bölge say?s?
	// x1,x2 : s?n?r de?erleri
	// nbb = aranan bölgedeki köksay?s?
	// f_x y function value    
       int nbb=1;
       int n=10;
        int nb;
	int i;
	double x,fp,fc,dx;
	double xb[][]=new double[2][1];
	nb=0;
	dx=(x2-x1)/n;
	x=x1;        
	fp=h_TP_LK_ML(T,x)-h;
       // System.out.println("x="+x+"  fp="+fp);
	for (i=1;i<=n;i++) {
		x+=dx;
		fc=h_TP_LK_ML(T,x)-h;
              //  System.out.println("x="+x+"  fc="+fc);
		// e?er kök olan bölge bulunduysa.....
		if (fc*fp < 0.0 || fp==0) {
			xb[0][nb]=x-dx;
			xb[1][nb]=x;
			nb++;
		}
		fp=fc;
		if (nbb == nb) {
                    //   System.out.println("-----------------------baracket bitti----------------------");
                    return xb;                      
                }
	}
        if( nb == 0)	{
       System.out.println("arama tamamland? kök olan bölge bulunamad?");
        System.exit(1);
        }
else if(nb<nbb)
 System.out.println("arama tamamland? sadece "+nb+"adet kök bulundu");
           //System.out.println("-----------------------baracket bitti----------------------");
        
    return xb;     
      
   }        
   public double P_hT_LK_ML(double h,double T){
		double[][] x=new double[2][1];             
                int MAXIT=40;
		double xacc=1.0e-6;		
		double x2=Pc;
		double x1=0.01*Pc;		
		int i=2;
		double h1=h;
		//System.out.println("h1=  "+h1);
		//System.out.println("x1= "+x1+" x2= "+x2);
                x=P_hT_LK_ML_reversebracket(x1,x2,T,h);	
	    x1=x[0][0];
            x2=x[1][0];
            if(x1==0 && x2==0) return 0.1;
           // System.out.println("x1= "+x1+" x2= "+x2);
	    //System.out.println("a");
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_TP_LK_ML(T,x1)-h1;
		fh=h_TP_LK_ML(T,x2)-h1;
		//System.out.println("fl="+fl+" fh="+fh);
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		    //System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);
		   // System.out.println("rtf="+rtf+" xl="+xl+" dx*fl="+(dx*fl)+"  (fl-fh)="+(fl-fh));
		    ff=h_TP_LK_ML(T,rtf)-h1;
		    //System.out.println("ff= "+ff+" rtf= "+rtf);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
	}  
   public double V_hT_LK_ML(double h,double T){
		int MAXIT=30;
		double xacc=1.0e-10;		
		double x2=Vc;
		double x1=x2/2;		
		int i=2;
		double h1=h;
		//System.out.println("x1= "+x1+" x2= "+x2);				
		while((h_TV_LK_ML(T,x1)-h1)*(h_TV_LK_ML(T,x2)-h1)>0){
		x1=x2/Math.pow(2,i);					
		i++;
	    }
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_TV_LK_MV(T,x1)-h1;
		fh=h_TV_LK_MV(T,x2)-h1;
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    for (j=1;j<=MAXIT;j++){
		    rtf=xl+dx*fl/(fl-fh);
		    ff=h_TV_LK_ML(T,rtf)-h1;
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti");
		return rtf;
	}          
   public double V_sT_LK_MV(double s,double T){
            int MAXIT=30;
		double xacc=1.0e-5;		
		double x2=Pc;
		double x1=0;		
		int i=2;
		double s1=s;
		//System.out.println("s1=  "+s1);
		//System.out.println("x1= "+x1+" x2= "+x2);		
	       int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=s_TV_LK_MV(T,x1)-s1;
		fh=s_TV_LK_MV(T,x2)-s1;	
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    //System.out.println("b");
	    for (j=1;j<=MAXIT;j++){	
		   // System.out.println("-------------------------"+j+". iterasyon------------------------------------");	    
		    rtf=xl+dx*fl/(fl-fh);
		    //System.out.println("rtf="+rtf+" xl="+xl+" dx*fl="+(dx*fl)+"  (fl-fh)="+(fl-fh));
		    ff=s_TV_LK_MV(T,rtf)-s1;
		   // System.out.println("ff= "+ff+" rtf= "+rtf);
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0)return rtf;
		}	
		//System.out.println("iterasyon bitti"+" rtf= "+rtf);
		return rtf;
            
        }            
   public double T_h_LK_MSL(double h){
		//h_T_LK_SL(x);
		int MAXIT=30;
		double xacc=1.0e-10;		
		double x2=Tc;
		double x1=x2/2;		
		int i=2;
		//System.out.println("iterasyon başlıyor");
		//System.out.println("h=  "+h);		
		while((h_T_LK_MSL(x1)-h)*(h_T_LK_MSL(x2)-h)>0){
		x1=x2/Math.pow(2,i);
		/*System.out.println("x1=  "+x1);
		System.out.println("(h_T_LK_SL(x1)-h)=  "+(h_T_LK_SL(x1)-h));
		System.out.println("(h_T_LK_SL(x2)-h)=  "+(h_T_LK_SL(x2)-h));	*/		
		i++;
	    }
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_T_LK_MSL(x1)-h;
		fh=h_T_LK_MSL(x2)-h;
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    for (j=1;j<=MAXIT;j++){
		    rtf=xl+dx*fl/(fl-fh);
		    ff=h_T_LK_MSL(rtf)-h;
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti");
		return rtf;
	}               
   public double P_hT_LK_MV(double h,double T){		
		//h_TV_LK_V(pro[1],pro[2])-h_TV_LK_V(298,pro[2]);
		int MAXIT=30;
		double xacc=1.0e-10;		
		double x2=Vc;
		double x1=x2/2;		
		int i=2;
		double h1=h;				
		while((h_TP_LK_MV(T,x1)-h1)*(h_TP_LK_MV(T,x2)-h1)>0){
		x1=x2/Math.pow(2,i);					
		i++;
	    }
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_TP_LK_MV(T,x1)-h1;
		fh=h_TP_LK_MV(T,x2)-h1;
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    for (j=1;j<=MAXIT;j++){
		    rtf=xl+dx*fl/(fl-fh);
		    ff=h_TP_LK_MV(T,rtf)-h1;
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti");
		return rtf;
	}               
   public double V_hT_LK_MV(double h,double T){		
		//h_TV_LK_V(pro[1],pro[2])-h_TV_LK_V(298,pro[2]);
		int MAXIT=30;
		double xacc=1.0e-10;		
		double x2=Vc;
		double x1=x2/2;		
		int i=2;
		double h1=h;				
		while((h_TV_LK_MV(T,x1)-h1)*(h_TV_LK_MV(T,x2)-h1)>0){
		x1=x2/Math.pow(2,i);					
		i++;
	    }
		int j;		
		double fl,fh,xl,xh,swap,dx,del,ff;
		double rtf=x1;
		fl=h_TV_LK_MV(T,x1)-h1;
		fh=h_TV_LK_MV(T,x2)-h1;
		if (fl*fh > 0.0)
		System.out.println("Kök sınırlarında hata oluştu sonuç hatalı olabilir");
		if (fl < 0.0){
			xl=x1;
			xh=x2;
		}
		else {
			xl=x2;
			xh=x1;
			swap=fl;
			fl=fh;
			fh=swap;
	    }
	    dx=xh-xl;
	    for (j=1;j<=MAXIT;j++){
		    rtf=xl+dx*fl/(fl-fh);
		    ff=h_TV_LK_MV(T,rtf)-h1;
		if (ff < 0.0){
			del=xl-rtf;
			xl=rtf;
			fl=ff;
		} else {
			del=xh-rtf;
			xh=rtf;
			fh=ff;
		}
		dx=xh-xl;
		if (Math.abs(del) < xacc || ff == 0.0) return rtf;
		}	
		//System.out.println("iterasyon bitti");
		return rtf;
	}  
	
	 public String[][] toString1(String knownpro,double v1, double v2){ 
	    String s1[][]=new String[16][3]; 
	    
	double ipro[]=property_SI(knownpro,v1,v2);    
	for(int i=0;i<ipro.length;i++){
			s1[i][1]= i==7 ? zoneName((int)ipro[7]) : ""+ipro[i];			
			
	}
	    s1[0][0]="P, pressure                  ";  
	    s1[1][0]="T, temperature               ";  	
	    s1[2][0]="v, specific volume           ";  	
	    s1[3][0]="h, enthalpy                  ";	
	    s1[4][0]="u, internal energy           ";	
	    s1[5][0]="s, entropy                   ";
	    s1[6][0]="x,                           ";
	    s1[7][0]="zone name                    ";
	    s1[8][0]="Compressibility factor       ";
	    s1[9][0]="g, qibbs free energy         ";	
	   s1[10][0]="s, surface tension           ";
	   s1[11][0]="cp, specific heat constant v ";
	   s1[12][0]="cv, specific heat constant v ";
	   s1[13][0]="M, molecular weight          ";
	   if(ipro[7]==1 || ipro[7]==2 || ipro[7]==3 || ipro[7]==6) s1[14][0]="kv, vapour conductivity      ";
       else if(ipro[7]==7 || ipro[7]==5)                        s1[14][0]="kl, liquid conductivity      ";                            
       else                                                     s1[14][0]="klv, mixture conductivity    ";
       if(ipro[7]==1 || ipro[7]==2 || ipro[7]==3 || ipro[7]==6) s1[15][0]="muv, vapour viscosity        ";
       else if(ipro[7]==7 || ipro[7]==5)                        s1[15][0]="mul, liquid viscosity        ";                            
       else                                                     s1[15][0]="mulv, mixture viscosity      ";   
	    
	    s1[0][2]=" bars          ";   
	    s1[1][2]=" deg K         ";   
	    s1[2][2]=" m^3/kmole     ";   
	    s1[3][2]=" KJ/kmole      ";   
	    s1[4][2]=" KJ/kmole      ";   
	    s1[5][2]=" KJ/kmole K    ";   
	    s1[6][2]="               ";   
	    s1[7][2]="               ";   
	    s1[8][2]="               ";   
	    s1[9][2]=" KJ/kmole      ";  
	   s1[10][2]=" N/m           "; 
	   s1[11][2]=" KJ/kmole K    ";
	   s1[12][2]=" KJ/kmole K    ";
	   s1[13][2]=" kg/kmole      ";
	   s1[14][2]=" W/(m.K)       ";
	   s1[15][2]=" Pa.s          "; 	     	    
	    return s1; 
	 } 	
	
/*
*Implemented methods from fluidInterface class
*/ 	
	public static absfluid getInstance(String fluidName) throws java.io.IOException{	 	
	 	return new LeeKeslerMix(fluidName);	
 	}
	public double h_TP(double T,double P) throws GException {
			int z=zone(T,P);    	       
            if(z==1 ||z==3 || z==6 || z==2) {
                //vapor , supercritical fluid , superheated vapor		                             
                 return h_TP_LK_MV(T,P);		                     
            }		       
            else if(z==7){                                
                return h_T_LK_MSL(T);		                          
            }		       
            else if(z==5){
                //liquid		                    		       
                return h_TP_LK_ML(T,P);		                      
            }		      
            else if(z==4){
                //vapor-liquid mixture	               	       
                return h_P_LK_MSL(T)+x_tp(T,P)*(h_P_LK_MSV(T)-h_P_LK_MSL(T));             
            } 
            else throw new UnDefinedStituationException();            
	}	
	public double h_TV(double T,double V)throws GException{return 0;}
	public double x(double T,double V)throws GException{
			int z=zonev(T,V);
			 if(z==1 ||z==3 || z==6 || z==2) {
                //vapor , supercritical fluid , superheated vapor		                             
                 return 2;		                     
            }		       
            else if(z==7){                                
                return 0;		                          
            }		       
            else if(z==5){
                //liquid		                    		       
                return -1;		                      
            }		      
            else if(z==4){
                //vapor-liquid mixture		       
                return x_tv(T,V);             
            } 
            else throw new UnDefinedStituationException();          
	}
	public double T(double h,double P) throws GException{
		return 0;
	}
	public double k(double T,double P) throws GException {
			int z=zone(T,P);	    		       
            if(z==1 ||z==3 || z==6 || z==2) {
                //vapor , supercritical fluid , superheated vapor    
                return kv_TP_LK_MV(T,P);               	       
            }		       
            else if(z==7){
                //saturated liquid	      
                return kl_T_LK_ML(T);                      
            }		       
            else if(z==5){
                //liquid         
                return kl_T_LK_ML(T);                
            }		      
            else if(z==4){               
                return kv_TP_LK_MV(T,P);                
            }
            else throw new UnDefinedStituationException();           
	}
	public double vis(double T,double P) throws GException {
			int z=zone(T,P);	    		       
            if(z==1 ||z==3 || z==6 || z==2) {
                //vapor , supercritical fluid , superheated vapor               
                return vis_T_L_MLPV(T);
                	       
            }		       
            else if(z==7){
                //saturated liquid	                
                return vis_T_PS_MLTL(T);	       
            }	       
            else if(z==5){
                //liquid                 
                return vis_T_PS_MLTL(T);   
            }		      
            else if(z==4){          
                return vis_T_L_MLPV(T); 
            }
            else throw new UnDefinedStituationException();            
	}
	public double ro(double T,double P)throws GException{
			int z=zone(T,P);    	       
            if(z==1 ||z==3 || z==6 || z==2) {
                //vapor , supercritical fluid , superheated vapor		                             
                 return 1/V_TP_LK_MV(T,P);		                     
            }		       
            else if(z==7){                                
                return 1/V_T_LK_MSL(T);		                          
            }		       
            else if(z==5){
                //liquid		                    		       
                return 1/V_TP_LK_ML(T,P);		                      
            }		      
            else if(z==4){
                //vapor-liquid mixture		       
                return 1/V_T_LK_MSV(T);             
            } 
            else throw new UnDefinedStituationException();  	
			
	}
	public double cp(double T,double P) throws GException {
			int z=zone(T,P);    	       
            if(z==1 ||z==3 || z==6 || z==2) {
                //vapor , supercritical fluid , superheated vapor		                             
                 return cp_TP_LK_MV(T,P);		                     
            }		       
            else if(z==7){                                
                return cp_T_LK_MSL(T);		                          
            }		       
            else if(z==5){
                //liquid		                    		       
                return cp_TP_LK_ML(T,P);		                      
            }		      
            else if(z==4){
                //vapor-liquid mixture		       
                return cp_T_LK_MSV(T);             
            } 
            else throw new UnDefinedStituationException(); 
	}
	public double sigma(double T,double P) throws GException {
			return STensionM(T);
	}
	   //--------------------------------------------------------------------

}//end of class


