che 360 project write up

42
Mathematical Modeling of CSTR and PFR for Polystyrene Production ChE 360 Project Michael McEldrew David Belias Austin Goewert David Kozak

Upload: austingoewert

Post on 09-May-2017

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Che 360 Project Write Up

Mathematical Modeling of CSTR and PFR for Polystyrene Production

ChE 360 Project

Michael McEldrew

David Belias

Austin Goewert

David Kozak

5/1/2014

Page 2: Che 360 Project Write Up

Table of Contents

Introduction.................................................................................................................................................2

Results.........................................................................................................................................................5

Mathematical Modeling of Polystyrene Formation using CSTR...............................................................5

Mathematical Modeling of Polystyrene Plug-Flow Reactor...................................................................12

Conclusion.................................................................................................................................................17

Appendix...................................................................................................................................................18

Appendix 1.............................................................................................................................................18

Appendix 2.............................................................................................................................................25

1

Page 3: Che 360 Project Write Up

IntroductionModeling processes in chemical engineering often require the use of analytical mathematical

methods. Throughout the 360 course, various methods have been used to solve systems of ordinary and partial differential system of equations. Each method contains its limitations. In this project, students were required to utilize their problem solving skills to create the most effective model to represent the system. Different mathematical methods were used with each reactor to obtain the most accurate solutions.

The first problem involves a monomer reacting exothermically with an initiator to produce polystyrene, which can be seen in Figure 1. A cooling jacket was run around a continuously stirred tank reactor to control the temperature. Perfect mixing, constant volume, and constant properties were assumed.

This problem had to be solved by modeling the mathematical equations from Figure 2. First, the three steady states were evaluated with respect to the given conditions. The steady state analysis involved using Newton’s Method. Afterwards, these states were compared to the dynamic process at two different reactor temperatures (350 K and 300 K). These changes were used to investigate the effects of temperature change on the reaction. The dynamic process was evaluated using Euler’s Explicit method in which the stiffness value was found to be of magnitude one.

2

Figure 1: Continuous polymerization reactor (CSTR)

Page 4: Che 360 Project Write Up

The second problem involved a jacketed plug flow reactor, which is diagrammed in Figure 3. The main difference pertaining to the plug flow reactor was the lack of complete mixing within the reactor. This reactor differed spatially from the CSTR and was thus described by the equations below in Figure 4.

3

Figure 2: CSTR equations

Figure 3: Continuous polymerization reactor (plug flow)

Figure 4: Plug flow equations

Page 5: Che 360 Project Write Up

This problem was initially solved to find the reactor temperature along the reactor length steady states. These values were calculated using the Finite Differences method. The second analysis for this problem was to evaluate the startup process of the reactor to investigate the effects it had on the steady state concentrations and jacket temperature. To solve for these equations, both Euler’s Explicit and Euler’s Implicit methods were used.

Note: All calculations were done in Matlab. See the Appendix for all of the scripts.

4

Page 6: Che 360 Project Write Up

Results

Mathematical Modeling of Polystyrene Formation using CSTRSteady-State Analysis:

The first problem posed for the CSTR reactor was to find the three steady state conversions that the mathematical model produces. The given model for this reactor was a system of four coupled differential equations, written for the initiator concentration, the monomer concentration, the reactor temperature, and the cooling jacket temperature. The steady state parameter allowed the system’s differential equations to be transformed into a system of nonlinear algebraic equations. Newton’s method was used to solve this system of equations. Newton’s method involves the formulation of the Jacobian Matrix. In this problem, the Jacobian Matrix was a four by four matrix, consisting of the partial derivatives taken with respect to each variable for each of the equations. The partial derivatives were evaluated using Matlab, and then formulated into a matrix within the program created to perform Newton’s Method, which can be seen in Appendix 1. Once this program was able to run the correct Newton iterations, the steady state solutions could be found. The problem stated that there would be three steady state conversions: high, low, and medium. In order to find these different steady states the initial guesses given to the program need to be altered accordingly. To find the high conversion, the initiator and monomer concentrations have to be low, because a high conversion implies the consumption of the reactants. Also, because the reaction is exothermic, the expected reactor and jacket temperatures were guessed to be high for high conversion. To find the low conversion, the initial guesses followed the opposite thinking. The concentrations of the initiator and monomer were guessed to be high, because there would be less consumption of the reactants. The temperature of the reactor and jacket were guessed to be low, because the less reaction would take place with a low conversion. To find the medium conversion, the guesses would be somewhere in between the low and high conversion guesses. It did take a number of guesses before the medium conversion steady state was found. The initial guesses and the subsequent conversions that were produced are summarized in Table 1. The actual steady state values for each conversion can be found in Table 2.

Conversion Initial Guess for Initiator

Concentration (mol/l)

Initial Guess for Monomer

Concentration (mol/l)

Initial Guess for Reactor

Temperature (K)

Initial Guess for Jacket Temperature

(K)

High Conversion 0.8009 0.002 0.5 400 360Medium Conversion 0.2232 0.02 3 340 320

Low Conversion 0.0.0455 0.2 5 320 300

Conversion Steady State Initiator

Concentration (mol/l)

Steady State Monomer

Concentration (mol/l)

Steady State Reactor

Temperature (K)

Steady State Jacket

Temperature (K)

High Conversion 0.8009 0.0008 0.6927 406.2144 334.6012Medium Conversion 0.2232 0.0615 2.7027 343.0869 312.1228

Low Conversion 0.0.0455 0.068 3.3245 323.1681 305.1681

5

Table 1: A summary of the initial guesses used to find each of the steady states for the CSTR model for producing polystyrene.

Table 2: The actual values found at each steady state using Newton iteration.

Page 7: Che 360 Project Write Up

Once these steady state conversions were found, the stability of each was analyzed. Stability of a steady state can be determined by calculating the eigenvalues of the Jacobian Matrix at the given steady state. The eigenvalues at each steady state were found using the Matlab “eig” function. The resulting eigenvalues define the stability of each steady state. For example, the eigenvalues calculated at the high conversion steady state were all negative or complex numbers with negative real parts. This set of eigenvalues implies that the high conversion steady state is stable and attractive. This particular steady state is known as a stable focus. The eigenvalues produced for each steady state and the corresponding stability analysis is summarized in Table 3.

Eigenvalue 1 Eigenvalue 2 Eigenvalue 3 Eigenvalue 4 Stability Attractivity Type of Critical Point

Stiffness Value

High Conversion

-0.0066 -0.0002 +0.0001i

-0.0002-0.0001i

0 stable attractive focus 148.2183

Low Conversion

-0.0367 -0.0881 -0.1026 +0.0060i

-0.1026 -0.0060i

stable attractive focus 2.8004

Medium Conversion

0.9879 -0.7216 +0.1936i

-0.7216 -0.1936i

-0.9318 unstable unattractive saddle 1.3222

As can be seen in Table 3, the medium conversion steady state was determined to be unstable, due to a positive eigenvalue. This explains why the medium conversion steady state was initially hard to find. The initial guesses needed to be especially close to the medium conversion steady state values. The stability of these steady state values will be revisited later in the dynamic analysis of this CSTR reactor.

Dynamic Analysis:

The dynamic analysis of this mathematical model involved the solution of four coupled ordinary differential equations. The method that was used to solve these differential equations was Euler’s Explicit Method. Euler's Explicit method is acceptable if the system is not stiff. Because each of the ordinary differential equations is nonlinear, it is impossible to determine the overall stiffness of the system. However, it is possible to get a very good estimate of the system’s stiffness if it is evaluated around each of the steady states. The stiffness of the system around each of the steady states was determined using Equation 1.

1¿Stiffness=|λmax||λmin|

