HEAT TRANSFER OF COMBUSTION SYSTEMS I

 

CONVECTIVE HEAT TRANSFER FOR THE CYLINDER IN CROSS FLOW

When flow passes through a cylinder curvature of the surface causes seperatio of the boundary layer from the surface, inverse direction flows flow vortices. Therefore flow can not be seperated as turbulent and laminar flow (being turbulent or laminar is depends on angle from the entry

Drag Coefficient in flow across the cylinder:

  where FD is the drag force, Af is the cylinder frontal area. Drag coefficient   for a smooth cylinder with different Re numbers are listed in the table below.

Curve fitting coefficients z=log10(Re)

 

a0

9.07761707258

a1

-16.33173325480

a2

15.95794360346

a3

-8.53288480165

a4

4.48774899067

a5

-3.25082959759

a6

1.72646242637

a7

-0.53044708645

a8

0.09163176753

a9

-0.00833081014

a10

0.00031109691

 

Let us plot the curve fitting function to observe the change of the drag coefficient

public class if_poly implements if_x

{ double a[];

  public if_poly(double ai[])

  {a=ai;}

   public double func(double x)

   {// this function calculates the value of

    // a polynomial

    int n=a.length;

    double ff;

    if(n!=0.0)

    { ff=a[n-1];

      for(int i=n-2;i>=0;i--)

      { ff=ff*x+a[i]; }

    }

    else

      ff=0;

    return ff;

    }

}

 

public class HT_drag_cylinder

{ public static void main(String arg[])

  {double a[]={9.07761707258,-16.33173325480,15.95794360346,-8.53288480165,

  4.48774899067,-3.25082959759,1.72646242637,-0.53044708645,0.09163176753,

  -0.00833081014,0.00031109691};

  if_poly f=new if_poly(a);

  Plot p=new Plot(f,0.0,6.0);

  p.plot();

}}

In the following figure drag coefficient is shown with actual data points

In the following figure effect of surface rougness on variation of the drag coefficient for across the cylinder is shown.

Heat transferr across a cylinder

Hilpert equation[31]:

             Properties are evaluated at

Re

C

m

0.4 - 4

0.989

0.330

4-40

0.911

0.385

40-4000

0.683

0.466

4000 - 40000

0.193

0.618

40000 - 400000

0.027

0.805

 

Churchill & Bernstein[30] equation:

      

Properties are evaluated at  film temperature

Zukauskas[29] equation:

            Properties are evaluated at  except Prs is evaluated at surface temperature. If  n=0.37, if  n=0.36

Coefficients of the equation are given as

Re

C

m

1 - 40

0.75

0.4

40-1000

0.51

0.5

103 – 2x105

0.26

0.6

2x105 – 106

0.076

0.7

In this equation Prs is calculated at surface temperature while remaining properties are at film temperature

Problem: Exhaust gas at =226.85 C and 101.325 kPa pressure flowing through a cylinder with a velocity of 10 m/s. Cylinder has a diameter of D=12.7x10-3 m and has a length of 100 mm. Its surface temperature is measured as Ts=126.85 C. Calculate overall heat transfer coefficients and heat transfer by using all three equations given above.

Exhaust gas :

CO2

3

9.81%

H2O

4

13.08%

O2

1

3.27%

N2

22.57143

73.83%

 

 

 public class HT_crossflow_cylinder_exhaust

{  Gmix g;

   public HT_crossflow_cylinder_exhaust(String gname[],double n[])

   {g=new Gmix("exhaust gas",gname,n);}

 

  public double h1(double V,double Tinf,double Ts,double P,double D)

  {//Nusselt number Hilpert equation

   double Re=Re(V,Tinf,P,D);

   double Pr=g.Prandtl(Tinf);

   double k1=g.k(Tinf);

   double Nu=0.0;

   double C=0;

   double m=0;

   if(Re>0.4 && Re<=4) {C=0.989;m=0.330;}

   else if(Re>4.0 && Re<=40) {C=0.911;m=0.385;}

   else if(Re>40.0 && Re<=4000) {C=0.683;m=0.466;}

   else if(Re>4000.0 && Re<=40000) {C=0.193;m=0.618;}

   else if(Re>40000.0 && Re<=400000) {C=0.027;m=0.805;}

   Nu=C*Math.pow(Re,m)*Math.pow(Pr,(1.0/3.0));

   return Nu*k1/D;

   }

   public double h2(double V,double Tinf,double Ts,double P,double D)

  {//Nusselt number Churchill & Bernstein equation

   double Tf=(Tinf+Ts)/2.0;

   double Re=Re(V,Tf,P,D);

   double Pr=g.Prandtl(Tinf);

   double k1=g.k(Tinf);

   double Nu=0.3+0.62*Math.pow(Re,0.5)*Math.pow(Pr,(1.0/3.0))/Math.pow((1+Math.pow((0.4/Pr),(2.0/3.0))),0.25);

   Nu*=Math.pow((1+Math.pow((Re/282000),(5.0/8.0))),(4.0/5.0));

   return Nu*k1/D;

   }

  public double h3(double V,double Tinf,double Ts,double P,double D)

  {//Nusselt number Zukauskas equation

   double Re=Re(V,Tinf,P,D);

   double Pr=g.Prandtl(Tinf);

   double k1=g.k(Tinf);

   double Prs=g.Prandtl(Ts);

   double Nu=0.0;

   double C=0;

   double m=0;

   double n=0;

   if(Re>1 && Re<=40) {C=0.75;m=0.4;}

   else if(Re>40.0 && Re<=1000) {C=0.51;m=0.5;}

   else if(Re>40.0 && Re<=4000) {C=0.683;m=0.466;}

   else if(Re>1000.0 && Re<=2e5) {C=0.26;m=0.6;}

   else if(Re>2e5 && Re<=1e6) {C=0.076;m=0.7;}

   if(Pr<=10) n=0.37;

   else n=0.36;

   Nu=C*Math.pow(Re,m)*Math.pow(Pr,n)*Math.pow((Pr/Prs),0.25);

   return  Nu*k1/D;

   }

  public  double Re(double V,double T,double P,double D)

  {   double mu=g.vis(T);

      double ro=1.0/g.v(T,P);

      double Re=ro*V*D/mu;

                  return Re;

  }               

  public static void main(String arg[])

  { String s1[]={"co2","h2o","o2","n2"};

    double n1[]={0.0981,0.1308,0.0327,0.7383};

     HT_crossflow_cylinder_exhaust ht=new  HT_crossflow_cylinder_exhaust(s1,n1);

                double Ts=126.85+273.15;  //water temp. degree K;

    double Tinf=226.85+273.15; //exhaust gas temperature

    double Tf=(Ts+Tinf)/2.0;

    double V=10.0; //m/s

    double L=5; // m

    double P=1.01325; //bar

    double D=12.7e-3; //m

    double h1=ht.h1(V,Tinf,Ts,P,D);

    double h2=ht.h2(V,Tf,Ts,P,D);

    double h3=ht.h3(V,Tinf,Ts,P,D);

    System.out.println("h1="+h1+" h2="+h2+" h3="+h3);

    double A=Math.PI*D*L;

    double Q1=h1*A*(Tinf-Ts);

    double Q2=h2*A*(Tinf-Ts);

    double Q3=h3*A*(Tinf-Ts);

    System.out.println("Q1="+Q1+" Q2="+Q2+" Q3="+Q3);

 

}}

 

---------- Capture Output ----------

> "E:\co\java\bin\javaw.exe" HT_crossflow_cylinder_exhaust

h1=17.411652470236252 h2=18.189882238499077 h3=15.136683528202356

Q1=347.3470287446902 Q2=362.87202260433924 Q3=301.9634154516549

> Terminated with exit code 0.

 

 

13. CONVECTIVE HEAT TRANSFER FOR INTERNAL FLOW

13.1 PRESSURE DROP IN PIPES

Pressure drop in pipes can be calculated by using Darcy-Weisbach formula. In order to use this formula, Darcy friction factor should be known. The best approximation to Darcy friction factor for turbulent flow is given by Colebrook-White equation. This equation can only be solved by numerical root finding methods which requires relatively costly computer calculations. There are several other approximation equations to Darcy friction factor with some relative error compared to Colebrook-White equation. In some of this equations the error percentage is so small that they can be directly used in place of Colebrook equation. This set of equations will be investigated in here.

 

Darcy-Weisbach formula is given as:

 

In this equation  is the pressure drop, f is the friction factor, L is the length of pipe, U is fluid average velocity, D is pipe diameter. Fiction factor f  is depends on flow regime. For laminar flow (Recritical=2300) Hagen-Poiseuille equation can be used.

  where Re is Reynolds’ number,  is dynamic viscosity, D pipe inlet diameter and  is the density.

 

For turbulent region Colebrook-White(1937) [4] equation is existed.

 

In this equation  is called surface roughness. Surface roughness of some common materials are given in the table below:

name

status

Aluminium, drawn/pressed

new

0.0013 - 0.0015 mm

Aluminium, drawn/pressed

used

to 0.03 mm

Asbestos-cement

new, smooth

0.03 - 0.1 mm

Brass, drawn/pressed

new

0.0013 - 0.0014 mm

Brass, drawn/pressed

used

to 0.03 mm

Cast iron

average city severage

1.2 mm

Cast iron

incrusted

to 3.0 mm

Cast iron

new, bituminized

0.10 - 0.13 mm

Cast iron

new, with skin

0.2 - 0.6 mm

Cast iron

operating several years, cleaned

1.5 mm

Cast iron

slightly rusty

1.0 - 1.5 mm

Clay

new, clay tile

9.0 mm

Clay, Drainage-pipe

new, calcined

0.7 mm

Concrete

new, medium rough

1.0 - 2.0 mm

Concrete

new, rough

2.0 - 3.0 mm

Concrete

new, smooth

0.3 - 0.8 mm

Concrete

operating several years

0.2 - 0.3 mm

Concrete, Centrifugal-

new, smooth plastered

0.1 - 0.15 mm

Concrete, Centrifugal-

new, without plaster

0.2 - 0.8 mm

Concrete, Steel-

new, smooth

01. - 0.15 mm

Copper, drawn/pressed

new

0.0013 - 0.0015 mm

Copper, drawn/pressed

used

to 0.03 mm

Glass, drawn/pressed

new

0.0013 - 0.0015 mm

Glass, drawn/pressed

used

to 0.03 mm

Plastic, drawn/pressed

new

0.0013 - 0.0015 mm

Plastic, drawn/pressed

used

to 0.03 mm

Rubber

new, smoot

0.0016 mm

Steel

after long operation cleaned

0.15 - 0.20 mm

Steel

homogeneous corrosion pits

0.15 mm

Steel

intensely incrusted

2.0 - 4.0 mm

Steel

slightly rusty and incrusted

0.15 - 0.40 mm

Steel, longitudinal welded

new, bituminized

0.01 - 0.05 mm

Steel, longitudinal welded

new, galvanized

0.008 mm

Steel, longitudinal welded

new, rolling skin

0.04 - 0.1 mm

Steel, weldless

new, comm.size galvanized

0.10 - 0.16 mm

Steel, weldless

new, neatly galvanized

0.07 - 0.10 mm

Steel, weldless

new, pickled

0.03 - 0.04 mm

Steel, weldless

new, rolling skin

0.02 - 0.06 mm

Steel, weldless

new, unpickled

0.03 - 0.06 mm

Stoneware

 

0.25 mm

Wood

after long operating

0.1 mm

Wood

new

0.2 - 1.0 mm

 

As it is seen from the equation in order to solve this equation numerical root finding methods should be used. As an example Let us investigate a very simple Newton-Raphson Root Finding Method.

 

 

 

 

Newton Raphson formula:

 

  k=0,…,n

In order to solve the equation some initial guess is also required.

PROBLEM: Water with temperature of T=26.85 C and P=300 kPa is flowing through a D=25x10-3 m commercial steel pipe. Find total pressure drop.

import javax.swing.*;

/* a[0] "P, pressure        ";

   a[1] "T, temperature     ";

   a[2] "v, specific volume ";

   a[3] "h, enthalpy        ";

   a[4] "u, internal energy ";

   a[5] "s, entropy         ";

   a[6] "x, quality         ";

   a[7] "Cp, specific heat at constant pressure ";

   a[8] "Cv, specific heat at constant volume ";

   a[9] ""+'\u03B1'+" isobaric thermal expansion coefficient ";

   a[10] ""+'\u03BA'+" isothermal compressibility" ;

   a[11] ""+'\u03B7'+" Dynamic viscosity" ;

   a[12] "k Thermal conductivity" ;

   a[13] ""+'\u03C3'+" Surface tension" ;

   a[14] "Prandtl number" ;

   a[15] ""+'\u03C1'+" density" ;

   a[16] " speed of sound" ;

*/

public class water

{ public steamIAPWS_IF97 st;

  public water()

  {st=new steamIAPWS_IF97();}

  public double[] property_TP(double T,double P)

  { // T degree K P kPa

    // 0 T 1 P 2 ro 3 h 4 s 5 Cp 6 k 7 mu 8 alpha 9 Pr

    double a[]=st.property("tp",T,P);

    double b[]=new double[12];

    b[0]=T;

    b[1]=P;

    //double multiply[]={1,1,1,1,1,1,1e-3,1e-6,1e-4,1};

    b[2]=a[15];     //ro kg/m^3

    b[3]=a[3];      //h kJ/kg

    b[4]=a[5];      //s kJ/kgK

    b[5]=a[7];      //Cp kJ/kgK

    b[6]=a[12];     //k W/mK

    b[7]=a[11];     //mu Pas

    b[8]=b[6]/(b[2]*b[5]*1e3); //alpha m^2/s

    b[9]=a[14];  //Pr

    b[10]=a[13];  //surface tension sigma

    b[11]=a[16];   //speed of sound

    return b;   

  }

 

  public static void main(String arg[])

  {water w=new water();

   double T=Double.parseDouble(JOptionPane.showInputDialog("T degree K = "));

   double P=Double.parseDouble(JOptionPane.showInputDialog("P kg/m^3 = "));

   double a[]=w.property_TP(T,P);

   String s[]={"T degree K","P kPa",""+'\u03C1'+" kg/m^3","h kJ/kg","s kJ/kgK","Cp kJ/kgK","k W/mK",""+'\u03BC'+" Pas",""+'\u03B1'+" m^2/s","Pr",""+'\u03C3'+" N/m","speed of sound m/s"};

   Text.print(a,s,"Thermophysical properties of steam");

  }   }

 

public class newtonA

{  public static double newton(if_x f,double x)

   {double eps=1.0e-10;

    while(Math.abs(f.func(x))>eps)

    {x=x-f.func(x)/f.dfunc(x);

    }

   return x;

   }

   public static double newton(if_x f,if_x df,double x)

   {double eps=1.0e-10;

    while(Math.abs(f.func(x))>eps)

    {x=x-f.func(x)/df.func(x);}

   return x;

   }

                public static void main(String arg[])

                {     double T=26.85+273.15;  // degree K

                      double P=300.0;         // kPa

                      double U=3.0;           // velocity m/s

                      double e=0.16e-3;       //surface rougness m

                      double D=25e-3;         // diameter m

                      double L=1; //m

                      water w=new water();

                      double a[]=w.property_TP(T,P);

                      double mu=a[7];

                      double ro=a[2];

                      double Re=ro*U*D/mu;

                      System.out.println("T="+T+" degree K");

                      System.out.println("ro="+ro+" kg/m^3");

                      System.out.println("P="+P+" kPa");

                      System.out.println("U="+U+" m/s");

                      System.out.println("D="+D+" m");

                      System.out.println("e="+e+" m");

                                 if_x f1=X->X+2.0*Math.log10((e/D)/3.7+2.51/Re*X);

                      if_x df1=X->1.0+2.0*(2.51/Re)/((e/D)/3.7+2.51/Re*X);

                      double X0=1.0/Math.sqrt(0.001);

                      double X1=newton(f1,df1,X0);

                      double f=1.0/(X1*X1);

                      double A=Math.PI*D*D/4.0;

                      double m=ro*A*U;  //kg/s

                      double dP=f*L/D*ro*U*U/2.0;

                      System.out.println("f = "+f);

                      System.out.println("dP = "+dP);

                }}

 

 ---------- Capture Output ----------

> "D:\co\java\bin\java.exe" newtonA

T=300.0 degree K

ro=996.6470643119458 kg/m^3

P=300.0 kPa

U=3.0 m/s

D=0.025 m

e=1.6E-4 m

f = 0.03368023003583202

dP = 6042.114430301341

> Terminated with exit code 0.

 

In the chart given below laminar and turbulent flow friction coefficient shown graphically.

There are other approximation equations that root finding is not employed. Some of them are listed below:

Haaland equation (1983) [4]

 

Moody  equation(1944) [9]

 

Wood equation (1966)  [18] Valid region: Re>10000 , 10-5<<0.04

 

 

                                     

                                                                        

Churchill equation (1977)  [3] Valid region: valid for all regions

 

 

 

Chen equation (1979)  [2] Valid region: all values

 

 

Swamee-Jain  equation (1976)  [14] Valid region: 5000>Re>107 , 0.00004<<0.05

 

 

Zigrang - Sylvester equation (1982) [20] Valid region: all values

 

 

 

Serghides equation (1984) [22] Valid region: all values

 

 

 

 

Goudar- Sonnad equation (2008)[21] Valid region: all values

 

 

 

 

 

      

      

      

 

 

 

Romeo Equation (2002) [11] Valid region: all values

 

 

 

 

 

Out of these equations Goudar-Sonnad & Serghides equations are given such an accurate results that they can be directly replace Colebroke-White equation to calculate the friction factor. Now let us try out different friction equations with the same problem.

 

PROBLEM: Water with temperature of T=26.85 C and P=300 kPa is flowing through a D=25x10-3 commercial steel pipe. Find total pressure drop. Try all different friction factor equations

import java.io.*;

public class colebrook2

{

 

 public static double f_Haaland(double Re,double eod)

 {

 //Haaland equation

 double f1=-1.8*Math.log10(Math.pow((eod/3.7),1.11)+6.9/ Re);

 f1=1.0/(f1*f1);

 return f1;

 }

 

 public static double f_Moody(double Re,double eod)

 {

 // Moody equation

 // 4000<Re<107 and e/D <0.01

 double f1=5.5e-3*(1+Math.pow((2e4*eod+1e6/Re),(1.0/3.0)));

 return f1;

 }

 

 public static double f_Wood(double Re,double eod)

 {

 // Wood equation

 // Re>10000 and any e/D

 double a=0.52*eod+0.094*Math.pow(eod,0.225);

 double b=88.0*Math.pow(eod,0.44);

 double C=1.62*Math.pow(eod,0.134);

 double f1=a+b*Math.pow(Re,-C);

 return f1;

 }

 

 public static double f_Churchill(double Re,double eod)

 {

 // Churchill equation

 // for all values of Re and e/D

 double A=Math.pow((-2.457*Math.log(Math.pow((7.0/Re),0.9)+0.27*eod)),16);

 double B=Math.pow((37530.0/Re),16);

 double f1=8.0*Math.pow((Math.pow((8.0/Re),12)+1.0/Math.pow((A+B),1.5)),(1.0/12.0));

 return f1;

 }

 

 public static double f_Chen(double Re,double eod)

 {

 // Chen equation

 // for all values of Re and e/D

 double A = Math.log10(Math.pow(eod,1.1098)/2.8257 + (5.8506/Math.pow(Re,0.8981)));

 double f1=-2.0*Math.log10(eod/3.7065-5.0452*A/Re);

 f1=1.0/(f1*f1);

 return f1;

 }

 

 public static double f_Swamee(double Re,double eod)

 {

 //Swamee-Jain equation

 double A=Math.log10(eod/3.7+5.74/Math.pow(Re,0.9));

 double f1=0.25/(A*A);

 return f1;

 }

 

 public static double f_Zigrand(double Re,double eod)

 {

 //Zigrang and Sylvester Equation

 // for 4000<Re<108  and 0.00004<e/D<0.05

 double A=Math.log10(eod/3.7-5.02/Re*Math.log10(eod/3.7+13/Re));

 double f1=-2.0*Math.log10((eod)/3.7-5.02*A/Re);

 f1=1.0/(f1*f1);

 return f1;

 }

 

 public static double f_Romeo(double Re,double eod)

 {

 // Romeo - Royo - Monzon Equation (2002)

 

 double A=Math.log10(eod/3.827-4.567/Re*Math.log10(Math.pow((eod/7.7918),0.9924)+Math.pow(5.3326/(208.815+Re),0.9345)));

 double f1=-2.0*Math.log10((eod)/3.7065-5.0272*A/Re);

 f1=1.0/(f1*f1);

 return f1;

 }

 

 public static double f_Serghides(double Re,double eod)

 {

 //Serghides equation

 // for Re>2100 and any e/D

 double A1=-2.0*Math.log10(eod/3.7+12.0/Re);

 double B1=-2.0*Math.log10(eod/3.7+2.51*A1/Re);

 double C1=-2.0*Math.log10(eod/3.7+2.51*B1/Re);

 double f1=A1-((B1-A1)*(B1-A1))/(C1-2.0*B1+A1);

 f1=1.0/(f1*f1);

 return f1;

 }

 

 public static double f_Goudar(double Re,double eod)

 {

 //Goudar Sonnad equation

 // for Re>2100 and any e/D

 double a=2/Math.log(10);

 double b=eod/3.7;

 double d=Math.log(10.0)/5.02*Re;

 double s=b*d+Math.log(d);

 double q=Math.pow(s,(s/(s+1)));

 double g=b*d+Math.log(d/q);

 double z=Math.log(q/g);

 double dLA=(g/(g+1))*z;

 double dCFA=dLA*(1+z/2.0/((g+1)*(g+1)+(z/3)*(2.0*g-1)));

 double f1=a*(Math.log(d/q)+dCFA);

 f1=1.0/(f1*f1);

 return f1;

 }

public static void main(String arg[]) throws IOException

{         double T=26.85+273.15;  // degree K

                      double P=300.0;         // kPa

                      double U=3.0;           // velocity m/s

                      double e=0.16e-3;       //surface rougness m

                      double D=25e-3;         // diameter m

                      double eod=e/D;

                      double L=1; //m

                      water w=new water();

                      double a[]=w.property_TP(T,P);

                      double mu=a[7];

                      double ro=a[2];

                      double Re=ro*U*D/mu;

                      System.out.println("T="+T+" degree K");

                      System.out.println("ro="+ro+" kg/m^3");

                      System.out.println("P="+P+" kPa");

                      System.out.println("U="+U+" m/s");

                      System.out.println("D="+D+" m");

                      System.out.println("e="+e+" m");

                      double f1=f_Haaland(Re,eod);

                      double f2=f_Moody(Re,eod);

                      double f3=f_Wood(Re,eod);

                      double f4=f_Churchill(Re,eod);

                      double f5=f_Chen(Re,eod);

                      double f6=f_Swamee(Re,eod);

                      double f7=f_Zigrand(Re,eod);

                      double f8=f_Romeo(Re,eod);

                      double f9=f_Serghides(Re,eod);

                      double f10=f_Goudar(Re,eod);

                      System.out.println("Friction factors:");

                      System.out.println("f Haaland = "+f1);

                      System.out.println("f Moody = "+f2);

                      System.out.println("f Wood = "+f3);

                      System.out.println("f Churchill = "+f4);

                      System.out.println("f Chen = "+f5);

                      System.out.println("f Swamee = "+f6);

                      System.out.println("f Zigrand = "+f7);

                      System.out.println("f Romeo = "+f8);

                      System.out.println("f Serghides = "+f9);

                      System.out.println("f Goudar = "+f9);

                      double A=Math.PI*D*D/4.0;

                      double m=ro*A*U;  //kg/s

                      double dP=f9*L/D*ro*U*U/2.0;

                      System.out.println("dP = "+dP);

}

//create_data();

}

 

---------- Capture Output ----------

> "D:\co\java\bin\java.exe" colebrook2

T=300.0 degree K

ro=996.6470643119458 kg/m^3

P=300.0 kPa

U=3.0 m/s

D=0.025 m

e=1.6E-4 m

Friction factors:

f Haaland = 0.03366809407987718

f Moody = 0.034019312456163006

f Wood = 0.03430754588971051

f Churchill = 0.033941360161729314

f Chen = 0.03369873685763093

f Swamee = 0.03395380279310423

f Zigrand = 0.03368022234776756

f Romeo = 0.03366856614181092

f Serghides = 0.03368023003463402

f Goudar = 0.03368023003463402

dP = 6042.114430086424

 

> Terminated with exit code 0.

 

import java.io.*;

class f4 extends f_x

{  public double func (double Re)

   {return 64.0/Re;}

}

class f3 extends fi_x 

{ public double eod[]={0.00001,0.00005,0.0001,0.0002,0.0004,0.0006,0.0008,0.001,0.002,0.003,0.004,0.006,0.008,0.01,0.015,0.02,0.03,0.04,0.05};

  public int n=eod.length;

double[] func(double Re) 

{ 

double f[]=new double[n];           

//f[0]=64.0/Re;

for(int i=0;i<n;i++) 

{f[i]=colebrook2.f_Goudar(Re,eod[i]);} 

return f; 

}} 

class PlotT3c 

{ 

public static void main (String args[]) throws IOException 

{

f3 ff=new f3();

f4 ff1=new f4();

Plot pp=new Plot(ff,2300.0,20000,1000,ff.n);

pp.addFunction(ff1,1000.0,2300,1000); 

//pp.setYlogScaleOn();

pp.setXgrid(5);

pp.setYgrid(20); 

pp.setPlabel("Laminar and Turbulent Flow Friction Coefficient"); 

pp.setXlabel("Re"); 

pp.setYlabel("f Goudar- Sonnad equation (2008)[21]"); 

pp.plot();}}

 

 

 

13.2 HEAT TRANSFER IN CIRCULAR PIPES

           

Entry Region for Laminar flow(Re<2300):

 

Entry Region for Turbulent flow(Re>2300):

 

mean temperature difference (derived by assuming Cp is constant) is

 

temperature going out of the bank is T0  can be estimated from

 once  known the heat transfer rate can be calculated

 

 

Heat transfer equations Fully developed Laminar flow (Re<2300)

Nu=3.66 Ts=const.

Nu=4.66 qs=const

 

Heat transfer equations Entry region Laminar flow Ts=const (Re<2300)

 

Hausen[26] equation:

 

 

Sieder & Tate Equation[25]

           <9.75

 

Heat transfer equations Fully developed turbulent flow Ts=const (Re>2300)

 

Dittus-Boelter equation[24]

 where n=0.4 for heating and n=0.3 for cooling  

  

 

Sieder-Tate equation[25]

          

 

Petukhov, Kirillov, and Popov[32] equation

        

A modified form of the equation

   n=0.11 for heating and n=0.25 for cooling

          

 

Gnielinski[33] equation

        

Gnielinski also suggested that

         

         

 

Sleicher and Rouse[79] equation

                      

 

Heat transfer equations Fully developed transitional/intermittent region  Ts=const

 

 

Abraham-Sparrow-Tong[34] equation

       

Abraham recommended Gnilenski equation to be used above Re>3100

 

Hausen[78] equation  for both liquid and gases Ts=const

  

 

PROBLEM: Water with temperature of T=26.85 C and P=300 kPa is flowing through a D=25x10-3 commercial steel pipe. Total pipe length L=2 m. Pipe surface temperature are kept constant at T=126.85 C. Find the total heat transfer and pipe exit temperature also find total pressure drop. Velocity is U=3 m/s

 

In the first approach to the problem an initial guess is assigned to the outside temperature and outside temperature is calculated at the end, if it is not resonable iterative process is applied.

import java.io.*;

public class HT_inside_pipe

{

 public static double f_Goudar(double Re,double eod)

 {

 //Goudar Sonnad equation

 // for Re>2100 and any e/D

 double a=2/Math.log(10);

 double b=eod/3.7;

 double d=Math.log(10.0)/5.02*Re;

 double s=b*d+Math.log(d);

 double q=Math.pow(s,(s/(s+1)));

 double g=b*d+Math.log(d/q);

 double z=Math.log(q/g);

 double dLA=(g/(g+1))*z;

 double dCFA=dLA*(1+z/2.0/((g+1)*(g+1)+(z/3)*(2.0*g-1)));

 double f1=a*(Math.log(d/q)+dCFA);

 f1=1.0/(f1*f1);

 return f1;

 }

 public static double Nu(double Re,double eod,double Pr)

 { //constant surface temperature internal flow

   double Nu=0;

   double x=Re/1000;

   double f=0;

   if(Re<2300) Nu=3.66;

   else if(Re>=2300 && Re<3100) Nu=2.2407*x*x*x*x-29.499*x*x*x+142.32*x*x-292.51*x+219.88;

   else {f=f_Goudar(Re,eod);

   Nu=(f/8)*(Re-1000.0)*Pr/(1.07+12.7*Math.sqrt(f/8)*(Math.pow(Pr,(2.0/3.0))-1));

   }

 return Nu;

   }

public static void main(String arg[]) throws IOException

{         double Ti=26.85+273.15;  // degree K

          double Ts=99.85+273.15; //degree K;

          double To=70.0+273.15;         //guess for outlet temperature To

          double T=(Ti+To)/2.0;

                      double P=300.0;         // kPa

                      double U=3.0;           // velocity m/s

                      double e=0.16e-3;       //surface rougness m

                      double D=25e-3;         // diameter m

                      double eod=e/D;

                      double L=2; //m

                      water w=new water();

                      double a[]=w.property_TP(T,P);

                      double ro=a[2];

                      double Cp=a[5];

                      double k=a[6];

                      double mu=a[7];

                      double Pr=a[9];

                      double Re=ro*U*D/mu;

                      System.out.println("T="+T+" degree K");

                      System.out.println("P="+P+" kPa");

                      System.out.println("U="+U+" m/s");

                      System.out.println("D="+D+" m");

                      System.out.println("e="+e+" m");

                      double f=f_Goudar(Re,eod);

                      System.out.println("f Goudar = "+f);

                      double Nu=Nu(Re,eod,Pr);

          double h=Nu*k/D;

          double A1=Math.PI*D*L;

          double Q1=h*A1*(Ts-T);

          System.out.print("h = "+h+"W/m^2K ");

          System.out.print("To initial = "+To);         

          To=Ti+Q1/(Cp*1e3);

          System.out.println(" To = "+To+"Q="+Q1);       

                      double A=Math.PI*D*D/4.0;

                      double m=ro*A*U;  //kg/s

                      System.out.println("m = "+m+"kg/s");

                      double dP=f*L/D*ro*U*U/2.0;

                      System.out.println("dP = "+dP);

}

//create_data();

}

 

 

---------- Capture Output ----------

> "D:\co\java\bin\java.exe" HT_inside_pipe

T=321.575 degree K

P=300.0 kPa

U=3.0 m/s

D=0.025 m

e=1.6E-4 m

f Goudar = 0.03338070406938855

h = 23310.932651973955W/m^2K To initial = 343.15 To = 345.0613334663793Q=188301.52057162303

m = 1.4561834076054112kg/s

dP = 11882.913018836436

> Terminated with exit code 0.

 

In the second approach problem is solved in finite difference steps. So that properties are taken as local water temperatures in each step.

 

import java.io.*;

public class HT_inside_pipe_FD

{

 public static double f_Goudar(double Re,double eod)

 {

 //Goudar Sonnad equation

 // for Re>2100 and any e/D

 double a=2/Math.log(10);

 double b=eod/3.7;

 double d=Math.log(10.0)/5.02*Re;

 double s=b*d+Math.log(d);

 double q=Math.pow(s,(s/(s+1)));

 double g=b*d+Math.log(d/q);

 double z=Math.log(q/g);

 double dLA=(g/(g+1))*z;

 double dCFA=dLA*(1+z/2.0/((g+1)*(g+1)+(z/3)*(2.0*g-1)));

 double f1=a*(Math.log(d/q)+dCFA);

 f1=1.0/(f1*f1);

 return f1;

 }

 public static double Nu(double Re,double eod,double Pr)

 { //constant surface temperature internal flow

   double Nu=0;

   double x=Re/1000;

   double f=0;

   if(Re<2300) Nu=3.66;

   else if(Re>=2300 && Re<3100) Nu=2.2407*x*x*x*x-29.499*x*x*x+142.32*x*x-292.51*x+219.88;

   else {f=f_Goudar(Re,eod);

   Nu=(f/8)*(Re-1000.0)*Pr/(1.07+12.7*Math.sqrt(f/8)*(Math.pow(Pr,(2.0/3.0))-1));

   }

 return Nu;

   }

public static void main(String arg[]) throws IOException

{         double Ti=26.85+273.15;  // degree K

          double Ts=99.85+273.15; //degree K;

          double T=Ti;

                      double P=300.0;         // kPa

                      double U=3.0;           // velocity m/s

                      double e=0.16e-3;       //surface rougness m

                      double D=25e-3;         // diameter m

                      double eod=e/D;

                      double L=2; //m

                      int N=100;

                      double dx=L/N;

                      double x=0;

                      double TT[]=new double[N+1];

                      double xx[]=new double[N+1];

                      water w=new water();

                      double ro,Cp,k,mu,Pr,Re,f,Nu,h,Q=0,Q1=0;

                      double A1=Math.PI*D*dx;

                      double A=Math.PI*D*D/4.0;

                      for(int i=0;i<=N;i++)

                      { double a[]=w.property_TP(T,P);

                        TT[i]=T;

                        xx[i]=i*dx;

            ro=a[2];

                        Cp=a[5];

                        k=a[6];

                        mu=a[7];

                        Pr=a[9];

                        Re=ro*U*D/mu;

            f=f_Goudar(Re,eod);

            Nu=Nu(Re,eod,Pr);

            h=Nu*k/D;

            Q1=h*A1*(Ts-T);

            Q+=Q1;         

            T=T+Q1/(Cp*1e3);

          }

          Plot p=new Plot(xx,TT);

          p.setPlabel("inside pipe constant surface temp Ts=const ");

          p.setXlabel("x m");

          p.setYlabel("T degree K");

          p.plot();

          System.out.println("Q="+Q+" Watt");

}

//create_data();

}

 

---------- Capture Output ----------

> "D:\co\java\bin\java.exe" HT_inside_pipe_FD

Q=180977.31507431748 Watt

 

If L=5 m of pipe is taken instead:

---------- Capture Output ----------

> "D:\co\java\bin\java.exe" HT_inside_pipe_FD

Q=285749.6814634827 Watt

 

PROBLEM: Water with temperature of T=26.85  and P=300 kPa is flowing through a Di=25x10-3  m , Do=28x10-3 m commercial steel pipe(k=36 W/mK) wit a velocity of V=2 m/s. Total pipe length L=200 m. In outside of the pipe exhaust gases  is flowing across the pipe with a velocity of V=10 m/s. Exhaust gas temperature is constant and  =226.85 .  Find the total heat transfer and pipe exit temperature also find total pressure drop.

Exhaust gas combination is as follows:

CO2

3

9.81%

H2O

4

13.08%

O2

1

3.27%

N2

22.57143

73.83%

 

 import java.io.*;

public class HT_inside_Outside_pipe_exhaust_gas

{ public Gmix g;  //exhaust gas mix

   public steamIAPWS_IF97 st; //steam and water

               

public  HT_inside_Outside_pipe_exhaust_gas(String gname[],double n[])

{g=new Gmix("exhaust gas",gname,n);

 st=new steamIAPWS_IF97();

}

 

  public double h1(double V,double Tinf,double Ts,double P,double D)

  {//Nusselt number Hilpert equation

   double Re=Re(V,Tinf,P,D);

   double Pr=g.Prandtl(Tinf);

   double k1=g.k(Tinf);

   double Nu=0.0;

   double C=0;

   double m=0;

   if(Re>0.4 && Re<=4) {C=0.989;m=0.330;}

   else if(Re>4.0 && Re<=40) {C=0.911;m=0.385;}

   else if(Re>40.0 && Re<=4000) {C=0.683;m=0.466;}

   else if(Re>4000.0 && Re<=40000) {C=0.193;m=0.618;}

   else if(Re>40000.0 && Re<=400000) {C=0.027;m=0.805;}

   Nu=C*Math.pow(Re,m)*Math.pow(Pr,(1.0/3.0));

   return Nu*k1/D;

   }

   public double h2(double V,double Tinf,double Ts,double P,double D)

  {//Nusselt number Churchill & Bernstein equation

   double Tf=(Tinf+Ts)/2.0;

   double Re=Re(V,Tf,P,D);

   double Pr=g.Prandtl(Tinf);

   double k1=g.k(Tinf);

   double Nu=0.3+0.62*Math.pow(Re,0.5)*Math.pow(Pr,(1.0/3.0))/Math.pow((1+Math.pow((0.4/Pr),(2.0/3.0))),0.25);

   Nu*=Math.pow((1+Math.pow((Re/282000),(5.0/8.0))),(4.0/5.0));

   return Nu*k1/D;

   }

  public double h3(double V,double Tinf,double Ts,double P,double D)

  {//Nusselt number Zukauskas equation

   double Re=Re(V,Tinf,P,D);

   double Pr=g.Prandtl(Tinf);

   double k1=g.k(Tinf);

   double Prs=g.Prandtl(Ts);

   double Nu=0.0;

   double C=0;

   double m=0;

   double n=0;

   if(Re>1 && Re<=40) {C=0.75;m=0.4;}

   else if(Re>40.0 && Re<=1000) {C=0.51;m=0.5;}

   else if(Re>40.0 && Re<=4000) {C=0.683;m=0.466;}

   else if(Re>1000.0 && Re<=2e5) {C=0.26;m=0.6;}

   else if(Re>2e5 && Re<=1e6) {C=0.076;m=0.7;}

   if(Pr<=10) n=0.37;

   else n=0.36;

   Nu=C*Math.pow(Re,m)*Math.pow(Pr,n)*Math.pow((Pr/Prs),0.25);

   return  Nu*k1/D;

   }

  public  double Re(double V,double T,double P,double D)

  {   double mu=g.vis(T);

      double ro=1.0/g.v(T,P);

      double Re=ro*V*D/mu;

                  return Re;

  }               

  //water side (inside pipe)

 public  double f_Goudar(double Re,double eod)

 {

 //Goudar Sonnad equation

 // for Re>2100 and any e/D

 double a=2/Math.log(10);

 double b=eod/3.7;

 double d=Math.log(10.0)/5.02*Re;

 double s=b*d+Math.log(d);

 double q=Math.pow(s,(s/(s+1)));

 double g=b*d+Math.log(d/q);

 double z=Math.log(q/g);

 double dLA=(g/(g+1))*z;

 double dCFA=dLA*(1+z/2.0/((g+1)*(g+1)+(z/3)*(2.0*g-1)));

 double f1=a*(Math.log(d/q)+dCFA);

 f1=1.0/(f1*f1);

 return f1;

 }

   //water side (inside pipe)

 public  double Nu(double Re,double eod,double Pr)

 { //constant surface temperature internal flow

   double Nu=0;

   double x=Re/1000;

   double f=0;

   if(Re<2300) Nu=3.66;

   else if(Re>=2300 && Re<3100) Nu=2.2407*x*x*x*x-29.499*x*x*x+142.32*x*x-292.51*x+219.88;

   else {f=f_Goudar(Re,eod);

   Nu=(f/8)*(Re-1000.0)*Pr/(1.07+12.7*Math.sqrt(f/8)*(Math.pow(Pr,(2.0/3.0))-1));

   }

 return Nu;

   }

public static void main(String arg[]) throws IOException

{        String s1[]={"co2","h2o","o2","n2"};

         double n1[]={0.0981,0.1308,0.0327,0.7383};

         HT_inside_Outside_pipe_exhaust_gas ht=new  HT_inside_Outside_pipe_exhaust_gas(s1,n1);

                      double Ti=26.85+273.15;  // degree K

          double Tinf=226.85+273.15; //degree K;

          double To=70.0+273.15;         //guess for outlet temperature To

          double T;

                      double P=300.0;         // kPa

                      double V=2.0;           // velocity m/s

                      double e=0.16e-3;       //surface rougness m

                      double Di=25e-3;         // diameter m

                      double Do=28e-3;         // diameter m

                      double eod=e/Di;

                      double L=200; //m

                      double kw=36.0; //W/mK

                      double a[];

                      double ro=0,Cp=0,k,mu,Pr,Re,f=0,Nu,h1,h2,U,Q1;

                      // iteration fr surface temperature T

                      for(int i=0;i<5;i++)

                      {

                                 T=(Ti+To)/2.0;

                      a=ht.st.property("tp",T,P);

                      ro=a[15];

                      Cp=a[7];

                      k=a[12];

                      mu=a[11];

                      Pr=a[14];

                      Re=ro*V*Di/mu;    

                      f=ht.f_Goudar(Re,eod);

                      System.out.println("f Goudar = "+f);

                      Nu=ht.Nu(Re,eod,Pr);

          h1=Nu*k/Di;

          //outside of the pipe

          h2=ht.h3(V,Tinf,T,P,Do);

          U=1.0/(1.0/(h1*(Math.PI*Di*L))+Math.log(Do/Di)/(2.0*Math.PI*kw*L)+1.0/(h2*(Math.PI*Do*L)));

          Q1=U*(Tinf-T);

           System.out.println("==== iteration i= "+i+"==============");

          System.out.println("Surface Temperature = "+T+" degree K");

          System.out.println("Cp = "+Cp+"J/kgK ");

          System.out.println("Q = "+Q1+"W/m^2K ");

          System.out.println("hi = "+h1+"W/m^2K ");

          System.out.println("ho = "+h2+"W/m^2K ");

          System.out.println("U = "+U+"W/K ");                  

          To=Ti+Q1/(Cp*1e3);

          T=(h2*Tinf+h1*T)/(h1+h2);

          System.out.println("Ti="+Ti+" degree K To = "+To+"  degree K");                     

          }

                      double A=Math.PI*Di*Di/4.0;

                      double m=ro*A*V;  //kg/s

                      System.out.println("m = "+m+" kg/s");

                      double dP=f*L/Di*ro*V*V/2.0;

                      System.out.println("dP = "+dP*1e-3+" kPa");

}

}

 

---------- Capture Output ----------

> "E:\co\java\bin\javaw.exe" HT_inside_Outside_pipe_exhaust_gas

f Goudar = 0.03367500764878147

==== iteration i= 0==============

Surface Temperature = 321.575 degree K

Cp = 4.1787826965244275J/kgK

Q = 326893.84212869185W/m^2K

hi = 15582.61533764829W/m^2K

ho = 105.41174252632993W/m^2K

U = 1832.1078443530437W/K

Ti=300.0 degree K To = 378.22704980581443  degree K

f Goudar = 0.03347045133256282

==== iteration i= 1==============

Surface Temperature = 339.1135249029072 degree K

Cp = 4.185253160282877J/kgK

Q = 295192.0122487482W/m^2K

hi = 18388.178143962425W/m^2K

ho = 105.44555900520638W/m^2K

U = 1834.7845092050397W/K

Ti=300.0 degree K To = 370.5314591361055  degree K

f Goudar = 0.03350799800550761

==== iteration i= 2==============

Surface Temperature = 335.26572956805273 degree K

Cp = 4.1832757696945855J/kgK

Q = 302167.3266355612W/m^2K

hi = 17789.875064131727W/m^2K

ho = 105.43850046212334W/m^2K

U = 1834.2711922859328W/K

Ti=300.0 degree K To = 372.2322273909334  degree K

f Goudar = 0.033499399509913846

==== iteration i= 3==============

Surface Temperature = 336.1161136954667 degree K

Cp = 4.183686088030815J/kgK

Q = 300626.5911366042W/m^2K

hi = 17922.995230472472W/m^2K

ho = 105.4400763851273W/m^2K

U = 1834.3877358264012W/K

Ti=300.0 degree K To = 371.85687090546116  degree K

f Goudar = 0.03350128202455611

==== iteration i= 4==============

Surface Temperature = 335.9284354527306 degree K

Cp = 4.183594226662113J/kgK

Q = 300966.67125708814W/m^2K

hi = 17893.658778422763W/m^2K

ho = 105.43972937523914W/m^2K

U = 1834.3621704806678W/K

Ti=300.0 degree K To = 371.93973768751823  degree K

m = 0.9639246565181816 kg/s

dP = 526.2893776679816 kPa

 

> Terminated with exit code 0.

 

Homework problems:

PROBLEM 1: A combustion of natural gas (%95 CH4+5% C2H6) with 100 % excess air is carried out in a combustion chamber. Air and fuel is at T=298 K at the inlet of the reaction and T=520 K at the exit. Exit exhoust gases flows across a pipe with a diameter of D=10 mm and length L=10m. Inside we have water with inlet temperature of T=300 K and velocity V=1.2 m/s. What is the total heat transfer and exit temperature of water?

 

PROBLEM 2: Water flows in a pipeline (commercial steel) of diameter D=0.2 m and L=100 m with constant temperature of T=300 K. Inlet pressure is P=20 bar. What is the exit pressure?

 

Computer termodynamic-thermophysical property programs used in this section

Thermodynamic properties of water-steam:

 steamIAPWS_IF97

/*======================================================

 Thermodynamic Package in java

 Class Steam Properties of water/steam

 Dr. Turhan Coban

 EGE University, School of Engineering,

 division of mechanical engineering

 web: www.turhancoban.com

 email: turhan_coban@yahoo.com

 File Name   : steamIAPWS_IF97.java

 This file contains the steamIAPWS_IF97 class

 this class sets thermophysical properties of steam

 =====================================================

 Description : This file contains the  steamIAPWS_IF97 class

 class steam calculates thermophysical properties of

 water and steam.

 DATA FILE DEFINATION

 required datas are written directly inside of the class as array structures

 reference : Referance: International Steam Tables, Wolfgang Wagner, Hans-Joachim Kretzschamar

 ISBN 978-3-540-21419-9, Springer 2008

 273.15 K <= T <= 1073.15 K 0 < p <= 100 MPa

 1073.15 K < T ? 2273.15 K 0 < p <= 50 MPa

 VERSION 1.0 : 30/9/2015

 VERSION 2.0 : 30/6/2019

============================================================

 

*/

//import javax.swing.*;

public class steamIAPWS_IF97

{

public String unit="SI";

public double Tc=647.096;//K crital temperature

public double R=0.461526;//kJ/(kgK) gas constant

public double Rm=8.31451;//kJ/(kmolK) gas constant

public double M=18.015257;//kg/kmol molar mass

public double Pc=22.064e3;//kPa critical pressure

public double roc=322;//kg/m^3 critical density

public double Tb=373.1243;//K boiling temperature

public double Pb=101.325;//kPa boiling pressure

public double Pt=611.657e-3;//kPa tripple point pressure

String Region="R1";

public steamData d[];

public steam st;

public steam_v_tp svtp;

 //saturation Ts data

double ats[]={273.16,

276.9371313,

280.7142626,

284.4913939,

288.2685253,

292.0456566,

295.8227879,

299.5999192,

303.3770505,

307.1541818,

310.9313131,

314.7084444,

318.4855758,

322.2627071,

326.0398384,

329.8169697,

333.594101,

337.3712323,

341.1483636,

344.9254949,

348.7026263,

352.4797576,

356.2568889,

360.0340202,

363.8111515,

367.5882828,

371.3654141,

375.1425455,

378.9196768,

382.6968081,

386.4739394,

390.2510707,

394.028202,

397.8053333,

401.5824646,

405.359596,

409.1367273,

412.9138586,

416.6909899,

420.4681212,

424.2452525,

428.0223838,

431.7995152,

435.5766465,

439.3537778,

443.1309091,

446.9080404,

450.6851717,

454.462303,

458.2394343,

462.0165657,

465.793697,

469.5708283,

473.3479596,

477.1250909,

480.9022222,

484.6793535,

488.4564848,

492.2336162,

496.0107475,

499.7878788,

503.5650101,

507.3421414,

511.1192727,

514.896404,

518.6735354,

522.4506667,

526.227798,

530.0049293,

533.7820606,

537.5591919,

541.3363232,

545.1134545,

548.8905859,

552.6677172,

556.4448485,

560.2219798,

563.9991111,

567.7762424,

571.5533737,

575.3305051,

579.1076364,

582.8847677,

586.661899,

590.4390303,

594.2161616,

597.9932929,

601.7704242,

605.5475556,

609.3246869,

613.1018182,

616.8789495,

620.6560808,

624.4332121,

628.2103434,

631.9874747,

635.7646061,

639.5417374,

643.3188687,

644,

645,

646,

647,

647,

646,

645,

644,

643.3188687,

639.5417374,

635.7646061,

631.9874747,

628.2103434,

624.4332121,

620.6560808,

616.8789495,

613.1018182,

609.3246869,

605.5475556,

601.7704242,

597.9932929,

594.2161616,

590.4390303,

586.661899,

582.8847677,

579.1076364,

575.3305051,

571.5533737,

567.7762424,

563.9991111,

560.2219798,

556.4448485,

552.6677172,

548.8905859,

545.1134545,

541.3363232,

537.5591919,

533.7820606,

530.0049293,

526.227798,

522.4506667,

518.6735354,

514.896404,

511.1192727,

507.3421414,

503.5650101,

499.7878788,

496.0107475,

492.2336162,

488.4564848,

484.6793535,

480.9022222,

477.1250909,

473.3479596,

469.5708283,

465.793697,

462.0165657,

458.2394343,

454.462303,

450.6851717,

446.9080404,

443.1309091,

439.3537778,

435.5766465,

431.7995152,

428.0223838,

424.2452525,

420.4681212,

416.6909899,

412.9138586,

409.1367273,

405.359596,

401.5824646,

397.8053333,

394.028202,

390.2510707,

386.4739394,

382.6968081,

378.9196768,

375.1425455,

371.3654141,

367.5882828,

363.8111515,

360.0340202,

356.2568889,

352.4797576,

348.7026263,

344.9254949,

341.1483636,

337.3712323,

333.594101,

329.8169697,

326.0398384,

322.2627071,

318.4855758,

314.7084444,

310.9313131,

307.1541818,

303.3770505,

299.5999192,

295.8227879,

292.0456566,

288.2685253,

284.4913939,

280.7142626,

276.9371313,

273.16,

269.3828687,

};

double ass[]={-8.03E-10,

0.057869366,

0.114820132,

0.17090979,

0.226185959,

0.280688921,

0.334453353,

0.387509565,

0.439884414,

0.491601992,

0.542684169,

0.593151011,

0.643021116,

0.692311881,

0.741039712,

0.789220196,

0.836868234,

0.883998147,

0.930623762,

0.976758475,

1.022415308,

1.067606945,

1.112345766,

1.156643873,

1.200513107,

1.243965065,

1.287011114,

1.3296624,

1.371929857,

1.413824215,

1.455356008,

1.49653558,

1.537373092,

1.577878528,

1.618061705,

1.657932276,

1.697499738,

1.736773444,

1.775762605,

1.814476304,

1.852923502,

1.891113045,

1.929053679,

1.966754058,

2.004222753,

2.041468264,

2.078499032,

2.115323453,

2.151949888,

2.188386675,

2.224642149,

2.260724652,

2.296642552,

2.332404257,

2.368018235,

2.403493035,

2.438837306,

2.474059819,

2.509169496,

2.544175433,

2.579086932,

2.613913536,

2.648665062,

2.683351645,

2.717983785,

2.752572394,

2.787128861,

2.821665117,

2.856193707,

2.890727884,

2.925281704,

2.959870148,

2.994509252,

3.029216267,

3.064009846,

3.098910261,

3.133939661,

3.169122382,

3.204485318,

3.24005837,

3.275874994,

3.311972875,

3.348394775,

3.385189609,

3.422413837,

3.460133332,

3.498425934,

3.537385101,

3.577125301,

3.617790272,

3.659566052,

3.702702023,

3.747545398,

3.794598203,

3.84461117,

3.89873568,

3.958772552,

4.027821507,

4.114640489,

4.136298,

4.172236,

4.221427,

4.322359,

4.506472,

4.646463,

4.714733,

4.765522,

4.794629871,

4.914793898,

5.002500273,

5.074572143,

5.137134557,

5.193157301,

5.244336662,

5.29175043,

5.336136392,

5.378027937,

5.417826981,

5.455846298,

5.492335632,

5.527498621,

5.561504231,

5.594494751,

5.626591543,

5.657899287,

5.688509188,

5.718501427,

5.747947089,

5.776909676,

5.805446334,

5.833608838,

5.861444406,

5.888996371,

5.916304742,

5.943406677,

5.970336883,

5.99712796,

6.023810689,

6.05041429,

6.07696664,

6.103494461,

6.130023489,

6.156578624,

6.183184054,

6.209863378,

6.236639708,

6.263535768,

6.290573979,

6.317776547,

6.345165532,

6.372762927,

6.400590726,

6.428670986,

6.457025898,

6.485677847,

6.514649476,

6.54396375,

6.573644016,

6.603714074,

6.634198236,

6.665121392,

6.696509081,

6.728387552,

6.760783836,

6.793725812,

6.827242271,

6.861362987,

6.896118779,

6.931541576,

6.967664479,

7.004521821,

7.042149228,

7.080583674,

7.119863539,

7.160028663,

7.201120402,

7.243181686,

7.286257076,

7.330392827,

7.375636952,

7.422039293,

7.469651605,

7.518527631,

7.568723206,

7.620296355,

7.673307404,

7.727819112,

7.783896796,

7.841608478,

7.901025042,

7.962220397,

8.025271651,

8.090259302,

8.157267428,

8.226383903,

8.297700609,

8.371313679,

8.447323745,

8.525836201,

8.606961505,

8.690815481,

8.777519672,

8.867201715,

8.959995749,

9.056042878,

9.155491666,

9.258498686,

};

public steamIAPWS_IF97()

{

svtp=new steam_v_tp();

st=new steam();

d=new steamData[40];

//Pb23, Tb23

double n0[]={0.34805185628969e3,- 0.11671859879975e1,0.10192970039326e-2,0.57254459862746e3,0.13918839778870e2};

int I0[]={0};

int J0[]={0};

double pstar0=1e3;  // 1 MPa

double Tstar0=1;    // 1 K

d[0]=new steamData(0,I0,J0,n0,pstar0,Tstar0);

// Region 1

int I1[]={0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3,4,4,4,5,8,8,21,23,29,30,31,32};

int J1[]={-2,-1,0,1,2,3,4,5,-9,-7,-1,0,1,3,-3,0,1,3,17,-4,0,6,-5,-2,10,-8,-11,-6,-29,-31,-38,-39,-40,-41};

double n1[]={1.463297121316700E-01,-8.454818716911400E-01,-3.756360367204000E+00,3.385516916838500E+00,-9.579196338787200E-01,1.577203851322800E-01,-1.661641719950100E-02,8.121462998356800E-04,2.831908012380400E-04,-6.070630156587400E-04,-1.899006821841900E-02,-3.252974877050500E-02,-2.184171717541400E-02,-5.283835796993000E-05,-4.718432107326700E-04,-3.000178079302600E-04,4.766139390698700E-05,-4.414184533084600E-06,-7.269499629759400E-16,-3.167964484505400E-05,-2.827079798531200E-06,-8.520512812010300E-10,-2.242528190800000E-06,-6.517122289560100E-07,-1.434172993792400E-13,-4.051699686011700E-07,-1.273430174164100E-09,-1.742487123063400E-10,-6.876213129553100E-19,1.447830782852100E-20,2.633578166279500E-23,-1.194762264007100E-23,1.822809458140400E-24,-9.353708729245800E-26};

double pstar1=16530.0;//16.53 MPa

double Tstar1=1386;//1 K

d[1]=new steamData(1,I1,J1,n1,pstar1,Tstar1);

// Region 2 and 3

int I2o[]={0};

int J2o[]={0,1,-5,-4,-3,-2,-1,2,3};

double n2o[]={-9.6927686500217E+00,1.0086655968018E+01,-5.6087911283020E-03,7.1452738081455E-02,-4.0710498223928E-01,1.4240819171444E+00,-4.3839511319450E+00,-2.8408632460772E-01,2.1268463753307E-02};

double pstar2o=1000.0;//1.0 MPa

double Tstar2o=540.0;//1 K

d[2]=new steamData(2,I2o,J2o,n2o,pstar2o,Tstar2o);

int I2r[]={1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,5,6,6,6,7,7,7,8,8,9,10,10,10,16,16,18,20,20,20,21,22,23,24,24,24};

int J2r[]={0,1,2,3,6,1,2,4,7,36,0,1,3,6,35,1,2,3,7,3,16,35,0,11,25,8,36,13,4,10,14,29,50,57,20,35,48,21,53,39,26,40,58};

double n2r[]={-1.7731742473213E-03,-1.7834862292358E-02,-4.5996013696365E-02,-5.7581259083432E-02,-5.0325278727930E-02,-3.3032641670203E-05,-1.8948987516315E-04,-3.9392777243355E-03,-4.3797295650573E-02,-2.6674547914087E-05,2.0481737692309E-08,4.3870667284435E-07,-3.2277677238570E-05,-1.5033924542148E-03,-4.0668253562649E-02,-7.8847309559367E-10,1.2790717852285E-08,4.8225372718507E-07,2.2922076337661E-06,-1.6714766451061E-11,-2.1171472321355E-03,-2.3895741934104E+01,-5.905956432427E-18,-1.262180889910E-06,-3.894684243574E-02,1.125621136046E-11,-8.231134089800E+00,1.980971280209E-08,1.040696521017E-19,-1.023474709593E-13,-1.001817937951E-09,-8.088290864699E-11,1.069303187941E-01,-3.366225057417E-01,8.918584535542E-25,3.062931687623E-13,-4.200246769821E-06,-5.905602968564E-26,3.782694761346E-06,-1.276860893468E-15,7.308761059506E-29,5.541471535078E-17,-9.436970724121E-07};

double pstar2r=1000.0;//1.0 MPa

double Tstar2r=540.0;//1 K

d[3]=new steamData(3,I2r,J2r,n2r,pstar2r,Tstar2r);

// Region 2 metastable region 4 and 5

int I20MS[]={0};

int J20MS[]={0,1,-5,-4,-3,-2,-1,2,3};

double n20MS[]={ - 9.6937268393049,0.10087275970006e2,-5.6087911283020E-03,7.1452738081455E-02,-4.0710498223928E-01,1.4240819171444E+00,-4.3839511319450E+00,-2.8408632460772E-01,2.1268463753307E-02};

double pstar20MS=1000.0;//1.0 MPa

double Tstar20MS=540.0;//1 K

d[4]=new steamData(4,I20MS,J20MS,n20MS,pstar20MS,Tstar20MS);

int I2rMS[]={1,1,1,1,2,2,2,3,3,4,4,5,5};

int J2rMS[]={0,2,5,11,1,7,16,4,16,7,10,9,10};

double n2rMS[]={-7.33622601865060E-03,-8.82238319431460E-02,-7.23345552132450E-02,-4.08131785344550E-03,2.00978033802070E-03,-5.30459218986420E-02,-7.61904090869700E-03,-6.34980376573130E-03,-8.60430930285880E-02,7.53215815227700E-03,-7.92383754461900E-03,-2.28881607784470E-04,-2.64565014828100E-03};

double pstar2rMS=1000.0;//1.0 MPa

double Tstar2rMS=540.0;//1 K

d[5]=new steamData(5,I2rMS,J2rMS,n2rMS,pstar2rMS,Tstar2rMS);

// REGION 3  6

int I3[]={0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,6,6,6,7,8,9,9,10,10,11};

int J3[]={0,0,1,2,7,10,12,23,2,6,15,17,0,2,6,7,22,26,0,2,4,16,26,0,2,4,26,1,3,26,0,2,26,2,26,2,26,0,1,26};

double n3[]={1.0658070028513E+00,-1.5732845290239E+01,2.0944396974307E+01,-7.6867707878716E+00,2.6185947787954E+00,-2.8080781148620E+00,1.2053369696517E+00,-8.4566812812502E-03,-1.2654315477714E+00,-1.1524407806681E+00,8.8521043984318E-01,-6.4207765181607E-01,3.8493460186671E-01,-8.5214708824206E-01,4.8972281541877E+00,-3.0502617256965E+00,3.9420536879154E-02,1.2558408424308E-01,-2.7999329698710E-01,1.3899799569460E+00,-2.0189915023570E+00,-8.2147637173963E-03,-4.7596035734923E-01,4.3984074473500E-02,-4.4476435428739E-01,9.0572070719733E-01,7.0522450087967E-01,1.0770512626332E-01,-3.2913623258954E-01,-5.0871062041158E-01,-2.2175400873096E-02,9.4260751665092E-02,1.6436278447961E-01,-1.3503372241348E-02,-1.4834345352472E-02,5.7922953628084E-04,3.2308904703711E-03,8.0964802996215E-05,-1.6557679795037E-04,-4.4923899061815E-05};

double pstar3=1000.0;//1.0 MPa

double Tstar3=647.096;

double rostar3=322.0;

d[6]=new steamData(6,I3,J3,n3,pstar3,Tstar3,rostar3);

// REGION 4    7

int I4[]={0};

int J4[]={0};

double n4[]={1.1670521452767E+03,-7.2421316703206E+05,-1.7073846940092E+01,1.2020824702470E+04,-3.2325550322333E+06,1.4915108613530E+01,-4.8232657361591E+03,4.0511340542057E+05,-2.3855557567849E-01,6.5017534844798E+02};

double pstar4=1000.0;//1.0 MPa

double Tstar4=1.0;//1 K

d[7]=new steamData(7,I4,J4,n4,pstar4,Tstar4);

// REGION 5   8 and 9

int I5_0[]={0};

int J5_0[]={0,1,-3,-2,-1,2};

double n5_0[]={-1.3179983674201E+01,6.8540841634434E+00,-2.4805148933466E-02,3.6901534980333E-01,-3.1161318213925E+00,-3.2961626538917E-01};

double pstar5_0=1000.0;//1.0 MPa

double Tstar5_0=1000.0;//1 K

d[8]=new steamData(8,I5_0,J5_0,n5_0,pstar5_0,Tstar5_0);

int I5_r[]={1,1,1,2,2,3};

int J5_r[]={1,2,3,3,9,7};

double n5_r[]={1.5736404855259E-03,9.0153761673944E-04,-5.0270077677648E-03,2.2440037409485E-06,-4.1163275453471E-06,3.7919454822955E-08};

double pstar5_r=1000.0;//1.0 MPa

double Tstar5_r=1000.0;//1 K

d[9]=new steamData(8,I5_r,J5_r,n5_r,pstar5_r,Tstar5_r);

// Viscosity

int I10[]={1,2,3,4};

int J10[]={0};

double n10[]={0.167752e-1,0.220462e-1,0.6366564e-2,-0.241605e-2 };

double pstar10=1000;//1.0 MPa

double Tstar10=647.096;

double rostar10=322.0;

d[10]=new steamData(10,I10,J10,n10,pstar10,Tstar10,rostar10);

int I11[]={0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,4,4,5,6,6};

int J11[]={0,1,2,3,0,1,2,3,5,0,1,2,3,4,0,1,0,3,4,3,5};

double n11[]={5.20094E-01,8.50895E-02,-1.08374E+00,-2.89555E-01,2.22531E-01,9.99115E-01,1.88797E+00,1.26613E+00,1.20573E-01,-2.81378E-01,-9.06851E-01,-7.72479E-01,-4.898370E-01,-2.57040E-01,1.61913E-01,2.57399E-01,-3.25372E-02,6.98452E-02,8.72102E-03,-4.35673E-03,-5.93264E-04};

double pstar11=1000;//1.0 MPa

double Tstar11=647.096;

double rostar11=322.0;

d[11]=new steamData(10,I11,J11,n11,pstar11,Tstar11,rostar11);

// Thermal conductivity

int I12[]={1,2,3,4};

int J12[]={0};

//Table 3.4

double n12[]={0.102811e-1,0.299621e-1,0.156146e-1,-0.422464e-2 };

double pstar12=1000;//1.0 MPa

double Tstar12=647.26;

double rostar12=317.7;

d[12]=new steamData(12,I12,J12,n12,pstar12,Tstar12,rostar12);

int I13[]={0};

int J13[]={0};

//Table 3.5

double n13[]={-0.397070,0.400302,0.1060e1,-0.171587,0.239219e1};

double pstar13=1000;//1.0 MPa

double Tstar13=647.26;

double rostar13=317.7;

d[13]=new steamData(13,I13,J13,n13,pstar13,Tstar13,rostar13);

int I14[]={0};

int J14[]={0};

double n14[]={0.701309e-1,0.118520e-1,0.642857,0.169937e-2,-0.102000e1,-0.411717e1,-0.617937e1,0.822994e-1,0.100932e2,0.308976e-2};

double pstar14=1000;//1.0 MPa

double Tstar14=647.26;

double rostar14=317.7;

d[14]=new steamData(14,I14,J14,n14,pstar14,Tstar14,rostar14);

 

// Saturated pressure as a function of enthalpy

int I15[]={0,1,1,1,1,5,7,8,14,20,22,24,28,36};

int J15[]={0,1,3,4,36,3,0,24,16,16,3,18,8,24};

double n15[]={6.0007364175302E-01,-9.3620365484986E+00,2.4659079859415E+01,-1.0701422285822E+02,-9.1582131580577E+13,-8.6233201170066E+03,-2.3583734474003E+01,2.5230496938413E+17,-3.8971877199772E+18,-3.3377571364530E+22,3.5649946963633E+10,-1.4854754472064E+26,3.3061151483880E+18,8.1364129446783E+37};

double pstar15=22000;//1.0 MPa

double Tstar15=1.0;

double hstar15=2600.0;

d[15]=new steamData(15,I15,J15,n15,pstar15,Tstar15,hstar15);

 

//Saturated pressure as a function of entropy

int I16[]={0,1,1,4,12,12,16,24,28,32};

int J16[]={0,1,32,7,4,14,36,10,0,18};

double n16[]={6.39767553612785E-01,-1.29727445396014E+01,-2.24595125848403E+15,1.77466741801846E+06,7.17079349571538E+09,-3.78829107169011E+17,-9.55586736431328E+34,1.87269814676188E+23,1.19254746466473E+11,1.10649277244882E+36};

double pstar16=22000;//1.0 MPa

double Tstar16=1.0;

double sstar16=5.2;

d[16]=new steamData(16,I16,J16,n16,pstar16,Tstar16,sstar16);

 

//REGION 1 T1_ph temperature as a function of pressure and enthapy

 

int I17[]={0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,3,3,4,5,6};

int J17[]={0,1,2,6,22,32,0,1,2,3,4,10,32,10,32,10,32,32,32,32};

double n17[]={-2.3872489924521E+02,4.0421188637945E+02,1.1349746881718E+02,-5.8457616048039E0,-1.5285482413140E-04,-1.0866707695377E-06,-1.3391744872602E+01,4.3211039183559E+01,-5.4010067170506E+01,3.0535892203916E+01,-6.5964749423638E+00,9.3965400878363E-03,1.1573647505340E-07,-2.5858641282073E-05,-4.0644363084799E-09,6.6456186191635E-08,8.0670734103027E-11,-9.3477771213947E-13,5.8265442020601E-15,-1.5020185953503E-17};

double pstar17=1000;//1.0 MPa

double Tstar17=1.0;

double hstar17=2500;

d[17]=new steamData(17,I17,J17,n17,pstar17,Tstar17,hstar17);

//REGION 2 T2_Ph

 

//T2a_ph Region 2a specific volume as a function of enthalpy and pressure

 

int I18[]={0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,4,4,4,5,5,5,6,6,7};

int J18[]={0,1,2,3,7,20,0,1,2,3,7,9,11,18,44,0,2,7,36,38,40,42,44,24,44,12,32,44,32,36,42,34,44,28};

double n18[]={1.0898952318288E+03,8.4951654495535E+02,-1.0781748091826E+02,3.3153654801263E+01,-7.4232016790248E+00,1.1765048724356E+01,1.8445749355790E+00,-4.1792700549624E+00,6.2478196935812E+00,-1.7344563108114E+01,-2.0058176862096E+02,2.7196065473796E+02,-4.5511318285818E+02,3.0919688604755E+03,2.5226640357872E+05,-6.1707422868339E-03,-3.1078046629583E-01,1.1670873077107E+01,1.2812798404046E+08,-9.8554909623276E+08,2.8224546973002E+09,-3.5948971410703E+09,1.7227349913197E+09,-1.3551334240775E+04,1.2848734664650E+07,1.3865724283226E+00,2.3598832556514E+05,-1.3105236545054E+07,7.3999835474766E+03,-5.5196697030060E+05,3.7154085996233E+06,1.9127729239660E+04,-4.1535164835634E+05,-6.2459855192507E+01};

double pstar18=1000;//1.0 MPa

double Tstar18=1.0;

double hstar18=2000;

d[18]=new steamData(18,I18,J18,n18,pstar18,Tstar18,hstar18);

//T2b_Ph Region 2b specific volume as a function of enthalpy and pressure

int I19[]={0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,4,4,5,5,5,6,7,7,9,9};

int J19[]={0,1,2,12,18,24,28,40,0,2,6,12,18,24,28,40,2,8,18,40,1,2,12,24,2,12,18,24,28,40,18,24,40,28,2,28,1,40};

double n19[]={1.4895041079516E+03,7.4307798314034E+02,-9.7708318797837E+01,2.4742464705674E+00,-6.3281320016026E-01,1.1385952129658E+00,-4.7811863648625E-01,8.5208123431544E-03,9.3747147377932E-01,3.3593118604916E+00,3.3809355601454E+00,1.6844539671904E-01,7.3875745236695E-01,-4.7128737436186E-01,1.5020273139707E-01,-2.1764114219750E-03,-2.1810755324761E-02,-1.0829784403677E-01,-4.6333324635812E-02,7.1280351959551E-05,1.1032831789999E-04,1.8955248387902E-04,3.0891541160537E-03,1.3555504554949E-03,2.8640237477456E-07,-1.0779857357512E-05,-7.6462712454814E-05,1.4052392818316E-05,-3.1083814331434E-05,-1.0302738212103E-06,2.8217281635040E-07,1.2704902271945E-06,7.3803353468292E-08,-1.1030139238909E-08,-8.1456365207833E-14,-2.5180545682962E-11,-1.7565233969407E-18,8.6934156344163E-15};

double pstar19=1000;//1.0 MPa

double Tstar19=1.0;

double hstar19=2000;

d[19]=new steamData(19,I19,J19,n19,pstar19,Tstar19,hstar19);

//T2c_Ph Region 2c specific volume as a function of enthalpy and pressure

int I20[]={-7,-7,-6,-6,-5,-5,-2,-2,-1,-1,0,0,1,1,2,6,6,6,6,6,6,6,6};

int J20[]={0,4,0,2,0,2,0,1,0,2,0,1,4,8,4,0,1,4,10,12,16,20,22};

double n20[]={-3.2368398555242E+12,7.3263350902181E+12,3.5825089945447E+11,-5.8340131851590E+11,-1.0783068217470E+10,2.0825544563171E+10,6.1074783564516E+05,8.5977722535580E+05,-2.5745723604170E+04,3.1081088422714E+04,1.2082315865936E+03,4.8219755109255E+02,3.7966001272486E+00,-1.0842984880077E+01,-4.5364172676660E-02,1.4559115658698E-13,1.1261597407230E-12,-1.7804982240686E-11,1.2324579690832E-07,-1.1606921130984E-06,2.7846367088554E-05,-5.9270038474176E-04,1.2918582991878E-03};

double pstar20=1000;//1.0 MPa

double Tstar20=1.0;

double hstar20=2000;

d[20]=new steamData(20,I20,J20,n20,pstar20,Tstar20,hstar20);

//v3a_Ph Region 3a specific volume as a function of enthalpy and pressure

int I21[]={-12,-12,-12,-12,-10,-10,-10,-8,-8,-6,-6,-6,-4,-4,-3,-2,-2,-1,-1,-1,-1,0,0,1,1,1,2,2,3,4,5,8};

int J21[]={6,8,12,18,4,7,10,5,12,3,4,22,2,3,7,3,16,0,1,2,3,0,1,0,1,2,0,2,0,2,2,2};

double n21[]={5.2994406296603E-03,-1.7009969023446E-01,1.1132381431293E+01,-2.1789812314513E+03,-5.0606182798088E-04,5.5649523968532E-01,-9.4367272609402E+00,-2.9785680756153E-01,9.3935394371719E+01,1.9294493946598E-02,4.2174066470476E-01,-3.6891412628233E+06,-7.3756684760064E-03,-3.5475324242437E-01,-1.9976816933873E+00,1.1545629705905E+00,5.6836687581596E+03,8.0816954012467E-03,1.7241634151931E-01,1.0427017529293E+00,-2.9769137279285E-01,5.6039446516359E-01,2.7523466117691E-01,-1.4834789486601E-01,-6.5114251347852E-02,-2.9246871538630E+00,6.6487609695267E-02,3.5233501426384E+00,-1.4634079231333E-02,-2.2450348666818E+00,1.1053346470614E+00,-4.0875734449561E-02};

double pstar21=100e3;//1.0 MPa

double hstar21=2100;

double vstar21=0.0028;

d[21]=new steamData(21,I21,J21,n21,pstar21,hstar21,vstar21);

//v3b_Ph Region 3b specific volume as a function of enthalpy and pressure

int I22[]={-12,-12,-8,-8,-8,-8,-8,-8,-6,-6,-6,-6,-6,-6,-4,-4,-4,-3,-3,-2,-2,-1,-1,-1,-1,0,1,1,2,2};

int J22[]={0,1,0,1,3,6,7,8,0,1,2,5,6,10,3,6,10,0,2,1,2,0,1,4,5,0,0,1,2,6};

double n22[]={-2.2519693433632E-09,1.4067436331349E-08,2.3378408528056E-06,-3.3183371522900E-05,1.0795677851432E-03,-2.7138206737886E-01,1.0720226249033E+00,-8.5382132907538E-01,-2.1521419434053E-05,7.6965608822273E-04,-4.3113658043386E-03,4.5334216730933E-01,-5.0774953587365E-01,-1.0047515452839E+02,-2.1920192464879E-01,-3.2108796566892E+00,6.0756781563777E+02,5.5768645068593E-04,1.8749904002955E-01,9.0536803044811E-03,2.8541717304869E-01,3.2992403099610E-02,2.3989741968548E-01,4.8275499595139E+00,-1.1803575370223E+01,1.6949004409179E-01,-1.7996722250779E-02,3.7181011633267E-02,-5.3628833506510E-02,1.6069710109252E+00};

double pstar22=100e3;//1.0 MPa

double hstar22=2800;

double vstar22=0.0088;

d[22]=new steamData(22,I22,J22,n22,pstar22,hstar22,vstar22);

//T3a_Ph Region 3a temperature as a function of enthalpy and pressure

int I23[]={-12,-12,-12,-12,-12,-12,-12,-12,-10,-10,-10,-8,-8,-8,-8,-5,-3,-2,-2,-2,-1,-1,0,0,1,3,3,4,4,10,12};

int J23[]={0,1,2,6,14,16,20,22,1,5,12,0,2,4,10,2,0,1,3,4,0,2,0,1,1,0,1,0,3,4,5};

double n23[]={-1.3364566781122E-07,4.5591265680298E-06,-1.4629464070098E-05,6.3934131297008E-03,3.7278392726885E+02,-7.1865437746045E+03,5.7349475210340E+05,-2.6756932911144E+06,-3.3406628330261E-05,-2.4547921406960E-02,4.7808784776500E+01,7.6466413181890E-06,1.2835062767697E-03,1.7121908137733E-02,-8.5100730458321E+00,-1.3651346162978E-02,-3.8446099759666E-06,3.3742380791166E-03,-5.5162487306679E-01,7.2920227710747E-01,-9.9252275737604E-03,-1.1930883140729E-01,7.9392919061542E-01,4.5427073179939E-01,2.0999859125991E-01,-6.4210982390474E-03,-2.3515586860454E-02,2.5223310834161E-03,-7.6488513336812E-03,1.3617642757429E-02,-1.3302788357567E-02};

double pstar23=100e3;//1.0 MPa

double Tstar23=760;

double hstar23=2300;

d[23]=new steamData(23,I23,J23,n23,pstar23,Tstar23,hstar23);

//T3b_Ph Region 3b temperature as a function of enthalpy and pressure

int I24[]={-12,-12,-10,-10,-10,-10,-10,-8,-8,-8,-8,-8,-6,-6,-6,-4,-4,-3,-2,-2,-1,-1,-1,-1,-1,-1,0,0,1,3,5,6,8};

int J24[]={0,1,0,1,5,10,12,0,1,2,4,10,0,1,2,0,1,5,0,4,2,4,6,10,14,16,0,2,1,1,1,1,1};

double n24[]={3.2325457364492E-05,-1.2757555658718E-04,-4.7585187735607E-04,1.5618301418160E-03,1.0572486011378E-01,-8.5851422113253E+01,7.2414009548091E+02,2.9647581027326E-03,-5.9272198336599E-03,-1.2630542281867E-02,-1.1571619636485E-01,8.4900096973960E+01,-1.0860226008662E-02,1.5430447532885E-02,7.5045544152447E-02,2.5252097361298E-02,-6.0250790123300E-02,-3.0762222135050E+00,-5.7401195986488E-02,5.0347136093985E+00,-9.2508188858483E-01,3.9173388291755E+00,-7.7314600713019E+01,9.4930876209859E+03,-1.4104371967941E+06,8.4916623081903E+06,8.6109572944670E-01,3.2334644281172E-01,8.7328193602044E-01,-4.3665304852668E-01,2.8659671452948E-01,-1.3177833127623E-01,6.7668206433028E-03};

double pstar24=100e3;//1.0 MPa

double Tstar24=860;

double hstar24=2800;

d[24]=new steamData(24,I24,J24,n24,pstar24,Tstar24,hstar24);

//T1_Ps Temperature as a function of pressure and entropy

int I25[]={0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,4};

int J25[]={0,1,2,3,11,31,0,1,2,3,12,31,0,1,2,9,31,10,32,32};

double n25[]={1.7478268058307E+02,3.4806930892873E+01,6.5292584978455E+00,3.3039981775489E-01,-1.9281382923196E-07,-2.4909197244573E-23,-2.6107636489332E-01,2.2592965981586E-01,-6.4256463395226E-02,7.8876289270526E-03,3.5672110607366E-10,1.7332496994895E-24,5.6608900654837E-04,-3.2635483139717E-04,4.4778286690632E-05,-5.1322156908507E-10,-4.2522657042207E-26,2.6400441360689E-13,7.8124600459723E-29,-3.0732199903668E-31};

double pstar25=1e3;//1.0 MPa

double Tstar25=1;

double sstar25=1;

d[25]=new steamData(25,I25,J25,n25,pstar25,Tstar25,sstar25);

//T2b_Ps

 

int I26[]={-6,-6,-5,-5,-4,-4,-4,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,3,3,3,4,4,5,5,5};

int J26[]={0,11,0,11,0,1,11,0,1,11,12,0,1,6,10,0,1,5,8,9,0,1,2,4,5,6,9,0,1,2,3,7,8,0,1,5,0,1,3,0,1,0,1,2};

double n26[]={3.1687665083497E+05,2.0864175881858E+01,-3.9859399803599E+05,-2.1816058518877E+01,2.2369785194242E+05,-2.7841703445817E+03,9.9207436071480E+00,-7.5197512299157E+04,2.9708605951158E+03,-3.4406878548526E+00,3.8815564249115E-01,1.7511295085750E+04,-1.4237112854449E+03,1.0943803364167E+00,8.9971619308495E-01,-3.3759740098958E+03,4.7162885818355E+02,-1.9188241993679E+00,4.1078580492196E-01,-3.3465378172097E-01,1.3870034777505E+03,-4.0663326195838E+02,4.1727347159610E+01,2.1932549434532E+00,-1.0320050009077E+00,3.5882943516703E-01,5.2511453726066E-03,1.2838916450705E+01,-2.8642437219381E+00,5.6912683664855E-01,-9.9962954584931E-02,-3.2632037778459E-03,2.3320922576723E-04,-1.5334809857450E-01,2.9072288239902E-02,3.7534702741167E-04,1.7296691702411E-03,-3.8556050844504E-04,-3.5017712292608E-05,-1.4566393631492E-05,5.6420857267269E-06,4.1286150074605E-08,-2.0684671118824E-08,1.6409393674725E-09};

double pstar26=1e3;//1.0 MPa

double Tstar26=1;

double sstar26=0.7853;

d[26]=new steamData(26,I26,J26,n26,pstar26,Tstar26,sstar26);

//T2c_Ps

int I27[]={-2,-2,-1,0,0,0,0,1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,7,7,7,7,7};

int J27[]={0,1,0,0,1,2,3,0,1,3,4,0,1,2,0,1,5,0,1,4,0,1,2,0,1,0,1,3,4,5};

double n27[]={9.0968501005365E+02,2.4045667088420E+03,-5.9162326387130E+02,5.4145404128074E+02,-2.7098308411192E+02,9.7976525097926E+02,-4.6966772959435E+02,1.4399274604723E+01,-1.9104204230429E+01,5.3299167111971E+00,-2.1252975375934E+01,-3.1147334413760E-01,6.0334840894623E-01,-4.2764839702509E-02,5.8185597255259E-03,-1.4597008284753E-02,5.6631175631027E-03,-7.6155864584577E-05,2.2440342919332E-04,-1.2561095013413E-05,6.3323132660934E-07,-2.0541989675375E-06,3.6405370390082E-08,-2.9759897789215E-09,1.0136618529763E-08,5.9925719692351E-12,-2.0677870105164E-11,-2.0874278181886E-11,1.0162166825089E-10,-1.6429828281347E-10};

double pstar27=1e3;//1.0 MPa

double Tstar27=1;

double sstar27=2.9251;

d[27]=new steamData(27,I27,J27,n27,pstar27,Tstar27,sstar27);

//v3a_Ps

int I28[]={-12,-12,-12,-10,-10,-10,-10,-8,-8,-8,-8,-6,-5,-4,-3,-3,-2,-2,-1,-1,0,0,0,1,2,4,5,6};

int J28[]={10,12,14,4,8,10,20,5,6,14,16,28,1,5,2,4,3,8,1,2,0,1,3,0,0,2,2,0};

double n28[]={7.9554407409398E+01,-2.3826124298459E+03,1.7681310061779E+04,-1.1052472708038E-03,-1.5321383365533E+01,2.9754459937698E+02,-3.5031520687124E+07,2.7751376106212E-01,-5.2396427103689E-01,-1.4801118299540E+05,1.6001489937427E+06,1.7080232266343E+12,2.4686699600649E-04,1.6532608479798E+00,-1.1800838466699E-01,2.5379864235590E+00,9.6512770466942E-01,-2.8217242053283E+01,2.0322461235382E-01,1.1064818606351E+00,5.2612794845128E-01,2.7700001873632E-01,1.0815334050113E+00,-7.4412788535789E-02,1.6409444354138E-02,-6.8046827530107E-02,2.5798857610164E-02,-1.4574986194442E-04};

double pstar28=100.0e3;//1.0 MPa

double sstar28=4.4;

double vstar28=0.0028;

d[28]=new steamData(28,I28,J28,n28,pstar28,sstar28,vstar28);

//v3b_Ps

int I29[]={-12,-12,-12,-12,-12,-12,-10,-10,-10,-10,-8,-5,-5,-5,-4,-4,-4,-4,-3,-2,-2,-2,-2,-2,-2,0,0,0,1,1,2};

int J29[]={0,1,2,3,5,6,0,1,2,4,0,1,2,3,0,1,2,3,1,0,1,2,3,4,12,0,1,2,0,2,2};

double n29[]={5.9159978032224E-05,-1.8546599713786E-03,1.0419051048001E-02,5.9864730203859E-03,-7.7139118990170E-01,1.7254976555704E+00,-4.6707607984653E-04,1.3453382338444E-02,-8.0809433680550E-02,5.0813937436577E-01,1.2858464336168E-03,-1.6389935391544E+00,5.8693819931806E+00,-2.9246666791861E+00,-6.1407630149954E-03,5.7619901404917E+00,-1.2161332060679E+01,1.6763754095794E+00,-7.4413583877346E+00,3.7816809143766E-02,4.0143220302769E+00,1.6027983747919E+01,3.1784877934773E+00,-3.5836231030485E+00,-1.1599526044683E+06,1.9925657357791E-01,-1.2227062479462E-01,-1.9144914371659E+01,-1.5044800290528E-02,1.4640790016215E+01,-3.2747778718823E+00};

double pstar29=100.0e3;//1.0 MPa

double sstar29=5.3;

double vstar29=0.0088;

d[29]=new steamData(29,I29,J29,n29,pstar29,sstar29,vstar29);

//T3a_Ps

int I30[]={-12,-12,-10,-10,-10,-10,-8,-8,-8,-8,-6,-6,-6,-5,-5,-5,-4,-4,-4,-2,-2,-1,-1,0,0,0,1,2,2,3,8,8,10};

int J30[]={28,32,4,10,12,14,5,7,8,28,2,6,32,0,14,32,6,10,36,1,4,1,6,0,1,4,0,0,3,2,0,1,2};

double n30[]={1.5004200826388E+09,-1.5939725848042E+11,5.0218114021798E-04,-6.7205776785547E+01,1.4505854540446E+03,-8.2388953488889E+03,-1.5485221423385E-01,1.1230504674670E+01,-2.9700021348282E+01,4.3856513263550E+10,1.3783783863546E-03,-2.9747852715746E+00,9.7177794734941E+12,-5.7152776705240E-05,2.8830794977842E+04,-7.4442828926270E+13,1.2801732484892E+01,-3.6827554588907E+02,6.6476890477918E+15,4.4935925195888E-02,-4.2289783609966E+00,-2.4061437643418E-01,-4.7434136525492E+00,7.2409399912611E-01,9.2387434969590E-01,3.9904365528102E+00,3.8406665186801E-02,-3.5934436557185E-03,-7.3519644882165E-01,1.8836704839613E-01,1.4106426681870E-04,-2.5741850149634E-03,1.2322002485156E-03};

double pstar30=100e3;//1.0 MPa

double Tstar30=760;

double sstar30=4.4;

d[30]=new steamData(30,I30,J30,n30,pstar30,Tstar30,sstar30);

//T3b_Ps

int I31[]={-12,-12,-12,-12,-8,-8,-8,-6,-6,-6,-5,-5,-5,-5,-5,-4,-3,-3,-2,0,2,3,4,5,6,8,12,14};

int J31[]={1,3,4,7,0,1,3,0,2,4,0,1,2,4,6,12,1,6,2,0,1,1,0,24,0,3,1,2};

double n31[]={5.2711170160166E-01,-4.0131783005274E+01,1.5302007313448E+02,-2.2479939821883E+03,-1.9399348466905E-01,-1.4046755789377E+00,4.2679987811402E+01,7.5281064341674E-01,2.2665723861642E+01,-6.2287355690993E+02,-6.6082366793540E-01,8.4126708727166E-01,-2.5371750176440E+01,4.8570896353295E+02,8.8053151749056E+02,2.6501559279463E+06,-3.5928715002578E-01,-6.5699156767375E+02,2.4176814918537E+00,8.5687346122259E-01,6.5514367531346E-01,-2.1353521320641E-01,5.6297495760635E-03,-3.1695572545047E+14,-6.9999700015246E-04,1.1984580321077E-02,1.9384812202210E-05,-2.1509574918231E-05};

double pstar31=100e3;//1.0 MPa

double Tstar31=860;

double sstar31=5.3;

d[31]=new steamData(31,I31,J31,n31,pstar31,Tstar31,sstar31);

}

public String print2(steamData sd)

{

String s="";

 for(int i=0;i<sd.I.length;i++)

 {s+=sd.I[i]+"\n";}

 for(int i=0;i<sd.J.length;i++)

 {s+=sd.J[i]+"\n";}

 for(int i=0;i<sd.n.length;i++)

 {s+=sd.n[i]+"\n";}

 return s; 

}

//PROPERTY General

// tv tp th tu ts tx pv pt ph pu ps px vp vt hs

public double[] propertyC(String s,double v1,double v2)

{ if(s.equals("pt")) return property_PT(v1,(v2+273.15));

  else if(s.equals("tp"))  return property_PT(v2,(v1+273.15));

  else if(s.equals("vt")) {double ro=1.0/v1;return property_roT(ro,(v2+273.15));}

  else if(s.equals("tv")) {double ro=1.0/v2;return property_roT(ro,(v1+273.15));}

  else if(s.equals("rot")) {return property_roT(v1,(v2+273.15));}

  else if(s.equals("tro")) {return property_roT(v2,(v1+273.15));}  

  else if(s.equals("tx"))  return property_Tx((v1+273.15),v2);

  else if(s.equals("px"))  return property_Px(v1,v2);

  else if(s.equals("pv"))  return property_Pro(v1,1.0/v2);

  else if(s.equals("pro"))  return property_Pro(v1,v2);

  else if(s.equals("vp"))  return property_Pro(v2,1.0/v1);

  else if(s.equals("rop"))  return property_Pro(v2,v1);

  else if(s.equals("ph"))  return property_Ph(v1,v2);

  else if(s.equals("hp"))  return property_Ph(v2,v1);

  else if(s.equals("ps"))  return property_Ps(v1,v2);

  else if(s.equals("sp"))  return property_Ps(v2,v1);

  else return property_PT(v1,v2);

}

public double[] property(String s,double v1,double v2)

{ if(s.equals("pt")) return property_PT(v1,v2);

  else if(s.equals("tp"))  return property_PT(v2,v1);

  else if(s.equals("vt")) {double ro=1.0/v1;return property_roT(ro,v2);}

  else if(s.equals("tv")) {double ro=1.0/v2;return property_roT(ro,v1);}

  else if(s.equals("rot")) {return property_roT(v1,v2);}

  else if(s.equals("tro")) {return property_roT(v2,v1);}  

  else if(s.equals("tx"))  return property_Tx(v1,v2);

  else if(s.equals("px"))  return property_Px(v1,v2);

  else if(s.equals("pv"))  return property_Pro(v1,1.0/v2);

  else if(s.equals("pro"))  return property_Pro(v1,v2);

  else if(s.equals("vp"))  return property_Pro(v2,1.0/v1);

  else if(s.equals("rop"))  return property_Pro(v2,v1);

  else if(s.equals("ph"))  return property_Ph(v1,v2);

  else if(s.equals("hp"))  return property_Ph(v2,v1);

  else if(s.equals("ps"))  return property_Ps(v1,v2);

  else if(s.equals("sp"))  return property_Ps(v2,v1);

  else return property_PT(v1,v2);

}

 

//PROPERTY Function(P,ro)

public double[] property_Pro(double P,double ro)

{   double a[]=new double[17];

                double v=1.0/ro;

    double T=273.15;

    double Ps=0,vf=0,vg=0;

    boolean R1a=false; boolean R1b=false; boolean R1=false;

    boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2=false;

    boolean R5=false;

                R1a= v<vf_P(P) && P<=16.529e3;

    R1b= v<=v1(P,623.15) && v>=v1(P,273.15) && P<100e3 && P>16.529e3;

    R1=R1a || R1b;

    if(!R1)

                { vf=vf_P(P);vg=vg_P(P);  R4= v>=vf_P(P) && v<=vg_P(P) && P<=22.064e3;}

                if(!R1 && !R4)

                {R2a=(v>vf_P(P)) && P<=16.529e3 && v<vb25(P);

                 R2b= v<vb23_P(P) && v<vb25(P) && P>16.529e3 && P<=100.0e3;

                 R2=R2a || R2b;

    }  

                if(!R1 && !R2 && !R4)

                {R3=v>vb13(P) && v<vb23_P(P) && P<=100e3 && P>16.529e3;}

    if(!R1 && !R4 && !R3 && !R2){R5= v>vb25(P) && v<v5(P,2273.15) && P<50e5 ;}

    if(R1)

    {  //liquid region

                    Region="R1";T=T1(P,ro);a[0]=P;a[1]=T;a[2]=1.0/ro;a[3]=h1(P,T);a[4]=u1(P,T);a[5]=s1(P,T);

        a[6]=-1.0;a[7]=Cp1(P,T);a[8]=Cv1(P,T);a[9]=alpha1(P,T);a[10]=kappa1(P,T);a[11]=viscosity_PT(P,T);

        a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=ro;a[16]=sound1(P,T);

    }

    else if(R2)

    {  //vapor region

                    Region="R2";T=T2(P,ro);

        a[0]=P;a[1]=T;a[2]=1.0/ro;a[3]=h2(P,T);a[4]=u2(P,T);a[5]=s2(P,T);

        a[6]=2.0;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

        a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=ro;

        a[16]=sound2(P,T);

    }

    else if(R4)

    { Region="R4";

      T=Ps(T);

                  vf=vf_T(T);

      vg=vg_T(T);

      double hf=hf_T(T);

      double hg=hg_T(T);      

      double x=(v-vf)/(vg-vf);

      double h=hf+(hg-hf)*x;

      double sf=sf_T(T);

      double sg=sg_T(T);     

      double s=sf+(sg-sf)*x;

      double Cpf=Cpf_T(T);

      double Cpg=Cpg_T(T);

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double soundf=soundf_T(T);

      double soundg=soundg_T(T);

      double Cp=Cpf+(Cpg-Cpf)*x;

      double Cv=Cvf+(Cvg-Cvf)*x;

      double sound1=soundf+(soundg-soundf)*x;

                  P=Ps(T);

                  double u=h-P*v;    

      a[0]=P;a[1]=T;a[2]=v;a[3]=h;a[4]=u;a[5]=s;a[6]=x;a[7]=Cp;a[8]=Cv;

      a[9]=alpha1(P,T)*(1-x)+alpha2(P,T)*x;

      a[10]=kappa1(P,T)*(1-x)+kappa2(P,T)*x;

      a[11]=viscosity_Tx(T,x);a[12]=k_Tx(T,x);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

      a[16]=sound1;

      }

else if(R3)

{   Region="R3";

    T=T3(P,ro);

                a[0]=P;a[1]=T;a[2]=1.0/ro;

    a[3]=h3(ro,T);a[4]=u3(ro,T);a[5]=s3(ro,T);

    a[6]=3.0;a[7]=Cp3(ro,T);a[8]=Cv3(ro,T);a[9]=alpha2(ro,T);a[10]=kappa2(ro,T);

    a[11]=viscosity_roT(ro,T);a[12]=k_roT(ro,T);a[13]=sigma(T);a[14]=Pr_roT(ro,T);a[15]=1.0/a[2];

    a[16]=sound3(ro,T);

}

else if(R5)

{    Region="R5";

     T=T5(P,ro);

                 a[0]=P;a[1]=T;a[2]=1.0/ro;a[3]=h5(P,T);a[4]=u5(P,T);a[5]=s5(P,T);

     a[6]=5.0;a[7]=Cp5(P,T);a[8]=Cv5(P,T);a[9]=alpha5(P,T);a[10]=kappa5(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound5(P,T);

}

return a;  

}

 

//PROPERTY Function(P,h)

public double[] property_Ph(double P,double h)

{     double a[]=new double[17]; 

                  boolean R1a=false; boolean R1b=false; boolean R1=false;

      boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2=false;

      boolean R5=false;

      boolean Rh2a=false;boolean Rh2b=false;boolean Rh2c=false;

      boolean Rh3a=false;boolean Rh3b=false;

      double T=273.15;

      double v=0;

      double ro;

      double vf;

      double vg;

      double hf;

      double hg;     

      double x;

      double h1;

      double sf;

      double sg;     

      double s1;

    if(P<=16.529e3)

    { T=Ts(P);

      hf=hf_T(T);

      if(h<=hf) R1a=true;

      hg=hg_T(T);

      h1=h2(P,1073.15);

      if(h>=hg && h<=h1) R2a=true;  

    }

    if(P<=22.064e3)

    {T=Ts(P);

     hf=hf_T(T);

     hg=hg_T(T);

     if(h>=hf && h<=hg) R4=true; 

    }

    R1b=P>=16.529e3 && P<=100e3 && h>=h1(P,273.15) && h<=h1(P,623.15);

    R1=R1a || R1b;

    if(!R1 && !R4)

                {R3=h>h1(P,623.15) && h<h2(P,Tb23(P)) && P<=100e3 && P>=16.529;}

                if(!R1 && !R4 && !R3)

                { R2b= h>=h2(P,Tb23(P)) && h<=h2(P,1073.15) && P>16.529e3 && P<=100.0e3;

                  R2=R2a || R2b;

                  if(R2a)

                  {Rh2a= P<=4e3 && h>hg_T(Ts(P)) && h<4142.5;}

                  if(R2)

                  {Rh2b= P>4e3 && P<200e3 && h>h2bc(P) && h<h2(P,623.15);

                   Rh2c= h>h2(P,Tb23(P)) && h<h2bc(P) && P<100e3 && P>6.5467e3;

                  }

                }

                if(!R1 && !R4 && !R3 && !R2)

                {R5= h>h2(P,1073.15) && h>h5(P,2273.15) && P<50e5 ;}

    if(R1)

    {Region="R1";T=T1_Ph(P,h);a[0]=P;a[1]=T;a[2]=v1(P,T);a[3]=h;a[4]=u1(P,T);a[5]=s1(P,T);

     a[6]=-1.0;a[7]=Cp1(P,T);a[8]=Cv1(P,T);a[9]=alpha1(P,T);a[10]=kappa1(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound1(P,T);

    }

                else if(Rh2a)

    {Region="Rh2a";T=T2a_Ph(P,h);

     a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h;a[4]=u2(P,T);a[5]=s2(P,T);

     a[6]=2.0;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound2(P,T);

    }

    else if(Rh2b)

    {Region="Rh2b";T=T2b_Ph(P,h);

     a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h;a[4]=u2(P,T);a[5]=s2(P,T);

     a[6]=2.0;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound2(P,T);

     }

    else if(Rh2c)

    {Region="Rh2c";T=T2c_Ph(P,h);

     a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h;a[4]=u2(P,T);a[5]=s2(P,T);

     a[6]=2.0;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T);a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound2(P,T);

    }

    else if(R4)

    { Region="R4";

      T=Ts(P);

                  vf=vf_T(T);

      vg=vg_T(T);

      hf=hf_T(T);

      hg=hg_T(T);     

      x=(h-hf)/(hg-hf);

      sf=sf_T(T);

      sg=sg_T(T);     

      double s=sf+(sg-sf)*x;

      v=vf+(vg-vf)*x;

                  double u=h-P*v;

                  double Cpf=Cpf_T(T);

      double Cpg=Cpg_T(T);

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double Cp=Cpf+(Cpg-Cpf)*x;

      double Cv=Cvf+(Cvg-Cvf)*x;

      a[7]=Cp;a[8]=Cv;

      a[0]=P;a[1]=T;a[2]=v;a[3]=h;a[4]=u;a[5]=s;a[6]=x;

      a[7]=Cp1(P,T)*(1.0-x)+Cp2(P,T)*x;a[8]=Cv1(P,T)*(1.0-x)+Cv2(P,T)*x;

      a[9]=alpha1(P,T)*(1.0-x)+alpha2(P,T)*x;

      a[10]=kappa1(P,T)*(1-x)+kappa2(P,T)*x;

      a[11]=viscosity_Tx(T,x);a[12]=k_Tx(T,x);a[13]=sigma(T);a[14]=Pr_Tx(T,x);a[15]=1.0/a[2];

      a[16]=sound_Tx(T,x);  

    }

else if(R3)

{  

    if(P>22.064e3) {Rh3a= h<=h3ab(P);Rh3b= h>h3ab(P) && h<=h2(P,Tb23(P));}

    else             {Rh3a = Rh3a && P>Ps3_h(h) && h<h1(P,623.15) && h<=h3ab(P);

                    Rh3b = Rh3b && P>Ps3_h(h)  && h<h1(P,623.15);

                   }

                Region="R3";

                if(Rh3a) T=T3a_Ph(P,h);

                else if(Rh3b) T=T3b_Ph(P,h);

                a[0]=P;a[1]=T;a[2]=v3(T,P);ro=1.0/a[2];

    a[3]=h;a[4]=u3(ro,T);a[5]=s3(ro,T);

    a[6]=3.0;a[7]=Cp3(ro,T);a[8]=Cv3(ro,T);a[9]=0.0;

    //alpha3(ro,T);

    a[10]=0.0;//kappa3(ro,T);

    a[11]=viscosity_roT(ro,T);a[12]=k_roT(ro,T);a[13]=sigma(T);a[14]=Pr_roT(ro,T);a[15]=1.0/a[2];

    a[16]=sound3(ro,T); 

}

else if(R5)

{    Region="R5";

     T=T5_Ph(P,h);

                 a[0]=P;a[1]=T;a[2]=v5(P,T);a[3]=h;a[4]=u5(P,T);a[5]=s5(P,T);

     a[6]=5.0;a[7]=Cp5(P,T);a[8]=Cv5(P,T);a[9]=alpha5(P,T);a[10]=kappa5(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T); a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound5(P,T);

}

return a;

}

//PROPERTY Function(P,s)

public double[] property_Ps(double P,double s)

{ double a[]=new double[17];

  boolean R1a=false,R1b=false,R1=false;

  boolean R2a=false,R2b=false,R2c=false,R2=false;

  boolean R3a=false,R3b=false,R3=false;

  boolean R4=false;

  boolean R5=false;

  double T=273.15,v=0,ro=0,vf=0,vg=0,hf=0,hg=0,x=0,h1=0,sf=0,sg=0,s1=0,h=0;

  if(P<=22.064e3) {T=Ts(P);sf=sf_T(T);sg=sg_T(T);}

  if(P<=16.529e3) { if(s<=sf) R1a=true;}

  if(P<=22.064e3) {if(s>=sf && s<=sg) R4=true;}

   double ss1=s1(P,273.15);

   double ss2=s1(P,623.15);

   R1b=P>=16.529e3 && P<=100e3 && s>=s1(P,273.15) && s<=s1(P,623.15);

   R1=R1a || R1b;

   if(!R1 && !R4)

                {R3a=s>s1(P,623.15) && s<=4.41202148223476 && P>Ps3_s(s) && P<100e3;

                 R3b=s<s2(P,Tb23(P)) && s>4.41202148223476 && P>Ps3_s(s) && P<100e3;

                 R3= R3a || R3b;

    }

                if(!R1 && !R4 && !R3)

                {R2a= P<=4e3 && s>sg && s<=s2(P,1073.15);        

                 R2c=s<=s2(P,Tb23(P)) && s<=5.85 && P<100e3;

                 R2b= s<s2(P,1073.15) && s>5.85 && P<100e3 && !R2a;

                 R2= R2a || R2b || R2c;

    }

    if(!R1 && !R4 && !R3 && !R2)

                {R5=  s>s2(P,1073.15)  && s<=s2(P,2073.15) && P<50e3;}

    //Assign values        

                if(R1)

    {Region="R1";T=T1_Ps(P,s);a[0]=P;a[1]=T;a[2]=v1(P,T);a[3]=h1(P,T);a[4]=u1(P,T);a[5]=s;

     a[6]=-1.0;a[7]=Cp1(P,T);a[8]=Cv1(P,T);a[9]=alpha1(P,T);a[10]=kappa1(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T); a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound1(P,T); 

    }

                else if(R2a)

    {Region="R2a";T=T2a_Ps(P,s);

     a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h2(P,T);a[4]=u2(P,T);a[5]=s;

     a[6]=2.1;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T); a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound2(P,T);

    }

    else if(R2b)

    {Region="R2b";T=T2b_Ps(P,s);

     a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h2(P,T);a[4]=u2(P,T);a[5]=s;

     a[6]=2.2;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T); a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound2(P,T);

    }

    else if(R2c)

    {Region="R2c";T=T2c_Ps(P,s);

     a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h2(P,T);a[4]=u2(P,T);a[5]=s;

     a[6]=2.3;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T); a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound2(P,T); 

    }

    else if(R4)

    { Region="R4";

      T=Ts(P);

                  vf=vf_T(T);

      vg=vg_T(T);

      sf=sf_T(T);

      sg=sg_T(T);     

      x=(s-sf)/(sg-sf);

      hf=hf_T(T);

      hg=hg_T(T);     

      h=hf+(hg-hf)*x;

      v=vf+(vg-vf)*x;

                  double u=h-P*v;

                  double Cpf=Cpf_T(T);

      double Cpg=Cpg_T(T);

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double Cp=Cpf+(Cpg-Cpf)*x;

      double Cv=Cvf+(Cvg-Cvf)*x;

      a[7]=Cp;a[8]=Cv;

      a[0]=P;a[1]=T;a[2]=v;a[3]=h;a[4]=u;a[5]=s;a[6]=x;

      a[11]=viscosity_Tx(T,x);a[12]=k_Tx(T,x);a[13]=sigma(T); a[14]=Pr_Tx(T,x);a[15]=1.0/a[2];

      a[16]=sound_Tx(T,x); 

    }

    else if(R3a)

    {Region="R3a";T=T3a_Ps(P,s);

                 a[0]=P;a[1]=T;a[2]=v3(T,P);ro=1.0/a[2];

     a[3]=h3(ro,T);a[4]=u3(ro,T);a[5]=s;

    a[6]=3.1;a[7]=Cp3(ro,T);a[8]=Cv3(ro,T);a[9]=alpha2(ro,T);a[10]=kappa2(ro,T);

    a[11]=viscosity_roT(P,T);a[12]=k_roT(P,T);a[13]=sigma(T); a[14]=Pr_roT(P,T);a[15]=1.0/a[2];

    a[16]=sound3(ro,T);

    }

    else if(R3b)

    {Region="R3b";T=T3b_Ps(P,s);

                 a[0]=P;a[1]=T;a[2]=v3(T,P);ro=1.0/a[2];

     a[3]=h3(ro,T);a[4]=u3(ro,T);a[5]=s;

     a[6]=3.2;a[7]=Cp3(ro,T);a[8]=Cv3(ro,T);a[9]=alpha2(ro,T);a[10]=kappa2(ro,T);

     a[11]=viscosity_roT(P,T);a[12]=k_roT(P,T);a[13]=sigma(T); a[14]=Pr_roT(P,T);a[15]=1.0/a[2];

     a[16]=sound3(ro,T);

    }

    else if(R5)

    {    Region="R5";

     T=T5_Ps(P,s);

                 a[0]=P;a[1]=T;a[2]=v5(P,T);a[3]=h5(P,T);a[4]=u5(P,T);a[5]=s;

     a[6]=5.0;a[7]=Cp5(P,T);a[8]=Cv5(P,T);a[9]=alpha5(P,T);a[10]=kappa5(P,T);

     a[11]=viscosity_PT(P,T);a[12]=k_PT(P,T);a[13]=sigma(T); a[14]=Pr_PT(P,T);a[15]=1.0/a[2];

     a[16]=sound5(P,T);

    }

  return a;

}

//PROPERTY Function(ro,T)

/*

T=623.15  P=100000.0 v=0.0013117600270041421 ro=762.3345577040078

T=623.15  P=16529.0  v=0.0017400753419988663 ro=574.6877596985404

T=623.15P=16529.0    v=0.00880124709409546   ro=113.6202619138912

T=647.096 P=22064.0  v=0.004452868905417744  ro=224.57431854400966

T=273.15  P=0.611    v=0.0010002069774326832 ro=999.7930653981094

T=863.15P=100000.0   v=0.0025847184959050373 ro=386.88932724561585

T=1073.15P=100000.0  v=0.004335507653248776  ro=230.65349665584338

T=1073.15P=50000.0   v=0.00907300964443448   ro=110.21701058296736

*/

public double[] property_roT(double ro,double T)

{  double a[]=new double[17];

    double v=1.0/ro;

   double P=0;

    boolean R1a=false; boolean R1b=false; boolean R1=false;

    boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2=false;

    boolean R5=false;

                R1a= (v<vf_T(T)) && (T>=273.15 && T<=623.15);

    R1b= v<=vb13(P3(ro,623.15)) && v>= 0.0013117600270041421 && v<= 00.0013117600270041421 && (T>623.15);

    R1=R1a || R1b;

    if(!R1)

                {R4= (v>=vf_T(T)) && v<=vg_T(T) && (T>=273.15 && T<=647.096);

                }

                if(!R1 && !R4)

                {R3=v>vb13(P3(ro,623.15)) && v<vb23(T) && (T>623.15 && T<863.15);

                }

                if(!R1 && !R4 && !R3)

                {R2a=(v>vf_T(T)) && (T>=273.15 && T<=623.15) && v<=vb25(P2(ro,1073.15));

                 R2b=(T>=273.15 && T<=623.15) && v>=vb23(T) && v<=vb25(P2(ro,1073.15));

                 R2=R2a || R2b;

    }

    if(!R1 && !R4 && !R3 && !R2){R5= T>1073.15;}

                if(R1)

    {Region="R1";P=P1(ro,T);a[0]=P;a[1]=T;a[2]=1.0/ro;a[3]=h1(P,T);a[4]=u1(P,T);a[5]=s1(P,T);

     a[6]=-1.0;a[7]=Cp1(P,T);a[8]=Cv1(P,T);a[9]=alpha1(P,T);a[10]=kappa1(P,T);

     a[11]=viscosity_PT(P,T);

     a[12]=k_PT(P,T);

     a[13]=sigma(T);

     a[14]=Pr_PT(P,T);

     a[15]=1.0/a[2];

     a[16]=sound1(P,T);

    }

    else if(R2)

    {Region="R2";P=P2(ro,T);

     a[0]=P;a[1]=T;a[2]=1.0/ro;a[3]=h2(P,T);a[4]=u2(P,T);a[5]=s2(P,T);

     a[6]=2.0;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

     a[11]=viscosity_PT(P,T);

     a[12]=k_PT(P,T);

     a[13]=sigma(T);

     a[14]=Pr_PT(P,T);

     a[15]=1.0/a[2];

     a[16]=sound2(P,T);

    }

    else if(R4)

    { Region="R4";

                  double vf=vf_T(T);

      double vg=vg_T(T);

      double hf=hf_T(T);

      double hg=hg_T(T);     

      double x=(v-vf)/(vg-vf);

      double h=hf+(hg-hf)*x;

      double sf=sf_T(T);

      double sg=sg_T(T);     

      double s=sf+(sg-sf)*x;

      double Cpf=Cpf_T(T);

      double Cpg=Cpg_T(T);

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double Cp=Cpf+(Cpg-Cpf)*x;

      double Cv=Cvf+(Cvg-Cvf)*x;

                  P=Ps(T);

                  double u=h-P*v;    

      a[0]=P;a[1]=T;a[2]=v;a[3]=h;a[4]=u;a[5]=s;a[6]=x;

      a[7]=Cp;a[8]=Cv;

      a[9]=alpha_Tx(T,x);

      a[10]=kappa_Tx(T,x);

      a[11]=viscosity_Tx(T,x);

      a[12]=k_Tx(T,x);

      a[13]=sigma(T);

     a[14]=Pr_Tx(T,x);

     a[15]=1.0/a[2];

     a[16]=sound_Tx(T,x);     

    }

else if(R3)

{   Region="R3";

    P=P3(ro,T);

                a[0]=P;a[1]=T;a[2]=1.0/ro;

    a[3]=h3(ro,T);a[4]=u3(ro,T);a[5]=s3(ro,T);

    a[6]=3.0;a[7]=Cp3(ro,T);a[8]=Cv3(ro,T);a[9]=alpha3(ro,T);a[10]=kappa3(ro,T);

     a[11]=viscosity_roT(ro,T);

     a[12]=k_roT(ro,T);

     a[13]=sigma(T);

     a[14]=Pr_roT(ro,T);

     a[15]=1.0/a[2];

     a[16]=sound3(ro,T);

}

else if(R5)

{    Region="R5";

     P=P5(ro,T);

                 a[0]=P;a[1]=T;a[2]=1.0/ro;a[3]=h5(P,T);a[4]=u5(P,T);a[5]=s5(P,T);

     a[6]=5.0;a[7]=Cp5(P,T);a[8]=Cv5(P,T);a[9]=alpha5(P,T);a[10]=kappa5(P,T);

     a[11]=viscosity_PT(P,T);

     a[12]=k_PT(P,T);

     a[13]=sigma(T);

     a[14]=Pr_PT(P,T);

     a[15]=1.0/a[2];

     a[16]=sound5(P,T);

}

return a;

}

public double Cp_roT(double ro,double T)

{   double CproT=0;

    double v=1.0/ro;

   double P=0;

    boolean R1a=false; boolean R1b=false; boolean R1=false;

    boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2=false;

    boolean R5=false;

                R1a= (v<vf_T(T)) && (T>=273.15 && T<=623.15);

    R1b= v<=vb13(P3(ro,623.15)) && v>= 0.0013117600270041421 && v<= 00.0013117600270041421 && (T>623.15);

    R1=R1a || R1b;

    if(!R1)

                {R4= (v>=vf_T(T)) && v<=vg_T(T) && (T>=273.15 && T<=647.096);

                }

                if(!R1 && !R4)

                {R3=v>vb13(P3(ro,623.15)) && v<vb23(T) && (T>623.15 && T<863.15);

                }

                if(!R1 && !R4 && !R3)

                {R2a=(v>vf_T(T)) && (T>=273.15 && T<=623.15) && v<=vb25(P2(ro,1073.15));

                 R2b=(T>=273.15 && T<=623.15) && v>=vb23(T) && v<=vb25(P2(ro,1073.15));

                 R2=R2a || R2b;

    }

    if(!R1 && !R4 && !R3 && !R2){R5= T>1073.15;}

                if(R1)

    {Region="R1";P=P1(ro,T);CproT=Cp1(P,T);

    }

    else if(R2)

    {Region="R2";P=P1(ro,T);

     CproT=Cp2(P,T);

    }

    else if(R3)

    { Region="R3";

    P=P3(ro,T);

                CproT=Cp3(ro,T);

    }

    else if(R4)

    { Region="R4";

                  double vf=vf_T(T);

      double vg=vg_T(T);

      double hf=hf_T(T);

      double hg=hg_T(T);     

      double x=(v-vf)/(vg-vf);

      double h=hf+(hg-hf)*x;

      double sf=sf_T(T);

      double sg=sg_T(T);     

      double s=sf+(sg-sf)*x;

      double Cpf=Cpf_T(T);

      double Cpg=Cpg_T(T);

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double Cp=Cpf+(Cpg-Cpf)*x;

      double Cv=Cvf+(Cvg-Cvf)*x;

                  P=Ps(T);

                  double u=h-P*v;    

      CproT=Cp;

    }

else if(R5)

{    Region="R5";

     P=P5(ro,T);

                 CproT=Cp5(P,T);

}

return CproT;

}

//PROPERTY Function(P,T)

public double[] property_PT(double P,double T)

{   double a[]=new double[17];

//Find which region data belongs to

    boolean R1a=false; boolean R1b=false; boolean R1=false;

    boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2c=false;boolean R2=false;

    boolean R5=false;

    R1a= (P>=16.529e3 && P<100e3) && (T>=273.15 && T<=623.15);

    R1b= (P>=Ps(T) && P<16.529e3) && (T>=273.15 && T<=Ts(P));

    R1=R1a || R1b;

    if(!R1)

    {R2a= (P>=0 && P<Ps(T) && P<16.529e3) && (T>=273.15 &&  T>Ts(P) && T<623.15);

     R2b= (P>=0 && P<16.529e3 && T>=623.15 && T<=1073.15);

     R2c= (P<Pb23(T) && T>Tb23(P) && T<=1073.15 && P<=100.0e3 && P>=16.529e3);

     R2= R2a || R2b || R2c;

    }

    if(!R1 && !R2)

    {    boolean a1=P>=16.529e3;

         boolean a2=P<100.0e3;

         boolean a3=T<Tb23(P);

         boolean a4=T>623.15;

         boolean a5=P>Pb23(T);

         boolean a6=a1 && a2 && a3 && a4 && a5;

                    R3=a6;

                }

    if(!R1 && !R2 && !R3)

    {R5=(P>=0 && P<50e3) && (T<=2273.15 && T>=1073.15);}

if(R1)

{Region="R1";

 a[0]=P;a[1]=T;a[2]=v1(P,T);a[3]=h1(P,T);a[4]=u1(P,T);a[5]=s1(P,T);

 a[6]=-1.0;a[7]=Cp1(P,T);a[8]=Cv1(P,T);a[9]=alpha1(P,T);a[10]=kappa1(P,T);

 a[11]=viscosity_PT(P,T);

 a[12]=k_PT(P,T);

 a[13]=sigma(T);

 a[14]=Pr_PT(P,T);

 a[15]=1.0/a[2];

 a[16]=sound1(P,T);

}

else if(R2)

{Region="R2";

 a[0]=P;a[1]=T;a[2]=v2(P,T);a[3]=h2(P,T);a[4]=u2(P,T);a[5]=s2(P,T);

 a[6]=2.0;a[7]=Cp2(P,T);a[8]=Cv2(P,T);a[9]=alpha2(P,T);a[10]=kappa2(P,T);

 a[11]=viscosity_PT(P,T);

 a[12]=k_PT(P,T);

 a[13]=sigma(T);

  a[14]=Pr_PT(P,T);

 a[15]=1.0/a[2];

 a[16]=sound2(P,T);

}

else if(R3)

{Region="R3";

 a[0]=P;a[1]=T;a[2]=v3(P,T);

 double ro=1.0/a[2];

 a[3]=h3(ro,T);a[4]=u3(ro,T);a[5]=s3(ro,T);

 a[6]=3.0;a[7]=Cp2(ro,T);a[8]=Cv2(ro,T);a[9]=alpha2(ro,T);a[10]=kappa2(ro,T);

 a[11]=viscosity_roT(ro,T);

 a[12]=k_roT(ro,T);a[13]=sigma(T);

 a[14]=Pr_roT(ro,T);

 a[15]=1.0/a[2];

 a[16]=sound3(ro,T);

}

else if(R5)

{Region="R5";a[0]=P;a[1]=T;a[2]=v5(P,T);a[3]=h5(P,T);a[4]=u5(P,T);a[5]=s5(P,T);

 a[6]=5.0;a[7]=Cp5(P,T);a[8]=Cv5(P,T);a[9]=alpha5(P,T);a[10]=kappa5(P,T);

 a[11]=viscosity_PT(P,T);

 a[12]=k_PT(P,T);a[13]=sigma(T);

 a[14]=Pr_PT(P,T);

 a[15]=1.0/a[2];

 a[16]=sound5(P,T);

}

return a;

}

public double Cp_PT(double P,double T)

{  double CpPT=0;

//Find which region data belongs to

    boolean R1a=false; boolean R1b=false; boolean R1=false;

    boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2c=false;boolean R2=false;

    boolean R5=false;

    R1a= (P>=16.529e3 && P<100e3) && (T>=273.15 && T<=623.15);

    R1b= (P>=Ps(T) && P<16.529e3) && (T>=273.15 && T<=Ts(P));

    R1=R1a || R1b;

    if(!R1)

    {R2a= (P>=0 && P<Ps(T) && P<16.529e3) && (T>=273.15 &&  T>Ts(P) && T<623.15);

     R2b= (P>=0 && P<16.529e3 && T>=623.15 && T<=1073.15);

     R2c= (P<Pb23(T) && T>Tb23(P) && T<=1073.15 && P<=100.0e3 && P>=16.529e3);

     R2= R2a || R2b || R2c;

    }

    if(!R1 && !R2)

    {    boolean a1=P>=16.529e3;

         boolean a2=P<100.0e3;

         boolean a3=T<Tb23(P);

         boolean a4=T>623.15;

         boolean a5=P>Pb23(T);

         boolean a6=a1 && a2 && a3 && a4 && a5;

                    R3=a6;

                }

    if(!R1 && !R2 && !R3)

    {R5=(P>=0 && P<50e3) && (T<=2273.15 && T>=1073.15);}

if(R1)

{Region="R1";

 CpPT=Cp1(P,T);

}

else if(R2)

{Region="R2";

 CpPT=Cp2(P,T);

}

else if(R3)

{Region="R3";

 double ro=1.0/v3(P,T);

 CpPT=Cp2(ro,T);

}

else if(R5)

{CpPT=Cp5(P,T);}

return CpPT;

}

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

public double ro_PT(double P,double T)

{   double ro=0;

//Find which region data belongs to

    boolean R1a=false; boolean R1b=false; boolean R1=false;

    boolean R4=false;boolean R3=false;boolean R2a=false;boolean R2b=false;boolean R2c=false;boolean R2=false;

    boolean R5=false;

    R1a= (P>=16.529e3 && P<100e3) && (T>=273.15 && T<=623.15);

    R1b= (P>=Ps(T) && P<16.529e3) && (T>=273.15 && T<=Ts(P));

    R1=R1a || R1b;

    if(!R1)

    {R2a= (P>=0 && P<Ps(T) && P<16.529e3) && (T>=273.15 &&  T>Ts(P) && T<623.15);

     R2b= (P>=0 && P<16.529e3 && T>=623.15 && T<=1073.15);

     R2c= (P<Pb23(T) && T>Tb23(P) && T<=1073.15 && P<=100.0e3 && P>=16.529e3);

     R2= R2a || R2b || R2c;

    }

    if(!R1 && !R2)

    {    boolean a1=P>=16.529e3;

         boolean a2=P<100.0e3;

         boolean a3=T<Tb23(P);

         boolean a4=T>623.15;

         boolean a5=P>Pb23(T);

         boolean a6=a1 && a2 && a3 && a4 && a5;

                    R3=a6;

                }

    if(!R1 && !R2 && !R3)

    {R5=(P>=0 && P<50e3) && (T<=2273.15 && T>=1073.15);}

if(R1)

{Region="R1";

 ro=1.0/v1(P,T);

}

else if(R2)

{Region="R2";

 ro=1.0/v2(P,T);

}

else if(R3)

{Region="R3";

 ro=1.0/v3(P,T);

}

else if(R5)

{ro=1.0/v5(P,T);}

return ro;

}

 

 

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

//PROPERTY Function(T,x)

public double[] property_Tx(double T,double x)

{ double a[]=new double[17];

  double P=Ps(T);

  System.out.println("T="+T+"x="+x+"P="+P);

  double hf=hf_T(T);

  double hg=hg_T(T);

  double sf=sf_T(T);

  double sg=sg_T(T);

  double vf=vf_T(T);

  double vg=vg_T(T);

  double h=hf*(1-x)+hg*x;

  double s=sf*(1-x)+sg*x;

  double v=vf*(1-x)+vg*x;

  double u=h-P*v;

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double Cp=Cp_Tx(T,x);

      double Cv=Cvf+(Cvg-Cvf)*x;

      a[0]=P;a[1]=T;a[2]=v;a[3]=h;a[4]=u;a[5]=s;

      a[6]=x;a[7]=Cp;a[8]=Cv;

      a[9]=alpha_Tx(T,x);

      a[10]=kappa_Tx(T,x);

      a[11]=viscosity_Tx(T,x);

      a[12]=k_Tx(T,x);

      a[13]=sigma(T);

      a[14]=Pr_Tx(T,x);

      a[15]=1.0/a[2];

      a[16]=sound_Tx(T,x);

return a;

}

public double[] property_Px(double P,double x)

{ double a[]=new double[17];

  double T=Ts(P);

  double hf=hf_T(T);

  double hg=hg_T(T);

  double sf=sf_T(T);

  double sg=sg_T(T);

  double vf=vf_T(T);

  double vg=vg_T(T);

  double visf=viscosity_roT(1.0/vf,T);

  double visg=viscosity_roT(1.0/vg,T);

  double kf=k_roT(1.0/vf,T);

  double kg=k_roT(1.0/vg,T);

      double Cvf=Cvf_T(T);

      double Cvg=Cvg_T(T);

      double Cp=Cp_Tx(T,x);

      double Cv=Cvf+(Cvg-Cvf)*x;

      double h=hf*(1-x)+hg*x;

      double s=sf*(1-x)+sg*x;

      double v=vf*(1-x)+vg*x;

      double u=h-P*v;

      a[0]=P;a[1]=T;a[2]=v;a[3]=h;a[4]=u;a[5]=s;

      a[6]=x;a[7]=Cp;a[8]=Cv;

      a[11]=viscosity_Tx(T,x);

      a[12]=k_Tx(T,x);

      a[13]=sigma(T);

      a[14]=Pr_Tx(T,x);

      a[15]=1.0/a[2];

      a[16]=sound_Tx(T,x);

return a;

}

public double[][] TS_saturation()

{

int n=200;

double a[][]=new double[2][2*n];

double T1=273.16;

double T;

double dT=(Tc-T1)/(n-1);

for(int i=0;i<=n;i++) {T=T1+i*dT;a[0][i]=T;a[1][i]=sf_T(T);}

for(int i=n;i<2*n;i++) {T=Tc-(i-n)*dT;a[0][i]=T;a[1][i]=sg_T(T);}             

return a;

}

public double[][] TS_P_dT(double P,double T1,double T2,int n)

{

double a[][]=new double[2][n];

double T;

double dT=(T2-T1)/(n-1);

for(int i=0;i<n;i++) {T=T1+i*dT;a[0][i]=T;double b[]=property("tp",T,P);a[1][i]=b[5];}

return a;

}

public void plot_TS(double P[],double T1,double T2,int n)

{ //double a[][]=TS_saturation();

  Plot p1=new Plot(ass,ats);

  int m=P.length;

  for(int i=0;i<m;i++)

  {double b[][]=TS_P_dT(P[i],T1,T2,n);

   p1.addData(b[1],b[0]);

  }

   p1.setPlabel("T-s diagram");

   p1.setXlabel("Entropy s kJ/(kgK)");

   p1.setYlabel("Temperature degree K");

   p1.plot();             

}

 

public void plot_TS(String pr,double v1,double v2)

{   //double a[][]=TS_saturation();

                Plot p1=new Plot(ass,ats);

                double b[]=property(pr,v1,v2);

                double s[]={b[5]};

                double T[]={b[1]};

                p1.addData(s,T);

                p1.setPlotType(1,23);

                p1.setPlabel("T-s diagram");

    p1.setXlabel("Entropy s kJ/(kgK)");

    p1.setYlabel("Temperature degree K");

                p1.plot();

}

public void plot_TS_C(String pr,double v1,double v2)

{   //double a[][]=TS_saturation();

                Plot p1=new Plot(ass,ats);

                v1+=273.15;

                double b[]=property(pr,v1,v2);

                double s[]={b[5]};

                double T[]={b[1]};

                p1.addData(s,T);

                p1.setPlotType(1,23);

                p1.setPlabel("T-s diagram");

    p1.setXlabel("Entropy s kJ/(kgK)");

    p1.setYlabel("Temperature degree K");

                p1.plot();

}

 

//Processes P=const from T1 to T2

public double[][] P_T1_T2_TS(double P, double T1,double T2,int n)

{ double a[][]=new double[2][n];

  double T;

  double dT=(T2-T1)/(n-1);

  for(int i=0;i<n;i++)

  {T=T1+i*dT;double b[]=property("pt",P,T);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

//Processes T=const from P1 to P2

public double[][] T_P1_P2_TS(double T, double P1,double P2,int n)

{ double a[][]=new double[2][n];

  double P;

  double dP=(P2-P1)/(n-1);

  for(int i=0;i<n;i++)

  {P=P1+i*dP;double b[]=property("pt",P,T);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

//Processes s=const from T1 to T2

public double[][] S_T1_T2_TS(double s, double T1,double T2,int n)

{ double a[][]=new double[2][n];

  double T;

  double dT=(T2-T1)/(n-1);

  for(int i=0;i<n;i++)

  {T=T1+i*dT;a[0][i]=s;a[1][i]=T;}

  return a;

}

//Processes s=const from P1 to P2

public double[][] S_P1_P2_TS(double s, double P1,double P2,int n)

{ double a[][]=new double[2][n];

  double P;

  double dP=(P2-P1)/(n-1);

  for(int i=0;i<n;i++)

  {P=P1+i*dP;double b[]=property("ps",P,s);a[0][i]=s;a[1][i]=b[1];}

  return a;

}

//Processes h=const from P1 to P2

public double[][] H_P1_P2_TS(double h, double P1,double P2,int n)

{ double a[][]=new double[2][n];

  double P;

  double dP=(P2-P1)/(n-1);

  for(int i=0;i<n;i++)

  {P=P1+i*dP;double b[]=property("ph",P,h);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

 

//Processes v=const from T1 to T2

public double[][] V_T1_T2_TS(double v, double T1,double T2,int n)

{ double a[][]=new double[2][n];

  double T;

  double dT=(T2-T1)/(n-1);

  for(int i=0;i<n;i++)

  {T=T1+i*dT;double b[]=property("tv",T,v);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

 

//Processes v=const from P1 to P2

public double[][] V_P1_P2_TS(double v, double P1,double P2,int n)

{ double a[][]=new double[2][n];

  double P;

  double dP=(P2-P1)/(n-1);

  for(int i=0;i<n;i++)

  {P=P1+i*dP;double b[]=property("pv",P,v);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

 

// Processes m=const, Pv^m=const. from P1,T1 to P2,T2

public double[][] M_P1_T1_P2_T2_TS(double P1,double T1,double P2,double T2,int n)

{ double a[][]=new double[2][n];

  double b[]=property("pt",P1,T1);

  double v1=b[2];

  b=property("pt",P2,T2);

  double v2=b[2];

  double m=Math.log(P1/P2)/Math.log(v2/v1);

  double C=P1*Math.pow(v1,m);

  double P;

  double v;

  double dP=(P2-P1)/(n-1);

  for(int i=0;i<n;i++)

  {P=P1+i*dP;v=Math.pow((C/P),(1.0/m));b=property("pv",P,v);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

 

// Processes m=const, Pv^m=const. from P1,T1 to P2

public double[][] M_P1_T1_P2_TS(double m,double P1,double T1,double P2,int n)

{ double a[][]=new double[2][n];

  double b[]=property("pt",P1,T1);

  double v1=b[2];

  double C=P1*Math.pow(v1,m);

  double P;

  double v;

  double dP=(P2-P1)/(n-1);

  for(int i=0;i<n;i++)

  {P=P1+i*dP;v=Math.pow((C/P),(1.0/m));b=property("pv",P,v);a[0][i]=b[5];a[1][i]=b[1];}

  return a;

}

 

 

public double[][] Pv_saturation(double vlimit)

{ //v1 limit value of the saturation curve

int n=200;

double a[][]=new double[2][2*n];

double P1=0.000611e3;

double P2=10;

double P;

double dP=(Pc-P1)/(n-1);

double dP1=(Pc-P2)/(n-1);

for(int i=0;i<n;i++) {P=P1+i*dP;a[0][i]=P;a[1][i]=vf_P(P);}

double v1=0.0;

int n1=n;

for(int i=n;i<2*n && v1<vlimit;i++) {P=Pc-(i-n)*dP1;a[0][i]=P;v1=a[1][i]=vg_P(P);n1++;}

double b[][]=new double[2][n1];

for(int i=0;i<n1;i++) {b[0][i]=a[0][i];b[1][i]=a[1][i];   }

return b;

}

 

public void plot_Pv(String pr,double v1,double v2,double vlimit)

{   double a[][]=Pv_saturation(vlimit);

                Plot p=new Plot(a[1],a[0]);

                double b[]=property(pr,v1,v2);

                double P[]={b[0]};

                double v[]={b[2]};

                p.addData(v,P);

                p.setPlotType(1,23);

                p.setXlogScaleOn();

                p.setPlabel("P-v diagram");

    p.setXlabel("Specific volume m^3/kg");

    p.setYlabel("Pressure kPa");

                p.plot();  

}

 

// REGION BOUNDARY BETWEEN 2-3

public double Pb23(double T)

{double teta=T/d[0].Tstar;

 double pi=d[0].n[0]+d[0].n[1]*teta+d[0].n[2]*teta*teta;

 return pi*d[0].Pstar; //kPa

}

public double Tb23(double P)

{double pi=P/d[0].Pstar;

 double teta=d[0].n[3]+Math.sqrt((pi-d[0].n[4])/d[0].n[2]);

 return teta*d[0].Tstar; //degree K

}

public double vb23(double T)

{double v=v2(Pb23(T),T);return v;}

 

public double vb23_P(double P)

{double v=v2(P,Tb23(P));return v;}

//REGION BOUNDARY 0-3

public double vb03(double P)

{double v=v1(P,273.15);return v;}

 

//REGION BOUNDARY 1-3

public double vb13(double P)

{double v=v1(P,623.15);return v;}

 

//REGION BOUNDARY 2-5

public double vb25(double P)

{double v=v2(P,1073.15);return v;}

 

// REGION BOUNDARY 2bc

public double P2bc(double h)

{double Pstar=1000.0;

 double hstar=1;

 double eta=h/hstar;

 double n[]={0.90584278514723e3,-0.67955786399241,0.12809002730136e-3};

 double pi=n[1]+n[2]*eta+n[3]*eta*eta*eta;

 return pi*Pstar; //degree K

}

public double h2bc(double P)

{double Pstar=1000.0;

 double hstar=1;

 double pi=P/Pstar;

 double n[]={0.90584278514723e3,-0.67955786399241,0.12809002730136e-3,0.26526571908428e4,0.45257578905948e1};

 double eta=n[3]+Math.sqrt((pi-n[4])/n[2]);

 return eta*hstar; //degree K

}

// REGION BOUNDARY 3ab

public double h3ab(double P)

{double Pstar=1000.0;

 double hstar=1;

 double pi=P/Pstar;

 double n[]={0.201464004206875e4,0.374696550136983e1,-0.219921901054187e-1,0.875131686009950e-4};

 double eta=n[0]+n[1]*pi+n[2]*pi*pi+n[3]*pi*pi*pi;

 return eta*hstar; //degree K

}

 

public static double pow(double x,int n)

{   if(n==0) return 1;

                int n1=Math.abs(n);

                int sign=n/n1;

    double pp=1.0;

    for(int i=0;i<n1;i++)

    {pp*=x;}

    if(sign<1) pp=1.0/pp;

    return pp;

}

// REGION 1

public double gamma1(double P,double T)

{double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

 int n1=d[1].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[1].n[i]*pow((7.1-pi),d[1].I[i])*pow((to-1.222),d[1].J[i]);}

 return total;

}

public double gamma1_pi(double P,double T)

{double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

 int n1=d[1].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=-d[1].n[i]*d[1].I[i]*pow((7.1-pi),(d[1].I[i]-1))*pow((to-1.222),d[1].J[i]);}

 return total;

}

public double gamma1_pi_pi(double P,double T)

{double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

 int n1=d[1].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[1].n[i]*d[1].I[i]*(d[1].I[i]-1)*pow((7.1-pi),(d[1].I[i]-2))*pow((to-1.222),d[1].J[i]);}

 return total;

}

public double gamma1_to(double P,double T)

{double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

 int n1=d[1].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[1].n[i]*pow((7.1-pi),d[1].I[i])*d[1].J[i]*pow((to-1.222),(d[1].J[i]-1));}

 return total;

}

public double gamma1_to_to(double P,double T)

{double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

 int n1=d[1].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[1].n[i]*pow((7.1-pi),d[1].I[i])*d[1].J[i]*(d[1].J[i]-1)*pow((to-1.222),(d[1].J[i]-2));}

 return total;

}

public double gamma1_pi_to(double P,double T)

{double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

 int n1=d[1].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=-d[1].n[i]*d[1].I[i]*pow((7.1-pi),(d[1].I[i]-1))*d[1].J[i]*pow((to-1.222),(d[1].J[i]-1));}

 return total;

}

public double func_h1(double Ti,double P,double h)

{  double dh=h1(P,Ti)-h;

   return dh;

}

 

public double dfunc_h1(double Ti,double P)

{return dh1_dT_v(P,Ti);}

 

public double T1_Ph(double P,double h)

{ //third order

double x=T1_PhD(P,h);

int nmax=500;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_h1(x,P,h);

   dfx=dfunc_h1(x,P);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_h1(x1,P);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_h1(x2,P);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in P1 estimation is exceeded  Method\n"+

   " results may not be valid");

return x;

}

 

public double T1_PhD(double P,double h)

{double pi=P/d[17].Pstar;

 double hstar=d[17].rostar;

 double eta=h/hstar;

 int n1=d[17].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow(pi,d[17].I[i]);

     x2=pow((eta+1.0),d[17].J[i]);

                 total+=d[17].n[i]*x1*x2;

 }

 return total*d[17].Tstar;

}

public double T1_Ps(double P,double s)

{double pi=P/d[25].Pstar;

 double sstar=d[25].rostar;

 double sigma=s/sstar;

 int n1=d[25].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow(pi,d[25].I[i]);

     x2=pow((sigma+2.0),d[25].J[i]);

                 total+=d[25].n[i]*x1*x2;

 }

 return total*d[25].Tstar;

}

 

public double g1(double P,double T)

{ return gamma1(P,T)*R*T; }

 

public double v1(double P,double T)

{  double pi=P/d[1].Pstar;

   double to=d[1].Tstar/T;

   return pi* gamma1_pi(P,T)*R*T/P;

}

 

public double ro1(double P,double T)

{return 1.0/v1(P,T);}

 

//root finding function

 

 

public double func_T1(double Ti,double P,double ro)

{  double dro=ro1(P,Ti)-ro;

   return dro;

}

 

public double dfunc_T1(double Ti,double P,double ro)

{return -ro*ro*dv1_dT_P(P,Ti);}

//public static double brent(f_x f,double xl,double xu)

 

public double T1(double P,double ro)

{ // third order

double v=1.0/ro;

double x=st.t_pv(P/100.0,v)+273.15;

//double x=473.15;

int nmax=1000;

double alpha=0.51652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_T1(x,P,ro); 

   dfx=dfunc_T1(x,P,ro);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_T1(x1,P,ro);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_T1(x2,P,ro);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid P1="+x);

return x;

}

 

public double func_ro1(double Pi,double ro,double T)

{  double dro=1.0/v1(Pi,T)-ro;

   return dro;

}

 

public double dfunc_ro1(double Pi,double ro,double T)

{return -ro*ro*dv1_dP_T(Pi,T);}

 

 

public double P1(double ro,double T)

{ // third order

double v=1.0/ro;

double x=st.P((T-273.15),v)*100.0;

int nmax=2000;

double alpha=0.5;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_ro1(x,ro,T);

   dfx=dfunc_ro1(x,ro,T);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_ro1(x1,ro,T);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_ro1(x2,ro,T);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

return x;

}

 

public double h1(double P,double T)

{ double pi=P/d[1].Pstar;

 double to=d[1].Tstar/T;

  return to* gamma1_to(P,T)*R*T;

}

public double u1(double P,double T)

{ double pi=P/d[1].Pstar;

  double to=d[1].Tstar/T;

  return (to* gamma1_to(P,T)-pi*gamma1_pi(P,T))*R*T;

}

public double s1(double P,double T)

{ double pi=P/d[1].Pstar;

  double to=d[1].Tstar/T;

  return (to* gamma1_to(P,T)-gamma1(P,T))*R;

}

public double Cp1(double P,double T)

{  double pi=P/d[1].Pstar;

   double to=d[1].Tstar/T;

   return (-to*to*gamma1_to_to(P,T))*R;

}

public double Cv1(double P,double T)

{ double pi=P/d[1].Pstar;

  double to=d[1].Tstar/T;

  double px=(gamma1_pi(P,T)-to*gamma1_pi_to(P,T));

  return (-to*to*gamma1_to_to(P,T)+px*px/gamma1_pi_pi(P,T))*R;

}

public double sound1(double P,double T)

{ double pi=P/d[1].Pstar;

  double to=d[1].Tstar/T;

  double g1=gamma1_pi(P,T);

  double g2=gamma1_pi(P,T)-to*gamma1_pi_to(P,T);

  double g3=to*to*gamma1_to_to(P,T);

  double g4=gamma1_pi_pi(P,T);

  double px=g1*g1/(g2*g2/g3-g4);

  return Math.sqrt(px*R*1e3*T);

}

//Isobaric cubic expansion coefficient

public double alpha1(double P,double T)

{ double pi=P/d[1].Pstar;

  double to=d[1].Tstar/T;

  double px=1-to*gamma1_pi_to(P,T)/gamma1_pi(P,T);

  return px/T;

  }

//Isothermal compressibility Kt

public double kappa1(double P,double T)

{ double pi=P/d[1].Pstar;

  double to=d[1].Tstar/T;

   double px=pi*gamma1_pi_pi(P,T)/gamma1_pi(P,T);

   return -px/P;

}

 

public double dv1_dP_T(double P,double T)

{   double k1=kappa1(P,T);

    double v1=v1(P,T);

                double dv=-v1*k1;

 return dv;

}

public double dv1_dT_P(double P,double T)

{return v1(P,T)*alpha1(P,T);}  

 

public double dh1_dT_v(double P,double T)

{return Cv1(P,T)+P*v1(P,T)*alpha1(P,T);}

//REGION 2

public double gamma2_0(double P,double T)

{double pi=P/d[2].Pstar;

 double to=d[2].Tstar/T;

 int n1=d[2].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[2].n[i]*pow(to,d[2].J[i]);}

 return Math.log(pi)+total;

}

public double gamma2_0_pi(double P,double T)

{double pi=P/d[2].Pstar;

 double to=d[2].Tstar/T;

 return 1.0/pi;

}

public double gamma2_0_pi_pi(double P,double T)

{double pi=P/d[2].Pstar;

 double to=d[2].Tstar/T;

 return -1.0/(pi*pi);

}

public double gamma2_0_to(double P,double T)

{double pi=P/d[2].Pstar;

 double to=d[2].Tstar/T;

 int n1=d[2].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[2].n[i]*d[2].J[i]*pow(to,(d[2].J[i]-1));}

 return total;

}

public double gamma2_0_to_to(double P,double T)

{double pi=P/d[2].Pstar;

 double to=d[2].Tstar/T;

 int n1=d[2].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[2].n[i]*d[2].J[i]*(d[2].J[i]-1)*pow(to,(d[2].J[i]-2));}

 return total;

}

public double gamma2_0_pi_to(double P,double T)

{double pi=P/d[2].Pstar;

 double to=d[2].Tstar/T;

 int n1=d[2].n.length;

 double total=0;

 return total;

}

public double gamma2_r(double P,double T)

{double pi=P/d[3].Pstar;

 double to=d[3].Tstar/T;

 int n1=d[3].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[3].n[i]*pow(pi,d[3].I[i])*pow((to-0.5),d[3].J[i]);}

 return total;

}

public double gamma2_r_pi(double P,double T)

{double pi=P/d[3].Pstar;

 double to=d[3].Tstar/T;

 int n1=d[3].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[3].n[i]*d[3].I[i]*pow(pi,(d[3].I[i]-1))*pow((to-0.5),d[3].J[i]);}

 return total;

}

public double gamma2_r_pi_pi(double P,double T)

{double pi=P/d[3].Pstar;

 double to=d[3].Tstar/T;

 int n1=d[3].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[3].n[i]*d[3].I[i]*(d[3].I[i]-1)*pow(pi,(d[3].I[i]-2))*pow((to-0.5),d[3].J[i]);}

 return total;

}

public double gamma2_r_to(double P,double T)

{double pi=P/d[3].Pstar;

 double to=d[3].Tstar/T;

 int n1=d[3].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[3].n[i]*pow(pi,d[3].I[i])*d[3].J[i]*pow((to-0.5),(d[3].J[i]-1));}

 return total;

}

public double gamma2_r_to_to(double P,double T)

{double pi=P/d[3].Pstar;

 double to=d[3].Tstar/T;

 int n1=d[3].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[3].n[i]*pow(pi,d[3].I[i])*d[3].J[i]*(d[3].J[i]-1)*pow((to-0.5),(d[3].J[i]-2));}

 return total;

}

public double gamma2_r_pi_to(double P,double T)

{double pi=P/d[3].Pstar;

 double to=d[3].Tstar/T;

 int n1=d[3].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[3].n[i]*d[3].I[i]*pow(pi,(d[3].I[i]-1))*d[3].J[i]*pow((to-0.5),(d[3].J[i]-1));}

 return total;

}

public double gamma2(double P,double T)

{ double g2=gamma2_0(P,T)+gamma2_r(P,T);

 return g2;

}

public double T2a_Ph(double P,double h)

{double pi=P/d[18].Pstar;

 double hstar=d[18].rostar;

 double eta=h/hstar;

 int n1=d[18].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow(pi,d[18].I[i]);

     x2=pow((eta-2.1),d[18].J[i]);

                 total+=d[18].n[i]*x1*x2;

 }

 return total*d[18].Tstar;

}

public double T2b_Ph(double P,double h)

{double pi=P/d[19].Pstar;

 double hstar=d[19].rostar;

 double eta=h/hstar;

 int n1=d[19].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi-2.0),d[19].I[i]);

     x2=pow((eta-2.6),d[19].J[i]);

                 total+=d[19].n[i]*x1*x2;

 }

 return total*d[19].Tstar;

}

public double T2c_Ph(double P,double h)

{double pi=P/d[20].Pstar;

 double hstar=d[20].rostar;

 double eta=h/hstar;

 int n1=d[20].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+25),d[20].I[i]);

     x2=pow((eta-1.8),d[20].J[i]);

                 total+=d[20].n[i]*x1*x2;

 }

 return total*d[20].Tstar;

}

public double T2a_Ps(double P,double s)

{ double I[]={-1.5,-1.5,-1.5,-1.5,-1.5,-1.5,-1.25,-1.25,-1.25,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-0.75,-0.75,-0.5,-0.5,-0.5,-0.5,-0.25,-0.25,-0.25,-0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.75,0.75,0.75,1,1,1.25,1.25,1.5,1.5};

  int J[]={-24,-23,-19,-13,-11,-10,-19,-15,-6,-26,-21,-17,-16,-9,-8,-15,-14,-26,-13,-9,-7,-27,-25,-11,-6,1,4,8,11,0,1,5,6,10,14,16,0,4,9,17,7,18,3,15,5,18};

  double n[]={-3.9235983861984E+05,5.1526573827270E+05,4.0482443161048E+04,-3.2193790923902E+02,9.6961424218694E+01,-2.2867846371773E+01,-4.4942914124357E+05,-5.0118336020166E+03,3.5684463560015E-01,4.4235335848190E+04,-1.3673388811708E+04,4.2163260207864E+05,2.2516925837475E+04,4.7442144865646E+02,-1.4931130797647E+02,-1.9781126320452E+05,-2.3554399470760E+04,-1.9070616302076E+04,5.5375669883164E+04,3.8293691437363E+03,-6.0391860580567E+02,1.9363102620331E+03,4.2660643698610E+03,-5.9780638872718E+03,-7.0401463926862E+02,3.3836784107553E+02,2.0862786635187E+01,3.3834172656196E-02,-4.3124428414893E-05,1.6653791356412E+02,-1.3986292055898E+02,-7.8849547999872E-01,7.2132411753872E-02,-5.9754839398283E-03,-1.2141358953904E-05,2.3227096733871E-07,-1.0538463566194E+01,2.0718925496502E+00,-7.2193155260427E-02,2.0749887081120E-07,-1.8340657911379E-02,2.9036272348696E-07,2.1037527893619E-01,2.5681239729999E-04,-1.2799002933781E-02,-8.2198102652018E-06};

  double Tstar=1;   // K

  double sstar=2.0; // kJ/(kgK)

  double Pstar=1000.0;              //1 MPa=1000 kPa

  double pi=P/Pstar;

  double sigma=s/sstar;

  int n1=n.length;

  double total=0;

  double x1=0;

  double x2=0;

  for(int i=0;i<n1;i++)

  {   x1=Math.pow(pi,I[i]);

     x2=pow((sigma-2.0),J[i]);

                 total+=n[i]*x1*x2;

  }

  return total*Tstar;

}

public double T2b_Ps(double P,double s)

{ double sstar=d[26].rostar; // kJ/(kgK)

  double pi=P/d[26].Pstar;

  double sigma=s/sstar;

  int n1=d[26].n.length;

  double total=0;

  double x1=0;

  double x2=0;

  for(int i=0;i<n1;i++)

  {   x1=pow(pi,d[26].I[i]);

      x2=pow((10.0-sigma),d[26].J[i]);

                 total+=d[26].n[i]*x1*x2;

  }

  return total*d[26].Tstar;

}

public double T2c_Ps(double P,double s)

{ double sstar=d[27].rostar; // kJ/(kgK)

  double pi=P/d[27].Pstar;

  double sigma=s/sstar;

  int n1=d[27].n.length;

  double total=0;

  double x1=0;

  double x2=0;

  for(int i=0;i<n1;i++)

  {   x1=pow(pi,d[27].I[i]);

     x2=pow((2.0-sigma),d[27].J[i]);

                 total+=d[27].n[i]*x1*x2;

  }

  return total*d[27].Tstar;

}

 

public double g2(double P,double T)

{ double g2=gamma2(P,T)*R*T;

 return g2;

}

 

public double v2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   return pi*(gamma2_0_pi(P,T)+gamma2_r_pi(P,T))*R*T/P;

}

public double ro2(double P,double T)

{  return 1.0/v2(P,T);}

 

//root finding function

public double func_T2(double Ti,double P,double ro)

{  double vi=1.0/ro;

                double dro=ro2(P,Ti)-ro;

   return dro;

}

 

public double dfunc_T2(double Ti,double P,double ro)

{return -ro*ro*dv2_dT_P(P,Ti);}

//public static double brent(f_x f,double xl,double xu)

 

public double T2(double P,double ro)

{ // third order

double v=1.0/ro;

double x=0;

double Ts=0;

double vg=0;

x=st.t_pv(P/100.0,v)+273.15;;

int nmax=1000;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_T2(x,P,ro); 

   dfx=dfunc_T2(x,P,ro);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_T2(x1,P,ro);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_T2(x2,P,ro);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid P1="+x);return x;

}

 

public double func_v2(double Pi,double v0,double T)

{  double dro=v2(Pi,T)-v0;

   return dro;

}

 

public double dfunc_v2(double Pi,double T)

{return dv2_dP_T(Pi,T);}

 

 

public double P2(double ro,double T)

{ //third order

double v=1.0/ro;

double x=st.P((T-273.15),v)*100.0;

int nmax=1000;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_v2(x,v,T);

   dfx=dfunc_v2(x,T);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_v2(x1,T);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_v2(x2,T);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid P1="+x);return x;

}

public double h2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   return to*(gamma2_0_to(P,T)+gamma2_r_to(P,T))*R*T;

}

 

public double u2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g1=to*(gamma2_0_to(P,T)+gamma2_r_to(P,T));

   double g2=pi*(gamma2_0_pi(P,T)+gamma2_r_pi(P,T));

   return (g1-g2)*R*T;

}

 

public double s2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g1=to*(gamma2_0_to(P,T)+gamma2_r_to(P,T));

   double g2=(gamma2_0(P,T)+gamma2_r(P,T));

   return (g1-g2)*R;

}

 

public double Cp2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g1=-to*to*(gamma2_0_to_to(P,T)+gamma2_r_to_to(P,T));

   return g1*R;

}

 

public double Cv2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g1=-to*to*(gamma2_0_to_to(P,T)+gamma2_r_to_to(P,T));

   double gx=1+pi*gamma2_r_pi(P,T)-to*pi*gamma2_r_pi_to(P,T);

   double g2=gx*gx/(1-pi*pi*gamma2_r_pi_pi(P,T));

   return (g1-g2)*R;

}

public double sound2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g_r_pi=gamma2_r_pi(P,T);

   double g_r_pi_pi=gamma2_r_pi_pi(P,T);

   double g_r_pi_to=gamma2_r_pi_to(P,T);

   double g_r_to_to=gamma2_r_to_to(P,T);

   double g_0_to_to=gamma2_0_to_to(P,T);

   double g1=1.0+2.0*pi*g_r_pi+pi*pi*g_r_pi;

   double g2=1.0-pi*pi*g_r_pi_pi;

   double g3=1.0+pi*g_r_pi-to*pi*g_r_pi_to;

   double g4=to*to*(g_0_to_to+g_r_to_to);

   double gx=g1/(g2+g3*g3/g4);

   return Math.sqrt(gx*R*1e3*T);

}

//Isobaric cubic expansion coefficient

public double alpha2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g1=1.0+pi*(gamma2_r_pi(P,T)-to*pi*gamma2_r_pi_to(P,T));

   double g2=1+pi*gamma2_r_pi(P,T);

   return (g1/g2)/T;

}

//Isothermal compressibility

public double kappa2(double P,double T)

{  double pi=P/d[3].Pstar;

   double to=d[3].Tstar/T;

   double g1=1.-pi*pi*gamma2_r_pi_pi(P,T);

   double g2=1+pi*gamma2_r_pi(P,T);

   return (g1/g2)/P;

}

public double dv2_dP_T(double P,double T)

{return -v2(P,T)*kappa2(P,T);}

 

public double dv2_dT_P(double P,double T)

{return v2(P,T)*alpha2(P,T);}

 

public double dh2_dT_v(double P,double T)

{return Cv2(P,T)+P*v2(P,T)*alpha2(P,T);}

 

// Region 2 Metastable

public double gamma2_OMS(double P,double T)

{double pi=P/d[4].Pstar;

 double to=d[4].Tstar/T;

 int n1=d[4].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[4].n[i]*pow(to,d[4].J[i]);}

 return Math.log(pi)+total;

}

public double gamma2_OMS_pi(double P,double T)

{double pi=P/d[4].Pstar;

 double to=d[4].Tstar/T;

 return 1.0/pi;

}

public double gamma2_OMS_pi_pi(double P,double T)

{double pi=P/d[4].Pstar;

 double to=d[4].Tstar/T;

 return -1.0/(pi*pi);

}

public double gamma2_OMS_to(double P,double T)

{double pi=P/d[4].Pstar;

 double to=d[4].Tstar/T;

 int n1=d[4].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[4].n[i]*d[4].J[i]*pow(to,(d[4].J[i]-1));}

 return total;

}

public double gamma2_OMS_to_to(double P,double T)

{double pi=P/d[4].Pstar;

 double to=d[4].Tstar/T;

 int n1=d[4].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[4].n[i]*d[4].J[i]*(d[4].J[i]-1)*pow(to,(d[4].J[i]-2));}

 return total;

}

public double gamma2_OMS_pi_to(double P,double T)

{double pi=P/d[4].Pstar;

 double to=d[4].Tstar/T;

 int n1=d[4].n.length;

 double total=0;

 return total;

}

public double gamma2_rMS(double P,double T)

{double pi=P/d[5].Pstar;

 double to=d[5].Tstar/T;

 int n1=d[5].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[5].n[i]*pow(pi,d[5].I[i])*pow((to-0.5),d[5].J[i]);}

 return total;

}

public double gamma2_rMS_pi(double P,double T)

{double pi=P/d[5].Pstar;

 double to=d[5].Tstar/T;

 int n1=d[5].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[5].n[i]*d[5].I[i]*pow(pi,(d[5].I[i]-1))*pow((to-0.5),d[5].J[i]);}

 return total;

}

public double gamma2_rMS_pi_pi(double P,double T)

{double pi=P/d[5].Pstar;

 double to=d[5].Tstar/T;

 int n1=d[5].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[5].n[i]*d[5].I[i]*(d[5].I[i]-1)*pow(pi,(d[5].I[i]-2))*pow((to-0.5),d[5].J[i]);}

 return total;

}

public double gamma2_rMS_to(double P,double T)

{double pi=P/d[5].Pstar;

 double to=d[5].Tstar/T;

 int n1=d[5].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[5].n[i]*pow(pi,d[5].I[i])*d[5].J[i]*pow((to-0.5),(d[5].J[i]-1));}

 return total;

}

public double gamma2_rMS_to_to(double P,double T)

{double pi=P/d[5].Pstar;

 double to=d[5].Tstar/T;

 int n1=d[5].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[5].n[i]*pow(pi,d[5].I[i])*d[5].J[i]*(d[5].J[i]-1)*pow((to-0.5),(d[5].J[i]-2));}

 return total;

}

public double gamma2_rMS_pi_to(double P,double T)

{double pi=P/d[5].Pstar;

 double to=d[5].Tstar/T;

 int n1=d[5].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[5].n[i]*d[5].I[i]*pow(pi,(d[5].I[i]-1))*d[5].J[i]*pow((to-0.5),(d[5].J[i]-1));}

 return total;

}

public double gamma2MS(double P,double T)

{ double g2=gamma2_OMS(P,T)+gamma2_rMS(P,T);

 return g2;

}

public double g2MS(double P,double T)

{ double g2=gamma2MS(P,T)*R*T;

 return g2;

}

 

public double v2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   return pi*(gamma2_OMS_pi(P,T)+gamma2_rMS_pi(P,T))*R*T/P;

}

 

public double h2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   return to*(gamma2_OMS_to(P,T)+gamma2_rMS_to(P,T))*R*T;

}

 

public double u2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   double g1=to*(gamma2_OMS_to(P,T)+gamma2_rMS_to(P,T));

   double g2=pi*(gamma2_OMS_pi(P,T)+gamma2_rMS_pi(P,T));

   return (g1-g2)*R*T;

}

 

public double s2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   double g1=to*(gamma2_OMS_to(P,T)+gamma2_rMS_to(P,T));

   double g2=(gamma2_OMS(P,T)+gamma2_rMS(P,T));

   return (g1-g2)*R;

}

 

public double Cp2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   double g1=-to*to*(gamma2_OMS_to_to(P,T)+gamma2_rMS_to_to(P,T));

   return g1*R;

}

 

public double Cv2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   double g1=-to*to*(gamma2_OMS_to_to(P,T)+gamma2_rMS_to_to(P,T));

   double gx=1+pi*gamma2_rMS_pi(P,T)-to*pi*gamma2_rMS_pi_to(P,T);

   double g2=gx*gx/(1-pi*pi*gamma2_rMS_pi_pi(P,T));

   return (g1-g2)*R;

}

 

//Isobaric cubic expansion coefficient

public double alpha2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   double g1=1.0+pi*(gamma2_rMS_pi(P,T)-to*pi*gamma2_rMS_pi_to(P,T));

   double g2=1+pi*gamma2_rMS_pi(P,T);

   return (g1/g2)/T;

}

 

//Isothermal compressibility

public double kappa2MS(double P,double T)

{  double pi=P/d[5].Pstar;

   double to=d[5].Tstar/T;

   double g1=1.-pi*pi*gamma2_rMS_pi_pi(P,T);

   double g2=1+pi*gamma2_rMS_pi(P,T);

   return (g1/g2)/P;

}

public double dv2MS_dp_T(double P,double T)

{return -v2MS(P,T)*kappa2MS(P,T);}

public double dv2MS_dT_TP(double P,double T)

{return v2MS(P,T)*alpha2MS(P,T);}       

 

//REGION 3

public double fi3(double ro,double T)

{double delta=ro/d[6].rostar;

 double to=d[6].Tstar/T;

 int n1=d[6].n.length;

 double total=d[6].n[0]*Math.log(delta);

 for(int i=1;i<n1;i++)

 {total+=d[6].n[i]*pow(delta,d[6].I[i])*pow(to,d[6].J[i]);}

 return total;

}

public double fi3_delta(double ro,double T)

{double delta=ro/d[6].rostar;

 double to=d[6].Tstar/T;

 int n1=d[6].n.length;

 double total=d[6].n[0]/delta;

 for(int i=1;i<n1;i++)

 {total+=d[6].n[i]*d[6].I[i]*pow(delta,(d[6].I[i]-1))*pow(to,d[6].J[i]);}

 return total;

}

public double fi3_delta_delta(double ro,double T)

{double delta=ro/d[6].rostar;

 double to=d[6].Tstar/T;

 int n1=d[6].n.length;

 double total=-d[6].n[0]/(delta*delta);

 for(int i=1;i<n1;i++)

 {total+=d[6].n[i]*d[6].I[i]*(d[6].I[i]-1)*pow(delta,(d[6].I[i]-2))*pow(to,d[6].J[i]);}

 return total;

}

public double fi3_to(double ro,double T)

{double delta=ro/d[6].rostar;

 double to=d[6].Tstar/T;

 int n1=d[6].n.length;

 double total=0;

 for(int i=1;i<n1;i++)

 {total+=d[6].n[i]*pow(delta,d[6].I[i])*d[6].J[i]*pow(to,(d[6].J[i]-1));}

 return total;

}

public double fi3_to_to(double ro,double T)

{double delta=ro/d[6].rostar;

 double to=d[6].Tstar/T;

 int n1=d[6].n.length;

 double total=0;

 for(int i=1;i<n1;i++)

 {total+=d[6].n[i]*pow(delta,d[6].I[i])*d[6].J[i]*(d[6].J[i]-1)*pow(to,(d[6].J[i]-2));}

 return total;

}

public double fi3_delta_to(double ro,double T)

{double delta=ro/d[6].rostar;

 double to=d[6].Tstar/T;

 int n1=d[6].n.length;

 double total=0;

 for(int i=1;i<n1;i++)

 {total+=d[6].n[i]*d[6].I[i]*pow(delta,(d[6].I[i]-1))*d[6].J[i]*pow(to,(d[6].J[i]-1));}

 return total;

}

public double v3a_Ph(double P,double h)

{double pi=P/d[21].Pstar;

 double hstar=d[21].Tstar;

 double vstar=d[21].rostar;

 double eta=h/hstar;

 int n1=d[21].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.128),d[21].I[i]);

     x2=pow((eta-0.727),d[21].J[i]);

                 total+=d[21].n[i]*x1*x2;

 }

 return total*vstar;

}

public double v3b_Ph(double P,double h)

{double pi=P/d[22].Pstar;

 double hstar=d[22].Tstar;

 double vstar=d[22].rostar;

 double eta=h/hstar;

 int n1=d[22].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.0661),d[22].I[i]);

     x2=pow((eta-0.720),d[22].J[i]);

                 total+=d[22].n[i]*x1*x2;

 }

 return total*vstar;

}

public double T3a_Ph(double P,double h)

{double pi=P/d[23].Pstar;

 double hstar=d[23].rostar;

 double eta=h/hstar;

 int n1=d[23].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.24),d[23].I[i]);

     x2=pow((eta-0.615),d[23].J[i]);

                 total+=d[23].n[i]*x1*x2;

 }

 return total*d[23].Tstar;

}

public double T3b_Ph(double P,double h)

{double pi=P/d[24].Pstar;

 double hstar=d[24].rostar;

 double eta=h/hstar;

 int n1=d[24].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.298),d[24].I[i]);

     x2=pow((eta-0.720),d[24].J[i]);

                 total+=d[24].n[i]*x1*x2;

 }

 return total*d[24].Tstar;

}

//Ps group

public double v3a_Ps(double P,double s)

{double pi=P/d[28].Pstar;

 double sstar=d[28].Tstar;

 double vstar=d[28].rostar;

 double sigma=s/sstar;

 int n1=d[28].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.187),d[28].I[i]);

     x2=pow((sigma-0.755),d[28].J[i]);

                 total+=d[28].n[i]*x1*x2;

 }

 return total*vstar;

}

public double v3b_Ps(double P,double s)

{double pi=P/d[29].Pstar;

 double sstar=d[29].Tstar;

 double vstar=d[29].rostar;

 double sigma=s/sstar;

 int n1=d[29].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.298),d[29].I[i]);

     x2=pow((sigma-0.816),d[29].J[i]);

                 total+=d[29].n[i]*x1*x2;

 }

 return total*vstar;

}

public double T3a_Ps(double P,double s)

{double pi=P/d[30].Pstar;

 double sstar=d[30].rostar;

 double sigma=s/sstar;

 int n1=d[30].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.24),d[30].I[i]);

     x2=pow((sigma-0.703),d[30].J[i]);

                 total+=d[30].n[i]*x1*x2;

 }

 return total*d[30].Tstar;

}

public double T3b_Ps(double P,double s)

{double pi=P/d[31].Pstar;

 double sstar=d[31].rostar;

 double sigma=s/sstar;

 int n1=d[31].n.length;

 double total=0;

 double x1=0;

 double x2=0;

 for(int i=0;i<n1;i++)

 {   x1=pow((pi+0.760),d[31].I[i]);

     x2=pow((sigma-0.818),d[31].J[i]);

                 total+=d[31].n[i]*x1*x2;

 }

 return total*d[31].Tstar;

}

 

 

public double P3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double fi_d=fi3_delta(ro,T);

   return delta*fi_d*ro*R*T;

}

 

//temperature root finding function

public double func_T3(double Ti,double P,double ro)

{  double vi=1.0/ro;

                double dp=P3(ro,Ti)-P;

   return dp;

}

/* Numeric derivative

public double dfunc_T3(double Ti,double P,double ro)

{  double dx=0.1;

   double f_p2dx=func_T3((Ti+2.0*dx),P,ro);

   double f_pdx=func_T3((Ti+dx),P,ro);

   double f_mdx=func_T3((Ti-dx),P,ro);

   double f_m2dx=func_T3((Ti-2.0*dx),P,ro);

   double dro=(-f_p2dx+8.0*f_pdx-8.0*f_mdx+f_m2dx)/(12*dx);

   return dro;

}

*/

 

public double dfunc_T3(double Ti,double P,double ro)

{return dP3_dT_v(ro,Ti);}

 

public double T3(double P,double ro)

{ // third order

double v=1.0/ro;

double x=723.0;

int nmax=1000;

double alpha=0.516253;

double beta=1-alpha;

double tolerance=1.0e-8;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_T3(x,P,ro); 

   dfx=dfunc_T3(x,P,ro);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_T3(x1,P,ro);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_T3(x2,P,ro);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid P1="+x);return x;

}

//specific volume root finding function

public double func_ro3(double roi,double P,double T)

{              double dp=P3(roi,T)-P;

    return dp;

}

// Numeric derivative

public double dfunc_ro3N(double roi,double P,double T)

{  double dx=0.015;

   double f_p2dx=func_ro3((roi+2.0*dx),P,T);

   double f_pdx=func_ro3((roi+dx),P,T);

   double f_mdx=func_ro3((roi-dx),P,T);

   double f_m2dx=func_ro3((roi-2.0*dx),P,T);

   double dro=(-f_p2dx+8.0*f_pdx-8.0*f_mdx+f_m2dx)/(12*dx);

   return dro;

}

 

 

public double dfunc_ro3(double roi,double P,double T)

{return -1/(roi*roi)*dP3_dv_T(roi,T);}

 

public double v3(double P,double T)

{ // third order

double x=v3I(P,T);

int nmax=1000;

double alpha=0.51234;

double beta=1-alpha;

double tolerance=1.0e-10;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_ro3(x,P,T); 

   dfx=dfunc_ro3(x,P,T);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_ro3(x1,P,T);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_ro3(x2,P,T);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return 1.0/x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid P1="+x);return 1.0/x;

}

 

public double h3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   return (to*fi3_to(ro,T)+delta*fi3_delta(ro,T))*R*T;

}

 

public double u3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   return (to*fi3_to(ro,T))*R*T;

}

 

public double s3(double ro,double T)

{double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   return (to*fi3_to(ro,T)-fi3(ro,T))*R;

}

 

public double Cp3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g1=delta*fi3_delta(ro,T)-delta*to*fi3_delta_to(ro,T);

   double g2=2.0*delta*fi3_delta(ro,T)+delta*delta*fi3_delta_delta(ro,T);

   double g3=-to*to*fi3_to_to(ro,T)+g1*g1/g2;

   return g3*R;

}

public double alpha3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g1=fi3_delta(ro,T)-to*fi3_delta_to(ro,T);

   double g2=2.0*fi3_delta(ro,T)+delta*fi3_delta_delta(ro,T);

   return g1/g2/T;

}

public double kappa3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g2=2.0*delta*fi3_delta(ro,T)+delta*delta*fi3_delta_delta(ro,T);

   return 1.0/g2/(ro*R*T);

}

public double Cv3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g3=-to*to*fi3_to_to(ro,T);

   return g3*R;

}

public double sound3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double fi_d=fi3_delta(ro,T);

   double fi_d_d=fi3_delta_delta(ro,T);

   double fi_d_to=fi3_delta_to(ro,T);

    double fi_to_to=fi3_to_to(ro,T);

   double g1=2.0*delta*fi_d;

   double g2=delta*delta*fi_d_d;

   double g3=delta*fi_d-delta*to*fi_d_to;

   double g4=to*to*fi_to_to;

   double gx=g1+g2-g3*g3/g4;

   double s=Math.sqrt(gx*R*1e3*T);

   return Math.sqrt(Math.abs(gx)*R*1e3*T);

}

 

//Isobaric cubic expansion coefficient

public double alphav3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g1=fi3_delta(ro,T)-to*fi3_delta_to(ro,T);

   double g2=2.0*fi3_delta(ro,T)+delta*fi3_delta_delta(ro,T);

   double g3=g1/g2;

   return g3/T;

}

 

//Isothermal compressibility

public double kappaT3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g1=2.0*delta*fi3_delta(ro,T)+delta*delta*fi3_delta_delta(ro,T);

   double g3=1.0/g1;

   return g3/(ro*R*T);

}

//relative pressure coefficient

public double alphap3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g1=1.0-to*fi3_delta_to(ro,T)/fi3_delta(ro,T);

   return g1/T;

}

//Isothermal stress coefficient

public double betap3(double ro,double T)

{  double delta=ro/d[6].rostar;

   double to=d[6].Tstar/T;

   double g1=2.0+delta*fi3_delta_delta(ro,T)/fi3_delta(ro,T);

   return g1*ro;

}

 

public double dP3_dv_T(double ro,double T)

{ return -P3(ro,T)*betap3(ro,T);}

 

public double dP3_dT_v(double ro,double T)

{ return P3(ro,T)*alphap3(ro,T);}

 

//Inverse function of Region 3

public double v3I(double P,double T)

{  return svtp.v3(P,T);}

 

public double ro3(double P,double T)

{  return 1.0/svtp.v3(P,T);}

 

double func_Ps3_h(double h,double Ps)

{return Ps3_h(h)-Ps;}

 

public double Ps3_h(double h)

{double hstar=d[15].rostar;

 double eta=h/hstar;

 int n1=d[15].n.length;

 double total=0;

 double x=0;

 for(int i=0;i<n1;i++)

 {x=d[15].n[i]*pow((eta-1.02),d[15].I[i])*pow((eta-0.608),d[15].J[i]);

  total+=x;

 }

 return total*d[15].Pstar;

}

//analytical derivative

public double dPs3_h(double h)

{double hstar=d[15].rostar;

 double eta=h/hstar;

 int n1=d[15].n.length;

 double total=0;

 double x1,x2;

 for(int i=0;i<n1;i++)

 {x1=d[15].n[i]*d[15].I[i]*pow((eta-1.02),(d[15].I[i]-1))*pow((eta-0.608),d[15].J[i]);

  x2=d[15].n[i]*pow((eta-1.02),d[15].I[i])*d[15].J[i]*pow((eta-0.608),(d[15].J[i]-1));

  total+=(x1+x2)/hstar;

 }

 return total*d[15].Pstar;

}

//Numerical derivative

public double dfunc_Ps3_h(double h)

{  double dx=0.1;

   double f_p2dx=Ps3_h((h+2.0*dx));

   double f_pdx=Ps3_h((h+dx));

   double f_mdx=Ps3_h((h-dx));

   double f_m2dx=Ps3_h((h-2.0*dx));

   double dro=(-f_p2dx+8.0*f_pdx-8.0*f_mdx+f_m2dx)/(12*dx);

   return dro;

}

 

 

//saturation liquid entalphy at region 3

public double hf3(double T)

{   double x1=1670.8582182746015;//enthalpy at 623.15 K(350 C) 16.529 MPa

    double x2=2087.55; //critical enthaphy

    return h_f_g3(T,x1,x2);

}

//saturation vapor entalphy at region 3

public double hg3(double T)

{   double x1=2087.55; //critical enthaphy

    double x2=2563.592003888462; //enthalpy at 623.15 K(350 C) 16.529 MPa

    return h_f_g3(T,x1,x2);

}

public double h_f_g3(double T,double x1,double x2)

{  //Brent method to find roots (enthalpy) between given limits

double Ps=Ps(T);

double test;

double p=0;

double es,ea;

double f1,f2,f3,fp;

int maxit=500,iter=0;

double tol=1.0e-15;

es=0.00000001;

f1=func_Ps3_h(x1,Ps);

f2=func_Ps3_h(x2,Ps);

double x3=(x1+x2)/2.0;f3=func_Ps3_h(x3,Ps);

if(f1==0) return x1;

else if(f2==0) return x2;

else if(f3==0) return x3;

p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

fp=func_Ps3_h(p,Ps);

ea=Math.abs(x3-p);

while((ea>es)&&(iter<maxit))

{              if(Math.abs(f3)<tol) return x3;

    if((p<x1) && (p>x2))

    {p=(x1+x2)/2.0;   

     if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

     else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    }

    else

    {       

    if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

    else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

    fp=func_Ps3_h(p,Ps);

    ea=Math.abs(x3-p);

    }

    iter++;

}

if(iter>=maxit) System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid");return p;

}

 

//saturation pressure as a function of entropy

double func_Ps3_s(double s,double Ps)

{return Ps3_s(s)-Ps;}

 

public double Ps3_s(double s)

{double sstar=d[16].rostar;

 double sigma=s/sstar;

 int n1=d[16].n.length;

 double total=0;

 double x=0;

 for(int i=0;i<n1;i++)

 {x=d[16].n[i]*pow((sigma-1.03),d[16].I[i])*pow((sigma-0.699),d[16].J[i]);

  total+=x;

 }

 return total*d[15].Pstar;

}

//analytical derivative

public double dPs3_s(double s)

{double sstar=d[16].rostar;

 double sigma=s/sstar;

 int n1=d[16].n.length;

 double total=0;

 double x1,x2;

 for(int i=0;i<n1;i++)

 {x1=d[16].n[i]*d[16].I[i]*pow((sigma-1.03),(d[15].I[i]-1))*pow((sigma-0.699),d[15].J[i]);

  x2=d[15].n[i]*pow((sigma-1.03),d[15].I[i])*d[15].J[i]*pow((sigma-0.699),(d[15].J[i]-1));

  total+=(x1+x2)/sstar;

 }

 return total*d[15].Pstar;

}

//Numerical derivative

public double dfunc_Ps3_s(double s)

{  double dx=0.1;

   double f_p2dx=Ps3_s((s+2.0*dx));

   double f_pdx=Ps3_s((s+dx));

   double f_mdx=Ps3_s((s-dx));

   double f_m2dx=Ps3_s((s-2.0*dx));

   double dro=(-f_p2dx+8.0*f_pdx-8.0*f_mdx+f_m2dx)/(12*dx);

   return dro;

}

//saturation liquid entropy at region 3

public double sf3(double T)

{   double x1= 3.778281340 ;//entropy at 623.15 K(350 C) 16.529 MPa

    double x2=4.4120; //critical entropy

    return s_f_g3(T,x1,x2);

}

//saturation vapor entropy at region 3

public double sg3(double T)

{   double x1=4.4120; //critical enthaphy

    double x2=5.210887825 ; //enthalpy at 623.15 K(350 C) 16.529 MPa

    return s_f_g3(T,x1,x2);

}

 

public double s_f_g3(double T,double x1,double x2)

{  //Brent method to find roots (enthalpy) between given limits

double Ps=Ps(T);

double test;

double p=0;

double es,ea;

double f1,f2,f3,fp;

int maxit=500,iter=0;

double tol=1.0e-15;

es=0.00000001;

f1=func_Ps3_s(x1,Ps);

f2=func_Ps3_s(x2,Ps);

double x3=(x1+x2)/2.0;f3=func_Ps3_s(x3,Ps);

if(f1==0) return x1;

else if(f2==0) return x2;

else if(f3==0) return x3;

p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

fp=func_Ps3_s(p,Ps);

ea=Math.abs(x3-p);

while((ea>es)&&(iter<maxit))

{              if(Math.abs(f3)<tol) return x3;

    if((p<x1) && (p>x2))

    {p=(x1+x2)/2.0;   

     if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

     else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    }

    else

    {       

    if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

    else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

    fp=func_Ps3_s(p,Ps);

    ea=Math.abs(x3-p);

    }

    iter++;

}

if(iter>=maxit) System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid" );

return p;

}

//saturation pressure as a function of specific volume

 

double func_Ps3_ro(double ro,double Ps)

{   double T=Ts(Ps);

                double x= Ps-P3(ro,T);

                double v=1.0/ro;

                return x;

}

public double ro_f_g3(double Ps,double xl,double xu)

{

//bisection root finding method

double test;

double xr=0;

double es,ea;

double fxl,fxr,fxu;

double xold=0;

int maxit=100,iter=0;

es=0.0000001;

ea=1.1*es;

String s="";

fxl= func_Ps3_ro(xl,Ps);

fxu= func_Ps3_ro(xu,Ps);

while((ea>es)&&(iter<maxit))

{   xold=xr;

    xr=(xl+xu)/2.0;

    fxr= func_Ps3_ro(xr,Ps);;

    iter++;

    if(xr!=0)

        { ea=Math.abs((xr-xold)/xr)*100;}

    test= fxl*fxr;

    if(test==0.0)      ea=0;

    else if(test<0.0) {xu=xr;fxu=fxr;}

    else if(test>0)   {xl=xr;fxl=fxr;}

    else              {ea=0;}

}

if(iter>=maxit) System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid" );

   return xr;

}

 

//saturation liquid specific volume at region 3

public double rof3(double T)

{   double x1= 322 ;

    double Ps=Ps(T);

    double x2=574.689524;

    return ro_f_g3(Ps,x1,x2);

}

 

//saturation vapor entropy at region 3

public double rog3(double T)

{   double x1=113.6247429; //critical enthaphy

    double x2=322; //enthalpy at 623.15 K(350 C) 16.529 MPa

    double Ps=Ps(T);

    return ro_f_g3(Ps,x1,x2);

}

//REGION 4

//Saturation pressure

public double P4(double Ts)

{  return Ps(Ts);}

 

public double Ps(double Ts)

{  double tp=Ts/d[7].Tstar;

   double tetha=tp+d[7].n[8]/(tp-d[7].n[9]);

   double A=tetha*tetha+d[7].n[0]*tetha+d[7].n[1];

   double B=d[7].n[2]*tetha*tetha+d[7].n[3]*tetha+d[7].n[4];

   double C=d[7].n[5]*tetha*tetha+d[7].n[6]*tetha+d[7].n[7];

   double Y=B*B-4.0*A*C;

   double X=-B+Math.sqrt(Y);

   double D=2.0*C/X;

   double E=D*D*D*D*d[7].Pstar;

   return E;

}

 

//Saturation temperature

public double T4(double Ps)

{  return Ts(Ps);}

 

public double Ts(double Ps)

{  double pi=Ps/d[7].Pstar;

   double beta=Math.pow(pi,0.25);

   int n1=d[7].n.length;

   double E=beta*beta+d[7].n[2]*beta+d[7].n[5];

   double F=d[7].n[0]*beta*beta+d[7].n[3]*beta+d[7].n[6];

   double G=d[7].n[1]*beta*beta+d[7].n[4]*beta+d[7].n[7];

   double D=2.0*G/(-F-Math.sqrt(F*F-4.0*E*G));

   double x1=d[7].n[9]+D;

   double x2=(d[7].n[8]+d[7].n[9]*D);

   double x3=x1*x1-4.0*x2;

   double x4=Math.sqrt(x3);

   double x5=x1-x4;

   double x6=x5/2.0;

   return x6*d[7].Tstar;

   }  

//Saturation region liquid enthalpy region1 and 3 (x=0)

public double hf_T(double T)

{

if(T<=623.15)

{double Ps=Ps(T);

 double h1=h1(Ps,T);

 return h1;

}

else if(T>623.15 && T<=647.096)

{  return hf3(T);}

else

{return 2087.55;}

}

 

public double uf_T(double T)

{ return hf_T(T)-Ps(T)*vf_T(T);}

 

//Saturation region vapor enthalpy region1 and 3  (x=1)

public double hg_T(double T)

{

if(T<=623.15)

{double Ps=Ps(T);

 double h2=h2(Ps,T);

 return h2;

}

else if(T>623.15 && T<=647.096)

{  return hg3(T);}

else

{return 2087.55;}

}

public double ug_T(double T)

{ return hg_T(T)-Ps(T)*vg_T(T);}

 

//Saturation region liquid enthalpy region1 and 3 (x=0)

public double hf_P(double P)

{

double T=Ts(P);

if(T<=623.15)

{double Ps=P;

 double h1=h1(Ps,T);

 return h1;

}

else if(T>623.15 && T<=647.096)

{  return hf3(T);}

else

{return 2087.55;}

}

public double uf_P(double P)

{ return hf_P(P)-P*vf_P(P);}

//Saturation region vapor enthalpy region1 and 3  (x=1)

public double hg_P(double P)

{ double T=Ts(P);

if(T<=623.15)

{ double h2=h2(P,T);

  return h2;

}

else if(T>623.15 && T<=647.096)

{  return hg3(T);}

else

{return 2087.55;}

}

public double ug_P(double P)

{ return hg_P(P)-P*vg_P(P);}

 

//Saturation region liquid entropy region1 and 3 (x=0)

public double sf_T(double T)

{

if(T<=623.15)

{double Ps=Ps(T);

 double s1=s1(Ps,T);

 return s1;

}

else if(T>623.15 && T<=647.096)

{  return sf3(T);}

else

{return 4.4120;}

}

//Saturation region vapor entropy region1 and 3  (x=1)

public double sg_T(double T)

{

if(T<=623.15)

{double Ps=Ps(T);

 double s2=s2(Ps,T);

 return s2;

} else if(T>623.15 && T<=647.096)

{  return sg3(T);}

else {return 4.4120;}

}

 

public double sf_P(double P)

{ double T=Ts(P);

if(T<=623.15)

{double s1=s1(P,T); return s1;}

else if(T>623.15 && T<=647.096)

{  return sf3(T);}

else {return 4.4120;}

}

//Saturation region vapor entropy region1 and 3  (x=1)

public double sg_P(double P)

{double T=Ts(P);

if(T<=623.15)

{double s2=s2(P,T);return s2;}

else if(T>623.15 && T<=647.096) {  return sg3(T);}

else {return 4.4120;}

}

//Saturation region liquid specific volume region1 and 3 (x=0)

public double rof_T(double T) {return 1.0/vf_T(T);}

public double vf_T(double T)

{

if(T<=623.15)

{double Ps=Ps(T);

 double v1=v1(Ps,T);

 return v1;

}

else if(T>623.15 && T<=647.096)

{  return 1.0/rof3(T);}

else

{return 0.00310559;}

}

//Saturation region vapor entropy region1 and 3  (x=1)

public double rog_T(double T) {return 1.0/vg_T(T);}

 

public double vg_T(double T)

{

if(T<=623.15)

{double Ps=Ps(T);

 double v2=v2(Ps,T);

 return v2;

}

else if(T>623.15 && T<=647.096)

{  return 1.0/rog3(T);}

else

{return 0.00310559;}

}

public double rof_P(double P) {return 1.0/vf_P(P);}

public double vf_P(double P)

{ double T=Ts(P);

if(T<=623.15)

{double v1=v1(P,T);return v1;}

else if(T>623.15 && T<=647.096) {  return 1.0/rof3(T);}

else {return 0.00310559;}

}

//Saturation region vapor entropy region1 and 3  (x=1)

public double rog_P(double P) {return 1.0/vg_P(P);}

public double vg_P(double P)

{double T=Ts(P);

if(T<=623.15)

{double v2=v2(P,T);return v2;}

else if(T>623.15 && T<=647.096) {  return 1.0/rog3(T);}

else {return 0.00310559;}

}

 

public double Cpf_T(double T)

{              double P=Ps(T);

    double Cp=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) Cp=Cp1(P,T);

    else {ro=rof3(T);Cp=Cp3(ro,T);}       

    return Cp;

}

public double soundf_T(double T)

{              double P=Ps(T);

    double sound=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) sound=sound1(P,T);

    else {ro=rof3(T);sound=sound3(ro,T);}      

    return sound;

}

public double kappaf_T(double T)

{              double P=Ps(T);

    double kappa=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) kappa=kappa1(P,T);

    else {ro=rof3(T);kappa=kappa3(ro,T);}      

    return kappa;

}

public double alphaf_T(double T)

{              double P=Ps(T);

    double alpha=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) alpha=alpha1(P,T);

    else {ro=rof3(T);alpha=alpha3(ro,T);}      

    return alpha;

}

public double Cpg_T(double T)

{              double P=Ps(T);

    double Cp=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) Cp=Cp2(P,T);

    else {ro=rog3(T);Cp=Cp3(ro,T);}      

    return Cp;

}

public double soundg_T(double T)

{              double P=Ps(T);

    double sound=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) sound=sound2(P,T);

    else {ro=rog3(T);sound=sound3(ro,T);}      

    return sound;

}

public double kappag_T(double T)

{              double P=Ps(T);

    double kappa=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) kappa=kappa2(P,T);

    else {ro=rog3(T);kappa=kappa3(ro,T);}      

    return kappa;

}

public double alphag_T(double T)

{              double P=Ps(T);

    double alpha=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) alpha=alpha2(P,T);

    else {ro=rog3(T);alpha=alpha3(ro,T);}      

    return alpha;

}

public double alpha_Tx(double T,double x)

{double alphag=alphag_T(T);

 double alphaf=alphaf_T(T);

 return alphaf*(1.0-x)+alphag*x;

}

public double kappa_Tx(double T,double x)

{double kappag=kappag_T(T);

 double kappaf=kappaf_T(T);

 return kappaf*(1.0-x)+kappag*x;

}

public double Cpf_P(double P)

{ double T=Ts(P);return Cpf_T(T);}

 

public double Cpg_P(double P)

{ double T=Ts(P);return Cpg_T(T);}

public double soundf_P(double P)

{ double T=Ts(P);return soundf_T(T);}

 

public double soundg_P(double P)

{ double T=Ts(P);return soundg_T(T);}

public double Cvf_T(double T)

{              double P=Ps(T);

    double Cv=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) Cv=Cv1(P,T);

    else {ro=rof3(T);Cv=Cv3(ro,T);}      

    return Cv;

}

public double Cvg_T(double T)

{              double P=Ps(T);

    double Cv=0;

    double ro=0.0;

    if(T>= 273.15 && T<=623.15) Cv=Cv2(P,T);

    else {ro=rog3(T);Cv=Cv3(ro,T);}      

    return Cv;

}

 

public double Cvf_P(double P)

{ double T=Ts(P);return Cvf_T(T);}

 

public double Cvg_P(double P)

{ double T=Ts(P);return Cvg_T(T);}

 

 

//REGION 5       8 and 9

public double gamma5_0(double P,double T)

{double pi=P/d[8].Pstar;

 double to=d[8].Tstar/T;

 int n1=d[8].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[8].n[i]*pow(to,d[8].J[i]);}

 return Math.log(pi)+total;

}

public double gamma5_0_pi(double P,double T)

{double pi=P/d[8].Pstar;

 double to=d[8].Tstar/T;

 return 1.0/pi;

}

public double gamma5_0_pi_pi(double P,double T)

{double pi=P/d[8].Pstar;

 double to=d[8].Tstar/T;

 return -1.0/(pi*pi);

}

public double gamma5_0_to(double P,double T)

{double pi=P/d[8].Pstar;

 double to=d[8].Tstar/T;

 int n1=d[8].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[8].n[i]*d[8].J[i]*pow(to,(d[8].J[i]-1));}

 return total;

}

public double gamma5_0_to_to(double P,double T)

{double pi=P/d[8].Pstar;

 double to=d[8].Tstar/T;

 int n1=d[8].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[8].n[i]*d[8].J[i]*(d[8].J[i]-1)*pow(to,(d[8].J[i]-2));}

 return total;

}

public double gamma5_0_pi_to(double P,double T)

{double pi=P/d[8].Pstar;

 double to=d[8].Tstar/T;

 int n1=d[8].n.length;

 double total=0;

 return total;

}

public double gamma5_r(double P,double T)

{double pi=P/d[9].Pstar;

 double to=d[9].Tstar/T;

 int n1=d[9].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[9].n[i]*pow(pi,d[9].I[i])*pow(to,d[9].J[i]);}

 return total;

}

public double gamma5_r_pi(double P,double T)

{double pi=P/d[9].Pstar;

 double to=d[9].Tstar/T;

 int n1=d[9].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[9].n[i]*d[9].I[i]*pow(pi,(d[9].I[i]-1))*pow(to,d[9].J[i]);}

 return total;

}

public double gamma5_r_pi_pi(double P,double T)

{double pi=P/d[9].Pstar;

 double to=d[9].Tstar/T;

 int n1=d[9].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[9].n[i]*d[9].I[i]*(d[9].I[i]-1)*pow(pi,(d[9].I[i]-2))*pow(to,d[9].J[i]);}

 return total;

}

public double gamma5_r_to(double P,double T)

{double pi=P/d[9].Pstar;

 double to=d[9].Tstar/T;

 int n1=d[9].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[9].n[i]*pow(pi,d[9].I[i])*d[9].J[i]*pow(to,(d[9].J[i]-1));}

 return total;

}

public double gamma5_r_to_to(double P,double T)

{double pi=P/d[9].Pstar;

 double to=d[9].Tstar/T;

 int n1=d[9].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[9].n[i]*pow(pi,d[9].I[i])*d[9].J[i]*(d[9].J[i]-1)*pow(to,(d[9].J[i]-2));}

 return total;

}

public double gamma5_r_pi_to(double P,double T)

{double pi=P/d[9].Pstar;

 double to=d[9].Tstar/T;

 int n1=d[9].n.length;

 double total=0;

 for(int i=0;i<n1;i++)

 {total+=d[9].n[i]*d[9].I[i]*pow(pi,(d[9].I[i]-1))*d[9].J[i]*pow(to,(d[9].J[i]-1));}

 return total;

}

public double gamma5(double P,double T)

{ double g5=gamma5_0(P,T)+gamma5_r(P,T);

 return g5;

}

public double g5(double P,double T)

{ double g5=gamma2(P,T)*R*T;

 return g5;

}

public double v5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   return pi*(gamma5_0_pi(P,T)+gamma5_r_pi(P,T))*R*T/P;

}

public double ro5(double P,double T)

{return 1.0/v5(P,T);}

//root finding function

public double func_T5(double Ti,double P,double ro)

{  double vi=1.0/ro;

                double dro=ro5(P,Ti)-ro;

   return dro;

}

//Numerical derivative

public double dfunc_T5N(double Ti,double P,double ro)

{  double dx=0.01;

   double f_p2dx=func_T5((Ti+2.0*dx),P,ro);

   double f_pdx=func_T5((Ti+dx),P,ro);

   double f_mdx=func_T5((Ti-dx),P,ro);

   double f_m2dx=func_T5((Ti-2.0*dx),P,ro);

   double dro=(-f_p2dx+8.0*f_pdx-8.0*f_mdx+f_m2dx)/(12*dx);

   return dro;

}

public double dfunc_T5(double Ti,double P,double ro)

{ return -ro*ro*dv5_dT_P(P,Ti);}

public double T5(double P,double ro)

{

double v=1.0/ro;

double x=st.t_pv(P/100.0,v);

int nmax=1000;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_T5(x,P,ro); 

   dfx=dfunc_T5(x,P,ro);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_T5(x1,P,ro);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_T5(x2,P,ro);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid" );;

return x;

}

public double func_v5(double Pi,double v0,double T)

{  double dro=v5(Pi,T)-v0;

   return dro;

}

public double dfunc_v5(double Pi,double T)

{return dv5_dP_T(Pi,T);}

public double P5(double ro,double T)

{ //third order

double v=1.0/ro;

double x=st.P((T-273.15),v)*100.0;

int nmax=500;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-15;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_v5(x,v,T);

   dfx=dfunc_v5(x,T);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_v5(x1,T);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_v5(x2,T);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid" );

return x;

}

public double func_h5(double Ti,double P,double h)

{  double dh=h5(P,Ti)-h;

   return dh;

}

public double dfunc_h5(double Ti,double P)

{return dh5_dT_v(P,Ti);}

 

public double T5_Ph(double P,double h)

{ //third order

double x=1100;

int nmax=500;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_h5(x,P,h);

   dfx=dfunc_h5(x,P);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_h5(x1,P);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_h5(x2,P);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T1 estimation is exceeded  Method\n"+

   " results may not be valid" );return x;

}

public double h5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   return to*(gamma5_0_to(P,T)+gamma5_r_to(P,T))*R*T;

}

 

public double u5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g1=to*(gamma5_0_to(P,T)+gamma5_r_to(P,T));

   double g2=pi*(gamma5_0_pi(P,T)+gamma5_r_pi(P,T));

   return (g1-g2)*R*T;

}

public double func_s5(double Ti,double P,double s)

{  double ds=s5(P,Ti)-s;

   return ds;

}

 

public double dfunc_s5(double Ti,double P)

{return ds5_dT_v(P,Ti);}

 

 

public double T5_Ps(double P,double s)

{ //third order

double x=1100;

int nmax=500;

double alpha=0.57652817;

double beta=1-alpha;

double tolerance=1.0e-12;

double fx,dfx;

double x1=0,dfx1=0;

double x2=0,dfx2=0;

for(int i=0;i<nmax;i++)

{  fx=func_s5(x,P,s);

   dfx=dfunc_s5(x,P);

   x1=x-alpha*fx/dfx;

   dfx1=dfunc_s5(x1,P);

   x2=x-beta*fx/dfx;

   dfx2=dfunc_s5(x2,P);

   x-=2.0*fx/(dfx1+dfx2);

  if(Math.abs(fx)<tolerance) { return x;}

}

System.out.println("Maximum number of iteration in T5_PS estimation is exceeded  Method\n"+

   " results may not be valid");

return x;

}

public double s5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g1=to*(gamma5_0_to(P,T)+gamma5_r_to(P,T));

   double g2=(gamma5_0(P,T)+gamma5_r(P,T));

   return (g1-g2)*R;

}

 

public double Cp5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g1=-to*to*(gamma5_0_to_to(P,T)+gamma5_r_to_to(P,T));

   return g1*R;

}

public double sound5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g_r_pi=gamma5_r_pi(P,T);

   double g_r_pi_pi=gamma5_r_pi_pi(P,T);

   double g_r_pi_to=gamma5_r_pi_to(P,T);

   double g_r_to_to=gamma5_r_to_to(P,T);

   double g_0_to_to=gamma5_0_to_to(P,T);

   double g1=1.0+2.0*pi*g_r_pi+pi*pi*g_r_pi*g_r_pi;

   double g2=1.0-pi*pi*g_r_pi_pi;

   double g3=1.0+pi*g_r_pi-to*pi*g_r_pi_to;

   double g4=to*to*(g_r_to_to+g_0_to_to);

   double gx=g1/(g2+g3*g3/g4);

   return Math.sqrt(gx*R*1e3*T);

}

public double Cv5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g1=-to*to*(gamma5_0_to_to(P,T)+gamma5_r_to_to(P,T));

   double gx=1+pi*gamma5_r_pi(P,T)-to*pi*gamma5_r_pi_to(P,T);

   double g2=gx*gx/(1-pi*pi*gamma5_r_pi_pi(P,T));

   return (g1-g2)*R;

}

 

//Isobaric cubic expansion coefficient

public double alpha5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g1=1.0+pi*(gamma5_r_pi(P,T)-to*pi*gamma5_r_pi_to(P,T));

   double g2=1+pi*gamma5_r_pi(P,T);

   return (g1/g2)/T;

}

 

//Isothermal compressibility

public double kappa5(double P,double T)

{  double pi=P/d[9].Pstar;

   double to=d[9].Tstar/T;

   double g1=1.-pi*pi*gamma5_r_pi_pi(P,T);

   double g2=1+pi*gamma5_r_pi(P,T);

   return (g1/g2)/P;

}

 

public double dv5_dP_T(double P,double T)

{return -v5(P,T)*kappa5(P,T);}

 

public double dv5_dT_P(double P,double T)

{return v5(P,T)*alpha5(P,T);}  

 

public double dh5_dT_v(double P,double T)

{return Cv5(P,T)+P*v5(P,T)*alpha5(P,T);}

 

public double ds5_dT_v(double P,double T)

{return Cv5(P,T)/T;}

 

// viscosity Pa.s

public double viscosity_PT(double P,double T)

{  //double a[]=property_PT(P,T);

   double ro=ro_PT(P,T);

   return viscosity_roT(ro,T);

}

public double viscosity_Tx(double T,double x)

{ double vf=vf_T(T);

  double vg=vg_T(T);

  double visf=viscosity_roT(1.0/vf,T);

  double visg=viscosity_roT(1.0/vg,T);

  double vis=(1.0-x)*visf+x*visg;

  return vis;

}

public double viscosity_Px(double P,double x)

{ double T=Ts(P);

  return viscosity_Tx(T,x);

 

}

public double viscosity_roT(double ro,double T)

{ double nustar=1e-6;

                double delta=ro/d[6].rostar;

   double teta=T/d[10].Tstar;

   int n1=d[10].n.length;

   double total=0;

   for(int i=0;i<n1;i++)

   {total+=d[10].n[i]*pow(teta,(1-d[10].I[i]));}

   total=1.0/total;

   total*=Math.sqrt(teta);

   int n2=d[11].n.length;

   double total1=0;

   for(int i=0;i<n2;i++)

   {total1+=d[11].n[i]*pow((delta-1),d[11].I[i])*pow((1.0/teta-1.0),d[11].J[i]);}

   total1*=delta;

   total1=Math.exp(total1);

   return (total*total1)*nustar;

}

//Thermal conductivity W/(mK)

public double k_PT(double P,double T)

{  double ro=ro_PT(P,T);

   return k_roT(ro,T);

}

public double k_Tx(double T,double x)

{ double vf=vf_T(T);

  double vg=vg_T(T);

  double kf=k_roT(1.0/vf,T);

  double kg=k_roT(1.0/vg,T);

  double k=(1.0-x)*kf+x*kg;

  return k;

}

public double k_Px(double P,double x)

{ double T=Ts(P);

  return k_Tx(T,x);

}

public double k_roT(double ro,double T)

{  double lambda_star=1;//W/(mK)

   double delta=ro/d[12].rostar;

   double teta=T/d[12].Tstar;

   int n1=d[12].n.length;

   double kappa0=Math.sqrt(teta)*(d[12].n[0]+d[12].n[1]*teta+d[12].n[2]*teta*teta+d[12].n[3]*teta*teta*teta);

   double x1=d[13].n[4]+delta;

   double x2=d[13].n[3]*x1*x1;

   double x3=Math.exp(x2);

   double x4=d[13].n[2]*x3;

   double x5=d[13].n[1]*delta;

   double x6=d[13].n[0];

   double x7=x6+x5+x4;

   double kappa1=x7;

  

   double dteta=Math.abs(teta-1.0)+d[14].n[9];

   double x3a=Math.pow(dteta,-0.6);

   double A=2.0+d[14].n[7]*x3a;

   double B=0;

   if(teta>=1) B=1.0/dteta;

   else        B=d[14].n[8]*x3a;

   double x4a=(d[14].n[0]/(teta*teta*teta*teta*teta*teta*teta*teta*teta*teta)+d[14].n[1]);

   double x5a=d[14].n[2]*(1.0-Math.pow(delta,2.8));

   double x6a=d[14].n[3]*A*Math.pow(delta,B);

   double x7a=(B/(1.0+B))*(1.0-Math.pow(delta,(1.0+B)));

   double x8a=d[14].n[4]*Math.exp(d[14].n[5]*Math.pow(teta,1.5)+d[14].n[6]/(delta*delta*delta*delta*delta));

   double kappa2=x4a*Math.pow(delta,1.8)*Math.exp(x5a)+x6a*Math.exp(x7a)+x8a;

   return (kappa0+kappa1+kappa2)*lambda_star;

}

 

//surface tension

public double sigma(double T)

{  double Tstar=647.096;

   double teta=T/Tstar;

   double sigma_star=1.0e-3;

   double s=235.8*Math.pow((1-teta),1.256)*(1.0-0.625*(1-teta));

   return s*sigma_star;

}

 

//Prandtl number

public double Pr_roT(double ro,double T)

{  double mu=viscosity_roT(ro,T);

   double k=k_roT(ro,T);

   double Cp=Cp_roT(ro,T)*1e3;

   return Cp*mu/k;

}

public double Cp_Tx(double T,double x)

{ double Cpf=Cpf_T(T);

  double Cpg=Cpg_T(T);

  double Cp=Cpf*(1.0-x)+Cpg*x;

  return Cp;

}

public double sound_Tx(double T,double x)

{ double soundf=soundf_T(T);

  double soundg=soundg_T(T);

  double sound=soundf*(1.0-x)+soundg*x;

  return sound;

}

public double Pr_Tx(double T,double x)

{ double vf=vf_T(T);

  double vg=vg_T(T);

  double rof=1.0/vf;

  double rog=1.0/vg;

  double Cpf=Cp_roT(rof,T);

  double Cpg=Cp_roT(rog,T);

  double Cp=Cpf*(1.0-x)+Cpg*x;

  Cp*=1e3;

  double visf=viscosity_roT(rof,T);

  double visg=viscosity_roT(rog,T);

  double kf=k_roT(rof,T);

  double kg=k_roT(rog,T);

  double vis=(1.0-x)*visf+x*visg;

  double k=(1.0-x)*kf+x*kg;

  return Cp*vis/k;

}

public double Pr_PT(double P,double T)

{  double mu=viscosity_PT(P,T);

   double k=k_PT(P,T);

   double Cp=Cp_PT(P,T);

   return Cp*mu/k*1e3;

}

 

public String[][] toString(String s, double v1, double v2)

{  String s1[][]=new String[17][4];

   s1[0][1]="P, pressure        ";

   s1[1][1]="T, temperature     ";

   s1[2][1]="v, specific volume ";

   s1[3][1]="h, enthalpy        ";

   s1[4][1]="u, internal energy ";

   s1[5][1]="s, entropy         ";

   s1[6][1]="x, quality         ";

   s1[7][1]="Cp, specific heat at constant pressure ";

   s1[8][1]="Cv, specific heat at constant volume ";

   s1[9][1]=""+'\u03B1'+" isobaric thermal expansion coefficient ";

   s1[10][1]=""+'\u03BA'+" isothermal compressibility" ;

   s1[11][1]=""+'\u03B7'+" Dynamic viscosity" ;

   s1[12][1]="k Thermal conductivity" ;

   s1[13][1]=""+'\u03C3'+" Surface tension" ;

   s1[14][1]="Prandtl number" ;

   s1[15][1]=""+'\u03C1'+" density" ;

   s1[16][1]=" speed of sound" ;

   s1[0][3]=" kPA          ";

   s1[1][3]=" deg K         ";

   s1[2][3]=" m"+'\u00B3'+"/kg        ";

   s1[3][3]=" KJ/kg         ";

   s1[4][3]=" KJ/kg         ";

   s1[5][3]=" KJ/kgK         ";

   s1[6][3]=" kg vap/kg mix ";

   s1[7][3]=" KJ/kgK";

   s1[8][3]=" KJ/kgK";

   s1[9][3]=" 1/K";

   s1[10][3]=" kPa";

   s1[11][3]=" Pa.s";

   s1[12][3]=" W/mK";

   s1[13][3]=" N/m";

   s1[14][3]=" ";

   s1[15][3]=" kg/m^3";

   s1[16][3]=" m/s";

double pp[]=property(s,v1,v2);

for(int i=0;i<17;i++)

   {s1[i][2]=""+pp[i];}

    //s1[6][2]=phase(pp[6]);

for(int i=0;i<17;i++)

{s1[i][0]=""+i;}  

return s1;

}

 

public String[][] toStringC(String s, double v1, double v2)

{  String s1[][]=new String[17][4];

   s1[0][1]="P, pressure        ";

   s1[1][1]="T, temperature     ";

   s1[2][1]="v, specific volume ";

   s1[3][1]="h, enthalpy        ";

   s1[4][1]="u, internal energy ";

   s1[5][1]="s, entropy         ";

   s1[6][1]="x, quality         ";

   s1[7][1]="Cp, specific heat at constant pressure ";

   s1[8][1]="Cv, specific heat at constant volume ";

   s1[9][1]=""+'\u03B1'+" isobaric thermal expansion coefficient ";

   s1[10][1]=""+'\u03BA'+" isothermal compressibility" ;

   s1[11][1]=""+'\u03B7'+" Dynamic viscosity" ;

   s1[12][1]="k Thermal conductivity" ;

   s1[13][1]=""+'\u03C3'+" Surface tension" ;

   s1[14][1]="Prandtl number" ;

   s1[15][1]=""+'\u03C1'+" density" ;

   s1[16][1]=" speed of sound" ;

   s1[0][3]=" kPA          ";

   s1[1][3]=" deg K         ";

   s1[2][3]=" m"+'\u00B3'+"/kg        ";

   s1[3][3]=" KJ/kg         ";

   s1[4][3]=" KJ/kg         ";

   s1[5][3]=" KJ/kgK         ";

   s1[6][3]=" kg vap/kg mix ";

   s1[7][3]=" KJ/kgK";

   s1[8][3]=" KJ/kgK";

   s1[9][3]=" 1/K";

   s1[10][3]=" 1/Pa";

   s1[11][3]=" Pa.s";

   s1[12][3]=" W/mK";

   s1[13][3]=" N/m";

   s1[14][3]=" ";

   s1[15][3]=" kg/m"+'\u00B3';

   s1[16][3]=" m/s";

  double pp[]=propertyC(s,v1,v2);

for(int i=0;i<17;i++)

   {s1[i][2]=""+pp[i];}

    //s1[6][2]=phase(pp[6]);

for(int i=0;i<17;i++)

{s1[i][0]=""+i;}  

return s1;

}

public String phase(double T, double v)

{

//phase of the steam-water system

if( Ps(T) > Pc)

  return "Supercritical fluid";

else

 {

 double ts=T;

 double vsl=vf_T(ts);

 double vsg=vg_T(ts);

 if(v<vsl)

   return "liquid";

 else if(v==vsl)

   return "saturated liquid";

 else if(v==vsg)

   return "saturated vapor";

 else if(v>vsl && v<vsg)

   return "saturated liquid-vapor mixture";

 else // (v>vsg)

   return "superheated vapor";

 }

}

public String phaseT(double T, double v)

{

//phase of the steam-water system

if( Ps(T) > Pc)

  return "Superkritik sıvı";

else

 {

 double ts=T;

 double vsl=vf_T(ts);

 double vsg=vg_T(ts);

 if(v<vsl)

   return "sıvı";

 else if(v==vsl)

   return "doymuş sıvı";

 else if(v==vsg)

   return "doymuş buhar";

 else if(v>vsl && v<vsg)

   return "doymuş sıvı buhar karışımı";

 else // (v>vsg)

   return "kızgın buhar";

 }

}

public String phase(double x)

{

// phase of the steam-water system

if( x==3)

  return "Supercritical fluid";

else

 {

 if(x<0)

   return "liquid";

 else if( x==0)

   return "saturated liquid";

 else if(x==1)

   return "saturated vapor";

 else if( x>0 && x<1)

   return "saturated liquid-vapor mixture";

 else // (x>1)

   return "superheated vapor";

 }

}

public String phaseT(double x)

{

//phase of the steam-water system

if( x==3)

  return "Superkritik sıvı";

else

 {

 if(x<0)

   return "sıvı";

 else if( x==0)

   return "doymuş sıvı";

 else if(x==1)

   return "doymuş buhar";

 else if( x>0 && x<1)

   return "doymuş sıvı buhar karışımı";

 else // (x>1)

   return "kızgın buhar";

 }

}

void setUnit(boolean x)

{unit="SI";}

 

void setUnit(String x)

{unit="SI";}

 

//DERIVATIVES

public static void main(String arg[])

{ steamIAPWS_IF97 st=new steamIAPWS_IF97();

  double T=650;

  double ro=250;

  double a[]=st.property("rot",ro,T);

  System.out.println(Matrix.toStringT(a));

  st.plot_TS_C("tx",100.0,1.0);

  }

}

 

Gas.java   thermodynamic and thermophysical properties of gases

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

// Thermodynamic Package in java

// Class Gas Properties of perfect gases

// Dr. Turhan Coban

// Ege University, School of Engineering,

// Department of Mechanical Engineering

// Bornova İZMİR - TURKEY

//

// email : turhan.coban

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

// File Name   : Gas.java

// This file contains the Gas class

// this class sets basic properties of perfect gases

// required data is read from Gas.dat.

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

// Description  : This file contains the gas class

//               class gas calculates thermophysical properties of

//               perfect gasses

//               following properties can be calculated

//               T()     : Temperature degree K

//               h(T)    : enthalpy  KJ/kmol

//               hf      : formation enthalpy KJ/kg

//               ht(T)   : total enthalpy KJ/kg (h+hf)

//               M       : molar mass kg/kmol

//               HT(T)   : total enthalpy KJ : M*ht(T)

//               P()     : presuure bar

//               s(T,P)  : entropy KJ/kmol K

//               Cp(T)   : specific heat at constant pressure KJ/kmol K

//               Cv(T)   : specific heat at constant volume KJ/kg K

//               gamma(T): adiabatic constant Cp/Cv

//               u(T)    : Internal energy KJ/kmol

//               c(T)    : speed of sound m/s

//               vis(T)  : viscosity      Ns/m^2

//               k(T)    : thermal conductivity KJ/kg K

// DATA FILE DEFINATION

// gas datas are written in the data file "Gas.dat"

// if gas data is not given in the data file, it can be curve fitted

// and added to the data file. Additional curve fitting programs supplied

// in Numerical Analysis package. Each data has the following form :

//------------------

// gasName

// n_equation M h0 hf sf

// xa[0] xb[0] xc[0] xd[0] tl[0] th[0]

// .........

// xa[n_equation-1] xb[n_equation-1]......th[n_equation-1]

// n_vis

// xvis[0]

// .........

// xvis[n_vis-1]

// n_k

// xk[0]

// .........

// xk[n_k-1]

//-------------------

// unit of the xa :  kcal/kmol

// note : if any curvefitting applied for a new gas temperature values

// in K nad enthalpy values in the unit of Kcal.kmol should be supply

// for the Cp curve fitting

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

//  VARIABLE IDENTIFICATION

// all the variables that type is not defined is a double variable

// PROTECTED VARIABLES :

// xa,xb,xc,xd ,tl,th : double pointers. This values used to calculate

// specific heat at constant pressure  from the following equation :

// Cp(T) = xa[i]+xb[i]*1e-3*T+xc[i]*1.0e5/T^2+xd[i]*1e-6*T^3

// where tl[i] <= T <= th[i]

// n_equation : number of equations (xa,xb,xc,xd,tl,th) for a gas

// xvis : real pointers to define viscosity according to formula :

// vis(T)=sum(xvis(i)*T^i) , for(i=0;i<n_vis;i++)

// n_vis : number of coefficients in polynomial viscosity curve fitting

// xk :real pointers to define thermal conductivity according to formula

// k(t)=sum(xk(i)*T^i) ,  for(i=0;i<n_k;i++)

// PUBLIC VARIABLES :

// gasName : name of the gas example : H2O   :variable class str

// (class str is defined at file cstr.h and str.cpp, written by Timotyhy A. Budd)

// M : mol number of the gas example mol number of H2O is 18.016 kg/kmol

// h0 : value of enthalpy at 298 K in the unit of Kcal/kmol

// hf : formation enthalpy at 298 K in the unit of Kcal/kmol

// sf : value of enthalpy at 298 K and 1 bar pressure

// N  : molar weight of the gas, kmol

// ierror : integer variable, error flag

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

import java.io.*;

import java.net.*;

import java.util.*;

import javax.swing.*;

 

class Gas

{

boolean mole=true; //switch for mole/mass basis

boolean SI=true;   //switch for SI/EN units

URL gn;

double xa[],xb[],xc[],xd[],tl[],th[];

int n_equation;

int n_vis;

int n_k;

double xvis[];

double xk[];

int natom;

String gasName;

Atom atomList[];

double M;  // molar mass of atom kg/kmol

double h0; // enthalpy at T=298 K

double s0; // enthrophy at 298 K

double hf; // enthalpy of formation  KJ/kmol

double sf; // entropy of formation    kJ/kmol K

double gf; // gibbs free energy of formation KJ/kmol

double N;  // moles of gas kmol

int ierror;

double R= 8.314472; //kJ/kmolK gas constant

BufferedReader fin;

File gasDir;

// definations of class functions

// constructors

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

public Gas()

{

//empty constructor

int i;

gasName="******************************";

natom=1;

atomList=new Atom[natom];

M=0;

N=1.0;

h0=0;

s0=0;

hf=0;

sf=0;

gf=0;

n_equation=6;

n_vis=10;

n_k=10;

xa=new double[6];

xb=new double[6];

xc=new double[6];

xd=new double[6];

tl=new double[6];

th=new double[6];

xvis=new double[10];

xk=new double[10];

for(i=0;i<n_equation;i++)

{xa[i]=0.0;xb[i]=0.0;xc[i]=0.0;xd[i]=0.0;tl[i]=293.0;th[i]=293.0;}

for(i=0;i<n_vis;i++)

{xvis[i]=0.0;}

for(i=0;i<n_k;i++)

{xk[i]=0.0;}

}

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

 

public Gas(String gName,double Nnew)

{readgas(gName,Nnew);}

 

public Gas(String gName)

{readgas(gName,1.0);}

 

public Gas(Gas g) throws IOException

{

int i;

gasName=g.gasName;

natom=g.natom;

atomList=new Atom[natom];

for(i=0;i<natom;i++)

{

atomList[i]=g.atomList[i];

}

M=g.M;

N=g.N;

h0=g.h0;

hf=g.hf;

s0=g.s0;

sf=g.sf;

gf=hf-298.15*sf;

n_equation=g.n_equation;

n_vis=g.n_vis;

n_k=g.n_k;

xa=new double[n_equation];

xb=new double[n_equation];

xc=new double[n_equation];

xd=new double[n_equation];

tl=new double[n_equation];

th=new double[n_equation];

xvis=new double[n_vis];

xk=new double[n_k];

for(i=0;i<n_equation;i++)

{xa[i]=g.xa[i];xb[i]=g.xb[i];xc[i]=g.xc[i];xd[i]=g.xd[i];tl[i]=g.tl[i];th[i]=g.th[i];}

for(i=0;i<n_vis;i++)

{xvis[i]=g.xvis[i];}

for(i=0;i<n_k;i++)

{xk[i]=g.xk[i];}

 

}

 

public String toString()

{

//return the chemical symbol of the gas

String s="";

for(int i=0;i<natom;i++)

  s=s+atomList[i].toString();

return s;

}

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

 

public void changeN(double Nnew)

{

N=Nnew;

}

               

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

 

public double vis(double T)

{

// SI Ns/m^2

// EN lbm/(ft.s)

if(!SI) T/=1.8;

// dynamic viscosity of the gas

double visg=0;

if(n_vis!=0.0)

{

  visg=xvis[n_vis-1];

  for(int i=n_vis-2;i>=0;i--)

   { visg=visg*T+xvis[i]; }

  visg*=1.0e-7;

}

else

  visg=0;

if(!SI) visg/=1.488;

return visg;

}

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

 

public double k(double T)

{

// thermal conductivity of the gas

if(!SI) T/=1.8;

double kg;

if(n_k!=0.0)

{

  int nk=n_k-1;

  kg=xk[nk];

  for(int i=n_k-2;i>=0;i--)

   { kg+=kg*T+xk[i]; }

                kg*=1.0e-3;

}

else

  kg=0;

if(!SI) kg/=1.731;

return kg;

}

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

 

   public double h1(double T)

   {

   if(!SI) T/=1.8;

   //  enthalpy KJ/kmol

   //integration of function dh=Cp(T)*dT

   double hh =h0;

     for(int i=0;i<n_equation;i++)

     {

                     if(((T>th[i]) && (i== (n_equation-1) ) )

                               || ((T<tl[i]) && (i== 0 ) ) )

             {

                     hh+=   xa[i]*(T- tl[i])

                          + xb[i]*1.0e-3/2.0*(T*T-tl[i]*tl[i])

                                 - xc[i]*1e5*(1/T-1/tl[i])

                                 + xd[i]*1e-6*(T*T*T-tl[i]*tl[i]*tl[i])/3.0;

      }

             else if((T<= th[i]) && (T> tl[i]))

                                                                {

                     hh+=   xa[i]*(T- tl[i])

                          + xb[i]*1.0e-3/2.0*(T*T-tl[i]*tl[i])

                                 - xc[i]*1e5*(1/T-1/tl[i])

                                 + xd[i]*1e-6*(T*T*T-tl[i]*tl[i]*tl[i])/3.0;

             }

             else if(T>th[i])

                                                                {

                     hh+=   xa[i]*(th[i]- tl[i])

                          + xb[i]*1.0e-3/2.0*(th[i]*th[i] - tl[i]*tl[i])

                                 - xc[i]*1e5*(1/th[i]-1/tl[i])

                                 + xd[i]*1e-6*(th[i]*th[i]*th[i]-tl[i]*tl[i]*tl[i])/3.0;

             }

                  }

   if(!SI) hh*=0.42992;

   if(!mole) hh/=M;

   return hh;

   }

   public double h(double T)

   {return h1(T)-h1(273.15);}

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

 

   public double ht( double t)

   {

   double hf1=hf;

   double h1,href;

   double Tref=298.15;

   if(!SI) {Tref=536.67;hf1=hf*0.42992;}

   h1=h(t);

   href=h(Tref);

   double ht= h(t)-h(Tref)+hf1;

   //System.out.println(gasName+" h1="+h1+"href="+href+"hf1="+hf1+"ht="+ht);

   if(!mole) ht/=M;

   return ht;

   }

 

   public double s0t( double t)

   {

   double sf1=sf;

   double Tref=298.15;

   if(!SI) {Tref=536.67;sf1*=0.238846;}

   double st=s(t)-s(Tref)+sf;

   if(!mole) st/=M;

   return st;

   }

 

   public double st( double t,double p)

   {

   double sf1=sf;

   double s1,sref;

   double Tref=298.15,Pref=1.0;

   if(!SI) {Tref=536.67;sf1*=0.238846;Pref=14.503684;}

   s1=s(t,p);

   sref=s(Tref,Pref);

   double sst=s1-sref+sf1;

   if(!mole) sst/=M;

   //System.out.println("s1="+s1+"sref="+sref+"sf1="+sf1+"sst="+sst+"P="+p+"Pref="+Pref);

   return sst;

   }

 

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

 

   public double H(double t)

   {

   return h(t)*N;

   }

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

 

   public double HT(double t)

   {

   return ht(t)*N;

   }

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

 

   public double u(double T)

   {

   // internal energy KJ/kmol

   // Integration of function du = Cv(T)*dT

   double ht=h(T);

   double R=8.3145;

   if(!SI) {R=1.986;}

   double at= R*T;

   if(!mole) at/=M;

   return ht-at;

   }

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

 

   public double v(double T,double P)

   {

   // specific volume of the gas m^3/kmol

   if(!SI) {T/=1.8;P/=14.503684;}

   double vt= 8314.5*T/(P*1e5);

   if(!mole) vt/=M;

   if(!SI) vt*=16.016949;

   return vt;

   }

  

   public double P(double T,double v)

   {

   // pressure of the gas bar

   double pp= 8.3145*1e3*T/v*1e-5;

   if(!mole) pp/=M;

   return pp;

   }

   public double v(double T)

   {

   if(!SI) {T/=1.8;}

   double P=1.0;

   // specific volume of the gas m^3/kmol

   double vt=R*1e3*T/(P*1e5);

   if(!mole) vt/=M;

   if(!SI) vt*=16.016949;

   return vt;

   }

 

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

   public double c(double t)

   {

   double g=gamma(t);

   if(!SI) t/=1.8;

   // speed of sound m/s

   double ct=Math.sqrt(R*1e3/M*t*g);

   if(!SI) ct/=0.3048;

   return ct;

   }

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

   public double alfa(double T,double P)

   { return k(T)*v(T,P)/Cp(T);}

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

 

   public double si(double T, double P)

   {

   // entropy KJ/kmol K

   // integration of function

   // ds = Cp(T) * dt/T - R dP/P

   // 0 point at 298 K

   // si=s(t,P)-s0(298)

   if(!SI) {T/=1.8;P/=14.503684;}

   double sot=s0;

   if(!mole) sot/=M;

   if(!SI) sot*=0.2388444444;

   return s(T,P)-sot;

   }

 

   public double s1(double T, double P)

   {

   //entropy KJ/kmol K

   //integration of function

   // ds = Cp(T) * dt/T - R dP/P

   // 0 point at 0 K (so is added up at 298 K)

   if(!SI) {T/=1.8;P/=14.503684;}

   double ss=s0;

   for(int i=0;i<n_equation;i++)

                               {

           if( ( T > th[i]  && i==n_equation - 1 )

                     ||( T < tl[i]  && i==0              ))

                                      {

                       ss+=xa[i]*Math.log(T/tl[i])

                       + xb[i]*1.0E-3*(T-tl[i])

                       - xc[i]*1e5/2.0*(1.0/(T*T) - 1.0/(tl[i]*tl[i]))

                       + xd[i]*1e-6/2.0*(T*T-tl[i]*tl[i]);

               }

                   else if((T <= th[i]) && (T > tl[i]))

                       {

                       ss+=xa[i]*Math.log(T/tl[i])

                       + xb[i]*1.0E-3*(T-tl[i])

                       - xc[i]*1e5/2.0*(1.0/(T*T) - 1.0/(tl[i]*tl[i]))

               + xd[i]*1e-6/2.0*(T*T-tl[i]*tl[i]);

                                                                               }

                   else if( T > th[i] )

                       {

                       ss+=xa[i]*Math.log(th[i]/tl[i])

                       + xb[i]*1.0E-3*(th[i]-tl[i])

                       - xc[i]*1e5/2.0*(1.0/(th[i]*th[i]) - 1.0/(tl[i]*tl[i]))

                       + xd[i]*1e-6/2.0*(th[i]*th[i] - tl[i]*tl[i]);

                                                                               }

                   }

   double sst= (ss-R*Math.log(P));

   if(!mole) sst/=M;

   if(!SI) sst*=0.238846;

   //System.out.println("sst="+sst+"s0="+s0+"sf="+sf);

   return sst;

   }

   public double s(double T, double P)

   { double P0=1.01325;

     double T0=273.15;

     return s1(T,P)-s1(T0,P0);

   }

 

   public double S(double T, double P)

   {

   return s(T,P)*N;

   }

 

   public double Si(double T, double P)

   {

   return si(T,P)*N;

   }

 

   public double s1(double T)

   {

   //entropy KJ/kmol K

   //integration of function

   // ds = Cp(T) * dt/T - R dP/P

   double P=1;

   if(!SI) {T/=1.8;}

   double ss=s0;

   for(int i=0;i<n_equation;i++)

                               {

           if( ( T > th[i]  && i==n_equation - 1 )

                     ||( T < tl[i]  && i==0              ))

                                      {

                       ss+=xa[i]*Math.log(T/tl[i])

                       + xb[i]*1.0E-3*(T-tl[i])

                       - xc[i]*1e5/2.0*(1.0/(T*T) - 1.0/(tl[i]*tl[i]))

                       + xd[i]*1e-6/2.0*(T*T-tl[i]*tl[i]);

               }

                   else if((T <= th[i]) && (T > tl[i]))

                       {

                       ss+=xa[i]*Math.log(T/tl[i])

                       + xb[i]*1.0E-3*(T-tl[i])

                       - xc[i]*1e5/2.0*(1.0/(T*T) - 1.0/(tl[i]*tl[i]))

               + xd[i]*1e-6/2.0*(T*T-tl[i]*tl[i]);

                                                                               }

                   else if( T > th[i] )

                       {

                       ss+=xa[i]*Math.log(th[i]/tl[i])

                       + xb[i]*1.0E-3*(th[i]-tl[i])

                       - xc[i]*1e5/2.0*(1.0/(th[i]*th[i]) - 1.0/(tl[i]*tl[i]))

                       + xd[i]*1e-6/2.0*(th[i]*th[i] - tl[i]*tl[i]);

                                                                               }

                   }

   if(!mole) ss/=M;

   if(!SI) ss*=0.238846;

   return ss;

   }

  

 

   public double si(double T)

   {

   return s(T)*N;

   }

  public double s(double T)

  {return s1(T)-s1(273.15);}

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

 

public double s0(double T)

{return s(T);}

 

public double pr(double T)

{

double Tref, Rref;

  if(!SI) {Tref=491.67;Rref=1.986;}

  else {Tref=298.15;Rref=8.3145;}

  if(!mole) Rref/=M;

  return Math.exp((s0(T)-s0(Tref))/Rref);

}

 

public double vr(double T)

{

  double Rref;

  if(!SI) {Rref=1.986;}

  else {Rref=8.3145;}

  return (Rref/M)*T/pr(T)*10;

}

 

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

public double g(double T,double P)

{

  return h(T)-T*s(T,P);

}

 

public double gt(double T,double P)

{

  return ht(T)-T*st(T,P);

}

 

public double gt0(double T)

{

  return ht(T)-T*s0(T);

}

public double gt(double T)

{

  double Pref;

  if(!SI) {Pref=14.503684;}

  else {Pref=1.0;}

  return ht(T)-T*st(T,Pref);

}

 

public double g(double T)

{

  double Pref;

  if(!SI) {Pref=14.503684;}

  else {Pref=1.0;}

  return h(T)-T*s(T,Pref);

}

 

public double G(double T,double P)

{

 return g(T,P)*N;

}

 

public double G(double T)

{

 return g(T)*N;

}

 

public double GT(double T)

{

 return gt(T)*N;

}

 

public double GT(double T,double P)

{

 return gt(T,P)*N;

}

 

 

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

public double g0(double T)

{

  return h(T)-T*s0(T);

}

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

public double Cp(double T)

{

   //specific heat at constant pressure KJ/kmol K

   if(!SI) {T/=1.8;}

   double cp=0.0;

   for (int i=0;i<n_equation;i++)

     {

        if( ( T > th[i]  && i==n_equation - 1 )

                                 ||( T < tl[i]  && i==0              ))

                               {

        cp=xa[i]+xb[i]*1.0e-3*T+xc[i]*1.0e5/T/T+xd[i]*1.0e-6*T*T;

                break;

                }

                else if((T <= th[i]) && (T >= tl[i]) )

                {

                cp=xa[i]+xb[i]*1.0e-3*T+xc[i]*1.0e5/T/T+xd[i]*1.0e-6*T*T;

                                 break;

                }

}

if(!mole) cp/=M;

if(!SI) cp*=0.2388444444;

return cp;

}

 

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

public double Cv(double T)

{

//specific heat at constant volume KJ/kmol K

double Rref;

if(!SI) {Rref=1.986;}

else {Rref=8.3145;}

if(!mole) Rref/=M;

double cv;

cv=Cp(T) - Rref;

return cv;

}

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

public double gamma(double T)

{

//adiabatic constant

return Cp(T)/Cv(T);

}

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

public double T( char name,double y0,double p)

{

// name can have values h : for enthalpy

//                      u : for internal energy

//                      s : for entropy

//                      v : specific volume

// yo : the value of the variable given by variable name

double t;

if(!SI) {t=540;}

else {t=300;}

if(name=='v') {

  double R;

  if(!SI) {R=1545/144;}  //R

  else    {R=8.3145e3/1e5;} //K

  if(!mole) R/=M;

  t= p*y0/R;

              }

  else

  {

  double dt=0;

  int nmax=400;

  double tolerance=1.0e-8;

  for(int i=0;i<nmax;i++)

    {

// apply newtons method for finding roots of equation

    if     (name=='h') dt=-( h(t)   - y0 ) /Cp(t);

    else if(name=='u') dt=-( u(t)   - y0 ) /Cv(t);

    else if(name=='s') dt=-( s(t,p) - y0 ) /(Cp(t)/t);

    else { System.out.println("wrong name defined please try h,u,s ot v");}

                 t+=dt;

//   if error range is less than tolerance, exit

    if(Math.abs(dt)<tolerance) break;

    }

  }

return t;

}

 

public double T( char name,double y0)

{

// name can have values h : for enthalpy

//                      u : for internal energy

//                      s : for entropy

//                      v : specific volume

// yo : the value of the variable given by variable name

double t,p=1.0;

  double R;

  if(!SI) {R=1545/144;p=14.503684;t=540;}  //R

  else    {R=8.3145e3/1e5;p=1.0;t=300;} //K

  if(!mole) {R/=M;}

if(name=='v') { t= p*y0/R; }

else

  {

  double dt=0;

  int nmax=400;

  double tolerance=1.0e-8;

  for(int i=0;i<nmax;i++)

    {

// apply newtons method for finding roots of equation

    if     (name=='h') dt=-( h(t)   - y0 ) /Cp(t);

    else if(name=='u') dt=-( u(t)   - y0 ) /Cv(t);

    else if(name=='s') dt=-( s(t,p) - y0 ) /(Cp(t)/t);

    else { System.out.println("wrong name defined please try h,u,s ot v");}

                 t+=dt;

//   if error range is less than tolerance, exit

    if(Math.abs(dt)<tolerance) break;

    }

  }

return t;

}

 

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

public double P( char name,double y0,double t1)

{

// name can have values v : for specific volume

//                      s : for entropy

// note : for a perfect gas enthalpy and internal energy

// is not function of pressure

// yo : the value of the variable given by variable name

  double R,R1;

  if(!SI) {R=1545;R1=1.986;}  //R

  else    {R=8.3145e3/1e5;R1=8.3145;} //K

  if(!mole) {R/=M;R1/=M;}

 

if(name=='v')       return R*t1/y0;

else if (name=='s') return Math.exp((s(t1,1.0)-y0)/R1);

else { System.out.println("wrong name defined please try s or v"); return 1.0;}

}

 

double T(double P, double v)

{double R1;

if(!mole) {R1=R/M;}

else R1=R*1e3;

double T=P*1e5*v/R1*1e-3;

return T;

}

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

public double Prandtl(double t)

{

// Prandtl number

double cp;

if(mole) {cp=Cp(t)/M;}

else {cp=Cp(t);}

double pr=0;

if(SI) pr=cp*vis(t)/k(t)*1e3;

else pr=cp*vis(t)/k(t)*3600;

return pr;

}

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

public void assign(Gas g1) throws IOException

{

// assign operator (assigning a new gas to the gas variable)

int i;

ierror=1;

gasName=g1.gasName;

N=g1.N;

n_equation=g1.n_equation;

n_k=g1.n_k;

n_vis=g1.n_vis;

M=g1.M;

h0=g1.h0;

hf=g1.hf;

sf=g1.sf;

natom=g1.natom;

atomList=new Atom[natom];

M=0;

for(i=0;i<natom;i++)

 {

 atomList[i]=new Atom(g1.atomList[i].name,g1.atomList[i].N);

 }

xa=new double[n_equation];

xb=new double[n_equation];

xc=new double[n_equation];

xd=new double[n_equation];

tl=new double[n_equation];

th=new double[n_equation];

xvis=new double[n_vis];

xk=new double[n_k];

for(i=0;i<n_equation;i++)

  { xa[i]=g1.xa[i];

    xb[i]=g1.xb[i];

    xc[i]=g1.xc[i];

    xd[i]=g1.xd[i];

    tl[i]=g1.tl[i];

    th[i]=g1.th[i];

  }

for(i=0;i<n_vis;i++)

  { xvis[i]=g1.xvis[i];}

for(i=0;i<n_k;i++)

  {xk[i]=g1.xk[i];}

}

 

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

public Gas multiply(double Nnew, Gas g1) throws IOException

{

Gas g2=new Gas(g1);

g2.N*=Nnew;

return g2;

}

 

public boolean equals(Gas g)

{

if(gasName.equals(g.gasName))

    return true;

else

    return false;

}

 

public boolean base(String s)

{

if(s.equals("mole")) {mole=true;}

else                 {mole=false;}

return mole;

}

 

public boolean unit(String s)

{

if(s.equals("SI")) {SI=true;}

else               {SI=false;}

return SI;

}

 

public double[] property(double t, double p)

{

double pp[]=new double[19];

pp[0]=p;

pp[1]=t;

pp[2]=v(t,p);

pp[3]=h(t);

pp[4]=u(t);

pp[5]=s(t,p);

pp[6]=g(t,p);

pp[7]=ht(t);

pp[8]=gt(t,p);

pp[9]=Cp(t);

pp[10]=Cv(t);

pp[11]=gamma(t);

pp[12]=c(t);

pp[13]=vis(t);

pp[14]=k(t);

pp[15]=M;

pp[16]=Prandtl(t);

pp[17]=pr(t);

pp[18]=vr(t);

return pp;

}

 

public String[][] toString1(double v1, double v2)

{

  String s1[][]=new String[19][3];

   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]="g, qibbs free energy         ";

   s1[7][0]="ht,chemical enthalpy          ";

   s1[8][0]="gt,chemical gibbs f.e.       ";

   s1[9][0]="Cp, specific heat at const P ";

   s1[10][0]="Cv, specific heat at const v";

   s1[11][0]="Cp/Cv, adiabatic constant   ";

   s1[12][0]="c, speed of sound           ";

   s1[13][0]="viscosity                   ";

   s1[14][0]="thermal conductivity        ";

   s1[15][0]="M, molecular weight         ";

   s1[16][0]="Prandtl number              ";

   s1[17][0]="Pr, reduced pressure        ";

   s1[18][0]="vr, reduced volume          ";

 

   if(SI && !mole)

   {

   s1[0][2]=" bars          ";

   s1[1][2]=" deg K         ";

   s1[2][2]=" m^3/kg        ";

   s1[3][2]=" KJ/kg         ";

   s1[4][2]=" KJ/kg         ";

   s1[5][2]=" KJ/kg K       ";

   s1[6][2]=" KJ/kg         ";

   s1[7][2]=" KJ/kg         ";

   s1[8][2]=" KJ/kg         ";

   s1[9][2]=" KJ/kg K        ";

   s1[10][2]=" KJ/kg K       ";

   s1[11][2]="               ";

   s1[12][2]=" m/s           ";

   s1[13][2]=" Ns/m^2        ";

   s1[14][2]=" W/m K         ";

   s1[15][2]=" kg/kmol       ";

   s1[16][2]="               ";

   s1[17][2]="               ";

   s1[18][2]="               ";

   }

   else if(SI && mole)

   {

   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]=" KJ/kmole      ";

   s1[7][2]=" KJ/kmole      ";

   s1[8][2]=" KJ/kmole      ";

   s1[9][2]=" KJ/kmole K    ";

   s1[10][2]=" KJ/kmole K   ";

   s1[11][2]="               ";

   s1[12][2]=" m/s           ";

   s1[13][2]=" Ns/m^2        ";

   s1[14][2]=" W/m K         ";

   s1[15][2]=" kg/kmol       ";

   s1[16][2]="               ";

   s1[17][2]="               ";

   s1[18][2]="               ";

   }

   else if(!SI && mole)

   {

   s1[0][2]=" lbf/in^2, psia  ";

   s1[1][2]=" deg R           ";

   s1[2][2]=" ft^3/lbmole     ";

   s1[3][2]=" BTU/lbmole      ";

   s1[4][2]=" BTU/lbmole      ";

   s1[5][2]=" BTU/lbmole K    ";

   s1[6][2]=" BTU/lbmole      ";

   s1[7][2]=" BTU/lbmole      ";

   s1[8][2]=" BTU/lbmole      ";

   s1[9][2]=" BTU/lbmole K    ";

   s1[10][2]=" BTU/lbmole K   ";

   s1[11][2]="                ";

   s1[12][2]=" ft/s           ";

   s1[13][2]=" lbm/(ft.s)     ";

   s1[14][2]=" BTU/(hr ft R)  ";

   s1[15][2]=" lbm/lbmole     ";

   s1[16][2]="                ";

   s1[17][2]="                ";

   s1[18][2]="                ";

   }

   else if(!SI && !mole)

   {

   s1[0][2]=" lbf/in^2, psia  ";

   s1[1][2]=" deg R           ";

   s1[2][2]=" ft^3/lbm     ";

   s1[3][2]=" BTU/lbm      ";

   s1[4][2]=" BTU/lbm      ";

   s1[5][2]=" BTU/lbm K    ";

   s1[6][2]=" BTU/lbm      ";

   s1[7][2]=" BTU/lbm      ";

   s1[8][2]=" BTU/lbm      ";

   s1[9][2]=" BTU/lbm K    ";

   s1[10][2]=" BTU/lbm K   ";

   s1[11][2]="                ";

   s1[12][2]=" ft/s           ";

   s1[13][2]=" lbm/(ft.s)     ";

   s1[14][2]=" BTU/(hr ft R)  ";

   s1[15][2]=" lbm/lbmole     ";

   s1[16][2]="                ";

   s1[17][2]="                ";

   s1[18][2]="                ";

   }

   double pp[]=property(v1,v2);

   for(int i=0;i<19;i++)

   {s1[i][1]=""+pp[i];}

return s1;

}

public void print(double T,double P)

{   String s[]={"name","value","unit"};

                Text.print(toString1(T,P),s,"Thermodynamic properties of "+gasName);}

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

public String readGasNames()

{ return readgas("null",1.0);}

public String[] readAllGasNames(){

                int l=0;

                StringTokenizer        st=new StringTokenizer(readGasNames());

                String[] gasNames=new String[st.countTokens()];

                while(st.hasMoreTokens()){

                               gasNames[l]=new String(st.nextToken()); 

                               l++;

                }

                return gasNames;

}

public String readgas(String gName,double Nnew)

{

String s="";

Vector<GasData> gi=new Vector<GasData>();

 

String a1air[]={"O","N","Ar","C"};

double an1air[]={0.419642,1.561756,0.009301,3.0E-4};

double agair[][]={{25.723723715676222,19.99232995854758,0.28314685702856945,-32.123563652414404,81.609,320.0},

{28.464145354908172,-1.164021370197852,0.3544070926810084,7.221339061364784,320.0,560.0},

{21.5993133407992,15.96178021757258,3.702729423134984,-4.879905099986132,560.0,800.0},

{22.763154093261136,14.200122777831522,2.238217697646537,-4.138882058708922,800.0,1040.0},

{26.291542733030408,9.495754850645417,-3.6190562872951055,-2.3764205985187483,1040.0,1280.0},

{29.32668801072842,6.09562628686765,-10.676895214728951,-1.3096147306086523,1280.0,1520.0},

{35.756238622623776,0.5200939494405615,-36.26361030650734,0.05483269974851683,1520.0,1760.0},

{36.61845505106491,0.10389584492555426,-43.90420820516371,0.09261066332475583,1760.0,2000.0},

{36.722142723274146,0.1707474036168994,-47.29394876002523,0.05444575004512367,2000.0,2240.0},

{28.718713072181927,4.775628262021043,24.52714872698266,-0.6915132545822185,2240.0,2480.0},

{44.50889410501734,-3.747424006916667,-136.81017213224615,0.604367728762747,2480.0,2720.0},

{-4.47620387925482,19.670678053826023,499.76687671980466,-2.547160034230336,2720.0,3000.0},

{ 36.80001467  ,0.539029387  ,-68.51625884  ,-0.019466005  ,3000.0  ,3400.0},

{ 34.73738048  ,1.352059205  ,-28.97252153  ,-0.109752215  ,3400.0  ,3800.0},

{ 44.11953294  ,-1.935021718  ,-256.9434715  ,0.214865727  ,3800.0  ,4200.0},

{ 56.82352321  ,-5.691266046  ,-681.9669078  ,0.525617897  ,4200.0  ,4600.0},

{ 41.99997604  ,-1.194108295  ,-204.1940195  ,0.141815168  ,4600.0  ,5000.0}};

double avisiair[]={-6.817292346102759,

0.8830146457621001,

-0.0012026562883010277,

1.8188979789272164E-6,

-2.139383229883467E-9,

1.8402774246587077E-12,

-1.1171057320985713E-15,

4.622248887615039E-19,

-1.23508557862883E-22,

1.9160802839635E-26,

-1.3085837116957147E-30};

double akiair[]={-1.1953112202083283,

0.11696095661777868,

-1.1547782080793012E-4,

1.3578222517628758E-7,

-1.1382639273194056E-10,

6.297910653661441E-14,

-2.021143575127782E-17,

2.114010910016399E-21,

8.315126218826288E-25,

-3.1062549427817927E-28,

3.1655477973439176E-32};

GasData gasd=new GasData("air",a1air,an1air,8649.144, 194.0942, -2.19608, -0.00013,agair,avisiair,akiair);

gi.addElement(gasd);

 

gasd=new GasData("c9h20" ,

2,

"C", 9.0,

"H", 20.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 506.79672960035003, -228920.532441993, -851.8779343,

-107.02456734534267, 203.3938534194742, 88.14664171553596, -96.37363943645977, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.7167959014585676E-4,0.1341173896651071,1.4111770592362127E-4,-1.5523703146991946E-7,6.040662038191801E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-8.655726801976016E-9,0.005104868738271762,1.196160384893119E-4,-3.2012539563641695E-8,1.2776708076950305E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c9h20g" ,

2,

"C", 9.0,

"H", 20.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 506.79672960035003, -228920.532441993, -851.8779343,

49.4491137, 669.9264271000001, -14.9800126, -231.94736670000003, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.7167959014585676E-4,0.1341173896651071,1.4111770592362127E-4,-1.5523703146991946E-7,6.040662038191801E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-8.655726801976016E-9,0.005104868738271762,1.196160384893119E-4,-3.2012539563641695E-8,1.2776708076950305E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c10h22" ,

2,

"C", 10.0,

"H", 22.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 546.09087224398, -249644.188213672, -949.1616365,

-117.78766671618585, 223.80472752761688, 97.23612442549552, -106.08575592953291, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.2415898784823298E-4,0.13014958895269046,1.387983209686361E-4,-1.5655305177653817E-7,6.064888438115443E-11,

0.0,0.0,0.0,0.0,0.0,

5,

2.3842200835844096E-7,0.0013572938266861456,1.1047390756502296E-4,-1.2635045806494438E-8,3.684013065717888E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c11h24" ,

2,

"C", 11.0,

"H", 24.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 585.3798769693701, -270636.820034063, -1046.48008,

-132.2334265775063, 251.4947012108614, 108.1163494781612, -119.08118948543044, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-5.307324698833327E-6,0.1053162909488492,2.117879433338743E-4,-2.654551951863926E-7,1.1754388242877134E-10,

0.0,0.0,0.0,0.0,0.0,

5,

-3.9143118346629535E-7,0.0013023111241636798,1.0089268097246418E-4,-7.025041989100478E-10,-6.848503062461858E-13,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c12h26" ,

2,

"C", 12.0,

"H", 26.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 637.88468045925, -291111.87010401295, -1144.097921,

-143.87011626489692, 273.54058176516355, 117.69203303871448, -129.49478998482647, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-2.537586357753696E-5,0.08323074161023669,2.7202121104785704E-4,-3.4521495865039165E-7,1.534843577840139E-10,

0.0,0.0,0.0,0.0,0.0,

5,

4.587016810830846E-8,-0.007398911760901683,1.2842245825517296E-4,-3.345195290216374E-8,5.437482159240711E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c13h28" ,

2,

"C", 13.0,

"H", 28.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 663.83654161937, -311731.730883972, -1241.415158,

-147.04798990988903, 279.7075996155644, 122.60419807754981, -132.98362082989038, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.5806620776714908E-5,0.07844201352963864,2.4811448477723985E-4,-3.0880775256890425E-7,1.381246539856922E-10,

0.0,0.0,0.0,0.0,0.0,

5,

2.412136268503673E-8,-0.007395079295747564,1.2217837625705386E-4,-2.988450404153853E-8,4.513719152742933E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c14h30" ,

2,

"C", 14.0,

"H", 30.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 703.2275892025301, -332297.39052013005, -1436.2173,

-161.68897918318777, 307.61301273498935, 133.73904834072442, -146.09039920941305, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-9.003127189544102E-6,0.07467382870311212,2.3469734708037038E-4,-2.8342254229651864E-7,1.246358630078916E-10,

0.0,0.0,0.0,0.0,0.0,

5,

-2.3469779897311582E-8,0.001944896412169328,9.12733549895961E-5,-9.158508784690156E-9,2.0938492740596015E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c15h32" ,

2,

"C", 15.0,

"H", 32.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 738.328, -353010.46537050005, -1436.2173,

-168.4149250349249, 320.1635340289247, 140.73052575181347, -152.21195486596596, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-8.877835721676774E-6,0.06762049771236889,2.462267657818984E-4,-2.945573520131417E-7,1.2782136270990938E-10,

0.0,0.0,0.0,0.0,0.0,

5,

3.0828593011733574E-8,-0.0072043263744490105,1.1045531313058632E-4,-2.3045664720305892E-8,2.783087669217389E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c16h34" ,

2,

"C", 16.0,

"H", 34.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 777.138, -373610.0, -1533.668679,

-179.15121917467042, 340.4724275512689, 149.83679756708537, -161.85853951201057, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-9.785964763864285E-6,0.054910602227437266,2.8689284291072426E-4,-3.479843229837326E-7,1.5011205062111818E-10,

0.0,0.0,0.0,0.0,0.0,

5,

3.323337338656529E-8,-0.007385429136775201,1.0505347543343646E-4,-1.8764269832383107E-8,1.6429192651912531E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c17h36" ,

2,

"C", 17.0,

"H", 36.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 816.115, -394211.0, -1630.952381,

-189.93850520227898, 360.8704744072048, 158.96271883542983, -171.534560090663, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

1.860989584656636E-9,0.09140362363541499,1.0828361109815887E-4,-9.269567824432556E-8,3.62497638243392E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-2.382654074040147E-9,-8.558101235394133E-4,7.244869168232526E-5,5.664579326436492E-9,-1.274266899409151E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c18h38" ,

2,

"C", 18.0,

"H", 38.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 854.924, -414852.0, -1728.370221,

-200.53439207215337, 380.95713597443296, 167.97147271845677, -181.099174807337, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

5.862456298189045E-9,0.0823469014139846,1.2462206132113351E-4,-1.0614261825026006E-7,4.109460731774317E-11,

0.0,0.0,0.0,0.0,0.0,

5,

2.5100961309476588E-8,-0.003753002145458595,7.26909443287127E-5,7.450245899376373E-9,-4.587917072212131E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c19h40" ,

2,

"C", 19.0,

"H", 40.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 893.902, -435453.0, -1825.620389,

-210.56080226464033, 399.9401526645353, 176.66541391632833, -190.15785859418344, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-2.70880207153823E-9,0.08591406443156302,8.454637099930551E-5,-3.7732409197133165E-8,6.707195562838386E-12,

0.0,0.0,0.0,0.0,0.0,

5,

2.367205098607883E-8,-8.684554268256761E-4,6.361434943613631E-5,7.065014628881983E-9,-1.6539249590925061E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c20h42" ,

2,

"C", 20.0,

"H", 42.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 932.711, -456094.0, -1923.205902,

-221.71485776705995, 421.0643904827715, 185.97272309803503, -200.1692370361124, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

2.027293888318127E-9,0.07673612097278237,1.0889165787375532E-4,-7.006877211779283E-8,2.2267453506086277E-11,

0.0,0.0,0.0,0.0,0.0,

5,

2.9608840712569418E-8,-6.626591712119989E-4,5.971525760628538E-5,7.704066565250578E-9,-1.903339688820189E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c11h16" ,

2,

"C", 11.0,

"H", 16.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 479.8, -33780.0, -626.4750168,

-101.87443721359665, 194.5584757839112, 83.86363136310875, -92.47793661224132, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-3.723628998955064E-4,0.1699363669990248,8.962193124051332E-5,-1.8212936103018107E-7,8.205944495576686E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-3.714095884177482E-7,0.006011547089428859,1.2097896044771517E-4,-7.213983643263033E-8,1.9048980420794488E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c12h18" ,

2,

"C", 12.0,

"H", 18.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 518.3084820137, -55059.0, -417.70954,

-113.10638151593328, 215.64238453037586, 93.16665244905325, -102.35104108227932, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.2368441471011238E-6,0.17913390102057747,1.0115532589338727E-5,-6.17730557608831E-8,2.5545042481051744E-114,

0.0,0.0,0.0,0.0,0.0,

5,

4.6385104113255693E-7,-0.003456824235854583,1.3299412384704112E-4,-6.486914094251672E-8,5.721342574746926E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c13h20" ,

2,

"C", 13.0,

"H", 20.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 557.2483, -75700.96, -823.499497,

-124.73220629937317, 237.69233713070446, 102.72291778309005, -112.77894560617881, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.83855,2295509.9987,0.16632954944617495,3.5510802031568645E-5,-1.1732211572905438E-7,

0.0,0.0,0.0,0.0,0.0,

5,

-1.5646217654818884E-7,0.006244123944270541,1.0947162356345075E-4,-6.269256034446835E-8,1.586138488567356E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c14h22" ,

2,

"C", 14.0,

"H", 22.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 596.46580766178, -96301.0, -920.9434272,

-136.3861850281647, 259.7824332489235, 112.30103789153657, -123.21927641097706, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.379090102382463E-4,0.16242894003306674,2.4836668568894993E-5,-1.0407295462401545E-7,5.039042962531729E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-5.287996351910351E-8,0.005930251558311284,1.0725024204560896E-4,-6.174347497514554E-8,1.5745451182098036E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c15h24" ,

2,

"C", 15.0,

"H", 24.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 636.5471700637, -116576.143451152, -1018.243897,

-146.04303664657388, 277.9382786768979, 121.0611356890927, -131.957813850854, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.1943272989611842E-4,0.1523719997119315,4.9743829136028594E-5,-1.212927015583655E-7,5.4502187931546994E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-3.317063779206819E-8,0.005858146537320863,1.0518854551833101E-4,-6.02655131701213E-8,1.529999858971014E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c16h26" ,

2,

"C", 16.0,

"H", 26.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 674.1259677089, -137605.25227209603, -1115.690879,

-159.59177663405035, 303.8243644515633, 131.36936448139474, -144.05479621496536, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.02313567968082E-4,0.14250986809344113,6.941877067379032E-5,-1.3738484788954758E-7,5.954032518144174E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-3.5633065387230545E-8,0.00606489018900902,1.0148839174561886E-4,-5.7159591282385236E-8,1.4234882451382921E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c17h28" ,

2,

"C", 17.0,

"H", 28.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 713.2149620525299, -158184.84, -1213.134742,

-168.08222117449924, 319.54279274628567, 139.63052216841658, -151.6577736106907, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-7.504601106234077E-5,0.14482845529727228,4.584419555597741E-5,-1.1367520762976119E-7,5.123128632489878E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-2.633790785466772E-8,0.005800148408525274,1.0051700960644894E-4,-5.71515351086016E-8,1.4395536090348058E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c18h30" ,

2,

"C", 18.0,

"H", 30.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 751.591, -178826.77, -1310.43833,

-182.32000093794747, 347.2922237515519, 150.05895936654395, -164.8907298378947, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-1.5315152346317973E-7,0.16058856997187831,-2.9596620805705243E-5,-1.1147830283886329E-8,7.0895192860287275E-12,

0.0,0.0,0.0,0.0,0.0,

5,

-1.3906354290327272E-8,0.005092640323709929,9.715711183844178E-5,-5.129457656544156E-8,1.2174753240469125E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c19h32" ,

2,

"C", 19.0,

"H", 32.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 790.98053064555, -199853.02275648498, -1579.59,

-194.35537225688876, 369.7884299144695, 159.95529294315696, -175.25912326850195, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-6.95171387121718E-9,0.15644693399008247,-2.3144793189544544E-5,-2.010226754500799E-8,1.1308973614336526E-11,

0.0,0.0,0.0,0.0,0.0,

5,

2.8641303551069086E-8,0.005088085446914192,8.627790778348299E-5,-2.5318675253571676E-8,-4.806046474014518E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c10h8" ,

2,

"C", 10.0,

"H", 8.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 333.326, 151100.0, -243.4607646,

-68.41110737166014, 130.91398911547844, 57.09368198926505, -62.421864574586436, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-2.57758514656814E-5,0.14550103251121982,2.1679718189648867E-4,-2.5084616397594295E-7,9.043802019204468E-11,

0.0,0.0,0.0,0.0,0.0,

5,

4.00485968530262E-5,-0.014340565607028566,1.631724662182199E-4,-9.390826428957132E-8,1.5793254149120795E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c11h10" ,

2,

"C", 11.0,

"H", 10.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 377.718865661466, 116950.420447574, -338.3635144,

-80.94104625088359, 154.39020537018783, 67.41254604675534, -73.45891020942402, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-6.867882156313954E-7,0.16644920641010685,6.459646735379465E-5,-1.02226914495962E-7,3.6310020033812184E-11,

0.0,0.0,0.0,0.0,0.0,

5,

1.1252457365884538E-7,-0.0024059310926531907,1.1567360926356685E-4,-6.053727539395704E-8,8.213003339044452E-12,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c12h12" ,

2,

"C", 12.0,

"H", 12.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 418.418798, 96712.77, -434.0045942,

-88.01567405186167, 165.08759970872012, 75.37552639852512, -77.2256410050037, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-9.52155989786263E-5,0.15628268325122008,8.114118471214127E-5,-1.4711331646150363E-7,6.051462492706506E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-2.5254297320032038E-8,0.006452688081481028,9.885440756107755E-5,-5.612413577285591E-8,1.4002260608926413E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

//CH4 methane

String a1CH4[]={"C","H"};

double an1CH4[]={1.0,4.0};

double agCH4[][]={{37.17508730836518,-43.772053872440374,-0.08455064288826528,130.74100327363013,298.15,400.0},

{2.308280360899021,97.89435244872931,5.887763951617632,-29.066030387966688,400.0,900.0},

{28.56950123926789,60.59843853981005,-34.06649673774811,-13.956461233222983,900.0,1500.0},

{72.78586849058512,19.714021272164196,-190.2998557041926,-3.2639379592283677,1500.0,2100.0},

{92.44917067621353,6.791019239031948,-326.3141461523196,-0.869405015368204,2100.0,2700.0},

{102.5083961266277,1.7819602099229177,-447.6972203863239,-0.16562371298398668,2700.0,3300.0},

{102.91996766008786,1.621949268991737,-454.8423093235588,-0.1489258923911679,3300.0,3900.0},

{106.2003112847043,0.47297901649692536,-535.2124560322603,-0.035251540174610595,3900.0,4500.0},

{105.92290719765117,0.5352491767734323,-522.1486928989681,-0.03857257521486511,4500.0,5100.0},

{106.90771932394065,0.24249760296751094,-553.0910568428603,-0.014448227994819849,5100.0,6000.0}};

double avisiCH4[]={-3.17434898401931,0.455271007474814,-2.73399388607163E-4,8.95312831114117E-8};

double akiCH4[]={3.99296677905716,0.0551053536678452,1.72999763063988E-4,-6.5721336346547E-8};

gasd=new GasData("ch4",a1CH4,an1CH4,10024.0, 186.251, -74873, -80.8486,agCH4,avisiCH4,akiCH4);

gi.addElement(gasd);

//c2h6 ethane

String a1C2H6[]={"C","H"};

double an1C2H6[]={2.0,6.0};

double agC2H6[][]={{58.06230921649487,-184.78836690479298,-0.9823798015995937,594.0428912174066,100.0,229.65},

{479.03297239474995,-2364.928195083367,-46.459522456366635,3740.0335370100133,229.65,279.0},

{1101.8358636136104,-4423.888950542867,-177.10277973254944,5274.987327778869,279.0,400.0},

{3.2935178976204496,178.28168304540583,0.8003495795702856,-59.48879344301974,400.0,800.0},

{41.04733014261953,115.75052747650923,-41.09837928220942,-30.083988241380915,800.0,1200.0},

{45.550480453566934,103.85489153567323,-21.960656869080555,-24.220350472439886,1200.0,1500.0},

{154.45024635533528,10.650938188693193,-484.09807796888236,-1.4014184723209353,1500.0,1900.0},

{157.34511955273632,8.655408370323041,-502.2741328681156,-1.0135591638410248,1900.0,2300.0},

{161.24511810951446,6.567413739243016,-542.258147399339,-0.7001067873322487,2300.0,2700.0},

{164.66524100480328,5.056573742023566,-592.2906879405651,-0.5155425299368608,2700.0,3100.0},

{158.53794938763468,7.598553219505648,-485.43097846290044,-0.8136482259540975,3100.0,3500.0},

{164.22191371893103,5.174028982351327,-574.3307145041895,-0.5256820210499236,3500.0,3900.0},

{179.64806027229784,-0.18147176390392877,-956.4713309595865,-0.0015064471598134688,3900.0,4300.0},

{185.56769873721876,-1.9950169231274248,-1145.4879496740782,0.15538311506923427,4300.0,4700.0},

{187.21081604436108,-2.585474821073577,-1172.8697129883994,0.21224171557602872,4700.0,5100.0},

{182.68437390457208,-1.7026902071344805,-874.4644076301637,0.16906538548545694,5100.0,5500.0},

{218.71903705995211,-10.645063744571386,-2607.809036864856,0.7931459145437953,5500.0,6000.0}};

double avisiC2H6[]={5.14,3.3449,-7.1071e-4};

double akiC2H6[]={-19.36,0.12547,3.8298e-5};

gasd=new GasData("c2h6",a1C2H6,an1C2H6,10024.0, 229.602, -84684, -103.0536913,agC2H6,avisiC2H6,akiC2H6);

gi.addElement(gasd);

 

//C2H4 ethene-ethylene

String a1C2H4[]={"C","H"};

double an1C2H4[]={2.0,4.0};

double agC2H4[][]={{31.08718810499148,-23.06204744576973,0.24191791476808933,206.983962359913,298.15,300.0},

{-13.679746696885866,198.62294839098487,5.678215650705322,-101.7064218593514,300.0,500.0},

{23.235554326955217,102.72127278003647,-10.901350526362489,-31.037484726700544,500.0,900.0},

{45.423435683027876,69.33270112688517,-40.74010034052113,-16.78204905050419,900.0,1300.0},

{78.0959916311849,35.372636386745384,-131.32967955174178,-6.819826468952545,1300.0,1700.0},

{101.76853364698538,16.51598336378407,-242.463657471924,-2.5882225717720395,1700.0,2100.0},

{112.62220461233987,9.408157646646456,-317.1468395310202,-1.2806814209155868,2100.0,2500.0},

{122.42404456677313,4.076532350014997,-416.05316476689865,-0.46311422251837797,2500.0,2900.0},

{126.74234375395703,2.0686499517731964,-475.7202639163133,-0.19985519175650351,2900.0,3300.0},

{135.86973892189172,-1.478079238769548,-654.2528467159568,0.18730715017245952,3300.0,3700.0},

{130.76589487622425,0.5220709565974846,-555.6602476818003,-0.03306962532211571,3700.0,4100.0},

{122.33336421459987,3.179966890805185,-302.3485962717391,-0.2693408257869576,4100.0,4500.0},

{141.1154314981171,-2.3355023643255888,-951.9806285953844,0.18723291898436933,4500.0,4900.0},

{151.43610131064105,-4.886337496376283,-1442.9946802015063,0.36313835618256707,4900.0,5300.0},

{140.79309588816068,-1.9133411353050238,-1052.3960732035214,0.13158206393428554,5300.0,5700.0},

{121.96862306515578,2.42622580714533,0.3063556712799079,-0.1500785805968666,5700.0,6000.0}};

double avisiC2H4[]={-39.85,3.8726,-1.1227e-3};

double akiC2H4[]={-1.23,3.6219e-2,1.2459e-4};

gasd=new GasData("c2h4",a1C2H4,an1C2H4,10518.0, 219.330, 52467, -53.51,agC2H4,avisiC2H4,akiC2H4);

gi.addElement(gasd);

 

//C3H8 Propane

String a1C3H8[]={"C","H"};

double an1C3H8[]={3.0,8.0};

double agC3H8[][]={{2.709229096469983,274.0071214529498,-1.2065293929259757,-104.15656888110409,298.15,600.0},

{35.07425713041475,205.13061705646987,-22.964953180233596,-62.47967467289455,600.0,1000.0},

{147.68933834507249,58.572903180387435,-223.84760188154615,-8.450813719792679,1000.0,1500.0}};

double avisiC3H8[]={-54.62,3.2722,-1.0672e-3};

double akiC3H8[]={-8.69,6.6409e-2,7.876e5};

gasd=new GasData("c3h8",a1C3H8,an1C3H8,10024.0, 270.019, -84684, 269.9212,agC3H8,avisiC3H8,akiC3H8);

gi.addElement(gasd);

 

//C4H10 Butane

String a1C4H10[]={"C","H"};

double an1C4H10[]={4.0,10.0};

double agC4H10[][]={{8.8411112475771,333.98478151550637,0.11532960841890062,-115.5944967332034,298.15,600.},

{6.012186143358417,339.97468160255306,2.0345276175363525,-119.20016283526301,600.0,1000.0},

{-3.8865263545241984,352.8392197229156,19.725426883672263,-123.93485071791932,1000.0,1500.0}};

double avisiC4H10[]={-49.46,2.9001,-6.9665e-4};

double akiC4H10[]={-1.82,1.9396e-2,1.3818e-4};

gasd=new GasData("c4h10",a1C4H10,an1C4H10,0.0, 310.227, -126148, -366.134,agC4H10,avisiC4H10,akiC4H10);

gi.addElement(gasd);

 

//C5H12 Pentane

String a1C5H12[]={"C","H"};

double an1C5H12[]={5.0,12.0};

double agC5H12[][]={{10.47537279006978,347.2273920574338,5.475527472078746,-1.4903882563385604,298.15,400.0},

{9.48091709732139,432.2094818943072,-6.243241658819199,-161.9630722185013,400.0,800.0},

{93.4080455178388,268.7320292805604,-66.34743568985233,-74.10923180265942,800.0,1200.0},

{673.5583799150078,-363.1243160196601,-1518.9458762329887,119.63413321130164,1200.0,1500.0}};

double avisiC5H12[]={-32.02,2.6746,-6.6178e-4};

double akiC5H12[]={-1.82,1.9396e-2,1.3818e-4};

gasd=new GasData("c5h12",a1C5H12,an1C5H12,0.0, 349.055, -146440.0,-463.726,agC5H12,avisiC5H12,akiC5H12);

gi.addElement(gasd);

//Methyl alchohol

gasd=new GasData("ch3oh" ,

3,

"C", 1.0,

"H", 4.0,

"O", 1.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 236.18430709999998, -202004.0883, -130.033557,

4.312301000000001, 128.8080122, 4.538382800000001, -44.1320047, 298.15, 1000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

2,

-0.516332857142899,0.0340285714285715,

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

2,

-6.08281828193834,0.0747356828193833,

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

//Octane

gasd=new GasData("c8h18" ,

2,

"C", 8.0,

"H", 18.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 463.67, -208450.0, -860.8053691,

43.5039997, 596.9648062000001, -12.840608900000001, -204.5830955, 298.15, 1100.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

//sulphure oxide

gasd=new GasData("so2" ,

2,

"S", 1.0,

"O", 2.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

2, 0.0, 248.212, -296842.0, 0.0,

26.246422300000003, 52.1830288, 0.23026850000000001, -23.6171747, 298.15, 600.0,

56.1980741, 1.5323322, -28.8296162, -0.10048080000000001, 600.0, 6000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

//sulphure oxide

gasd=new GasData("so3" ,

2,

"S", 1.0,

"O", 3.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 256.812178, -396019.953, -83.5955,

57.1819486, 27.364271199999997, -12.9201562, -7.7328349, 298.15, 2000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c2h2" ,

2,

"C", 2.0,

"H", 2.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 200.9783468, 226877.27300000002, 58.9261745,

43.6547209, 31.6723855, -7.5109398, -6.3135436, 298.15, 2000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c6h6",

2,

"C", 6.0,

"H", 6.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 269.2, 82930.0, -156.8120805,

5.9911677, 333.99399250000005, -10.3327756, -128.6321708, 298.15, 1100.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

3,

1.23300588215128,0.0184121136424449,9.93835432861289E-6,

0.0,0.0,0.0,0.0,0.0,0.0,0.0,

3,

-3.40024196295058,0.0147238437229216,1.10679653679683E-4,

0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("h2o2" ,

2,

"H", 2.0,

"O", 2.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 233.031722, -136193.351, -103.0536913,

52.33375, -11.890228, -11.890228, 0.0, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("nh3" ,

2,

"N", 1.0,

"H", 3.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

2, 0.0, 192.33, -46190.0, -99.32885906,

25.8110055, 31.6430786, 0.3516828, 0.0, 298.15, 800.0,

52.756606700000006, 10.466750000000001, -63.7676277, 0.0, 800.0, 2000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

//H2 hydrogen

String a1H2[]={"H"};

double an1H2[]={2.0};

double agH2[][]={{11.508997060028037,98.68272534099832,0.8241443728964292,-146.47147075487408,298.0,300.0},

{33.54524867881161,-12.210857124598489,-1.7456396844212596,10.074433281107176,300.0,500.0},

{31.07421577186371,-5.175597133082082,-0.8173138337326622,4.402304012148266,500.0,900.0},

{23.245582828841485,6.364182202934712,10.028643525215026,-0.40789312258308535,900.0,1300.0},

{19.853650144919794,10.069197699685896,18.50185307134015,-1.5475969619464518,1300.0,1700.0},

{22.835676520106627,7.6718371700950065,4.755713445416609,-1.0046084800067425,1700.0,2100.0},

{30.352200255524124,2.974004438611988,-52.78955672686392,-0.17609364991614967,2100.0,2500.0},

{25.659289152360312,5.3827829284053985,0.7811937079565058,-0.5258834350203144,2500.0,2900.0},

{34.71737612162783,1.0392087292970071,-116.88770293127145,0.0612075951047709,2900.0,3300.0},

{28.90471608012268,3.2516100869344826,2.216884622217297,-0.17588732290115694,3300.0,3700.0},

{36.98294018253396,0.4036399461542716,-192.06577611506046,0.1074211307913159,3700.0,4100.0},

{28.996598415560683,3.120853048671733,10.125384478047936,-0.1517777515076703,4100.0,4500.0},

{15.010891525111804,7.314051049897713,472.37023762718,-0.5056691131905932,4500.0,4900.0},

{25.828874378877703,4.500032863027445,0.005431634761202251,-0.30000241688308116,4900.0,5300.0},

{23.072963880407887,5.550008760318859,0.0018172978589971332,-0.40000059734707977,5300.0,5700.0},

{70.70655920176688,-5.0080120092273255,-2851.542125388009,0.2563184222347695,5700.0,6000.0}};

double avisiH2[]={2.20821838055369,0.506980026395776,-0.00138019011996754,3.33648388844839E-6,-4.91516640898999E-9,4.34474801305987E-12,-2.25000324346063E-15,6.28027257836331E-19,-7.28348681229068E-23};

double akiH2[]={-20.9811386435507,1.0769371545451,-0.00238706110811684,5.26186077214256E-6,-7.66004998358933E-9,6.96248035011081E-12,-3.72842468870476E-15,1.0718592543995E-18,-1.27416628164376E-22};

gasd=new GasData("h2",a1H2,an1H2,8467.0, 130.680, 0.0, 0.0,agH2,avisiH2,akiH2);

gi.addElement(gasd);

 

//H2O water

String a1H2O[]={"H","O"};

double an1H2O[]={2.0,1.0};

double agH2O[][]= {{33.25219299471233,-1.0869505509180986,0.008208296694573765,7.341909343373295,298.15,300.0},

{29.127982455916964,10.642631579636186,1.0294736842726413,1.4596491222299655,300.0,600.0},

{28.614236360226595,11.633818187977187,1.4779112757087844,0.8887272696365881,600.0,900.0},

{20.67445214275589,23.667018373867247,11.817719563378859,-4.2552424729714575,900.0,1200.0},

{21.062298962123926,23.636712701413288,9.150276226727847,-4.370687536734363,1200.0,1500.0},

{28.4294045026366,17.271641842703737,-20.103000227106183,-2.823733595529846,1500.0,1800.0},

{68.24107462328517,-10.868431006571445,-255.91068842346112,2.768388650083263,1800.0,2100.0},

{40.774906547136936,8.54664742403356,-95.39757782957692,-1.0740716000341166,2100.0,2400.0},

{49.09712023197981,4.001668755141955,-178.6652037738798,-0.3741838176465953,2400.0,2700.0},

{47.350183036793105,4.838335259198056,-155.96769448925178,-0.4871349368102726,2700.0,3000.0},

{22.862611949396502,15.071698808412426,257.4720951420907,-1.687834381261323,3000.0,3300.0},

{71.73415069240694,-4.939901334465408,-609.020787455237,0.6191920201717109,3300.0,3600.0},

{16.896014001174215,15.071639543545274,616.331910421964,-1.4377749857397182,3600.0,3900.0},

{44.832973602779845,4.900008694425029,7.200713395655248E-4,-0.40000080507270447,3900.0,4200.0},

{66.77089094701616,-2.0483286778929077,-647.6993536717218,0.21886930519675468,4200.0,4500.0},

{22.058555285120306,11.023111331243765,904.2458034027555,-0.8563440815820761,4500.0,4800.0},

{58.540090945293436,-0.8300245055902843,-0.003708282834432604,0.20000185661338735,4800.0,5100.0},

{88.95693496151813,-7.7427849226775365,-1659.465414568823,0.6313100171911288,5100.0,5400.0},

{53.492469225072156,1.1798872466161838,-0.024061429165222848,7.618581743311251E-6,5400.0,5700.0},

{4.320975506094123,12.292662124088588,2851.4546890275697,-0.7062959921419553,5700.0,6000.0}};

double avisiH2O[]={0.620039710415251,0.236733467320225,3.34578658760477E-4,-2.81676758094982E-7,8.57370742701562E-11};

double akiH2O[]={9.79578978098437,-0.00571790459190282,1.36242662282321E-4,-4.13488699966119E-8,-1.06237803964109E-12};

gasd=new GasData("h2o",a1H2O,an1H2O,9904.0, 188.834, -241826.0, -44.4206,agH2O,avisiH2O,akiH2O);

gi.addElement(gasd);

//H2O liquid water

gasd=new GasData("h2ol",a1H2O,an1H2O,9904.0, 188.834, -285830.0, -163.3037062,agH2O,avisiH2O,akiH2O);

gi.addElement(gasd);

//Argonne

String a1Ar[]={"Ar"};

double an1Ar[]={1.0};

double agAr[][]= {{20.786,0.0,0.0,0.0,298.15,6000.0}};

double avisiAr[]={449.97,6.3892,-1.2455e-3};

double akiAr[]={5.48,4.3869e-2,-6.8141e-6};

gasd=new GasData("Ar",a1Ar,an1Ar,6197.0, 154.845, 0.0, 0.0,agAr,avisiAr,akiAr);

gi.addElement(gasd);

 

//Neon(Ne)

String a1Ne[]={"Ne"};

double an1Ne[]={1.0};

double agNe[][]= {{20.786,0.0,0.0,0.0,298.15,6000.0}};

double avisiNe[]={1029.64,7.46,-1.36e-3};

double akiNe[]={13.79,1.2156e-1,-2.359e-5};

gasd=new GasData("Ne",a1Ne,an1Ne,6197.0, 146.327, 0.0, 0.0,agNe,avisiNe,akiNe);

gi.addElement(gasd);

 

//Helium

String a1He[]={"He"};

double an1He[]={1.0};

double agHe[][]= {{20.786,0,0,0,298.15,300.0}};

double avisiHe[]={710.94,4.43,-5.18e-4};

double akiHe[]={55.16,0.3254,-2.2723e-5};

gasd=new GasData("He",a1He,an1He,6197.0, 126.152, 0.0, 0.0,agHe,avisiHe,akiHe);

gi.addElement(gasd);

 

//CO carbonmonoxide

String a1CO[]={"C","O"};

double an1CO[]={1.0,1.0};

double agCO[][]={{29.9205747410865,-5.857911893698358,-0.03436248863675908,11.242703308410146,298.15,600.0},

{21.798528619473394,15.773128646252683,3.1399020513756226,-4.703393122536725,600.0,1200.0},

{31.712560558812783,4.050247315107531,-18.375308854233488,-0.779302343859673,1200.0,1800.0},

{36.7639085598263,0.3080039274849798,-46.362285207728334,0.007279613719967338,1800.0,2400.0},

{36.0344294025623,0.7403471812239162,-39.644078347464664,-0.06646239530096253,2400.0,3000.0},

{44.42559437722321,-2.7419046751032567,-183.94638535769303,0.34007916921517595,3000.0,3600.0},

{35.68189681606468,0.6805556205217947,-11.414285702918633,-0.038613183648017045,3600.0,4200.0},

{31.96834727998243,1.7740104137947827,115.54985801872436,-0.1292535537128194,4200.0,4800.0},

{37.091496752003394,0.21408915426868896,-45.83131440620033,0.0037822967024921487,4800.0,5400.0},

{66.44086791496446,-6.657433993349859,-1630.4083119146712,0.4561198202097833,5400.0,6000.0}};

double avisiCO[]={32.9320014410821,0.540487664029441,-1.94231975194201E-4};

double akiCO[]={-0.703939786390105,0.0979611147468075,-4.74566421217897E-5,1.63643716760022E-8};

gasd=new GasData("co",a1CO,an1CO,8671.0, 197.653, -110527.0, 89.32885906,agCO,avisiCO,akiCO);

gi.addElement(gasd);

 

//CO2 carbondioxide

String a1CO2[]={"C","O"};

double an1CO2[]={1.0,2.0};

double agCO2[][]={{18.276706282416832,74.82477157094694,0.38856362687164314,-44.469285173789494,298.15,600.0},

{37.48163407256464,25.37750383533334,-9.564104908722078,-7.59294240291845,600.0,1200.0},

{54.2441495167402,5.688598866114662,-46.68918618060732,-1.0313672317827667,1200.0,1800.0},

{61.95600656165789,0.2133924240182685,-93.57979591701138,0.07705248586505074,1800.0,2400.0},

{64.44414785053367,-0.9348654207303824,-125.98141956149136,0.22105373564026365,2400.0,3000.0},

{54.03437906222963,3.4974045113144783,52.20468173408244,-0.3197326873376619,3000.0,3600.0},

{60.16831618749666,1.0255575960742063,-57.78487799411432,-0.040940477914796894,3600.0,4200.0},

{44.24802864693779,5.756787720823266,475.28309378855755,-0.4361858557540068,4200.0,4800.0},

{27.9758385005928,8.469281789736105,1605.257228378785,-0.5078985005049036,4800.0,5400.0},

{59.80715208813105,0.809939448821011,-10.134673926652594,0.008846836870534143,5400.0,6000.0}};

double avisiCO2[]={-1.76629106344796,0.565126210250838,-1.88532276569092E-4,-7.70475550981309E-8,2.30189515042086E-10,-1.99872708748364E-13,8.45339311929731E-17,-1.70181078916019E-20,1.30133178850726E-24};

double akiCO2[]={-0.486468351507844,0.0201726161151732,2.43958455766759E-4,-6.07514098761129E-7,8.97577413703562E-10,-7.57474509212984E-13,3.4138182475368E-16,-7.42167095733084E-20,6.10863784559108E-24};

gasd=new GasData("co2",a1CO2,an1CO2,9364.0, 213.795, -393522.0, 3.174080176,agCO2,avisiCO2,akiCO2);

gi.addElement(gasd);

 

//Hydrogen (mono)

String a1H[]={"H"};

double an1H[]={1.0};

double agH[][]={{20.78600000003579,-2.4703047048195125E-10,-1.556979010200628E-12,4.4655867513281294E-10,100.0,300.0},

{20.786,-0.0,0.0,-0.0,300.0,500.0},

{20.785999999435816,1.1125372558673235E-9,3.9877240953477097E-10,-6.024125844745859E-10,500.0,900.0},

{20.786000001781677,-2.190249897617117E-9,-3.3935454007877633E-9,7.501195476450939E-10,900.0,1300.0},

{20.78600004413201,-3.949789462541935E-8,-1.6075248951540484E-7,9.891993765242304E-9,1300.0,1700.0},

{20.786000080564456,-5.678907877278107E-8,-4.758770889432171E-7,1.1223022154358398E-8,1700.0,2100.0},

{20.786000379665534,-2.207725355326006E-7,-3.305429651753591E-6,3.602865736975677E-8,2100.0,2500.0},

{20.785999161529638,4.1504904268587394E-7,1.0091475740925011E-5,-5.769347852218818E-8,2500.0,2900.0},

{20.786001419835554,-6.11814904047925E-7,-2.2576564619932536E-5,7.405959991971421E-8,2900.0,3300.0},

{20.7860040700615,-1.552409242876826E-6,-8.26622760901873E-5,1.663802289959326E-7,3300.0,3700.0},

{20.785992204881286,2.6676408129711367E-6,1.9677338069154962E-4,-2.565668758827146E-7,3700.0,4100.0},

{20.786020751550463,-6.44004303776823E-6,-6.372356663386651E-4,5.617629655071869E-7,4100.0,4500.0},

{20.785972676762054,7.756464070379164E-6,0.0010030567097288013,-6.18963417488674E-7,4500.0,4900.0},

{20.78600659097283,-1.7239775520501291E-6,-2.8506441108473854E-4,1.2677012953362603E-7,4900.0,5300.0},

{20.786,-0.0,0.0,-0.0,5300.0,5700.0},

{20.784701741479516,2.959728794547439E-4,0.07396829556225161,-1.8973543716107073E-5,5700.0,6000.0}};

double avisH[]={};

double akH[]={};

gasd=new GasData("h",a1H,an1H,9364.0, 213.795, -393522.0, 3.174080176,agH,avisH,akH);

gi.addElement(gasd);

 

gasd=new GasData("ho" ,

2,

"H", 1.0,

"O", 1.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 183.754263, 38978.177, 0.0,

26.711146, 3.935498, 1.8421480000000001, 0.0, 298.15, 3000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

//OH hydrogen oxide

gasd=new GasData("oh" ,

2,

"O", 1.0,

"H", 1.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 183.754263, 38978.177, 0.0,

26.711146, 3.935498, 1.8421480000000001, 0.0, 298.15, 3000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

0,

 

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

//N nitrogen (mono)

String aN[]={"N"};

double anN[]={1.0};

double agN[][]={{20.78600000003579,-2.4703047048195125E-10,-1.556979010200628E-12,4.4655867513281294E-10,298.15,300.0},

{20.786,-0.0,0.0,-0.0,300.0,500.0},

{20.785999999435816,1.1125372558673235E-9,3.9877240953477097E-10,-6.024125844745859E-10,500.0,900.0},

{20.786000001781677,-2.190249897617117E-9,-3.3935454007877633E-9,7.501195476450939E-10,900.0,1300.0},

{20.78600004413201,-3.949789462541935E-8,-1.6075248951540484E-7,9.891993765242304E-9,1300.0,1700.0},

{21.75232378273957,-0.729726125145615,-5.134098515965546,0.15635704129163225,1700.0,2100.0},

{22.814301742082968,-1.4139490737537606,-12.583195270808268,0.2796564669768139,2100.0,2500.0},

{27.15326928896284,-3.679942558607097,-59.88255775910829,0.6129170450631107,2500.0,2900.0},

{22.996858458228868,-1.805301788848111,1.3616018258518974,0.3741141752535037,2900.0,3300.0},

{28.939805045753065,-4.235325312197047,-105.3470984588738,0.654738513443109,3300.0,3700.0},

{8.59743196853106,2.9656684425612445,377.2857633508066,-0.06306446471221766,3700.0,4100.0},

{2.8513340936207947,4.440046820788396,604.6952714651944,-0.16131665688062374,4100.0,4500.0},

{20.418949238610825,-0.7676462396903804,7.234142850933034,0.2741090191145416,4500.0,4900.0},

{-15.164229223555038,8.886370962550062,1443.0002097391666,-0.46314081768837695,4900.0,5300.0},

{-6.249447617562528,6.495632362147724,1079.546349292798,-0.2833620888287191,5300.0,5700.0},

{-37.95881561013834,13.79761450774053,2851.442785717294,-0.756292939939889,5700.0,6000.0}};

double avisN[]={-4.92854013060778,0.379062761757185,-1.48297458234132E-4};

double akN[]={-17.3496859087276,0.117899036192513,3.9952428877858E-5};

gasd=new GasData("n",aN,anN,6197.0, 153.3,472683.0,57.4979,agN,avisN,akN);

gi.addElement(gasd);

//N2 nitrogen

String a1[]={"N"};

double an1[]={2.0};

double ag[][]={{29.555385254879834,-3.232642098568939,-0.019052612012152012,6.224236424391002,298.15,400.0},

{23.988366007007876,9.959151874366158,2.417913410404676,-1.4254648553558849,400.0,900.0},

{25.86164354664174,9.448074436200576,-3.782953765636655,-2.232690628715062,900.0,1500.0},

{32.88912500566657,2.803699246843971,-27.35073189104521,-0.4604684103153939,1500.0,2100.0},

{35.9796232107348,0.749609529291484,-48.70788838331627,-0.07328997910652715,2100.0,2700.0},

{36.175006858688064,0.6214704973224496,-49.66177442961639,-0.050856017292492346,2700.0,3300.0},

{35.978446045142014,0.6414315086898076,-40.934634506230836,-0.046214975739819024,3300.0,3900.0},

{40.933267819293036,-0.9995199973148224,-176.40761457591654,0.10733882875920711,3900.0,4500.0},

{35.901894859933094,0.4422039657867144,5.059559515400795,-0.008831649055007006,4500.0,5100.0},

{48.26707554027542,-2.8182573871402785,-514.3623038423627,0.23188115973340007,5100.0,6000.0}};

double avisi[]={-7.01963701225759,0.858327699273598,-0.00112340740644438,1.4031330184525E-6,-1.2471558843147E-9,7.37784281928769E-13,-2.73840279340566E-16,5.73795735055663E-20,-5.15666835382267E-24};

double aki[]={2.74464219691575,0.032560938823238,5.61143449732873E-4,-2.65097510427981E-6,6.32147739080813E-9,-8.64030177972148E-12,6.79049143882341E-15,-2.84261270585969E-18,4.90168626035256E-22};

gasd=new GasData("n2",a1,an1,8670.0, 191.609, 0.0, 0.0,ag,avisi,aki);

gi.addElement(gasd);

 

//N2O nitrous oxide

 

String a1N2O[]={"N","O"};

double an1N2O[]={2.0,1.0};

double agN2O[][]={{15.837110028852324,101.32295061832228,0.42693515072762644,-88.97569216943455,298.15,300.0},

{26.93733205723148,51.414330656572076,-1.2470246298122536,-25.279690315250523,300.0,500.0},

{33.71154666891525,33.893107466367915,-4.365757875026845,-12.344506937030982,500.0,900.0},

{47.268091632128886,13.342109526471981,-22.256741109167688,-3.518970176699781,900.0,1300.0},

{55.526163663506814,4.63115258384996,-44.441326099452056,-0.9277940383139889,1300.0,1700.0},

{58.95788389269775,1.875898150831236,-60.28483183774019,-0.30483553016304854,1700.0,2100.0},

{61.39080223760698,0.3635055797829293,-79.18435123843624,-0.03914029895191969,2100.0,2500.0},

{61.968264520604386,0.10843834710077724,-87.48017278927178,-0.008275209931395957,2500.0,2900.0},

{67.75447468582628,-2.387775454987395,-179.41613527289036,0.2944681304547475,2900.0,3300.0},

{68.54576575596501,-2.4120985971773767,-219.56214104742463,0.2630271359608437,3300.0,3700.0},

{58.40082721848299,1.32853151936952,3.4233137111722534,-0.12588944546646244,3700.0,4100.0},

{68.9804219902619,-2.0650510420059036,-302.350369906387,0.1806607387213082,4100.0,4500.0},

{59.87290102371135,0.6650280974215728,0.0036334325796401417,-0.050002242184440465,4500.0,4900.0},

{43.571862736617554,4.880691410250632,721.5010832217938,-0.3565708451220564,4900.0,5300.0},

{39.346287573804545,5.5882481292750725,1052.3767809879173,-0.3815757218842709,5300.0,5700.0},

{110.6384327586923,-11.011843301430144,-2851.250044974605,0.7062435015838048,5700.0,6000.0}};

 

double avisN2O[]={56.8,5.56,-1.52e-3};

double akN2O[]={-6.03,7.9837e-2,-2.2582e-6};gasd=new GasData("n2o",a1N2O,an1N2O,8670.0, 191.609, 0.0, 0.0,agN2O,avisN2O,akN2O);

gi.addElement(gasd);

 

//NO nitrous oxide

String a1NO[]={"N","O"};

double an1NO[]={1.0,1.0};

double agNO[][]={{33.06470671449779,-21.269110442793636,0.1026056059465571,33.814850059272956,298.15,300.0},

{28.507125706890548,-1.910010933766341,0.8796716480496226,10.329468963512923,300.0,500.0},

{20.88783380194883,19.818962109277045,3.6622151511843333,-7.105271267053868,500.0,900.0},

{29.078203580684043,7.623159755846156,-7.50631411577063,-1.9634586588537664,900.0,1300.0},

{33.690127460043215,2.767724467164074,-19.916980809037497,-0.5228637571051207,1300.0,1700.0},

{35.914942110580476,0.972421145071174,-30.047821068952494,-0.11535487198801654,1700.0,2100.0},

{35.630599922571434,1.1186351436273005,-26.804248923987185,-0.13716665788909274,2100.0,2500.0},

{36.24984852360516,0.7222442919725142,-30.722509087178683,-0.06765783393781291,2500.0,2900.0},

{30.95445483518726,2.948196840764959,57.08222809827734,-0.32971790219504904,2900.0,3300.0},

{45.69448274798853,-2.9554888576114995,-217.3452749936191,0.33713985024094534,3300.0,3700.0},

{35.677990670013585,0.7550031927700818,2.355376917162876E-4,-0.05000030705973665,3700.0,4100.0},

{25.94191460810105,3.7354659632323846,307.41191382316293,-0.3065486024002062,4100.0,4500.0},

{36.06493973218778,0.5523564588393092,7.234491873390216,-0.02589119621658216,4500.0,4900.0},

{53.158071826453174,-3.9456742877261006,-721.4982551467294,0.3065695855710619,4900.0,5300.0},

{77.55947637936835,-9.51930284480678,-2077.6235714544623,0.6613780891303459,5300.0,5700.0},

{36.96629516334837,0.2503886625369599,0.09713346015991346,-2.4915430046628612E-5,5700.0,6000.0}};

double avisNO[]={399.21,5.37,-1.24e-3};

double akNO[]={1.176,8.2369e-2,-1.2527e-5};

gasd=new GasData("no",a1NO,an1NO,9192.0, 210.758, 90291.0, 12.37967,agNO,avisNO,akNO);

gi.addElement(gasd);

//NO2 nitrous oxide

String a1NO2[]={"N","O"};

double an1NO2[]={1.0,2.0};

double agNO2[][]={{30.419923243284725,11.225237094199722,0.1390454891208037,34.30987956466868,298.15,300.0},

{19.921680843699797,59.02956040729965,1.6972946376188907,-27.63618400208032,300.0,500.0},

{28.848490105757726,39.49277293939486,-3.5348251857339785,-15.902440139629013,500.0,900.0},

{47.91656245271523,9.580241573373653,-26.978524463494757,-2.632374842229869,900.0,1300.0},

{54.474733246326196,2.5901777651945257,-44.296533425196515,-0.5295203017786501,1300.0,1700.0},

{55.13591297729685,1.9132431089811635,-45.45011377174848,-0.34628381516520473,1700.0,2100.0},

{56.58720071029509,0.8390041741077551,-52.789560684444204,-0.12609360674120293,2100.0,2500.0},

{59.7899744913188,-0.8243441472968078,-88.26135593922417,0.11760816477075853,2500.0,2900.0},

{53.84513463399024,1.8603047653007985,-1.3614919754626995,-0.22411453553239902,2900.0,3300.0},

{60.0560843947667,-0.7319336562853527,-107.5638901859376,0.08062564961588378,3300.0,3700.0},

{55.07972953620507,1.0620373359889947,6.844732024315181,-0.1017764186838601,3700.0,4100.0},

{45.984660050930906,3.7900255821883704,302.3478504245785,-0.33065851794542844,4100.0,4500.0},

{69.51209150538168,-3.2187249332900496,-486.8341733577374,0.25744839073064635,4500.0,4900.0},

{56.84496641251348,0.3407614078545906,-10.031482069155562,-0.02411035883176773,4900.0,5300.0},

{77.04348184804368,-4.527210522151548,-1038.8240434598433,0.3056930747009306,5300.0,5700.0},

{106.74448120689875,-11.042538272516868,-2851.4237326034468,0.7062880528910391,5700.0,6000.0}};

double avisNO2[]={-3723.75,23.3,-2.15e-2};

double akNO2[]={-1.289,1.039e-3,-2.1445e-5};

gasd=new GasData("no2",a1NO2,an1NO2,10186.0, 240.034, 33095.0, -60.919,agNO2,avisNO2,akNO2);

gi.addElement(gasd);

 

String a1O2[]={"O"};

double an1O2[]={2.0};

double agO2[][]= {{30.305755822163935,-10.352619250900608,-0.04124905757934241,24.80919470401675,298.15,400.0},

{21.73823802392653,21.77728379736334,1.7215387678229244,-8.887428759810007,400.0,900.0},

{34.33935065648359,2.0739035871871834,-14.19063346816028,-0.12274342219881462,900.0,1500.0},

{34.67209682250057,1.3999685587069723,-12.479224285702216,0.14514066645504695,1500.0,2100.0},

{30.608215911885633,4.036835018896909,16.23660518345336,-0.3366870911487245,2100.0,2700.0},

{29.202919299351393,4.755091788061779,32.570802685442125,-0.4406584681618593,2700.0,3300.0},

{35.72121669008157,2.0894866817313353,-83.44273263314227,-0.13363223742712027,3300.0,3900.0},

{50.138103318271845,-2.838815671528686,-450.82334702070494,0.3409807885889686,3900.0,4500.0},

{62.98478913313546,-6.667708777572803,-878.1963372568249,0.6616642463832294,4500.0,5100.0},

{72.03150695415353,-9.063361371002015,-1258.0392013089024,0.8397325265327471,5100.0,6000.0}};

double avisiO2[]={-15.2819046089901,1.05385147522418,-0.00162349107208735,2.77516859994582E-6,-3.58520001415248E-9,3.10021571553767E-12,-1.65985810687716E-15,4.93745323575399E-19,-6.2166840764683E-23};

double akiO2[]={-2.03305576203544,0.123232902604801,-1.32156973422579E-4,1.04767440853954E-7,1.6553201252612E-10,-5.17627201737314E-13,5.42871301595178E-16,-2.63481619947786E-19,4.95504765460086E-23};

gasd=new GasData("o2",a1O2,an1O2,8683.0, 205.147, 0.0, 0.0,agO2,avisiO2,akiO2);

gi.addElement(gasd);

 

gasd=new GasData("c13h14" ,

2,

"C", 13.0,

"H", 14.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 458.652985, 74734.95, -530.0544936,

-88.31529408682678, 165.66543787164608, 77.8608819804265, -78.97214484658718, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-9.52155989786263E-5,0.15628268325122008,8.114118471214127E-5,-1.4711331646150363E-7,6.051462492706506E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-2.5254297320032038E-8,0.006452688081481028,9.885440756107755E-5,-5.612413577285591E-8,1.4002260608926413E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("c14h16" ,

2,

"C", 14.0,

"H", 16.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 497.61521653438, 53091.261437494, -627.6287726,

-116.9412128116458, 222.35898099153994, 97.04327375888522, -105.48554284478324, 298.15, 1500.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-9.52155989786263E-5,0.15628268325122008,8.114118471214127E-5,-1.4711331646150363E-7,6.051462492706506E-11,

0.0,0.0,0.0,0.0,0.0,

5,

-2.5254297320032038E-8,0.006452688081481028,9.885440756107755E-5,-5.612413577285591E-8,1.4002260608926413E-11,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

gasd=new GasData("e-" ,

0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

1, 0.0, 0.0, 0.0, 0.0,

0.0, 0.0, 0.0, 0.0, 298.15, 9000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

1,

0.0,

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

1,

0.0,

0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

 

//C3H8 Propane

gasd=new GasData("c3h8" ,

2,

"C", 3.0,

"H", 8.0,

"H", 0.0,

"H", 0.0,

"H", 0.0,

3, 0.0, 269.91, -103850.0, -269.6644295,

-3.0254338120284023, 291.88950251744706, 0.41963902408606885, -119.49421908824642, 298.15, 600.0,

38.22001198694175, 200.09504665335731, -26.459448251559852, -60.24847920688976, 600.0, 1000.0,

153.50146875641366, 52.633258329935245, -239.92959900787577, -6.760646801711672, 1000.0, 1500.0,

-3.0254338120284023, 291.88950251744706, 0.41963902408606885, -119.49421908824642, 1500.0, 6000.0,

0.0,0.0,0.0,0.0,0.0,0.0,

0.0,0.0,0.0,0.0,0.0,0.0,

4,

-4.54983515889651,0.322705572359441,-1.38531691344012E-4,6.96141593360938E-8,

0.0,0.0,0.0,0.0,0.0,0.0,

5,

-8.26855601111686,0.0560941709538814,1.09756835344882E-4,-1.07698643777443E-8,3.47288739672947E-13,

0.0,0.0,0.0,0.0,0.0 );

gi.addElement(gasd);

 

int i;

String aName;

double aNN;

ierror=1;

N=Nnew;

Enumeration<GasData> n1=gi.elements();

while(n1.hasMoreElements())

{

   gasd=n1.nextElement();

   s+=gasd.gasName+" ";

   if (gasd.gasName.equals(gName)) {ierror=0;break;}

}

gasName=gasd.gasName;

natom=gasd.natom;

atomList=new Atom[natom];

M=0;

for(i=0;i<natom;i++)

 {

 aName=gasd.aName[i];

 aNN=gasd.aN[i];

 atomList[i]=new Atom(aName,aNN);

 M+=atomList[i].mass;

 }

n_equation=gasd.n_equation;

h0=gasd.h0;

s0=gasd.s0;

hf=gasd.hf;

sf=gasd.sf;

gf=hf-298.15*sf;

xa=new double[n_equation];

xb=new double[n_equation];

xc=new double[n_equation];

xd=new double[n_equation];

tl=new double[n_equation];

th=new double[n_equation];

for(i=0;i<n_equation;i++)

  {

    xa[i]=gasd.xa[i];

    xb[i]=gasd.xb[i];

    xc[i]=gasd.xc[i];

    xd[i]=gasd.xd[i];

    tl[i]=gasd.tl[i];

    th[i]=gasd.th[i];

  }

n_vis=gasd.n_vis;

xvis=new double[n_vis];

for(i=0;i<n_vis;i++)

  {

  xvis[i]=gasd.xvis[i];

  }

n_k=gasd.n_k;

xk=new double[n_k];

for(i=0;i<n_k;i++)

  {

  xk[i]=gasd.xk[i];

  }

return s;

}

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

// root solving function

double fp(double Pri,double ti)

{              return pr(ti)-Pri;}

 

public double Ti(double Pri)

{

// Pri : reduced pressure

// Pi pressure

double a=298.0;

double b=1500.0;

// brent metodu ile kök değerini bulur

double test;

double p=0;

double es,ea;

double f1,f2,f3,fp;

int maxit=500,iter=0;

double tol=1.0e-10;

es=0.001;

double x1=a;f1=fp(Pri,x1);

double x2=b;f2=fp(Pri,x2);

double x3=(x1+x2)/2.0;f3=fp(Pri,x3);

if(f1==0) return x1;

else if(f2==0) return x2;

else if(f3==0) return x3;

p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

fp=fp(Pri,p);

ea=Math.abs(x3-p);

while((ea>es)&&(iter<maxit))

{              if(Math.abs(f3)<tol) return x3;

    if((p<x1) && (p>x2))

    {p=(x1+x2)/2.0;   

     if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

     else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    }

    else

    {       

    if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

    else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

    fp=fp(Pri,p);

    ea=Math.abs(x3-p);

    }

    iter++;

}

if(iter>=maxit) JOptionPane.showMessageDialog(null,"Uyarı maximum iterasyon sayısı aşıldı \n"+

   " çözüm geçerli olmıyabilir","MAKSİMUM ITERASYON SAYISI UYARISI",JOptionPane.WARNING_MESSAGE);

return p;

}

 

double fv(double vri,double ti,double vi)

{   double pi=P(ti,vi);   

                double a[]=property(ti,pi);

                return a[18]-vri;

}

public double Tvi(double vri,double vi)

{

                double xl=250.0;

                double xu=1200.0;

//bisection root finding method

double test;

double xr=0;

double es,ea;

double fxl,fxr;

int maxit=100,iter=0;

es=0.0000001;

ea=1.1*es;

while((ea>es)&&(iter<maxit))

{

    xr=(xl+xu)/2.0;

    iter++;

    if((xl+xu)!=0)

        { ea=Math.abs((xu-xl)/(xu+xl))*100;}

    fxl= fv(vri,xl,vi);// f.func(xl);

    fxr= fv(vri,xr,vi);//f.func(xr);

    test= fxl*fxr;

    if(test==0.0)      ea=0;

    else if(test<0.0)  xu=xr;

    else              {xl=xr;}

}

if(iter>=maxit) JOptionPane.showMessageDialog(null,"Maximum number of iteration is exceeded \n"+

   " result might not be valid","MAKSİMUM NUMBER OF ITERATION WARNING",JOptionPane.WARNING_MESSAGE);

return xr;

}

 

}

 

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

 

 

Atom.java: properties of atoms

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

// Thermodynamic Package in java

// Class Atom

// Properties of single atom

// -----------------------------------------------------

// Dr. Turhan Coban

// TUBITAK Ulusal Metroloji Enstitüsü, Gebze KOcaeli, Turkey

// email : Turhan.Coban@ume.tubitak.gov.tr

// -----------------------------------------------------

// File Name   : Atom.java

// This file contains the atom class

// this class sets basic properties of requested atoms

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

 

import java.io.*;

import java.util.*;

 

class Atom

{

public int  number;            // atomic number

public String name;            // name of the the atom

public String symbol;          // symbol of the atom

public double mass;            // mass of the atom

public double N;               // number of the atoms

public int s[]=new int[7];

public int d[]=new int[7];

public int p[]=new int[7];

public int f[]=new int[7];

String atom_name[];

String atom_symbol[];

public Atom()

{

//empty constructor

number=0;

symbol="";

name="";

mass=0;

N=1;

}

 

public Atom(String st1, double NN)

{ getAtom(st1,NN); }

 

public Atom(String st1, int NN)

{ getAtom(st1,(double)NN); }

 

public Atom(String st1)

{ getAtom(st1,1.0); }

 

public Atom(Atom  a)

{ assign(a); }

 

public Atom(Atom  a, double NN)

{ assign(a); N=NN; }

 

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

 

public void getAtom(String st1,double NN)

{

// this constructor will load Atom data from a given atom name

// or atom symbol and number of atoms

// type

String atom_name1[]={"Hydrogen", "Helium", "Lithium", "Berylium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Florine",

 "Neon", "Sodium", "Magnesium", "Aliminium", "Silicon", "Phosphourus", "Sulphur", "Chlorine", "Argon", "Potassium",

 "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc",

 "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Kyrpton", "Rubidium", "Strontium","Yttirum", "Zirconium",

 "Niobium", "Molybdenium", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin",

 "Anthimony", "Tellerium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium",

 "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium",

 "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinium", "Gold", "Mercury", "Thallium",

 "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium","Protactinium","Uranium",

 "Neptunium","Plutonium","Americium","Curium","Berkelium","Californium","Einsteinium","Fermium","Mendelevium","Nobelium",

 "Lawrencium","Rutherfordium","Dubnium","Seaborgium","Bohrium","Hassium","Meithnerium","Ununnilium","Unununium","Ununbium",

 "null","Ununquadium","null","Ununhexium"};

atom_name=atom_name1;

String atom_symbol1[]= {"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Ag", "P", "S", "Cl", "Ar",

 "K", "Ca", "Se", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Si", "Br", "Kr", "Ru", "Sr", "Yt",

 "Zr", "Nb", "Mo", "Tc", "Sm", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb","Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd",

 "Pm", "Sc", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl",

 "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No",

 "Lr","Rf","Db","Sg","Bh","Hs","Mt","Uun","Uuu","Uub","null","Uuq","null","Uuh"};

double atom_mass[]= {1.00794, 4.002602, 6.941, 9.012182, 10.811, 12.0107, 14.00674, 15.9994, 18.9984032, 20.1797, 22.989770,

 24.305, 26.981539, 28.0855, 30.973762, 32.066, 35.4527, 39.938, 39.0983, 40.078, 44.95591, 47.88, 50.9415, 51.9961, 54.93805,

 55.587, 58.9332, 58.69, 63.546, 65.39, 69.723, 72.61, 74.92159, 78.96, 79.904, 83.8, 85.4678, 87.62, 88.90585, 91.224, 92.90638,

 95.94, 98.0, 101.007, 102.9055, 106.42, 107.8682, 112.411, 114.82, 118.71, 121.75, 127.6, 126.90447, 131.29, 132.90543, 137.327,

 138.9055, 140.115, 140.90765, 144.24, 145.0, 150.36, 151.965, 157.25, 158.92534, 162.5, 164.93032, 167.26, 168.93421, 173.04,

 174.967, 178.49, 180.9479, 183.85, 186.207, 190.2, 192.22, 195.08, 196.96654, 200.59, 204.3833, 207.2, 208.98037, 209.0, 210.0,

 222.0, 223.0, 226.0, 227.0, 232.0381, 231.0, 238.0289, 237.0, 244.0, 243.0, 247.0, 247.0, 251.0, 252.0, 257.0, 258.0, 259.0,

 260.0,261.0,262.0,263.0,262.0,265.0,268.0,281.0,272.0,285.0,0.0,289.0,0.0,292.0 };

atom_symbol=atom_symbol1;

 double electron[][]={{}

                    };

 

 for(int atom_number=1;atom_number<=116;atom_number++)

   {

      if(st1.equals(atom_name[atom_number-1]) || st1.equals(atom_symbol[atom_number-1]) )

      {

      N=NN;

      number=atom_number;

      name=atom_name[atom_number-1];

      symbol=atom_symbol[atom_number-1];

      mass=atom_mass[atom_number-1]*N;

      break;

      }

   }

}

 

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

public void assign(Atom  a)

{

number=a.number;

name=a.name;

symbol=a.symbol;

mass=a.mass;

N=a.N;

}

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

//boolean equals logical comparisons

public boolean equals(String s)

{

boolean b;

if(name.equals(s) || symbol.equals(s))

  return true;

else

  return false;

}

 

public boolean equals(int n)

{

boolean b;

if(number==n)

  return true;

else

  return false;

}

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

 

//this ostream function will send the symbol+number of atoms to cout

public String toString1()

{

String st=symbol;

return st;

}

public String toString()

{

String st=symbol;

if(N != 1.0)

   if(N==Math.floor(N))  st = st + (int)N;

   else                  st = st + N;

return st;

}

}

 

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

 

GasData.java

public class GasData extends Object

{

//this file reads and store

public String gasName;

public int natom;

public String aName[];

public double aN[];

public int n_equation;

public double xa[],xb[],xc[],xd[],tl[],th[];

public int n_vis;

public double xvis[];

public int n_k;

public double xk[];

public double h0; // enthalpy at T=298 K

public double s0; // enthrophy at 298 K

public double hf; // enthalpy of formation

public double sf; // entropy of formation    kJ/kmol K

 

public GasData(String igasName,String ianame[],double ia[],

double ih0,double iso,double ihf,double isf,

double ixa[][],double ixvis[],double ixk[])

{

gasName=igasName;

natom=ianame.length;

aName=new String[natom];

aN=new double[natom];

for(int i=0;i<natom;i++) {aName[i]=ianame[i];aN[i]=ia[i];}

//n_equation=ixa[0].length;h0=ih0;s0=iso;hf=ihf;sf=isf;

n_equation=ixa.length;h0=ih0;s0=iso;hf=ihf;sf=isf;

xa=new double[n_equation];

xb=new double[n_equation];

xc=new double[n_equation];

xd=new double[n_equation];

tl=new double[n_equation];

th=new double[n_equation];

for(int i=0;i<n_equation;i++)

{ 

 xa[i]=ixa[i][0];

 xb[i]=ixa[i][1];

 xc[i]=ixa[i][2];

 xd[i]=ixa[i][3];

 tl[i]=ixa[i][4];

 th[i]=ixa[i][5];

}

 

n_vis=ixvis.length;

xvis=new double[n_vis];

for(int i=0;i<n_vis;i++)

{xvis[i]=ixvis[i];}

 

n_k=ixk.length;;

xk=new double[n_k];

for(int i=0;i<n_vis;i++)

{xk[i]=ixk[i];}

}

 

public GasData(String igasName,

           int inatom,

           String ianame1,double ia1,

           String ianame2,double ia2,

           String ianame3,double ia3,

           String ianame4,double ia4,

           String ianame5,double ia5,

           int inequation, double ih0,double iso,double ihf,double isf,

           double ixa1,double ixb1,double ixc1,double ixd1, double itl1, double ith1,

           double ixa2,double ixb2,double ixc2,double ixd2, double itl2, double ith2,

           double ixa3,double ixb3,double ixc3,double ixd3, double itl3, double ith3,

           double ixa4,double ixb4,double ixc4,double ixd4, double itl4, double ith4,

           double ixa5,double ixb5,double ixc5,double ixd5, double itl5, double ith5,

           double ixa6,double ixb6,double ixc6,double ixd6, double itl6, double ith6,

           int invis,

           double ixvis1,double ixvis2,double ixvis3,double ixvis4,double ixvis5,double ixvis6,

           double ixvis7,double ixvis8,double ixvis9,double ixvis10,

           int ink,

           double ixk1,double ixk2,double ixk3,double ixk4,double ixk5,double ixk6,

           double ixk7,double ixk8,double ixk9,double ixk10)

{

gasName=igasName;

natom=inatom;

aName=new String[5];

aN=new double[5];

aName[0]=ianame1;

aN[0]=ia1;

aName[1]=ianame2;

aN[1]=ia2;

aName[2]=ianame3;

aN[2]=ia3;

aName[3]=ianame4;

aN[3]=ia4;

aName[4]=ianame5;

aN[4]=ia5;

n_equation=inequation;h0=ih0;s0=iso;hf=ihf;sf=isf;

xa=new double[6];

xb=new double[6];

xc=new double[6];

xd=new double[6];

tl=new double[6];

th=new double[6];

xa[0]=ixa1;xa[1]=ixa2;xa[2]=ixa3;xa[3]=ixa4;xa[4]=ixa5;xa[5]=ixa6;

xb[0]=ixb1;xb[1]=ixb2;xb[2]=ixb3;xb[3]=ixb4;xb[4]=ixb5;xb[5]=ixb6;

xc[0]=ixc1;xc[1]=ixc2;xc[2]=ixc3;xc[3]=ixc4;xc[4]=ixc5;xc[5]=ixc6;

xd[0]=ixd1;xd[1]=ixd2;xd[2]=ixd3;xd[3]=ixd4;xd[4]=ixd5;xd[5]=ixd6;

tl[0]=itl1;tl[1]=itl2;tl[2]=itl3;tl[3]=itl4;tl[4]=itl5;tl[5]=itl6;

th[0]=ith1;th[1]=ith2;th[2]=ith3;th[3]=ith4;th[4]=ith5;th[5]=ith6;

n_vis=invis;

xvis=new double[10];

xvis[0]=ixvis1;xvis[1]=ixvis2;xvis[2]=ixvis3;xvis[3]=ixvis4;xvis[4]=ixvis5;

xvis[5]=ixvis6;xvis[6]=ixvis7;xvis[7]=ixvis8;xvis[8]=ixvis9;xvis[9]=ixvis10;

 

n_k=ink;

xk=new double[10];

xk[0]=ixk1;xk[1]=ixk2;xk[2]=ixk3;xk[3]=ixk4;xk[4]=ixk5;

xk[5]=ixk6;xk[6]=ixk7;xk[7]=ixk8;xk[8]=ixk9;xk[9]=ixk10;

}

public String k_toString()

{String s=gasName+" ";

n_k=xk.length;;

for(int i=0;i<n_k;i++)

{s+=xk[i]+" ";}

return s;

}

public String vis_toString()

{String s=gasName+" ";

n_vis=xvis.length;;

for(int i=0;i<n_vis;i++)

{s+=xvis[i]+" ";}

return s;

}

}

 

Gmix.java Thermodynamic and thermophysical properties of ideal gas mixtures

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

// File Name    : Gmix.java

// Author       : Dr. Turhan Coban

// EGE University, School of engineering

// Department of Mechanical Engineering, bornova, izmir, TURKEY

// email        : Turhan.Coban@ege.edu.tr

// Description  : This file contains class gmix which  calculates

// thermophysical properties of mixture of perfect gases.

//               following properties can be calculated

//               T()     : Temperature degree K

//               h(T)    : enthalpy  KJ/kmol

//               hf      : formation enthalpy KJ/kg

//               ht(T)   : total enthalpy KJ/kg (h+hf)

//               M       : molar mass kg/kmol

//               HT(T)   : total enthalpy KJ : M*ht(T)

//               P()     : presure bar

//               s(T,P)  : entropy KJ/kmol K

//               Cp(T)   : specific heat at constant pressure KJ/kmol K

//               Cv(T)   : specific heat at constant volume KJ/kg K

//               gamma(T): adiabatic constant Cp/Cv

//               c(T)    : speed of sound m/s

//               u(T)    : Internal energy KJ/kmol

//               vis(T)  : viscosity

//               k(T)    : thermal conductivity KW/kg K

// DATA FILE DEFINATION

// gas mixture definations are given the data file "Gmix.txt"

// if gas mixture data is not given in the Gmix.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

//-------------------

// and defination : gmix a(gmixName); will defined this gas mixture

// the same mixture can be defined directly in the main program as :

// -------------------

// Gas a_0=new Gas("a_0");

//.......

// Gas a_ngas=new Gas("a_ngas);

// Gmix a=new Gmix;

// a=N_0*a_0+...+N_ngas*a_ngas;

// -------------------

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

//  VARIABLE IDENTIFICATION

// all the variables that type is not defined is a double variable

// PUBLIC  VARIABLES :

// gasName  : String class variable of gas mixture name

// ngas     : int variable, number of simple gasses

// N   : total molar mass of the gas mixture

// gasList  :gas class vector variables

// All the other variables defined for class gas is also valid for gmix

import java.io.*;

import java.net.*;

import java.util.*;

import javax.swing.*;

 

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

   class Gmix extends absfluid{

// this class calculates perfect gas thermodynamic

// properties when the perfect gas constitutes of

// several single gases

        boolean mole=true;

        boolean SI=true;

        public int ngas;  // number of simple gasses inside of the gas mixture

        String gasName;

        public double M;  // molar mass of atom kg/kmol

        public double h0; // enthalpy at T=298 K

        public double hf; // enthalpy of formation

        public double sf; // entropy of formation    kJ/kmol K

        public double N;  // moles of gas kmol

        int ierror;

        int natom;          //number of unique atoms in the atom list

        Gas  gasList[];     //list of the component gasses

        Atom atomList[];    //list of component atoms

        File gmixFile;      // File name and directory

        BufferedReader cfin;

        // construction methods :

//========definations of class gmix =============================

//constructor functions

                public Gmix(String name) throws IOException

                {

        // class complex gas construction function

        // this function reads the initial gases in

                // the mixture and their molar weight from

        // the file Gmix.txt and construct mixed gas

      ierror=1;

      try{

      //cfin=new BufferedReader(new FileReader("data"+java.io.File.separator+"Gmix.txt"));

      cfin=new BufferedReader(new FileReader("Gmix.txt"));

        int i,j;

        N=0;

                M=0;

        hf=0;

        natom=0;

                try{

                while(cfin!=null)

                {

                gasName=Text.readString(cfin);

                //System.out.println("gasName=*"+gasName+"*name=*"+name+"*");

                if(gasName.equals(name)) { ierror=0; break;}

    }

    }  catch(EOFException e_eof)

    {

     System.out.println("error required gas mixture "+name+" is not found");

     cfin.close();return;

    }

     //cfin>>ngas;

     ngas=Text.readInt(cfin);

        gasList=new Gas[ngas];

                    //ierror=0;

        String pgasName;

        double ppercent;

        Gas tempgas;

                for(i=0;i<ngas;i++)

        {

        pgasName=Text.readString(cfin);

        ppercent=Text.readDouble(cfin);

        //System.out.println(pgasName+" "+ppercent+"ierror="+ierror);

       

        //cfin>>pgasName>>ppercent;

        tempgas=new Gas(pgasName,ppercent);

        //ierror=tempgas.ierror;

        {

        if(ierror!=1)

          {

                      try{

             gasList[i]=new Gas(tempgas);

             gasList[i].mole=true;

             } catch(IOException ioe) {System.out.println("IOException");}

                           N+=tempgas.N;

                           M+=tempgas.N*tempgas.M;

                      hf+=tempgas.N*tempgas.hf;

                      }

        else

          {

                      System.out.println("gas is not found in the list ierror="+ierror);

          System.out.println("this gas is not added to the list");

                      i--;

          ngas--;

          }

      }

      }

      M=M/N;

      hf=hf/N;

      arrange_atoms();

   } catch(FileNotFoundException fnfe) {System.out.println("File not found");}

   base("mole");

   }

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

   public Gmix() throws IOException

   {

   //empty construction function

   N=0;

   M=0;

   String pgasname="\0";

   ngas=0;

   base("mole");

   }

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

                public Gmix(Gmix g1) throws IOException

                {

                gasName=g1.gasName;

                N=g1.N;

                M=g1.M;

        hf=g1.hf;

                ngas=g1.ngas;

        natom=g1.natom;

                gasList=new Gas[ngas];

                for(int i=0;i<ngas;i++) gasList[i]=new Gas(g1.gasList[i]);

        for(int i=0;i<natom;i++) atomList[i]=new Atom(g1.atomList[i]);

    base("mole");   

    }

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

    public Gmix(Gas g1[])

                {

        N=0;

                M=0;

        hf=0;

        natom=0;

        ngas=g1.length;

        gasList=new Gas[ngas];

        String pgasName;

        double ppercent;

                    for(int i=0;i<ngas;i++)

        {    gasList[i]=g1[i];

                         N+=gasList[i].N;

                         M+=gasList[i].N*gasList[i].M;

                         hf+=gasList[i].N*gasList[i].hf;

                     }

      M=M/N;

      hf=hf/N;

      arrange_atoms();

      base("mole");

   }

    public Gmix(String name,String n1[],double N1[])

                {

        gasName=name;

                               N=0;

                M=0;

        hf=0;

        natom=0;

        ngas=n1.length;

        gasList=new Gas[ngas];

        String pgasName;

        double ppercent;

                    for(int i=0;i<ngas;i++)

        {    gasList[i]=new Gas(n1[i],N1[i]);

                         N+=gasList[i].N;

                         M+=gasList[i].N*gasList[i].M;

                         hf+=gasList[i].N*gasList[i].hf;

                     }

      M=M/N;

      hf=hf/N;

      arrange_atoms();

      base("mole");

   }

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

 

public String readGmixNames() throws IOException

{  

    String temp=new String("");

    String pgasName;

    double ppercent;

    try{

      //cfin=new BufferedReader(new FileReader("data"+java.io.File.separator+"Gmix.txt"));

      cfin=new BufferedReader(new FileReader("Gmix.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 Gmix.txt not found");}

    return temp;

}

 

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

 

public void arrange_atoms()

{

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)

{

int k;

//Atom tempAtom=new Atom(gasList[i].atomList[j].symbol,gasList[i].atomList[j].N*gasList[i].N/N);

for(k=0;k<natom;k++)

{

//String s0=gasList[i].gasName;

String s1=gasList[i].atomList[j].symbol;

String s2=atomList[k].symbol;

//System.out.println("natom ="+natom+"k = "+k+atomList[k].symbol+"s0="+s0+"s1="+s1+"s2="+s2);

if(s1.equals(s2))

  {

  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;

}

 

 

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

    public void changeN(double newN) throws IOException

                {

                normalise();

                for(int i=0;i<ngas;i++)

                  { gasList[i].N*=newN; }

          N=newN;

                }

 

                public boolean base(String s)

    {

    if(s.equals("mole")) {mole=true;for(int i=0;i<ngas;i++){ gasList[i].mole=true; }}

    else                 {mole=false;for(int i=0;i<ngas;i++){ gasList[i].mole=false;}}

    return mole;

    }

 

    public boolean unit(String s)

    {

    if(s.equals("SI")) {SI=true;for(int i=0;i<ngas;i++){ gasList[i].SI=true; }}

    else               {SI=false;for(int i=0;i<ngas;i++){ gasList[i].SI=false; }}

    return SI;

    }

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

                public void add(Gas g1) throws IOException

                {

                // this function adds a single gas to the mixture

        int gasflag=1;

        // if the gas exist in the list simply change N and M values

                for(int i=0;i<ngas;i++)

                {

                if(gasList[i].gasName.equals(g1.gasName))

                   {

                   gasflag=0;

           M=M*N+g1.M*g1.N;

                   gasList[i].N+=g1.N;

           N+=g1.N;

           M=M/N;

           }

                }

                if(gasflag!=0)

          {

                  Gas newGas[];

                  newGas=new Gas[ngas+1];

                  for(int i=0;i<ngas;i++)

                  {

                  newGas[i]=new Gas(gasList[i]);

                  }

                  ngas++;

                  double MT=M*N+g1.M*g1.N;

                  N+=g1.N;

                  M=MT/N;

                  newGas[ngas-1]=new Gas(g1);

                  gasList=newGas;

          }

        arrange_atoms();

        }

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

                public void remove(String name) throws IOException

                {

                // this function removes a  single gas

                // from the list

    int i,k;

                for(i=0;i<ngas;i++)

                  {

                    if(gasList[i].gasName.equals(name))

                      {

                                Gas newGas[];

                                   newGas=new Gas[ngas];

                M=0;

                N=0;

                               for(k=0;k<i;k++)

                               { newGas[k]=new Gas(gasList[k]);

                                 M+=newGas[k].M*newGas[k].N;

                                 N+=newGas[k].N;

                               }

                               for( k=i;k<(ngas-1);k++)

                               {

                                 newGas[k]=new Gas(gasList[k+1]);

                                 M+=newGas[k].M*newGas[k].N;

          N+=newGas[k].N;

                               }

                               M=M/N;

                      ngas--;

                    gasList=newGas;

                    break;

                      }

                  }

        arrange_atoms();

        // correct dynamic memory size

                }

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

                public void add(String name,double Nnew) throws IOException

                {

                // this function adds a single gas to the mixture

        Gas g1=new Gas(name,Nnew);

        int gasflag=1;

        // if the gas exist in the list simply change N and M values

                for(int i=0;i<ngas;i++)

                {

                if(gasList[i].gasName.equals(g1.gasName))

                   {

                   gasflag=0;

           M=M*N+g1.M*g1.N;

                   gasList[i].N+=g1.N;

           N+=g1.N;

           M=M/N;

           }

                }

                if(gasflag!=0)

          {

                  Gas newGas[];

                  newGas=new Gas[ngas+1];

                  for(int i=0;i<ngas;i++)

                  {

                  newGas[i]=new Gas(gasList[i]);

                  }

                  ngas++;

                  double MT=M*N+g1.M*g1.N;

                  N+=g1.N;

                  M=MT/N;

                  newGas[ngas-1]=new Gas(g1);

                  gasList=newGas;

          }

        arrange_atoms();

        }

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

 

                public void   simplify() throws IOException

                {

                // this function combines any  single gas

                // that repeated in the list

        double ngasold=ngas;

    int i,j,k;

                for(i=0;i<ngas;i++)

                  {

                  for(j=i+1;j<ngas;j++)

                    {

                    if(gasList[i].gasName.equals(gasList[j].gasName))

                      {

                      gasList[i].N+=gasList[j].N;

                      for(k=j;k<(ngas-1);k++)

                        { gasList[k]=new Gas(gasList[k+1]); }

                      ngas--;

                      }

                    }

                  }

        // correct dynamic memory size

                if(ngasold!=ngas)

        {

                Gas newGas[];

                newGas=new Gas[ngas];

                for(i=0;i<ngas;i++)

                  {

          newGas[i]=new Gas(gasList[i]);

                  }

                gasList=newGas;

                }

        }

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

public void  normalise() throws IOException

{

for(int i=0;i<ngas;i++)

  {

  gasList[i].N=gasList[i].N/N;

  }

N=1.0;

arrange_atoms();

}

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

public void changeMix(double Nmix[]) throws IOException

   {

   // this function changes

                // all the molar weights in the mixture

   N=0;

   M=0;

                for(int i=0;i<ngas;i++)

   {

   gasList[i].N=Nmix[i];

   N+=Nmix[i];

   M+=Nmix[i]*gasList[i].M;

   }

   M=M/N;

   arrange_atoms();

                }

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

  public double  vis(double T)

   {

   // dynamic viscosity of the mixture

   // note that viscosity of the mixture IS NOT the simple addition

   // of viscosity of component gasses

      double vmix=0;

   for(int i=0;i<ngas;i++)

     {

     T=T;

     double fij;

     double xj=0;

     double p1;

     double c1,c2,c3;

     for(int j=0;j<ngas;j++)

       {

       double vratio;

       double xi=gasList[i].M/gasList[j].M;

       if(gasList[j].vis(T)!=0)

         {

                     c1=gasList[i].vis(T)/gasList[j].vis(T);

                     vratio=Math.sqrt(c1);

                     }

       else

                     vratio=0;

                   c2=Math.pow(xi,0.25);

                   p1=(1+vratio/c2);

                   c3=8.0+8.0*xi;

                   fij=p1*p1 / Math.sqrt(c3);

       xj+=fij*gasList[j].N/N;

       }

     vmix+=gasList[i].N/N*gasList[i].vis(T)/xj;

     }

   return vmix;

   }

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

   public double  k(double T)

   {

   // thermal conductivity of the mixture

   // note that thermal conductivity  of the mixture IS NOT the

   // simple addition of the thermal conductivity  of component gasses

   double vmix=0;

   for(int i=0;i<ngas;i++)

     {

     T=T;

     double fij;

     double xj=0;

     double p1;

     double c1,c2,c3;

     for(int j=0;j<ngas;j++)

       {

       double vratio;

       double xi=gasList[i].M/gasList[j].M;

       if(gasList[j].k(T)!=0)

           {

                        c1=gasList[i].k(T)/gasList[j].k(T);

//           if(c1<0) System.out.println("negative c1 value ");

                        vratio=Math.sqrt(c1);

                       }

       else

                       vratio=0;

       c2=Math.pow(xi,0.25);

       p1=(1+vratio/c2);

       c3= 8.0+8.0*xi;

//       if(c2<0) System.out.println(" negative c2 value ");

       fij=p1*p1/Math.sqrt(c3);

       xj+=fij*gasList[j].N/N;

       }

     vmix+=gasList[i].N/N*gasList[i].k(T)/xj;

     }

   return vmix;

   }

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

   public double  Prandtl(double T)

   {

   // Prandtl number

   double Pr=0;

   if(mole) Pr=Cp(T)*vis(T)/k(T)/M*1e3;

   else     Pr=Cp(T)*vis(T)/k(T);

   return Pr;

   }

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

   public double  h(double T)

   {

   //specific enthalpy of the mixture KJ/kmol

   double HH=0;

   for(int i=0;i<ngas;i++)

                { HH+=gasList[i].h(T)*gasList[i].N; }

                return HH/N;

   }

   public double T(double h){    

                               //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_bracket(h);        

                                 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=h(x1)-h;

                                               fh=h(x2)-h;

                                               //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=h(rtf)-h;

                                                               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[][]  T_bracket(double h){

                               // 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?         

                                               int n=10;

                                               int nbb=1;

                                               int nb;                                    

                                               int i;

                                               double x,fp,fc,dx;

                                               double x1=273.15;

                                               double x2=3000;

                                               double xb[][]=new double[2][nbb];

                                               nb=0;

                                               dx=(x2-x1)/n;

                                               x=x1;

                                               //System.out.println("===========================bracket basladi===================================");

                                               fp=h(x1)-h;

                                               //System.out.println("x1= "+x1+" fp= "+fp);

                                               for (i=1;i<=n;i++)

                                               {

                                                               x+=dx;

                                                               fc=h(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("===========================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;

                                 }

                               return xb;   

   }

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

   public double  ht(double T)

   {

   //specific  enthalpy of the mixture ht=h+hf

   // hf : formation enthalpy

   double HH=0;

   for(int i=0;i<ngas;i++)

                { HH+=gasList[i].ht(T)*gasList[i].N; }

   return HH/N;

   }

   public double st( double t,double p)

   {

   double sf1=sf;

   double s1,sref;

   double Tref=298.15,Pref=1.0;

   if(!SI) {Tref=536.67;sf1*=0.238846;Pref=14.503684;}

   s1=s(t,p);

   sref=s(Tref,Pref);

   double sst=s1-sref+sf1;

   if(!mole) sst/=M;

   return sst;

   }

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

   public double  H(double t)

   {

   //total enthalpy of the mixture KJ

   return h(t)*N;

   }

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

   public double  HT(double t)

   //total enthalpy of the mixture HT=N*(h+hf)  KJ

   {

   return ht(t)*N;

   }

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

   public double  u(double T)

   {

   // specific internal energy of the mixture  KJ/kmol

   double UU=0;

   for(int i=0;i<ngas;i++)

                { UU+=gasList[i].u(T)*gasList[i].N; }

   return UU/N;

   }

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

public double g(double T,double P)

{

  return h(T)-T*s(T,P);

}

 

public double gt(double T,double P)

{

  return ht(T)-T*st(T,P);

}

 

public double gt(double T)

{

  double Pref=1.0;

  return ht(T)-T*st(T,Pref);

}

 

 

public double g(double T)

{

  double Pref;

  if(!SI) {Pref=14.503684;}

  else {Pref=1.0;}

  return h(T)-T*s(T,Pref);

}

 

public double G(double T,double P)

{

 return g(T,P)*N;

}

 

public double G(double T)

{

 return g(T)*N;

}

 

public double GT(double T)

{

 return gt(T)*N;

}

 

public double GT(double T,double P)

{

 return gt(T,P)*N;

}

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

   public double  Cp(double T)

   {

   // Specific energy at constant pressure  KJ/kmol K

   double C=0;

                for(int i=0;i<ngas;i++)

                { C+=gasList[i].Cp(T)*gasList[i].N; }

   return C/N;

   }

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

   public double  Cv(double T)

   //Specific energy at constant volume  KJ/kmol K

   {

   double C=0;

   for(int i=0;i<ngas;i++)

                { C+=gasList[i].Cv(T)*gasList[i].N; }

   return C/N;

   }

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

   public double  gamma(double T)

   {

   //adiabatic constant

   return Cp(T)/Cv(T);

   }

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

   public double  c(double T)

   //speed of sound m/s

   {

   return Math.sqrt(8314.5/M*T*gamma(T));

   }

      public double alfa(double T,double P)

   { return k(T)*v(T,P)/Cp(T);}

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

   public double  s(double T, double P)

   {

   //specific entropy KJ/kmol K

   double SS=0;

   for(int i=0;i<ngas;i++)

   {SS+=gasList[i].s(T,P)*gasList[i].N;}

   return SS/N;

   }

 

   public double  s(double T)

   {

   //specific entropy KJ/kmol K

   double SS=0;

   double s2;

   for(int i=0;i<ngas;i++)

                {s2=gasList[i].N*gasList[i].s(T);

                 SS+=s2;

                }

   return SS/N;

                }

               

public double  s0(double T)

{return s(T);}

  

public double pr(double T)

{

double Tref, Rref;

  if(!SI) {Tref=491.67;Rref=1.986;}

  else {Tref=298.15;Rref=8.3145;}

  if(!mole) Rref/=M;

  double s1=s0(T);

  double s2=s0(Tref);

  double s3=Math.exp((s1-s2)/Rref);

  //System.out.println("s1="+s1+"s2="+s2+"s3="+s3);

  return s3;

}

 

public double vr(double T)

{

  double Rref;

  if(!SI) {Rref=1.986;}

  else {Rref=8.3145;}

  return (Rref/M)*T/pr(T)*10;

}

 

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

   public double  v(double T, double P)

   {

   double VV=0;

   for(int i=0;i<ngas;i++)

                { VV+=gasList[i].v(T,P)*gasList[i].N; }

   return VV/N;

   }

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

public double  T( char name,double y0,double p)

{

double t=300;

if(name=='v') {t= p*1e5*y0/8.314e3;}

else

  {

  double dt;

  int nmax=400;

  double tolerance=1.0e-8;

  for(int i=0;i<nmax;i++)

    {

    if     (name=='h') dt=-( h(t)   - y0 ) /Cp(t);

    else if(name=='u') dt=-( u(t)   - y0 ) /Cv(t);

    else if(name=='s') dt=-( s(t,p) - y0 ) /(Cp(t)/t);

                 else { System.out.println("wrong name defined please try h,u,s ot v"); break;}

    t+=dt;

    if(Math.abs(dt)<tolerance) break;

    }

  }

return t;

}

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

public double  P( char name,double y0,double t1)

{

if(name=='v')       return 8.314e3*t1/y0*1e-5;

else if (name=='s') return Math.exp((s(t1,1.0)-y0)/8.314);

else { System.out.println("wrong name defined please try s or v"); return 1.0;}

}

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

public void  multiplyassign(double Nx)

{

                for(int i=0;i<ngas;i++)

                  { gasList[i].N*=Nx; }

                N*=Nx;

}

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

public void addassign(Gas g1) throws IOException

{

                // this function adds a single gas to the mixture

        int gasflag=1;

        // if the gas exist in the list simply change N and M values

                for(int i=0;i<ngas;i++)

                {

                if(gasList[i].gasName==g1.gasName)

                   {

                   gasflag=0;

           M=M*N+g1.M*g1.N;

                   gasList[i].N+=g1.N;

           N+=g1.N;

           M=M/N;

           }

                }

                if(gasflag!=0)

          {

                  Gas newGas[];

                  newGas=new Gas[ngas+1];

                  for(int i=0;i<ngas;i++)

                  {

                  newGas[i]=new Gas(gasList[i]);

                  }

                  ngas++;

                  double MT=M*N+g1.M*g1.N;

                  N+=g1.N;

                  M=MT/N;

                  newGas[ngas-1]=new Gas(g1);

                  gasList=newGas;

          }

}

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

public void addassign(Gmix right) throws IOException

{

                // this function adds a gas mixture to the mixture

                for(int i=0;i<right.ngas;i++)

                {

        add(right.gasList[i]);

                }

}

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

public Gmix multiply( double Nx,Gmix right) throws IOException

{

Gmix g1=new Gmix(right);

g1.N*=Nx;

for(int i=0;i<g1.ngas;i++)

  {

  g1.gasList[i].N*=Nx;

  }

return g1;

}

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

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

public Gmix add(Gmix l,Gas r) throws IOException

{

Gmix g1=new Gmix(l);

Gas g2=new Gas(r);

g1.add(g2);

return  g1;

}

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

public Gmix  add(Gas l,Gmix r) throws IOException

{

Gmix g1=new Gmix(r);

Gas g2=new Gas(l);

g1.add(g2);

return g1;

}

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

public Gmix add(Gmix l,Gmix r) throws IOException

{

Gmix g1=new Gmix(l);

for(int i=0;i<r.ngas;i++)

                {

                g1.add(r.gasList[i]);

                }

return g1;

}

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

public void  assign(Gmix g1) throws IOException

{

                gasName=g1.gasName;

                N=g1.N;

                M=g1.M;

                ngas=g1.ngas;

                Gas newGas[];

    newGas=new Gas[ngas];

                for(int i=0;i<ngas;i++) newGas[i]=g1.gasList[i];

        gasList = newGas;

}

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

public void assign(Gas  g1) throws IOException

{

// a single gas is assigned to the mixture

   gasName=g1.gasName;

   N=g1.N;

   M=g1.M;

   ngas=1;

   gasList=new Gas[ngas];

   gasList[0]=new Gas(g1);

}

 

public String toString(String ch)

{

//return the c

String s="";

int i,j;

if(ch.equals("name"))

   s=s+gasName+"\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 String[][] toString1(double v1, double v2)

{

  String s1[][]=new String[19][3];

   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]="g, qibbs free energy         ";

   s1[7][0]="ht,chemical entropy          ";

   s1[8][0]="gt,chemical gibbs f.e.       ";

   s1[9][0]="Cp, specific heat at const P ";

   s1[10][0]="Cv, specific heat at const v";

   s1[11][0]="Cp/Cv, adiabatic constant   ";

   s1[12][0]="c, speed of sound           ";

   s1[13][0]="viscosity                   ";

   s1[14][0]="thermal conductivity        ";

   s1[15][0]="M, molecular weight         ";

   s1[16][0]="Prandtl number              ";

   s1[17][0]="Pr, reduced pressure        ";

   s1[18][0]="vr, reduced volume          ";

 

   if(SI && !mole)

   {

   s1[0][2]=" bars          ";

   s1[1][2]=" deg K         ";

   s1[2][2]=" m^3/kg        ";

   s1[3][2]=" KJ/kg         ";

   s1[4][2]=" KJ/kg         ";

   s1[5][2]=" KJ/kg K       ";

   s1[6][2]=" KJ/kg         ";

   s1[7][2]=" KJ/kg         ";

   s1[8][2]=" KJ/kg         ";

   s1[9][2]=" KJ/kg K        ";

   s1[10][2]=" KJ/kg K       ";

   s1[11][2]="               ";

   s1[12][2]=" m/s           ";

   s1[13][2]=" Ns/m^2        ";

   s1[14][2]=" W/m K         ";

   s1[15][2]=" kg/kmol       ";

   s1[16][2]="               ";

   s1[17][2]="               ";

   s1[18][2]="               ";

   }

   else if(SI && mole)

   {

   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]=" KJ/kmole      ";

   s1[7][2]=" KJ/kmole      ";

   s1[8][2]=" KJ/kmole      ";

   s1[9][2]=" KJ/kmole K    ";

   s1[10][2]=" KJ/kmole K   ";

   s1[11][2]="               ";

   s1[12][2]=" m/s           ";

   s1[13][2]=" Ns/m^2        ";

   s1[14][2]=" W/m K         ";

   s1[15][2]=" kg/kmol       ";

   s1[16][2]="               ";

   s1[17][2]="               ";

   s1[18][2]="               ";

   }

   else if(!SI && mole)

   {

   s1[0][2]=" lbf/in^2, psia  ";

   s1[1][2]=" deg R           ";

   s1[2][2]=" ft^3/lbmole     ";

   s1[3][2]=" BTU/lbmole      ";

   s1[4][2]=" BTU/lbmole      ";

   s1[5][2]=" BTU/lbmole K    ";

   s1[6][2]=" BTU/lbmole      ";

   s1[7][2]=" BTU/lbmole      ";

   s1[8][2]=" BTU/lbmole      ";

   s1[9][2]=" BTU/lbmole K   ";

   s1[10][2]=" BTU/lbmole K   ";

   s1[11][2]="                ";

   s1[12][2]=" ft/s           ";

   s1[13][2]=" lbm/(ft.s)     ";

   s1[14][2]=" BTU/(hr ft R)  ";

   s1[15][2]=" lbm/lbmole     ";

   s1[16][2]="                ";

   s1[17][2]="                ";

   s1[18][2]="                ";

   }

   else if(!SI && !mole)

   {

   s1[0][2]=" lbf/in^2, psia  ";

   s1[1][2]=" deg R           ";

   s1[2][2]=" ft^3/lbm     ";

   s1[3][2]=" BTU/lbm      ";

   s1[4][2]=" BTU/lbm      ";

   s1[5][2]=" BTU/lbm K    ";

   s1[6][2]=" BTU/lbm      ";

   s1[7][2]=" BTU/lbm      ";

   s1[8][2]=" BTU/lbm      ";

   s1[9][2]=" BTU/lbm K    ";

   s1[10][2]=" BTU/lbm K   ";

   s1[11][2]="                ";

   s1[12][2]=" ft/s           ";

   s1[13][2]=" lbm/(ft.s)     ";

   s1[14][2]=" BTU/(hr ft R)  ";

   s1[15][2]=" lbm/lbmole     ";

   s1[16][2]="                ";

   s1[17][2]="                ";

   s1[18][2]="                ";

   }

   double pp[]=property(v1,v2);

   for(int i=0;i<19;i++)

   {s1[i][1]=""+pp[i];}

return s1;

}

public double[] property(double t, double p)

{

double pp[]=new double[19];

pp[0]=p;

pp[1]=t;

pp[2]=v(t,p);

pp[3]=h(t);

pp[4]=u(t);

pp[5]=s(t,p);

pp[6]=g(t,p);

pp[7]=ht(t);

pp[8]=gt(t,p);

pp[9]=Cp(t);

pp[10]=Cv(t);

pp[11]=gamma(t);

pp[12]=c(t);

pp[13]=vis(t);

pp[14]=k(t);

pp[15]=M;

pp[16]=Prandtl(t);

pp[17]=pr(t);

pp[18]=vr(t);

return pp;

}

 

/*

*Implemented methods from fluidInterface class

*/            

                public static absfluid getInstance(String fluidName) throws java.io.IOException {                       

                                return new Gmix(fluidName);   

                }

                public double h_TP(double T,double P) throws GException {

                                               return h(T);           

                }

                public double T(double h,double P) throws GException {

                                               return T(h);           

                }

                public double h_TV(double T,double V) throws GException {

                                               return h(T);           

                }

                public double x(double T,double V)throws GException{

                                               return 2; 

                }

                public double k(double T,double P) throws GException {

                                               return k(T);

                }

                public double vis(double T,double P) throws GException {

                                               return vis(T);      

                }

                public double ro(double T,double P)throws GException{                                                                                                       

            return 1/v(T,P);

    }

    public double cp(double T,double P)throws GException{                                                                                                   

            return Cp(T);                               

                }

                public double sigma(double T,double P) throws GException {

                                               return Double.NaN;

                }

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

//sıfırlamak istediğim fonksiyon

double fp(double Pri,double ti)

{              return pr(ti)-Pri;}

 

public double Ti(double Pri)

{

// Pri : reduced pressure

// Pi pressure

double a=298.15;

double b=2000.0;

// brent metodu ile kök değerini bulur

double test;

double p=0;

double es,ea;

double f1,f2,f3,fp;

int maxit=500,iter=0;

double tol=1.0e-15;

es=0.000000001;

double x1=a;f1=fp(Pri,x1);

double x2=b;f2=fp(Pri,x2);

double x3=(x1+x2)/2.0;f3=fp(Pri,x3);

if(f1==0) return x1;

else if(f2==0) return x2;

else if(f3==0) return x3;

//if(f1*f2>0) System.out.println("verilen bölgede kök yok");

p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

fp=fp(Pri,p);

ea=Math.abs(x3-p);

while((ea>es)&&(iter<maxit))

{              if(Math.abs(f3)<tol) return x3;

    if((p<x1) && (p>x2))

    {p=(x1+x2)/2.0;   

     if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

     else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    }

    else

    {       

    if(p>x3) {x1=x3;f1=f3;x3=p;f3=fp;}

    else if(p<x3) {x2=x3;f2=f3;x3=p;f3=fp;}

    p=-(f2*f3*x1*(f2-f3)+f3*f1*x2*(f3-f1)+f1*f2*x3*(f1-f2))/((f1-f2)*(f2-f3)*(f3-f1));

    fp=fp(Pri,p);

    ea=Math.abs(x3-p);

    }

    iter++;

}

if(iter>=maxit) JOptionPane.showMessageDialog(null,"Uyarı maximum iterasyon sayısı aşıldı \n"+

   " çözüm geçerli olmıyabilir","MAKSİMUM ITERASYON SAYISI UYARISI",JOptionPane.WARNING_MESSAGE);

return p;

}

}//end of class

 

You can make predefined mixtures by using Gmix.txt

kazan1

4

co2 1.072

h2o 2.035

n2 8.57

o2 0.207

 

brayton

4

co2 1.2

h2o 2.2

o2 4.255

n2 24.659

 

yashava1

3

n2 0.79

o2 0.21

h2o 0.002