Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Chemical Engineering 2E04

Mastery Problem 1.3

Discretized Modeling

Learning Outcomes

•     Experience the power of linear approximations.

•     Use MATLAB to solve a real engineering system.

•     Exploit problem structure to improve solution times for large systems.

•    Gain practice with parsing large problem statements to extract realistic expectations.

Submission Instructions

•    You can complete this problem in groups of up to TWO (2).

•    Your submission will be a .zip file containing two components:

1.    A complete MATLAB code, which must output exactly what is required in the deliverables section at the end of this problem statement.

2.    A one-page cover letter outlining your learning experience, any challenges you faced, and a brief analysis of the key outcomes of the problem. Your cover letter should be signed and dated. The cover letter is not to exceed one page.

•    Submissions must be deposited in the A2L drop box for this mastery problem.

•     BOTH names and student numbers should appear in two places:

1.    On the cover letter, along with your signature.

2.    Be output using an fprintf() statement at the beginning of your MATLAB code.

•     For all mastery problems, please use the naming convention:

2E04_M_#.#_NNNNNNNNN_NNNNNNNNN

Where  #.# is the  mastery  problem  number, and NNNNNNNNN are the student  numbers of all students. Use this naming convention for the  .zip containing all files. Your MATLAB codes can be named whatever is most convenient for your code to run.

Grading Comments

•    This problem will be graded as all-or-nothing (0% or 100%).

•    You may submit your solution to this problem as many times as you wish before the end of term.

•    You may request feedback/guidance from the TAs and the instructor at any time.

•     Failing to follow these guidelines will result in your submission being graded as 0%.

•  Suspicious  submissions  will  be  flagged  for  academic  dishonesty  be  pursued  according  to McMaster’sacademic integrity policy.

Background

The following is presented as a real application of discretized linearization of a normally nonlinear system. It may seem long and complicated but remember that you are not expected to model this system. Maybe this is something you would do later in your degree (for ChE, at least), but that doesnt mean we cant use 2E04 to solve it! Just keep that in mind when reading below.

In the natural gas recovery industry, raw gas extracted from the ground by conventional means can contain up to 8 mol% CO2. In Canada, the maximum allowable CO2  composition in user-quality natural gas is only 0.7 mol% due to corrosion issues, wasted energy spent transporting worthless CO2 over long distances, and because it dilutes the gas, reducing its value. Therefore, CO2  removal is usually required at the drilling site.

One way of removing the CO2  is to use a CO2 -selective membrane. Low pressure steam is used as the “sweep” gas in counter-current flow. CO2  leaves the natural gas through the membrane and enters the

sweep gas via selective molecular diffusion. Captured CO2 can be purified from the water-CO2 stream using condensation and may then be pipelined or used forenhanced oil recovery. The steam used as the sweep gas may then be regenerated in a furnace (that uses a little of our own, now purified, natural gas!) before

heading  back to the membrane. A  block-flow diagram of the natural gas extraction and CO2   removal processes is shown in Figure 1.

CO2 to

sequestration

Condenser

Flash Drum                   Boiler

Water

Steam

with CO2

Steam

Pipeline Quality

Natural Gas

Figure 1: Natural gas refining process, including steam regeneration and pipelining.

This problem will focus solely on modeling and solving the membrane process. The section that concerns us is boxed in Figure 1. Here is some info about the membrane:

•    The membrane can be visualized as a heat exchanger operating in a counter-current configuration, BUT the exchanger can transfer mass (across the membrane) as well as energy.

•    The  membrane  is  a tube  containing the  natural  gas  passing through  a  larger  tube  (or  shell) containing the sweep gas (steam), with the inner tube being made of our membrane material.

•    We  have  CO2   moving  from  one  stream  to  the  other.  Therefore,  mass  and  energy  are  being exchanged between our two streams (the natural gas and the sweep gas) instead of only energy.

We desire a discretized model of the membrane so that we can perform steady-state mass and energy balances in each discretized section, which we can then solve as a scalable system of linear equations.

The Discretization Strategy

We are going to implement some of the numerical methods we developed in class in order to solve our model. Our mass and energy balances cannot be for the whole” membrane since it is very likely that the temperatures and concentrations of CO2  in the natural gas and sweep gas phases will change along the length of the membrane.

