0% found this document useful (0 votes)
25 views29 pages

Reactor Technology Project 1

This document describes a project studying reactions for the combustion and oxidation of sulfur and sulfur dioxide. It outlines the objectives, provides differential equations for mass, energy and momentum, and describes the development of functions and MATLAB code to model the reactions in a multi-tube reactor and analyze profiles of pressure, temperature, velocity and composition.

Uploaded by

niloufar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views29 pages

Reactor Technology Project 1

This document describes a project studying reactions for the combustion and oxidation of sulfur and sulfur dioxide. It outlines the objectives, provides differential equations for mass, energy and momentum, and describes the development of functions and MATLAB code to model the reactions in a multi-tube reactor and analyze profiles of pressure, temperature, velocity and composition.

Uploaded by

niloufar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

TKP4145

Reactor technology
Project 1

Lise Jensen, Kasper Linnestad, Anders Leirpoll and Kjetil Sonerud

April 1, 2014
Contents
1 Objectives 4

2 Initial Information 4

3 Differential Equations 4
3.1 Species Mass Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Energy Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.3 Momentum Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Called functions 5
4.1 Heat Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.2 Enthalpy of Reaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.3 Rate of Reaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.4 Friction Factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.5 Ideal Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.6 Ideal Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.7 Derivative of Pressure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.8 Derivative of Partial Pressure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.9 Derivative of Temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.10 Derivative of Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.11 Reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.12 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5 Construction in MATLAB 21
5.1 The Main File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.1.1 Declaring the variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.1.2 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.1.3 Calculation and Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

6 Results 25

List of program codes


4.1 getHeatCapacity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.2 getReactionEnthalpy.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.3 getReactionRate.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.4 getReactionRateConstant.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.5 getEquilibriumConstant.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.6 getFrictionFactor.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.7 getReynolds.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.8 getIdealDensity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.9 getIdealVelocity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.10 getPressureDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.11 getPartialPressureDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.12 getTemperatureDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.13 getVelocityDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.14 reactor.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.15 getPlotComposition.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.16 getPlotPressure.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.17 getPlotTemperature.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.18 getPlotVelocity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.1 main.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2
5.2 main.m continued . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.3 main.m continued . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.4 main.m continued . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3
1 Objectives
In this project, two reactions for the combustion and oxidization of sulfur and sulfur dioxide are studied:

S + O2 → SO2 (1.1)

1
SO2 + 2 O2 → SO3 (1.2)

The first reaction is carried out in a furnace where sulfur is burned, while the second reaction takes place
in a multi-tube reactor. One of these tubes will be modelled in detail, to look closer at pressure profile,
temperature profile, gas velocity profile, as well as the partial pressures and mole fractions of each component.

2 Differential Equations
The differential equations for mass, energy and momentum are given below. These are solved using a
numerical method as discussed in Sec. ??, and solved in MATLAB as discussed in Sec. ?? and Sec. ??.

2.1 Species Mass Balance

The complete species mass balance is given in Eq. 3.1 below. This equation is used to derive the expressions
for the velocity profile and the partial pressure profiles in the reactor.

∂ cj
+ ∇ · (cj u∗ ) = ∇ · (Dj ∇cj ) + Ri (2.1)
∂t
where the terms represent change of concentration with time, convective transport, molecular diffusion and
the reaction rate, respectively. In this case plug flow is assumed with steady state and no dispersion so the
species mass balance is simplified to
d(u∗z cj )
= νj rρbulk
c (2.2)
dz
Where cj is the concentration of component j ∈ {SO2 , O2 , SO3 , N2 }, u∗z is the mole averaged velocity in the
z-direction, r is the reaction rate of the oxidation (2.2) and ρbulk is the density of the gas in the bulk phase.
By summing over all components to obtain the total mass balance, Eq. (3.3) is obtained
d(u∗z ctot ) X d(u∗z cj ) X
= = rρbulk
c νj (2.3)
dz j
dz j

du∗
By using the ideal gas law, differentiating Eq. (3.3) and solving for dz ,
z
Eq. (??) is obtained
du∗z RT bulk X u∗ dT u∗ dp
= rρc νj + z − z (2.4)
dz p j
T dz p dz

Eq. (??) is used to describe the velocity profile in the reactor.


dpj
In a similar fashion, by using the ideal gas law and differentiating Eq. (3.2) and solving for dz , Eq. (3.5)
is obtained
dpj RT bulk X u∗ dT u∗ dp
= rρc νj + z − z (2.5)
dz p j
T dz p dz

Eq. (3.5) is used to describe the partial pressure profiles in the reactor.

4
2.2 Energy Balance

The complete energy balance is given in Eq. 3.6 below. This equation is used to derive the expression for
the temperature profile in the reactor.
X ∂T X X
ρj cp,j + ρj cp,j uT · ∇T = ∇ · (λ∇T ) − ∆HRi Ri + Q (2.6)
j
∂t j i

where the terms represent change of heat with time, advective transport, heat transport by conduction, heat
effect of the chemical reactions and radiation heat flux, respectively. Assuming steady state, neglecting the
transient and conductive terms and only considering heat flow in axial direction, the equation is simplified
to Eq. 3.7
X dT U
uz ρj cp,j = −∆HRi rSO2 ρbulk − 4 (T − Ta ) (2.7)
j
dz dt

