//======================================================
// java Termodinamik paketi
// Class gylicol
// Dr. Turhan Coban
// Ege Üniversitesi Mühendislik fakultesi
// Makina Bölümü
// 
//======================================================
// Dosya adı   : gylicol.java
// Bu dosya soğutucu akışkanların termodinamik özelliklerini 
//hesaplar

import java.io.*;
import java.net.*;
import java.util.*;

class brine
{
brineData rd;
//=======constroctors=======
public brine()
{ readsogut("Ethylene Gylicol");}

public brine(String rName)
{ readsogut(rName);}

public String readGasNames()
{ String s1=rd.refrigerantName;String s2=readsogut("null");readsogut(s1);return s2;}

public double Tf(double x)
{//freezing temperature
  return 273.15*(rd.A[5][0]*x+rd.A[5][1]*x*x);
}

public double ro(double x,double t)
{ //density 
double T=t+273.15;
double to=273.15/T;
  return rd.A[0][0]+rd.A[0][1]*x+rd.A[0][2]*to+rd.A[0][3]*to*x+rd.A[0][4]*to*to;
}

public double Cp(double x,double t)
{ //specific heat kJ/kgK
double T=t+273.15;
double to=273.15/T;
  return rd.A[1][0]+rd.A[1][1]*x+rd.A[1][2]*to+rd.A[1][3]*to*x+rd.A[1][4]*to*to;
}

public double k(double x,double t)
{ //thermal conductivity W/MK
double T=t+273.15;
double to=273.15/T;
  return rd.A[2][0]+rd.A[2][1]*x+rd.A[2][2]*to+rd.A[2][3]*to*x+rd.A[2][4]*to*to;
}

public double Pr(double x,double t)
{ //Prandtl Number
double T=t+273.15;
double to=273.15/T;
  return Math.exp(rd.A[4][0]+rd.A[4][1]*x+rd.A[4][2]*to+rd.A[4][3]*to*x+rd.A[4][4]*to*to);
}

public double vis(double x,double t)
{ //Viscosity Pa s
double T=t+273.15;
double to=273.15/T;
  return Math.exp(rd.A[3][0]+rd.A[3][1]*x+rd.A[3][2]*to+rd.A[3][3]*to*x+rd.A[3][4]*to*to);
}

//========== reading refrigerant data =============
public String readsogut(String rName)
{
String s="";
Vector gi=new Vector();

rd=new brineData("Ethylene Gylicol","Etilen glikol",
658.49825,  5.36449, 0.83818, -4.63024,  3.96951, -0.06982,
-54.81501,  0.78863,-1.37620, -2.14817,  0.70076, -0.35780,
664.71643, -2.59001,-0.07629,-12.70106,-12.98045,  0.0,
232.72605, -2.73187, 1.07720,  5.40536,  2.64789,  0.0,
-322.61661, 1.43759,-0.20174, 10.98990, 11.58900,  0.0);

try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}

rd=new brineData("Propylene Gylicol","Propilen glikol",
 508.41109, 4.47642, 1.18886, -1.02798,  6.66139, -0.03736,
-182.40820, 0.60863,-1.49110,-10.03298, -6.99440, -0.40050,
 965.76507,-0.71497,-0.69682,-19.93497,-18.55114,  0.0,
 280.29104,-1.93855, 1.13633, 14.65802, 12.04640,  0.0,
-472.22510, 0.47873, 0.06735, 14.62050, 14.47735,  0.0);

try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}

int i;
Enumeration n1=gi.elements();
while(n1.hasMoreElements())
{
   rd=(brineData)n1.nextElement();
   s+=rd.refrigerantName+" ";
   if (rd.refrigerantName.equals(rName)) {break;}
}
return s;
}
}