14
Chapter 10 Computer-Aided Balance Calculations Degree-of-Freedom Analysis For a process to be “properly specified” means that all variables throughou process can be calculated using the information provided. Variables include all material stream properties (e.g., total flow rate, com temperature and pressure), all energy stream duties, and all special unit characteristics (e.g., adiabatic efficiencies of compressors, extents of re chemical reactors, tray efficiencies and heat losses for distillation tower The variables that are given values up front are called design variables , whereas, those calculated from the process relations are called state variables . t is generally assumed that you can assign any value you want to a design variab independent of the values assigned to the other design variables. The number of degrees of freedom (n df ) is e!ual to the number of un"nown variables minus the number of independent e!uations that can be used to sol them. f n df # $ the process is properly specified (caution % see note below). f n df > $ the process is under specified, and this number of state vari must be specified, thus turning them into design variables. f n df < $, the process is over specified, and this number of design var must be allowed to become state variables. &ote' ou cannot violate any of the e!uations by the values you assign to design variables Thus, some sets of variables do not ma"e a good set of variables, as the e!uations prevent you from assigning values to each independently (cf., *xample +$.+ +, p. -$- ). Euationscan include material balances, energy balances, e!uations of state phase e!uilibrium relations (e.g., thermal e!uilibrium, mechanical e!uilib /aoult0s law), reversible adiabatic compression e!uations, chemical e!uili e!uations, component split relationships, component recovery e!uations, component conversion e!uations, sum of mole or mass fractions e!ual unity, !ndependent euations are a set of e!uations for which none can be derived by algebraic combinations of the others. For example, if & components are inv for a unit, then & independent material balances can be written (one for ea component), but a material balance for total mass can not be added to this since it can be derived by adding all the component balances.

Numerical Methods

Embed Size (px)

DESCRIPTION

Numerical Methods (Computer-Aided Balance Calculations) Bisection Method, Newton-Raphson Method...

Citation preview

Chapter 10 Computer-Aided Balance Calculations

Chapter 10 Computer-Aided Balance Calculations

Degree-of-Freedom Analysis

For a process to be properly specified means that all variables throughout the process can be calculated using the information provided.

Variables include all material stream properties (e.g., total flow rate, composition, temperature and pressure), all energy stream duties, and all special unit characteristics (e.g., adiabatic efficiencies of compressors, extents of reaction for chemical reactors, tray efficiencies and heat losses for distillation towers, etc.).

The variables that are given values up front are called design variables, whereas, those calculated from the process relations are called state variables. It is generally assumed that you can assign any value you want to a design variable, independent of the values assigned to the other design variables.

The number of degrees of freedom (ndf) is equal to the number of unknown variables minus the number of independent equations that can be used to solve for them.

If ndf = 0 the process is properly specified (caution see note below).

If ndf ( 0 the process is under specified, and this number of state variables must be specified, thus turning them into design variables.

If ndf ( 0, the process is over specified, and this number of design variables must be allowed to become state variables.

Note: You cannot violate any of the equations by the values you assign to the design variables! Thus, some sets of variables do not make a good set of design variables, as the equations prevent you from assigning values to each independently (cf., Example 10.1-1, p. 505-7).

Equations can include material balances, energy balances, equations of state, phase equilibrium relations (e.g., thermal equilibrium, mechanical equilibrium, Raoults law), reversible-adiabatic compression equations, chemical equilibrium equations, component split relationships, component recovery equations, component conversion equations, sum of mole or mass fractions equal unity, etc.

Independent equations are a set of equations for which none can be derived by algebraic combinations of the others. For example, if N components are involved for a unit, then N independent material balances can be written (one for each component), but a material balance for total mass can not be added to this set, since it can be derived by adding all the component balances.

Example Problem

Perform a degree of freedom analysis for a flash separation unit with two components. There are three streams, with N+2 variables per stream (T, P, n, x), and the duty for the flash unit, for a total of 13 variables. There are 7 equations that can be written (2MB, 1EB, 4PhaseEqlm). Thus, there are 6 design variables that must be given, or there must be a total of 6 design variables and other independent equations given. The number of state variables will be 7. A typical set of design variables might be the 4 properties of the feed stream plus the T and P for the flash unit.

Balance Calculations on a Spreadsheet (Excel)Make sure the Drawing Toolbar is selected (under the menu Tools/Customize/Toolbars). You will see this toolbar at the bottom of the Excel worksheet.

Spreadsheet Construction Procedure:

1. Draw boxes on the spreadsheet for the process units.

2. Draw arrows for the streams (material and energy).

3. Name all streams and process units.

4. List total flow, temperature, pressure, and components for all material streams, leaving cells for values (component flows or fractional compositions) and units.

5. Put all known information on the flowchart, making sure each bit is clearly identified.

6. Perform a degree-of-freedom analysis to make sure the process is properly specified.

7. Write out all equations involving the unknown variables and decide on a procedure for solution. Construction of a procedural flowchart is recommended for complex processes.

8. Program blank cells on the spreadsheet to calculate the unknown variables.

Example Problem: Discuss Problem 9.16 or 9.17 as an Excel spreadsheet problem. This is done as a hands-on demo in the computer lab.

Procedural Flowcharts

Calculation procedures are often represented on a block diagram, such as found on p. 507. These diagrams are procedural flowcharts, often just called flowcharts. We will use the full name to avoid confusion with our process flowcharts.

How is a block diagram like this prepared in Word or Excel?

1. Draw boxes and arrows (there are Flowchart shapes under AutoShapes on the Drawing Toolbar).

2. Fill in the boxes with text.

Example Problem: See Example 10.1-1 on p. 505 in the text.

Example: A procedural flowchart is given below for Problem 9.16 in the text.

The calculations as indicated in the above example are sequential. This is not always the case, and decision blocks must be used for iterative procedures.

Decision blocks are generally drawn as indicated below. A question is placed in the box. The path followed from this box will depend on whether the answer is Yes or No.

Notice how this is used in the diagram on p. 507. In Problem 10.7b, produce a block diagram for the required subroutine, rather than an actual program.

Solving Algebraic Equations

Solutions to single algebraic equations can be accomplished by using Goal Seek or Solver in Excel, or by a variety of other methods.

Solutions to set of equations are best accomplished using special equation-solving software, such as E-Z Solve, which is on the disk that came with the text, or by sophisticated software packages like MathCad, MatLab, etc.

Solution of Linear Algebraic Equations

A general set of linear algebraic equation can be written using summations, or in matrix notation, as indicated here.

Common Problems

Singular a set of equations that is degenerate

Row degeneracy one (or more) of the equations is a linear combination of the others

Column degeneracy all equations contain the variables in the same linear combinations

Other problems no solution or an incorrect solution

Near singular round-off errors render them linearly dependent at some stage of the solution process the solution fails

Big round-off errors accumulated round-off errors swamp the true solution can occur if the number of equations is large happens most frequently when near singular solution does not fail but gives incorrect result

Tasks

Solve the matrix equation A(x = b for the N-dimensional vector of unknowns x, where A is a square matrix of coefficients (NxN) and b is an N-dimensional known vector.

Find the inverse matrix A-1, so that x = A-1b.

Methods

Gauss-Jordan elimination stable, traditional method

Set up the A matrix of coefficients, augmented by the b vector, and reduce so as to produce an augmented identity matrix, which yields the solution by inspection.

The same manipulations on the identity matrix will yield the inverse A-1.

There are other matrix-inversion methods that are used for special types of problems. They will not be discussed here.

Example:

for which the solution is .

The A matrix augmented by the b vector, written beside the identity matrix gives the following:

The goal is to make the A matrix into an identity matrix, i.e., one with 1s on the diagonal and 0s elsewhere.

Divide the first row by 2 (to make a11 = 1):

Multiply the first row by 5 and subtract from second row (to make a21 =0):

Divide the second row by 21/2 (to make a22 = 1):

Multiply second row by 3/2 and subtract from first row (to make a12 = 0). This achieves the original goal:

By inspection, the first (augmented) matrix yields the solution :

The second matrix is the inverse matrix, which can be verified by multiplying it by the original A matrix to yield the identity matrix

(A-1A=I).

Roots of Nonlinear Equations (Single Equations or Systems of Equations)

Use iterative techniques, which always depend strongly on the initial guess. Use analysis to help with the initial guesses. Single nonlinear equations can be easily solved on an Excel spreadsheet using Solver.

For systems of nonlinear equations, solutions are usually accomplished by use of special equation-solving software, such as E-Z Solve (on the text CD), or by software like MathCad, MatLab, etc.

Example: Do an Excel and MathCad tutorial in the computer lab, using as an example the solution of a nonlinear equation (10x + x5 = 7) , first by using Solver in Excel, then by employing a Solve Block with the Find function in MathCad.

Method of Bisections and Regula-Falsi

For a one-dimensional problem f(x) = 0, a bisection method will work, although it is a slow process. If the root is initially bracketed in the interval (a,b), then it is evaluated at the midpoint x, and then it will be bracketed by either (a,x) or (x,b), a bracket half the size of the original one. This process is repeated until the desired accuracy is achieved.

For Regula-falsi, calculate the new x as follows, rather than use the mid-point:

This puts the new x on the straight line connecting the two bracketing points x(a),f(a) and x(b),f(b).

Newton-Raphson Method (Newton Iteration Method)

This method is almost always much better than the methods described above for both one-dimensional and multidimensional problems, as it uses the derivative(s) to help locate the root(s).

A Taylor-series expansion is used, truncated after the linear term, and the function is forced to zero by setting the LHS to zero.

In essence, this method uses the slope to determine the next value of x, by ordinary trigonometry on a plot of f(x) vs. x. (See graphs on p. 614 in the text.)

If the derivative is not available analytically, then this method is modified to estimate it numerically. Otherwise, it is applied in exactly the same manner.

This is the default method that is used in Excel Solver: Tangent estimates, Forward derivatives, and Newton method. There are some more powerful methods available under Solver Options: Quadratic estimates, Central derivatives, and Conjugate method. Also, using Autoscaling helps when the numerical values of the function are very small.

For the multidimensional problem posed above, this becomes

Again, forcing the LHS to zero gives the iteration increments from the simultaneous solution of the following linear equations:

EMBED Equation.3

This is an example of where we need the solution of a set of simultaneous linear equations, i.e., a matrix inversion method. This is incorporated into any software capable of the solution of simultaneous nonlinear equations.

Successive SubstitutionSometimes we do not have an analytical expression for f(x), such as when a property of a recycle stream comes from a long series of process calculations involving a number of process units.

Rearrange the equation from f(x) = 0 to x = g(x) = f(x) + x. Then, successive substitution means that you just replace the old x value with the newly calculated one g(x) and repeat the cyclic calculations.

This is a terrible method, and you will often have great problems with convergence. Any good convergence block calculator will use a better convergence scheme method, like the Wegstein algorithm discussed below, or (even better) it will use a Newton iteration method where the derivatives are estimated by successive calculations of the function.

Wegstein Algorithm

This method uses successive substitution to get started, then uses a convergence scheme to make subsequent estimations of x from the calculated g(x). It is easy to implement on an Excel spreadsheet.

1. Choose an initial guess x(1) and calculate g(x(1)).

2. Use successive substitution and set x(2) = g(x(1)).

3. Calculate g(x(2)).

4. Calculate the following functions:

5. Let the new x value be

6. Check for convergence .

7. Repeat steps 4-6 until convergence criteria satisfied.

See Appendix A.2g, p. 617, for more details on this method.

Sequential Modular Process Simulation

Elements of Modular Simulation

Methods for process simulation:

1. sequential modular simulation

2. equation-based simulation

3. combined-method simulation

Most modern process simulators utilize the third method, but one has to understand the first two methods (individually) before the third method makes sense.

In sequential modular simulation the process flowchart is drawn using a series of standard (defined) process units: mixer, splitter, flash vaporization unit, distillation tower, conversion reactor, heater, heat exchanger, etc. These standard units are called blocks or modules or simulation units.

There is a computer program for each module that takes data you supply on input streams and calculates properties of output streams. These calculations then proceed from left to right, one unit at a time, until all unknown variables have been calculated.

If the basis for your process involves an output, rather than a feed, then the results of the calculation will have to be scaled.

If there is a cycle in the process, such as a recycle stream, then this sequential calculation scheme will not work. It is made to work by using an iterative method employing a convergence block, which will be discussed below.

There is nothing magic about the calculations performed in the background for each module. They involve solving the material balance equations, the energy balance equation, and any other standard relations that pertain to that particular unit.

In Example 10.2-1, p. 512, a simple mixer module is analyzed. The calculations for this module involve only material and energy balances.

In more complex modules, such as a flash unit, equilibrium relations have to be added, in addition to material and energy balances.

In Example 10.2-2, p. 514, a multi-unit process is set up as a sequential modular simulation problem. There are no cycles in this process.

Cyclic Systems and the Convergence Block

If the process includes recycle streams, then the sequential modular simulation described above will not work, because there are feed streams for some units whose properties depend on downstream units that have not been analyzed yet.

Thus, an iterative calculation is required, where the stream properties are assumed, the sequential modular calculations accomplished, and then the calculated properties for the recycle stream are compared with those assumed. If they agree within a prescribed tolerance, then the results are accepted. If they dont, then additional rounds of calculations must be done until there is convergence.

On the simulation flowchart, a fictitious unit is included in the recycle stream (or in some other stream within the recycle loop), which is called a convergence block or a recycle module. The stream chosen to contain the convergence block is called the tear stream, and the best stream to choose is the one with the fewest unknown variables. Initial guesses for the tear stream properties will have to be included with this convergence block.

The method of solution where the assumed values of the tear stream unknown variables are replaced in the next iteration by the calculated values is called successive substitution. If convergence is too slow using this approach, other, more-powerful convergence schemes can be used to provide new tear stream property estimates from those just calculated. The Wegstein method and Newtons method are the most common iteration techniques used to accelerate convergence.

Design Specifications

For sequential modular simulation as described above, it is assumed that the calculations are performed from left to right, i.e., that feed stream properties are known, and product stream properties are calculated for each unit.

It is often desirable to specify a property of an exit stream, for example by specifying a recovery of a certain component in a separations process, and calculate appropriate process conditions or feed stream properties.

This can be done by using what are called design specifications. A loop is created in the cycle of calculations relative to an output property for which a specification is desired. The convergence block (or Adjust Module) is used to adjust the variable that would normally be the design variable, until the calculated output variable is equal to its specified value.

You will see design specifications used explicitly in the simulation package we are using at WSU (HYSYS) for complex processes, like distillation towers, where iterative calculations are always required, and convergence must be handled very carefully.

Equation-Based Simulation of Chemical Processes

This method involves collecting all the equations for all units in the process and solving them simultaneously for the unknown process variables.

This method is easy to visualize and implement on a computer, but it becomes a daunting challenge for the engineer trying to simulate a complex chemical process. This is because the degree of freedom analysis becomes exceedingly complex, and there is no chance to attack the problem a piece at a time, as can be done in sequential modular simulation.

Thus, a compromise approach has been taken in the development of HYSYS and other simulation packages, where most of the elements of sequential modular simulation are retained, but equation-based simulation is used to analyze most individual process modules, thereby eliminating the need for many of the design specification convergence loops described above. In simple terms, any time an individual module is properly specified (by supplying the proper number of variables), it will calculate, because it is done by equation-based simulation, independent of which variables have been supplied. There are exceptions to this general rule, as noted below.

Commercial Process Simulation Packages Introduction to HYSYS

Overview

HYSYS is the process simulation package available in our chemical engineering computing labs. It is not the most flexible simulation software available, nor is it the most commonly used package in industry, but it has the advantage of being user-friendly and easy for students to use as they learn the basics. HYSYS was developed for the petroleum industry, although it has been extended to handle some other types of chemical processes. Simulations are accomplished using menu-driven tools, with a graphical interface for construction of process flow diagrams (PFDs). Only the basic features will be discussed here.

Selection of Components

There are many library components, complete with full sets of component properties. Where possible, these components are located using the filters provided, added to a complete component list for the process, and used without modification in the simulations.

Difficulties can occur because 1) a fluid cannot be broken down into individual components, such as heavy petroleum fractions, or 2) the component is not in the software library. In either case, these difficulties can often be overcome by defining a pseudo-component, with a minimal set of basic properties specified by the user. A complete set of component properties will then be generated by the software. In these cases, the user must be vigilant to make sure these components are behaving properly in the simulation.

Fluid Property Packages

A fluid property package must be selected, which will be used to calculate properties of mixtures in streams (e.g., densities, enthalpies, etc.), and to calculate phase equilibria in streams and in separations units.

The simplest package assumes ideal gas behavior in the gas phase and ideal liquid solution behavior in the liquid phase. Thus, it used Raoults law for phase equilibrium calculations. This package in HYSYS is titled Antoine, because it used the Antoine equation for vapor pressures. Liquid mixture properties are calculated as component averages. This package matches up with the calculations you have been doing by hand in ChE 201.

For light hydrocarbon mixtures, equations of state like Peng-Robinson or Suave-Redlich-Kwong, or a corresponding states method like Lee-Kesler Plocker, are commonly used. These can be found through use of the EOS filter.

For components that form highly non-ideal liquid solutions (e.g., ethanol + water), a modified Raoults law must be used. These are called activity coefficient models, and they can be found under the filter Activity Models. Some examples are the NRTL and UNIQUAC models.

There are some other special properties packages in HYSYS, such as properties of water (including steam), and for electrolyte solutions.

Process Flow Diagrams (PFDs)The heart of a simulation is the development of a PFD for the process. This is done by selecting modules from the side toolbar and depositing them on the PFD. Then, all needed material and energy streams are placed on the PFD. Each unit is connected to the appropriate input and output streams. Streams and units are named and arranged on the PFD to provide an easily understood process diagram.

If the process calculations can be performed by left-to-right stepwise calculations, then the procedure is to start with the feed streams (on the left side of the PFD), putting in the specifications (values for the design variables), along with the known variables for the first unit encountered, until that unit is solved. Then, each module is made to work in a stepwise fashion from left to right across the diagram.

If there are recycle streams or specifications that cannot be handled by the calculational schemes in the software for individual units, then logical modules must be added to the PFD. These include modules like the Recycle Module, the Set Module and the Adjust Module.

Example: Solve the flash unit problem of Example 10.1-1, p. 505-7, with the design variables n1 = 100 mol/h, x1 = 0.500, T1 = 80 C, and x3 = 0.400. Select a Separator Module and place it on the PFD. Place input and exit streams and connect the unit to them. No energy stream is required, as this flash unit is to be adiabatic. In the Worksheet for the unit, put in the known feed stream conditions and composition, and the composition for the liquid product stream. The unit calculations should occur naturally.

Example: Solve the flash unit problem of Example 10.1-1, p. 505-7, with the design variables n2 = n3 = 50 mol/h, x2 = 0.4, and x3 = 0.2. When you enter these design variables into the Worksheet for the unit, the unit remained Not Solved. Since both the temperature and pressure are unknown, an Adjust Module must be used in HYSYS to handle this situation. The target variable will be the temperature in the feed stream, which will be the temperature of the flash unit, as there is zero duty for this adiabatic flash unit. Choose the adjusted variable to be the mole fraction of hexane in the vapor stream (leave this variable blank in the unit Worksheet). The target value must be specified for the adjusted variable, and the tolerance and number of iterations must be set in the Adjust Module. Then, put an initial guess into the unit Worksheet for the feed stream temperature, and the iterative calculations will proceed to the desired solution. Make sure the convergence tolerance and number of iterations are sufficient by putting both larger and smaller feed temperatures in, and making sure the same results are obtained to the desired accuracy.

Specify the percent excess air, percent conversion of SO2, and choose as a basis the molar flow of SO3 exiting the reactor.

Calculate the SO2 fed using the SO3 produced and the SO2 fractional conversion specification.

Calculate the SO2 out by a material balance on this species.

Calculate the O2 feed rate using the SO2 fed, the stoichiometry of the reaction, and the percent excess air specification..

Calculate the N2 feed rate as (79/21) times the O2 feed rate.

No

Yes

Is some relationship satisfied?

Calculate the O2 and N2 exit rates by material balances on these two components.

_1098248094.unknown

_1104760476.unknown

_1105182442.unknown

_1105354297.unknown

_1105354336.unknown

_1105351314.unknown

_1105354051.unknown

_1104760710.unknown

_1098248846.unknown

_1098249201.unknown

_1098249261.unknown

_1098248708.unknown

_1098173223.unknown

_1098174533.unknown

_1098183889.unknown

_1098173251.unknown

_1098172819.unknown

_1098173007.unknown

_1098173138.unknown

_1098172831.unknown

_1098171970.unknown

_1098172791.unknown