program COCO2mix;
{program COCO2mix;}
{for calculating flow rates for CO-CO2 gas mixtures.
Uses calibration of Deines et al. (1974)}
{coded by Victor Kress (1988)}
const
  r:real=0.00198726;{kcal/deg.mole}
var
  tk,tc,logfo2,fo2,nno,fmq,mh,wm,iw,dg,co,co2,k,ratio:real;
function tth(x:real):real;
  begin
    tth:=sqrt(x)*sqrt(x)*sqrt(x);
  end;
begin
repeat
  writeln(' Input T(c) logfo2 and CO2 flow rate (0 to exit):');
  readln(tc,logfo2,co2);
  if tc>0 then begin;
    tk:=tc+273.15;
    nno:=-24930.0/tk+9.36; {Chou (1978)}
    fmq:=-24441.0/tk+8.290; {Myers and Eugster (1983)}
    mh:=-23847.0/tk+13.480; {Myers and Eugster (1983)}
    wm:=-36951.0/tk+16.092; {Myers and Eugster (1983)}
    iw:=-26834.7/tk+6.471; {Myers and Eugster (1983)}
    writeln('     delMH    delNNO    delFMQ     delWM     delIW');
    writeln((logfo2-mh):10:2,(logfo2-nno):10:2,(logfo2-fmq):10:2,
           (logfo2-wm):10:2,(logfo2-iw):10:2);
    fo2:=exp(2.3025851*logfo2);
    dg:=62.110326-2.1444460e-2*tc+4.720325e-7*sqr(tc)-4.5574288e-12*tc*tc*tc
        -7.3430182e-15*sqr(sqr(tc));
    k:=exp(-dg/(r*(tc+273.15)));
    ratio:=(k-3*k*fo2-2*tth(fo2))/(2*k*fo2+fo2+tth(fo2)+sqrt(fo2));
    co:=ratio*co2;
    writeln('%CO      =  ',(100/(1+1/ratio)):5:2);
    writeln('CO2 rate = ', co2:6:2);
    writeln('CO  rate = ', co:6:2);
    writeln;
  end; {if}
until tc <= 0;
end.