Let’s make some (reasonable) assumptions about a given slice” (see Figure 2) of the membrane, provided that our slice is sufficiently small. The raw natural gas enters the tube on the far left (section 1), is purified

throughout the membrane, and leaves on the far right (section N). The steam enters the shell on the far right (section N+1) and exits on the left (section 1). SeeFigure 2for details.

ΔL

TNG 1 FNGCO2,1 FNGCH4,1

Membrane

rtube

Natural Gas

Steam                                                                   Steam

with CO2

TNG N+1

FNGCO2,N+1

FNGCH4,N+1

Zoomed in

Unit Section i

Figure 2: Gas membrane diagram showing segmentation of length ΔL. We will perform mass and energy balances on this single discretized section and connect them together as a system of linear equations

Assumptions

•    The flow in each regional slice (for both the shell and tube portions of the exchanger) can be assumed to be well-mixed. This is imperative for us to perform mass and energy balances on each region fairly and accurately. As a word of caution this is not generally true and is somewhat case- specific, but if we make our slices sufficiently small this should be a valid assumption (can you think why?). This allows us to assume two more important things:

1.    We  can  ignore  changes  in  radial  dimension. In  other words,  for  a  given  slice  of the membrane, the temperature and concentrations of the species at hand do not change the farther we get from the centre of the tube.

2.    We can ignore axial diffusion (as in, diffusion along the length of the membrane) and focus only on radial diffusion (through the membrane wall toward the sweep gas).

•    We will assume constant heat capacity to make the computations easier.

•    The system is operating at steady-state.

•    Our natural gas consists of only CH4 and CO2. In reality, there is a bunch of other stuff in there, but we will ignore that for now and focus on the two things we care about.

•    CO2  is the only thing that diffuses through the membrane. Again, this is to make our lives easier. Membranes are never truly 100% selective, but some can be very good.

•    We are operating strictly in the gas phase. No phase changes makes everything easier.

•    The flow rates of natural gas (in the tube) and steam (in the shell) are constant. This is because we are only assuming CO2 diffuses through the membrane, and it makes our mass balances easier.

With these assumptions we can safely say that one tube represents all tubes. This is good, because in reality there are likely to be a bank (or bundle) of tubes in a membrane, but according to our assumptions we can safely say each tube will behave the same way. Therefore, all we really need to do is develop a model for a single tube and we should be able to extend that to more tubes if needed.

The Model

We will break down a given tube of length L into N sections, such that ΔL = . As shown in Figure 2, each section will be called section i, with section 1 being on the left and the right-most as section N. Here it is important to note that the streams on the left of section i are labeled stream i, and the streams to the right are named i + 1. This is regardless of the direction of the stream. For example, the steam entering section i

in Figure 2 is called F1, and the gas stream leaving section i is F1(G) , even though they are moving in opposite directions.

Therefore, in total there are N membrane segments and each segment streams for both the shell and tube sides. Since FH(P)2O,i  and FCH4(NG),i  (the flows of water in the permeate and CH4  in the natural gas stream) are constant, each section of each side of the membrane contains two unknown variables.

OK, so that is fine and dandy. Remember that this is going to be a linear system, so at least the equations won’t get too wild. It just looks like a lot. The only two things we really need to worry about now are the linear approximations of flux across the membrane (Zi ) and the heat conducted across the membrane (Qi ):

Zi  = kA(F FCO(P)2,i+1)

Qi  = UA(Ti(N)G − T1)

where k is the diffusion coefficient, A is the surface area of membrane segment i, given by A = 2几r」L and U is the overall heat transfer coefficient from the tube surface to the permeate phase all of which are constant and known.

Note here that we have made another very important assumption: the bulk phase of each section i is described by the stream entering it. This means the shell side CO2 flow rate is a (constant) FC(P)O2,i+1 in section i, and the tube side CO2 flow rate is a constant FCO2(NG),i . The same goes for temperature. The temperature in the tube in section i is TiNG  and the temperature in the shell is Ti1 . This is not meant to confuse you or anything, it is just to make the math work. Math working is important.