where cp,j is the heat capacity of component j, ∆HRi is the enthalpy of reaction, U is the overall heat
transfer coefficient, dt is the tube diameter, T and Ta is the temperatures inside and outside the tubes,
respectively. Eq. (3.7) is used to describe the temperature profile in the reactor.

2.3 Momentum Balance

To estimate the pressure drop in the reactor, Erguns equation is applied:

dp f ρu2
=− (2.8)
dz dt

where dp
dz is the derivative of pressure with respect to z, f is the friction factor, ρg is the gas density, u is the
fluid velocity and dt is the tube diameter. This expression is using the mass averaged velocity rather than
the mole average velocity, but we assume that they are almost equal in this project.
The friction factor is given in Eq. 3.9 as a function of void fraction, , and the Reynold’s number of the
particle, NRe .
1− 5/6 1 − 
 
f= 3 1.75 + 4.2NRe (2.9)
 NRe

3 Numerical method
In this project, the MATLAB solver ode45 is used to solve the differantial equations. The solver is based on
an explicit Runge-Kutta (4,5) formula, the Dormand-Prince pair[?]. It is a one-step solver—in computing
y(tn ), it needs only the solution at the immediately preceding time point, y(tn−1 ). In general, ode45 is
regarded by MathWorks (the company behind MATLAB) as “(...)the best function to apply as a first try for
most problems.”[?]
If the problem had been sufficiently stiff, the ode15s would have been the solver of choice. This solver is
also used in the case of DAEs. A stiff problem will consist of several processes, at least one of which will
have a (relatively) very small time constant.
In this case, it is verified that the use of ode45 is computationally more efficient than the use of ode15s.
By using tic/toc in MATLAB, the runtime is found to be ∼ 1 s and ∼ 2 s, respectivly. This is regarded as
evidence that the system in question is not particularly stiff, and that ode45 is the most suitable solver.

5
4 MATLAB functions

4.1 Heat Capacity

Program code 4.1: getHeatCapacity.m


1 function cp = getHeatCapacity(temperature)
2 %% Heat Capacity
3 % Calculates the heat capacities of the components at a given temperature,
4 % and returns them as a column vector.
5 % Input:
6 % temperature: The temperature, T [K]
7 % Output: h i
8 % cp: The heat capacities, cp = cp,SO2 cp,O2 cp,SO3 cp,N2
9

10 % cp,i = α + β T + γ T 2
11 cp =[30.178+42.452e-3*temperature-18.218e-6*temperature^2; % [J mol−1 K−1 ]
12 23.995+17.507e-3*temperature-6.628e-6*temperature^2; % [J mol−1 K−1 ]
13 35.634+71.722e-3*temperature-31.539e-6*temperature^2; % [J mol−1 K−1 ]
14 26.159+6.615e-3*temperature-2.889e-7*temperature^2]; % [J mol−1 K−1 ]
15 end

6
4.2 Enthalpy of Reaction

Program code 4.2: getReactionEnthalpy.m


1 function dH = getReactionEnthalpy(temperature)
2 %% Reaction Enthalpy
3 % Calculates the reaction enthalpy for the reaction:
4 % SO2 + 12 O2 → SO3
5 % at a given temperature
6 % Input:
7 % temperature: The temperature, T [K]
8 % Output:
9 % dH: The enthalpy of reaction, ∆rx H
10

11 % The reference temperature, Tref


12 tref = 699.8; % [K]
13

14 % The reaction enthalpy reference, ∆rx H(Tref )


15 dHref = -98787.5; % [J mol−1 ]
16

17 % The parameters, ∆α, ∆β, ∆γ


18 dAlpha = -6.5415; % [J mol−1 K−1 ]
19 dBeta = 0.02057; % [J mol−1 K−2 ]
20 dGamma = -1.0011e-5; % [J mol−1 K−3 ]
21

22 % The reaction enthalpy


23 % ∆rx H(T ) = ∆rx H(Tref ) + ∆α(T − Tref ) + ∆β 2 2
2 (T − Tref ) +
∆γ
3 (T
3 3
− Tref )
24 dH = dHref + dAlpha*(temperature - tref) +...
25 dBeta/2*(temperature^2 - tref^2) +...
26 dGamma/3*(temperature^3 - tref^3); % [J mol−1 ]
27 end

7
4.3 Rate of Reaction

Program code 4.3: getReactionRate.m


1 function rr = getReactionRate(temperature, pressure)
2 %% Reaction Rate
3 % Calculates the reaction rate for the reaction:
4 % SO2 + 12 O2 → SO3
5 % at a given temperature and partial pressures
6 % Input:
7 % temperature: The temperature, T [K]
8 % pressure: The partial pressures, p, [Pa]
9 % Output:
10 % rr: The rate of reaction, r
11

12 % The reaction rate constant, k


13 k = getReactionRateConstant(temperature);
14

15 % The equilibrium constant, Kp


16 kp = getEquilibriumConstant(temperature); %[Pa−1/2 ]
17

18 % The partial pressures, p


19 pSO2 = pressure(1); % [Pa]
20 pO2 = pressure(2); % [Pa]
21 pSO3 = pressure(3); % [Pa]
22
"  2 #
q pSO pSO3
23 % r = −rSO2 = k pSO3
2
pO2 − Kp pSO2

