• No results found

Various activities related to chemical engineering require using simulation as a tool to develop the technology to produce a new product or increase the productivity of an existing plant. A good understanding of chemical engi-neering fundamentals and of process models is a prerequisite to conducting simulations. Familiarity with the software being used for the simulation is an added advantage. The development of web-based simulation environ-ments and the use of the Internet for communicating and transmitting data and other relevant information in various formats have made it possible for simulations to be performed at remote locations also. For example, trouble-shooting at the site of industry may be carried out at a different place where the simulator and the simulating personnel are present.

Earlier modelling efforts focussed on the development of models that could  be solved analytically. Therefore, textbooks of that time treated the modelling activity as the application of mathematical techniques to obtain analytical solutions. The use of various transforms, perturbation techniques, complex numbers, solutions in terms of series, matrix algebra solved ordinary and partial differential equations representing various processes. Application of these techniques to solve various chemical engineering problems was pre-sented. Some of these books are given at the end of this chapter (see Davis 2001;

Ramirez 1997; Rice and Do 1995).

The development of numerical techniques encouraged modellers to solve more rigorous problems which earlier could not be solved analytically.

However, the analytical solutions still serve as benchmark solutions to test the effectiveness of the new numerical methods under development. The lit-erature on modelling focussed on the use of various matrix methods to solve simultaneous linear equations, optimisation techniques to solve non-linear equations and solutions for ordinary and partial differential equations (Davis 2001; Ramirez 1997; Rice and Do 1995). The emphasis had been on solving model equations, and this is called an ‘equation-solving approach’

(Shacham 1982).

At present, various methods are available to solve not only ordinary but also  partial differential equations coupled with algebraic equations.

Commercial programmes for computational fluid dynamics (CFD) (FLUENT, COSMOL-MULTIPHYSICS, STAR-CD etc.) and flowsheeting programmes for process simulation (ASPEN PLUS, HYSIS, CHEMCAD, UNISIM, PROSIM, COCO, DWSIM etc.) are available. These software should be treated as tools only and are helpful for developing technology for process industries.

The modeller can now focus on the representation of a process in mathemati-cal equations. The problem of solving these equations involves expressing them using the syntax and semantics of the chosen software.

2.1 Strategy for Simulation

The simulation studies are carried out following a systematic approach. The steps followed to carry out simulation studies involve ‘common-sense steps’

(Ramirez 1997), such as choosing an appropriate model for the given problem and then experimenting with the model. Various steps in a typical simulation normally involve the activities that are discussed in this section. These also have been discussed in the literature (Chung 2004) and are shown in Figure 2.1.

2.1.1 Problem Definition

The first step in carrying out any simulation study is to understand the prob-lem. The goal or aim of the simulation studies should be clearly understood.

For example, let us take a reaction such as the production of aluminium sul-phate by the reaction of alumina and sulphuric acid. From a chemist’s point of view, the problem is to obtain the reaction temperature, the amount of the reactants’ kinetic data and the yield. From a chemical engineer’s point of view, the type of the reactor, controlling of the reaction temperature, feeding of the reactants to the reactor are important. An engineer’s goal is to deter-mine the operating conditions of the reactor that are safe and economical.

Therefore, the reaction should be visualised at an industrial scale, and the problems associated at this scale should be clear.

2.1.2 Understanding the Process

The second step of a simulation study is to understand the physical picture and identify the physical phenomenon and chemical transformation taking place in the process. At this stage, one must understand the process details

Problem

definition Understanding

the process Process

modelling Software selection

Solution of model equations Model

validation Simulation

study

FIGURE 2.1

The steps in a simulation study.

19 An Overview of Modelling and Simulation

and identify the fundamental mechanisms of the process. The depth of knowledge required depends upon the scope of the problem. In the example given in Section 2.1.1, it is realised that alumina is in the form of powder and hence has to be added slowly to the sulphuric acid. A chemical engineer may arrive at the conclusion that the reaction is very fast, and hence the kinetic data are not required as the reaction is mass transfer controlling. Therefore, the aim might be to determine the rate of addition of the alumina powder so that the temperature of the reaction remains constant.