If the stiffness value is close in magnitude to one then the system can be considered not stiff. If the stiffness value is much greater than one, then the system is stiff. The stiffness values for each steady state were low enough to consider the system as not stiff. The precise stiffness values can be seen in Table 3. This stiffness evaluation allowed the analysis to proceed accurately with Euler’s Explicit Method. This method allows the ordinary differential equations to be discretized in space, creating a large system of linear algebraic equations that can be solved explicitly. The low conversion steady state values for

6

Table 3: The eigenvalues and stability for each steady state conversion

Equation 1: equation for stiffness, where λ denotes an eigenvalue for a given state.

Page 8: Che 360 Project Write Up

concentration and temperature were used as initial conditions for the dynamic analysis. However, the feed temperature was set at 350 K, so the profile did not remain at the steady state points. The program designed to run this dynamic analysis was created in Matlab and listed in Appendix 1. The maximum time for any dynamic process can be calculated by using Equation 2 below.

2¿MaxTime Step= 1|λmax|

The maximum time step for the low conversion was found to be 11.35 seconds, but a time step of 5 seconds was used. This ensures a more accurate dynamic analysis. After running the analysis, the concentration and temperature profiles were plotted. The results for concentration and temperature profiles can be seen in Figure 5.

As can be seen in Figure 5a, the concentration of the monomer (green) begins at the initial steady state concentrations and drops sharply. This shows that the monomer is reacting to form polystyrene. The slight increase is due to the reaction of monomer slowing down, and fresh monomer being added to the CSTR. Since fresh monomer is being added, and the reaction is not as large, the monomer concentration in the reactor increases. Eventually, the addition of monomer is neutralized by the polymerization reaction and a steady state concentration is reached. The initiator concentration begins at the steady state value and after approximately five hours, the initiator concentration drops to zero where it remains for the duration of the process. The initiator concentration drops at the same time that the monomer concentration reaches a minimum. This is expected because once there is no more initiator in the reactor, the consumption of the monomer for the polystyrene polymerization reaction slows down. As a result, the addition of fresh monomer increases the monomer concentration

7

Figure 5: a) Concentration of initiator (blue) and monomer (green) for low conversion values. b) Reactor temperature (blue) and jacket temperature (green).

Page 9: Che 360 Project Write Up

in the reactor. Eventually, no more reaction is taking place and the monomer concentration remains steady as the flow rate in and out of the reactor are the same, so equal amounts of monomer are entering and leaving. These concentrations are also affected by the reactor temperature. Although the reactor is initially at a low conversion steady state, the warmer feed heats up the reactor enough to force the reactor to a new, high steady state, at a conversion of 0.8509.

Figure 5b shows the reactor temperature (blue) and jacket temperature (green) profiles. At about five hours, the reactor temperature reaches a maximum. It should be noted that this initial spike in reactor temperature is most likely unsafe. In order to diminish this effect, a decreased jacket temperature would be recommended to absorb some of the heat created by the initial spike in the reaction. This increase in temperature is expected because the monomer concentration is at a minimum at this point. The reaction is exothermic, so a large amount of heat is being produced, thus increasing the reactor temperature. This also means that the monomer is being consumed in the reaction, so its concentration will decrease drastically. Due to the increase in reactor temperature, the jacket temperature also increases during this time. After this maximum, the reactor temperature begins to decline due to decreased initiator concentration, and due to an influx of fresh feed that is now below the reactor temperature. As the initiator is consumed, the system begins to reach a steady state, and equilibrium is reached between the heat produced by the reaction and the heat transferred into the cooling jacket. The jacket temperature also reaches a steady state at this time.

The process was then analyzed at the medium conversion steady state. The feed temperature was changed to 300 K, so the dynamics could be analyzed. The maximum time step was analyzed using Equation 2 shown above. The maximum time step was found to be 1.012 seconds, so a time step of 0.1 seconds was chosen. Figure 6 below shows the concentration and temperature profiles of this dynamic analysis.

8

Figure 6: a) Concentration of initiator (blue) and monomer (green) for medium conversion values. b) Reactor temperature (blue) and jacket temperature (green).

Page 10: Che 360 Project Write Up

Looking at Figure 6, it can be seen that the conditions result in a diminished reaction. The reactor was initially at 343 K; however the feed entered at 300 K. The colder feed causes the reactor temperature to decrease. The temperature of the reactor and the jacket then converged to new steady state temperatures, which were much lower than the initial temperature. Since the reactor temperature evolved to a much lower steady state temperature, a lower conversion ensued. A lower conversion implies an increase in monomer concentration throughout the reactor, which can be seen in Figure 6a. The initiator concentration increased slightly as the process continued, which was due to the feed stream entering and adding more initiator. However, initiator was not being used up because reaction was happening at a lower magnitude. Although the reactor is initially at the medium conversion steady state the cold feed causes the reactor to move to a new, lower steady state, at a conversion of 0.0031.

The conversions for both of the dynamic analyses were plotted against the reactor temperature. The results are displayed below in Figure 7 below.

Figure 7 shows two strands of a phase portrait, one for the reactor initially at the medium conversion steady state (leftmost) and another for the reactor initially at the low conversion steady state (rightmost). It can be seen that the leftward strand diverges from the medium conversion steady state at 0.2232 to a much lower conversion steady state at around 0.0031. This lower conversion also is accompanied by a decreasing temperature. On the other hand, the right ward strand is initially at the low conversion steady state, but the influx of warm feed causes the reaction to accelerate and reach a new steady state at a conversion of 0.8509. Although it was expected that perturbing the reactor by adding feeds at different temperatures could result in the reactor moving to a new steady state, it was unexpected that these steady states would not be the same as the ones found in the steady state

9

Figure 7: Conversion versus reactor temperature for the low and medium conversion dynamic processes.

Page 11: Che 360 Project Write Up

analysis. However, this dilemma is resolved when the conditions for which those initial steady states were calculated. In the steady state analysis of this system the feed temperature was taken to be constant at 330 K, however, in the dynamic analysis above the feed was varied at 300 and 350, leading to new steady states. In fact, most likely if the initial conditions for the reactor are varied then three new steady states could be found for each of the altered feed temperatures.

The above phase plane portrait shows the steady state conversion tendencies for the CSTR reactor at varying initial temperatures. This phase portrait was created for a feed entering at 330 K; the same conditions as in the steady state analysis. As can be seen in Figure 8, the initial reactor temperature will determine if the reactor will tend toward any of the three steady state conversions: high medium or low. If the reactor temperature is initially greater than around 343 K the reactor will most likely proceed to the high conversion steady state of 0.8009, and a temperature of 406 K. However, if the reactor is initially below 343 K then the reactor tends toward the low conversion steady state of 0.0455, and a temperature of 323 K. These two steady states are stable to slight perturbation of initial reactor temperatures. This stability makes sense when the eigenvalues around these critical points are revisited. The eigenvalues all had negative real parts, and there were imaginary parts in a couple of them. This set of eigenvalues is distinctive for critical points that are known as stable focus points. Stable focus points show characteristic spirals which can be seen for the high and low conversion steady states. The last steady state is the medium conversion steady state, which appears in Figure 8 to be unstable. There does seem to be one strand of the phase portrait that appears to converge to the medium conversion steady state. This strand represents the dynamics of a reactor that begins at 343 K, which is in fact the medium conversion steady state reactor temperature. This means that the only way

10

Figure 8: Phase-plane portrait of conversion at varying initial reactor temperatures for a feed entering at 340 K.

Page 12: Che 360 Project Write Up

the reactor will converge to this steady state is if the initial conditions of the reactor are very close to the steady state conditions. When looking at the eigenvalues, this instability is expected, because one of the eigenvalues is positive and real. Positive eigenvalues are characteristic of unstable critical points.

