Addressing the Predominant Stairwell Injection Issues - MATLAB (Edition) - Advanced

In this example, we have incorporated the tables for stairwell, exterior, and door leakages from the Smoke Control book. As the value of 'DeltaP_min' changes in the first loop, our MATLAB code automatically adjusts the variables for each leakage to ensure that 'DeltaP_min' reaches a minimum value of 12.4 by the end. This adjustment guarantees compliance with the stairwell pressurization requirement.

W_building = 75;
L_building = 75;
Stairwell_L = 3;
Stairwell_W = 9;
Floor_height = 4;
N_stories = 15;
Door_W = 0.91;
Door_H = 2.01;
Door_knob = 0.076;
Max_Force_opening = 133;
F_door_closing = 20;
T_out = -10; T_out_K = T_out + 273.15;
T_inside = 20; T_inside_K = T_inside + 273.15;
H = N_stories * Floor_height;
FT = 3460*((1/T_out_K) - (1/T_inside_K));
Roof_leakage = 5.2e-5;
% Constants
S_leakage_values =[1.4e-5, 1.1e-4, 3.5e-4, 5e-4];
ExteriorWall_leakage_values =[5e-5, 1.7e-4, 3.5e-4 ,1.2e-3];
Door_leakage_values =[0.0074,0.015,0.022,0.032];

Air_density=1.2; 
C=0.65;

flag=false;

for i=1:length(S_leakage_values)
    for j=1:length(ExteriorWall_leakage_values)
        for k=1:length(Door_leakage_values)
            S_leakage=S_leakage_values(i);
            ExteriorWall_leakage_init=ExteriorWall_leakage_values(j);
            Door_leakage_init=Door_leakage_values(k);

            S_leakage_adjusted=S_leakage; % Initialize adjusted value
            ExteriorWall_leakage_adjusted=ExteriorWall_leakage_init; 
            Door_leakage_adjusted=Door_leakage_init; 

            counter=0; 
            DeltaP_min=9;

            while DeltaP_min <=12.4 && counter<10000

                S_leakage_adjusted = S_leakage_adjusted * 1.01; % Increase by 1%
                ExteriorWall_leakage_adjusted = ExteriorWall_leakage_adjusted * 1.01; % Increase by 1%
                Door_leakage_adjusted = Door_leakage_adjusted * 1.01; % Increase by 1%

                Asb=((Stairwell_W+Stairwell_L)*S_leakage_adjusted*H)+N_stories*Door_leakage_adjusted;
                Abo=0.5*ExteriorWall_leakage_adjusted*((W_building+L_building-(2*(Stairwell_L+Stairwell_W)))*H+(2*Door_leakage_adjusted));

                Aso = S_leakage_adjusted*(Stairwell_W+Stairwell_L)*H;
            Roof_total = 2*Door_leakage_adjusted + (Stairwell_L*Stairwell_W*Roof_leakage);


                FR=1+((Asb/Abo)^2); 

                Deltap_SBt=(FT/FR)*H+DeltaP_min; 

                DeltaP_Sbt_avg=0.5*(Deltap_SBt+DeltaP_min); 

                DeltaP_So=FR*DeltaP_min; 

                DeltaP_Sot=FR*Deltap_SBt; 

                DeltaP_So_Avg=0.5*(DeltaP_So+DeltaP_Sot); 

                M_Sb=C*Asb*sqrt(2*Air_density*DeltaP_Sbt_avg); 

                M_SO=C*Aso*sqrt(2*Air_density*DeltaP_So_Avg); 

                M_roof=C*(Roof_total)*sqrt(2*Air_density*(0.5*(DeltaP_Sot+DeltaP_So))); 

                M_total=M_roof+M_SO+M_Sb; 

                Density_outside=Air_density*(T_inside_K/T_out_K); 

                V_vent_min_req=M_total/Density_outside; 

                DeltaP_min=DeltaP_min+.1;  

                counter=counter+1;
            end

            if(DeltaP_min>12.4)
                fprintf('The required condition is met after :%d iterations\n',counter);
                fprintf('Final Variable Values for S_leakage = %e:\n', S_leakage_adjusted);
                fprintf('ExteriorWall_leakage_init: %.6f\n', ExteriorWall_leakage_adjusted);
                fprintf('Door_leakage_init: %.6f\n', Door_leakage_adjusted);
                fprintf('Delta P Min: %.2f\n', DeltaP_min);
fprintf('Mass Flow Rate Sb: %.2f\n', M_Sb);
fprintf('Mass Flow Rate SO: %.2f\n', M_SO);
fprintf('Mass Flow Rate Roof Total: %.2f\n', M_roof);
fprintf('Total Mass Flow Rate: %.2f\n', M_total);
fprintf('New Fan Capacity: %.2f\n', M_total/Density_outside);

                
                flag=true;
                break;
            else 
                fprintf('The required condition could not be met after :%d iterations for S_leakage = %e\n',counter, S_leakage_adjusted);
            end
        end
        if flag, break; end
    end
    if flag, break; end
end