# Dynamic Modeling of Transport Process Systems

### Summary

This book presents a methodology for the development and computer implementation of dynamic models for transport process systems. Rather than developing the general equations of transport phenomena, it develops the equations required specifically for each new example application. These equations are generally of two types: ordinary differential equations (ODEs) and partial differential equations (PDEs) for which time is an independent variable. The computer-based methodology presented is general purpose and can be applied to most applications requiring the numerical integration of initial-value ODEs/PDEs. A set of approximately two hundred applications of ODEs and PDEs developed by the authors are listed in Appendix 8.

## Book Preview

### Dynamic Modeling of Transport Process Systems - C. A. Silebi

book.

*Preface *

*Preface*

**C.A. Silebi, ***Lehigh University *

**W.E. Schiesser, ***Lehigh University and SSC Laboratory ² *

In 1979, Lehigh’s Department of Chemical Engineering offered for the first time a second-semester junior course in the dynamic modeling and simulation of transport process systems: systems in which the transfer of mass, momentum, and energy takes place, possibly with chemical reaction. It was our feeling at the time, and still is, that the dynamic analysis of transport process systems is an essential aspect of the Lehigh undergraduate program. We detail at the beginning of **Chapter 1 why we consider dynamic modeling to be fundamental, so we will not elaborate on this matter here. Instead we simply point out that realistic transport process systems do not operate in the idealistic world of the steady state for which the inputs and outputs are always in balance. Rather, because of the requirement to change the operating conditions intentionally, for example in batch processes, or because of the unexpected disturbances and changes that inevitably occur, the state of transport systems will change with time, and we must be able to analyze this situation. That is the intent of this book, to present a methodology for the development and computer implementation of dynamic models for transport process systems. **

Also, in this book we do not develop the general equations of transport phenomena, that is, the equations of change,

since this has been done in several other places, starting with the classic book by Bird, Stewart, and Lightfoot.**¹ Rather, we develop the equations required specifically for each new example application. These equations are generally two types: ordinary differential equations (ODEs) and partial differential equations (PDEs) for which time is an independent variable. **

The junior course has been given each year since 1979, and much of the material in this book, particularly the applications, is an outgrowth of this course. We thank, in particular, the many students who patiently worked through the many problems we assigned. This course has always been something of an educational experiment and challenge in the sense of teaching not only the engineering aspects of the unsteady state, including a brief introduction to automatic control, but also the basics of numerical analysis for ODEs and PDEs and the computer implementation of the numerical analysis. In other words, there is a substantial amount of material to cover in several disciplines. Our students have generally been quite willing to study, and attempt to learn, all of this material in one short semester. We thank them for their interest and patience.

The computer-based methodology we present is general purpose and can, at least in principle, be applied to most applications requiring the numerical integration of initial-value ODEs/PDEs; in fact it has been used for studies in fields ranging from agricultural engineering to zoology. Some indication of the generality of the methods is suggested by the glucose tolerance test example in **Chapter 6, an ODE application in physiology (biomedicine, mathematical biology), and the river pollution model in Chapter 8, a PDE application in environmental systems (ecology). We hope that analysts and researchers outside the field of chemical engineering will find the book interesting and useful in bringing to their attention computer-based methods for dynamic simulation that can be used effectively in their fields. Certainly, the underlying mathematics of ODEs/PDEs does not belong to any particular field; mathematics is the language of science and engineering and only the applications are specific to various fields. **

The literature in dynamic modeling has developed rapidly during the past 20 years, and a detailed discussion of the many applications that have been reported could not be accommodated in one book of reasonable length, so we have not even attempted to survey what has been done. Rather, we hope to provide the reader with enough background and motivation to facilitate further reading of the literature. The software discussed in the book is available from the authors as source code on diskettes so that the reader can run any of the applications in the book using only a Fortran 77 compiler, which is probably the best way to fully understand the basic concepts discussed in the book, particularly with regard to the organization and use of the software. Also, a set of some 200 applications of ODEs and PDEs developed by the authors is listed in **Appendix 8. All of these applications are available on diskettes as documented Fortran 77 subroutines. **