Overall, the dynamic analysis gave an insight to the importance of initial reactor conditions in the convergence to steady states. Specifically, as the initial reactor temperature is lowered the low convergence steady state becomes more favorable, but as the initial reactor temperature is increased the high conversion steady state becomes more favorable. Also, this dynamic analysis displayed the importance of feed temperature on steady state values. Specifically, as the feed temperature is increased the reactor will converge to higher conversion steady states, but as the feed temperature is lowered the reactor will converge to lower conversion steady states.

11

Page 13: Che 360 Project Write Up

Mathematical Modeling of Polystyrene Plug-Flow ReactorSteady State Analysis:

The next analysis was performed on the same reaction, but a plug-flow reactor was used instead of a CSTR. The initiator and monomer concentrations were again modeled using differential mass balances. Energy balances were also performed on the reactor and jacket temperatures. Numerical methods were used to simulate the steady state and dynamic process behavior of the reactor. Since the reactor is no longer a tank, the concentrations and temperatures change with position. When modeling the dynamic process, these values also change with time.

Steady-state concentrations and temperatures at each position in the reactor were solved using the finite differences method. Specifically, centered differences were used to approximate the derivatives, so an algebraic equation could be formed. This method is the one of the most accurate of the discretization methods. Equations 3 and 4 show how the first and second derivatives were transformed using centered differences method. This transforms the second order ordinary differential equation into a system of linear algebraic equations.

3¿∂x1∂z

=x1 ,i+1−x1 ,i−12∗dS

4 ¿∂2 x1∂ z2

=x i+1−2x1 ,i+x1 ,i−1

dS2

Solving for the steady state at each position along the reactor creates a boundary value problem, so only boundary conditions were necessary to solve the problem. The left side boundary conditions were Dirichlet boundary conditions, so no discretization was required. However, the right side boundary conditions were Robin conditions, so the derivatives needed to be discretized using Equation 3. For the space points between the boundaries, the derivatives were discretized as explained above. In order to solve the problem, a super-matrix was setup that was size 4*N x 1. This allowed it to be solved using the fsolve command in Matlab. The first N rows of the matrix corresponded to initiator concentration, the next N were monomer concentration, and so on. The program that was created in Matlab to solve these equations can be found in Appendix 2. The steady state concentrations and temperatures that were calculated are displayed below in Figure 9.

12

Page 14: Che 360 Project Write Up

It can be seen in Figures 9a and 9b, that the initiator and monomer concentrations stay relatively constant going from the left to the right side of the reactor. This means that the reaction is not taking place, so the inflow of initiator and monomer are balanced by the flow out of the reactor. Figures 9c and 9d show the temperature profiles of the reactor and jacket, respectively. The temperature of the reactor begins at 330 K and decreases quickly to 295.9 K. The jacket temperature begins at 295 K and increases to the equilibrium temperature of 295.9 K. These results show that this process is basically a heat exchanger, with the jacket cooling the feed to a temperature of 295.9 K. The jacket temperature is heated slightly up to the equilibrium temperature of 295.9 K. The lack of reaction could be explained by the system being too stiff to be solved by the finite differences method. The constants given for the model mostly likely are the root of this stiffness. Of the methods that have been learned, none of them were able to solve a very stiff system accurately.

13

Figure 9: Steady state values of a) Initiator Concentration b) Monomer Concentration c) Reactor Temperature d) Jacket Temperature with increasing position within the PFR reactor.

Page 15: Che 360 Project Write Up

Dynamic Analysis:

The dynamic analysis of the plug flow reactor was then performed to model the behavior of the system throughout time, as well as space. Both Euler’s Explicit and Implicit methods were used to numerically solve the resulting partial differential equations. To approximate the time derivatives, the Explicit method uses forward differences, which can be seen in Equation 5.

5¿∂x1∂t

=x1 ,i+1−x1 ,i

dt

It is acceptable to use this method for systems of nonlinear differential equations that are not stiff.

On the other hand, the Implicit method uses backward differences, which is shown in Equation 6. It is used for nonlinear differential equations that are stiff.

6¿∂x1∂ t

=x1 , i−x1, i−1

dt

Euler’s Explicit method was used first to model the dynamic behavior of the reactor, and the results for the concentration and temperature profiles are displayed in Figure 10.

14

Figure 10: The dynamic profiles of a) initiator concentration, b) monomer concentration, c) jacket temperature, d) reactor temperature for the PFR polystyrene production analysis using Euler’s Explicit method.

Page 16: Che 360 Project Write Up

Figure 10a shows the initiator concentration profile. At initial time and the entrance of the reactor, the concentration is at 8,698 mol/m3. Almost as soon the initiator enters the reactor, its concentration drops very low. Also, as time progresses, the concentration at the entrance of the reactor remains constant at its initial value. Inside of the reactor, the concentration goes to zero as time progresses. Figure 10b highlights the same results for the monomer concentration. It begins at a concentration of 588.8 mol/m3 and drops very low when it enters the reactor. The concentration profiles basically describe a reactor that is simply beginning to fill up with the feed. These results can be explained by the shortness of this dynamic analysis. The model was only stable enough to describe the system for about the first minute. Therefore, the reactor didn’t have enough time to even fill the reactor yet. The root of this problem is ones again stiffness. This system is too stiff to be solved using Euler’s Explicit method. The concentration plots show the reactor filling up with some initiator and monomer towards the left side of the reactor, but the values never reach any substantial concentration toward the right side of the reactor. The zero concentration values are not due to the reaction being able to consume them at very high rates. Instead, the system is too stiff to use Euler’s Explicit Method after the first few minutes.

The constant concentration values can also be seen by the plots in Figures 10c and 10d which show the reactor and jacket temperatures, respectively. The reactor temperature begins at 330 K at the left boundary, but after around 45 seconds the left side begins to increase in temperature. If the temperature profile were to continue in time, it would begin to oscillate, and eventually complex numbers would begin to be found as solutions. Again, this diverging reactor temperature can be attributed to system stiffness which causes error build-up and instability propagation. The jacket temperature begins at 295 K at the left boundary, and increases throughout the reactor in time. Around the same time the reactor temperature begins to increase rapidly, the jacket temperature starts to slope upward as heat is transferred from the reactor to the jacket. The instability that can be seen in the reactor temperature will have an effect on the entire system, and the model breaks down shortly after a minute. All of these effects can be correlated to the instability of Euler’s Explicit method when used for stiff systems.

Since the system was too stiff to be solved by Euler’s Explicit, the Implicit method was used in order to decrease the error of the dynamic analysis and show profiles that ranged longer in time. The results from this method can be seen below in Figure 11.

15

Page 17: Che 360 Project Write Up

Figure 11a shows the initiator concentration profile. At the inlet of the reactor at an initial time, the concentration is at 588.8 mol/m3. As time progresses, the initiator concentration has a spike in its value, and then it oscillates in time at a constant position within the reactor. These oscillations are also due to the system being too stiff for this method to solve. Normally, stiff systems are solved with the Implicit method, but even this system is too stiff. This same result can be seen in Figure 11b for the

16

Figure 11: The dynamic profiles of a) initiator concentration, b) monomer concentration, c) reactor temperature, d) jacket temperature for the PFR Polystyrene production analysis using Euler’s Implicit method.

Page 18: Che 360 Project Write Up

monomer concentration within the reactor. Both the initiator and monomer concentration profiles have the same shape and look very similar. As time and position within the reactor increase, the concentration of initiator and monomer begin to increase, which means the reactor is being filled with these materials. The concentrations remain relatively constant at the initial values as time elapses. These results imply that no reaction is occurring, but this can be attributed to the very stiff system.