The number of phases, the method of contact of these phases, the rate of reactions at the phase boundaries and the devices to provide contact between the phases are all important. It may be important to identify the parameters which affect the performance of the process, as well as possible insignificant parameters. These will later help in making the assumptions.

2.1.3 Process Modelling

The process can now be modelled. Based on the information available in the literature and the knowledge of the person involved in the modelling, the physical picture of the process has to be transformed into mathematical equa-tions. A physical picture of the model can be represented in the form of a sketch, which is a better way of expressing the idea compared to words. The model sketch at this stage may be just the main mechanisms of the process. Dobre and Marcano (2007) described the various steps of the process of modelling.

This first step in the modelling was called the ‘model by words’. The equations can now be written with the help of the model sketch. At this stage, the sketch of the model never needs to resemble the sketch of the process. For example, scraped surface heat exchangers are used for heating or cooling of very viscous fluids. They consist of concentric cylinders, with the inner rotating cylinder having scrapers and an outer jacketed stationary cylinder. A model based on the surface renewal concept has deficiency; hence, other models such as three-dimensional (3D) lubrication theory were developed (Fitt et  al. 2007).

The renewal of the fluid element at the surface is quite different from the actual scraping of the surface; using a model based on the surface renewal concept is the result of forgetting that there is no fluid layer which is actually replaced.

Also, the boundary layer is only fictitious; it is only a concept. The difference between fictitious and real things should always be clearly understood. This point will be clarified with examples in Chapters 4 to 6.

The sketch of the model should show a simplified process in terms of a suf-ficient number of well-understood phenomena. If any of the phenomena are not well understood, they should be investigated before developing the model.

The model sketch helps us in understanding the interrelations of various phe-nomena, which may also be called ‘sub-models’. These sub-models may be interrelated by parallel or in-series mechanisms or a combination of both.

The model equations are then written with the help of the model sketch consisting of well-understood sub-models, which are relatively simple,

small  and reliable. The model sketch also helps modellers in writing the model equations and indicates to some extent whether the model equations are to be solved sequentially or simultaneously. Expressing the equation in the form of an information flow diagram is helpful in obtaining a stable solution strategy to solve model equations. It also explains interrelationships between various parameters. The role of the model sketch in explaining the models will be discussed in Chapters 4 to 6.

2.1.4 Software Selection: Factors Affecting the Selection

There are many programming languages and specific-purpose languages which may be used for simulation purposes. The following factors affect the selection of suitable software.

2.1.4.1 Availability

In the 1980s and 1990s, computer programmes were written in FORTRAN and C. Later versions of FORTRAN are quite powerful and have syntax simi-lar to that of C. These languages were available to many investigators and were the obvious choice at that time. These languages may still be used if supported by library functions.

Currently, many high-level languages such as MATLAB®, MATHMATICA, MATHCAD, gPROM, STELLA, ACCEND and GAMS are available. Some of these are very specific. It is also possible to use a combination of software packages.

2.1.4.2 Cost

The cost of the software is also an important factor. Commercial packages may be purchased and used. Another option is to use open-source languages such as SCILAB, ACCEND and LIBRA Office CALC.

2.1.4.3 Trained Personnel

Any software has its own syntax and semantics. The user has to learn the soft-ware before using it, which is time consuming. The user sometimes prefers to continue using the software which he or she is familiar with, ignoring the advantages of a new software or programming language. Thus, it is very impor-tant to start with appropriate software which can be used for a long period.

2.1.4.4 Suitability

The software chosen should be suitable for the purpose. It must have features which reduce the work while writing the computer programme for solving equations. At the same time, it must be flexible enough. Some desirable properties include easy syntax and semantics, provisions to use previously

21 An Overview of Modelling and Simulation

developed modules using FORTRAN and C and write user-defined modules, and capabilities to communicate with a wide range of input and output devices and file formats.

Many analytical solutions of simple models involve functions such as Bessel’s function and an error function. Function evaluations involve the sum-mation of a series. Almost all simulation languages, software and spread-sheets have implemented these functions. Other functions which are not available can also be easily incorporated by writing small user-defined func-tion sub-programmes.