During the past 20 years, many people have contributed to the development of dynamic modeling and the numerical methods for ODEs/PDEs discussed in this book. We have had the privilege of knowing and working with the following people: Shaul Abramovich, Fernando Aguirre, Ken Anselmo, Page Buckley, George Byrne, Ruben Carcagno, Mike Carver, Kathy Chen, Richard Chen, Mark Davis, Jonathan Demko, Glen Dissinger, Bruce Finlayson, Bengt Fornberg, Grant Fox, Roger Franks, Bill Gear, Alan Hindmarsh, Sam Hu, Mac Hyman, Stan Johnson, David Kahaner, Walter Karplus, Leon Lapidus, Stanley Lee, Werner Liniger, Al Loeb, Bill Luyben, Neil Madsen, Mike McAshan, Eduardo Meyer, Joe Palen, Linda Petzold, Carl Pirkle, Everett Pitcher, John Rice, Gerry Saidel, Roger Sargent, Bob Seader, John Seinfeld, Larry Shampine, Jeng Shih, Harvey Stenger, Gilbert Stengle, Warren Stewart, Orhan Tarhan, Skip Thompson, Buddy Watts, Albert Wilansky, Ralph Willoughby, Adnan Yurcel, Jim Zaiser, and Matt Zellner. In particular, we wish to acknowledge the contributions of the following people: Mike Carver for the five-point biased upwind approximations, Richard Chen for the orthogonal collocation routines discussed in **Chapter 8, Alan Hindmarsh for the ODEPACK integrators (LSODE, LSODES, LSODI), Linda Petzold for DASSL, Carl Pirkle for the two-dimensional reactor model discussed in Chapter 8, Larry Shampine and Buddy Watts for RKF45, Gilbert Stengle for assistance in deriving the second-derivative formulas discussed in Section 8.2, and Aimee Squires for helpful suggestions and careful editing. Our intention is to appropriately acknowledge the contributors to this book, and we extend sincere apologies for any oversights. Finally, we welcome comments from the readers and users of this book. **

**²The SSC Laboratory is operated by the Universities Research Association, Inc., for the U.S. Department of Energy under Contract No. DE-AC02-89ER40486. **

**¹Bird, R. B., Stewart, W. E., and Lightfoot, E. N. (1960). Transport Phenomena. John Wiley and Sons, Inc., New York. **

### 1

*The Nature of Dynamic Systems *

*The Nature of Dynamic Systems*

In the analysis of transport process systems, systems in which the transport or transfer of mass, momentum, and energy takes place, the assumption of steady-state operation is commonplace. Specifically, the assumption is made that the input and output flows are exactly balanced so that the internal state variables that describe the system, for example, concentration or temperature, do not change with time. Mathematically, this steady-state condition is expressed simply as

**(1.1) **

where input

and output

denote the rates at which the principal streams flow into and out of the system, respectively, for example, flows of energy and material.

The exact balance of inputs and outputs expressed by **eq. (1.1) represents an idealized situation, however, which is rarely realized in practice; more typically an imbalance between inputs and outputs occurs due to, for example, a disturbance that enters through the inputs. Thus, for this situation, eq. (1.1) must be generalized to **

**(1.2) **

**Equation (1.2), although quite simple in appearance, serves as the basis for most of the models and associated computer simulations that we will consider in the remainder of this book. **

Two special cases of **eq. (1.2) can be considered: **

for which *accumulation *will take place within the system since input exceeds output (consider a tank with liquid inlet and outlet lines for which the inlet flow exceeds the outlet flow so liquid accumulates within the tank), and

for which *depletion *will take place within the system since the output exceeds the input (again, the tank with liquid inlet and outlet streams would have a decreasing liquid level). Thus we can interpret depletion as negative accumulation (from the second case).

*1.1 The Origin of Differential Equations *

*1.1 The Origin of Differential Equations*

As a specific example of the application of **eq. (1.2), consider the holding tank in Figure 1.1. If we apply eq. (1.2) to this tank, the input and output flow rates are simply Q0 and Q, respectively, which typically would have the units of cm³/sec. The first thing we notice from this example is that the variables usually involve time, for example, the preceding flow rates. Although this also occurs in steady-state analysis, the next term we will consider in eq. (1.2) involves time in a way that is not encountered in steady-state analysis. The accumulation term is dV/dt, that is, the time rate of change of the volume of liquid in the tank, which also has the typical units of cm³/sec. **

**Fig. 1.1 **Dynamics of a holding tank.

Thus **eq. (1.2) applied to the holding tank becomes **