Due to the stiffness of the system, the plug flow reactor is simulated to act as a simple heat exchanger. Figures 11c and 11d display the reactor and jacket temperature profiles. The reactor temperature begins at its initial condition of 330 K and quickly decreases to 310 K. There is a sudden increase in the temperature around 150 seconds, which is the same time the monomer concentration spikes. The spike in the monomer concentration is due to system stiffness creating error build-up, which causes the reactor temperature to spike. As a result, the jacket temperature has a sudden increase at this same time because heat is being transferred from the reactor to the jacket. Eventually, both the jacket and reactor temperature decrease to 295 K and 380 K, respectively, as time progresses. At the inlet of the reactor, the temperatures are at their boundary conditions and at the first position within the reactor, the temperature rapidly drops to 280 K and begins to oscillate. This can be seen the best at longer time points as the process begins to reach steady state. Again, the Euler’s Implicit method was unable to solve this system accurately due to large system stiffness. The error associated with Euler’s Explicit Method is on the order of the time step squared. Euler’s Implicit Method lowers this error to be on the order of just the time step. Still, the system was stiff enough that this error was large enough to accumulate and create oscillating and diverging solutions. In order to more accurately analyze the plug flow reactor, a different method should be used to deal with the stiffness.

ConclusionAfter analyzing both reactors for the production of polystyrene, more analysis needs to be

completed to determine the best reactor for the process. The CSTR had stable low and high conversion steady states for the given parameters and conditions of the reactor. There was a medium conversion steady state, but it was unstable, so these conditions would be very hard to obtain. Having a stable high conversion steady state shows promise for this reactor to be used in production of polystyrene. Also, this system had a very low stiffness ratio, so Euler’s Explicit method could be used to numerically solve the problem. As a result, a system of algebraic equations did not need to be solved, making the solution easier to obtain. The mathematical model for this process was successful in obtaining a solution to both the steady state and dynamic problems.

On the other hand, the plug flow reactor analysis did not yield useful results. The system was extremely stiff, even for Euler’s Implicit method. Steady states were obtained, but it was concluded that the concentration did not change with position in the reactor. As a result, the reactor became a simple co-current heat exchanger, with the jacket and reactor temperatures reaching an equilibrium. For the dynamic analysis, the system was again too stiff to be solved by Euler’s Explicit and Implicit methods. Again, the results showed that no reaction was occurring and the jacket was cooling the reactor

17

Page 19: Che 360 Project Write Up

contents. In order to more effectively analyze the process, a method could have been used that solves very stiff systems. Overall, the CSTR analysis shows promise for this operation, but the PFR would need to be more accurately analyzed or modeled to make a definite conclusion.

Appendix

Appendix 1Problem 1.1 and 1.2 Code

%Finding steady states with Newton's Method and analyzing stability and%stiffness

function [x]=project11(k) %k is the number of iterations used (1000)

%Below are the initial guesses used to solve for the low, med, and high%conv steady states

%x=[0.2;5;320;300]; %Conv=0.0445 %Low Conv SSx=[0.02;3;340;320]; %Conv=0.2232 %Int Conv SS%x=[0.002;0.5;400;360]; %Conv=0.8009 %High Conv SS

Fs=0.1275; %feed solvent flow rateFm=0.105; %feed monomer flow rateFi=0.03; %feed initiator flow rateCma=8.698; %feed monomer concentrationCia=0.5888; %feed initiator concentrationTa=330; %feed temperatureV=3000; %reactor volumeVj=3312.4; %jacket volumeTjin=295; %inlet jacket temperaturerhoCp=360; %density of reacting mixture*heat capacityFj=0.131; %heat-conducting fluid flow raterhojCpj=966.3; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for termination

%Calculation of the Jacobian for Newton's Method%syms x1 x2 x3 x4%F1=(Fi*Cia-(Fi+Fm+Fs)*x1)/(V)-(kdo*exp(-(Ed)/x3)*x1);%F2=(Fm*Cma-(Fi+Fm+Fs)*x2)/V-(kpo)*exp(-Ep/x3)*x2*(2*f*kdo*exp(Ed/x3)*x1/(kto*exp(Et/x3)))^(0.5);%F3=(Fi+Fm+Fs)*(Ta-x3)/V-dH/(rhoCp)*kpo*exp(Ep/x3)*x2*(2*f*kdo*exp(Ed/x3)*x1/(kto*exp(Et/x3)))^(0.5)-UA/(rhoCp*V)*(x3-x4);%F4=Fj*(Tjin-x4)/Vj+UA/(rhojCpj*Vj)*(x3-x4);

%J=[diff(F1,x1), diff(F1,x2), diff(F1,x3), diff(F1,x4);%diff(F2,x1), diff(F2,x2), diff(F2,x3), diff(F2,x4);%diff(F3,x1), diff(F3,x2), diff(F3,x3), diff(F3,x4);

18

Page 20: Che 360 Project Write Up

%diff(F4,x1), diff(F4,x2), diff(F4,x3), diff(F4,x4)]

% J =[- 59500000000000*exp(-14897/x3) - 7/80000, 0, -(886371500000000000*x1*exp(-14897/x3))/x3^2, 0]%[-(302736000000*x2*exp(-17611/x3))/(57120*x1*exp(-14054/x3))^(1/2),- 10600000*exp(-3557/x3)*(57120*x1*exp(-14054/x3))^(1/2) - 7/80000, - (37704200000*x2*exp(-3557/x3)*(57120*x1*exp(-14054/x3))^(1/2))/x3^2 - (4254651744000000*x1*x2*exp(-17611/x3))/(x3^2*(57120*x1*exp(-14054/x3))^(1/2)), 0]%[ (7362883966293333135*x2*exp(-17611/x3))/(524288*(57120*x1*exp(-14054/x3))^(1/2)), (4124864967111111*exp(-3557/x3)*(57120*x1*exp(-14054/x3))^(1/2))/8388608, (14672144688014221827*x2*exp(-3557/x3)*(57120*x1*exp(-14054/x3))^(1/2))/(8388608*x3^2) + (51738985631143251939645*x1*x2*exp(-17611/x3))/(262144*x3^2*(57120*x1*exp(-14054/x3))^(1/2)) - 7024281018808382541/46116860184273879040000, 4782489204295069/73786976294838206464]%[ 0, 0, 3227401481264261/147573952589676412928, -1876414528486709264373/30551497534877759386419200]

for j=1:k

F1=(Fi*Cia-(Fi+Fm+Fs)*x(1))/(V)-(kdo*exp(-(Ed)/x(3))*x(1)); F2=(Fm*Cma-(Fi+Fm+Fs)*x(2))/V-((kpo)*exp(-Ep/x(3)))*x(2)*(2*f*kdo*exp(-Ed/x(3))*x(1)/(kto*exp(-Et/x(3))))^(0.5); F3=(Fi+Fm+Fs)*(Ta-x(3))/V-dH/(rhoCp)*kpo*exp(-Ep/x(3))*x(2)*(2*f*kdo*exp(-Ed/x(3))*x(1)/(kto*exp(-Et/x(3))))^(0.5)-UA/(rhoCp*V)*(x(3)-x(4)); F4=Fj*(Tjin-x(4))/Vj+UA/(rhojCpj*Vj)*(x(3)-x(4));