24 rr = k * sqrt(pSO2/pSO3) * (pO2 - (pSO3/(kp*pSO2))^2); % [mol kg−1 s−1 ]


25 end

Program code 4.4: getReactionRateConstant.m


1 function k = getReactionRateConstant(temperature)
2 %% Reaction Rate Constant
3 % Calculates the reaction rate constant for the reaction:
4 % SO2 + 12 O2 → SO3
5 % at a given temperature
6 % Input:
7 % temperature: The temperature, T [K]
8 % Output:
9 % k: The reaction rate constant, k
10

% k = 9.8692 · 10−3 exp −97782



11
T − 110.1 ln(T ) + 848.1
12 k = 9.8692e-3 * ...
13 exp(-97782./temperature - 110.1*log(temperature) + 848.1); % [mol kg−1 s−1 Pa−1 ]
14 end

8
Program code 4.5: getEquilibriumConstant.m
1 function kp = getEquilibriumConstant(temperature)
2 %% Equilibrium Constant
3 % Calculates the equlibrium constant for the reaction:
4 % SO2 + 12 O2 → SO3
5 % at a given temperature
6 % Input:
7 % temperature: The temperature, T [K]
8 % Output:
9 % kp: The equilibrium constant, Kp
10

11 % The gas constant, R


12 r = 8.3144621; % [J mol−1 K−1 ]
13

14 % The equlibrium constant


% Kp = 3.142 · 10−3 exp 98325

15
RT − 11.24
16 kp = 3.142e-3 * exp(98325./(r.*temperature) - 11.24); % [Pa−1/2 ]
17 end

4.4 Friction Factor

Program code 4.6: getFrictionFactor.m


1 function f = getFrictionFactor(void,...
2 density,...
3 velocity,...
4 diameter,...
5 viscosity)
6 %% Friction Factor
7 % Calculates the ergun friction factor for a packed bed reactor,
8 % using the void fraction and the Reynolds number of the catalyst
9 % particle.
10 % Input:
11 % void: The void fraction of the column, 
12 % density: The density of the gas, ρg [kg m−3 ]
13 % velocity: The velocity of the gas, uz [m s−1 ]
14 % diameter: The diameter of the particles, dp [m]
15 % viscosity: The dynamic viscosity of the gas, µ [kg s−1 m−1 ]
16 % Output:
17 % f: The friction factor, f , used in Ergun’s equation
18

19 % Reynold’s number, NRe


20 re = getReynolds(density, velocity, diameter, viscosity);
21

22 % Friction factor,
 f 
1− 5/6 1−
23 % f = 3 1.75 + 4.2NRe N Re

24 f = ((1-void)/(void.^3))*(1.75+(4.2*re^(5/6))*(1-void)/re);
25 end

9
Program code 4.7: getReynolds.m
1 function re = getReynolds(density, velocity, diameter, viscosity)
2 %% Reynold’s number
3 % Calculates the Reynolds Number for flow in a pipe or tube, using the fluid
4 % density, flow velocity, characteristic diameter and dynamic fluid
5 % viscosity
6 % Input:
7 % density: The density of the gas, ρg [kg m−3 ]
8 % velocity: The velocity of the gas, uz [m s−1 ]
9 % diameter: The diameter of the particles, dp [m]
10 % viscosity: The dynamic viscosity of the gas, µ [kg s−1 m−1 ]
11 % Output:
12 % re: The Reynold’s number, NRe
13

14 % NRe = udρµ
15 re = density*velocity*diameter/viscosity;
16 end

4.5 Ideal Density

Program code 4.8: getIdealDensity.m


1 function rho = getIdealDensity(pressure, molarMass, temperature)
2 %% Ideal density
3 % Calculates the density of an ideal gas
4 % Input:
5 % pressure: The partial pressures, p, [Pa]
6 % molarMass: The molecular weights, Mmass [kg mol−1 ]
7 % temperature: The temperature, T [K]
8 % Output:
9 % rho: The density, ρ [kg m−3 ]
10

11 % The gas constant, R


12 r = 8.3144621; % [J mol−1 K−1 ]
13

MT p
14 % ρ = mass
RT
15 rho = molarMass’*pressure/(r*temperature); % [kg m−3 ]
16 end

10
4.6 Ideal Velocity

Program code 4.9: getIdealVelocity.m


1 function vel = getIdealVelocity(mole, temperature, pressure, area)
2 %% Velocity
3 % Calculates the velocity from the ideal gas law:
4 % u = nRTpAc
5 % at a given temperature, pressure, cross sectional area and total number of
6 % moles.
7 % Input:
8 % mole: The molar flows, n̂ [mol s−1 ]
9 % temperature: The temperature, T [K]
10 % pressure: The partial pressures, p [Pa]
11 % area: The cross sectional area, Ac [m2 ]
12 % Output:
13 % vel: The velocity, uz
14

15 % The gas constant, R


16 r = 8.3144621; % [J mol−1 K−1 ]
17

18 % The total number of moles, n


19 n = sum(mole); % [mol s−1 ]
20

21 % The total pressure, p


22 p = sum(pressure); % [Pa]
23

24 % Velocity uz = nRT
Ac p
25 vel = n*r*temperature/(area*p); % [m s−1 ]
26 end

11
4.7 Derivative of Pressure

Program code 4.10: getPressureDerivative.m


