import java.io.*;

public class kalina
{
	
public static void main (String args[]) 
{

water_ammonia_mix wamix=new water_ammonia_mix();
steam st=new steam();
ref_CS3 refcs3=new ref_CS3();
	// p in kpa
	// T in Kelvin
	// x nh3 molar fraction
    //propertymix(T,p,x)	
 
   ////---1--///
   
   double m_in=11.4;//kg/s	
   double P0=20.0;//bar
   double hsvin[]=wamix.propertymix(489, 3230 , 0.97);//turbine inlet   
   double hturin=hsvin[0];
   double sturin=hsvin[1];
   
   ///--2--///
   double hsvout[]=new double[2];
   hsvout=wamix.propertymix(316, 660 , 0.97);//turbine outlet
   double hturout=hsvout[0];
   double sturout=hsvout[1];
   
   ///--3--///
   double mleansol=5.4;//kg/s
   double leansol[] =new double[2];
   leansol=wamix.propertymix(319, 3130 , 0.5);// nh3 lean solution
   double hleansol=leansol[0];
   double sleansol=leansol[1];
   
   ///--4--///
   double mltrecin=16.8;//kg/s
   double ltrecin[] =new double[2];
   ltrecin=wamix.propertymix(319,660,0.5);// LT recuperator inlet
   double hltrecin=ltrecin[0];
   double sltrecin=ltrecin[1];

   //--5--///
   double mltrecout=16.8;//kg/s
   double ltrecout[] =new double[2];
   ltrecout=wamix.propertymix(303,560,0.82);// LT recuperator out
   double hltrecout=ltrecout[0];            // Condenser inlet
   double sltrecout=ltrecout[1];
   
   ///--6--///
   double mcondout=16.8;//kg/s
   double condout[] =new double[2];
   condout=wamix.propertymix(281,460,0.82);//pump inlet
   double hcondout=condout[0];             // condenser out
   double scondout=condout[1];
   
   ///--7--//
   double mpumpout=16.8;//kg/s
   double pumpout[] =new double[2];
   pumpout=wamix.propertymix(281,3530,0.82);// LT recuperator inlet
   double hpumpout=pumpout[0];
   double spumpout=pumpout[1];
   
   ///--8--//
   double mbasicsol=16.8;//kg/s
   double basicsol[] =new double[2];
   basicsol=wamix.propertymix(314,3430,0.82);// LT recuperator outlet
   double hbasicsol=basicsol[0];             // HT recuperator inlet
   double sbasicsol=basicsol[1];
   
   //--9--//
   double mhtrecout=16.8;//kg/s
   double htrecout[] =new double[2];
   htrecout=wamix.propertymix(336,3330,0.82);// HT recuperator out
   double hhtrecout=htrecout[0];             // evaporator inlet
   double shtrecout=htrecout[1];
   
   //--10--//
   double mseperatorout=5.4;//kg/s
   double seperatorout[] =new double[2];
   seperatorout=wamix.propertymix(389,3230,0.5);// HT recuperator out
   double hseperatorout=seperatorout[0];             // evaporator inlet
   double sseperatorout=seperatorout[1];
   
   ///--11--//
   double tin=120.0;
   double Tin=tin+273;
   double tout=30.0;
   double Tout=tout+273;
   double mfgas=89;//kg/s
   double a0[]=st.property("tp",tout,P0);
   double hout=a0[3];
   //double cpout=refcs3.Cpl(tout); // desulfirised flue gas
   double b0[]=st.property("tp",tin,P0);
   double hin=b0[3];
   //double cpin=(b1[3]-b0[3])/0.01;
   //double cpin=refcs3.Cpv(tin); // in evaporator
   System.out.println("hout="+hout+"tout="+tout);
   System.out.println("hin="+hin+"tin="+tin);
   double Q=mfgas*(hin-hout);
      System.out.println("Q="+Q);
   ///--12--//
   double mseperatorin=16.8;//kg/s
   double seperatorin[] =new double[2];         // evaporator out
   seperatorin=wamix.propertymix(389,3230,0.5);// seperator in
   double hseperatorin=seperatorin[0];             
   double sseperatorin=seperatorin[1];
   
   /// efficiency  ?????
   double Houtcond=mltrecout*hltrecout-mcondout*hcondout;
   double Wnet=m_in*(hturin-hturout);
   
   double Qnet=Q-Houtcond;
   
   double eff=Wnet/Qnet;
   System.out.println("Qnet="+Qnet+"Qcond="+Houtcond+"Wnet="+Wnet+"hturin="+hturin+"hturout="+hturout);
   
		}
}  