33
TKP4145 Reactor technology Project 2 Lise Jensen, Kasper Linnestad, Anders Leirpoll and Kjetil Sonerud March 25, 2014

Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

TKP4145

Reactor technology

Project 2

Lise Jensen, Kasper Linnestad, Anders Leirpoll and Kjetil Sonerud

March 25, 2014

Page 2: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

Contents

1 Objectives 4

2 Differential Equations 42.1 Species Mass Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 Ideal Gas Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 The Equation of Continuity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.4 Energy Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.5 Momentum Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Numerical method 7

4 MATLAB functions 84.1 Mole Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.2 Average Molar Mass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.3 Ideal Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.4 Viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.5 Reynolds Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.6 Heat Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.7 Reaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.8 Heat Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.9 Diffusivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.10 Derivative of Pressure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.11 Derivative of Temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.12 Derivative of Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.13 Derivative of Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.14 Derivative of Mass Fraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.15 Reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.16 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.17 Inlet States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.18 Mass matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5 MATLAB main script 285.1 Main . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

6 Results 30

List of program codes

4.1 getMolarFractions.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.2 getAvgMolarMass.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.3 getIdealDensity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.4 getViscosity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.5 getReynolds.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.6 getHeatCapacity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.7 getReaction.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.8 getHeatCoefficients.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.9 getDiffusivity.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.10 getPressureDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.11 getTemperatureDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.12 getDensityDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.13 getVelocityDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.14 getMassFractionDerivative.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2

Page 3: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.15 reactor.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.16 getConstants.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.17 getInletStates.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.18 getMassMatrix.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275.1 main.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

3

Page 4: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

1 Objectives

In this project, the synthesis gas production process in a multi-tube reactor is studied:

Steam reforming:CH4 + H2O −−⇀↽−− CO + 3 H2 (1.1)

Water-gas-shift-reaction:CO + H2O −−⇀↽−− CO2 + H2 (1.2)

Sum of Eq. (1.1) and (1.2):CH4 + 2 H2O −−⇀↽−− CO2 + 4 H2 (1.3)

The reaction is carried out in a multi-tube packed bed reactor. One of the tubes is modelled in detail totake a closer look at the pressure, temperature and velocity profiles, as well as the mole fractions of thecomponents.

2 Differential Equations

The differential equations for mass, energy and momentum are given below. In addition, the continuityequation (from the total mass balance) and the differential equation for density (from the ideal gas law) isused. These are solved using a numerical method as discussed in Sec. 3, and solved in MATLAB as discussedin Sec. 4 and Sec. 5.

Due to the geometrical properties of the reactor, cylindrical coordinates are used in all the differentialequations.

2.1 Species Mass Balance

The complete species mass balance is given in Eq. 2.1 below. This equation is used to derive an expression

for∂ω

∂z.

∂ρω

∂t+∇ · (ρωuT) = −∇ · j + R (2.1)

where the terms represent the transient term, convection, dispersion and reaction rate, respectively.

By assuming steady-state, the transient term can be neglected. The radial convective contribution and theaxial dispersion can be neglected, as well as any change in angular direction due to symmetry. The reactionrate is modified so that it is expressed in terms of moles. The dispersion term in the radial direction is givenby

jr = −ρD ∂ω

∂r(2.2)

By applying the aforementioned assumptions, Eq. (2.1) reduces to

∂z(ρωuz) =

1

r

∂r

(rρD

∂ω

∂r

)+ R (2.3)

where ρ is the density of the gas, r is the radius of the tube, D is the mass transfer coefficients, ω is themass fractions, uz is the axial velocity and R is the reaction rates on a mass basis.

4

Page 5: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

Applying the product rule and solving for ∂ω∂z

∂ω

∂z=

1

ρuz

−ωuz ∂ρ∂z− ρω ∂uz

∂z+ D

r

∂ω

∂r+ ρ

∂2ω

∂r2+∂ω

∂r

∂ρ

∂r

)+ R

(2.4)

where

R = (1− ε)ρcatMw ⊗NT r (2.5)

ρcatis the density of the catalyst, ε is the void fraction, Mmass is the molar masses, NT is the stoichiometricmatrix and r are the reaction rates of the different reactions occurring in the reactor on a molar basis.

2.2 Ideal Gas Law

Want to find an expression for how the density of the gas changes down the reactor. The density is givenby the ideal gas law

ρ =Mmassp

RT(2.6)

where Mmass is the average molar mass of the gas and p is the pressure. Differentiating the expression for ρwith respect to the axial length of the reactor, z, assuming that the average mole weight does not change inthe axial direction.

∂ρ

∂z=

∂z

(Mmassp

RT

)=Mmass

R

(1

T

∂p

∂z− p

T 2

∂T

∂z

)(2.7)

2.3 The Equation of Continuity

The equation of continuity is used to derive an expression for the derivative of the velocity with respect toz. The equation for is given by

∂ρ

∂t+∇ · (ρu) = 0 (2.8)

Assuming steady state ( ∂∂t = 0), symmetry in angular direction ( ∂∂θ = 0), and that the convection in theradial direction is negligible, the continuity equation is reduced to

∂ρuz∂z

= 0 (2.9)

∂uz∂z

= −uzρ

∂ρ

∂z(2.10)

2.4 Energy Balance

The energy balance is used to derive an expression for ∂T∂z . The energy balance, neglecting the heat of

mixing, pV -work and the viscous dissipation term is given by

ρcp∂T

∂t+ ρcpu

T · ∇T = ∇ · (λ∇T )−∆rxHTR (2.11)

Where the terms represent the transient term, convective term, diffusion term and the reaction term, respec-tively. Considering steady state and symmetry in angular direction, and assuming that the diffusion in axial

5

Page 6: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

direction, the convective contribution in radial direction and that the change in effective radial conductionis negligible, the energy balance becomes

∂T

∂z=

1

ρcpuz

λeff,r

(1

r

∂T

∂r+∂2T

∂r2

)−∆rxHTR

(2.12)

2.5 Momentum Balance

To estimate the pressure drop in the reactor, Ergun’s equation is applied [4]

∂p

∂z= −fρgu

2

dt(2.13)

where ∂p∂z is the derivative of pressure with respect to z, f is the friction factor, ρg is the cross-sectional

averaged gas density, u is the cross-sectional averaged fluid velocity and dt is the tube diameter.

The friction factor is given in Eq. 2.14 as a function of void fraction, ε, and the cross-sectional averagedReynold’s number of the particle, NRe.

f =1− εε3

(1.75 + 4.2N

5/6Re

1− εNRe

)(2.14)

6

Page 7: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

3 Numerical method

In this project, the MATLAB solver ode15s is used to solve the differantial equations [3]. The solver is basedon numerical differentiation formulas and optionally the backward differentiation formulas (also known asGear’s method). It is a multi-step solver—in computing y(tn), it makes use of preceding time points i,y(tn−i). In radial direction dss020 and dss042 are used to discretize the differential equations of first andsecond order respectively. These files utilize a higher order finite difference scheme. ode15s is used tointegrate in axial direction. To satisfy the boundary conditions, a mass matrix is applied.