1 function dp = getPressureDerivative(void,...
2 density,...
3 velocity,...
4 diameter,...
5 viscosity)
6 %% Pressure Derivative
7 % Calculates the pressure drop in z-direction for a packed bed reactor,
8 % using the ergun friction factor, gas density, superficial velocity and
9 % particle diameter.
10 % Equation source: Ergun, S. (1952), "Fluid flow through
11 % packed columns", Chemical Engineering Progress, 48 (2), 89-94.
12 % Input:
13 % void: The void fraction of the column, 
14 % density: The density of the gas, ρg [kg m−3 ]
15 % velocity: The velocity of the gas, uz [m s−1 ]
16 % diameter: The diameter of the particles, dp [m]
17 % viscosity: The dynamic viscosity of the gas, µ [kg s−1 m−1 ]
18 % Output:
dp
19 % dp: The derivative of the pressure,
dz
20

21 % Friction factor, f
22 f = getFrictionFactor(void, density, velocity, diameter, viscosity);
23

24 % The derivative of pressure


dp 2
25 % = − f ρdtu
dz
26 dp = -(f*density*velocity.^2)/diameter; % [Pa m−1 ]
27 end

12
4.8 Derivative of Partial Pressure

Program code 4.11: getPartialPressureDerivative.m


1 function dp = getPartialPressureDerivative(temperature,...
2 velocity,...
3 nu,...
4 rhoCat,...
5 pressure,...
6 reactionRate,...
7 velocityDerivative,...
8 temperatureDerivative)
9 %% Partial pressures derivative
10 % Calculates the derivative of the partial pressures
11 % Input:
12 % temperature: The temperature, T [K]
13 % velocity: The velocity of the gas, uz [m s−1 ]
14 % nu: The stoichiometric coefficients, ν
15 % rhoCat: The density of the catalyst, ρcat [kg m−3 ]
16 % pressure: The partial pressures, p, [Pa]
17 % reactionRate: The rate of reaction, r [mol s−1 kg−1 ]
duz
18 % velocityDerivative: The derivative of the velocity, [s−1 ]
dz
dT
19 % temperatureDerivative: The derivative of the temperature, [K m−1 ]
dz
20 % Output:
dp
21 % dp: The derivative of the partial pressures,
dz
22

23 % The gas constant, R


24 r = 8.3144621; % [J mol−1 K−1 ]
25

dp duz dT
26 % = RTu ν T ρcat r − upz + Tp
dz z dz dz
27 dp = r*temperature/velocity * nu’ * rhoCat * reactionRate - ...
28 pressure/velocity * velocityDerivative + ...
29 pressure/temperature * temperatureDerivative; % [Pa m−1 ]
30 end
31

13
4.9 Derivative of Temperature

Program code 4.12: getTemperatureDerivative.m


1 function dT = getTemperatureDerivative(temperature,...
2 velocity,...
3 pressure,...
4 rhoCat,...
5 heatTransferCoefficient,...
6 tubeDiameter,...
7 ambientTemperature,...
8 reactionRate,...
9 reactionEnthalpy,...
10 heatCapacity)
11 %% Temperature Derivative
12 % Calculates the derivative of the temperature
13 % Input:
14 % temperature: The temperature, T [K]
15 % velocity: The velocity of the gas, uz [m s−1 ]
16 % pressure: The partial pressures, p, [Pa]
17 % rhoCat: The density of the catalysator, ρcat [kg m−3 ]
18 % heatTransferCoefficient: The overall heat transfer coefficient, U [J s−1 m−2 K−1 ]
19 % tubeDiameter: The diameter of the tube, dt [m]
20 % ambientTemperature: The temperature outside, Toutside [K]
21 % reactionRate: The rate of reaction, r [mol s−1 kg−1 ]
22 % reactionEnthalpy: The enthalpy of reaction, ∆rx H [J mol−1 ]
23 % heatCapacity: The heat capacity of each component, cp [J mol−1 K−1 ]
24 % Output:
dT
25 % dT: The derivative of the temperature,
dz
26

27 % The gas constant, R


28 r = 8.3144621; % [ K Jmol ]
29

dT  
30 % = uRT
zp
T rρcat (−∆ rx H) − 4U
dt (T − Toutside )
dz
31 dT = r*temperature/(velocity*heatCapacity’*pressure) * ...
32 (reactionRate*rhoCat*(-reactionEnthalpy) - ...
33 4*heatTransferCoefficient/tubeDiameter * ...
34 (temperature-ambientTemperature)); % [K m−1 ]
35 end

14
4.10 Derivative of Velocity

Program code 4.13: getVelocityDerivative.m


1 function du = getVelocityDerivative(temperature,...
2 pressure,...
3 rhoCat,...
4 nu,...
5 velocity,...
6 reactionRate,...
7 temperatureDerivative,...
8 pressureDerivative)
9 %% Velocity Derivative
10 % Calculates the derivative of the velocity
11 % Input:
12 % temperature: The temperature, T [K]
13 % pressure: The partial pressures, p, [Pa]
14 % rhoCat: The density of the catalysator, ρcat [kg m−3 ]
15 % nu: The stoichiometric coefficients, ν
16 % velocity: The velocity of the gas, uz [m s−1 ]
17 % reactionRate: The rate of reaction, r [mol s−1 kg−1 ]
dT
18 % temperatureDerivative: The derivative of the temperature, [K m−1 ]
dz
dp
19 % pressureDerivative: The derivative of the pressure, [Pa m−1 ]
dz
20 % Output:
duz
21 % du: The derivative of the velocity,
dz
22

