19.07.2014 Views

[Luyben] Process Mod.. - Student subdomain for University of Bath

[Luyben] Process Mod.. - Student subdomain for University of Bath

[Luyben] Process Mod.. - Student subdomain for University of Bath

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

90 COMPUTER SIMULATION<br />

lation packages is usually significantly longer than when run on a FORTRAN,<br />

BASIC, or PASCAL program written <strong>for</strong> the specific problem.<br />

Proponents <strong>of</strong> these packages argue, however, that the setup and programming<br />

time is reduced by using simulation languages. This may be true <strong>for</strong> the<br />

engineer who doesn’t know any programming and uses the computer only very<br />

occasionally and only <strong>for</strong> dynamic simulations. But almost all high school and<br />

certainly all engineering graduates know some computer programming language.<br />

So using a simulation package requires the engineer to learn a new language and<br />

a new system. Since some language is already known and since the simple, easily<br />

programmed numerical techniques work well, it has been my experience that it is<br />

much better <strong>for</strong> the engineer to develop a specific program <strong>for</strong> the problem at<br />

hand. Not only is it more computationally efficient, but it guarantees that the<br />

engineer knows what is in the program and what the assumptions and techniques<br />

are. This makes debugging when it doesn’t work and modifying it to handle new<br />

situations much easier.<br />

On the other hand, the use <strong>of</strong> special subroutines <strong>for</strong> doing specific calculations<br />

is highly recommended. The book by Franks (<strong>Mod</strong>eling and Simulation in<br />

Chemical Engineering, John Wiley and Son, Inc., 1972) contains a number <strong>of</strong><br />

useful subroutines. And <strong>of</strong> course there are usually extensive libraries <strong>of</strong> subroutines<br />

available at most locations such as the IMSL subroutines. These can be<br />

called very conveniently from a user’s program.<br />

4.2 COMPUTER PROGRAMMING<br />

A comprehensive discussion <strong>of</strong> computer programming is beyond the scope <strong>of</strong><br />

this book. I assume that you know some computer programming language. All<br />

the examples will use FORTRAN since it is the most widely used by practicing<br />

chemical engineers.<br />

However, it might be useful to make a few comments and give you a few<br />

tips about programming. These thoughts are not coming from a computer scientist<br />

who is interested in generating the most efficient and elegant code, but from<br />

an engineer who is interested in solving problems.<br />

Many people get all excited about including extensive comment statements<br />

in their code. Some go so far as to say that you should have two lines <strong>of</strong> comments<br />

<strong>for</strong> every one line <strong>of</strong> code. In my view this is ridiculous! If you use symbols<br />

in your program that are the same as you use in the equations describing the<br />

system, the code should be easy to follow. Some comment statements to point<br />

out the various sections <strong>of</strong> the program are fine.<br />

For example, in distillation simulations the distillate and bottoms composition<br />

should be called “XD(J)” and “XB(J)” in the program. The tray compositions<br />

should be called “X(N,J),” where IV is the tray number starting from the<br />

bottom and J is the component number. Many computer scientists put all<br />

the compositions into one variable “X(N,J)” and index it so that the distillate is<br />

X(l,J), the top tray is X(2,J), etc. This gives a more compact program but<br />

makes it much more difficult to understand the code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!