Saturday, September 14, 2019

Water from air Delphi2 Code

THE CODE BELOW IS FREEWARE:
T1 is the temperature of the surrounding air in deg C, RH1 is the relative humidity in percent, P1 is the atmospheric pressure in kPa (at sea level it is about 101.325 kPa), T2 is the temperature to which the air will be cooled, V1 is the volume of air you are going to cool in cubic metres. Code below:
label 1;
var
EnthV1MWh,EnthV1kWh,EnthV1,NokgdaV1,Enthd,Psatw1,Psatw2,Tk1,Tk2,Mvpa1,Enth1,Enth2,Ma1,Mv1,HR1,HR2,
Pv1,PV2,T1,RH1,P1,P2,T2,V1,kgDryAir,EdpkgDA,EnthDV,HR1mHR2,HR1mHR2V,kgpkWh,Td,RH,Psat,Pv,Tdew:extended;
errors1:boolean;
calcstr2,calcstr1,calcstr3,calcstr4,calcstr5,calcstr6,calcstr7,
calcstr8,calcstr9,calcstr10,calcstr11,calcstr12,calcstr13,calcstr14,
calcstr15,calcstr16,calcstr17,calcstr18:string[30];
begin
errors1:=false;
form2.hide;
form2.show;
try
T1:=strtofloat(form2.edit1.Text);
RH1:=strtofloat(form2.edit2.Text);
P1:=strtofloat(form2.edit3.Text);
T2:=strtofloat(form2.edit4.Text);
V1:=strtofloat(form2.edit5.Text);
except
errors1:=true;
end;
if (errors1=true) or
(T1<0.1) or (T1>100) or (RH1<0.1) or (RH1>100) or (P1<50) or (P1>150) or (T2<0.1) or
(T2>100) or (V1<0) or (T2>=T1-0.01)
then begin
form2.canvas.textout(0,100,'CHECK ENTRIES.');
goto 1
end;
Tk1:=T1+273.15;
Tk2:=T2+273.15;

Td:=T1;
RH:=RH1;
Psat:=0.61121*exp((18.678-Td/234.5)*Td/(257.14+Td));
Pv:=(RH/100)*Psat;
Tdew:=Td;
repeat
Tdew:=Tdew-0.001;
Psat:=0.61121*exp((18.678-Tdew/234.5)*Tdew/(257.14+Tdew));
until (Psat<=Pv);
str(Tdew:12:2,calcstr18);


Psatw1:=0.61121*exp((18.678-T1/234.5)*T1/(257.14+T1));
Pv1:=Psatw1*RH1/100;
HR1:=0.622*Pv1/(P1-Pv1);
Ma1:=(P1-Pv1)/(0.287*Tk1);
Enth1:=(1.005*T1)+HR1*(2501.3+1.88*T1);
Psatw2:=0.61121*exp((18.678-T2/234.5)*T2/(257.14+T2));
HR2:=Hr1;
P2:=P1;
if (Psatw2<PV1) then begin
Pv2:=Psatw2;
HR2:=0.622*Pv2/(P2-Pv2);
form2.canvas.textout(0,90,'Water condenses out. Dew point is:'+calcstr18+' deg C');
end;
Enth2:=(1.005*T2)+HR2*(2501.3+1.88*T2);
kgDryAir:=V1*Ma1;
EdpkgDA:=(Enth2-Enth1);
EnthDV:=kgDryAir*EdpkgDA;
HR1mHR2:=HR1-HR2;
HR1mHR2V:=kgDryAir*HR1mHR2;
kgpkWh:=(-1)*HR1mHR2V/(EnthDV/3600);
str(Enth1:13:4,calcstr1);
str(Enth2:13:4,calcstr2);
str(EdpkgDA:13:6,calcstr3);
str(Ma1:13:4,calcstr4);
str(kgDryAir,calcstr5);
str(EnthDV,calcstr6);
str((EnthDV/3600),calcstr7);
str((EnthDV/3600000),calcstr8);
str((HR1mHR2*1000):13:4,calcstr9);
str(HR1mHR2V,calcstr10);
str((HR1*1000):13:4,calcstr11);
str((HR2*1000):13:4,calcstr12);
str(EnthV1MWh,calcstr16);
str(kgpkWh:13:4,calcstr17);
form2.canvas.textout(0,120,'Enthalpy1 per kg dry air is: '+calcstr1+' kJ/kg dry air.');
form2.canvas.textout(0,150,'Enthalpy2 per kg dry air is: '+calcstr2+' kJ/kg dry air.');
form2.canvas.textout(0,180,'Enthalpy difference per kg dry air is: '+calcstr3+' kJ/kg dry air.');
form2.canvas.textout(0,210,'Mass of DRY air in one cubic metre of original air is: '+calcstr4+' kg.');
form2.canvas.textout(0,240,'Number of kg of dry air in V1 is: '+calcstr5+' kg.');
form2.canvas.textout(0,270,'FOR VOLUME V1: Heat added to volume V1 of air (Enthalpy difference for volume V1) is: '+calcstr6+' kJ.');
form2.canvas.textout(0,300,'FOR VOLUME V1: Heat added to volume V1 of air is: '+calcstr7+' kWh.');
form2.canvas.textout(0,330,'FOR VOLUME V1: Heat added to volume V1 of air is: '+calcstr8+' MWh.');
form2.canvas.textout(0,370,'HR1 - HR2 g/kg is: '+calcstr9+' grams of water vapour per kg dry air (CONDENSES OUT).');
form2.canvas.textout(0,400,'(HR1 - HR2 kg/kg)x(number of kg dry air in volume V1) is: '+calcstr10+' kg of water (CONDENSES OUT).');
form2.canvas.textout(0,440,'HR1 is: '+calcstr11+' g/kg.');
form2.canvas.textout(0,470,'HR2 is: '+calcstr12+' g/kg.');
form2.canvas.textout(0,520,'SUMMARY. Total mass of water condensing out of the air is: '+calcstr10+' kg.');
form2.canvas.textout(0,550,'SUMMARY: Total heat added to the air is: '+calcstr7+' kWh.');
form2.canvas.textout(0,580,'SUMMARY: kg of water produced per kWh of heat removed from air: '+calcstr17+' kg/kWh.');
form2.canvas.textout(0,610,'SUMMARY: Dew point temperature is: '+calcstr18+' deg C.');
1: end;


No comments:

Post a Comment