23 % The gas constant, R


24 r = 8.3144621; % [ K Jmol ]
25

26 % Total pressure, p
27 pressure = sum(pressure);
28

29 % Net molar formation, ν


30 nu = sum(nu);
31

duz uz dT dp
32 % = RTp ρcat rν + T dz − upz
dz dz
33 du = r*temperature./pressure*rhoCat*reactionRate*nu+ ...
34 velocity/temperature*temperatureDerivative - ...
35 velocity/sum(pressure)*pressureDerivative; % [s−1 ]
36 end

4.11 Reactor

Program code 4.14: reactor.m


1 function dx = reactor(~,x,par)
2 %% The reactor model
3 % To be used in a matlab integrator (ode45, ode15s, etc.)
4 % Calculates the derivative of the temperature, velocity and partial
5 % pressures, given the temperature, velocity, the partial pressures and all
6 % the other parameters.

15
7 % Input:
8 % x: The state
9 % x(1) is the temperature
10 % x(2) is the velocity
11 % x(3:6) is the partial pressures
12 % par: The parameters as a struct
13 % rhoCat: The density of the catalysator, ρcat [kg m−3 ]
14 % nu: The stoichiometric coefficients, ν
15 % u: The overall heat transfer coefficient, U [J s−1 m−2 K−1 ]
16 % r0: The radius of the tube, r0 [m]
17 % dp: The diameter of the particles, dp [m]
18 % tOutside: The temperature outside, Toutside [K]
19 % void: The void fraction, 
20 % viscosity: The dynamic viscosity, µ [kg m−1 s−1 ]
21 % mMass: The molar masses, Mmass [kg mol−1 ]
22 %% Extracting parameters
23 rhoCat = par.rhoCat;
24 nu = par.nu;
25 heatTransferCoefficient = par.u;
26 tubeDiameter = 2*par.r0;
27 particleDiameter = par.dp;
28 ambientTemperature = par.tOutside;
29 void = par.void;
30 viscosity = par.mu;
31 molecularMass = par.mMass;
32

33 %% Extracting states
34 temperature = x(1);
35 velocity = x(2);
36 pressure = x(3:end);
37

38 %% Calculations
39 reactionRate = getReactionRate(temperature, pressure);
40 reactionEnthalpy = getReactionEnthalpy(temperature);
41 heatCapacity = getHeatCapacity(temperature);
42 density = getIdealDensity(pressure, molecularMass, temperature);
43

44 %% Derivatives;
45 pressureDerivative = getPressureDerivative(void,...
46 density,...
47 velocity,...
48 particleDiameter,...
49 viscosity);
50

51 temperatureDerivative = getTemperatureDerivative(temperature,...
52 velocity,...
53 pressure,...
54 rhoCat,...
55 heatTransferCoefficient,...
56 tubeDiameter,...
57 ambientTemperature,...
58 reactionRate,...
59 reactionEnthalpy,...
60 heatCapacity);

16
61

62 velocityDerivative = getVelocityDerivative(temperature,...
63 pressure,...
64 rhoCat,...
65 nu,...
66 velocity,...
67 reactionRate,...
68 temperatureDerivative,...
69 pressureDerivative);
70

71 partialPressureDerivative = getPartialPressureDerivative(temperature,...
72 velocity,...
73 nu,...
74 rhoCat,...
75 pressure,...
76 reactionRate,...
77 velocityDerivative,...
78 temperatureDerivative);
79 % Return the derivatives
80 dx = [temperatureDerivative;
81 velocityDerivative;
82 partialPressureDerivative];
83 end

4.12 Plots

Program code 4.15: getPlotComposition.m


1 function getPlotComposition(partialPressure,x,speciesList,ylims,suffix)
2 %% Plot the composition
3 % Create a plot of the partial pressures of the components, and plots the
4 % molar fractions assuming ideal gas. Saves the plots as pdfs.
5 % Input:
6 % partialPressure: The partial pressures as a matrix where the rows
7 % correspond to the pacial coordinate, and the columns
8 % correspond to the different species.
9 % x: The spacial coordinate as a vector
10 % speciesList: The list of species as a cell array.
11 % ylims: Partial pressure limits
12 % suffix: A name suffix for the pdf files.
13

14

15 % Calculate mole fractions, xi


16 for i = 1:size(partialPressure,1)
17 moleFraction(i,:) = partialPressure(i,:)/sum(partialPressure(i,:));
18 end
19

20 if length(speciesList) < 4
21 color = {’k’,’r’,’b’};
22 else
23 color = jet(length(speciesList));
24 end
25

26 molelims = [0 max(max(moleFraction(:,1:length(speciesList))))];
27

17
28 % Plot each species
29 for i = 1:length(speciesList)
30 % Generating legend
31 legendString{i} = [’$\ce{’ speciesList{i} ’}$’];
32

33 % Plot pressure
34 h = figure(i);
35 plot(x,partialPressure(:,i),’k’,’LineWidth’,2);
36 xlabel(’$z$ [m]’);
37 ylabel([’$p_{\ce{’ speciesList{i} ’}}$ [Pa]’]);
38 xlim([min(x) max(x)]);
39 ylim(ylims);
40 matlabfrag([speciesList{i} ’_pressure’ suffix],’handle’,h);
41 close(h);
42