**(1.3) **

**Equation (1.3) really results from a mass balance, for which we have assumed that the liquid density is constant (generally a good assumption for liquids). If this could not be assumed, eq. (1.3) would be written as **

Note that for constant density (*ρ *= *ρ*0), *ρ *cancels to give **eq. (1.3). **

**Equation (1.3) is an example of the mathematical equations we will be considering throughout this book, that is, differential equations that are in contrast to the algebraic equations that are typically used in steady-state analysis. Technically, eq. (1.3) is a first order ordinary differential equation (ODE). It is first order because the highest order derivative in the equation is first order, and it is an ordinary differential equation since it has only one independent variable, t (and as a consequence, the derivative, dV/dt, is a total derivative). **

*1.2 Well-Posed Problems *

*1.2 Well-Posed Problems*

We might at this point consider solving **eq. (1.3). The first question that naturally arises is, what do we mean by a solution? Generally the answer is, the dependent variable as a function of the independent variable, in this case V(t). However, before we obtain this solution we must attend to some details to insure that the problem is well-posed, that is, that all of the mathematical details have been properly stated. **

The first thing we note about **eq. (1.3) is that it has three variables that could conceivably be functions of time, V(t), Q0(t) and Q(t). In effect we have three unknowns and one equation, so that two more mathematical relationships are required. For example, if we assume that the outlet line has a valve that regulates the flow, we can use a typical valve equation, which for gravity flow can be written as **

**(1.4) **

where *Cv *is a constant for a particular valve, and *h *is the height of liquid in the tank. The problem with **eq. (1.4) is that if we substitute it in eq. (1.3) we have introduced another unknown, h, so that we still have three unknowns, V(t), Q0(t), and h(t). However, we also recognize that V = Ah, where A is the tank cross-sectional area (assumed constant), and therefore substitution in eq. (1.3) gives **

**(1.5) **

We have intentionally not combined **eqs. (1.4) and (1.5) since, in general, as the mathematical models (sets of equations) for transport process systems become more complicated, we will find that systems of equations are more convenient to use in computing solutions. **

Finally, we will assume that the entering flow rate, *Q*0, is a known function of time, for example, a given constant. Thus all three variables in **eqs. (1.4) and (1.5) are now defined mathematically, and we might therefore expect that we can obtain a solution, in this case h(t) [remember again that we mean by a solution the dependent variable of the differential equation as a function of the independent variable, or h(t)]. However, there is one other detail we must consider before we have a well-posed problem. We must specify a starting value or point for the solution, which is called an initial condition: **

**(1.6) **

where *h*0 is a given constant at *t *= 0. The initial condition could be stated more generally as

where the initial time is now *t*0, but usually we will take *t*0 = 0.

**Equations (1.4), (1.5), and (1.6) now constitute the mathematical model for the holding tank of Fig. 1.1, and we can proceed to a solution. Although we have developed this model in possibly excessive detail, the steps will be applicable to all models and are summarized here: **

1. A set of equations is written based on a set of assumptions (e.g., constant density) and a selection of conservation principles (e.g., conservation of mass).

2. As the equations are written, the units of each term in a given equation are checked to insure that they are the same as for all other terms in the same equation (cm³/sec).

3. The number of unknowns is computed, and if there is not a corresponding number of equations, more equations must be added to bring the total up to the number of unknowns [**eq. (1.4) and V = Ah] **

