public class moist_air
{
Gas1 g1=new Gas1("air");
ref_CS3 rfcs=new ref_CS3();
steam st=new steam();	
yashava yh=new yashava();    
//LeeKesler LK1=new LeeKesler("H2O");
final double Ma=29.00;//Molecular mass of dry air
final double Mv=18.00;//Molecular mass of water vapor
final double SA=111;//K
final double SV=961;//K

public double enthalpy_moist(double t,double P,double rh)
{
	// P in bar
	// t in Celcius
    // rh relative humidity
  double[] prop=yh.property1("tdb_rh",t,rh,P);
  double w=prop[5];
  double h=((1.0029+5.4e-5*t)*t)+(2500.84+(1.856+2e-4*t)*t)*w;//kj/kg
  return h;
}	

public double Cp_moist(double t,double P,double rh)
{
double[] prop=yh.property1("tdb_rh",t,rh,P);
double w=prop[5];
return (1.0029+5.4e-5*t)+(1.856+2e-4*t)*w; 	
}

public double ro_moist(double t,double P,double rh)
{
double[] prop=yh.property1("tdb_rh",t,rh,P);
double w=prop[5];	
double ro_m=((1+w)/(461.56*(0.62198+w)))*((P*100000)/(t+273.15));	
return ro_m;
}


public double[] vis_moist(double t,double P,double rh)
{
	
double[] prop=yh.property1("tdb_rh",t,rh,P);
double w=prop[5];	
double T=t+273.15;
double cc=647.27/T;
double vis_air=(0.40401+(0.074582*T)-(5.7171e-5*T*T)+(2.9928e-8*T*T*T)-(6.2524e-12*T*T*T*T))/1e6;
double nomin=Math.sqrt(1/cc);
double denomin=0.0181583+(0.0177624*cc)+(0.0105287*cc*cc)-(0.0036744*cc*cc*cc);
double vis_v=(nomin/denomin)*1e-6;
double xm=1.61*w; 
double fiav=Math.pow((1+(Math.sqrt(vis_air/vis_v)*Math.pow((Mv/Ma),0.25))),2)/((2.82842712)*Math.sqrt(1+(Ma/Mv)));
double fiva=Math.pow((1+(Math.sqrt(vis_v/vis_air)*Math.pow((Ma/Mv),0.25))),2)/((2.82842712)*Math.sqrt(1+(Mv/Ma)));
double vis=(vis_air/(1+fiav*xm))+(vis_v/(1+fiva/xm));
double[] depo=new double[3];
depo[0]=vis_air;   
depo[1]=vis_v;   
depo[2]=vis;   

return depo;
}
	


public double k_moist(double t,double P,double rh)
{
double[] prop=yh.property1("tdb_rh",t,rh,P);
double w=prop[5];
double T=t+273.15;	
double ka=2.43714e-2+(7.83035e-5*t)-(1.94021e-8*t*t)+(2.85943e-12*t*t*t)-(2.61420e-14*t*t*t*t);
double kv=1.74822e-2+(7.69127e-5*t)-(3.23464e-7*t*t)+(2.59524e-9*t*t*t)-(3.17650e-12*t*t*t*t);	
double[] prp=g1.property(T,P);	
double kair=prp[14];
//double[] stprop=property_SI("tp",t,p);
//double[] LKprop =LK1.property_SI("tp",T,P);//T in Kelvin P in bar
//double kv1=LKprop[14];
double[] vist=vis_moist(t,P,rh);
double visair=vist[0];
double visvap=vist[1];
double SAV=0.733*Math.sqrt(SA*SV);
double alfa_av=(visair/visvap)*Math.pow((Mv/Ma),0.75)*((1+SA/T)/(1+SV/T));
double beta_av=(1+SAV/T)/(1+SA/T);
double AAV=0.25*alfa_av*beta_av;
double alfa_va=(visvap/visair)*Math.pow((Ma/Mv),0.75)*((1+SV/T)/(1+SA/T));
double beta_va=(1+SAV/T)/(1+SV/T);
double AVA=0.25*alfa_va*beta_va;
double wm=1.61*w;
double k=(ka/(1+AAV*wm))+(kv/(1+AVA/wm)); 
return k;
}

public double Pr(double t,double P,double rh)
{
double k=k_moist(t,P,rh);
double cp=Cp_moist(t,P,rh)*1000;
double[] viss=vis_moist(t,P,rh);
double vs=viss[2];
return vs*cp/k;
}


public static void main(String args[])	
{
double t=40;//C
double P=3.01325;//bar	
double rh=0.65;//bağıl nem
	
moist_air ma=new moist_air();	
double ww=ma.enthalpy_moist(t,P,rh);	
double cp=ma.Cp_moist(t,P,rh);
double rov=ma.ro_moist(t,P,rh);
double[] propp=ma.yh.property("tdb_rh",t,rh,P);
double ro =1/propp[2];
double[] vis=ma.vis_moist(t,P,rh);
double viss=vis[2];
double kc=ma.k_moist(t,P,rh);
double pr=ma.Pr(t,P,rh);
System.out.println("Nemli hava entalpi = "+ww+" kJ/kg");	
System.out.println("Nemli hava cp = " +cp+" kJ/kg");
System.out.println("Nemli hava yoğunluk = "+rov+" kg/m3");
System.out.println("Nemli hava ısı iletim kat = "+kc+" W/mK");
System.out.println("Nemli hava Prandtl = "+ pr);	
System.out.println("Nemli hava viskozite = "+ viss+" Pa.s");
}	
	
	
	
	
}