43 % Plot mole fraction


44 h = figure(i);
45 plot(x,moleFraction(:,i),’k’,’LineWidth’,2);
46 xlabel(’$z$ [m]’);
47 ylabel([’$x_{\ce{’ speciesList{i} ’}}$’]);
48 xlim([min(x) max(x)]);
49 ylim(molelims);
50 matlabfrag([speciesList{i} ’_fraction’ suffix],’handle’,h);
51 close(h);
52

53 % Plot all the partial pressures


54 hPressure = figure(length(speciesList)+1);
55 hold on
56 if length(speciesList) < 4
57 plot(x,partialPressure(:,i),color{i},’LineWidth’,2)
58 else
59 plot(x,partialPressure(:,i),’Color’,color(i,:),’LineWidth’,2)
60 end
61

62 % Plot all the mole fractions


63 hFraction = figure(length(speciesList)+2);
64 hold on
65 if length(speciesList) < 4
66 plot(x,moleFraction(:,i),color{i},’LineWidth’,2)
67 else
68 plot(x,moleFraction(:,i),’Color’,color(i,:),’LineWidth’,2)
69 end
70

71

72 end %for
73

74 hPressure = figure(length(speciesList)+1);
75 xlabel(’$z$ [m]’);
76 ylabel(’$p$ [Pa]’);
77 legend(legendString, ’Location’, ’Best’);
78 xlim([min(x) max(x)]);
79 ylim(ylims);
80 matlabfrag([’partialpressure’ suffix],’handle’,hPressure);
81 close(hPressure);

18
82

83 hFraction = figure(length(speciesList)+2);
84 xlabel(’$z$ [m]’);
85 ylabel(’$x$’);
86 legend(legendString, ’Location’, ’Best’);
87 xlim([min(x) max(x)]);
88 ylim(molelims);
89 matlabfrag([’molefraction’ suffix],’handle’,hFraction);
90 close(hFraction);
91 end

Program code 4.16: getPlotPressure.m


1 function getPlotPressure(pressure,x,ylims,suffix,t)
2 %% Plot the temperature
3 % Creates a plot of the temperature and saves it as a pdf.
4 % Input:
5 % pressure: The velocity as a matrix where the rows correspond to
6 % the time, and the columns correspond to the spacial
7 % coordinate.
8 % x: The spacial coordinate as a vector
9 % ylims: Pressure limits
10 % suffix: A name suffix for the pdf files.
11 % t: The time as a vector (optional)
12

13 pressure = sum(pressure,2);
14

15 if nargin < 5
16 h = figure(1);
17 plot(x,pressure,’k’,’LineWidth’,2);
18 xlabel(’$z$ [m]’);
19 ylabel(’$p$ [Pa]’);
20 xlim([min(x) max(x)]);
21 ylim(ylims);
22 else
23 disp(’Not yet implemented’);
24 end
25

26 matlabfrag([’pressure’ suffix],’handle’,h);
27

28 close(h);
29 end

19
Program code 4.17: getPlotTemperature.m
1 function getPlotTemperature(temperature,x,ylims,suffix,t)
2 %% Plot the temperature
3 % Creates a plot of the temperature and saves it as a pdf.
4 % Input:
5 % temperature: The velocity as a matrix where the rows correspond to
6 % the time, and the columns correspond to the spacial
7 % coordinate.
8 % x: The spacial coordinate as a vector.
9 % ylims: Temperature limits.
10 % suffix: A name suffix for the pdf files.
11 % t: The time as a vector (optional)
12

13 if nargin < 5
14 h = figure(1);
15 plot(x,temperature,’k’,’LineWidth’,2);
16 xlabel(’$z$ [m]’);
17 ylabel(’$T$ [K]’);
18 xlim([min(x) max(x)]);
19 ylim(ylims);
20 else
21 disp(’Not yet implemented’);
22 end
23

24 matlabfrag([’temperature’ suffix],’handle’,h);
25

26 close(h);
27 end

20
Program code 4.18: getPlotVelocity.m
1 function getPlotVelocity(velocity,x,ylims,suffix,t)
2 %% Plot the velocity
3 % Creates a plot of the velocity and saves it as a pdf.
4 % Input:
5 % velocity: The velocity as a matrix where the rows correspond to the
6 % time, and the columns correspond to the spacial coordinate.
7 % x: The spacial coordinate as a vector
8 % ylims: Velocity limits
9 % suffix: A name suffix for the pdf files.
10 % t: The time as a vector (optional)
11

12 if nargin < 5
13 h = figure(1);
14 plot(x,velocity,’k’,’LineWidth’,2);
15 xlabel(’$z$ [m]’);
16 ylabel(’$v_z$ $\mathrm{[m s^{-1}]}$’);
17 xlim([min(x) max(x)]);
18 ylim(ylims);
19 else
20 disp(’Not yet implemented’);
21 end
22

23 matlabfrag([’velocity’ suffix],’handle’,h);
24

25 close(h);
26 end

21
5 MATLAB main script
5.1 The Main File

Program code 5.1: main.m