df1x1=-59500000000000*exp(-14897/x(3)) - 7/80000; df1x2=0; df1x3=-(886371500000000000*x(1)*exp(-14897/x(3)))/x(3)^2; df1x4=0; df2x1=-(302736000000*x(2)*exp(-17611/x(3)))/(57120*x(1)*exp(-14054/x(3)))^(1/2); df2x2=- 10600000*exp(-3557/x(3))*(57120*x(1)*exp(-14054/x(3)))^(1/2) - 7/80000; df2x3=- (37704200000*x(2)*exp(-3557/x(3))*(57120*x(1)*exp(-14054/x(3)))^(1/2))/x(3)^2 - (4254651744000000*x(1)*x(2)*exp(-17611/x(3)))/(x(3)^2*(57120*x(1)*exp(-14054/x(3)))^(1/2)); df2x4=0; df3x1= (7362883966293333135*x(2)*exp(-17611/x(3)))/(524288*(57120*x(1)*exp(-14054/x(3)))^(1/2)); df3x2=(4124864967111111*exp(-3557/x(3))*(57120*x(1)*exp(-14054/x(3)))^(1/2))/8388608; df3x3=(14672144688014221827*x(2)*exp(-3557/x(3))*(57120*x(1)*exp(-14054/x(3)))^(1/2))/(8388608*x(3)^2) + (51738985631143251939645*x(1)*x(2)*exp(-17611/x(3)))/(262144*x(3)^2*(57120*x(1)*exp(-14054/x(3)))^(1/2))-7024281018808382541/46116860184273879040000; df3x4=4782489204295069/73786976294838206464; df4x1=0; df4x2=0; df4x3=3227401481264261/147573952589676412928; df4x4=-1876414528486709264373/30551497534877759386419200;

DF=[df1x1 df1x2 df1x3 df1x4;df2x1 df2x2 df2x3 df2x4;df3x1 df3x2 df3x3 df3x4;df4x1 df4x2 df4x3 df4x4]; F=[F1;F2;F3;F4]; xo=x; x=xo-(inv(DF)*F); c=(norm((x-xo),1))/(norm(x,1)); if c<=0.00000001 break; end end conv=((Fm*Cma)-((Fi+Fm+Fs)*x(2)))/(Fm*Cma) lambda=eig(DF) lambdamin=min(abs(lambda)); lambdamax=max(abs(lambda)); Stiffness=lambdamax/lambdaminend

19

Page 21: Che 360 Project Write Up

Problem 1.3 Code

%Simulation of dynamic process using Euler Explicit at low conversion%steady state

function [xplot,Tplot,tplot,Xplot]=project13(k,dt,x1o,x2o,x3o,x4o,Xo)

%k is number of iterations (20000)%dt is time step (5)%Initial conditions are low conversion SS values%x1o=0.068%x2o=3.3245%x3o=323.5557%x4o=305.1681%Xo=0.0455

Fs=0.1275; %feed solvent flow rateFm=0.105; %feed monomer flow rateFi=0.03; %feed initiator flow rateCma=8.698; %feed monomer concentrationCia=0.5888; %feed initiator concentrationTa=350; %feed temperatureV=3000; %reactor volumeVj=3312.4; %jacket volumeTjin=295; %inlet jacket temperaturerhoCp=360; %density of reacting mixture*heat capacityFj=0.131; %heat-conducting fluid flow raterhojCpj=966.3; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for termination

to=0;xo=[x1o;x2o];To=[x3o;x4o];

Xplot=zeros(k,1);xplot=zeros(k,2);xplot(1,:)=xo;Tplot=zeros(k,2);Tplot(1,:)=To;tplot=zeros(k,1);Xplot(1,:)=Xo;for j=1:k x1t=x1o+dt*((Fi*Cia-(Fi+Fm+Fs)*x1o)/(V)-(kdo*exp(-(Ed)/x3o)*x1o)); x2t=x2o+dt*((Fm*Cma-(Fi+Fm+Fs)*x2o)/V-((kpo)*exp(-Ep/x3o))*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)); x3t=x3o+dt*((Fi+Fm+Fs)*(Ta-x3o)/V-dH/(rhoCp)*kpo*exp(-Ep/x3o)*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)-UA/(rhoCp*V)*(x3o-x4o)); x4t=x4o+dt*(Fj*(Tjin-x4o)/Vj+UA/(rhojCpj*Vj)*(x3o-x4o));

x1o=x1t; x1=x1o;

x2o=x2t; x2=x2o;

x3o=x3t;

20

Page 22: Che 360 Project Write Up

x3=x3o;

x4o=x4t; x4=x4o;

x=[x1;x2]; xplot(j+1,:)=x;

T=[x3;x4]; Tplot(j+1,:)=T;

tt=to+dt; to=tt; t=to; tplot(j+1,:)=t/3600;

Xo=((Fm*Cma)-((Fi+Fm+Fs)*x2o))/(Fm*Cma); Xt=((Fm*Cma)-((Fi+Fm+Fs)*x2))/(Fm*Cma); Xo=Xt; X=Xo; Xplot(j+1,:)=X;endhold onfigure(1)plot(tplot,xplot)xlabel 'Time (hours)'ylabel 'Concentration (mol/L)'hold off

% hold on% figure(2)% plot(tplot1,xplot1)% xlabel 'Time (hours)'% ylabel 'Concentration (mol/L)'% hold off

%hold on%figure (3)%plot(Tplot(:,1),Xplot)%xlabel 'Reactor Temperature (K)'%ylabel 'Conversion'%hold offend

Problem 1.4 Code

%Simulation of dynamic process using Euler Explicit at medium conversion%steady state

function [xplot1,Tplot1,tplot1,Xplot1]=project14(k,dt,x1o,x2o,x3o,x4o,Xo)

%k is number of iterations (10000)%dt is time step (1)%Initial conditions are med conversion SS values%x1o=0.068%x2o=3.3245%x3o=323.5557%x4o=305.1681%Xo=0.0455

Fs=0.1275; %feed solvent flow rateFm=0.105; %feed monomer flow rateFi=0.03; %feed initiator flow rate

21

Page 23: Che 360 Project Write Up

Cma=8.698; %feed monomer concentrationCia=0.5888; %feed initiator concentrationTa=300; %feed temperatureV=3000; %reactor volumeVj=3312.4; %jacket volumeTjin=295; %inlet jacket temperaturerhoCp=360; %density of reacting mixture*heat capacityFj=0.131; %heat-conducting fluid flow raterhojCpj=966.3; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for termination

to=0;xo=[x1o;x2o];To=[x3o;x4o];

Xplot1=zeros(k,1);xplot1=zeros(k,2);xplot1(1,:)=xo;Tplot1=zeros(k,2);Tplot1(1,:)=To;tplot1=zeros(k,1);Xplot1(1,:)=Xo;for j=1:k x1t=x1o+dt*((Fi*Cia-(Fi+Fm+Fs)*x1o)/(V)-(kdo*exp(-(Ed)/x3o)*x1o)); x2t=x2o+dt*((Fm*Cma-(Fi+Fm+Fs)*x2o)/V-((kpo)*exp(-Ep/x3o))*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)); x3t=x3o+dt*((Fi+Fm+Fs)*(Ta-x3o)/V-dH/(rhoCp)*kpo*exp(-Ep/x3o)*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)-UA/(rhoCp*V)*(x3o-x4o)); x4t=x4o+dt*(Fj*(Tjin-x4o)/Vj+UA/(rhojCpj*Vj)*(x3o-x4o));

x1o=x1t; x1=x1o;

x2o=x2t; x2=x2o;

x3o=x3t; x3=x3o;

x4o=x4t; x4=x4o;

x=[x1;x2]; xplot1(j+1,:)=x;

T=[x3;x4]; Tplot1(j+1,:)=T;

tt=to+dt; to=tt; t=to; tplot1(j+1,:)=t/3600;

Xo=((Fm*Cma)-((Fi+Fm+Fs)*x2o))/(Fm*Cma); Xt=((Fm*Cma)-((Fi+Fm+Fs)*x2))/(Fm*Cma); Xo=Xt;

22

Page 24: Che 360 Project Write Up

X=Xo; Xplot1(j+1,:)=X;endhold onfigure(1)plot(tplot1,xplot1)xlabel 'Time (hours)'ylabel 'Concentration (mol/L)'hold off

%hold on%figure(2)%plot(tplot1,xplot1)%xlabel 'Time (hours)'%ylabel 'Concentration (mol/L)'%hold off

% hold on% figure (3)% plot(Tplot1(:,1),Xplot1)% xlabel 'Reactor Temperature (K)'% ylabel 'Conversion'% hold offend

