Additional comments on Process modeling material Ville Alopaeus, 26.11.2015 Formulation of balances Mathematical modeling should typically start by formulating appropriate balances. The basic form for balances is always ACCUMULATION = IN – OUT + GENERATION. The most typical balances are material, energy, and linear momentum balances. Material balance could be written for mass or moles. In chemical engineering, it is typically formulated separately for each chemical component and each phase. Energy balance is often separated in two parts: thermal energy balance (enthalpy) and mechanical energy balance. The former is typically needed in heat transfer problems, and the latter in fluid flow problems. Note that pressure drop correlations can be considered as mechanical energy balances (with some assumptions, such as time independent flow etc.). Linear momentum balances are not written very often, they are mainly used in Computational Fluid Dynamics (CFD). Very often mechanics related problems are solved by setting forces equal. This is actually a special case of linear momentum balance, since forces appear as source terms there. Linear momentum is mass times velocity, and time rate of change of linear momentum is mass times acceleration for constant mass systems, which has a unit of force (N). Other balances in chemical engineering are e.g. volume balance, entropy balance (e.g. for compressors), and population balances for size distributions of bubbles, drops and particles. Further important things that need to be considered already when the modeling work is started, is the time allowed for the modeling project, and the desired accuracy. If time is limited, the number of variables and model complexity must be kept at minimum. The model structure should also be simple if it needs to be solved rapidly, e.g. nonlinear partial differential equations need to be solved in such ways, where lots of additional variables (resulting from discretization discussed later) result in. If accuracy is of importance, then the model typically will be more complicated, and time required for model solution (numerical method implemented in a computer) is also longer. Control volume When writing balances, it is important to define control volume (boundaries) properly. The control volume could be e.g. a slice of a tubular reactor, single process unit (assumed homogeneous, i.e. fully mixed), a process plant or whatever part of space. The most important thing is to carefully consider inlet and outlet streams, whether the system is time dependent or assumed steady state, and what production of the modeled variable occurs within the control volume (e.g. reaction producing or consuming the component considered). Particular care should be taken to avoid mistakes in the sign conventions. Constitutive equations (rate laws) 1 Typically the most difficult part is finding the correct constitutive equations, or rate laws that are needed for the balances. These may include heat conduction, heat convection (advection), and radiation as the three possible heat transfer mechanisms. For mass transfer, the possible mechanisms are convection and diffusion. There are also lots of expressions for reaction rates, including detailed molecular level analysis of catalyst surfaces etc. Although the balances themselves are basically always correct (if all the terms are included), the constitutive equations often contain lots of parameters that need to be estimated or measured. For example diffusion coefficients, heat conductivity and other physical properties, or reaction kinetic model parameters. Some of them can be estimated or are tabulated in the literature, such as chemical component properties, but some of them must be experimentally determined, such as reaction kinetic parameters. If the resulting model is a differential equation (ordinary or partial), boundary conditions are needed to solve them. The number of boundary conditions needed depend on the order of the differential equation. Boundary conditions typically can be obtained from geometric or other reasoning. One of the most typical example of such is the film theory for mass transfer, where two boundary conditions are obtained for the diffusion equation, one at the boundary (for example phase interface), and the other for bulk phase. The model predicts that there is a finite distance (typically on the order of millimeter) between these two. This distance is called the film, and its thickness depends on the fluid flow far away from the interface. After integration, the model predicts mass transfer fluxes. Here is a comparison of differential form (one possible way of writing Fick's law), and its integrated form, where l is the film thickness, and c1 and c2 are the concentrations at the two ends of the film. Note that the notations may vary, so it is better to try to understand the phenomenon first, which would result in remembering, understanding, and being able to apply the equations. If you start by trying to remember, you will get lost due to different formulations and a huge number of equations telling basically the same thing. J D dc dx J Differential form (Fick's law) D c1 c 2 k c1 c 2 l Integrated form Inter-phase mass transfer is then a source term for material balances, "IN" for one phase, and "OUT" for the other. In addition to the diffusion flux, the convective part is needed if that is important (IN or OUT term due to fluid flow carrying the modeled component) Dimensionless numbers and correlations In practice, the film thickness for mass transfer, and many other parameters are not known. Mass transfer (as well as other rate laws) is typically written so that there is a response (diffusion flux) that depends on a proportionality coefficient (mass transfer coefficient) and driving force (composition difference) as shown earlier. Typically there are parameters that cannot be directly measured, but there are correlations from where these can be estimated. The correlations are typically formulated with dimensionless numbers. Perhaps the most well-known is the Reynolds number, which appears also in fluid dynamics. Correlations for mass transfer could be e.g. of the form 2 Sh 2 a Re m Sc n Where Sh is the Sherwood number (containing the unknown mass transfer coefficient), Re is the Reynolds number, and Sc is the Schmidt number. a, m and n are system (geometry) dependent parameters that are fitted so that the correlation represents measured mass transfer rates as well as possible. Solution of the model equations The solution method must be selected according to the final model type. One often encountered model type results in a set of algebraic equations. Examples of such result from time independent stirred tank reactor or stage-wise separation process model, such as distillation column. Another typical category is ordinary differential equations. These result e.g. from time independent tubular reactor or homogeneous batch reactor, or other plug flow models, such as mass transfer on a distillation tray where bubbles could be assumed to flow as plug in the liquid phase. Mass transfer occurs between these phases. If there is enough time, the phases approach equilibrium; otherwise the model can be used to predict tray efficiencies. Third model type is partial differential equations, which result in when there are significant variations in many directions, or simultaneous time and space dependent variations. The models are often solved in such numerical tools (e.g. finite differences), where changes as function of position are discretized and changes at these discrete points are followed. In this way ordinary differential equations can be transformed into a set of algebraic equations, or partial differential equations transformed into a set of ordinary differential equations. If the ordinary differential equation is of first order, such as tubular or batch reactor model, it is typically solved from a given initial state by marching short steps in time (batch case) or space (tubular case), until the end. Efficient algorithms are available for this, as well as other numerical solutions generally leading to some sort of matrix equations. If the model is algebraic set of equations, that happen to be linear, the system can be written in a matrix form and solved by using suitable matrix system solution techniques. Perhaps the most classical formulation of a matrix equation could be the following, where (x) is a vector (column matrix) of known values, [B] is a known matrix (in this example it could be anything, but typically a square matrix), and (y) is a vector of unknowns. The equation on the left can be solved by simply multiplying left and right hand sides by inverted [B] matrix, resulting in the equation on the right. x By y B1 x If the system is not linear, it can be linearized. Linearization generally means that you assume a linear response, and in some way calculate the linear equation parameters (linearize). Linearization is typically valid only near the linearization point. The validity region depends on how nonlinear the system really is. Basically linearization is the same as drawing a tangent to a function at a given point. y Ax b In some cases, the constant term (b) is neglected during linearization. 3 When computer programs, such as Matlab, are used to solve the model equations, the typical "flow chart" is following: Here the person using these programs typically specifies the problem statement in the uppermost box (initialization), and calls for an appropriate solver. This solver could be e.g. ODE integrator (e.g. "ode15s" in Matlab), solution of nonlinear set of algebraic equations (e.g. "fsolve" in Matlab), or numerical integration of a given function (e.g. "integral" in Matlab). User model is the function to be evaluated (physical model), which gives the necessary values for the solver, e.g. derivatives (ode15s), discrepancy functions (balance errors, fsolve), or integrated function values at solver proposed points (integral). When the solver algorithm is solved, e.g. tubular reactor solution reaches the outlet or errors in the algebraic equations are small enough, or the full integral is calculated, the solver returns results to the main program. There the results can be analyzed, graphs can be plotted etc. Distributions and population balances Distributions with respect to independent variables (so called internal coordinates) appear often in Chemical engineering. If these distributions are important for the process operation or product quality, they should be modeled in order to be able to predict process performance. One common modeled distribution is related to particle, bubble or droplet sizes in multiphase systems. The reason could be that we want to calculate mass transfer area between the phases, by summing up the surface areas of each particle in our control volume, or predict the product size distribution, e.g. in crystallization or polymerization. One class of important parameter that can be calculated from a distribution is its moments. The distribution moment is defined as mi i n L L dL L 0 Here mi is i'th moment of the distribution, n(L) is the number density (number of particles in the control volume), L is the size (moments could be calculated for other properties as well, but ony size is considered here for simplicity). One useful property of the moments is that many of them have physical meanings. Zeroth moment of the number density distribution would be the total number of particles, second moment 4 is proportional to the total surface area (which is important for mass transfer), and third moment is proportional to the total volume of the particles (related to dispersed phase volume fraction). Also some other well-known properties, such as average or standard deviation of the distribution can be calculated directly from the moments. Integration of size distributions is one typical task where numerical integration could be needed. Numerical integration (here for one variable only) formulas can be often written in the form of quadratures: b n a i 1 y f x dx w i f x i Where the integral of a continuous function is approximated by evaluating the function at given quadrature points xi, multiplying these values by corresponding quadrature weights wi, and summing up each contribution. Perhaps the simplest numerical integration method would be to divide the interval a-b into equal distance rectangles, calculate rectangle height from the function value at mid-point of the rectangle, and then summing up each rectangle areas to approximate the integral. This would lead to equally spaced quadrature points and equal quadrature weights (b-a)/(number of points). There are, however, much more efficient quadrature formulas available, e.g. in Matlab. 5