Mathcad for J : Hertanto Adidharma Valery Temyanko Math cad for Chemical Engineers Hertanto Adidharma University of Wyoming Valery Temyanko University of Arizona © Copyright 2007 by Hertanto Adidharma and Valery Temyanko All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the written prior permission of the author. Note for Librarians: A cataloguing record for this book is available from Library and Archives Canada at www.collectionscanada.ca/amicus/index-e.html ISBN 1-4251-1541-1 Printed in Victoria, BC, Canada. Printed on paper with minimum 30% recycled fibre. Trajford's print shop runs on “green energy**from solan wind and other environmentally friendly power sources. TRARORD P U B L I S H I N G Offices in Canada, USA. Ireland and UK Book sales for North America and international: Trafford Publishing, 6E-2333 Government St., Victoria, BC V8T 4P4 CANADA phone 250 383 6864 (toll-free 1 888 232 4444) fax 250 383 6804; email to [email protected] Book sales in Europe: ^ Trafford Publishing (uk) Limited, 9 Park End Street, 2nd Floor Oxford, UK OXi IHH UNITED KINGDOM phone 44 (0)1865 722 113 (local rate 0845 230 9601) facsimile 44 (0)1865 722 868; [email protected] Order online at: trafford.com/07-0005 10 9 8 7 6 5 4 3 2 1 About the Authors Hertanto Adidharma is currently a professor of chemical engi neering at the University of Wyoming. He has ten years experience in chemical engineering education. He has taught various chemical engineering courses: Material and Energy Balance, Transport Phe nomena, Chemical Reaction Engineering, Thermodynamics, Nu merical Methods, Computer Programming, Unit Operations, and introduction to Chemical Engineering Computing. Before entering teaching, he spent several years in chemical industry and became an independent consultant. Valery Temyanko is currently a Staff Engineer, Sr. at the Univer sity of Arizona. He has more than 10 years of industrial experi ence. Research and development of resin transfer molding (RTM), reaction injection molding (RIM), reforming of fuel, process opti mization and control are the primary areas of his expertise. Contents vii Contents Preface xi Chapter 1. Introduction 1 Chapter 2. Getting Started with Mathcad 5 2.1. Mathcad Worksheet and User Interface 5 2.2. Variables and Functions 7 2.3. Arrays: Vector and Matrix 9 2.4. Working with Units 12 ^2.5. Graphics Features 14 2.6. Symbolic Math Capabilities 18 Problems 20 Chapter 3. Non-Linear Equation 25 3.1. Polynomial 25 3.2. Non-Polynomial 31 Problems 33 Chapter 4. System of Equations 39 4.1. System of Linear Equations 39 4.2. System of Non-Linear Equations 45 4.3. System of Equations with Constraints 50 Problems 52 Chapter 5. Curve Fitting 59 5.1. Interpolation 59 5.1.1. Linear Interpolation 60 Vlll Contents 5.1.2. Cubic Spline 60 5.2. Regression 65 5.2.1. Linear Regression 66 5.2.2. Polynomial Regression 68 5.2.3. Non-Linear Regression 70 Problems 74 Chapter 6. Differentiation and Integration 79 6.1. Differentiation 79 6.2. Integration " 83 Problems 85 Chapter 7. Optimization 91 7.1. Extreme Value Problem 91 7.1.1. Unconstrained Function 91 7.1.2. Constrained Function 94 7.2. Linear Programming 99 7.3. Non-Linear Programming 103 Problems 106 Chapter 8. Differential Equation 111 8.1. Ordinary Differential Equation 111 8.1.1. First Order ODE ill 8.1.2. System of First Order ODEs 116 8.1.3. Higher Order ODE - Initial Value Problem 117 8.1.4. Higher Order ODE - Boundary Value Problem 119 Contents ix 8.1.5. Second Order ODE - Cylindrical/ Spherical Coordinate 121 8.1.6. System of Higher Order ODEs 122 8.2. Partial Differential Equation 129 8.2.1. Parabolic PDE 129 8.2.2. System of Parabolic PDEs 132 8.2.3. Elliptic PDE 133 Problems 137 Chapter 9. Miscellaneous 145 9.1. Data Handling 145 9.2. Data Exchange with Excel 145 9.3. Introduction to Mathcad Programming 149 9.3.1. Conditional (//'Statement) 149 9.3.2. Loops (for/while Statement) 151 Problems 160 Index 169 \ Preface xi Preface Xhis book serves as a must-to-have guide and quick refer ence for chemical engineers and those who would like to learn and use Mathcad for their computational tool. The book is also in tended for one-semester course on Chemical Engineering Comput ing using Mathcad. Authors believe that unlike other computa tional software packages, Mathcad is very intuitive and thus easy to learn. There are several mathematical or computational software packages available today. Among the most widely used are Maple, Maxima, MatLab, Mathematica, Mathcad, and Excel. The prefer ence of one particular computational package over the others is usually, ironically, based only on familiarity. The approach of “familiar” software works with some limitations, but it is never the most efficient way of problem solving. It is very important to choose and use the latest software and not to be afraid of switching and learning. This is the best time investment that one can do. Given many years of experience in solving a wide variety of chemical engineering tasks, authors are convinced that Mathcad is easy to learn and easy to use, yet versatile and powerful. Thus, it is an extremely important and useful software package for modem chemical engineers. Although Mathcad 13 is the software package chosen by the authors and will be used throughout the book, most of the features discussed can also be applied using earlier versions of Mathcad. Also, although Mathcad will always evolve into a newer version, most of the contents in this book will be applicable for any subsequent version of Mathcad. The main objective of the book is to develop o6mputational skills needed in chemical engineering applications. The readers will leam how to solve different types of mathematical models. At the same time, the book introduces readers to many chemical engi neering applications, such as Xll Preface • Property estimation • Material and energy balance • Thermodynamics • Transport phenomena • Kinetic and reactor design c • Unit operations • Process control • Process economics • Statistical thermodynamics The already-developed mathematical models in those ap plications will be solved using Mathcad. The development of the mathematical models itself, from fundamental theories, is beyond the scope of this book. Readers must consult other chemical engi neering textbooks. For students, they usually leam how to develop such models from other courses. In this book, readers can leam how to use Mathcad func tions in clearly described procedures intended for quick reference. To introduce readers to some related mathematical problems ap peared in chemical engineering applications, examples and prob lems are given in each chapter. Finally, it is important to mention that the book is not in tended to give readers a complete manual of Mathcad, but rather to provide them with the essential Mathcad functions and features commonly needed in chemical engineering. After reading this book, of course the readers are encouraged to keep exploring the power of Mathcad. Hertanto Adidharma Valery Temyanko Mathcad for Chemical Engineers