Cover Page

Chemical and Biomedical Engineering Calculations Using Python®

 

Jeffrey J. Heys

Montana State University
Bozeman, Montana, USA

 

 

 

 

Wiley Logo

Preface

Computers have become a powerful tool in the field of engineering. Before the widespread availability of computers, mathematical models of engineering problems needed to be simplified to the point that the calculations could be reliably performed by a single individual using a calculator or slide rule, and, fortunately, for many engineering problems, simplified models were adequate. However, as process complexity and engineering design complexity increased, engineers increasingly turned to computers for help in managing and automating the large number of calculations required.

The computational tools used by engineers have evolved considerably over the past few decades. In the 1960s and 1970s, computers were not widely available, and they were a specialized tool that was operated by highly trained individuals. In the 1980s and 1990s, computers became widely available, but the engineering software and computational tools were relatively simple compared to what is available in the twenty-first century. The individual that was using the computer general understood the calculations that were being performed, and the computer was primarily a tool for automating those calculations. Many engineering students during this time learned to program in either FORTRAN or C, and the programs written by engineers were frequently limited to a few hundred lines of code. More specialized and easier to use programming environments like MATLAB and IDL were also developed during the 1980s, and they usually helped to decrease the time required to write a computer algorithm, but they increased the time required to execute or run the algorithm.

The trend toward greater specialization and ease of use in computational tools continued in the twenty-first century. The various fields of engineering saw an exponential increase in powerful and easy-to-use tools like AutoCAD, SolidWorks, ANSYS, and Aspen. (Clearly, it is a good idea to choose a name for your software that begins with “A” so it appears first alphabetically.) The individual that uses these software packages may have some understanding of the calculations that are being performed, but they almost never fully understand the calculations and in some cases have no understanding of the mathematics that is being performed by the computer. Today, engineering students are typically taught to use multiple computational software packages during the typical undergraduate education. The irony of this situation is that students often do not understand the calculation being performed by the software – they do not know the limitations of the mathematical models, they do not know the expected accuracy of the approximate solution, and they do not always have the intuition necessary to recognize a highly incorrect result. Another loss associated with the rise of specialized software tools for engineers is that it is often very difficult to find a computational tool for a new problem. The software often works well for the limited range of problems for which it was designed, but, if an engineer wishes to analyze something new or include some change that takes the problem just beyond the range of problems for which the software was design, that engineer is often “out of luck” because no computational tool is available to help.

I do not advocate abandoning modern engineering software. I do not advocate returning to the use of custom FORTRAN computer codes for every problem. I do advocate that engineering students get some experience writing short computer programs. This experience teaches one to think precisely as computers are notoriously unforgiving when we make mistakes in our logic. It teaches one to decompose a complex process down into small, individual steps. This experience teaches one to develop a unique solution for a new problem that is not handled well by existing software. Finally, the experience of creating a computer algorithm helps to develop a recognition of when computations are likely to be reliable and when they are not – when the computational solution is sufficiently accurate and when it is not.

The goal of this book is to provide the reader with an understanding of standard computational methods for approximating the solution to common problems in Chemical and Biomedical Engineering. The book does not have a comprehensive coverage of computational methods, but it is instead intended to provide the introductory coverage necessary to understand the most commonly used algorithms. The computer language used to explore the different computational methods is Python. The advantages of using Python include its wide and growing popularity, large library of existing algorithms, and its licensing as free, open source software. The final and possibly greatest advantage in using Python is that it is easy to learn to write general computational algorithms and more specialized numerical algorithms are also easy to write, thanks to the NumPy and SciPy libraries. By the end of this book, the reader should have a solid understanding of how to write and use computational algorithms in Python to solve common mathematical problems in Chemical and Biomedical Engineering.

The course that motivated the creation of this textbook is one semester of approximately 15 weeks. It is my belief that most of this material can be covered in that length of time. Each chapter in the textbook covers a different topic and the book was constructed so that the material in that chapter could be covered in approximately 1 week. There are, of course, some exceptions. The large number of topics and short amount of time associated with a single semester may encourage instructors using this book to consider a slightly different format than the traditional lecture format. For example, if two class times per week are available, an instructor may want to consider requiring students to read the book or watch an online lecture that presents the material to be covered before coming to the first class meeting time each week. The two class periods could then be used to cover example problems (the first class each week) and a “working class” could be used for the second class meeting of the week. When students are trying to complete the homework, they often need support to overcome a difficult error message or unexpected and unphysical numerical answer from the computer, and allowing students to work on problems for one class time per week is often very beneficial.

Suggested homework problems are included at the end of each chapter. Many of the homework problems are written so that the person answering the problem must respond to a request from a real or hypothetical organization such as a company or government agency. The author of this book typically assigns one or two problems per week and requires students to submit their solutions in the form of a memo to the organization that posed the problem. The memo typically is about 1 page of text plus 1–3 figures for a total of 2 or 3 pages for the main body of the memo, and the Python code is included by the student in an appendix with the memo. Requiring students to practice technical writing is a benefit of using this approach, and many students are motivated when the problems have more of a “real world” flavor and are less abstract.

In closing, I would like to offer my sincerest thanks and gratitude to the many unnamed individuals that have contributed to building Python and making scientific computing using Python such a wonderful reality. To me, it is really humbling and encouraging to see the great work that these individuals have freely given to the world. I would like to single out two individuals by name because of the transformative impact of their work – without their work, I would never have started using Python as extensively as I do, and this book would never have been written. The first individual is Travis Oliphant, the primary creator of NumPy and the founder of Continuum Analytics, which produces the Anaconda Python Distribution. The second individual is Fernando Perez, a physicist, creator of iPython, and, most importantly to me, the person that came into my office at the University of Colorado at Boulder and told me that I should try learning Python because it made programming fun!

Bozeman, Montana
Jeffrey J. Heys
July 15, 2016

About the Companion Website

This book is accompanied by a companion website:

nfgz001

www.wiley.com/go/heys/engineeringcalculations_python

The website includes: