ebook img

Simulation of ODE/PDE Models with MATLAB , OCTAVE and SCILAB: Scientific and Engineering Applications PDF

416 Pages·2016·11.65 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Simulation of ODE/PDE Models with MATLAB , OCTAVE and SCILAB: Scientific and Engineering Applications

Alain Vande Wouwer Philippe Saucez Carlos Vilas Simulation of ODE/PDE Models with MATLAB®, OCTAVE and SCILAB Scientific and Engineering Applications Simulation of ODE/PDE Models with MATLAB(cid:2), OCTAVE and SCILAB Alain Vande Wouwer Philippe Saucez • Carlos Vilas Simulation of ODE/PDE (cid:2) Models with MATLAB , OCTAVE and SCILAB Scientific and Engineering Applications 123 AlainVandeWouwer CarlosVilas Service d’Automatique (Bio)Process EngineeringGroup Université de Mons Institutode Investigaciones Marinas Mons (CSIC) Belgium Vigo Spain Philippe Saucez Service deMathématique etRecherche Opérationnelle Université de Mons Mons Belgium Additionalmaterial tothis bookcan bedownloaded from http://extras.springer.com ISBN 978-3-319-06789-6 ISBN 978-3-319-06790-2 (eBook) DOI 10.1007/978-3-319-06790-2 Springer ChamHeidelberg New YorkDordrecht London LibraryofCongressControlNumber:2014939391 (cid:3)SpringerInternationalPublishingSwitzerland2014 Thisworkissubjecttocopyright.AllrightsarereservedbythePublisher,whetherthewholeorpartof the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,broadcasting,reproductiononmicrofilmsorinanyotherphysicalway,andtransmissionor informationstorageandretrieval,electronicadaptation,computersoftware,orbysimilarordissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purposeofbeingenteredandexecutedonacomputersystem,forexclusiveusebythepurchaserofthe work. Duplication of this publication or parts thereof is permitted only under the provisions of theCopyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the CopyrightClearanceCenter.ViolationsareliabletoprosecutionundertherespectiveCopyrightLaw. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publicationdoesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexempt fromtherelevantprotectivelawsandregulationsandthereforefreeforgeneraluse. While the advice and information in this book are believed to be true and accurate at the date of publication,neithertheauthorsnortheeditorsnorthepublishercanacceptanylegalresponsibilityfor anyerrorsoromissionsthatmaybemade.Thepublishermakesnowarranty,expressorimplied,with respecttothematerialcontainedherein. Printedonacid-freepaper SpringerispartofSpringerScience+BusinessMedia(www.springer.com) To V. L. E. A. To Daniel Druart Philippe Saucez Foreword Withthe availabilityofcomputers ofincreasingpowerandlower cost, computer- basedmodelingisnowawidespreadapproachtotheanalysisofcomplexscientific andengineeringsystems.First-principlesmodelsandnumericalsimulationcanbe used to investigate system dynamics, to perform sensitivity analysis, to estimate unknown parameters or state variables, and to design model-based control schemes. However, due to the usual gap between research and common practice, scientists and engineers still often resort to conventional tools (e.g. low-order approximate solutions), and do not make use of the full array of readily available numerical methods. Manysystemsfromscienceandengineeringaredistributedparametersystems, i.e.,systemscharacterizedbystatevariables(ordependentvariables)intwoormore coordinates (or independent variables). Time and space are the most frequent combinationofindependentvariables,asisthecaseofthefollowing(time-varying, transient,orunsteadystate)examples: • temperature profiles in a heat exchanger • concentration profiles in a sorptive packed column • temperature and concentration profiles in a tubular reactor • car density along a highway • deflection profile of a beam subject to external forces • shape and velocity of a water wave • distribution of a disease in a population (spread of epidemics) but other combinations of independent variables are possible as well. For instance, time and individual size (or another characteristic such as age) occur in population models used in ecology, or to describe some important industrial processes such as polymerization, crystallization, or material grinding. In these models, space can also be required to represent the distribution of individuals (of various sizes)inaspatialregionorinanonhomogeneousreactor medium(dueto nonideal mixing conditions in a batch reactor, or to continuous operation in a tubular reactor). The preceding examples show that there exists a great variety of distributed parametersystems,arisingfrom different areas of science andengineering, which are characterized by time-varying distributionsof dependent variables. In view of vii viii Foreword the system complexity, a mathematical model, i.e., a mathematical description of the physical (chemical, biological, mechanical, electrical, etc.) phenomena taking place in the system, is often a prerequisite to system analysis and control. Such a modelconsistsofpartialdifferentialequations(PDEs),boundaryconditions(BCs), and initial conditions (ICs) describing the evolution of the state variables. In addition, distributed parameter systems can interact with lumped parameter sys- tems, whose state variables are described by ordinary differential equations (ODEs), and supplementary algebraic equations (AEs) can be used to express phenomenasuchasthermodynamicequilibria,heatandmasstransfer,andreaction kinetics (combinations of AEs and ODEs are also frequently termed differential- algebraic equations, or DAEs). Hence, a distributed parameter model is usually described by a mixed set of nonlinear AE/ODE/PDEs or PDAEs. Most PDAEs models are derived from first principles, i.e., conservation of mass, energy, and momentum, and are given in a state space representation which is the basis for system analysis. Thisbookisdedicatedtonumericalsimulationofdistributedparametersystems described by mixed systems of PDAEs. Special attention is paid to the numerical method of lines (MOL), a popular approach to the solution of time-dependent PDEs, which proceeds in two basic steps. First, spatial derivatives are approxi- mated using finite difference, element, or volume approximations. Second, the resulting system of semi-discrete (discrete in space continuous in time) equations is integrated in time using an available solver. Besides conventional finite dif- ference, element, and volume techniques, which are of high practical value, more advancedspatialapproximationtechniquesareexaminedinsomedetail,including finite element and finite volume approaches. Although the MOL has attracted considerable attention and several general- purposelibrariesorspecificsoftwarepackageshavebeendeveloped,thereisstilla need for basic, introductory, yet efficient, tools for the simulation of distributed parameter systems, i.e., software tools that can be easily used by practicing sci- entists and engineers, and that provide up-to-date numerical algorithms. Consequently, a MOL toolbox has been developed within MATLAB/ OCTAVE/SCILAB.Theseenvironmentsconvenientlydemonstratetheusefulness and effectiveness of the above-mentioned techniques and provide high-quality mathematical libraries, e.g., ODE solvers that can be used advantageously in combination with the proposed toolbox. In addition to a set of spatial approxi- mations and time integrators, this toolbox includes a library of application examples, in specific areas, which can serve as templates for developing new programs. The idea here is that a simple code template is often more compre- hensible and flexible than a software environment with specific user interfaces. This way, various problems including coupled systems of AEs, ODEs, and PDEs in one or more spatial dimensions can easily be developed, modified, and tested. This text, which provides an introduction to some advanced computational techniquesfordynamicsystemsimulation,issuitableasafinalyearundergraduate course or at the graduate level. It can also be used for self-study by practicing scientists and engineers. Preface Our initial objective in developing this book was to report on our experience in numerical techniques for solving partial differential equation problems, using simple programming environments such as MATLAB, OCTAVE, or SCILAB. Computational tools and numerical simulation are particularly important for engineers, but the specialized literature on numerical analysis is sometimes too denseortoodifficulttoexploreduetoagapinthemathematicalbackground.This book is intended to provide an accessible introduction to the field of dynamic simulation, with emphasis on practical methods, yet including a few advanced topicsthatfindanincreasingnumberofengineeringapplications.Attheoriginof thisbookproject,someyearsago,wewereteamingupwithBillSchiesser(Lehigh University) with whom we had completed a collective book on Adaptive Method ofLines.Unfortunately,thispreviousworkhadtakentoomuchofourenergy,and the project faded away, at least for the time being. Time passed, and the book idea got a revival at the time of the post-doctoral stay of Carlos in the Control Group of the University of Mons. Carlos had just achieved a doctoral work at the University of Vigo, involving partial differential equation models, finite element techniques, and the proper orthogonal decompo- sition, ingredients, which all were excellent complements to our background material. Thethreeofusthendecidedtojoinourforcestodevelopamanuscriptwithan emphasis on practical implementation of numerical methods for ordinary and partial differential equation problems, mixing introductory material to numerical methods, a variety of illustrative examples from science and engineering, and a collection of codes that can be reused for the fast prototyping of new simulation codes. All in one, the book material is based on past research activities, literature review,aswellascoursestaughtattheUniversityofMons,especiallyintroductory numericalanalysiscoursesforengineeringstudents.Asacomplementtothetext,a website (www.matmol.org) has been set up to provide a convenient platform for downloading codes and method tutorials. Writingabookisdefinitelyadelicateexercise,andwewouldliketoseizethis opportunitytothankBillforhissupportintheinitialphaseofthisproject.Manyof his insightful suggestions are still present in the current manuscript, which has definitely benefited from our discussions and nice collaboration. ix x Preface Of course, we also would like to express our gratitude to our colleagues at UMONS and at IMM-CSIC (Vigo), and particularly Marcel, Christine, Antonio, Julio,Eva,andMíriam,andalltheformerandcurrentresearchteams,forthenice working environment and for the research work achieved together, which was a sourceofinspirationindevelopingthismaterial.Wearealsogratefultoanumber of colleagues in other universities for the nice collaboration, fruitful exchanges at several conferences, or insightful comments on some of our developments: MichaelZeitz,AchimKienle,PaulZegeling,GerdSteinebach,KeithMiller,Skip Thompson, Larry Shampine, Ken Anselmo, Filip Logist, to just name a few. In addition, we acknowledge the support of the Belgian Science Policy Office (BELSPO), which through the Interuniversity Attraction Program Dynamical Systems,ControlandOptimization(DYSCO)supportedpartofthisresearchwork and made possible several mutual visits and research stays at both institutions (UMONS and IIM-CSIC) over the past several years. Finally,wewouldliketostresstheexcellentcollaborationwithOliverJackson, Editor in Engineering at Springer, with whom we had the initial contact for the publication of this manuscript and who guided us in the review process and selection of a suitable book series. In the same way, we would like to thank Charlotte Cross, Senior editorial assistant at Springer, for the timely publication process,andforherhelpandpatienceinthedifficultmanuscriptcompletionphase. Mons, March 2014 Alain Vande Wouwer Vigo Philippe Saucez Carlos Vilas Contents 1 An Introductory Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Some ODE Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 An ODE/DAE Application . . . . . . . . . . . . . . . . . . . . . . . . . . 32 1.3 A PDE Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 1.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2 More on ODE Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.1 A Basic Fixed Step ODE Integrator. . . . . . . . . . . . . . . . . . . . 45 2.2 A Basic Variable-Step Nonstiff ODE Integrator. . . . . . . . . . . . 51 2.3 A Basic Variable Step Implicit ODE Integrator. . . . . . . . . . . . 67 2.4 MATLAB ODE Suite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 2.5 Some Additional ODE Applications. . . . . . . . . . . . . . . . . . . . 86 2.5.1 Spruce Budworm Dynamics . . . . . . . . . . . . . . . . . . . 86 2.5.2 Liming to Remediate Acid Rain . . . . . . . . . . . . . . . . 93 2.6 On the Use of SCILAB and OCTAVE. . . . . . . . . . . . . . . . . . 109 2.7 How to Use Your Favorite Solvers in MATLAB? . . . . . . . . . . 115 2.7.1 A Simple Example: Matrix Multiplication. . . . . . . . . . 117 2.7.2 MEX-Files for ODE Solvers. . . . . . . . . . . . . . . . . . . 122 2.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 3 Finite Differences and the Method of Lines. . . . . . . . . . . . . . . . . . 125 3.1 Basic Finite Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 3.2 Basic MOL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 3.3 Numerical Stability: Von Neumann and the Matrix Methods. . . 129 3.4 Numerical Study of the Advection Equation . . . . . . . . . . . . . . 136 3.5 Numerical Study of the Advection-Diffusion Equation. . . . . . . 142 3.6 Numerical Study of the Advection-Diffusion-Reaction Equation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 3.7 Is it Possible to Enhance Stability? . . . . . . . . . . . . . . . . . . . . 151 3.8 Stiffness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 3.9 Accuracy and the Concept of Differentiation Matrices . . . . . . . 157 xi

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.