Lecture Notes in Physics
Editorial Board
R. Beig, Wien, Austria W. B eiglbock,¨ Heidelberg, Germany W. Domcke, Garching, Germany B.-G. Englert, Singapore U. Frisch, Nice, France P. Hanggi,¨ Augsburg, Germany G. Hasinger, Garching, Germany K. Hepp, Zurich,¨ Switzerland W. Hillebrandt, Garching, Germany D. Imboden, Zurich,¨ Switzerland R. L. Jaffe, Cambridge, MA, USA R. Lipowsky, Golm, Germany H. v. Lohneysen,¨ Karlsruhe, Germany I. Ojima, Kyoto, Japan D. Sornette, Nice, France, and Los Angeles, CA, USA S. Theisen, Golm, Germany W. Weise, Garching, Germany J. Wess, Munchen,¨ Germany J. Zittartz, Koln,¨ Germany The Editorial Policy for Monographs The series Lecture Notes in Physics reports new developments in physical research and teaching - quickly, informally, and at a high level. The type of material considered for publication includes monographs presenting original research or new angles in a classical field. The timeliness of a manuscript is more important than its form, which may be preliminary or tentative. Manuscripts should be reasonably self-contained. They will often present not only results of the author(s) but also related work by other people and will provide sufficient motivation, examples, and applications.
Acceptance The manuscripts or a detailed description thereof should be submitted either to one of the series editors or to the managing editor. The proposal is then carefully refereed. A final decision concerning publication can often only be made on the basis of the complete manuscript, but otherwise the editors will try to make a preliminary decision as definite as they can on the basis of the available information.
Contractual Aspects Authors receive jointly 30 complimentary copies of their book. No royalty is paid on Lecture Notes in Physics volumes. But authors are entitled to purchase directly from Springer other 1 books from Springer (excluding Hager and Landolt-Börnstein) at a 33 3 % discount off the list price. Resale of such copies or of free copies is not permitted. Commitment to publish is made by a letter of interest rather than by signing a formal contract. Springer secures the copyright for each volume.
Manuscript Submission Manuscripts should be no less than 100 and preferably no more than 400 pages in length. Final manuscripts should be in English. They should include a table of contents and an informative introduction accessible also to readers not particularly familiar with the topic treated. Authors are free to use the material in other publications. However, if extensive use is made elsewhere, the publisher should be informed. As a special service, we offer free of charge LATEX macro packages to format the text according to Springer’s quality requirements. We strongly recommend authors to make use of this offer, as the result will be a book of considerably improved technical quality. The books are hardbound, and quality paper appropriate to the needs of the author(s) is used. Publication time is about ten weeks. More than twenty years of experience guarantee authors the best possible service.
LNP Homepage (springerlink.com) On the LNP homepage you will find: −The LNP online archive. It contains the full texts (PDF) of all volumes published since 2000. Abstracts, table of contents and prefaces are accessible free of charge to everyone. Information about the availability of printed volumes can be obtained. −The subscription information. The online archive is free of charge to all subscribers of the printed volumes. −The editorial contacts, with respect to both scientific and technical matters. −Theauthor’s/editor’sinstructions. Dieter Britz
Digital Simulation in Electrochemistry
Third Completely Revised and Extended Edition With Supplementary Electronic Material
123 Author Dieter Britz Kemisk Institut Arhus˚ Universitet 8000 Arhus˚ C Denmark Email: [email protected]
Dieter Britz, DigitalSimulationinElectrochemistry, Lect. Notes Phys. 666 (Springer, Berlin Heidelberg 2005), DOI 10.1007/b97996
Library of Congress Control Number: 2005920592 ISSN 0075-8450 ISBN 3-540-23979-0 3rd ed. Springer Berlin Heidelberg New York ISBN 3-540-18979-3 2nd ed. Springer-Verlag Berlin Heidelberg New York ISBN 3-540-10564-6 1st ed. published as Vol. 23 in Lecture Notes in Chemistry Springer-Verlag Berlin Heidelberg New York
This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. Springer is a part of Springer Science+Business Media springeronline.com © Springer-Verlag Berlin Heidelberg 2005 Printed in Germany The use of general descriptive names, registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. Typesetting: by the authors and TechBooks using a Springer LATEX macro package Cover design: design & production,Heidelberg Printed on acid-free paper 2/3141/jl-543210 This book is dedicated to H. H. Bauer, teacher and friend
Preface
This book is an extensive revision of the earlier 2nd Edition with the same title, of 1988. The book has been rewritten in, I hope, a much more didac- tic manner. Subjects such as discretisations or methods for solving ordinary differential equations are prepared carefully in early chapters, and assumed in later chapters, so that there is clearer focus on the methods for partial differential equations. There are many new examples, and all programs are in Fortran 90/95, which allows a much clearer programming style than earlier Fortran versions. In the years since the 2nd Edition, much has happened in electrochemical digital simulation. Problems that ten years ago seemed insurmountable have been solved, such as the thin reaction layer formed by very fast homogeneous reactions, or sets of coupled reactions. Two-dimensional simulations are now commonplace, and with the help of unequal intervals, conformal maps and sparse matrix methods, these too can be solved within a reasonable time. Techniques have been developed that make simulation much more efficient, so that accurate results can be achieved in a short computing time. Stable higher-order methods have been adapted to the electrochemical context. The book is accompanied (on the webpage www.springerlink.com/ openurl.asp?genre=issue&issn=1616-6361&volume=666) by a number of ex- ample procedures and programs, all in Fortran 90/95. These have all been verified as far as possible. While some errors might remain, they are hopefully very few. I have a debt of gratitude to a number of people who have checked the manuscript or discussed problems with me. My wife Sandra polished my Eng- lish style and helped with some of the mathematics, and Tom Koch Sven- nesen checked many of the mathematical equations. Others I have consulted for advice of various kinds are Professor Dr. Bertel Kastening, Drs. Leslaw Bieniasz, Ole Østerby, J¨org Strutwolf and Thomas Britz. I thank the various editors at Springer for their support and patience. If I have left anybody out, I apologize. As is customary to say (and true), any errors remaining in the book cannot be blamed on anybody but myself.
Arhus,˚ Dieter Britz February 2005
Contents
1 Introduction ...... 1
2 Basic Equations ...... 5 2.1 General...... 5 2.2 SomeMathematics:TransportEquations...... 6 2.2.1 Diffusion...... 6 2.2.2 DiffusionCurrent...... 7 2.2.3 Convection...... 8 2.2.4 Migration...... 9 2.2.5 Total Transport Equation ...... 10 2.2.6 HomogeneousKinetics...... 10 2.2.7 HeterogeneousKinetics ...... 12 2.3 Normalisation – Making the Variables Dimensionless ...... 12 2.4 SomeModelSystemsandTheirNormalisations ...... 14 2.4.1 PotentialSteps...... 14 2.4.2 ConstantCurrent ...... 24 2.4.3 LinearSweepVoltammetry(LSV)...... 25 2.5 AdsorptionKinetics ...... 28
3 Approximations to Derivatives ...... 33 3.1 ApproximationOrder...... 33 3.2 Two-PointFirstDerivativeApproximations...... 34 3.3 Multi-PointFirstDerivativeApproximations...... 36 3.4 TheCurrentApproximation...... 38 3.5 The Current Approximation Function G ...... 39 3.6 High-Order Compact (Hermitian) Current Approximation . . . 39 3.7 SecondDerivativeApproximations...... 43 3.8 DerivativesonUnevenlySpacedPoints...... 44 3.8.1 ErrorOrders...... 47 3.8.2 ASpecialCase...... 48 3.8.3 CurrentApproximation...... 48 3.8.4 ASpecificApproximation...... 48 X Contents
4 Ordinary Differential Equations...... 51 4.1 An Example ode ...... 51 4.2 LocalandGlobalErrors...... 52 4.3 WhatDistinguishestheMethods...... 52 4.4 EulerMethod...... 52 4.5 Runge-Kutta,RK...... 54 4.6 BackwardsImplicit,BI...... 56 4.7 TrapeziumorMidpointMethod...... 56 4.8 BackwardDifferentiationFormula,BDF...... 57 4.8.1 StartingBDF...... 58 4.9 Extrapolation...... 61 4.10Kimble&White,KW...... 62 4.10.1UsingKWasaStartforBDF ...... 64 4.11 Systems of odes ...... 65 4.12RosenbrockMethods...... 67 4.12.1ApplicationtoaSimpleExampleODE...... 70 4.12.2ErrorEstimates...... 71
5 The Explicit Method ...... 73 5.1 TheDiscretisation...... 73 5.2 Practicalities...... 74 5.3 Chronoamperometryand-Potentiometry...... 76 5.4 Homogeneous Chemical Reactions (hcr)...... 77 5.4.1 TheReactionLayer...... 79 5.5 LinearSweepVoltammetry...... 80 5.5.1 Boundary Condition Handling ...... 81
6 Boundary Conditions ...... 85 6.1 Classification of Boundary Conditions ...... 85 6.2 Single Species: The u-v Device...... 86 6.2.1 DirichletCondition...... 86 6.2.2 DerivativeBoundaryConditions...... 86 6.3 TwoSpecies...... 90 6.3.1 Two-PointDerivativeCases...... 93 6.4 Two Species with Coupled Reactions. U-V ...... 94 6.5 BruteForce...... 100 6.6 AGeneralFormalism...... 101
7 Unequal Intervals ...... 103 7.1 Transformation...... 104 7.1.1 DiscretisingtheTransformedEquation...... 105 7.1.2 TheChoiceofParameters...... 107 7.2 DirectApplicationofanArbitraryGrid...... 107 7.2.1 ChoiceofParameters...... 110 7.3 Concluding Remarks on Unequal Spatial Intervals ...... 110 Contents XI
7.4 UnequalTimeIntervals ...... 111 7.4.1 Implementation of Exponentially Increasing Time Intervals ...... 112 7.5 AdaptiveIntervalChanges...... 112 7.5.1 Spatial Interval Adaptation ...... 113 7.5.2 TimeIntervalAdaptation ...... 116
8 The Commonly Used Implicit Methods ...... 119 8.1 TheLaasonenMethodorBI...... 121 8.2 TheCrank-NicolsonMethod,CN...... 121 8.3 Solving the Implicit System ...... 122 8.4 UsingFour-PointSpatialSecondDerivatives...... 124 8.5 Improvements on CN and Laasonen ...... 126 8.5.1 Damping the CN Oscillations ...... 127 8.5.2 Making Laasonen More Accurate ...... 131 8.6 HomogeneousChemicalReactions...... 134 8.6.1 NonlinearEquations...... 135 8.6.2 CoupledEquations...... 140
9 Other Methods ...... 145 9.1 TheBoxMethod...... 145 9.2 ImprovementsonStandardMethods...... 148 9.2.1 TheKimbleandWhiteMethod...... 148 9.2.2 Multi-PointSecondSpatialDerivatives...... 151 9.2.3 DuFort-Frankel ...... 152 9.2.4 Saul’yev...... 154 9.2.5 Hopscotch...... 156 9.2.6 Runge-Kutta ...... 158 9.2.7 HermitianMethods...... 159 9.3 Method of Lines (MOL) and Differential Algebraic Equations (DAE) ...... 165 9.4 TheRosenbrockMethod ...... 167 9.4.1 AnExample,theBirk-PeroneSystem...... 170 9.5 FEM,BEMandFAM(briefly)...... 172 9.6 Orthogonal Collocation, OC ...... 173 9.6.1 CurrentCalculationwithOC...... 180 9.6.2 ANumericalExample ...... 180 9.7 Eigenvalue-EigenvectorMethod ...... 182 9.8 IntegralEquationMethod...... 184 9.9 TheNetworkMethod...... 185 9.10TreanorMethod...... 186 9.11MonteCarloMethod...... 187 XII Contents
10 Adsorption ...... 189 10.1TransportandIsothermLimitedAdsorption...... 190 10.2 Adsorption Rate Limited Adsorption ...... 191
11 Effects Due to Uncompensated Resistance and Capacitance ...... 193 11.1 Boundary Conditions ...... 195 11.1.1AnExample...... 197
12 Two-Dimensional Systems ...... 201 12.1Theories...... 202 12.1.1TheUltramicrodiskElectrode,UMDE...... 202 12.1.2OtherMicroelectrodes ...... 208 12.1.3SomeRelations ...... 209 12.2Simulations...... 210 12.3SimulatingtheUMDE...... 212 12.3.1DirectDiscretisation...... 213 12.3.2DiscretisationintheMappedSpace...... 221 12.3.3 A Remark on the Boundary Conditions ...... 232
13 Convection ...... 235 13.1SomeFluidDynamics...... 235 13.1.1LayerRelations...... 239 13.2ElectrodesinFlowSystems...... 239 13.3Simulations...... 240 13.4 A Simple Example: The Band Electrode inaChannelFlow...... 241 13.5Normalisations...... 242
14 Performance ...... 247 14.1Convergence...... 247 14.2Consistency...... 250 14.3 Stability ...... 251 14.3.1HeuristicMethod...... 251 14.3.2 Von Neumann Stability Analysis ...... 252 14.3.3 Matrix Stability Analysis ...... 254 14.3.4SomeSpecialCases...... 260 14.4 The Stability Function ...... 261 14.5AccuracyOrder...... 263 14.5.1OrderDetermination ...... 264 14.6Accuracy,EfficiencyandChoice...... 266 14.7SummaryofMethods...... 270 Contents XIII
15 Programming ...... 273 15.1LanguageandStyle...... 273 15.2Debugging...... 274 15.3Libraries...... 275
16 Simulation Packages ...... 277
A Tables and Formulae ...... 281 A.1 FirstDerivativeApproximations...... 281 A.2 CurrentApproximations...... 282 A.3 SecondDerivativeApproximations...... 282 A.4 UnequalIntervals...... 282 A.4.1 FirstDerivatives ...... 283 A.4.2 SecondDerivatives ...... 284 A.5 Jacobi Roots for Orthogonal Collocation ...... 285 A.6 RosenbrockConstants...... 285
B Some Mathematical Proofs ...... 289 B.1 ConsistencyoftheSequentialMethod...... 289 B.2 TheFeldbergStartforBDF...... 290 B.3 Similarity of the Feldberg Expansion andTransformationFunctions ...... 295
C Procedure and Program Examples ...... 299 C.1 ExampleModules ...... 299 C.2 Procedures ...... 301 C.2.1 ProceduresforUnequalIntervals...... 302 C.2.2 JCOBI...... 304 C.3 ExamplePrograms ...... 304
References ...... 313
Erratum ...... E1
Index ...... 331 1 Introduction
This book is about the application of digital simulation to electrochemical problems. What is digital simulation? The term “simulation” came into wide use with the advent of analog computers, which could produce electrical signals that followed mathematical functions to describe or model a given physical system. When digital computers became common, people began to do these simulations digitally and called this digital simulation. What sort of systems do we simulate in electrochemistry? Most commonly they are electrochemical transport problems that we find difficult to solve, in all but a few model systems – when things get more complicated, as they do in real electrochemical cells, problems may not be solvable algebraically, yet we still want answers. Most commonly, the basic equation we need to solve is the diffusion equa- tion, relating concentration c to time t and distance x from the electrode surface, given the diffusion coefficient D:
∂c ∂2c = D . (1.1) ∂t ∂x2 This is Fick’s second diffusion equation [242], an adaptation to diffusion of the heat transfer equation of Fourier [253]. Technically, it is a second-order parabolic partial differential equation (pde). In fact, it will mostly be only the skeleton of the actual equation one needs to solve; there will usually be such complications as convection (solution moving) and chemical reactions taking place in the solution, which will cause concentration changes in addition to diffusion itself. Numerical solution may then be the only way we can get numbers from such equations – hence digital simulation. The numerical technique most commonly employed in digital simulation is (broadly speaking) that of finite differences and this is much older than the digital computer. It dates back at least to 1911 [468] (Richardson). In 1928, Courant, Friedrichs and Lewy [182] described what we now take to be the essentials of the method; Emmons [218] wrote a detailed description of finite difference methods in 1944, applied to several different equation types. There is no shortage of mathematical texts on the subject: see, for example, Lapidus and Pinder [350] and Smith [514], two excellent books out of a large number.
Dieter Britz: Digital Simulation in Electrochemistry, Lect. Notes Phys. 666,1–4 (2005) www.springerlink.com c Springer-Verlag Berlin Heidelberg 2005 2 1 Introduction
It should not be imagined that the technique became used only when dig- ital computers appeared; engineers certainly used it long before that time, and were not afraid to spend hours with pencil and paper. Emmons [218] casually mentions that one fluid flow problem took him 36 hours! Not surpris- ingly, it was during this early pre-computer era that much of the theoretical groundwork was laid and refinements worked out to make the work easier – those early stalwarts wanted their answers as quickly as possible, and they wanted them correct the first time through. Electrochemical digital simulation is almost synonymous with Stephen Feldberg, who wrote his first paper on it in 1964 [234]. It is not always remembered that Randles [460] used the technique much earlier (in 1948), to solve the linear sweep problem. He did not have a computer and did the arithmetic by hand. The most widely quoted electrochemical literature source is Feldberg’s chapter in Electroanalytical Chemistry [229], which describes what will here be called the “box” method. Feldberg is rightly regarded as the pioneer of digital simulation in electrochemistry, and is still prominent in developments in the field today. This has also meant that the box method has become standard practice among electrochemists, while what will here be called the “point” method is more or less standard elsewhere. Having experimented with both, the present author favours the point method for the ease with which one arrives at the discrete form of one’s equations, especially when the differential equation is complicated. A brief description will now be given of the essentials of the simulation technique. Assume (1.1) above. We wish to obtain concentration values at a given time over a range of distances from the electrode. We divide space (the x coordinate) into small intervals of length h and time t into small time steps δt. Both x and t can then be expressed as multiples of h and δt,usingi as the index along x and j as that for t,sothat
xi = ih (1.2) and tj = jδt . (1.3)
Figure 1.1 shows the resulting grid of points. At each drawn point, there is a value of c. The digital simulation method now consists of developing rows of c values along x, (usually) one t-step at a time. Let us focus on the three filled-circle points ci−1, ci and ci+1 at time tj. One of the various techniques to be described will compute from these three known points a new concentration value ci = ci(t =(j +1)δt) (empty circle) at xi for the next time value tj+1, by expressing (1.1) in discrete form: − ci ci D = (c − − 2c + c ) . (1.4) δt h2 i 1 i i+1 1 Introduction 3
Fig. 1.1. Discrete sample point grid