4. An initial condition must be specified for each time derivative in a set of first order ordinary differential equations [*h*(0) = *h*0 for *dh*/*dt*].

Finally, one other characteristic of the model for the holding tank, **eqs. (1.4), (1.5), and (1.6), should be noted. Equation (1.4) is algebraic while eq. (1.5) is an ODE. This is a combination of equation types frequently encountered in the dynamic analysis of transport process systems, that is, combinations of differential and algebraic equations (DAEs). In fact, the computer solution of DAEs has been studied extensively, and software for the solution of this problem is now well developed; we will later present a methodology for the solution of DAE problems. **

*1.3 Analytical and Numerical Solutions *

*1.3 Analytical and Numerical Solutions*

We now consider the solution of **eqs. (1.4) to (1.6). Recall again that a solution is essentially a function, h(t), that satisfies eqs. (1.4) and (1.5) subject to the initial condition, eq. (1.6), and, when plotted, will look something like Fig. 1.2. **

**Fig. 1.2 **The solution of **eqs. (1.4) to (1.6). **

The solution can, in principle, have either of two forms: (a) an *analytical solution *or (b) a *numerical solution*. An analytical solution is a closed form function that identically satisfies an ODE and its initial condition. A numerical solution is, as the name implies, a set of numerical values of the ODE dependent variable [*h*(*t*)] as a function of the independent variable (*t*), starting at the initial condition (*h*0). We will first derive the analytical solution to **eqs. (1.4) to (1.6). **

**Equation (1.5) can be written as **

**(1.7) **

where *a *= *Q*0/*A, b *= − *Cv*/*A *(*Q*0 will now be taken as a constant). Many first order ODEs such as **eq. (1.7) can be integrated analytically by several basic methods from calculus, for example, by separation of variables or by an integrating factor; we choose separation of variables. A straightforward rearrangement of eq. (1.7), followed by integration, gives **

**(1.8) **

, for which the resulting integral in *x *is available from a table of integrals. The final result (after changing back from *x *to *h*) is

### (1.9)

**Equation (1.9) is the analytical or exact solution to eq. (1.7) subject to initial condition (1.6). In general, to confirm that a solution to an ODE problem is correct, it must satisfy both the ODE and the initial condition, Applying these criteria to eq. (1.9), clearly with t = 0, h = h0, both sides of eq. (1.9) are zero, that is, it satisfies the initial condition, eq. (1.6). Substitution of eq. (1.9) into eq. (1.7) also confirms that it is a solution to the ODE (this is left as an excercise for the reader). **

The derivation of an exact solution is a satisfying experience in the sense that once done, there is no question of the validity of the result; that is, it is a self-contained (closed form) exact solution. Unfortunately, for most realistic transport process problems, the derivation of an analytical solution can rarely be accomplished. Also, even when an analytical solution such as **eq. (1.9) can be derived, it is often difficult to use in the sense of computing from the solution the dependent variable [ h(t)] versus the independent variable (t) for further observation and understanding (typically, for plotting the solution as in Fig. 1.2). We shall now consider why these conditions are generally true. **

The derivation of **eq. (1.9) naturally leads to the question, how difficult would be the derivation of a solution to two simultaneous ODEs such as eq. (1.7)? The answer is, essentially impossible! This may seem like a surprising conclusion, but, in fact, methods for generally solving two or more simultaneous, first order ODEs are not available (i.e., we do not know how to solve such problems). There is one important special case for which this is not so (when we can, in fact, obtain solutions to two or more simultaneous ODEs), as explained by the following example ODEs. **

**Equation (1.7) has an important characteristic that should be appreciated in order to understand how difficult an ODE (or two or more ODEs) is to integrate analytically; it is nonlinear. This property arises from the √h term. In general, if an ODE contains one or more terms in which the dependent variable, or its derivative(s), multiply each other or are raised to other than the first power, the equation is nonlinear, and therefore difficult to integrate analytically. When this condition occurs in systems of simultaneous ODEs, generally the derivation of an analytical solution is essentially impossible. **

To illustrate this distinction further, the following equations are linear (note that the dependent variable *y *appears to only the first power):

while the following equations are nonlinear (note that the dependent variable *y *appears to powers other than one, including possibly derivatives):

In general, we can analytically integrate a *few linear *ODEs (say up to four linear ODEs) in the same sense we can solve linear algebraic equations by matrix methods. Unfortunately the ODEs that describe transport process systems will generally be nonlinear, for example, **eq. (1.7), and therefore difficult, if not impossible, to integrate analytically. **

A second reason why ODEs are difficult to integrate analytically is the number of such equations normally encountered in analyzing a realistic problem. You may have had some experience with this difficulty in calculus when obtaining the solution to simultaneous linear ODEs. Generally one linear equation is easy to integrate. Two equations are a bit more challenging. Three equations are rather demanding (you may recall having to solve a system of three algebraic equations in the process of obtaining the solution to the three ODEs). Four ODEs are very tedious, and five equations are essentially out of the question. Recall also that we are talking about linear equations. Two or more nonlinear ODEs would be essentially impossible.

What is the point of this discussion? As we shall soon see in subsequent chapters of this book, the analysis of transport process systems of modest complexity can easily lead to a system of five ODEs, which will generally be nonlinear. As we get to more sophisticated transport process systems, 10 to 100 ODEs are not unusual. In fact, systems of 100 to 1000 ODEs are now commonplace, and 10,000 to 100,000 nonlinear ODEs are now being considered!

You could naturally ask, isn’t this an impossible situation since, as the preceding discussion indicates, we can’t obtain solutions to such systems of ODEs? This is true if we are talking about analytical solutions. Fortunately we have another approach that will, in theory, produce solutions to ODEs of *essentially any number and nonlinearity*, that is, *numerical solutions generated with a computer*. Thus the methodology we shall adopt for use in the remainder of this book is *numerical integration*. As the name implies, the solutions will not be exact in the sense of analytical solutions, but we will develop methods to insure that the numerical solutions are of sufficient accuracy for engineering purposes (typically with no more than 0.1% error, although this error can, in principle, be reduced to any level by doing more computing). The numerical procedures, generally termed *numerical integration algorithms*, will be considered in **Chapter 2. **

One other point should be mentioned about analytical solutions. Since they are exact (satisfy the ODE and its initial condition identically), they can be used as a standard for judging the accuracy of numerical solutions. In other words, numerical integration is approximate and always produces some error. By numerically integrating ODEs with known analytical solutions, the accuracy of the numerical algorithm can be judged by comparing the numerical solutions with the known analytical solutions. Not only is this procedure useful in validating a newly developed numerical integration algorithm, but it can also be invaluable in checking the programming of a new algorithm to insure that the equations of the algorithm are correctly implemented in a computer code.

There is, however, one possible complication in using an analytical solution to evaluate numerical procedures: the calculation of the dependent variable from the analytical solution for a given value of the independent variable may be difficult. This problem is illustrated by **eq. (1.9). The calculation of h for a given value of t requires the solution of a nonlinear, transcendental (nonalgebraic) equation and will require the use of a root-finding algorithm such as Newton’s method. The obvious alternative, in the case of eq. (1.9), is to calculate t for a given h, but, in general, this inverse procedure is not any easier in using an analytic solution. **

*1.4 Qualitative Characteristics of Solutions *

*1.4 Qualitative Characteristics of Solutions*

The preceding discussion of the analytical solution of ODEs indicated that the derivation of analytical solutions is relatively difficult and quickly becomes impossible as the number and nonlinearity of the ODEs increase. However, we can often obtain useful information about the characteristics of the solution to ODEs *without actually deriving the solution*.

These characteristics are typically qualitative (they concern the general features of the solution and not the quantitative details). For example, referring to **Fig. 1.2, which is a plot of eq. (1.9) for specific values of Q0, h0, A, and Cv for large times (t → ∞), the solution approaches a steady state (does not change with additional time); the corresponding mathematical condition in the case of eq. (1.5) or (1.7) is dh/dt → 0. We might then ask what is the final value of h for t → ∞? This question is easily answered. From eq. (1.7), **

or

**(1.10) **

which is the final, steady-state value of *h *(= *h*(*t *→ ∞) = *h*(∞)). If *a *+ *b√h *= 0 is substituted in **eq. (1.9), it is easily shown that t = ∞, as expected (recall that ln(0) = −∞). **

Since *Q*0 has the units of *L*³/*t *(e.g., cm³/sec) and *Cv *the units *L*³/*t *– *L*¹/² (cm³/sec-cm¹/²), *h *given by **eq. (1.10) has the units of L (cm) as expected. Note also that h given by eq. (1.10) does not depend on the holding tank cross-sectional area, A. In other words, the steady-state liquid height, hequals the inlet flow rate (Q0). This example illustrates that some model parameters affect only the dynamic characteristics of a problem system; generally they appear in the temporal derivatives of the model (A in A dh/dt), and when the temporal derivatives are zero at steady state these parameters have no effect on the steady-state behavior of the system. **

In general, the solution to a system of ODEs will approach a steady state unless the system is unstable (models an unstable physical system). The procedure for computing the steady-state solution is the same as for the preceding example of a single ODE; all of the time (temporal) derivatives are set to zero, which is the mathematical condition for the steady state, and the resulting system of algebraic (or transcendental) equations is solved for the steady-state values of the dependent variables. Incidentally, these are the values of the dependent variables that just balance the input and output