import javax.swing.*;

public class absorbtion_water_lithiumbromide1 
{
double m1,m2,m3;
double qg;         // heat transfer in generator
double qc;         // condenser heat transfer
double qa;         // absorber heat transfer
double qe;         // evaporator heat transfer
double qhe;        //heat exchanger heat transfer
double COP;        // etkinlik katsayısı
double t0m,t2m;
double v1,ro1,P1,P2;
double h0,h1,h2,h3,h4,h5,h6,h7,h8,h9;
double x1,x2;
double wpump;
// m1 mass flow rate pump exit generator inlet, weak mixture
// m2 generator exit - through pressure drop valve to absorber, strong mixture
// m3 exit generator, through condenser, through expansion valve, through evaporator to absorber //pure water-steam
public absorbtion_water_lithiumbromide1(double mpump,double t_generator,double t_condenser,double t_absorber, double t_evaporator,double t_heatexchanger)
{
water_lithiumbromide_mix wlb=new water_lithiumbromide_mix();
m1=mpump;
x1=wlb.X(t_absorber,t_evaporator);
x2=wlb.X(t_generator,t_condenser);
m2=m1*x1/x2;
m3=m1-m2;
h0=wlb.h_ltw(t_absorber,x1);
h2=wlb.h_ltw(t_heatexchanger,x1);
t0m=wlb.t_l(t_absorber,x1);
t2m=wlb.t_l(t_generator,x2);
P1=wlb.P(t0m);
P2=wlb.P(t2m);
ro1=wlb.ro_lt(t_absorber,x1);
v1=1/ro1;
wpump=v1*(P2-P1);
h1=h0+wpump;
double dh1=(h2-h1);
qhe=m1*dh1;
h3=wlb.h_ltw(t_generator,x2);
h4=h3-qhe/m2;
double st[]=wlb.steam_property("tx",t_generator,1.0);
h5=st[3];
double st1[]=wlb.steam_property("tx",t_condenser,0.0);
h6=st1[3];
h7=h6;
double st2[]=wlb.steam_property("tx",t_evaporator,1.0);
h8=st2[3];
qg=m3*h5+m2*h3-m1*h2;   // heat transfer in generator
qc=m3*h5-m3*h6;         // condenser heat transfer
qa=m2*h4+m3*h6-m1*h0;   // absorber heat transfer
qe=m3*h8-m3*h7;         // evaporator heat trasfer
COP=qe/qg;
}
public String toString()
{String s="";
s+="zayıf karışım kütlesel yüzdesi x1="+x1+"\n";
s+="kuvvetli karışım kütlesel yüzdesi x2="+x2+"\n";
s+="absorberden çıkan zayıf karışım debisi m1="+m1+"kg/s\n";
s+="jeneratörden çıkıp absorbere giden kuvvetli karışım debisi m2="+m2+" kg/s\n";
s+="saf su - su buharı debisi m3="+m3+" kg/s\n";
s+="P1="+P1+" kPa\n";
s+="P2="+P2+" kPa\n";
s+="zayıf karışım ro1="+ro1+" kg/m^3 v1="+v1+" m^3/kg \n";
s+="ho absorber  = "+h0+" kJ/kgK \n";
s+="h1 pompa çıkışı  = "+h1+" kJ/kgK\n";
s+="h2 ısı değiştirici çıkışı  = "+h2+" kJ/kgK\n";
s+="h3 Jeneratör çıkışı kuvvetli karışım  = "+h3+" kJ/kg\n";
s+="h4 ısı değiştirici çıkışı = "+h4+" kJ/kg\n";
s+="h5 Jeneratör çıkışı su buharı  = "+h5+"kJ/kgK\n";
s+="h6 kondenser çıkışı = "+h6+"kJ/kg\n";
s+="h7 evaporatör girişi = "+h7+"kJ/kg\n";
s+="h8 evaporatör çıkışı = "+h8+"kJ/kg\n";
s+="t1_mix = "+t0m+"derece C\n";
s+="t2_mix = "+t2m+"derece C\n";
s+="W pompa = "+wpump*m1*1e3+" W\n";
s+="qg = "+qg+" kW\n";
s+="qc = "+qc+" kW\n";
s+="qa = "+qa+" kW\n";
s+="q_he = "+qhe+" kW\n";
s+="COP = "+COP+"\n";
return s;
}

public static void main(String arg[])
{ double m_pump=0.00264; //kg/s
  double t_generator=90.0; //derece C
  double t_condenser=44.3; //derece C
  double t_absorber=34.9; //derece C
  double t_evaporator=6.0; //derece C
  double t_heatexchanger=65.0; //derece C
  absorbtion_water_lithiumbromide1 awb=new absorbtion_water_lithiumbromide1(m_pump,t_generator,t_condenser,t_absorber,t_evaporator,t_heatexchanger);
  JOptionPane.showMessageDialog(null,awb.toString(),"su-Lityum bromid absorbsiyon soğutma çevrimi",JOptionPane.PLAIN_MESSAGE);
}
}