% MATLAB file used to perform the calculations for Activity 35.1
function Activity_35
    % Known constants
    Ltot = 6.0; % m
    L1 = 3.0; % m
    L3 = 0.45*Ltot;
    T = 450 + 273.15; % K
    P = 5.0; % atm
    R = 8.206E-5; % m^3*atm/mol/K
    VFR = 200./35.3; % m^3/h
    yAfeed = 0.15;
    yBfeed = 0.15;
    yIfeed = 0.7;
    fStagnant = 0.15;
    
    % Calculated constants
    nfeed = P*VFR/R/T;
    nA1 = yAfeed*nfeed;
    nB1 = yBfeed*nfeed;
    nZ1 = 0;
    nI1 = yIfeed*nfeed;
    
    
    % Analyze R1
    [nA2,nB2,nZ2] = Activity_35_pfr(nA1,nB1,nI1,nZ1,L1);
    
    % Analyze SS1
    nA3 = 0.15*nA2;
    nB3 = 0.15*nB2;
    nZ3 = 0.15*nZ2;
    nI3 = 0.15*nI1;
    nA4 = nA2 - nA3;
    nB4 = nB2 - nB3;
    nZ4 = nZ2 - nZ3;
    nI4 = nI1 - nI3;
    
    % Analyze R2
    [nA5,nB5,nZ5] = Activity_35_cstr(nA3,nB3,nI3,nZ3);
    
    % Analyze SM1
    nA6 = nA4 + nA5;
    nB6 = nB4 + nB5;
    nZ6 = nZ4 + nZ5;
    nI6 = nI4 + nI3;
    
    % Analyze R3
    [nA7,nB7,nZ7] = Activity_35_pfr(nA6,nB6,nI6,nZ6,L3);
    
    % Calculate the conversion
    pct_conv_zoned = 100*(nA1-nA7)/nA1
    
    % Compare to a PFR
    [nA,nB,nZ] = Activity_35_pfr(nA1,nB1,nI1,nZ1,Ltot);
    pct_conv_pfr = 100*(nA1-nA)/nA1

end % of Activity_35.m