The simulation languages should have features to solve systems of alge-braic and differential equations, inequalities etc. The results are presented in various graphical and tabular forms. A general-purpose high-level program-ming language, such as C++, FORTRAN and Visual C, requires an extensive time-consuming programming effort which may be reduced if the libraries for various functions and procedures are available. Other programming lan-guages (MATLAB, OCTAVE, SCILAB, gPROM etc.) have simple commands to solve various types of equations and optimisation problems and to plot vari-ous types of graphs, and varivari-ous input–output functions to access databases stored in files. The programming effort is less, and hence the time required to develop a model is much less. Such high-level languages have features that are commonly required. However, there is loss of flexibility.

Programming languages can be classified into two types: procedure ori-ented and object oriori-ented. Earlier programming languages were procedure based. These involved a main programme using various functions and sub-routines. The functions returned values while the subroutines were used to perform various tasks. The functions and subroutines were user defined and were usable components of the software. High-level languages such as MATLAB and SCILAB are primarily procedure based. A vast amount of code developed in FORTRAN, and C is procedure based. A deviation from the procedure-based programming will require rewriting the code. The com-puter programmes using the procedure-oriented languages are presented in the form of system flowcharts. The system flowcharts represent the manner in which the definition of input–output, the presence of loops (FOR…NEXT, WHILE…DO etc.), the calling of subroutines and reference to the database are handled. The system flowchart is thus a graphical representation of the important inputs, outputs and data flow among the key points in the system.

For example, let us examine the system flow diagram for the estimation of dew point (Figure 2.2). The computer programme starts by reading the number of components, M; total pressure, PT; initial guess for the dew point, TD; con-stant, S; feed composition, zi; i = 1 … M and tolerance EPC to specify the desired accuracy. Since at dew point the composition of the vapour does not change, yi is taken as equal to zi. The initial guess for the liquid compositions, xi, is made.

To avoid entering any of the endless loops due to convergence problems, two counters (Counter 1 and Counter 2) are initiated to check the two loops in the programme. The loops start checking the values of Counter 1 and Counter 2.

If the convergence is not achieved, then further execution of the programme is stopped; otherwise, the subroutine EQUIL is called. This subroutine deter-mines the composition of the liquid in equilibrium with that of vapour at a particular temperature. The values of xi are renewed. The first loop (on the right of the flow diagram) is repeated after checking the values of the toler-ance (EPS) until the difference between the old and new values of xi (for all i) is less than the tolerance. After successful execution of the first loop, the sec-ond loop (on the left of the flow diagram) is executed. It checks the csec-ondition for the existence of dew point. If the value of TD is not equal to the required value, then a new value of TD is guessed by an appropriate method such as the bisection method. When the guess value of TD is equal to the desired value, then the second loop is executed. The value of TD is accepted as output at the required port (printer, file, temporary storage etc.).

Start

Read S, PT, TD, zi, M, EPS Initialise: yi = zi, xiold = 1/M Counter 1 = 0, Counter 2 = 0

Counter 1 = 50 or Counter 2 = 50

If Yes

No

Stop

If

|xinew–xiold|<EPS

for all i Sum(zi/KIfi–1) ≤ EPS

xinew = zi/Ki

xinorm = xinew/Sum(xinew) xinew = (1–S)xiold+Sxinorm

xiold = xinew

Counter 1 = Counter 1+1

Output TD

EQUIL Ki

Yes

Yes

No No

Counter 2 = Counter 2+1 Get new TD

FIGURE 2.2

Flow diagram for dew point calculation.

23 An Overview of Modelling and Simulation

