Wednesday, July 17, 2019

Density of breath and surrounding air

The Delphi 2 code (Pascal) below calculates the density of breath and of the surrounding air. If you enter a hollow or lift or tank and so on and your breath is more dense than the surrounding air it will sink and you could surround yourself with air that has a lot of carbon dioxide in. This could happen during heatwave conditions.
The inputs to the program are: Ts (temperature in deg C of the surrounding air, eg 38), RHs (relative humidity of the surrounding air in %, eg 34), P (the atmospheric air pressure in kPa, eg 100), PercO (the percentage of oxygen used up in breathing, eg 25), Tbr (the temperature of the breath in deg C, eg 37). The Delph1 2 code is below:
label 1;
var
PvBr,Mas,Mvs,Pvs,Psatws,PercO,Ts,Tsk,P,RHs,Tbr,Tbrk,Psatwbr,Denssa,Densbr,a,molDaBr,
MolNBr,MolOBri,MolOBrf,molCO2Bri,molCO2Brf,MolVBr,MolArBr,MolNeBr,MolHeBr,Mol,
MolKrBr,MolXeBr,VN,VO,VCO2,VV,VArg,VNe,VHe,VKr,VXe,MNbr,MOBrf,MCO2brf,MVBr,
MArBr,MNeBr,MHeBr,MKrBr,MXeBr,MBr,VolBr,TDI,Td,RHDI,DI,Pw,Tw,Aw,Bw,RHSw,Psat,
Tdew,Pvd,RH,LCL:extended;
errors1:boolean;
calcstr2,calcstr1,calcstr3,calcstr4,calcstr5,calcstr6,calcstr7,
calcstr8,calcstr9,calcstr10,calcstr11,calcstr12,calcstr13,calcstr14,calcstr15,calcstr16,
calcstr17,calcstr18,calcstr19,calcstr20,calcstr21,calcstr22,calcstr23,calcstr24:string[30];
begin
errors1:=false;
form16.hide;
form16.show;
try
Ts:=strtofloat(form16.edit1.Text);
RHs:=strtofloat(form16.edit2.Text);
P:=strtofloat(form16.edit3.Text);
PercO:=strtofloat(form16.edit4.Text);
Tbr:=strtofloat(form16.edit5.Text);
except
errors1:=true;
end;
if (errors1=true) or
(Ts<0) or (Ts>70) or (RHs<=0) or (RHs>100) or (P<10) or (P>150) or(percO<0) or (percO>90)
or (Tbr<0) or (Tbr>70) then begin
form16.canvas.textout(0,100,'CHECK ENTRIES.');
goto 1
end;
Tsk:=Ts+273.15;
Tbrk:=Tbr+273.15;
Psatws:=0.61121*exp((18.678-Ts/234.5)*Ts/(257.14+Ts));
Psatwbr:=0.61121*exp((18.678-Tbr/234.5)*Tbr/(257.14+Tbr));
Pvs:=Psatws*RHs/100;
Mvs:=Pvs/(0.4615*Tsk);
Mas:=(P-Pvs)/(0.287*Tsk);
PvBr:=Psatwbr;
molDaBr:=100-(PvBr/P)*100;
MolNBr:=78.03/100*moldaBr;
MolOBri:=20.99/100*molDaBr;
MolOBrf:=MolOBri-(percO/100*molObri);
MolCO2bri:=(0.033/100)*moldaBr;
MolCO2Brf:=molCO2bri+(percO/100*molObri);
molVbr:=100*Pvbr/P;
molArBr:=(0.94/100)*moldabr;
molNeBr:=(0.0015/100)*moldabr;
molHeBr:=(0.000524/100)*moldabr;
molKrBr:=(0.00014/100)*moldabr;
molXeBr:=(0.000006/100)*moldabr;
MNbr:=molNbr*0.028013;
MObrf:=molOBrf*0.031999;
MCO2Brf:=molCO2Brf*0.04401;
MVBr:=molVBr*0.018015;
MArBr:=molArBr*0.039948;
MNeBr:=molNeBr*0.020183;
MHeBr:=molHeBr*0.004003;
MKrBr:=molKrBr*0.08380;
MXeBr:=molXeBr*0.13130;
Denssa:=Mvs+Mas;
MBr:=MNbr+MOBrf+MCO2Brf+MVBr+MArBr+MNeBr+MHeBr+MKrBr+MXeBr;
VolBr:=100*0.00831447*Tbrk/P;
DensBr:=MBr/VolBr;
a:=9.80665*((denssa/densbr)-1);
VN:=100*MolNBr*(0.00831447*TBrk/P)/VolBr;
VO:=100*MolOBrf*(0.00831447*TBrk/P)/VolBr;
VCO2:=100*MolCO2Brf*(0.00831447*TBrk/P)/VolBr;
VV:=100*MolVBr*(0.00831447*TBrk/P)/VolBr;
VArg:=100*MolArBr*(0.00831447*TBrk/P)/VolBr;
VNe:=100*MolNeBr*(0.00831447*TBrk/P)/VolBr;
VHe:=100*MolHeBr*(0.00831447*TBrk/P)/VolBr;
VKr:=100*MolKrBr*(0.00831447*TBrk/P)/VolBr;
VXe:=100*MolXeBr*(0.00831447*TBrk/P)/VolBr;
str(Denssa:13:3,calcstr1);
str(DensBr:13:3,calcstr2);
str(a:13:2,calcstr3);
str(VN:13:4,calcstr4);
str(VO:13:4,calcstr5);
str(VCO2:13:4,calcstr6);
str(VV:13:4,calcstr7);
str(VArg:13:4,calcstr8);
str(VNe:13:4,calcstr9);
str(VHe:13:4,calcstr10);
str(VKr:13:4,calcstr11);
str(VXe:13:4,calcstr12);