Using our equations for flux and heat conduction, the mass and energy balances for a segment i are given to you on the next page.

Mass balances (mass in  = mass out)

H2O in the Permeate

Stream:

CH4  in the Natural Gas

Stream:

CO2  in the Permeate Stream:

FC(P)O2,i+1 + Zi  = FC(P)O2,i i = 1 … N

FC(P)O2,i+1 + kA(FCO2(NG),i FC(P)O2,i+1) = FC(P)O2,i


CO2  in the Natural Gas Stream:

FCO2(NG),i  = FCO2(NG),i+1 + Zi i = 1 … N

FCO2(NG) ,i = FCO2(NG),i+1 + kA(FCO2(NG),i FC(P)O2,i+1)

Energy balances (energy in  = energy out)

HH(P)2O,i+1 + HC(P)O2,i+1 + Qi + HZ,i = HH(P)2O,i + HC(P)O2,i

HCH4(NG),i + HCO2(NG),i = HCH4(NG),i+1 + HCO2(NG),i+1 + Qi + HZ,i

Where Cp is a constant heat capacity and:

Hc(s),i  = Fi Cpc Tis

HZ,i  = Zi CpCO2TiNG  (Enthalpy for the diffusing stream)

Where that creepy curly s represents general stream names and the equally strange c represents a chemical component of interest (like CO2  or CH4). For this problem, we have the following membrane and stream characteristics:

•    Tube Dimensions                                                     •     Natural gas input at 55°C

o  2.0 m in diameter                                                     o  14 kmol/min of CO2

o  23 m in length                                                          o  94 kmol/min of CH4

•     Membrane Properties                                              •    Steam input of 115 kmol/min at 230°C.

o  U =  54 kJ/(K-m2 -min)                                       Note that this is the PURE permeate

o  k  =  0.033 m-2                                                                                 stream (FN(P)G,N+1  = 0)

•     Heat capacities (Cp) in kJ/(kmol-K)

o  CO2           39.4

o  H2O       32.2

o  CH4            34.8

Provided Companion Codes

If you’ve made it this far, you have my respect! As such, I’m going to give you some good news. In the file companion for this mastery problem, there are two companion codes that set up the mass and energy balances for you (you’re welcome!). These are given to you as protected files. You cannot open them, but you  may  use them  as  any typical function  in MATLAB by  simply  calling them  as  normal  in your main/driver files. Here is what they do:

•     [Am, bm] = massbalances_protected (N).p – The user inputs N (the number of discretized segments for the membrane), and the function returns  Am and bm. These are the matrix AM  and vector bM  required to SOLVE the mass balances for this membrane in the form AMxM  = bM . The solution vector xM will be in the order [FC(P)O2,1 , … , FC(P)O2,N+1 , FCO2(NG),1 , … , FCO2(NG),N+1]T .

•     [Ae, be] = energybalances_protected (N,xm).p – The user inputs N (the number of discretized segments for the membrane) and xM  (the SOLUTION to the mass balances), and the function returns Ae and be. These are the matrix AE  and vector bE  required to SOLVE the energy balances for this membrane in the form AE xE  = bE . The solution vector xE  will be in the order [T1(P) , … , TN(P)+1 , T1(NG) , … , TN(N)1]T .

Provided these two files are in your working directory, you should be able to copy/paste run the following script to solve the system for N = 50 segments. You can then go ahead and make a plot of the CO2  flow rates and temperatures along the length of the membrane.

% Obtain mass balance matrices

[Am, bm]  = massbalances_protected(N);

% Solve for the mass flows

xm = Am\bm;

% Obtain energy balance matrices

[Ae, be] = energybalances_protected(N,xm);

% Solve for temperatures

xe = Ae\be;

Objectives

Using the information presented as above and the two provided MATLAB files, you are to:

1.    Solve the membrane mass and energy balances for a variety of discretization levels N.

2.    Determine the number of segments that provides accurate results while balancing model efficiency.

3.    Code and implement the Gauss Seidel method to solve the membrane mass and energy balances.

4.    Explore how different initial guesses can improve Gauss Seidel convergence times.

Deliverables

You are to submit a code package containing a driver code, the provided mass and energy balance functions, and a function called GS that performs