"===============Input Data==================" tcw=26 "Cooling Water Temperature in Degree C" T_o=25 "Ambient Temperature in Degree C" tf=35 "Feed Water Temperature in Degree C" Pm=250 "Motive Steam Pressure in Kpa" T_s=60 "Compressed Vapor Temperature in Degree C" T_m=t_sat(Steam,P=Pm) "Motive Steam Temperature in Degree C" P_s=p_sat(Steam,T=T_s) "Compressed Vapor Prssure in Kpa" P_ev=p_sat(Steam,T=(Tv_[k])) "Entrained Vapor Pressure in Kpa" Delta_Tc=0 M_d=1 "Total Disttilate Water for System in Kg/s" X_f=42000 "Feed Salinity in ppm" X_n=69000 "Brine Salinity in the Last Effect, ppm" "Why did we fixed the value??????????" T_n=tcw + 10 "Last Effect Temperature in Degree C" n=4 "Number of Effects" k=2 "Ejector Location" Z = k+1 "Effect after Ejector" Delta_T_loss=2 "======================== Equations======================" S_o = (X_f/1000) "Salinity of Water (gm/Kg)" C_p=(a+(b*T_ave)+(c*T_ave^2)+(d*T_ave^3))/1000 "Specific Heat of Water (KJ/Kg Deg C), Appendix A , Page 528" a=4206.8-(6.6197*S_o)+((1.2288/100)*S_o^2) b=-1.1262+((5.4178/100)*S_o)-((2.2719/10000)*S_o^2) c=1.2026/100-((5.3566/10000)*S_o)+((1.8906/1000000)*S_o^2) d=6.8777/10000000+((1.517/1000000)*S_o)-((4.4268/1000000000)*S_o^2) T_ave = (T_[1]+tcw)/2 BPE = G*X + H*X^2 + I*X^3 "Boiling Point Elevation in Degree C" G = 8.325E-2 + T_[n] *1.883E-4 + T_[n]^2 * 4.02E-6 H = -7.625E-4 + T_[n] * 9.02E-5 - T_[n]^2 * 5.2E-7 I = 1.522E-4 - T_[n] * 3E-6 - T_[n]^2 * 3E-8 X = (X_n / 10000) " Salt weight Percentage " " For Cp Formula : Salinity Range (PPM) : 20000 < X < 160000 Temperature Range (Degree C) : 20 <_T < 180 C" M_f/M_d=X_n/(X_n-X_f) Delta_T_total = T_s - T_n "Total Temperature Differrence in degree C" Delta_T_[1]=Delta_T_total/(U_[1]*(sum(1/U_[i],i=1,n))) "Temperature Differnece in the First Effect" T_[1]=T_s-Delta_T_[1] "Temperature in the First Effect" duplicate i=2,n Delta_T_[i]=Delta_T_[1]*U_[1]/U_[i] "Temperature Differnece in the Rest Effect" T_[i]=T_[i-1]-Delta_T_[i] "Temperature in the Rest Effect" end duplicate i=1,n Tv_[i]=T_[i]-BPE "Temperature Formed in Each effect, Degree C" end sumU =sum(1/U_[i],i=1,n) U_c=1.6175+(0.1537/1000)*(Tv_[n])+(0.1825/1000)*(Tv_[n])^2-(0.00008026/1000)*(Tv_[n])^3 "Condenser Overall Heat Transfer Coefficient" duplicate i=1,n U_[i]=1.9394+(1.40562/1000)*Tv_[i]-(0.0207525/1000)*Tv_[i]^2+(0.0023186/1000)*(Tv_[i])^3 "Overall Heat Transfer Coefficient for all effects" end L = Enthalpy(Steam_IAPWS,T=T_s,x=1)-Enthalpy(Steam_IAPWS,T=T_s,x=0) "Enthalpy of Water Vaporization for Steam" M_d = sum(D_[i],i=1,n)+sum(df_[i],i=2,n)+sum(de_[i],i=2,n) "Total Disttilate Water for System in Kg/s" B_[1] = F_[1] - D_[1] "Brine Flow Rate Leaving First Effect" X_[1] = (X_f * F_[1]) /B_[1] "Salinity for the First Effect" A_[1] = (D_[1]*L_[1]+F_[1]*C_p*(T_[1]-Tf))/(U_[1]*(T_s-T_[1])) "Heat Transfer Area of the First Effect" duplicate i=1,n L_[i] = Enthalpy(Steam_IAPWS,T=T_[i],x=1)-Enthalpy(Steam_IAPWS,T=T_[i],x=0) "Enthalpy of Water Vaporization for Each Effect" F_[i] = M_f/n "Feed Flow Rate in Each Effect" end duplicate i=2,n B_[i] = F_[i]+B_[i-1]-D_[i] "Brine Flow Rate Leaving the Rest Effects" X_[i]*B_[i] = (X_f*F_[i]+X_[i-1]*B_[i-1]) "Salinity Balance in Each Effect" end Q_[1]=Ms*L "Energy Equation in the Firs Effect" duplicate i=2,n Q_[i] = D_[i]*L_[i]+F_[i]*C_p*(T_[i]-Tf) "Energy Equation in Each Effect" A_[i] = (Q_[i])/(U_[i]*(Delta_T_[i]-Delta_T_loss)) "Heat Transfer Area of the Rest Effects" end de_[1]=0 "Vapor Formed by Brine Flashing in the Effect (i-1)" Le_[1]=0 "Enthalpy of Vaporization of the Vapor Formed by Brine Flashing in the Effect (i-1)" { Case #1 : " k=1, Effect #2" D_[2]*L_[2]+F_[2]*C_p*(T_[2]-Tf)=(D_[1]-Mev)*L_[1]+df_[1]*Lfla_v_[1]+(de_[1]*Le_[1]) "Energy Balance in the Second Effect After Ejector" duplicate i=3,n D_[i]*L_[i]+F_[i]*C_p*(T_[i]-Tf)=(D_[i-1])*L_[i-1]+df_[i-1]*Lfla_v_[i-1]+(de_[i-1]*Le_[i-1]) end Qc=(D_[n]+de_[n]+df_[n])*L_[n] "Heat Load in the Condenser"} {Case #2 : 1<k<n , Z<n} duplicate i=2,k "1<k<n , Z<n" D_[i]*L_[i]+F_[i]*C_p*(T_[i]-Tf)=(D_[i-1])*L_[i-1]+df_[i-1]*Lfla_v_[i-1]+(de_[i-1]*Le_[i-1]) "Energy Balance in Each Effect Before Ejector" end D_[k+1]*L_[k+1]+F_[k+1]*C_p*(T_[k+1]-Tf)=(D_[k]-Mev)*L_[k]+df_[k]*Lfla_v_[k]+(de_[k]*Le_[k]) duplicate i=k+2,n "Z<n" D_[i]*L_[i]+F_[i]*C_p*(T_[i]-Tf)=(D_[i-1])*L_[i-1]+df_[i-1]*Lfla_v_[i-1]+(de_[i-1]*Le_[i-1]) end Qc=(D_[n]+de_[n]+df_[n])*L_[n] "Heat Load in the Condenser" {Case #3 : "k=n"} {duplicate i=2,k "k=n" D_[i]*L_[i]+F_[i]*C_p*(T_[i]-Tf)=(D_[i-1])*L_[i-1]+df_[i-1]*Lfla_v_[i-1]+(de_[i-1]*Le_[i-1]) "Energy Balance in Each Effect Before Ejector" end Qc=(D_[n]+de_[n]+df_[n]-Mev)*L_[n]} duplicate i=2,n de_[i]=B_[i-1]*C_p*(T_[i-1]-T_dot_[i])/Le_[i] Le_[i]=2499.5698-2.204864*(T_dot_[i]-2)-2.304E-3*(T_dot_[i]-2)^2 T_dot_[i]=T_[i]+NEAe_[i] "Temperature in the Flash Box" NEAe_[i]=33*(Delta_T_[i])^0.55/Tv_[i] "Non-equi;ibrium Allownce equation B.2 page 568" end "=============Flashed vapor in the flash boxes===============" df_[1]=0 "Flashed Vapor in the First Flashed Box" Lfla_v_[1]= 0 "Enthalpy of Vaporization in the First Flashed Box" Tc_[1]=Tv_[1]-Delta_Tc duplicate i=2,n NEA_fla_[i]=33*(Delta_T_[i])^0.55/Tv_flas_[i] Tfla_fla_[i]=Tv_flas_[i]+NEA_fla_[i] " Tfla_fla : Temperature of Flashed Box, Tv_flas :Vaporization Temperature in the Flashed Box" Tv_flas_[i]=Tv_[i] Lfla_v_[i]= 2501.897149-2.407*Tfla_fla_[i]+1.192E-3*Tfla_fla_[i]^2-1.5863E-5*Tfla_fla_[i]^3 Tc_[i]=Tv_[i]-Delta_Tc df_[i]=(sum(D_[j], j=1,i-1))*C_p*(Tc_[i-1]-Tfla_fla_[i])/Lfla_v_[i] end {================TVC==================} PCF = 3*10^(-7)*Pm^(2)-0.0009*Pm+1.6101 "Motive Steam Pressure Correction Factor" TCF = 2*10^(-8)*(Tv_[k])^(2)-0.0006*(Tv_[k])+1.0047 "Motive Steam Temperature Correction Factor" Ra=0.296*((P_s)^(1.19)/(P_ev)^(1.04))*(Pm/P_ev)^(0.015)*PCF/TCF "Entrainment Ratio" Ms=(D_[1]*L_[1]+C_p*F_[1]*(T_[1]-Tf))/L "Steam Flow Rate from Energy Balance in the First Effect" Mm=Ms/(1+1/Ra) "Motive Steam Floe Rate" Mev=Ms-Mm "Entrained Vapor Flow Rate" CR=P_s/P_ev "Cmpression Ratio" PR=M_d/Mm "Performance Ratio" Qc=(M_f+M_cw)*C_p*(tf-tcw) "Heat Load in the Condenser" LMTDc = (tf-tcw)/ln((T_[n]-tcw)/(T_[n]-tf)) "Condenser Log Mean Temperature Difference" Ac = Qc/(U_c*LMTDc) "Condenser Heat Transfer Area" sA = (sum(A_[i],i=1,n)+Ac)/M_d "Specific Heat Transfer Area" sM_cw=M_cw/M_d "Specific Cooling Water Flow" {============================================second law analysis ==========================================} {======================================FIRST EFFECT===========================================} {===============================Steam===================================} hs_in_[1]=enthalpy(Steam,T=T_s,x=1) "First effect Inlet Steam Enthalpy" ss_in_[1]=entropy(Steam,T=T_s,x=1) "First effect Inlet Steam Entropy" hs_o=enthalpy(Water,T=T_o,x=0) "Water Enthalpy at Ambient Temperature" ss_o=entropy(Water,T=T_o,x=0) "Water Entropy at Ambient Temperature" hs_out_[1]=enthalpy(Steam,T=T_s,x=0) "First effect Outlet Steam Enthalpy" ss_out_[1]=entropy(Steam,T=T_s,x=0) "First effect Outlet Steam Entropy" duplicate i=2,n hs_in_[i]=enthalpy(Steam,T=Tv_[i-1],x=1) "Rest effects Inlet Water Vapor Enthalpy" ss_in_[i]=entropy(Steam,T=Tv_[i-1],x=1) "Rest effects Inlet Water Vapor Entropy" hs_out_[i]=enthalpy(Steam,T=Tv_[i-1],x=0) "Rest effects Outlet Water Vapor Enthalpy" ss_out_[i]=entropy(Steam,T=Tv_[i-1],x=0) "Rest effects Outlet Water Vapor Entropy" end {Case # 2} duplicate i=2,k "1<k<n , Z<n" EX_s_in_[i]=(D_[i-1]+df_[i-1])*((hs_in_[i]-hs_o)-(T_o+273)*(ss_in_[i]-ss_o)) "Exergy for Water Vapor Inlet from Second Effect to the Ejector" EX_s_out_[i]=(D_[i-1]+df_[i-1])*((hs_out_[i]-hs_o)-(T_o+273)*(ss_out_[i]-ss_o)) "Exergy for Water Vapor Outlet from Second Effect to the Ejector" end EX_s_in_[z]=(D_[k]+df_[k]-Mev)*((hs_in_[z]-hs_o)-(T_o+273)*(ss_in_[z]-ss_o)) "Exergy for Water Vapor Inlet in the Effect After Ejector" EX_s_out_[z]=(D_[k]+df_[k]-Mev)*((hs_out_[z]-hs_o)-(T_o+273)*(ss_out_[z]-ss_o)) "Exergy for Water Vapor Outlet in the Effect After Ejector" duplicate i=z+1,n "z<n" EX_s_in_[i]=(D_[i-1]+df_[i-1])*((hs_in_[i]-hs_o)-(T_o+273)*(ss_in_[i]-ss_o)) "Exergy for Water Vapor Inlet in the Rest Effects" EX_s_out_[i]=(D_[i-1]+df_[i-1])*((hs_out_[i]-hs_o)-(T_o+273)*(ss_out_[i]-ss_o)) "Exergy for Water Vapor Outlet in the Rest Effects" end {Case #3} {duplicate i=2,n "k=n" EX_s_in_[i]=(D_[i-1]+df_[i-1])*((hs_in_[i]-hs_o)-(T_o+273)*(ss_in_[i]-ss_o)) "Exergy for Water Vapor Inlet from Second Effect to the Ejector" EX_s_out_[i]=(D_[i-1]+df_[i-1])*((hs_out_[i]-hs_o)-(T_o+273)*(ss_out_[i]-ss_o)) "Exergy for Water Vapor Outlet from Second Effect to the Ejector" end} duplicate i=2,n Delta_EX_hot_[i]=EX_s_in_[i]-EX_s_out_[i] "Water Vapor Exergy change in the First Effect" end EX_s_in_[1]=Ms*((hs_in_[1]-hs_o)-(T_o+273)*(ss_in_[1]-ss_o)) "Exergy for Steam Inlet in the First Effect" EX_s_out_[1]=Ms*((hs_out_[1]-hs_o)-(T_o+273)*(ss_out_[1]-ss_o)) "Exergy for Steam Outlet in the First Effect" Delta_EX_hot_[1]=EX_s_in_[1]-EX_s_out_[1] "Steam Exergy change in the First Effect" {==============================sea Water=============================} hf_in_[1]="Enthalpy(Water,T=Tf_2,x=0)"SW_Enthalpy(Tf,X_f/1000)/1000 "First effect Inlet Seawater Enthalpy" hf_o="Enthalpy(water,T=T_o,x=0)"SW_Enthalpy(T_o,S_o)/1000 "Seawater Enthalpy at Ambient Temperature" sf_in_[1]="Entropy(water,T=Tf_2,x=0)"SW_Entropy(Tf,X_f/1000)/1000 "First effect Inlet Seawater Entropy" sf_o="Entropy(water,T=T_o,x=0)"SW_Entropy(T_o,S_o)/1000 "Seawater Entropy at Ambient Temperature" hb_out_[1]="Enthalpy(water,T=T_[1],x=0)"SW_Enthalpy(T_[1],X_[1]/1000)/1000 "First effect Outlet Brine Water Enthalpy" sb_out_[1]="Entropy(water,T=T_[1],x=0)"SW_Entropy(T_[1],X_[1]/1000)/1000 "First effect Outlet Brine Water Entropy" hv_out_[1]=enthalpy(Steam,T=Tv_[1],x=1) "First effect Outlet Water Vapor Enthalpy" sv_out_[1]=entropy(Steam,T=Tv_[1],x=1) "First effect Outlet Water Vapor Entropy" duplicate i=2,n hf_in_[i]="Enthalpy(Water,T=T_[i],x=0)"SW_Enthalpy(Tf,X_f/1000)/1000 "Rest effects Inlet Seawater Enthalpy" sf_in_[i]="Entropy(water,T=T_[i],x=0)"SW_Entropy(Tf,X_f/1000)/1000 "Rest effects Inlet Seawater Entropy" hb_out_[i]="Enthalpy(water,T=T_[i],x=0)"SW_Enthalpy(T_[i],X_[i]/1000)/1000 "Rest effects Outlet Brine Water Enthalpy" sb_out_[i]="Entropy(water,T=T_[i],x=0)"SW_Entropy(T_[i],X_[i]/1000)/1000 "Rest effects Outlet Brine Water Entropy" hv_out_[i]=enthalpy(Steam,T=Tv_[i],x=1) "Rest effects Outlet Water Vapor Enthalpy" sv_out_[i]=entropy(Steam,T=Tv_[i],x=1) "Rest effects Outlet Water Vapor Entropy" EX_f_in_[i]=F_[1]*((hf_in_[i]-hf_o)-((T_o+273)*(sf_in_[i]-sf_o))) "Exergy for Seawater Inlet in the Rest Effects" EX_b_out_[i]=B_[i]*((hb_out_[i]-hf_o)-((T_o+273)*(sb_out_[i]-sf_o))) "Exergy for Brine Water Outlet in the Rest Effects" EX_v_out_[i]=D_[i]*((hv_out_[i]-hs_o)-((T_o+273)*(sv_out_[i]-ss_o))) "Exergy for Outlet Water Vapor in the Rest Effects" Delta_EX_cold_[i]=EX_v_out_[i]+EX_b_out_[i]-EX_f_in_[i]-EX_b_out_[i-1] Delta_EX_[i]=Delta_EX_hot_[i]-Delta_EX_cold_[i] Efficiency_EX_[i]=Delta_EX_cold_[i]/Delta_EX_hot_[i] end EX_f_in_[1]=F_[1]*((hf_in_[1]-hf_o)-(T_o+273)*(sf_in_[1]-sf_o)) EX_b_out_[1]=B_[1]*((hb_out_[1]-hf_o)-(T_o+273)*(sb_out_[1]-sf_o)) EX_v_out_[1]=D_[1]*((hv_out_[1]-hs_o)-(T_o+273)*(sv_out_[1]-ss_o)) Delta_EX_cold_[1]=EX_v_out_[1]+EX_b_out_[1]-EX_f_in_[1] Delta_EX_[1]=Delta_EX_hot_[1]-Delta_EX_cold_[1] Efficiency_EX_[1]=Delta_EX_cold_[1]/Delta_EX_hot_[1] {============exergy analysis for the condenser==============} {===============hot fluid=======================} hs_in_c=enthalpy(Steam,T=Tv_[n],x=1) "Condenser Inlet Steam Enthalpy" ss_in_c=entropy(Steam,T=Tv_[n],x=1) "Condenser Inlet Steam Entropy" hs_out_c=enthalpy(Steam,T=Tv_[n],x=0) "Condenser Outlet Steam Enthalpy" ss_out_c=entropy(Steam,T=Tv_[n],x=0) "Condenser Outlet Steam Entropy" EX_s_in_c=(D_[n])*((hs_in_c-hs_o)-(T_o+273)*(ss_in_c-ss_o)) "Exergy for Inlet Water Vapor to Condenser" EX_s_out_c=(D_[n])*((hs_out_c-hs_o)-(T_o+273)*(ss_out_c-ss_o)) "Exergy for Outlet Water Vapor From Condenser" Delta_EX_hot_c=EX_s_in_c-EX_s_out_c "Exergy Difference between Inlet and Outlet of Water Vapor to Condenser" {===============cold fluid=======================} hf_in_c="Enthalpy(Steam,T=Tcw,x=0)"SW_Enthalpy(tcw,X_f/1000)/1000 sf_in_c="Entropy(steam,T=Tcw,x=0)"SW_Entropy(tcw,X_f/1000)/1000 hf_out_c="Enthalpy(Steam,T=Tf,x=0)"SW_Enthalpy(tf,X_f/1000)/1000 sf_out_c="Entropy(Steam,T=Tf,x=0)"SW_Entropy(tf,X_f/1000)/1000 EX_f_in_c=(M_f+M_cw)*((hf_in_c-hf_o)-(T_o+273)*(sf_in_c-sf_o)) "Exergy of Inlet Seawater to Condenser" EX_f_out_c=(M_f+M_cw)*((hf_out_c-hf_o)-(T_o+273)*(sf_out_c-sf_o)) "Exergy of Outlet Seawater From Condenser" Delta_EX_cold_c=EX_f_out_c-EX_f_in_c "Exergy Difference between Inlet and Outlet of Seawater to Condenser" Delta_EX_c=Delta_EX_hot_c-Delta_EX_cold_c "Condenser Exergy Difference" Efficiency_EX_c=Delta_EX_cold_c/Delta_EX_hot_c "Condenser Exergetic Efficiency" {==================Total exergy analysis ==================} Distillate_exergy=exergy_Mev_out+(sum(EX_s_out_[i],i=2,n)) Blowdown_exergy="(sum(EX_b_out_[i],i=1,n))"EX_b_out_[n] Total_exergy_destruction=exergy_TVC_m+EX_f_in_c-(exergy_Mm_out+exergy_Mcw_out+Blowdown_exergy+Distillate_exergy) Total_efficiency_II=Distillate_exergy/(exergy_TVC_m+EX_f_in_c-exergy_Mm_out) {============exergy analysis for the flash boxes==============} {======================================} duplicate i=2,n hcf_in_[i]=enthalpy(Steam,T=Tv_[i-1],x=0) scf_in_[i]=entropy(Steam,T=Tv_[i-1],x=0) hvf_out_[i]=enthalpy(Steam,T=Tv_flas_[i],x=1) svf_out_[i]=entropy(Steam,T=Tv_flas_[i],x=1) hcf_out_[i]=enthalpy(Steam,T=Tfla_fla_[i],x=0) scf_out_[i]=entropy(Steam,T=Tfla_fla_[i],x=0) EXf_in_[i]=sum(D_[j],j=1,i-1)*((hcf_in_[i]-hs_o)-(T_o+273)*(scf_in_[i]-ss_o)) EXvf_out_[i]=(df_[i])*((hvf_out_[i]-hs_o)-(T_o+273)*(svf_out_[i]-ss_o)) EXcf_out_[i]=(sum(D_[j],j=1,i-1)-sum(df_[m],m=1,i))*((hcf_out_[i]-hs_o)-(T_o+273)*(scf_out_[i]-ss_o)) Exergy_destruction_flash_[i]=EXf_in_[i]-(EXcf_out_[i]+EXvf_out_[i]) Efficiency_EX_flash_[i]=(EXcf_out_[i]+EXvf_out_[i])/EXf_in_[i] end {====================TVC Exergy calculation======================} exergy_TVC_m=(Mm)*((h_TVC_in-hs_o)-(T_o+273)*(s_TVC_in-ss_o)) exergy_TVC_ev=(Mev)*((h_ev_in-hs_o)-(T_o+273)*(s_ev_in-ss_o)) exergy_TVC_out=(Ms)*((hs_in_[1]-hs_o)-(T_o+273)*(ss_in_[1]-ss_o)) exergy_Mm_out=Mm*((hs_out_[1]-hs_o)-(T_o+273)*(ss_out_[1]-ss_o)) exergy_Mev_out=Mev*((hs_out_[1]-hs_o)-(T_o+273)*(ss_out_[1]-ss_o)) exergy_Mcw_out=(M_cw)*((hf_out_c-hf_o)-(T_o+273)*(sf_out_c-sf_o)) TVC_exergydistruction=exergy_TVC_m+exergy_TVC_ev-exergy_TVC_out TVC_exergaticefficiency=exergy_TVC_out/(exergy_TVC_m+exergy_TVC_ev) h_TVC_in=enthalpy(Steam,T=T_m,x=1) "Enthalpy of Inlet Motive Steam to the Ejector" s_TVC_in=entropy(Steam,T=T_m,x=1) "Entropy of Inlet Motive Steam to the Ejector" h_ev_in=enthalpy(Steam,T=(Tv_[k]),x=1) "Enthalpy of Inlet Entrained Vapor to the Ejector" s_ev_in=entropy(Steam,T=(Tv_[k]),x=1) "Enthalpy of Inlet Entrained Vapor to the Ejector"