form16.canvas.textout(0,100,'SURROUNDING AIR: DENSITY is: '+calcstr1+' kg/m^3.');
form16.canvas.textout(0,130,'BREATH:          DENSITY is: '+calcstr2+' kg/m^3.');
form16.canvas.textout(0,170,'BREATH: ACCELERATION (negative is down and positive is up) is: '+calcstr3+' m/s^2.');
form16.canvas.textout(0,210,'Breath % vol N2: '+calcstr4+'%.');
form16.canvas.textout(0,240,'Breath % vol O2: '+calcstr5+'%.');
form16.canvas.textout(0,270,'Breath % vol CO2: '+calcstr6+'%.');
form16.canvas.textout(0,300,'Breath % vol H20(g): '+calcstr7+'%.');
form16.canvas.textout(0,330,'Breath % vol Ar: '+calcstr8+'%.');
form16.canvas.textout(0,360,'Breath % vol Ne: '+calcstr9+'%.');
form16.canvas.textout(0,390,'Breath % vol He: '+calcstr10+'%.');
form16.canvas.textout(0,420,'Breath % vol Kr: '+calcstr11+'%.');
form16.canvas.textout(0,450,'Breath % vol Xe: '+calcstr12+'%.');
Td:=Ts;
TDI:=Td;
RHDI:=RHs;
DI:= (2*TDI) + (RHDI/100*TDI)+24;
Pw:=P/101.325;
Tw:=Td;
repeat
Tw:=Tw-0.001;
 Aw:=611.2*exp(17.502*Tw/(240.97+Tw))-66.8745*(1+0.00115*Tw)*Pw*(Td-Tw);
Bw:=6.112*exp(17.502*Td/(240.97+Td));
RHSw:=Aw/Bw;
until (RHSw<=rhs);
RH:=RHs;
Tdew:=Td;
Psat:=0.61121*exp((18.678-Td/234.5)*Td/(257.14+Td));
Pvd:=(RH/100)*Psat;
repeat
Tdew:=Tdew-0.001;
Psat:=0.61121*exp((18.678-Tdew/234.5)*Tdew/(257.14+Tdew));
until (Psat<=Pvd);
LCL:=125*(Td-Tdew);
str(DI:13:1,calcstr13);
str(Tw:13:2,calcstr14);
str(Tdew:13:2,calcstr15);
str(LCL:13:2,calcstr16);
form16.canvas.textout(0,490,'Discomfort Index: '+calcstr13+' (90 to 100 very uncomfortable, 100 to 110 extremely uncomfortable, >110 hazardous).');
form16.canvas.textout(0,520,'Wet Bulb T: '+calcstr14+' deg C');
form16.canvas.textout(0,550,'Dew point: '+calcstr15+' deg C.');
form16.canvas.textout(0,580,'LCL: '+calcstr16+' m.');

1: end;

No comments:

Post a Comment