diff --git a/General_Plug_Flow_Reactor.m b/General_Plug_Flow_Reactor.m deleted file mode 100644 index f2cfbf4f979..00000000000 --- a/General_Plug_Flow_Reactor.m +++ /dev/null @@ -1,75 +0,0 @@ -% This code snippet is a sample to model a converging nozzle as -% Plug Flow Reactor with given dimensions and an incoming gas. The pressure -% is not constant here as opposed to the Python Version of the Plug Flow -% Reactor modelling. - -%% Setting the Gas -clear all -close all -clc -gas_conv = IdealGasMix('gri30.cti'); -ich4 = speciesIndex(gas_conv,'CH4'); -io2 = speciesIndex(gas_conv,'O2'); -in2 = speciesIndex(gas_conv,'N2'); -nsp = nSpecies(gas_conv); -x = zeros(nsp,1); -% Change the below values for different Phi values of methane Combsution -x(ich4,1) =0.2899; -x(io2,1) = 2.0; -x(in2,1) = 7.52; -set(gas_conv,'T',1473,'P',4.4763e5,'MoleFractions',x); -gas_conv=equilibrate(gas_conv,'HP'); - -%% Converging Section -% The Dimensions and conditions of the reactor are given below -A_in=0.018; % Inlet Area -A_out=0.003; % Exit Area -L=1.284*0.0254; % Length of the reactor -n=100; % The whole reactor is divided into n small reactors -mdot_conv=1.1466; % Mass flow rate into the reactor -% k = -1 makes the solver solve for converging area. -% Use k = +1 for diverging area. make sure to change the inlet and exit area for diverging area -% Use k = 0 for constant cross sectional area -k=-1; -%-------------------------------------------------------------- -dAdx=abs(A_in-A_out)/L; -[T_conv,rho_conv,x_conv,Y_conv]=PFR_setup(A_in,A_out,L,n,k,gas_conv,mdot_conv); % The above values are passed on to the PFR function to solve for density, temperature and Mas fractions - -for i=1:length(x_conv) - gas_after_solving_conv = gas_conv; - set(gas_after_solving_conv,'Temperature',T_conv(i),'Density',rho_conv(i),'MassFractions',Y_conv(i,:)); % The gas is set to the solved property values at each location - A_conv(i) = A_in+k*x_conv(i)*dAdx; - vx_conv(i) = mdot_conv./(A_conv(i)*rho_conv(i)); % Velocity is calculated from Mass flow rate, Area and Density - R_conv(i)=8314/meanMolecularWeight(gas_after_solving_conv); % Specific Gas Constant - M_conv(i) = vx_conv(i)/soundspeed(gas_after_solving_conv); % Mach No. is calculated from local velocity and local speed of sound - P_conv(i) = rho_conv(i)*R_conv(i)*T_conv(i); % Pressure is calculated from density, temeprature adn gas constant - disp('Finished Solving Convergent part, setting gas now') - i - length(x_conv) -end - -%% Plotting -plot(x_conv,M_conv) -xlabel('Position') -ylabel('Mach No') -title('Mach No Variation') -figure(2) -plot(x_conv,A_conv) -xlabel('Position') -ylabel('Area(m^2)') -title('Reactor Profile') -figure(3) -plot(x_conv,T_conv) -xlabel('Position') -ylabel('Temperature') -title('Temperature Variation') -figure(4) -plot(x_conv,rho_conv) -xlabel('X-Position (m)') -ylabel('Density (Kg/m^3)') -title('Density Variation') -figure(5) -plot(x_conv,P_conv) -xlabel('X-Position (m)') -ylabel('Pressure (Pa)') -title('Pressure Variation') diff --git a/PFR_setup.m b/PFR_setup.m deleted file mode 100644 index e60bd879f91..00000000000 --- a/PFR_setup.m +++ /dev/null @@ -1,34 +0,0 @@ -function [T,rho,x,Y]=PFR_setup(A_in,A_out,L,n,k,gas,mdot) - -dAdx=abs(A_in-A_out)/L; -dx=L/n;% The whole length of the reactor is divided into n small lengths - -T(1)=temperature(gas); -P(1)=pressure(gas); -Y(1,:)=massFractions(gas); -rho(1)=density(gas); - -x=0:dx:L; - -for i=2:length(x) - - i - Total_i=length(x) - nsp = nSpecies(gas); - initial(1) = rho(i-1); %--------------------------------------------------------------------------------------------------------- - initial(2) = T(i-1); %----The values of variables at previous location are given as initial values to the current iteration---- - initial(3:nsp+2) = Y(i-1,:); %--------------------------------------------------------------------------------------------------------- - limits=[x(i-1),x(i)]; % The limmits of the current reactor - set(gas,'T',T(i-1),'Density',rho(i-1),'MoleFractions',Y(i-1,:)); - options = odeset('RelTol',1.e-10,'AbsTol',1e-10,'InitialStep',1e-8,'NonNegative',1); - [x_soln,y]= ode15s(@PFR_solver_CANTERA,limits,initial,options,gas,mdot,A_in,dAdx,k); % These values are passed onto the ode15s solver - - T(i)=y(end,2); %---------------------------------------------- - rho(i)=y(end,1); %-----The last location values are copied------ - Y(i,:)=y(end,3:nsp+2); %---------------------------------------------- - -end - - - -end diff --git a/PFR_solver_CANTERA.m b/PFR_solver_CANTERA.m deleted file mode 100644 index 68e98145de3..00000000000 --- a/PFR_solver_CANTERA.m +++ /dev/null @@ -1,43 +0,0 @@ -function [F] = PFR_solver_CANTERA(x,initial,gas,mdot,A_in,dAdx,k) - -rho = initial(1); -T = initial(2); -Y = initial(3:length(initial)); - -if k==1 - A = A_in-k*dAdx*x; -elseif k==-1|k==0 - A=A_in+k*dAdx*x; - dAdx=-dAdx; -end - -MW_mix = meanMolecularWeight(gas); -Ru = 8314; -R = Ru/MW_mix; -nsp = nSpecies(gas); -vx = mdot/(rho*A); -P = rho*R*T; -if k~=0 - set(gas,'Temperature',T,'Density',rho,'MassFractions',Y); % the gas is set to the corresponding properties during each iteration of the ode loop -else - set(gas,'Temperature',T,'Pressure',P,'MassFractions',Y); % the gas is set to the corresponding properties during each iteration of the ode loop - -end -MW = molecularWeights(gas); -h = enthalpies_RT(gas).*R.*T; -w = netProdRates(gas); -%-------------------------------------------------------------------------- -%---F(1), F(2) and F(3:end) are the differential equations modelling the--- -%---density, temperature and mass fractions variations along a plug flow--- -%-------------------------reactor------------------------------------------ -%-------------------------------------------------------------------------- -F(1)=((1-R/cp_mass(gas))*((rho*vx)^2)*(1/A)*(dAdx) + rho*R*sum(MW.*w.*(h-MW_mix*cp_mass(gas)*T./MW))/(vx*cp_mass(gas)) ) / (P*(1+vx^2/(cp_mass(gas)*T)) - rho*vx^2); -F(2) = (vx*vx/(rho*cp_mass(gas)))*F(1) + vx*vx*(1/A)*(dAdx)/cp_mass(gas) - (1/(vx*rho*cp_mass(gas)))*sum(h.*w.*MW); - -for i = 3:nsp+2 - F(i) = w(i-2)*MW(i-2)/(rho*vx); -end -F = F'; - -end -