It has been more than a decade since object-oriented programming languages (OOPLs) have become more acceptable than procedure-based programming (Stephanopoulos et al. 1987). In the OOPL approach, an object (often defined as a class) is the reusable software component. The ‘class’ contains various meth-ods similar to subroutines in procedure-based languages. It also has properties similar to variables in procedure-based languages. The unique features of the object are that various similar classes can be created with a single line code called an instance of the class. Once an instance is created, more functionality can be added to it, including other available classes. Thus, a class can inherit the features of more than one class. It not only reduces the programming efforts but also is easier to reuse. To use a class, one should know the function and properties of the class, which is accessible from outside. C++, Visual BASIC and JAVA are OOPLs. For modelling of chemical engineering problems, ASCEND was developed using object-oriented programming. Such languages have predefined classes such as TANK and HEAT EXCHANGER. Now MATLAB has provisions to create classes now and supports OOPLs.

The structure of the computer programme is shown by the class inheri-tance. A programme usually has a main class consisting of various other classes (called ‘children’). The class inheritance for the dew point calculation is presented in Figure  2.3. The main class is ‘DEWPOINT’ which consists

DEW POINT Methods:

Dew point

EQUIL Methods:

Fugacity coefficient Activity coefficient Ki

EOS Methods:

Calculate unknown data Data:

Pressure Temperature Composition

FIGURE 2.3

Class heritance for dew point estimation.

of the classes ‘EQUIL’ and ‘EOS’. The EOS uses equation of state and holds data (temperature, pressure and composition of the mixture) and methods to calculate the unknown from the remaining data. The EQUIL uses this class to calculate fugacity, activity coefficient and hence Ki. For simplicity, it is assumed that a cubic equation of state such as Peng–Robinson is predict-ing liquid properties also. Otherwise, methods such as UNIFAQ, UNIQUAK and ASOG might be required.

2.1.5 Solution of Model Equations

The model is coded using the syntax of the chosen software. For example, to solve a set of simultaneous equations, the coefficients may be entered as a matrix. The representation of the matrix may depend upon the software used. When two or more types of software are used for simulation pur-poses, the transportability of the data among them should be taken care of.

The equations are then solved. There may be more than one way to solve a set of equations. For example, a differential equation may be solved using an ordinary differential equation (ODE) solver, or using symbolic mathemat-ics to express it in terms of Laplace transform and solve it as an algebraic equation. The user-defined modules should be debugged at various stages to avoid any programming error. Dedicated software has various error- checking methods and informs the user.

2.1.6 Model Validation

Solving the model does not mean that the model has been developed suc-cessfully. A model must mimic the performance of the process or system.

Therefore, it is important to estimate various parameters using the model and compare them with experimental data. Getting a satisfactory agreement between the experimental data and model prediction is called ‘model vali-dation’. A model is ready to use for simulation studies only after successful validation. Few models have adjustable parameters or terms which may or may not be experimentally measurable, but their presence in the model is essential for predicting the correct trend of the experimental data. These parameters can be obtained by fitting the experimental data with the model equations. This process is known as ‘parameter identification’.

2.1.7 Simulation Study

The model is used several times with an aim to study the effect of operating parameters on the performance of the process. The optimum operating con-ditions can also be determined if desired. The results are presented in various formats. These may be in the form of tables or graphs. Many graphical plots are topic specific, such as a triangular plot to represent liquid– liquid equilib-rium data. Various high-level languages can plot the graphs in many formats

25 An Overview of Modelling and Simulation

and print them. Few software are capable of producing even animated movies to show time-varying phenomena. If these facilities are not available, then the results should be processed after simulation. Graphs may be plotted using spreadsheets or programmes such as ORIGIN.

2.2 Approaches for Model Development

The development of a model for complex chemical engineering processes involves the omission of several details of the process. It, however, results in a reduced scope of the model. Even though a simple model sometimes does not represent a large system, it can still be used as a sub-model for a part of the process or system. A model may consist of one or more sub-models which may be interconnected in series or in parallel. A model representing a large process in mathematical form can be developed in any of the three

The development of a model for complex chemical engineering processes involves the omission of several details of the process. It, however, results in a reduced scope of the model. Even though a simple model sometimes does not represent a large system, it can still be used as a sub-model for a part of the process or system. A model may consist of one or more sub-models which may be interconnected in series or in parallel. A model representing a large process in mathematical form can be developed in any of the three