Problem 1.5 Code

%Phase-portrait of dynamic processclearclc

Fs=0.1275; %feed solvent flow rateFm=0.105; %feed monomer flow rateFi=0.03; %feed initiator flow rateCma=8.698; %feed monomer concentrationCia=0.5888; %feed initiator concentrationTa=330; %feed temperatureV=3000; %reactor volumeVj=3312.4; %jacket volumeTjin=295; %inlet jacket temperaturerhoCp=360; %density of reacting mixture*heat capacityFj=0.131; %heat-conducting fluid flow raterhojCpj=966.3; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for termination

for x3o=300:2:360; %low conversion x1o=0.068; x2o=3.3245; x4o=305.1681; Xo=.0455; dt=1;

23

Page 25: Che 360 Project Write Up

k=100000;

to=0; xo=[x1o;x2o]; To=[x3o;x4o];

Xplot=zeros(k,1); xplot=zeros(k,2); xplot(1,:)=xo; Tplot=zeros(k,2); Tplot(1,:)=To; tplot=zeros(k,1); Xplot(1,:)=Xo;

for j=1:k x1t=x1o+dt*((Fi*Cia-(Fi+Fm+Fs)*x1o)/(V)-(kdo*exp(-(Ed)/x3o)*x1o)); x2t=x2o+dt*((Fm*Cma-(Fi+Fm+Fs)*x2o)/V-((kpo)*exp(-Ep/x3o))*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)); x3t=x3o+dt*((Fi+Fm+Fs)*(Ta-x3o)/V-dH/(rhoCp)*kpo*exp(-Ep/x3o)*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)-UA/(rhoCp*V)*(x3o-x4o)); x4t=x4o+dt*(Fj*(Tjin-x4o)/Vj+UA/(rhojCpj*Vj)*(x3o-x4o));

x1o=x1t; x1=x1o;

x2o=x2t; x2=x2o;

x3o=x3t; x3=x3o;

x4o=x4t; x4=x4o;

x=[x1;x2]; xplot(j+1,:)=x;

T=[x3;x4]; Tplot(j+1,:)=T;

tt=to+dt; to=tt; t=to; tplot(j+1,:)=t/3600;

Xo=((Fm*Cma)-((Fi+Fm+Fs)*x2o))/(Fm*Cma); Xt=((Fm*Cma)-((Fi+Fm+Fs)*x2))/(Fm*Cma); Xo=Xt; X=Xo; Xplot(j+1,:)=X; end hold on figure (12) pause(1) plot(Tplot(:,1),Xplot) xlabel 'Reactor Temperature (K)' ylabel 'Conversion' hold offend

for x3o=300:2:360 %medium conversion x1o=0.0615; x2o=2.7027; x4o=312.1228; Xo=.2232;

24

Page 26: Che 360 Project Write Up

dt=1; k=100000;

to=0; xo=[x1o;x2o]; To=[x3o;x4o];

Xplot=zeros(k,1); xplot=zeros(k,2); xplot(1,:)=xo; Tplot=zeros(k,2); Tplot(1,:)=To; tplot=zeros(k,1); Xplot(1,:)=Xo; for j=1:k x1t=x1o+dt*((Fi*Cia-(Fi+Fm+Fs)*x1o)/(V)-(kdo*exp(-(Ed)/x3o)*x1o)); x2t=x2o+dt*((Fm*Cma-(Fi+Fm+Fs)*x2o)/V-((kpo)*exp(-Ep/x3o))*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)); x3t=x3o+dt*((Fi+Fm+Fs)*(Ta-x3o)/V-dH/(rhoCp)*kpo*exp(-Ep/x3o)*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)-UA/(rhoCp*V)*(x3o-x4o)); x4t=x4o+dt*(Fj*(Tjin-x4o)/Vj+UA/(rhojCpj*Vj)*(x3o-x4o));

x1o=x1t; x1=x1o;

x2o=x2t; x2=x2o;

x3o=x3t; x3=x3o;

x4o=x4t; x4=x4o;

x=[x1;x2]; xplot(j+1,:)=x;

T=[x3;x4]; Tplot(j+1,:)=T;

tt=to+dt; to=tt; t=to; tplot(j+1,:)=t/3600;

Xo=((Fm*Cma)-((Fi+Fm+Fs)*x2o))/(Fm*Cma); Xt=((Fm*Cma)-((Fi+Fm+Fs)*x2))/(Fm*Cma); Xo=Xt; X=Xo; Xplot(j+1,:)=X; end hold on figure (12) pause(1) plot(Tplot(:,1),Xplot) xlabel 'Reactor Temperature (K)' ylabel 'Conversion' hold offend

for x3o=300:2:400 %high conversion x1o=0.0008; x2o=0.6927; x4o=334.6012; Xo=.8009; dt=1;

25

Page 27: Che 360 Project Write Up

k=100000;

to=0; xo=[x1o;x2o]; To=[x3o;x4o];

Xplot=zeros(k,1); xplot=zeros(k,2); xplot(1,:)=xo; Tplot=zeros(k,2); Tplot(1,:)=To; tplot=zeros(k,1); Xplot(1,:)=Xo; for j=1:k x1t=x1o+dt*((Fi*Cia-(Fi+Fm+Fs)*x1o)/(V)-(kdo*exp(-(Ed)/x3o)*x1o)); x2t=x2o+dt*((Fm*Cma-(Fi+Fm+Fs)*x2o)/V-((kpo)*exp(-Ep/x3o))*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)); x3t=x3o+dt*((Fi+Fm+Fs)*(Ta-x3o)/V-dH/(rhoCp)*kpo*exp(-Ep/x3o)*x2o*(2*f*kdo*exp(-Ed/x3o)*x1o/(kto*exp(-Et/x3o)))^(0.5)-UA/(rhoCp*V)*(x3o-x4o)); x4t=x4o+dt*(Fj*(Tjin-x4o)/Vj+UA/(rhojCpj*Vj)*(x3o-x4o));

x1o=x1t; x1=x1o;

x2o=x2t; x2=x2o;

x3o=x3t; x3=x3o;

x4o=x4t; x4=x4o;

x=[x1;x2]; xplot(j+1,:)=x;

T=[x3;x4]; Tplot(j+1,:)=T;

tt=to+dt; to=tt; t=to; tplot(j+1,:)=t/3600;

Xo=((Fm*Cma)-((Fi+Fm+Fs)*x2o))/(Fm*Cma); Xt=((Fm*Cma)-((Fi+Fm+Fs)*x2))/(Fm*Cma); Xo=Xt; X=Xo; Xplot(j+1,:)=X; end hold on figure (12) pause(1) plot(Tplot(:,1),Xplot) xlabel 'Reactor Temperature (K)' ylabel 'Conversion' hold offend

Appendix 2Problem 2.7 Code

26

Page 28: Che 360 Project Write Up

%Solving the finite differences equations

function [z,xt]=project27SS(xg1,xg2,xg3,xg4,dS)

%dS is space step (0.1)%guesses are the left side boundary conditions%x1g=0.0005888%x2g=0.008698%x3g=330%x4g=295

L=300;N=L/dS+1;z=zeros(N,1);xo=zeros(4*N,1);xo(1)=xg1;xo(N+1)=xg2;xo(2*N+1)=xg3;xo(3*N+1)=xg4;

for i=2:N z(i)=z(i-1)+dS; xo(i)=xg1; xo(N+i)=xg2; xo(2*N+i)=xg3; xo(3*N+i)=xg4;end%test=project21(xo);xt=fsolve(@(xf) project27(xf,dS),xo,optimset('Display','off'));

%Solving the steady state for PFR

function F=project27(x,dS)