In general, ode45 is regarded by MathWorks (the company behind MATLAB) as “(...)the best function toapply as a first try for most problems.”[2]. However, since the current problem is stiff, ode15s is applied.This solver is also used in the case of DAEs. A stiff problem will consist of several processes, at least one ofwhich will have a small time constant. The stiff nature of the differential equations can clearly be observed inthe temperature plot, where the drop at the inlet is near instantaneous. This is also experienced by runningthe ode45 solver, which would use hours to solve the problem, whereas ode15s has a runtime of 4 s, with asatisfying amount of discrete points.

In this project we have set the relative tolerance and the absolute tolerance to 108 and 1010 respectively. Wealso increased the number of radial discretization points to 30 to achieve a higher resolution for the figures.

z[m]

r[m]

Figure 3.1: The reactor tube is discretized in axial direction using ode15s and radial direction using dss020

and dss042 for first and second order derivatives, respectively. The points containing boundary conditionsat r = 0 and r = R are shown in bright red, while the the remaining points are shown in faded red.

7

Page 8: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4 MATLAB functions

4.1 Mole Fractions

Program code 4.1: getMolarFractions.m1 function y = getMolarFractions(omega, mMass)

2 %% Converts mass fractions to molar fractions

3 % Input:

4 % omega: mass fractions ω5 % Matrix: Columns correspond to ri, rows to components.

6 % mMass: molecular mass Mmass

7 % Vector: Each row correspond to each component

8 % Output:

9 % y: mole fractions y10 % Matrix: Same as ω11 y = zeros(size(omega));

12 for i=1:size(omega,2)

13 y(:,i) = (omega(:,i)./mMass)/(omega(:,i)’*(1./mMass));

14 end

15 end

4.2 Average Molar Mass

Program code 4.2: getAvgMolarMass.m1 function avgmolarmass = getAvgMolarMass(molarMass, molefraction)

2 %% Average Molar Mass

3 % Calculates the average molar mass

4 % Input:

5 % molarMass: The molecular weights, Mmass [kg mol−1]6 % molefraction: Mole fractions of the components, y7 % Output:

8 % avgmolarmass: The average molar mass, Mmass [kg mol−1]9

10 % Mmass = MTmassy

11 avgmolarmass = molarMass’*molefraction; % [kg mol−1]12 end

8

Page 9: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.3 Ideal Density

Program code 4.3: getIdealDensity.m1 function rho = getIdealDensity(pressure, AvgMolarMass, temperature)

2 %% Ideal density

3 % Calculates the density of an ideal gas

4 % Input:

5 % pressure: The total pressure, p, [Pa]6 % AvgMolarMass: The average molecular weight, Mmass [kg mol−1]7 % temperature: The temperature, T [K]8 % Output:

9 % rho: The density, ρ [kg m−3]10

11 % The gas constant, R12 r = 8.3144621; % [J mol−1K−1]13

14 % ρ = MmasspRT

15 rho = AvgMolarMass.*pressure./(r.*temperature); % [kg m−3]16 end

4.4 Viscosity

Program code 4.4: getViscosity.m1 function mu = getViscosity(temperature, S, B, molefraction)

2 %% Viscosity

3 % Calculates the viscosities of the components at a given temperature

4 % and mole fraction

5 % Input:

6 % temperature: The temperature, T [K]7 % S: Component viscosity coefficient [K]8 % B: Component viscosity coefficient [kg K0.5ms−1]9 % molefraction: The molefractions (optional)

10 % Output:

11 % mu: The viscosity or the average viscosity depending on the number of

12 % inputs.

13 % µi = biT1.5

T+Si

14 % µ = µTy15

16 mu = zeros(length(S),length(temperature));

17 for i = 1:length(S)

18 mu(i,:) = (B(i)*temperature.^1.5)./(temperature+S(i));

19 end

20 if nargin == 4

21 % The molefractions are given, calculate the average viscosity

22 muMatrix = mu;

23 mu = zeros(size(temperature));

24 for i = 1:length(temperature)

25 mu(i) = muMatrix(:,i)’*molefraction(:,i);

26 end

27 end

28 end

9

Page 10: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.5 Reynolds Number

Program code 4.5: getReynolds.m1 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−1m−1]11 % Output:

12 % re: The Reynold’s number, NRe

13

14 % NRe = udρµ

15 re = density.*velocity.*diameter./viscosity;

16 end

4.6 Heat Capacity

Program code 4.6: getHeatCapacity.m1 function cp = getHeatCapacity(temperature, coeffMatrix, molefraction)

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 % coeffMatrix: The coefficients α, β, γ, δ as a

8 % matrix

9 % molefraction: The molefractions (optional)

10 % Output:

11 % cp: The heat capacities

12 % cp = α + β T + γ T 2 + δ T 3

13 % cp = yTcp14

15 cp = coeffMatrix*[ones(size(temperature)); temperature; temperature.^2; temperature.^3];

16 % [J mol−1K−1]17 if nargin == 3

18 % The molefractions are given, calculate the average heat capacity

19 cpMatrix = cp;

20 cp = zeros(size(temperature));

21 for i = 1:length(temperature)

22 cp(i) = cpMatrix(:,i)’*molefraction(:,i);

23 end

24 end

25 end

10

Page 11: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.7 Reaction

This file was given with the problem formulation, but it has been modified somewhat.

Program code 4.7: getReaction.m1 function [rrx, deltaH] = getReaction(T, ...

2 y, ...

3 P, ...

4 Aj, ...

5 actEn, ...

6 Ax, ...

7 adEnt, ...

8 ent298, ...

9 ent948)

10 %% Reaction

11 % This function calculates the reaction rates for all the components

12 % and the heat of the reaction in all the discretication points.

13 % Input:

14 % T [=] K Temperature

15 % y [=] - Mol fraction vector

16 % P [=] Pa Total pressure

17 % Aj [=] kmol/kgcat h Preexponential factors as a vector

18 % actEn [=] J/kmol Activation energies for the reactions as a vector

19 % gasConst [=] J/kmol K Universal Gas constant

20 % Ax Preexponential factors for the adsorbtion constants

21 % adEnt [=] J/kmole Activation energies for the reactions

22 % ent298 [=] J/kmol Reaction enthalpies at 298K

23 % ent948 [=] J/kmol Reaction enthalpies at 948K

24 %

25 % Output

26 % rrx [=] mol/kg(cat)s Reaction rates for each reaction