1 %% Main file
2 % Authors:
3 % Kjetil Sonerud
4 % Lise Jensen
5 % Anders Leirpoll
6 % Kasper Linnestad
7 % Created: 01-Feb-14
8 % Last edited: 11-Feb-14
9 % Requires:
10 % getEquilibriumConstant.m
11 % getFrictionFactor.m
12 % getHeatCapacity.m
13 % getIdealDensity.m
14 % getIdealVelocity.m
15 % getPartialPressureDerivative.m
16 % getPlotComposition.m
17 % getPlotPressure.m
18 % getPlotTemperature.m
19 % getPlotVelocity.m
20 % getPressureDerivative.m
21 % getReactionEnthalpy.m
22 % getReactionRate.m
23 % getReactionRateConstant.m
24 % getReynolds.m
25 % getTemperatureDerivative.m
26 % getVelocityDerivative.m
27 % reactor.m
28 % matlabfrag (https://dl.dropboxusercontent.com/u/6304542/matlabfrag.m)
29 % Comments:
30 % This script simulates a PFM for a oxidation sulfur dioxide
31 %% TKP4145 - Reactor technology
32 % Project 1
33 clear all
34 close all
35 clc

22
5.1.1 Declaring the variables

Program code 5.2: main.m continued


36 tic;
37

38 %% Given information
39 % Feed per tube, n0
40 n0 = 0.2149; % [mol s−1 ]
41

42 % Length of reactor, L
43 l = 6.096; % [m]
44

45 % Void fraction, 
46 par.void = 0.45;
47

48 % Initial density, ρ0
49 rho0 = 0.865; % [kg m−3 ]
50

51 % Initial pressure, p0
52 p0 = 202650; % [Pa]
53

54 % Diameter of particles, dp
55 par.dp = 0.004572; % [m]
56

57 % Radius of tube, r0
58 par.r0 = 0.0353; % [m]
59

60 % Dynamic viscosity, µ
61 par.mu = 3.7204e-5; % [kg m−1 s−1 ]
62

63 % Overall heat transfer coefficient, U


64 par.u = 56.783; % [J m−2 s−1 K−1 ]
65

66 % Cross sectional area, Ac


67 ac = 0.00392; % [m2 ]
68

69 % Temperature outside, Toutside


70 par.tOutside = 702.6; % [K]
71

72 % Catalyst density ρcat


73 par.rhoCat = 541.42; % [kg m−3 ]
74
h iT
75 % Molar fractions, xSO2 xO2 xSO3 xN2
76 xSO2 = 0.11;
77 xO2 = 0.1;
78 xSO3 = 1e-10;
79 xN2 = 1 - xSO2 - xO2 - xSO3;
80 x0 = [xSO2 xO2 xSO3 xN2]’;
81

82 % Stoichiometric matrix, ν
83 par.nu = [-1 -0.5 1 0];
84

23
5.1.2 Initialization

Program code 5.3: main.m continued


85 % Molar mass, Mmass
86 par.mMass = 1e-3*[64.064 31.998 80.063 28.014]’; % [kg mol−1 ];
87 %% Initialization
h iT
88 % Inlet partial pressures pSO2 pO2 pSO3 pN2
89 p0 = p0*x0; % [Pa]
90

91 % Inlet temperature, T0
92 t0 = [777.78 666.67]; % [K]
93

94 % Inlet velocity, uz,0


95 u0 = getIdealVelocity(n0,t0,p0,ac); % [m s−1 ]
96

97 % Inlet state, x0
98 x0 = [t0 ;
99 u0 ;
100 p0 p0];
101

24
5.1.3 Calculation and Plotting

Program code 5.4: main.m continued


102

103 options = odeset(’RelTol’,1e-8,’AbsTol’,1e-10);


104 %% Calculation
105 for i = 1:size(x0,2)
106 % Integrate over the whole reactor
107 [z, x] = ode45(@reactor,[0 l],x0(:,i),options,par);
108

109 % Temperature, T (z) [K]


110 t = x(:,1);
111 getPlotTemperature(t,z,[650 880],num2str(t0(i)));
112

113 % Velocity, uz (z) [m s−1 ]


114 u = x(:,2);
115 getPlotVelocity(u,z,[1.4 2.5],num2str(t0(i)))
116

117 % Partial pressure, p(z) [Pa]


118 p = x(:,3:end);
119 getPlotComposition(p,z,{’SO2’ ’O2’ ’SO3’},[0 0.25e5],num2str(t0(i)));
120

121 % Total pressure, p(z) [Pa]


122 getPlotPressure(p,z,[1.2e5 2.1e5],num2str(t0(i)));
123

124 % Check if mass is conserved (constant mass flux G = ρ uz )


125 for j = 1:length(z)
126 g(j) = getIdealDensity(p(j,:)’,par.mMass,t(j))*u(j); % [kgm−2 s−1]
127 end %for
128

129 % Deviation from initial mass flux: G0 = ρ0 uz,0


130 g0 = getIdealDensity(p0,par.mMass,t0(i))*u0(i);
131 maxDeviation = max(abs(g0-g));
132 fprintf(’Maximum deviation:\t%.8f\n’,maxDeviation);
133

134 % Temperature hotspots


135 [t_hs, index] = max(t);
136 fprintf(’Hotspot for T_0 = %.3fK: %.3fK at z = %.2fm \n’,x0(1,i),t_hs,z(index));
137 end %for
138

139 %% Calculating run time


140 runtime = toc;
141 fprintf(’The script used %.3f sec.\n’,runtime);

25
6 Results
Fig. 1 displays the change in mole fractions of SO2 , O2 and SO3 with the length of the reactor. As expected
the mole fractions of the reactants, SO2 and O2 , decreases as they are used in the reaction, and the mole
fraction of SO3 increases. For the case with inlet temperature of 666,67 K the mole fraction of SO3 increases
linearly the first 3 m, and then the increase flattens out. For the case with inlet temperature of 777 K the
increase of the mole fraction of SO3 is steeper in the beginning and at about 2 m into the reactor it is
constant. This difference in the two cases is due to the temperature dependency of the reaction rate.

SO2 SO2
0.1 O2 0.1 O2
SO3 SO3
0.09 0.09

0.08 0.08

0.07 0.07

0.06 0.06
x

x
0.05 0.05

0.04 0.04

0.03 0.03

0.02 0.02

0.01 0.01

0 0
0 1 2 3 4 5 6 0 1 2 3 4 5 6
z [m] z [m]

(a) Mole fractions of species with T0 = 666,67 K (b) Mole fractions of species with T0 = 777,78 K

Figure 1: Mole fractions of species. Note that xN2 is omitted for clarity.

As can be seen in Fig. 2, the partial pressures of the reactants decrease and more product is produced along
the reactor tube. The change in partial pressure is large at the tube inlet, and decreases further down the
tube, closer to equilibrium.

×104 ×104
2.5 2.5
SO2 SO2
O2 O2
SO3 SO3
2 2

1.5 1.5
p [Pa]

p [Pa]

1 1

0.5 0.5

0 0
0 1 2 3 4 5 6 0 1 2 3 4 5 6
z [m] z [m]

(a) Partial pressure of species with T0 = 666,67 K (b) Partial pressure of species with T0 = 777,78 K

Figure 2: Partial pressure of species. Note that pN2 is omitted for clarity. Note also that all the partial
pressures are reduced towards the end of the reactor due to drop in total pressure

Fig. 3 shows how the pressure changes along the length of the reactor. When the gas velocity through the
reactor increases, the pressure drops according to Ergun’s equation, (3.8). The linearity of the pressure drop

26
is due to conservation of mass, ρ0 u0 = ρg uz , which makes Ergun’s equation linear. Conservation of mass is
not explicitly used in the modeling, but it is observed that this relationship is valid.

×105 ×105
2.1 2.1

2 2

1.9 1.9

1.8 1.8

1.7 1.7
p [Pa]

p [Pa]
1.6 1.6

1.5 1.5

1.4 1.4

1.3 1.3

1.2 1.2
0 1 2 3 4 5 6 0 1 2 3 4 5 6
z [m] z [m]

(a) Total pressure in the reactor with T0 = 666,67 K (b) Total pressure in the reactor with T0 = 777,78 K

Figure 3: Total pressure in the reactor. Note the pressure drop.

The reactor temperature profile can be seen in Fig. 4. At the reactor tube inlet the temperature is high due
to the reaction being exothermic and rate of reaction being a function of concentration, which is high at the
inlet. The reaction continues to heat up the reactor tube until a temperature hotspot at 1,70 m and 0,32 m
of Thotspot = 738,86 K and Thotspot = 863,09 K for low and high initial temperature, respectively. From here,
the reactor cooling exceeds heat of reaction and the temperature decreases and stabilizes.

880 880

860 860

840 840

820 820

800 800

780 780
T [K]

T [K]

760 760

740 740

720 720

700 700

680 680

660 660

0 1 2 3 4 5 6 0 1 2 3 4 5 6
z [m] z [m]

(a) Temperature profile in the reactor with T0 = 666,67 K (b) Temperature profile in the reactor with T0 = 777,78 K

Figure 4: Temperature profile in the reactor.

27
The velocity profile in the reactor is shown in Fig. 5. At the reactor tube inlet the temperature is high,
which causes an increase in velocity as expected from the assumption of ideal gas. Further down the tube is
cooled, which causes the velocity to drop, before the pressure drop causes a further increase in velocity.

2.4 2.4

2.3 2.3

2.2 2.2

2.1 2.1
vz [ms−1 ]

vz [ms−1 ]
2 2

1.9 1.9

1.8 1.8

1.7 1.7

1.6 1.6

1.5 1.5

1.4 1.4
0 1 2 3 4 5 6 0 1 2 3 4 5 6
z [m] z [m]

(a) Velocity profile in the reactor with T0 = 666,67 K (b) Velocity profile in the reactor with T0 = 777,78 K

Figure 5: Velocity profile in the reactor.

28
References
[1] Jakobsen, Hugo A., Fixed Bed Reactors - lecture notes in TKP4145. Department of Chemical Engineering,
NTNU. Spring 2011.

[2] Dormand, J. R. and P. J. Prince, A family of embedded Runge-Kutta formulae, J. Comp. Appl. Math.,
Vol. 6, 1980, pp. 19–26.

[3] http://www.mathworks.se/help/matlab/ref/ode45.html, retrieved 17.02.2014

[4] Ergun, S.,Fluid flow through packed columns, Chemical Engineering Progress, 48 (2), 89-94

29

You might also like