Fs=0.1275*1000; %feed solvent flow rateFm=0.105*1000; %feed monomer flow rateFi=0.03*1000; %feed initiator flow raterhoCp=360*10; %density of reacting mixture*heat capacityrhojCpj=966.3*10; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700*10000; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for terminationL=300; %Reactor Lengthd=30; %Reactor Diameterv=(Fi+Fm+Fs)/((pi*((d)^2))/4); %axial fluid velocityvj=5; %Axial heat-conducting fluid velocityD1=5*(10^-6); %Initiator DiffusivityD2=1.4*(10^-7); %Monomer Diffusivityk=3.3; %Fluid thermal conductivitykj=56; %Heat conducting fluid thermal conductivityx1o=.0005888;x2o=.008698;x3o=330;x4o=295;

N=L/dS+1;F=zeros(4*N,1);F(1)=x(1)-x1o; %Left side boundary condition for initiator concentrationF(N+1)=x(N+1)-x2o; %Left side boundary condition for monomer concentration

27

Page 29: Che 360 Project Write Up

F(2*N+1)=x(2*N+1)-x3o; %Left side boundary condition for reactor tempF(3*N+1)=x(3*N+1)-x4o; %Left side boundary condition for jacket tempfor i=2:N-1 kd=kdo*exp(-Ed/x(2*N+i)); kp=kpo*exp(-Ep/x(2*N+i)); kt=kto*exp(-Et/x(2*N+i)); R=(((2*f*kd*x(i))/(kt))^2)^0.25; F(i)=-v*((x(i+1)-x(i-1))/(2*(dS)))+D1*((x(i+1)-2*x(i)+x(i-1))/((dS)^2))-kd*x(i); F(N+i)=-v*((x(N+i+1)-x(N+i-1))/(2*(dS)))+D2*((x(N+i+1)-2*x(N+i)+x(N+i-1))/((dS)^2))-kp*x(N+i)*R; F(2*N+i)=-v*((x(2*N+i+1)-x(2*N+i-1))/(2*(dS)))+(k/rhoCp)*((x(2*N+i+1)-2*x(2*N+i)+x(2*N+i-1))/((dS)^2))-(dH/rhoCp)*kp*x(N+i)*R-((UA)/rhoCp)*(x(2*N+i)-x(3*N+i)); F(3*N+i)=-vj*((x(3*N+i+1)-x(3*N+i-1))/(2*(dS)))+(kj/rhojCpj)*((x(3*N+i+1)-2*x(3*N+i)+x(3*N+i-1))/((dS)^2))+((UA)/rhojCpj)*(x(2*N+i)-x(3*N+i));endF(N)=D1*((2*x(N-1)-2*x(N))/((dS)^2))-(kdo*exp(-Ed/x(3*N)))*x(N); %Right side boundary condition for initiator concentrationF(2*N)=D2*((2*x(2*N-1)-2*x(2*N))/((dS)^2))-(kpo*exp(-Ep/x(3*N)))*x(2*N)*((((2*f*kdo*exp(-Ed/x(3*N))*x(N))/(kto*exp(-Et/x(3*N))))^2)^0.25); %Right side boundary condition for monomer concentrationF(3*N)=(k/rhoCp)*((2*x(3*N-1)-2*x(3*N))/((dS)^2))-(dH/rhoCp)*(kpo*exp(-Ep/x(2*N)))*x(3*N)*((((2*f*kdo*exp(-Ed/x(3*N))*x(N))/(kto*exp(-Et/x(3*N))))^2)^0.25)-((UA)/rhoCp)*(x(3*N)-x(4*N)); %Right side boundary condition for reactor tempF(4*N)=(kj/rhojCpj)*((2*x(4*N-1)-2*x(4*N))/((dS)^2))+((UA)/rhojCpj)*(x(3*N)-x(4*N)); %Right side boundary condition for jacket tempendfigure(1)plot(z,xt(1:N))figure(2)plot(z,xt(N+1:2*N))figure(3)plot(z,xt(2*N+1:3*N))figure(4)plot(z,xt(3*N+1:4*N))end

Problem 2.8 Code (Euler Explicit)

%Dynamic simulation for PFR using euler explicit

function [S,time,x1,x2,x3,x4]=project28exp1(dt,dS,tf)

%dt is time step (0.5)%dS is space step (0.5)%tf is the final time point calculated (61)

Fs=0.1275/1000; %feed solvent flow rateFm=0.105/1000; %feed monomer flow rateFi=0.03/1000; %feed initiator flow raterhoCp=360*1000; %density of reacting mixture*heat capacityrhojCpj=966.3*1000; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for terminationL=3; %Reactor Lengthd=.3; %Reactor Diameterv=(Fi+Fm+Fs)/((pi*((d)^2))/4); %axial fluid velocity

28

Page 30: Che 360 Project Write Up

vj=0.05; %Axial heat-conducting fluid velocityD1=5*(10^-10); %Initiator DiffusivityD2=1.4*(10^-11); %Monomer Diffusivity

k=.033; %Fluid thermal conductivitykj=.56; %Heat conducting fluid thermal conductivity

x1L=588.8;x2L=8698;x3L=330;x4L=295;

x1o=0;x2o=0;x3o=330;x4o=295;

NS=L/dS+1; Nt=tf/dt+1;x1=zeros(Nt,NS);x2=zeros(Nt,NS);x3=zeros(Nt,NS);x4=zeros(Nt,NS);

for i=2:Nt x1(i,1)=x1L; x2(i,1)=x2L; x3(i,1)=x3L; x4(i,1)=x4L;end

for j=2:NS x1(1,j)=x1o; x2(1,j)=x2o; x3(1,j)=x3o; x4(1,j)=x4o;endx1(1,1)=0;x2(1,1)=0;x3(1,1)=330;x4(1,1)=295;

for t=1:Nt-1 for S=2:NS-1 dx1=-v*(x1(t,S+1)-x1(t,S-1))/(2*dS) +D1*(x1(t,S+1)-2*x1(t,S)+x1(t,S-1))/dS^2 -x1(t,S)*kdo*exp(-Ed*x3(t,S)^-1); dx2=-v*(x2(t,S+1)-x2(t,S-1))/(2*dS) +D2*(x2(t,S+1)-2*x2(S)+x2(t,S-1))/dS^2-x2(t,S)*kpo*exp(-Ep*x3(t,S)^-1)*(2*f*(kdo*exp(-Ed*x3(t,S)^-1))*x1(t,S)/(kto*exp(-Et*x3(t,S)^-1)))^(1/2); dx3=-v*(x3(t,S+1)-x3(t,S-1))/(2*dS) + k/rhoCp*(x3(t,S+1)-2*x3(t,S)+x3(t,S-1))/dS^2 -dH/rhoCp*x2(t,S)*kpo*exp(-Ep*x3(t,S)^-1)*(2*f*(kdo*exp(-Ed*x3(t,S)^-1))*x1(t,S)/(kto*exp(-Et*x3(t,S)^-1)))^(1/2) - UA/rhoCp*(x3(t,S)-x4(t,S)); dx4=-vj*(x4(t,S+1)-x4(t,S-1))/(2*dS) + (kj/rhojCpj)*(x4(t,S+1)-2*x4(t,S)+x4(t,S-1))/dS^2 +(UA/rhojCpj)*(x3(t,S)-x4(t,S)); x1(t+1,S)=x1(t,S)+dt*dx1; x2(t+1,S)=x2(t,S)+dt*dx2; x3(t+1,S)=x3(t,S)+dt*dx3; x4(t+1,S)=x4(t,S)+dt*dx4; end