27 % (#r-points x #components-matrix)

28 % deltaH [=] J/m^3s Reaction heat for each reaction

29 % (#r-points x #components-matrix)

30

31 %% Initializing

32 gasConst = 8.3144621; % Gas constant

33 numr = size(T,2); % Number of components

34 nComp = size(y,1); % Number of radial discretization points

35

36 %% Reaction enthalpies

37 % Three reactions for each point in the r-direction

38 deltaH = zeros(3,numr);

39 for i=1:3

40 deltaH(i,:)=ent298(i)*ones(1,numr)+(T-298*ones(1,numr))./(948-298).*(ent948(i)-ent298(i));

41 end

42

43 %% Partial pressures

44 pComp = zeros(nComp,numr);

45 for i=1:nComp

46 pComp(i,:) = y(i,:).*P/1e5;

47 end

48

49 % Initialization: reaction rate for each point in the r-direction

11

Page 12: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

50 rrx = zeros(3,numr);

51 % Initialization: denominator in the rate expression for each point in

52 % the r-direction

53 denom = zeros(1,numr);

54

55 for i=1:numr

56 % Rate constant

57 Krx = Aj.*exp(-actEn./(gasConst*T(1,i)));

58

59 % Adsorbtion constant

60 Kads = Ax.*exp(-adEnt./(gasConst*T(1,i)));

61

62 % Equilibrium constants

63 Keq(1) = 10^(-11650/T(1,i)+13.076);

64 Keq(2) = 10^(1910/T(1,i)-1.784);

65 Keq(3) = Keq(1)*Keq(2);

66

67 % Reaction rates

68 denom(i) = 1 + Kads(2)*pComp(2,i) + Kads(3)*pComp(4,i) ...

69 + Kads(1)*pComp(1,i) + Kads(4)*pComp(5,i)/pComp(4,i);

70

71 rrx(1,i)= Krx(1)/(pComp(4,i))^2.5*(pComp(1,i)*pComp(5,i) ...

72 - (pComp(4,i))^3*pComp(2,i)/Keq(1))/(denom(i))^2;

73

74 rrx(2,i)= Krx(2)/(pComp(4,i))*(pComp(2,i)*pComp(5,i) ...

75 - (pComp(4,i))*pComp(3,i)/Keq(2))/(denom(i))^2;

76

77 rrx(3,i)= Krx(3)/(pComp(4,i))^3.5*(pComp(1,i)*(pComp(5,i))^2 ...

78 - (pComp(4,i))^4*pComp(3,i)/Keq(3))/(denom(i))^2;

79 end

80

81 end

4.8 Heat Coefficients

his file was given with the problem formulation, but it has been modified somewhat.

Program code 4.8: getHeatCoefficients.m1 function [Ur,lambdaer]=gethHeatCoefficients(Re,...

2 T,...

3 Y,...

4 gasViscosity,...

5 cpGas,...

6 particleDiameter,...

7 radiusi,...

8 radiuso,...

9 lambdaSt,...

10 epsilon,...

11 lambda,...

12 avgMolarMass)

13 % heatcoef

14 % The function computes the heat transfer coefficient for radial transport of

15 % heat from the bed to the surroundings

16 % Input:

12

Page 13: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

17 % Re [=] - Reynolds number

18 % T [=] K Temperature

19 % Y [=] - Mol fraction

20 % VIS [=] kg/ms Gas viscosity

21 % CPgas [=] J/kgK Gas heat capasity

22 %

23 % Output

24 % Ur [=] J/m^2sK Heat coefficient

25 % LAMBDAer [=] J/msK Effective radial conductivity

26

27 %% Constants

28 numr = size(Y,2);

29 %nComp = size(Y,1);

30 pconst = 1.0;

31 beta = 1.0;

32 lambdas = 0.243;

33 phi = 0.3;

34

35 % Mass based heat capacity

36 cpGas = cpGas./avgMolarMass;

37

38 %Calculates the gas heat conductivity

39 Tmatrix = [ones(size(T)); T; T.^2; T.^3];

40 lambdacomp = lambda*Tmatrix;

41 lambdag = diag(Y’*lambdacomp)’;

42

43 %Prandtl number

44 Pr = gasViscosity.*cpGas./lambdag;

45

46 %Radial effective static conduction

47 alpharv = (0.227/(1+epsilon/(2*(1-epsilon))*(1-pconst)/pconst)*(T/100).^3);

48 alphars = 0.227*pconst/(2-pconst)*(T/100).^3;

49 lambdaer0 = lambdag.*(epsilon*(1 + beta*particleDiameter*alpharv./lambdag) + ...

50 beta*(1-epsilon)./(1./(1/phi + alphars*particleDiameter./lambdag) + 2/3*lambdag/lambdas));

51

52 %Effective radial conductivity

53 lambdaer = lambdaer0+0.14*lambdag.*Re.*Pr;

54

55 %Heat transfer coefficient near the wall

56 alphaw0=8.694/(2*radiusi)^(4/3)*lambdaer0(numr);

57 alphaw=alphaw0+0.444*Re(numr)*Pr(numr)*lambdag(numr)/particleDiameter;

58

59 %Overall heat transfer coefficient

60 Ur=(radiusi*log(radiuso/radiusi)/lambdaSt+1/alphaw)^(-1);

61

62 end

13

Page 14: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.9 Diffusivity

Program code 4.9: getDiffusivity.m1 function diffusivity = getDiffusivity(dparticle,velocity,radiusi)

2 %% Calculates the diffusivity

3 % The Peclet numbers given in the problem formulation

4 % Input:

5 % dparticle: Diameter of the particles dp

6 % velocity: The axial velocity at each radial discretization uz7 % radiusi: The inner radius of the tubes ri

8 % Output:

9 % diffusivity: The diffusivity D [m2 s−1]10

11 peNumberrd = 8*(2-(1-2*dparticle/radiusi)^2); % Peclet number

12 peNumbermr = 1.1*peNumberrd; % Peclet number

13 diffusivity = velocity*dparticle/peNumbermr;

14 end

14

Page 15: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.10 Derivative of Pressure

Program code 4.10: getPressureDerivative.m1 function dpdz = getPressureDerivative(rho,u,re,void,dp,r)

2 %% Derivative of pressure

3 % This function computes the 1D pressure gradient in the system by using

4 % superficial velocity, density and Reynolds number.

5 % Input:

6 % rho: Gas density ρ [kg m−3]7 % Row vector of r

8 % u: Velocity uz [m s−1]9 % Row vector of r

10 % re Reynolds number

11 % Row vector of r

12 % void: Void fraction ε13 % Row vector of r

14 % dp: Particle diameter dp

15 % Constant

16 % r: The radius r17 % Vector

18 % Output:

19 % dpdz Pressure gradient∂p

∂z20

21 % Cross-sectional averaging

22 format long

23 rho = trapz(r,rho.*r)/(.5*r(end)^2);

24 u = trapz(r,u.*r)/(.5*r(end)^2);

25 re = trapz(r,re.*r)/(.5*r(end)^2);

26 % Friction factor, f = 1−εε3 (1.75 + 4.2Re(5/6)(1−ε)

re )27 f = (1-void)/void^3*(1.75+4.2*re^(5/6)*(1-void)/re);

28 % The Ergun equation,∂p

∂z=

−fρ u2z

dp

29 dpdz = -f*rho*u^2/dp*ones(size(rho));

30 end

15

Page 16: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.11 Derivative of Temperature

Program code 4.11: getTemperatureDerivative.m1 function dT = getTemperatureDerivative(rho,...

2 heatCapacity,...

3 velocity,...

4 lambda,...

5 radius,...

6 rhoCat,...

7 reactionRate,...

8 reactionEnthalpy,...

9 dtdr,...

10 dt2dr2,...

11 void,...

12 avgMolarMass)

13 %% Temperature Derivative

14 % Calculates the derivative of the temperature

15 % Input:

16 % temperature: The temperature, T [K]17 % rho: The density of the gas, ρ [kg m−3]18 % heatCapacity: The heat capacity of the gas, cp [J mol−1K−1]19 % velocity: The velocity of the gas, uz [m s−1]20 % lambda: The effective radial conductivity, λr, [J s−1m−1K−1]21 % radius: The inner tube radius, r [m]22 % rhoCat: The density of the catalyst, ρcat [kg m−3]23 % reactionRate: The rate of reaction, r [mol s−1kg−1]24 % reactionEnthalpy: The enthalpy of reaction, ∆rxH [J mol−1]

25 % dtdr: The result from dss020.m,∂T

∂r

26 % dt2dr2: The result from dss042.m,∂2T

∂r2

27 % void: The void fraction ε28 % avgMolarMass: The average molar mass Mmass [kg mol−1]29 % Output:

30 % dT: The derivative of the temperature,∂T

∂z31

32 heatCapacity = heatCapacity./avgMolarMass;

33 % Total enthalpy of reactions at each radial point

34 dH = zeros(size(rho));

35 for i = 1:length(rho)

36 dH(i) = reactionRate(:,i)’*reactionEnthalpy(:,i);

37 end

38 %(1-void)*rhoCat*dH

39 %∂T

∂z= (ρ cp uz)

−1

[λr

r (∂T

∂r+ r

∂2T

∂r2) + (rρcat(−∆rxH)

]40 dT = ((rho.*heatCapacity.*velocity).^-1) .*...

41 (lambda.*(1./(radius+1e-50).*dtdr + dt2dr2) -...

42 (1-void)*rhoCat*dH); % [K m−1]43 end

16

Page 17: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.12 Derivative of Density

Program code 4.12: getDensityDerivative.m1 function drho = getDensityDerivative(temperature, pressure, averageMolarMass, pressureDerivative, temperatureDerivative)

2 %% Density Derivative

3 % Calculates the change in density in z-direction in a multitube reactor

4 %

5 % Input:

6 % temperature: The temperature, T [K]7 % Vector: columns correspond to ri8 % pressure: The pressure, p [Pa]9 % Vector: columns correspond to ri

10 % averageMolarMass: The average molar mass, M_w [g/mol]

11 % Vector: columns correspond to ri

12 % pressureDerivative: The derivative of the pressure,∂p

∂z[Pa m−1]

13 % Vector: columns correspond to ri

14 % temperatureDerivative: The derivative of the temperature∂T

∂z[K m−1]

15 % Vector: columns correspond to ri16 % Output:

17 % drho: The derivative of the density,∂ρ

∂z[kg m−4]

18

19 % The gas constant, R20 r = 8.3144621; % [J mol−1K−1]21

22 %∂ρ

∂z= Mmass

R

(1T

∂p

∂z− p

T 2

∂T

∂z

)23 drho = averageMolarMass/r.*(1./temperature.*pressureDerivative - ...

24 pressure./temperature.^2 .* temperatureDerivative);

25 end

26

27

17

Page 18: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.13 Derivative of Velocity

Program code 4.13: getVelocityDerivative.m1 function du = getVelocityDerivative(velocity,...

2 density,...

3 densityDerivative)

4 %% Velocity Derivative

5 % Calculates the derivative of the velocity

6 % Input:

7 % velocity: The velocity of the gas, uz [m s−1]8 % density: The gas density, ρ, [kg m3]

9 % densityDerivative: The derivative of the gas density,dρ

dz[kg m−4]

10 % Output:

11 % du: The derivative of the velocity,∂uz∂z

12

13 %∂uz∂z

= −uz

ρ

∂ρ

∂z14 du = -velocity.*densityDerivative./density; % [s−1]15 end

4.14 Derivative of Mass Fraction

Program code 4.14: getMassFractionDerivative.m1 function domega = getMassFractionDerivative(rho,...

2 rhoCat,...

3 velocity,...

4 diffusivity,...

5 radius,...

6 reactionRate,...

7 densityDerivative,...

8 velocityDerivative,...

9 omega,...

10 domegadr,...

11 domega2dr2,...

12 drhodr,...

13 void,...

14 mMass,...

15 stoMat)

16 %% Weight fraction derivative

17 % Calculates the derivative of the weight fraction with respect to z.

18 % All the inputs are row vectors where the columns correspond to each

19 % discretization point of the radius.

20 % Input:

21 % rho: The density of the gas ρ [kg m−3]22 % Row vector

23 % rhoCat: The density of the catalyst, ρcat [kg m−3]24 % Constant

25 % velocity: The velocity of the gas, uz [m s−1]26 % Row vector

27 % diffusivity: The diffusivity D [m s−1]28 % Column vector corresponding to each component

18

Page 19: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

29 % radius: The radius of the reactor tube r [m]30 % Row vector

31 % reactionRate: The reaction rate r [mol s−1kg−1]32 % Matrix: rows correspond to reactions

33 % desityDerivative: The derivative of the density with respect to z∂ρ

∂z[kg m−4]

34 % Row vector

35 % velocityDerivative: The derivative of the velocity with respect to z∂uz∂z

[m s−2]

36 % Row vector

37 % omega: The mass fractions ω38 % Matrix: rows correspond to the components

39 % domegadr: The derivative of the weight fraction with respect to r∂ω

∂r[m−1]

40 % Matrix: rows correspond to the components

41 % domega2dr2: The second derivative of the weight fraction with respect to r∂2ω

∂r2[m−2]

42 % Matrix: rows correspond to the components

43 % drhodr: The derivative of the density∂ρ

∂r[kg m−4]

44 % Row vector

45 % void: The void fraction ε46 % Constant

47 % mMass: Molar mass Mmass [kg mol−1]48 % Column vector corresponding to each component

49 % stoMat: Stoichiometric matrix N

50 % Each row correspond to each reaction, each column

51 % correspond to each component

52 % Output

53 % domega: The derivative of the weight fraction with respect to z∂ω

∂z[m−1]

54 % Matrix: rows correspond to the components

55

56 % Reaction rate for each component at each radial point

57 reactionRateComp = zeros(size(omega));

58 for i = 1:length(rho)

59 reactionRateComp(:,i) = (1-void)*rhoCat*mMass.*(stoMat’*reactionRate(:,i));

60 end

61 domega = zeros(size(omega));

62 if size(diffusivity,1)==1

63 % Use overall diffusion (not dependent on component)

64 for i = 1:size(omega,1)

65 domega(i,:) = 1./(rho.*velocity) .* (...

66 -omega(i,:).*velocity.*densityDerivative -...

67 rho.*omega(i,:).*velocityDerivative +...

68 diffusivity .* (rho./(radius+1e-50).*domegadr(i,:) +...

69 rho.*domega2dr2(i,:) +...

70 domegadr(i,:).*drhodr) +...

71 reactionRateComp(i,:));

72 end

73 else

74 % Diffusion is dependent on each component

75 error(’Not yet implemented’);

76 end

19

Page 20: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

77 end

4.15 Reactor

Program code 4.15: reactor.m1 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 mass fractions, temperatures, velocities

5 % and pressure, given the mass fractions, temperature, velocity, the partial

6 % pressures at all the radial discretization points, and all the other

7 % parameters.

8 % Input:

9 % x: The states

10 % par: The parameters as a struct

11 % rhoCat: The density of the catalysator, ρcat [kg m−3]12 % nu: The stoichiometric coefficients, ν13 % u: The overall heat transfer coefficient, U [J s−1m−2K−1]14 % r0: The radius of the tube, r0 [m]15 % dp: The diameter of the particles, dp [m]16 % tOutside: The temperature outside, Toutside [K]17 % void: The void fraction, ε18 % viscosity: The dynamic viscosity, µ [kg m−1s−1]19 % mMass: The molar masses, Mmass [kg mol−1]20 %% Extracting parameters

21 stoMat = par.nu; % Stoichiometric matrix

22 molecularMass = par.mMass; % Molar mass [kg mol−1]23 numr = par.numr; % Number of radial discretizations

24 numComp = par.nComp; % Number of chemical components

25 rhoCat = par.rhoCat; % Density of catalyst [kg m−3]26 void = par.eps; % Void fraction

27 dparticle = par.dp; % The diameter of the particles m28 radius = par.radius; % The discretized radius [m]29 s = par.s; % Viscosity coefficients [K]30 b = par.b; % Viscosity coefficients [kg m−1s−1K−.5]31 cpCoefficients = par.cp; % Heat capacity coefficients [J mol−1K−n]32 lambda = par.lambda; % Conductivity coefficients [W m−1K−n]33 rateConstants = par.aj; % Rate constants [mol kg−1s−1]34 adsConstants = par.ax; % Adsorbtion constants [Pa−n]35 actEnergy = par.actEn; % Activation energies [J mol−1]36 adsEnthalpy = par.adEnt; % Adsorption enthalpies [J mol−1]37 enthalpy298 = par.ent298; % Reaction enthalpies [J mol−1]38 enthalpy948 = par.ent948; % Reaction enthalpies [J mol−1]39 radiusi = par.radiusi; % Inner tube radius [m]40 radiuso = par.radiuso; % Outer tube radius [m]41 lambdaTube = par.lambdaSt; % Heat conductivity of the wall [W m−1K−1]42 tempOut = par.tempOut; % Outside temperature [K]43 %% Extracting states

44 % Mass fractions

45 massFrac = zeros(numComp,numr);

46 for i = 1:numComp

47 numMass = (1+(i-1)*numr):i*numr;

48 massFrac(i,:) = x(numMass)’;

49 end

20

Page 21: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

50 % Temperature

51 numTemp = (numMass(end)+1):(numMass(end)+numr);

52 temperature = x(numTemp)’;

53 % Pressure

54 numPressure = (numTemp(end)+1):(numTemp(end)+numr);

55 pressure = x(numPressure)’;

56 % Velocity

57 numVelocity = (numPressure(end)+1):(numPressure(end)+numr);

58 velocity = x(numVelocity)’;

59 %% Calculations

60 moleFrac = getMolarFractions(massFrac,molecularMass);

61 avgMolarMass = getAvgMolarMass(molecularMass,moleFrac);

62 rho = getIdealDensity(pressure,avgMolarMass,temperature);

63 viscosity = getViscosity(temperature,s,b,moleFrac);

64 re = getReynolds(rho,velocity,dparticle,viscosity);

65 heatCapacity = getHeatCapacity(temperature,cpCoefficients,moleFrac);

66 [reactionRate, reactionEnthalpy] = getReaction(temperature,moleFrac,...

67 pressure,rateConstants,...

68 actEnergy,adsConstants,...

69 adsEnthalpy,enthalpy298,...

70 enthalpy948);

71 [heatTransfer,lambdaEffective] = getHeatCoefficients(re,temperature,...

72 moleFrac,viscosity,...

73 heatCapacity,dparticle,...

74 radiusi,radiuso,...

75 lambdaTube,void,...

76 lambda,...

77 avgMolarMass);

78 diffusivity = getDiffusivity(dparticle,velocity,radiusi);

79 %% Radial derivatives

80 % Mass fractions

81 dMassFracdr = zeros(size(massFrac));

82 dMassFrac2dr2 = dMassFracdr;

83 for i = 1:numComp

84 dMassFracdr(i,:) = dss020(radius(1),radius(end),massFrac(i,:),1);

85 end

86 for i = 1:numComp

87 dMassFrac2dr2(i,:) = dss042(radius(1),radius(end),...

88 massFrac(i,:),dMassFracdr(i,:),2,2);

89 end

90 % Temperature

91 dTemperaturedr = dss020(radius(1),radius(end),temperature,1);

92 dTemperature2dr2 = dss042(radius(1),radius(end),...

93 temperature,dTemperaturedr,2,2);

94 % Density

95 dRhodr = dss020(radius(1),radius(end),rho,1);

96

97 % Velocity

98 dVelocitydr = dss020(radius(1),radius(end),velocity,1);

99 %% Axial derivatives

100 dPressuredz = getPressureDerivative(rho,velocity,re,void,dparticle,radius);

101 dTemperaturedz = getTemperatureDerivative(rho,...

102 heatCapacity,...

103 velocity,...

21

Page 22: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

104 lambdaEffective,...

105 radius,...

106 rhoCat,...

107 reactionRate,...

108 reactionEnthalpy,...

109 dTemperaturedr,...

110 dTemperature2dr2,...

111 void,...

112 avgMolarMass);

113 dRhodz = getDensityDerivative(temperature,pressure,avgMolarMass,dPressuredz,dTemperaturedz);

114 dVelocitydz = getVelocityDerivative(velocity,rho,dRhodz);

115 dMassFracdz = getMassFractionDerivative(rho,...

116 rhoCat,...

117 velocity,...

118 diffusivity,...

119 radius,...

120 reactionRate,...

121 dRhodz,...

122 dVelocitydz,...

123 massFrac,...

124 dMassFracdr,...

125 dMassFrac2dr2,...

126 dRhodr,...

127 void,...

128 molecularMass,...

129 stoMat);

130 %% Construct the vector containing all the state derivatives

131 dx = zeros(size(x));

132 % Mass fractions

133 for i = 1:numComp

134 numMass = (1+(i-1)*numr):i*numr;

135 dx(numMass) = [dMassFracdr(i,1)

136 dMassFracdz(i,2:end-1)’

137 dMassFracdr(i,end)];

138 end

139 numTemp = (numMass(end)+1):(numMass(end)+numr);

140 dx(numTemp) = [dTemperaturedr(1,1)

141 dTemperaturedz(1,2:end-1)’

142 dTemperaturedr(1,end) + ...

143 heatTransfer/lambdaEffective(1,end)*...

144 (temperature(1,end)-tempOut)];

145 % Pressure

146 numPressure = (numTemp(end)+1):(numTemp(end)+numr);

147 dx(numPressure) = dPressuredz’;

148 % Velocity

149 numVelocity = (numPressure(end)+1):(numPressure(end)+numr);

150 dx(numVelocity) = [dVelocitydr(1)

151 dVelocitydz(2:end-1)’

152 dVelocitydr(end)];

153 end

4.16 Constants

Program code 4.16: getConstants.m

22

Page 23: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

1 function const = getConstants

2 %% Constants

3 % Sets all constants needed in the calculations as a struct.

4 % Input:

5 % -

6 % Output:

7 % const: Struct containing all the constants needed

8 %Initial data

9

10 %Stochiometric matrix

11 const.species = {’CH4’ ’CO’ ’CO2’ ’H2’ ’H2O’ ’N2’};

12 % CH4 CO CO2 H2 H20 N2

13 const.nu = [-1 1 0 3 -1 0 % rx 1

14 0 -1 1 1 -1 0 % rx 2

15 -1 0 1 4 -2 0]; % rx 3

16 %-------------------------------------------------------------------

17 const.Tin = 793; % Initial temperature [K]

18 const.pin = 29e5; % Initial pressure [Pa]

19 const.uin = 1.89; % Velocity [m/s]

20

21

22 % Constants

23 %-------------------------------------------------------------------

24 const.gasConst = 8.3145; % Gas constant [J/K mol]

25 const.nComp = 6; % Number of components [-]

26 const.numz = 30; % Number of axial discretization points

27 const.numr = 30; % Number of radial discretization points

28 const.mpart = 6; % Number of radial discretization points

29 % in the pellet

30 % Catalyst data

31 %-------------------------------------------------------------------

32 const.rhoCat = 2355.2; % Density catalyst [kgcat/m^3]

33 const.eps = 0.528; % Pore fraction [-]

34 const.dp = 0.0173; % Particle diameter [m]

35 const.rp = const.dp/2; % Particle radius [m]

36 const.hp = 30000; % Heat transfer coefficient [W/m^2K]

37 const.kCat = 50; % Particle conductivity [W/mK]

38 const.av = 3/const.rp.*(1-const.eps); % Particle surface area per volume [1/m]

39

40 % Tube data

41 %-------------------------------------------------------------------

42 const.tempOut = 1100; % Temp. outside the tube [K]

43 const.lambdaSt = 52; % Heat coef. for tube metal[W/mK]

44 const.radiusi = 0.051; % Inner radius of the tube [m]

45 const.radiuso = 0.066; % Outer radius of the tube [m]

46 const.length = 7.0; % Tube length [m]

47 const.radius = linspace(0,const.radiusi,const.numr); % Radial discretization points [m]

48

49 % Initial massfraction of the components [-]

50 %-------------------------------------------------------------------

51 const.fracIn(1,1) = 0.1911; % CH4

52 const.fracIn(2,1) = 0.0001; % CO

53 const.fracIn(3,1) = 0.0200; % CO2

54 const.fracIn(4,1) = 0.0029; % H2

23

Page 24: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

55 const.fracIn(5,1) = 0.7218; % H2O

56 const.fracIn(6,1) = 0.0641; % N2

57

58

59 % Molemass of the components [kg/mol]

60 %-------------------------------------------------------------------

61

62 const.mMass(1,1) = 16.04e-3; % Molemass CH4

63 const.mMass(2,1) = 28.01e-3; % Molemass CO

64 const.mMass(3,1) = 44.01e-3; % Molemass CO2

65 const.mMass(4,1) = 2.02e-3; % Molemass H2

66 const.mMass(5,1) = 18.02e-3; % Molemass H2O

67 const.mMass(6,1) = 28.01e-3; % Molemass N2

68

69

70 % Preexponential factors for the rate constants [mol/kgcat s]

71 %-------------------------------------------------------------------

72 const.aj(1,1) = 4.255E15/3.6; % Factor for rx. 1

73 const.aj(1,2) = 1.955E6/3.6; % Factor for rx. 2

74 const.aj(1,3) = 1.020E15/3.6; % Factor for rx. 3

75

76

77 % Preexponential factors for the adsorbtion constants

78 %-------------------------------------------------------------------

79 const.ax(1,1) = 6.65E-9; % Factor for CH4 [Pa^-1]

80 const.ax(1,2) = 8.23E-10; % Factor for CO [Pa^-1]

81 const.ax(1,3) = 6.12E-14; % Factor for H2 [Pa^-1]

82 const.ax(1,4) = 1.77E5; % Factor for H2O [-]

83

84

85 % Activation energies for the reactions [J/mol]

86 %-------------------------------------------------------------------

87 const.actEn(1,1) = 240.1e3; % Activation energy for rx. 1

88 const.actEn(1,2) = 67.13e3; % Activation energy for rx. 2

89 const.actEn(1,3) = 243.9e3; % Activation energy for rx. 3

90

91

92 % Reaction enthalpies at 298K [J/mol]

93 %-------------------------------------------------------------------

94 const.ent298(1,1) = 206.1E3; % Enthalpy for rx. 1

95 const.ent298(1,2) = -41.15E3; % Enthalpy for rx. 2

96 const.ent298(1,3) = 164.9E3; % Enthalpy for rx. 3

97

98

99 % Reaction enthalpies at 948K [J/mol]

100 %-------------------------------------------------------------------

101 const.ent948(1,1) = 224.E3; % Enthalpy for rx. 1

102 const.ent948(1,2) = -37.30E3; % Enthalpy for rx. 2

103 const.ent948(1,3) = 187.5E3; % Enthalpy for rx. 3

104

105

106 % Adsorption enthalpies [J/mol]

107 %-------------------------------------------------------------------

108 const.adEnt(1,1) =-38.28E3; % Enthalpy for adsorption of CH4

24

Page 25: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

109 const.adEnt(1,2) =-70.65E3; % Enthalpy for adsorption of CO

110 const.adEnt(1,3) =-82.90E3; % Enthalpy for adsorption of H2

111 const.adEnt(1,4) = 88.68E3; % Enthalpy for adsorption of H2O

112

113

114 % Heat capasity coefficients for the components

115 %-------------------------------------------------------------------

116 CP(1,1) = 1.925E4; % 1. coefficient for CH4 [J/kmoleK]

117 CP(1,2) = 5.213E1; % 2. coefficient for CH4 [J/kmoleK^2]

118 CP(1,3) = 1.197E-2; % 3. coefficient for CH4 [J/kmoleK^3]

119 CP(1,4) =-1.132E-5; % 4. coefficient for CH4 [J/kmoleK^4]

120

121 CP(2,1) = 3.087E4; % 1. coefficient for CO [J/kmoleK]

122 CP(2,2) =-1.285E1; % 2. coefficient for CO [J/kmoleK^2]

123 CP(2,3) = 2.789E-2; % 3. coefficient for CO [J/kmoleK^3]

124 CP(2,4) =-1.272E-5; % 4. coefficient for CO [J/kmoleK^4]

125

126 CP(3,1) = 1.980E4; % 1. coefficient for CO2 [J/kmoleK]

127 CP(3,2) = 7.344E1; % 2. coefficient for CO2 [J/kmoleK^2]

128 CP(3,3) =-5.602E-2; % 3. coefficient for CO2 [J/kmoleK^3]

129 CP(3,4) = 1.715E-5; % 4. coefficient for CO2 [J/kmoleK^4]

130

131 CP(4,1) = 2.714E4; % 1. coefficient for H2 [J/kmoleK]

132 CP(4,2) = 0.9274E1; % 2. coefficient for H2 [J/kmoleK^2]

133 CP(4,3) =-1.381E-2; % 3. coefficient for H2 [J/kmoleK^3]

134 CP(4,4) = 0.7645E-5; % 4. coefficient for H2 [J/kmoleK^4]

135

136 CP(5,1) = 3.224E4; % 1. coefficient for H2O [J/kmoleK]

137 CP(5,2) = 0.1924E1; % 2. coefficient for H2O [J/kmoleK^2]

138 CP(5,3) = 1.055E-2; % 3. coefficient for H2O [J/kmoleK^3]

139 CP(5,4) = 0.3596E-5; % 4. coefficient for H2O [J/kmoleK^4]

140

141 CP(6,1) = 3.115E4; % 1. coefficient for N2 [J/kmoleK]

142 CP(6,2) =-1.357E1; % 2. coefficient for N2 [J/kmoleK^2]

143 CP(6,3) = 2.680E-2; % 3. coefficient for N2 [J/kmoleK^3]

144 CP(6,4) =-1.168E-5; % 4. coefficient for N2 [J/kmoleK^4]

145

146 % Units --> SI

147 const.cp = CP/1000; % [J/molK^4]

148

149

150 % Conductivity coefficients for the components

151 %-------------------------------------------------------------------

152 const.lambda(1,1) =-1.869E-3; % 1. coefficient for CH4 [W/mK]

153 const.lambda(1,2) = 8.727E-5; % 2. coefficient for CH4 [W/mK^2]

154 const.lambda(1,3) = 1.179E-7; % 3. coefficient for CH4 [W/mK^3]

155 const.lambda(1,4) =-3.614E-11; % 4. coefficient for CH4 [W/mK^4]

156

157 const.lambda(2,1) = 5.067E-4; % 1. coefficient for CO [W/mK]

158 const.lambda(2,2) = 9.1025E-5; % 2. coefficient for CO [W/mK^2]

159 const.lambda(2,3) =-3.524E-8; % 3. coefficient for CO [W/mK^3]

160 const.lambda(2,4) = 8.199E-12; % 4. coefficient for CO [W/mK^4]

161

162 const.lambda(3,1) =-7.215E-3; % 1. coefficient for CO2 [W/mK]

25

Page 26: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

163 const.lambda(3,2) = 8.015E-5; % 2. coefficient for CO2 [W/mK^2]

164 const.lambda(3,3) = 5.477E-9; % 3. coefficient for CO2 [W/mK^3]

165 const.lambda(3,4) =-1.053E-11; % 4. coefficient for CO2 [W/mK^4]

166

167 const.lambda(4,1) = 8.099E-3; % 1. coefficient for H2 [W/mK]

168 const.lambda(4,2) = 6.689E-4; % 2. coefficient for H2 [W/mK^2]

169 const.lambda(4,3) =-4.158E-7; % 3. coefficient for H2 [W/mK^3]

170 const.lambda(4,4) = 1.562E-10; % 4. coefficient for H2 [W/mK^4]

171

172 const.lambda(5,1) = 7.341E-3; % 1. coefficient for H2O [W/mK]

173 const.lambda(5,2) =-1.013E-5; % 2. coefficient for H2O [W/mK^2]

174 const.lambda(5,3) = 1.801E-7; % 3. coefficient for H2O [W/mK^3]

175 const.lambda(5,4) =-9.100E-11; % 4. coefficient for H2O [W/mK^4]

176

177 const.lambda(6,1) = 3.919E-4; % 1. coefficient for N2 [W/mK]

178 const.lambda(6,2) = 9.966E-5; % 2. coefficient for N2 [W/mK^2]

179 const.lambda(6,3) =-5.067E-8; % 3. coefficient for N2 [W/mK^3]

180 const.lambda(6,4) = 1.504E-11; % 4. coefficient for N2 [W/mK^4]

181

182

183 % Viscosity coefficients

184 %-------------------------------------------------------------------

185 const.b(1,1) = 1.00E-6; % Coefficient for CH4 [kg/msK^0.5]

186 const.b(2,1) = 1.50E-6; % Coefficient for CO [kg/msK^0.5]

187 const.b(3,1) = 1.50E-6; % Coefficient for CO2 [kg/msK^0.5]

188 const.b(4,1) = 0.65E-6; % Coefficient for H2 [kg/msK^0.5]

189 const.b(5,1) = 1.74E-6; % Coefficient for H2O [kg/msK^0.5]

190 const.b(6,1) = 1.40E-6; % Coefficient for N2 [kg/msK^0.5]

191

192 const.s(1,1) = 165; % Coefficient for CH4 [K]

193 const.s(2,1) = 220; % Coefficient for CO [K]

194 const.s(3,1) = 220; % Coefficient for CO2 [K]

195 const.s(4,1) = 67; % Coefficient for H2 [K]

196 const.s(5,1) = 626; % Coefficient for H2O [K]

197 const.s(6,1) = 108; % Coefficient for N2 [K]

198

199

200 % Diffusion volumes

201 %-------------------------------------------------------------------

202 const.sumV(1,1) = 25.14; % Coefficient for CH4 [-]

203 const.sumV(1,2) = 18.01; % Coefficient for CO [-]

204 const.sumV(1,3) = 26.90; % Coefficient for CO2 [-]

205 const.sumV(1,4) = 6.12; % Coefficient for H2 [-]

206 const.sumV(1,5) = 13.10; % Coefficient for H2O [-]

207 const.sumV(1,6) = 18.50; % Coefficient for N2 [-]

208

209 end

26

Page 27: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

4.17 Inlet States

Program code 4.17: getInletStates.m1 function x0 = getInletStates(par)

2 %% Transforms the inlet states

3 % Returns the inlet states as vectors with length equal to the number of

4 % radal discretization points.

5 % Input:

6 % par: The parameters given by getConstants

7 % Output:

8 % x0: The inlet states [ω0 T0 p0 uz,0]T

9 % at each radial discretization point. All the boundary conditions

10 % are set to zero.

11 omega0 = par.fracIn; % Mass fractions ω12 t0 = par.Tin; % Inlet temperature T0

13 p0 = par.pin; % Inlet pressure p0

14 u0 = par.uin; % Inlet velocity uz,015

16 numr = par.numr; % Number of radial discretization points

17

18 x0 = kron([omega0;t0;p0;u0],ones(numr,1));

19 end

4.18 Mass matrix

Program code 4.18: getMassMatrix.m1 function m = getMassMatrix(x0,par)

2 %% Creates the mass matrix

3 % Input:

4 % x0: The inlet states at all radial discretization points

5 % [ω0 T0 p0 uz,0]T

6 % par: The parameters given by getConstants.m

7 % Output:

8 % m: The mass matrix to be used in the ode solver

9

10 numr = par.numr;

11 % Initializing the mass matrix

12 m = eye(length(x0));

13 % Setting zeros where we have boundary conditions

14 % Mass fractions and temperature:

15 boundaryStates = length(x0)/numr - 2;

16 for i = 1:boundaryStates

17 m(1+(i-1)*numr,1+(i-1)*numr) = 0;

18 m(i*numr,i*numr) = 0;

19 end

20 % Velocity

21 m(1+(i+1)*numr,1+(i+1)*numr) = 0;

22 m((i+2)*numr,(i+2)*numr) = 0;

23 m = sparse(m);

24 end

27

Page 28: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

5 MATLAB main script

5.1 Main

Program code 5.1: main.m1 %% Main file

2 % Authors:

3 % Kjetil Sonerud

4 % Lise Jensen

5 % Anders Leirpoll

6 % Kasper Linnestad

7 % Created: 01-Feb-14

8 % Last edited: 27-Feb-14

9 % Requires:

10 % dss020.m

11 % dss042.m

12 % getAvgMolarMass.m

13 % getConstants.m

14 % getDensityDerivative.m

15 % getDiffusivity.m

16 % getHeatCapacity.m

17 % getHeatCoefficient.m

18 % getIdealDensity.m

19 % getInletStates.m

20 % getMassFractionDerivative.m

21 % getMassMatrix.m

22 % getMolarFractions.m

23 % getPlotMolarFractions.m

24 % getPlotPressure.m

25 % getPlotTemperature.m

26 % getPlotVelocity.m

27 % getPressureDerivative.m

28 % getReaction.m

29 % getReynolds.m

30 % getTemperatureDerivative.m

31 % getVelocityDerivative.m

32 % getViscosity.m

33 % reactor.m

34 % matlabfrag (https://dl.dropboxusercontent.com/u/6304542/matlabfrag.m)

35 % Comments:

36 % This script simulates a Fixed Bed Reactor

37 %% TKP4145 - Reactor technology

38 % Project 2

39 clear all

40 close all

41 clc

42 tic;

43 %% Given information

44 par = getConstants;

45 x0 = getInletStates(par);

46 massMatrix = getMassMatrix(x0,par);

47 %% Calculation

48 options = odeset(’RelTol’,1e-10,’AbsTol’,1e-10,’Mass’,massMatrix);

49 [z, x] = ode15s(@reactor,[0 par.length],x0,options,par);

28

Page 29: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

50 %% Calculating run time

51 runtime = toc;

52 fprintf(’The script used %.3f sec.\n’,runtime);

53 %% Extract the states

54 % Radius

55 radius = par.radius;

56 % Mass fractions

57 numComp = par.nComp;

58 numr = par.numr;

59 for i = 1:numComp

60 indexMass = 1+(i-1)*numr:i*numr;

61 massFrac(i,:,:) = x(:,indexMass);

62 end

63 % Temperature

64 indexTemperature = indexMass(end)+1:indexMass(end)+numr;

65 temperature = x(:,indexTemperature);

66 % Pressure

67 indexPressure = indexTemperature(end)+1:indexTemperature(end)+numr;

68 pressure = x(:,indexPressure);

69 % Velocity

70 indexVelocity = indexPressure(end)+1:indexPressure(end)+numr;

71 velocity = x(:,indexVelocity);

72 %% Plot

73 getPlotTemperature(temperature,z,[min(min(temperature)) max(max(temperature))],’’,radius)

74 getPlotPressure(pressure,z,[min(min(pressure)) max(max(pressure))]/1e5,’’,radius)

75 getPlotVelocity(velocity,z,[min(min(velocity)) max(max(velocity))],’’,radius)

76 % Convert mass fractions to molar fractions

77 moleFrac = zeros(size(massFrac));

78 for i = 1:length(z)

79 moleFrac(:,i,:) = getMolarFractions(squeeze(massFrac(:,i,:)),par.mMass);

80 end

81 getPlotMolarFractions(moleFrac,z,par.species,’’,radius)

29

Page 30: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

6 Results

Fig. 6.1 - 6.3 display the change in mole fractions of H2O, H2, N2, CH4, CO and CO2 along the length ofthe reactor. As expected, the mole fractions of the reactants, CH4 and H2O, decrease as they are used inthe reaction, and the mole fractions of H2 and CO2 increase. The rate of change is caused by the reactionrate, which is dependent on the reactor temperature. As N2 is an inert component in the reactor, its molefraction remains constant.

Mole fraction of H2O

y H2O

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

0.4

0.45

0.5

0.55

0.6

0.65

0.7

(a) Mole fraction of H2O.

Mole fraction of CH4

y CH

4

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

0.05

0.1

0.15

0.2

(b) Mole fraction of CH4.

Figure 6.1: Mole fractions of species; H2O and CH4

Mole fraction of H2

y H2

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

(a) Mole fraction of H2.

Mole fraction of CO2

y CO

2

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

0.01

0.02

0.03

0.04

0.05

0.06

(b) Mole fraction of CO2.

Figure 6.2: Mole fractions of species; H2 and CO2

Fig. 6.4 shows how the pressure change along the length of the reactor. When the gas velocity through thereactor increases, the pressure drops according to Ergun’s equation, (2.13). The linearity of the pressuredrop is due to conservation of mass, ρ0u0 = ρguz, which makes Ergun’s equation linear. Conservation ofmass is not explicitly used in the modeling, but it is observed that this relationship is valid.

The reactor temperature profile can be seen in Fig. 6.5. At the reactor tube inlet the temperature is(relatively) low due to the reaction being endothermic and rate of reaction being high. This is due tothe fact that the reaction rate is a function of concentration, which is high at the inlet. The reactioncontinues to cool down the reactor tube until the lowest temperature point is reached at 1,9 · 10−8 m ofTmin = 843,73 K. From here, the external reactor heating exceeds the heat of reaction and the temperature

30

Page 31: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

Mole fraction of N2

y N2

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

0.032

0.034

0.036

0.038

0.04

(a) Mole fraction of N2.

Mole fraction of CO

y CO

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

0.01

0.02

0.03

0.04

0.05

0.06

0.07

(b) Mole fraction of CO.

Figure 6.3: Mole fractions of species; N2 and CO

Pressure in the reactor

p[bar]

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

28.2

28.3

28.4

28.5

28.6

28.7

28.8

28.9

Figure 6.4: Total pressure in the reactor.

increases, until it stabilizes. From Fig. 6.6, it is seen that this directly affects the velocity profile.

The velocity profile in the reactor is shown in Fig. 6.6. At the reactor tube inlet the temperature is low,which causes a decrease in velocity as expected from the assumption of ideal gas. The temperature increasesfurther down the tube, which together with the pressure drop causes the velocity to increase.

31

Page 32: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

Temperature in the reactor

T[K

]

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

750

800

850

900

950

1000

1050

Figure 6.5: Temperature profile in the reactor.

Axial velocity in the reactor

uz[m

s−1]

r [m]z [m]

0

2

4

60

0.010.02

0.030.04

0.05

1.8

1.9

2

2.1

2.2

2.3

2.4

2.5

2.6

Figure 6.6: Velocity profile in the reactor.

32

Page 33: Reactor technology Project 2folk.ntnu.no/andersty/4. Klasse/TKP4145... · 5 (2.4) where R = (1 ")ˆcatM w NTr (2.5) ˆcatis the density of the catalyst, "is the void fraction, Mmass

References

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

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

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

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

33