Table Of ContentNumerical Methods for Chemical Engineering
Suitableforafirst-yeargraduatecourse,thistextbookunitestheapplicationsofnumerical
mathematicsandscientificcomputingtothepracticeofchemicalengineering.Writtenin
apedagogicstyle,thebookdescribesbasiclinearandnonlinearalgebraicsystemsallthe
way through to stochastic methods, Bayesian statistics, and parameter estimation. These
subjectsaredevelopedatanominalleveloftheoreticalmathematicssuitableforgraduate
engineers. The implementation of numerical methods in M® is integrated within
eachchapterandnumerousexamplesinchemicalengineeringareprovided,togetherwitha
libraryofcorrespondingM programs.Althoughtheapplicationsfocusonchemical
engineering,thetreatmentofthetopicsshouldalsobeofinteresttonon-chemicalengineers
andotherappliedscientiststhatworkwithscientificcomputing.Thisbookwillprovidethe
graduatestudentwiththeessentialtoolsrequiredbyindustryandresearchalike.
Supplementary material includes solutions to homework problems set in the text,
M programs and tutorial, lecture slides, and complicated derivations for the more
advancedreader.Theseareavailableonlineatwww.cambridge.org/9780521859714.
K JB hasbeenAssistantProfessoratMITsince2000.Hehastaughtexten-
sivelyacrosstheengineeringdisciplineatboththeundergraduateandgraduatelevel.This
bookisaresultofthesuccessfulcoursetheauthordevisedatMITfornumericalmethods
appliedtochemicalengineering.
Numerical Methods for
Chemical Engineering
Applications in M ®
ATLAB
KENNETH J. BEERS
MassachusettsInstituteofTechnology
Cambridge,NewYork,Melbourne,Madrid,CapeTown,Singapore,Sa˜oPaulo
CambridgeUniversityPress
TheEdinburghBuilding,CambridgeCB22RU,UK
PublishedintheUnitedStatesofAmericabyCambridgeUniversityPress,NewYork
www.cambridge.org
Informationonthistitle:www.cambridge.org/9780521859714
(cid:1)C K.J.Beers2007
Thispublicationisincopyright.Subjecttostatutoryexception
andtotheprovisionsofrelevantcollectivelicensingagreements,
noreproductionofanypartmaytakeplacewithout
thewrittenpermissionofCambridgeUniversityPress.
Firstpublished2007
PrintedintheUnitedKingdomattheUniversityPress,Cambridge
AcatalogrecordforthispublicationisavailablefromtheBritishLibrary
ISBN-13 978-0-521-85971-4hardback
ISBN-10 0-521-85971-9hardback
CambridgeUniversityPresshasnoresponsibilityforthepersistenceoraccuracyofURLsfor
externalorthird-partyinternetwebsitesreferredtointhispublication,anddoesnotguaranteethat
anycontentonsuchwebsitesis,orwillremain,accurateorappropriate.
Contents
Preface pageix
1 Linearalgebra 1
Linearsystemsofalgebraicequations 1
Reviewofscalar,vector,andmatrixoperations 3
Eliminationmethodsforsolvinglinearsystems 10
Existenceanduniquenessofsolutions 23
Thedeterminant 32
Matrixinversion 36
Matrixfactorization 38
Matrixnormandrank 44
Submatricesandmatrixpartitions 44
Example.Modelingaseparationsystem 45
Sparseandbandedmatrices 46
MATLABsummary 56
Problems 57
2 Nonlinearalgebraicsystems 61
Existenceanduniquenessofsolutionstoanonlinearalgebraicequation 61
IterativemethodsandtheuseofTaylorseries 62
Newton’smethodforasingleequation 63
Thesecantmethod 69
Bracketingandbisectionmethods 70
Findingcomplexsolutions 70
Systemsofmultiplenonlinearalgebraicequations 71
Newton’smethodformultiplenonlinearequations 72
EstimatingtheJacobianandquasi-Newtonmethods 77
Robustreduced-stepNewtonmethod 79
Thetrust-regionNewtonmethod 81
SolvingnonlinearalgebraicsystemsinMATLAB 83
Example.1-Dlaminarflowofashear-thinningpolymermelt 85
Homotopy 88
Example.Steady-statemodelingofacondensation
polymerizationreactor 89
v
vi Contents
Bifurcationanalysis 94
MATLABsummary 98
Problems 99
3 Matrixeigenvalueanalysis 104
Orthogonalmatrices 104
Aspecificexampleofanorthogonalmatrix 105
Eigenvaluesandeigenvectorsdefined 106
Eigenvalues/eigenvectorsofa2×2realmatrix 107
Multiplicityandformulasforthetraceanddeterminant 109
Eigenvaluesandtheexistence/uniquenesspropertiesoflinear
systems 110
Estimatingeigenvalues;Gershgorin’stheorem 111
ApplyingGershgorin’stheoremtostudytheconvergenceofiterative
linearsolvers 114
Eigenvectormatrixdecompositionandbasissets 117
NumericalcalculationofeigenvaluesandeigenvectorsinMATLAB 123
Computingextremaleigenvalues 126
TheQRmethodforcomputingalleigenvalues 129
Normalmodeanalysis 134
Relaxingtheassumptionofequalmasses 136
Eigenvalueproblemsinquantummechanics 137
SinglevaluedecompositionSVD 141
Computingtherootsofapolynomial 148
MATLABsummary 149
Problems 149
4 Initialvalueproblems 154
Initialvalueproblemsofordinarydifferentialequations
(ODE-IVPs) 155
Polynomialinterpolation 156
Newton–Cotesintegration 162
Gaussianquadrature 163
Multidimensionalintegrals 167
LinearODEsystemsanddynamicstability 169
OverviewofODE-IVPsolversinMATLAB 176
Accuracyandstabilityofsingle-stepmethods 185
StiffstabilityofBDFmethods 192
Symplecticmethodsforclassicalmechanics 194
Differential-algebraicequation(DAE)systems 195
Parametriccontinuation 203
MATLABsummary 207
Problems 208
Contents vii
5 Numericaloptimization 212
Localmethodsforunconstrainedoptimizationproblems 212
Thesimplexmethod 213
Gradientmethods 213
Newtonlinesearchmethods 223
Trust-regionNewtonmethod 225
Newtonmethodsforlargeproblems 227
UnconstrainedminimizerfminuncinMATLAB 228
Example.Fittingakineticratelawtotime-dependentdata 230
Lagrangianmethodsforconstrainedoptimization 231
ConstrainedminimizerfminconinMATLAB 242
Optimalcontrol 246
MATLABsummary 252
Problems 252
6 Boundaryvalueproblems 258
BVPsfromconservationprinciples 258
Real-spacevs.function-spaceBVPmethods 260
Thefinitedifferencemethodappliedtoa2-DBVP 260
Extendingthefinitedifferencemethod 264
Chemicalreactionanddiffusioninasphericalcatalystpellet 265
Finitedifferencesforaconvection/diffusionequation 270
Modelingatubularchemicalreactorwithdispersion;treating
multiplefields 279
NumericalissuesfordiscretizedPDEswithmorethantwo
spatialdimensions 282
TheMATLAB1-Dparabolicandellipticsolverpdepe 294
Finitedifferencesincomplexgeometries 294
Thefinitevolumemethod 297
Thefiniteelementmethod(FEM) 299
FEMinMATLAB 309
FurtherstudyinthenumericalsolutionofBVPs 311
MATLABsummary 311
Problems 312
7 Probabilitytheoryandstochasticsimulation 317
Thetheoryofprobability 317
Importantprobabilitydistributions 325
Randomvectorsandmultivariatedistributions 336
Browniandynamicsandstochasticdifferentialequations
(SDEs) 338
Markovchainsandprocesses;MonteCarlomethods 353
Geneticprogramming 362
viii Contents
MATLABsummary 364
Problems 365
8 Bayesianstatisticsandparameterestimation 372
Generalproblemformulation 372
Example.Fittingkineticparametersofachemicalreaction 373
Single-responselinearregression 377
Linearleast-squaresregression 378
TheBayesianviewofstatisticalinference 381
Theleast-squaresmethodreconsidered 388
Selectingapriorforsingle-responsedata 389
Confidenceintervalsfromtheapproximateposteriordensity 395
MCMCtechniquesinBayesiananalysis 403
MCMCcomputationofposteriorpredictions 404
Applyingeigenvalueanalysistoexperimentaldesign 412
Bayesianmultiresponseregression 414
Analysisofcompositedatasets 421
Bayesiantestingandmodelcriticism 426
Furtherreading 431
MATLABsummary 431
Problems 432
9 Fourieranalysis 436
Fourierseriesandtransformsinonedimension 436
1-DFouriertransformsinMATLAB 445
Convolutionandcorrelation 447
Fouriertransformsinmultipledimensions 450
Scatteringtheory 452
MATLABsummary 459
Problems 459
References 461
Index 464
Preface
Thistextfocusesontheapplicationofquantitativeanalysistothefieldofchemicalengi-
neering. Modern engineering practice is becoming increasingly more quantitative, as the
useofscientificcomputingbecomesevermorecloselyintegratedintothedailyactivities
ofallengineers.Itisnolongerthedomainofasmallcommunityofspecialistpractitioners.
Whereasinthepast,onehadtohand-craftaprogramtosolveaparticularproblem,carefully
husbandingthelimitedmemoryandCPUcyclesavailable,nowwecanveryquicklysolvefar
morecomplexproblemsusingpowerful,widely-availablesoftware.Thishasintroducedthe
needforresearchengineersandscientiststobecomecomputationallyliterate–toknowthe
possibilitiesthatexistforapplyingcomputationtotheirproblems,tounderstandthebasic
ideasbehindthemostimportantalgorithmssoastomakewisechoiceswhenselectingand
tuningthem,andtohavethefoundationalknowledgenecessarytonavigateindependently
throughtheliterature.
This text meets this need, and is written at the level of a first-year graduate student
inchemicalengineering,aconsequenceofitsdevelopmentforuseatMITforthecourse
10.34, “Numerical methods applied to chemical engineering.” This course was added in
2001tothegraduatecorecurriculumtoprovideallfirst-yearMastersandPh.D.students
withanoverviewofquantitativemethodstoaugmenttheexistingcorecoursesintransport
phenomena,thermodynamics,andchemicalreactionengineering.Carehasbeentakento
develop any necessary material specific to chemical engineering, so this text will prove
usefultootherengineeringandscientificfieldsaswell.Thereaderisassumedtohavetaken
the traditional undergraduate classes in calculus and differential equations, and to have
®
someexperienceincomputerprogramming,althoughnotnecessarilyinMATLAB .
Even a cursory search of the holdings of most university libraries shows there to be a
greatnumberoftextswithtitlesthatarevariationsof“AdvancedEngineeringMathematics”
or“NumericalMethods.”Sowhyaddyetanother?
I find that there are two broad classes of texts in this area. The first focuses on intro-
ducing numerical methods, applied to science and engineering, at the level of a junior
orseniorundergraduateelectivecourse.Thescopeisnecessarilylimitedtorathersimple
techniquesandapplications.Thesecondclassistargetedtoresearch-levelworkers,either
higher graduate-level applied mathematicians or computationally-focused researchers in
scienceandengineering.Thesemaybeeitheradvancedtreatmentsofnumericalmethods
formathematicians,ordetaileddiscussionsofscientificcomputingasappliedtoaspecific
subjectsuchasfluidmechanics.
ix
x Preface
Neitheroftheseclassesoftextisappropriateforteachingthefundamentalsofscientific
computingtobeginningchemicalengineeringgraduatestudents.Examplesshouldbetyp-
ical of those encountered in graduate-level chemical engineering research, and while the
studentsshouldgainanunderstandingofthebasisofeachmethodandanappreciationof
itslimitations,theydonotneedexhaustivetheory-prooftreatmentsofconvergence,error
analysis, etc. It is a challenge for beginning students to identify how their own problems
maybemappedintoonesamenabletoquantitativeanalysis;therefore,anyappropriatetext
shouldhaveanextensivelibraryofworkedexamples,withcodeavailabletoservelateras
templates.Finally,thetextshouldaddresstheimportanttopicsofmodeldevelopmentand
parameterestimation.Thisbookhasbeendevelopedwiththeseneedsinmind.
Thistextfirstpresentsafundamentaldiscussionoflinearalgebra,toprovidethenecessary
foundationtoreadtheappliedmathematicalliteratureandprogressfurtheronone’sown.
Next, a broad array of simulation techniques is presented to solve problems involving
systems of nonlinear algebraic equations, initial value problems of ordinary differential
anddifferential-algebraic(DAE)systems,optimizations,andboundaryvalueproblemsof
ordinary and partial differential equations. A treatment of matrix eigenvalue analysis is
included,asitisfundamentaltoanalyzingthesesimulationtechniques.
Nextfollowsadetaileddiscussionofprobabilitytheory,stochasticsimulation,statistics,
andparameterestimation.Asengineeringbecomesmorefocuseduponthemolecularlevel,
stochasticsimulationtechniquesgaininimportance.ParticularattentionispaidtoBrownian
dynamics,stochasticcalculus,andMonteCarlosimulation.Statisticsandparameteresti-
mationareaddressedfromaBayesianviewpoint,inwhichMonteCarlosimulationprovesa
powerfulandgeneraltoolformakinginferencesandtestinghypothesesfromexperimental
data.
In each of these areas, topically relevant examples are given, along with MATLAB
(www.mathworks.com)programsthatservethestudentsastemplateswhenlaterwriting
their own code. An accompanying website includes a MATLAB tutorial, code listings of
all examples, and a supplemental material section containing further detailed proofs and
optionaltopics.Ofcourse,whilesignificantefforthasgoneintotestingandvalidatingthese
programs,noguaranteeisprovidedandthereadershouldusethemwithcaution.
Theproblemsaregradedbydifficultyandlengthineachchapter.ThoseofgradeAare
simple and can be done easily by hand or with minimal programming. Those of grade B
requiremoreprogrammingbutarestillratherstraightforwardextensionsorimplementations
oftheideasdiscussedinthetext.ThoseofgradeCeitherinvolvesignificantthinkingbeyond
thecontentpresentedinthetextorprogrammingeffortatalevelbeyondthattypicalofthe
examplesandgradeBproblems.
Thesubjectscoveredarebroadinscope,leadingtotheconsiderable(thoughhopefully
notexcessive)lengthofthistext.Thefocusisuponprovidingafundamentalunderstanding
oftheunderlyingnumericalalgorithmswithoutnecessarilyexhaustivelytreatingalloftheir
details,variations,andcomplexitiesofuse.Masteryofthematerialinthistextshouldenable
first-yeargraduatestudentstoperformoriginalworkinapplyingscientificcomputationto
their research, and to read the literature to progress independently to the use of more
sophisticatedtechniques.
Description:In August 2003, ETHZ Computational Laboratory (CoLab), together with the Swiss Center for Scientific Computing in Manno and the Università della Svizzera Italiana (USI), organized the Summer School in "Multiscale Modelling and Simulation" in Lugano, Switzerland. This summer school brought together