dx1=D1*(-2*x1(t,NS)+2*x1(t,NS-1))/dS^2 -x1(t,NS)*kdo*exp(-Ed*x3(t,NS)^-1); dx2=D2*(-2*x2(t,NS)+2*x2(t,NS-1))/dS^2 -x2(t,NS)*kpo*exp(-Ep*x3(t,NS)^-1)*(2*f*(kdo*exp(-Ed*x3(t,NS)^-1))*x1(t,NS)/(kto*exp(-Et*x3(t,NS)^-1)))^(1/2); dx3=k/rhoCp*(-2*x3(t,NS)+2*x3(t,NS-1))/dS^2 -dH/rhoCp*x2(t,NS)*kpo*exp(-Ep*x3(t,NS)^-1)*(2*f*(kdo*exp(-Ed*x3(t,NS)^-1))*x1(t,NS)/(kto*exp(-Et*x3(t,NS)^-1)))^(1/2) - UA/rhoCp*(x3(t,NS)-x4(t,NS));

29

Page 31: Che 360 Project Write Up

dx4=(kj/rhojCpj)*(-2*x4(t,NS)+2*x4(t,NS-1))/dS^2 +(UA/rhojCpj)*(x3(t,NS)-x4(t,NS)); x1(t+1,NS)=x1(t,NS)+dt*dx1; x2(t+1,NS)=x2(t,NS)+dt*dx2; x3(t+1,NS)=x3(t,NS)+dt*dx3; x4(t+1,NS)=x4(t,NS)+dt*dx4;end[S,time]=meshgrid(0:dS:L,0:dt:tf);

figure(9)surf(S,time,x1)figure(10)surf(S,time,x2)figure(11)surf(S,time,x3)figure(12)surf(S,time,x4)end

Problem 2.8 Code (Euler Implicit)

%Dynamic simulation for PFR using euler implicit

function [z,time,x]=project28imp(dt,dS,tf)

%dt is time step (5)%dS is space step (0.2)%tf is the final time point calculated (800)

Fs=0.1275/1000; %feed solvent flow rateFm=0.105/1000; %feed monomer flow rateFi=0.03/1000; %feed initiator flow raterhoCp=360*1000; %density of reacting mixture*heat capacityrhojCpj=966.3*1000; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for terminationL=3; %Reactor Lengthd=.3; %Reactor Diameterv=(Fi+Fm+Fs)/((pi*((d)^2))/4); %axial fluid velocityvj=.05; %Axial heat-conducting fluid velocityD1=5*(10^-10); %Initiator DiffusivityD2=1.4*(10^-11); %Monomer Diffusivityk=.033; %Fluid thermal conductivitykj=.56; %Heat conducting fluid thermal conductivityx1L=588.8;x2L=8698;x3L=330;x4L=295;

N=L/dS+1; Nt=tf/dt+1;xo=zeros(1,4*N);xo(1,1:N)=0;xo(1,N+1:2*N)=0;

30

Page 32: Che 360 Project Write Up

xo(1,2*N+1:3*N)=330;xo(1,3*N+1:4*N)=295;x=zeros(Nt,4*N);

for j=2:Nt x(j,1)=x1L; x(j,N+1)=x2L; x(j,2*N+1)=x3L; x(j,3*N+1)=x4L;endx(1,:)=xo;for t=1:Nt-1 xt=fsolve(@(xf) xf-xo'-dt*(spacefn(xf,dS)),xo',optimset('Display','off')); x(t+1,:)=xt'; xo=xt'; %xplot=xo;end

function F=spacefn(x,dS)

Fs=0.1275/1000; %feed solvent flow rateFm=0.105/1000; %feed monomer flow rateFi=0.03/1000; %feed initiator flow raterhoCp=360; %density of reacting mixture*heat capacityrhojCpj=966.3; %density of the heat conducting fluid*heat capacityUA=70; %Global heat transfer coefficient*heat exchange area between the jacket and reactor constituentsf=0.6; %initiator efficiencydH=-16700; %heat of reactionkdo=5.95*(10^13); %preexponential factor for dissociationEd=14897; %activation energy for dissociationkpo=1.06*(10^7); %preexponential factor for propagationEp=3557; %activation energy for propagationkto=1.25*(10^9); %preexponential factor for terminationEt=843; %activation energy for terminationL=3; %Reactor Lengthd=.3; %Reactor Diameterv=(Fi+Fm+Fs)/((pi*((d)^2))/4); %axial fluid velocityvj=.05; %Axial heat-conducting fluid velocityD1=5*(10^-6); %Initiator DiffusivityD2=1.4*(10^-7); %Monomer Diffusivityk=.033; %Fluid thermal conductivitykj=.56; %Heat conducting fluid thermal conductivityx1L=588.8;x2L=8698;x3L=330;x4L=295;

N=L/dS+1;F=zeros(4*N,1);F(1)=x(1)-x1L; %Left side boundary condition for initiator concentrationF(N+1)=x(N+1)-x2L; %Left side boundary condition for monomer concentrationF(2*N+1)=x(2*N+1)-x3L; %Left side boundary condition for reactor tempF(3*N+1)=x(3*N+1)-x4L; %Left side boundary condition for jacket tempfor i=2:N-1 kd=kdo*exp(-Ed/x(2*N+i)); kp=kpo*exp(-Ep/x(2*N+i)); kt=kto*exp(-Et/x(2*N+i)); R=(((2*f*kd*x(i))/(kt))^2)^0.25; F(i)=-v*((x(i+1)-x(i-1))/(2*(dS)))+D1*((x(i+1)-2*x(i)+x(i-1))/((dS)^2))-kd*x(i); F(N+i)=-v*((x(N+i+1)-x(N+i-1))/(2*(dS)))+D2*((x(N+i+1)-2*x(N+i)+x(N+i-1))/((dS)^2))-kp*x(N+i)*R; F(2*N+i)=-v*((x(2*N+i+1)-x(2*N+i-1))/(2*(dS)))+(k/rhoCp)*((x(2*N+i+1)-2*x(2*N+i)+x(2*N+i-1))/((dS)^2))-(dH/rhoCp)*kp*x(N+i)*R-((UA)/rhoCp)*(x(2*N+i)-x(3*N+i)); F(3*N+i)=-vj*((x(3*N+i+1)-x(3*N+i-1))/(2*(dS)))+(kj/rhojCpj)*((x(3*N+i+1)-2*x(3*N+i)+x(3*N+i-1))/((dS)^2))+((UA)/rhojCpj)*(x(2*N+i)-x(3*N+i));end

31

Page 33: Che 360 Project Write Up

F(N)=D1*((2*x(N-1)-2*x(N))/((dS)^2))-(kdo*exp(-Ed/x(3*N)))*x(N); %Right side boundary condition for initiator concentrationF(2*N)=D2*((2*x(2*N-1)-2*x(2*N))/((dS)^2))-(kpo*exp(-Ep/x(3*N)))*x(2*N)*((((2*f*kdo*exp(-Ed/x(3*N))*x(N))/(kto*exp(-Et/x(3*N))))^2)^0.25); %Right side boundary condition for monomer concentrationF(3*N)=(k/rhoCp)*((2*x(3*N-1)-2*x(3*N))/((dS)^2))-(dH/rhoCp)*(kpo*exp(-Ep/x(3*N)))*x(2*N)*((((2*f*kdo*exp(-Ed/x(3*N))*x(N))/(kto*exp(-Et/x(3*N))))^2)^0.25)-((UA)/rhoCp)*(x(3*N)-x(4*N)); %Right side boundary condition for reactor tempF(4*N)=(kj/rhojCpj)*((2*x(4*N-1)-2*x(4*N))/((dS)^2))+((UA)/rhojCpj)*(x(3*N)-x(4*N)); %Right side boundary condition for jacket tempend[z,time]=meshgrid(0:dS:L,0:dt:tf);figure(5)surf(z,time,x(1:Nt,1:N))figure(6)surf(z,time,x(1:Nt,N+1:2*N))figure(7)surf(z,time,x(1:Nt,2*N+1:3*N))figure(8)surf(z,time,x(1:Nt,3*N+1:4*N))

end

32