You are on page 1of 284

Computation

Visualization
Programming
Parti al Di fferenti al Equati on
Tool box
For Use with MATLAB

User s Gui de
Computer Solutions Europe AB
How to Contact The MathWorks:
508-647-7000 Phone
508-647-7001 Fax
The MathWorks, I nc. Mai l
24 Pri me Park Way
Nati ck, MA 01760-1500
http://www.mathworks.com Web
ftp.mathworks.com Anonymous FTP ser ver
comp.soft-sys.matlab Newsgroup
support@mathworks.com Techni cal support
suggest@mathworks.com Product enhancement suggesti ons
bugs@mathworks.com Bug r epor ts
doc@mathworks.com Documentati on err or r epor ts
subscribe@mathworks.com Subscr i bi ng user r egi strati on
service@mathworks.com Or der status, l i cense renewal s, passcodes
info@mathworks.com Sal es, pr i ci ng, and gener al i nformati on
Partial Differential Equation Toolbox Users Guide
COPYRI GHT 1984 - 1997 by The MathWor ks, I nc. Al l Ri ghts Reser ved.
The softwar e descr i bed i n thi s document i s fur ni shed under a l i cense agr eement. The softwar e may be used
or copied onl y under the ter ms of the l i cense agr eement. No par t of thi s manual may be photocopi ed or r epr o-
duced i n any for m wi thout pr i or wr i tten consent fr om The MathWorks, I nc.
U.S. GOVERNMENT: I f Li censee is acqui r i ng the Pr ogr ams on behal f of any uni t or agency of the U.S.
Gover nment, the fol l owi ng shal l appl y: (a) For uni ts of the Depar tment of Defense: the Gover nment shal l
have onl y the r i ghts speci fi ed i n the l i cense under whi ch the commer ci al computer softwar e or commer ci al
softwar e documentati on was obtained, as set for th in subpar agr aph (a) of the Ri ghts in Commerci al
Computer Softwar e or Commer ci al Softwar e Documentati on Cl ause at DFARS 227.7202-3, ther efor e the
r i ghts set for th her ei n shal l appl y; and (b) For any other unit or agency: NOTI CE: Notwi thstandi ng any
other l ease or l i cense agr eement that may per tai n to, or accompany the del i ver y of, the computer softwar e
and accompanyi ng documentati on, the r i ghts of the Gover nment r egar di ng i ts use, repr oducti on, and di scl o-
sur e ar e as set for th in Cl ause 52.227-19 (c)(2) of the FAR.
MATLAB, Si muli nk, Handle Gr aphi cs, and Real -Ti me Wor kshop ar e r egi ster ed trademar ks and Statefl ow
and Tar get Language Compi ler ar e tr ademar ks of The MathWor ks, I nc.
Other pr oduct or br and names are tr ademar ks or r egister ed tr ademar ks of thei r r espective hol ders.
Pr i nti ng Hi stor y: August 1995 Fi rst pri nti ng
Febr uar y 1996 Repr i nt

FAX
u
@
i
Contents
1
Tutorial
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
What Does thi s Tool box Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Can I Use the PDE Tool box? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
What Probl ems Can I Sol ve? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
I n Whi ch Areas Can the Tool box Be Used? . . . . . . . . . . . . . . . . . 1-5
How Do I Defi ne a PDE Probl em? . . . . . . . . . . . . . . . . . . . . . . . . 1-5
How Can I Sol ve a PDE Pr obl em? . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Can I Use the Tool box for Nonstandard Pr obl ems? . . . . . . . . . . 1-6
How Can I Vi sual i ze My Resul ts? . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Are There Any Appl i cati ons Al r eady I mpl emented? . . . . . . . . . . 1-7
Can I Extend the Functi onal i ty of the Tool box? . . . . . . . . . . . . . 1-7
How Can I Sol ve 3-D Probl ems by 2-D Model s? . . . . . . . . . . . . . 1-8
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Basics of The Finite Element Method . . . . . . . . . . . . . . . . . . .1-18
Using the Graphical User Interface . . . . . . . . . . . . . . . . . . . . .1-23
The PDE Tool box Gr aphi cal User I nter face . . . . . . . . . . . . . . .1-23
The Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-24
The Tool bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-25
The GUI Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-26
The CSG Model and the Set Formul a . . . . . . . . . . . . . . . . . . . .1-27
Creati ng Rounded Corners . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-28
Suggested Model i ng Method . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-31
Object Sel ecti on Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-35
Di spl ay Addi ti onal I nfor mati on . . . . . . . . . . . . . . . . . . . . . . . . .1-35
Enter i ng Par ameter Val ues as MATLAB Expressi ons . . . . . . .1-36
Usi ng PDE Tool box versi on 1.0 Model M-fi l es . . . . . . . . . . . . . .1-36
ii Contents
Using Command-Line Functions . . . . . . . . . . . . . . . . . . . . . . . 1-37
Data Structures and Uti l i ty Functi ons . . . . . . . . . . . . . . . . . . . 1-37
Constr ucti ve Sol i d Geometry Model . . . . . . . . . . . . . . . . . . . 1-38
Decomposed Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
Boundar y Condi ti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
Equati on Coeffi ci ents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
Sol uti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40
Post Pr ocessi ng and Presentati on . . . . . . . . . . . . . . . . . . . . . 1-40
Hi nts and Suggesti ons for Usi ng Command-Li ne
Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40
2
Examples
Examples of Elliptic Problems . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Poi ssons Equati on on Uni t Di sk . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . . 2-2
Usi ng Command-Li ne Functi ons . . . . . . . . . . . . . . . . . . . . . . 2-4
A Scatter i ng Pr obl em . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . . 2-8
A Mi ni mal Surface Probl em . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-10
Usi ng Command-Li ne Functi ons . . . . . . . . . . . . . . . . . . . . . 2-11
Domai n Decomposi ti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Examples of Parabolic Problems. . . . . . . . . . . . . . . . . . . . . . . 2-16
The Heat Equati on: A Heated Metal Bl ock . . . . . . . . . . . . . . . . 2-16
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-17
Usi ng Command-Li ne Functi ons . . . . . . . . . . . . . . . . . . . . . 2-19
Heat Di str i buti on i n Radi oacti ve Rod . . . . . . . . . . . . . . . . . . . . 2-21
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-22
Examples of Hyperbolic Problems . . . . . . . . . . . . . . . . . . . . . 2-23
The Wave Equati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-23
Usi ng Command-Li ne Functi ons . . . . . . . . . . . . . . . . . . . . . 2-25
iii
Examples of Eigenvalue Problems . . . . . . . . . . . . . . . . . . . . . 2-27
Ei genval ues and Ei genfuncti ons for the L-Shaped
Membrane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-27
Usi ng Command-Li ne Functi ons . . . . . . . . . . . . . . . . . . . . . 2-28
L-Shaped Membrane wi th Rounded Corner . . . . . . . . . . . . . . . 2-31
Ei genval ues and Ei genmodes of a Square . . . . . . . . . . . . . . . . 2-32
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-33
Usi ng Command-Li ne Functi ons . . . . . . . . . . . . . . . . . . . . . 2-33
Application Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
The Appl i cati on Modes and the GUI . . . . . . . . . . . . . . . . . . . . . 2-35
Str uctur al Mechani cs - Pl ane Str ess . . . . . . . . . . . . . . . . . . . . . 2-36
Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-39
Str uctur al Mechani cs - Pl ane Str ai n . . . . . . . . . . . . . . . . . . . . 2-41
El ectr ostati cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-44
Magnetostati cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-48
AC Power El ectromagneti cs . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51
Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-52
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-53
Conducti ve Medi a DC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-55
Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-55
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-56
Heat Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-57
Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-58
Usi ng the Graphi cal User I nterface . . . . . . . . . . . . . . . . . . . 2-59
Di ffusi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-61
iv Contents
3
The Graphical User Interface
PDE Toolbox Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Fi l e Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
New . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Save As . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Pr i nt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Edi t Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Opti ons Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Gr i d Spaci ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Axes Li mi ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Appl i cati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Dr aw Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Rotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Boundar y Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Speci fy Boundary Condi ti ons . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
PDE Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
PDE Speci fi cati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Mesh Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Parameter s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Sol ve Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
Parameter s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
Pl ot Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Parameter s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Addi ti onal Pl ot Contr ol Opti ons . . . . . . . . . . . . . . . . . . . . . . 3-34
Wi ndow Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
Hel p Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
The Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-38
v
4
The Finite Element Method
The Elliptic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
The Elliptic System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
The Parabolic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
The Hyperbolic Equation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
The Eigenvalue Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
Nonlinear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
Adaptive Mesh Refinement . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
The Er ror I ndi cator Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
The Mesh Refi ner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-27
The Termi nati on Cr i teri a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
Fast Solution of Poissons Equation . . . . . . . . . . . . . . . . . . . . 4-29
vi Contents
5
Reference
Commands Grouped by Function . . . . . . . . . . . . . . . . . . . . . . . 5-3
PDE Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
User I nter face Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Geometry Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Pl ot Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Uti l i ty Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
User Defi ned Al gor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Demonstrati on Pr ograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
PDE Coeffi ci ents for Scal ar Case . . . . . . . . . . . . . . . . . . . . . 5-20
PDE Coeffi ci ents for System Case . . . . . . . . . . . . . . . . . . . . 5-21
Boundar y Condi ti on Di al og Box . . . . . . . . . . . . . . . . . . . . . . 5-80
Model M-fi l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-81
Index

1
Tutori al
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
What Does thi s Tool box Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Can I Use the PDE Tool box? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
What Pr obl ems Can I Sol ve? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
I n Whi ch Ar eas Can the Tool box Be Used? . . . . . . . . . . . . . . . . . 1-5
How Do I Defi ne a PDE Pr obl em? . . . . . . . . . . . . . . . . . . . . . . . . 1-5
How Can I Sol ve a PDE Probl em? . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Can I Use the Tool box for Nonstandar d Probl ems? . . . . . . . . . . 1-6
How Can I Vi sual i ze My Resul ts? . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Ar e Ther e Any Appl i cati ons Al ready I mpl emented? . . . . . . . . . 1-7
Can I Extend the Functi onal i ty of the Tool box? . . . . . . . . . . . . . 1-7
How Can I Sol ve 3-D Pr obl ems by 2-D Model s? . . . . . . . . . . . . . 1-8
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Basics of The Finite Element Method . . . . . . . . . . . . . . . . . 1-18
Using the Graphical User Interface . . . . . . . . . . . . . . . . . . 1-23
The PDE Tool box Graphi cal User I nterface . . . . . . . . . . . . . . . 1-23
The Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
The Tool bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25
The GUI Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
The CSG Model and the Set For mul a . . . . . . . . . . . . . . . . . . . . 1-27
Cr eati ng Rounded Cor ner s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28
Suggested Model i ng Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
Object Sel ecti on Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
Di spl ay Addi ti onal I nformati on . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
Enteri ng Parameter Val ues as MATLAB Expr essi ons . . . . . . . 1-36
Usi ng PDE Tool box ver si on 1.0 Model M-fi l es . . . . . . . . . . . . . 1-36
Using Command-Line Functions . . . . . . . . . . . . . . . . . . . . . 1-37
Data Structures and Utility Functions . . . . . . . . . . . . . . . 1-37
Hi nts and Suggesti ons for Usi ng Command-Li ne Functi on . . . 1-40
1 Tutori al
1-2
Introduction
Thi s secti on attempts to answer some of the questi ons you mi ght formul ate
when you turn the fi r st page: What does thi s tool box do? Can I use i t? What
pr obl ems can I sol ve?, etc.
What Does this Toolbox Do?
The Parti al Di ffer enti al Equati on (PDE) Tool box pr ovi des a power ful and
fl exi bl e envi ronment for the study and sol uti on of parti al di ffer enti al equati ons
i n two space di mensi ons and ti me. The equati ons ar e di scr eti zed by the Fi ni te
El ement Method (FEM). The objecti ves of the PDE Tool box ar e to provi de you
wi th tool s that:
Defi ne a PDE pr obl em, i .e., defi ne 2-D regi ons, boundar y condi ti ons, and
PDE coeffi ci ents.
Numeri cal l y sol ve the PDE pr obl em, i .e., gener ate unstr uctur ed meshes,
di screti ze the equati ons, and pr oduce an approxi mati on to the sol uti on.
Vi sual i ze the resul ts.
Can I Use the PDE Toolbox?
The PDE Tool box i s desi gned for both begi nner s and advanced user s.
The mi ni mal r equi r ement i s that you can formul ate a PDE pr obl em on paper
(draw the domai n, wri te the boundary condi ti ons, and the PDE). Start
MATLAB. At the MATLAB command l i ne type:
pde t ool
Thi s i nvokes the graphi cal user i nterface (GUI ), whi ch i s a sel f-contai ned
gr aphi cal envi ronment for PDE sol vi ng. For common appl i cati ons you can use
the speci fi c physi cal ter ms rather than abstr act coeffi ci ents. Usi ng pdet ool
r equi r es no knowl edge of the mathemati cs behi nd the PDE, the numeri cal
schemes, or MATLAB. I n Getti ng Started on page 1-9 we gui de you thr ough
an exampl e step by step.
Advanced appl i cati ons ar e al so possi bl e by downl oadi ng the domai n geometry,
boundar y condi ti ons, and mesh descr i pti on to the MATLAB workspace. Fr om
the command l i ne (or M-fi l es) you can cal l functi ons from the tool box to do the
hard work, e.g., gener ate meshes, di scr eti ze your probl em, per for m
i nterpol ati on, pl ot data on unstructured gri ds, etc., whi l e you retai n ful l contr ol
over the gl obal numer i cal al gori thm.
Introducti on
1-3
What Problems Can I Solve?
The basi c equati on of the PDE Tool box i s the PDE
i n ,
whi ch we shal l refer to as the elliptic equation, r egardl ess of whether i ts
coeffi ci ents and boundary condi ti ons make the PDE probl em el l i pti c i n the
mathemati cal sense. Anal ogousl y, we shal l use the ter ms parabolic equation
and hyperbolic equation for equati ons wi th spati al operators l i ke the one above,
and fi rst and second order ti me deri vati ves, respecti vel y. i s a bounded
domai n i n the pl ane. c, a, f, and the unknown u ar e scal ar , compl ex val ued
functi ons defi ned on . c can be a 2-by-2 matri x functi on on . The tool box can
al so handl e the par abol i c PDE
the hyper bol i c PDE
and the ei genval ue probl em
where d i s a compl ex val ued functi on on , and i s an unknown ei genval ue.
For the parabol i c and hyper bol i c PDE the coeffi ci ents c, a, f, and d can depend
on ti me. A nonl i near sol ver i s avai l abl e for the nonl i near el l i pti c PDE
where c, a, and f ar e functi ons of the unknown sol uti on u. Al l sol ver s can handl e
the system case
You can wor k wi th systems of ar bi tr ar y di mensi on fr om the command l i ne. For
the el l i pti c pr obl em, an adapti ve mesh r efi nement al gori thm i s i mpl emented.
I t can al so be used i n conjuncti on wi th the nonl i near sol ver. I n addi ti on, a fast
sol ver for Poi ssons equati on on a r ectangul ar gr i d i s avai l abl e.
c u ( ) au + f =
u
t
----- d c u ( ) au + f =
,
u
2

t
2
-------- d c u ( ) au + f =
,
c u ( ) au + du =
c u ( ) u ( ) a u ( )u + f u ( ) =
,
c
11
u
1
( ) c
12
u
2
( ) a
11
u
1
a
12
u
2
+ + f
1
=
c
21
u
1
( ) c
22
u
2
( ) a
21
u
1
a
22
u
2
+ + f
2
=
.
1 Tutori al
1-4
The fol l owi ng boundar y condi ti ons ar e defi ned for scal ar u:
Dirichlet: hu = r on the boundary .
Generalized Neumann: on .
i s the outward uni t normal . g, q, h, and r are compl ex val ued functi ons
defi ned on . (The ei genval ue pr obl em i s a homogeneous pr obl em, i .e., g = 0,
r = 0.) I n the nonl i near case, the coeffi ci ents, g, q, h, and r can depend on u, and
for the hyperbol i c and parabol i c PDE, the coeffi ci ents can depend on ti me. For
the two-di mensi onal system case, Di r i chl et boundar y condi ti on i s
the general i zed Neumann boundary condi ti on i s
and the mixed boundar y condi ti on i s
where i s computed such that the Di ri chl et boundary condi ti on i s sati sfi ed.
Di ri chl et boundary condi ti ons are al so cal l ed essential boundary condi ti ons,
and Neumann boundary condi ti ons are al so cal l ed natural boundar y
condi ti ons. See Chapter 4, "The Fi ni te El ement Method" for the gener al system
case.

n c u ( ) qu + g =

n

h
11
u
1
h
12
u
2
+ r
1
=
h
21
u
1
h
22
u
2
+ r
2
=
,
n c
21
u
1
( ) n c
22
u
2
( ) q
21
u
1
q
22
u
2
+ + + g
2
=
n c
11
u
1
( ) n c
12
u
2
( ) q
11
u
1
q
12
u
2
+ + + g
1
=
,
h
11
u
1
h
12
u
2
+ r
1
=
n c
21
u
1
( ) n c
22
u
2
( ) q
21
u
1
q
22
u
2
+ + + g
2
h
12
+ =
n c
11
u
1
( ) n c
12
u
2
( ) q
11
u
1
q
12
u
2
+ + + g
1
h
11
+ =
,
Introducti on
1-5
In Which Areas Can the Toolbox Be Used?
The PDEs i mpl emented i n the tool box ar e used as a mathemati cal model for a
wi de var i ety of phenomena i n al l branches of engi neeri ng and sci ence. The
fol l owi ng i s by no means a compl ete l i st of exampl es:
The el l i pti c and par abol i c equati ons ar e used for model i ng
steady and unsteady heat tr ansfer i n sol i ds
fl ows i n por ous medi a and di ffusi on pr obl ems
el ectrostati cs of di el ectr i c and conducti ve medi a
potenti al fl ow
The hyper bol i c equati on i s used for
transi ent and harmoni c wave pr opagati on i n acousti cs and el ectr omagneti cs
transver se moti ons of membranes
The ei genval ue pr obl ems are used for, e.g.,
deter mi ni ng natur al vi br ati on states i n membranes and structural
mechani cs pr obl ems
Last, but not l east, the tool box can be used for educati onal pur poses as a
compl ement to under standi ng the theory of the Fi ni te El ement Method.
How Do I Define a PDE Problem?
The si mpl est way to defi ne a PDE probl em i s usi ng the gr aphi cal user i nter face
(GUI ), i mpl emented i n pde t ool . There ar e three modes that corr espond to
di ffer ent stages of defi ni ng a PDE pr obl em:
Draw mode, you cr eate , the geometry, usi ng the constr ucti ve sol i d
geometry (CSG) model par adi gm. A set of sol i d objects (rectangl e, ci r cl e,
el l i pse, and pol ygon) i s pr ovi ded. You can combi ne these objects usi ng set
formulas.
I n Boundary mode, you speci fy the boundary condi ti ons. You can have
di ffer ent types of boundary condi ti ons on di ffer ent boundar y segments.
I n PDE mode, you i nteracti vel y speci fy the type of PDE and the coeffi ci ents
c, a, f, and d. You can speci fy the coeffi ci ents for each subdomai n
i ndependentl y. Thi s may ease the speci fi cati on of, e.g., var i ous mater i al
pr oper ti es i n a PDE model .
1 Tutori al
1-6
How Can I Solve a PDE Problem?
Most pr obl ems can be sol ved from the graphi cal user i nter face. There are two
major modes that hel p you sol ve a pr obl em:
I n Mesh mode, you generate and pl ot meshes. You can contr ol the
parameter s of the automated mesh generator.
I n Solve mode, you can i nvoke and control the nonl i near and adapti ve
sol ver s for el l i pti c probl ems. For par abol i c and hyper bol i c pr obl ems, you can
speci fy the i ni ti al val ues, and the ti mes for whi ch the output shoul d be
gener ated. For the ei genval ue sol ver, you can speci fy the i nterval i n whi ch to
search for ei genval ues.
After sol vi ng a probl em, you can r etur n to the Mesh mode to fur ther r efi ne
your mesh and then sol ve agai n. You can al so empl oy the adapti ve mesh refi ner
and sol ver. Thi s opti on tri es to fi nd a mesh that fi ts the sol uti on.
Can I Use the Toolbox for Nonstandard Problems?
For advanced, nonstandar d appl i cati ons you can tr ansfer the descr i pti on of
domai ns, boundar y condi ti ons etc. to your MATLAB wor kspace. Fr om there you
use the functi ons of the PDE Tool box for managi ng data on unstr uctur ed
meshes. You have ful l access to the mesh generators, FEM di scr eti zati ons of
the PDE and boundary condi ti ons, i nter pol ati on functi ons, etc. You can desi gn
your own sol ver s or use FEM to sol ve subprobl ems of mor e compl ex al gori thms.
See al so the secti on Usi ng Command-Li ne Functi ons.
How Can I Visualize My Results?
From the gr aphi cal user i nterface you can use Plot mode, where you have a
wi de range of vi sual i zati on possi bi l i ti es. You can vi sual i ze both i nsi de the
pde t ool GUI and i n separate fi gures. You can pl ot three di fferent sol uti on
pr oper ti es at the same ti me, usi ng col or, hei ght, and vector fi el d pl ots. Sur face,
mesh, contour , and arr ow (qui ver) pl ots are avai l abl e. For sur face pl ots, you
can choose between i nter pol ated and fl at r enderi ng schemes. The mesh may be
hi dden or exposed i n al l pl ot types. For par abol i c and hyperbol i c equati ons, you
can even produce an ani mated movi e of the sol uti ons ti me-dependence. Al l
vi sual i zati on functi ons are al so accessi bl e from the command l i ne.
Introducti on
1-7
Are There Any Applications Already Implemented?
The PDE Tool box i s easy to use i n the most common ar eas due to the
appl i cati on i nterfaces. Ei ght appl i cati on i nter faces ar e avai l abl e, i n addi ti on to
the gener i c scal ar and system (vector val ued u) cases:
Structural Mechani cs - Pl ane Str ess
Structural Mechani cs - Pl ane Str ai n
El ectr ostati cs
Magnetostati cs
AC Power El ectromagneti cs
Conducti ve Medi a DC
Heat Transfer
Di ffusi on
These i nter faces have di al og boxes where the PDE coeffi ci ents, boundar y
condi ti ons, and sol uti on are expl ai ned i n ter ms of physi cal enti ti es. The
appl i cati on i nterfaces enabl e you to enter speci fi c par ameters, such as Youngs
modul us i n the str uctur al mechani cs pr obl ems. Al so, vi sual i zati on of the
rel evant physi cal vari abl es i s pr ovi ded.
Sever al nontr i vi al exampl es are i ncl uded i n thi s manual . Many exampl es are
sol ved both by usi ng the GUI and i n command-l i ne mode.
The tool box contai ns a number of demonstr ati on M-fi l es. They i l l ustrate some
ways i n whi ch you can wri te your own appl i cati ons.
Can I Extend the Functionality of the Toolbox?
The PDE Tool box i s wr i tten usi ng MATLABs open system phi l osophy. There
ar e no bl ack-box functi ons, al though some functi ons may not be easy to
under stand at fi r st gl ance. The data structures and formats are documented.
You can exami ne the exi sti ng functi ons and create your own as needed.
1 Tutori al
1-8
How Can I Solve 3-D Problems by 2-D Models?
The PDE Tool box sol ves probl ems i n two space di mensi ons and ti me, whereas
r eal i ty has thr ee space di mensi ons. The r educti on to 2-D i s possi bl e when
vari ati ons i n the thi rd space di mensi on (taken to be z) can be accounted for i n
the 2-D equati on. I n some cases, l i ke the pl ane str ess anal ysi s, the materi al
par ameters must be modi fi ed i n the pr ocess of di mensi onal i ty reducti on.
When the pr obl em i s such that vari ati on wi th z i s negl i gi bl e, al l z-deri vati ves
dr op out and the 2-D equati on has exactl y the same uni ts and coeffi ci ents as
i n 3-D.
Sl ab geometr i es ar e treated by i ntegr ati on thr ough the thi ckness. The resul t i s
a 2-D equati on for the z-averaged sol uti on wi th the thi ckness, say D(x,y),
mul ti pl i ed onto al l the PDE coeffi ci ents, c, a, d, and f, etc. For i nstance, i f you
want to compute the stresses i n a sheet wel ded together fr om pl ates of di fferent
thi ckness, mul ti pl y Youngs modul us E, vol ume for ces, and speci fi ed sur face
tr acti ons by D(x,y). Si mi l ar defi ni ti ons of the equati on coeffi ci ents are cal l ed for
i n other sl ab geometry exampl es and appl i cati on modes.
G etti ng Started
1-9
Getting Started
To get you started, l ets use the gr aphi cal user i nterface (GUI ) pdet ool , whi ch
i s a par t of the PDE Tool box, to sol ve a PDE step by step. The pr obl em that we
woul d l i ke to sol ve i s Poissons equation, . The 2-D geometr y on whi ch
we woul d l i ke to sol ve the PDE i s qui te compl ex. The boundar y condi ti ons ar e
of Dirichlet and Neumann types.
Fi rst, i nvoke MATLAB. To star t the GUI , type the command pde t ool at the
MATLAB prompt. I t can take a mi nute or two for the GUI to star t. The GUI
l ooks si mi l ar to the fi gure bel ow, wi th excepti on of the gri d. Turn on the gri d
by sel ecti ng Grid fr om the Options menu. Al so, enabl e the snap-to-gri d
featur e by sel ecti ng Snap from the Options menu. The snap-to-gri d featur e
si mpl i fi es al i gni ng the sol i d objects.
The fi r st step i s to draw the geometry on whi ch you want to sol ve the PDE. The
GUI provi des four basi c types of solid objects: pol ygons, rectangl es, ci rcl es, and
el l i pses. The objects are used to create a Constructive Solid Geometry model
(CSG model ). Each sol i d object i s assi gned a uni que l abel , and by the use of set
al gebr a, the r esul ti ng geometr y can be made up of a combi nati on of uni ons,
i nter secti ons, and set di ffer ences. By defaul t, the r esul ti ng CSG model i s the
uni on of al l sol i d objects.
u f =
1 Tutori al
1-10
To sel ect a sol i d object, ei ther cl i ck on the button wi th an i con depi cti ng the
sol i d object that you want to use, or sel ect the object by usi ng the Draw
pul l -down menu. I n thi s case, rectangl e/squar e objects ar e sel ected. To draw a
r ectangl e or a squar e starti ng at a cor ner, pr ess the rectangl e button wi thout a
+ si gn i n the mi ddl e. The button wi th the + si gn i s used when you want to draw
starti ng at the center. Then, put the cur sor at the desi red corner, and
cl i ck-and-dr ag usi ng the left mouse button to cr eate a r ectangl e wi th the
desi r ed si de l engths. (Use the r i ght mouse button to cr eate a squar e.) Noti ce
how the snap-to-gri d featur e forces the rectangl e to l i ne up wi th the gri d.
When you r el ease the mouse, the CSG model i s updated and r edr awn. At thi s
stage, al l you have i s a r ectangl e. I t i s assi gned the l abel R1. I f you want to
move or resi ze the rectangl e, you can easi l y do so. Cl i ck-and-dr ag an object to
move i t, and doubl e-cl i ck on an object to open a di al og box, wher e you can enter
exact l ocati on coor di nates. From the di al og box, you can al so al ter the l abel . I f
you ar e not sati sfi ed and want to r estar t, you can del ete the r ectangl e by
pr essi ng the Delete key or by sel ecti ng Clear fr om the Edit menu. Next, dr aw
a ci rcl e by cl i cki ng on the button wi th the el l i pse i con wi th the + si gn, and then
cl i ck-and-dr ag i n a si mi l ar way, usi ng the right mouse button, star ti ng at the
ci rcl e center .
G etti ng Started
1-11
The resul ti ng CSG model i s the uni on of the r ectangl e R1 and the ci r cl e C1,
descr i bed by set al gebr a as R1+C1. The area where the two objects over l ap i s
cl ear l y vi si bl e as i t i s dr awn usi ng a dar ker shade of gray. The object that you
just drew the ci rcl e has a bl ack border , i ndi cati ng that i t i s sel ected. A
sel ected object can be moved, r esi zed, copi ed, and del eted. You can sel ect mor e
than one object by Shift-cl i cki ng on the objects that you want to sel ect. Al so, a
Select All opti on i s avai l abl e from the Edit menu.
Fi nal l y, add two more objects, a r ectangl e R2 and a ci rcl e C2. The desi r ed CSG
model i s for med by subtr acti ng the ci r cl e C2 from the uni on of the other three
objects. You do thi s by edi ti ng the set formul a that by defaul t i s the uni on of al l
objects: C1+R1+R2+C2. You can type any other val i d set for mul a i nto Set
formula edi t fi el d. Cl i ck i n the edi t fi el d and use the keyboard to change the
set for mul a to:
( R1+C1+R2) - C2
1 Tutori al
1-12
I f you want, you can save thi s CSG model as an M-fi l e. Use the Save As. . .
opti on from the File menu, and enter a fi l ename of your choi ce. I ts good
pr acti ce to conti nue to save your model at r egul ar i nterval s usi ng Save. Al l the
addi ti onal steps i n the process of model i ng and sol vi ng your PDE are then
saved to the same M-fi l e. Thi s concl udes the drawi ng part. You can now defi ne
the boundary condi ti ons for the outer boundar i es. Enter the Boundary mode
by pr essi ng the i con or by sel ecti ng Boundary Mode from the Boundary
menu. You can now r emove subdomai n border s and defi ne the boundar y
condi ti ons.
The gray edge segments are subdomai n borders i nduced by the i nter secti ons of
the ori gi nal sol i d objects. Borders that do not r epr esent border s between, e.g.,
ar eas wi th di ffer i ng mater i al pr oper ti es, can be removed. Fr om the Boundary
menu, sel ect the Remove All Subdomain Borders opti on. Al l bor ders ar e
then removed fr om the decomposed geometry.
The boundari es ar e i ndi cated by col or ed l i nes wi th ar rows. The col or refl ects
the type of boundar y condi ti on, and the ar row poi nts towar ds the end of the
boundar y segment. The di recti on i nfor mati on i s provi ded for the case when the
boundar y condi ti on i s par ameteri zed al ong the boundar y. The boundary
condi ti on can al so be a functi on of x and y, or si mpl y a constant. By defaul t, the
boundar y condi ti on i s of Di r i chl et type: u = 0 on the boundar y.
Di ri chl et boundary condi ti ons are i ndi cated by r ed col or . The boundary
condi ti ons can al so be of a general i zed Neumann (bl ue) or mi xed (gr een) type.
For scal ar u, however , al l boundary condi ti ons are ei ther of Di ri chl et or the
general i zed Neumann type. You sel ect the boundary condi ti ons that you want
to change by cl i cki ng to sel ect one boundar y segment, by Shift-cl i cki ng to
sel ect mul ti pl e segments, or by usi ng the Edit menu opti on Select All to sel ect
al l boundar y segments. The sel ected boundary segments ar e i ndi cated by bl ack
col or .

G etti ng Started
1-13
For thi s pr obl em, change the boundary condi ti on for al l the ci rcl e ar cs. Sel ect
them by usi ng the mouse and Shift-cl i ck on those boundar y segments.
Doubl e-cl i cki ng anywhere on the sel ected boundar y segments opens the
Boundary Condition di al og box. Her e, you sel ect the type of boundar y
condi ti on, and enter the boundar y condi ti on as a MATLAB expressi on. Change
the boundary condi ti on al ong the sel ected boundar i es to a Neumann condi ti on,
. Thi s means that the sol uti on has a sl ope of 5 i n the normal
di recti on for these boundary segments.
I n the Boundary Condition di al og box, sel ect the Neumann condi ti on type,
and enter 5 i n the edi t box for the boundary condi ti on par ameter g. To defi ne
a pure Neumann condi ti on, l eave the q parameter at i ts defaul t val ue, 0. When
you press the OK button, noti ce how the sel ected boundary segments change
to bl ue to i ndi cate Neumann boundary condi ti on.
n u 5 =
1 Tutori al
1-14
Next, speci fy the PDE i tsel f through a di al og box that i s accessed by pressi ng
the button wi th the PDE i con or by sel ecti ng PDE Specification. . . fr om the
PDE pul l -down menu. I n the PDE mode, you can al so access the PDE
Specification di al og box by doubl e-cl i cki ng on a subdomai n. That way,
di fferent subdomai ns can have di fferent PDE coeffi ci ent val ues. Thi s probl em,
however, consi sts of onl y one subdomai n.
I n the di al og box, you can sel ect the type of PDE (el l i pti c, parabol i c, hyper bol i c,
or ei genmodes) and defi ne the appl i cabl e coeffi ci ents dependi ng on the PDE
type. Thi s probl em consi sts of an el l i pti c PDE defi ned by the equati on
wi th c = 1.0, a = 0.0, and f = 10.0.
cu ( ) au + f =
,
G etti ng Started
1-15
Fi nal l y, create the tri angul ar mesh that the PDE Tool box uses i n the Finite
Element Method (FEM) to sol ve the PDE. The tri angul ar mesh i s created and
di spl ayed when pressi ng the button wi th the i con or by sel ecti ng the Mesh
menu opti on Initialize Mesh. I f you want a mor e accurate sol uti on, the mesh
can be successi vel y refi ned by pressi ng the button wi th the four tr i angl e i con
(the Refine button) or by sel ecti ng the Refine Mesh opti on from the Mesh
menu. Usi ng the J iggle Mesh opti on, the mesh can be ji ggl ed to i mpr ove the
tr i angl e qual i ty. Parameter s for contr ol l i ng the ji ggl i ng of the mesh, the
refi nement method, and other mesh generati on parameter s can be found i n a
di al og box that i s opened by sel ecti ng Parameters fr om the Mesh menu. You
can undo any change to the mesh by sel ecti ng the Mesh menu opti on Undo
Mesh Change.
I ni ti al i ze the mesh, then refi ne i t once and fi nal l y ji ggl e i t once.
We ar e now ready to sol ve the pr obl em. Press the = button or sel ect Solve PDE
from the Solve menu to sol ve the PDE. The sol uti on i s then pl otted. By defaul t,
the pl ot uses i nterpol ated col ori ng and a l i near col or map. A col orbar i s al so
provi ded to map the di fferent shades to the numer i cal val ues of the sol uti on. I f
you want, the sol uti on can be expor ted as a vector to the MATLAB mai n
wor kspace.
1 Tutori al
1-16
Ther e ar e many more pl ot modes avai l abl e to hel p you vi sual i ze the sol uti on.
Press the button wi th the 3-D sol uti on i con or sel ect Parameters. . . fr om the
Plot menu to access the di al og box for sel ecti on of the di fferent pl ot opti ons.
Sever al pl ot styl es are avai l abl e, and the sol uti on can be pl otted i n the GUI or
i n a separ ate fi gur e as a 3-D pl ot. Now, sel ect a pl ot where the col or and the
hei ght both r epresent u. Choose i nter pol ated shadi ng and use the conti nuous
(i nterpol ated) hei ght opti on. The defaul t col ormap i s the c ool col or map; a
pop-up menu l ets you sel ect fr om a number of di fferent col ormaps. Fi nal l y,
pr ess the Plot button to pl ot the sol uti on; press the Done button to save the
pl ot setup as the curr ent defaul t. The sol uti on i s pl otted as a 3-D pl ot i n a
separ ate fi gur e wi ndow.
G etti ng Started
1-17
The fol l owi ng sol uti on pl ot i s the resul t. You can use the mouse to rotate the
pl ot i n 3-D. By cl i cki ng-and-dr aggi ng the axes, the angl e fr om whi ch the
sol uti on i s vi ewed can be changed.
Thi s concl udes the fi rst exampl e of sol vi ng a PDE by usi ng the pde t ool GUI.
Many more exampl es i n Chapter 2, "Exampl es" focus on sol vi ng parti cul ar
probl ems i nvol vi ng di ffer ent ki nds of PDEs, geometri es and boundar y
condi ti ons and coveri ng a r ange of di ffer ent appl i cati ons.
1 Tutori al
1-18
Basics of The Finite Element Method
The sol uti ons of si mpl e PDEs on compl i cated geometri es can rar el y be
expr essed i n terms of el ementary functi ons. You are confr onted wi th two
pr obl ems: Fi rst you need to descr i be a compl i cated geometry and generate a
mesh on i t. Then you need to di screti ze your PDE on the mesh and bui l d an
equati on for the di scr ete appr oxi mati on of the sol uti on. The pdet ool graphi cal
user i nter face provi des you wi th easy-to-use graphi cal tool s to descr i be
compl i cated domai ns and generate tri angul ar meshes. I t al so di scr eti zes PDEs,
fi nds di scr ete sol uti ons and pl ots r esul ts. You can access the mesh structures
and the di screti zati on functi ons di r ectl y fr om the command l i ne (or M-fi l e) and
i ncorpor ate them i nto speci al i zed appl i cati ons.
Bel ow i s an over vi ew of the Fi ni te El ement Method (FEM). The pur pose of thi s
pr esentati on i s to get you acquai nted wi th the el ementar y FEM noti ons. Here
you fi nd the pr eci se equati ons that are sol ved and the nature of the di screte
sol uti on. Di fferent extensi ons of the basi c equati on i mpl emented i n the PDE
Tool box are presented. A more detai l ed descri pti on can be found i n Chapter 4,
"The Fi ni te El ement Method".
You start by appr oxi mati ng the computati onal domai n wi th a uni on of
si mpl e geometr i c objects, i n thi s case tri angl es. The tr i angl es form a mesh and
each ver tex i s cal l ed a node. You ar e i n the si tuati on of an archi tect desi gni ng
a dome. He has to str i ke a bal ance between the i deal rounded forms of the
ori gi nal sketch and the l i mi tati ons of hi s si mpl e bui l di ng-bl ocks, tr i angl es or
quadri l ateral s. I f the r esul t does not l ook cl ose enough to a perfect dome, the
ar chi tect can al ways i mprove hi s work usi ng smal l er bl ocks.
Next you say that your sol uti on shoul d be si mpl e on each tr i angl e. Pol ynomi al s
ar e a good choi ce: they ar e easy to eval uate and have good approxi mati on
pr oper ti es on smal l domai ns. You can ask that the sol uti ons i n nei ghbor i ng
tr i angl es connect to each other conti nuousl y across the edges. You can sti l l
deci de how compl i cated the pol ynomi al s can be. Just l i ke an archi tect, you
want them as si mpl e as possi bl e. Constants ar e the si mpl est choi ce but you
cannot match val ues on nei ghbori ng tr i angl es. Li near functi ons come next.

Basi cs of The Fi ni te Element M ethod


1-19
Thi s i s l i ke usi ng fl at ti l es to bui l d a waterpr oof dome, whi ch i s perfectl y
possi bl e.
Now you use the basi c el l i pti c equati on:
i n .
I f u
h
i s the pi ecewi se l i near appr oxi mati on to u, i t i s not cl ear what the second
deri vati ve term means. I nsi de each tri angl e, i s a constant (because u
h
i s
fl at) and thus the second-or der term vani shes. At the edges of the tri angl es,
i s i n gener al di sconti nuous and a fur ther deri vati ve makes no sense.
What you ar e l ooki ng for i s the best appr oxi mati on of u i n the cl ass of
conti nuous pi ecewi se pol ynomi al s. Therefore you test the equati on for u
h

agai nst al l possi bl e functi ons v of that cl ass. Testi ng means for mal l y to
mul ti pl y the resi dual agai nst any functi on and then i ntegr ate, i .e., deter mi ne
u
h
such that
for al l possi bl e v. The functi ons v are usual l y cal l ed test functions.
Parti al i ntegr ati on (Gr eens for mul a) yi el ds that u
h
shoul d sati sfy
1
0.5
0
0.5
1
1
0.5
0
0.5
1
0
0.2
0.4
0.6
0.8

1
0.5
0
0.5
1
1
0.5
0
0.5
1
0
0.2
0.4
0.6
0.8

A triangular mesh (left) and a continuous piecewise linear function on that mesh
c u ( ) au + f =
u
h

c u
h

c u
h
( ) au
h
f + ( )v x d

0 =
c u
h
( ) v

au
h
vdx n

+ c u
h
( )vds fv x d

= v ,
1 Tutori al
1-20
where i s the boundar y of and i s the outwar d poi nti ng normal on .
Note that the i ntegr al s of thi s for mul ati on are wel l -defi ned even i f u
h
and v ar e
pi ecewi se l i near functi ons.
Boundary condi ti ons ar e i ncl uded i n the fol l owi ng way. I f u
h
i s known at some
boundar y poi nts (Di r i chl et boundar y condi ti ons), we restr i ct the test functi ons
to v =0 at those poi nts, and requi re u
h
to attai n the desi red val ue at that poi nt.
At al l the other poi nts we ask for Neumann boundary condi ti ons, i .e.,
. The FEM for mul ati on reads: Fi nd u
h
such that
where i s the part of the boundar y wi th Neumann condi ti ons. The test
functi ons v must be zero on .
Any conti nuous pi ecewi se l i near u
h
i s r epresented as a combi nati on
, wher e
i
are some speci al pi ecewi se l i near basi s
functi ons and U
i
are scal ar coeffi ci ents. Choose
i
l i ke a tent, such that i t has
the hei ght 1 at the node i and the hei ght 0 at al l other nodes. For any fi xed v,
the FEM formul ati on yi el ds an al gebrai c equati on i n the unknowns U
i
. You
want to deter mi ne N unknowns, so you need N di fferent i nstances of v. What
better candi dates than v =
j
, j = 1, 2, . . . , N? You fi nd a l i near system KU =F
where the matri x K and the r i ght-hand si de F contai n i ntegral s i n ter ms of the
test functi ons
i
,
j
and the coeffi ci ents defi ni ng the pr obl em: c, a, f, q, and g.
The sol uti on vector U contai ns the expansi on coeffi ci ents of u
h
, whi ch ar e al so
the val ues of u
h
at each node x
i
si nce u
h
(x
i
) =U
i
.
I f the exact sol uti on u i s smooth, then FEM computes u
h
wi th an err or of the
same si ze as that of the l i near i nterpol ati on. I t i s possi bl e to esti mate the er ror
on each tri angl e usi ng onl y u
h
and the PDE coeffi ci ents (but not the exact
sol uti on u, whi ch i n general i s unknown).
The PDE Tool box provi des functi ons that assembl e K and F. Thi s i s done
automati cal l y i n the graphi cal user i nter face, but you al so have di rect access to
the FEM matr i ces from the command-l i ne functi on as s empde.
To summar i ze, the FEM approach i s to appr oxi mate the PDE sol uti on u by a
pi ecewi se l i near functi on i s expanded i n a basi s of test-functi ons
i
,
and the resi dual i s tested agai nst al l the basi s functi ons. Thi s procedure yi el ds
a l i near system KU =F. The components of U are the val ues of u
h
at the nodes.
n
cu
h
( ) n qu
h
+ g =
c u
h
( ) v

au
h
vdx qu
h
vds

+ + fv x d

= gv s d

+
v,

1

1

u
h
x ( ) U
i

i
x ( )
i 1 =
N

=
u
h
u
h

Basi cs of The Fi ni te Element M ethod


1-21
For x i nsi de a tr i angl e, u
h
(x) i s found by l i near i nterpol ati on fr om the nodal
val ues.
FEM techni ques are al so used to sol ve more general pr obl ems. Bel ow ar e some
gener al i zati ons that you can access both thr ough the graphi cal user i nter face
and wi th command-l i ne functi ons.
Ti me-dependent probl ems ar e easy to i mpl ement i n the FEM context. The
sol uti on u(x,t) of the equati on
can be approxi mated by . Thi s yi el ds a system of
or di nar y di fferenti al equati ons (ODE) whi ch you i ntegr ate
usi ng ODE sol vers. Two ti me deri vati ves yi el d a second order ODE
, etc. The tool box supports probl ems wi th one or two ti me
der i vati ves (the functi ons par abol i c and hy pe r bol i c).
Ei genval ue probl ems: Sol ve
for the unknowns u and ( i s a compl ex number ). Usi ng the FEM
di scr eti zati on, you sol ve the al gebrai c ei genval ue pr obl em KU =
h
MU to
fi nd u
h
and
h
as appr oxi mati ons to u and . A r obust ei genval ue sol ver i s
i mpl emented i n pde e i g.
I f the coeffi ci ents c, a, f, q, or g are functi ons of u, the PDE i s cal l ed nonl i near
and FEM yi el ds a nonl i near system K(U) U= F(U). You can use i terati ve
methods for sol vi ng the nonl i near system. The tool box provi des a nonl i near
sol ver cal l ed pde nonl i n usi ng a damped Gauss-Newton method.
u
t
----- d c u ( ) au + f =
u
h
x t , ( ) U
i
t ( )
i
x ( )
i 1 =
N

=
M
t d
d
U KU + F =
M
t
2
2
d
d
U KU + F =
cu ( ) au + du =
1 Tutori al
1-22
Smal l tr i angl es ar e needed onl y i n those par ts of the computati onal domai n
wher e the er r or i s l ar ge. I n many cases the er r or s ar e l ar ge i n a smal l
r egi on and maki ng al l tri angl es smal l i s a waste of computati onal effor t.
Maki ng smal l tr i angl es onl y wher e needed i s cal l ed adapti ng the mesh
r efi nement to the sol uti on. An i ter ati ve adapti ve str ategy i s the fol l owi ng:
For a gi ven mesh, form and sol ve the l i near system KU = F. Then esti mate
the er r or and r efi ne the tr i angl es i n whi ch the er r or i s l arge. The i ter ati on
i s control l ed by adapt me s h and the er r or i s esti mated by pde j mps .
Al though the basi c equati on i s scal ar, systems of equati ons ar e al so handl ed by
the tool box. The i nteracti ve envi ronment accepts u as a scal ar or 2-vector
functi on. I n command-l i ne mode, systems of arbi trar y si ze are accepted.
I f c > 0 and a 0, under rather gener al assumpti ons on the domai n and
the boundar y condi ti ons, the sol uti on u exi sts and i s uni que. The FEM l i near
system has a uni que sol uti on whi ch conver ges to u as the tri angl es become
smal l er. The matri x K and the r i ght-hand si de F make sense even when u does
not exi st or i s not uni que. I t i s advi sabl e that you devi se checks to pr obl ems
wi th questi onabl e sol uti ons.
Usi ng the G raphi cal User Interface
1-23
Using the Graphical User Interface
The PDE Toolbox Graphical User Interface
The PDE Tool box i ncl udes a compl ete graphi cal user i nterface (GUI ), whi ch
cover s al l aspects of the PDE sol uti on pr ocess. You star t i t by typi ng:
pde t ool
at the MATLAB command l i ne. I t may take a whi l e the fi r st ti me you l aunch
pdetool duri ng a MATLAB sessi on. The fi gure bel ow shows the pde t ool GUI as
i t l ooks when you have started i t.
At the top, the GUI has a pul l -down menu bar that you use to control the
model i ng. I t conforms to common pul l -down menu standar ds. Menu i tems
fol l owed by a r i ght ar row l ead to a submenu. Menu i tems fol l owed by an el l i psi s
l ead to a di al og box. Stand-al one menu i tems l ead to di rect acti on. Bel ow the
menu bar, a tool bar wi th i con buttons provi de qui ck and easy access to some of
the most i mportant functi ons.
1 Tutori al
1-24
To the r i ght of the tool bar i s a pop-up menu that i ndi cates the cur rent
appl i cati on mode. You can al so use i t to change the appl i cati on mode. The
upper r i ght par t of the GUI al so pr ovi des the x- and y-coordi nates of the cur rent
cur sor posi ti on. I t i s updated when you move the cursor i nsi de the mai n axes
ar ea i n the mi ddl e of the GUI . The edi t box for the set for mul a contai ns the
acti ve set for mul a. I n the mai n axes you dr aw the 2-D geometr y, di spl ay the
mesh, pl ot the sol uti on, etc. At the bottom of the GUI , an i nfor mati on l i ne
pr ovi des i nformati on about the curr ent acti vi ty. I t can al so di spl ay hel p
i nfor mati on about the tool bar buttons.
The Menus
Ther e ar e 11 di fferent pul l -down menus i n the GUI . For a mor e detai l ed
descri pti on of the menus and the di al og boxes, see Chapter 3, "The Graphi cal
User I nterface".
File menu. From the File menu you can Open and Save model M-fi l es that
contai n a command sequence that reproduces your model i ng sessi on. You
can al so pr i nt the cur rent gr aphi cs and exi t the GUI .
Edit menu. From the Edit menu you can cut, cl ear , copy, and paste the sol i d
objects. Ther e i s al so a Select All opti on.
Options menu. The Options menu contai ns opti ons such as toggl i ng the
axi s gri d, a snap-to-gr i d feature, and zoom. You can al so adjust the axi s
l i mi ts and the gri d spaci ng, sel ect the appl i cati on mode, and refresh the GUI .
Draw menu. From the Draw menu you can sel ect the basi c sol i d objects
such as ci r cl es and pol ygons. You can then dr aw objects of the sel ected type
usi ng the mouse. Fr om the Draw menu you can al so r otate the sol i d objects
and export the geometr y to the MATLAB mai n workspace.
Boundary menu. From the Boundary menu you access a di al og box where
you defi ne the boundar y condi ti ons. Addi ti onal l y, you can l abel edges and
subdomai ns, remove bor ders between subdomai ns, and expor t the
decomposed geometr y and the boundary condi ti ons to the wor kspace.
PDE menu. The PDE menu pr ovi des a di al og box for speci fyi ng the PDE,
and ther e ar e menu opti ons for l abel i ng subdomai ns and exporti ng PDE
coeffi ci ents to the workspace.
Usi ng the G raphi cal User Interface
1-25
Mesh menu. From the Mesh menu you cr eate and modi fy the tri angul ar
mesh. You can i ni ti al i ze, r efi ne, and ji ggl e the mesh, undo previ ous mesh
changes, l abel nodes and tri angl es, di spl ay the mesh qual i ty, and export the
mesh to the wor kspace.
Solve menu. From the Solve menu you sol ve the PDE. You can al so open a
di al og box wher e you can adjust the sol ve par ameters, and you can expor t the
sol uti on to the wor kspace.
Plot menu. Fr om the Plot menu you can pl ot a sol uti on pr oper ty. A di al og
box l ets you sel ect whi ch property to pl ot, whi ch pl ot styl e to use and sever al
other pl ot parameter s. I f you have recorded a movi e (ani mati on) of the
sol uti on, you can export i t to the workspace.
Window menu. The Window menu l ets you sel ect any curr entl y open
MATLAB fi gur e wi ndow. The sel ected wi ndow i s brought to the front.
Help menu. The Help menu provi des a bri ef hel p wi ndow.
The Toolbar
The tool bar under neath the mai n menu at the top of the GUI contai ns i con
buttons that pr ovi de qui ck and easy access to some of the most i mportant
functi ons.
The fi ve l eft-most buttons ar e Draw mode buttons and they r epresent, from
l eft to r i ght:
Draw a r ectangl e/square star ti ng at a cor ner .
Draw a r ectangl e/square star ti ng at the center .
Draw an el l i pse/ci r cl e star ti ng at the per i meter.
Draw an el l i pse/ci r cl e star ti ng at the center .
Draw a pol ygon. Cl i ck-and-drag to create pol ygon si des. You can cl ose the
pol ygon by pressi ng the r i ght mouse button. Cl i cki ng at the starti ng vertex
al so cl oses the pol ygon.
The Draw mode buttons can onl y be acti vated one at the ti me and they al l
wor k the same way: si ngl e-cl i cki ng on a button al l ows you to draw one sol i d
object of the sel ected type. Doubl e-cl i cki ng on a button makes i t sti ck, and you
can then conti nue to draw sol i d objects of the sel ected type unti l you
si ngl e-cl i ck on the button to rel ease i t. Usi ng the r i ght mouse button or
Control-cl i ck, the drawi ng i s constr ai ned to a squar e or a ci r cl e.
1 Tutori al
1-26
The second gr oup of si x buttons i ncl udes the fol l owi ng buttons:
: Enter s the Boundary mode.
PDE: Opens the PDE Speci fi cati on di al og box.
I ni ti al i zes the tri angul ar mesh.
The refine button (the four tri angl e i con): Refi nes the tri angul ar mesh.
=: Sol ves the PDE.
The 3-D sol uti on pl ot i con: Opens the Plot Selection di al og box.
The ri ght-most button wi th the magni fyi ng gl ass toggl es the zoom functi on
on/off.
The GUI Modes
The PDE sol vi ng process can be di vi ded i nto several steps:
1 Defi ne the geometry (2-D domai n).
2 Defi ne the boundar y condi ti ons.
3 Defi ne the PDE.
4 Cr eate the tri angul ar mesh.
5 Sol ve the PDE.
6 Pl ot the sol uti on and other physi cal properti es cal cul ated from the sol uti on
(post processi ng).
The pdet ool GUI i s desi gned i n a si mi l ar way. You work i n si x di fferent modes,
each corr espondi ng to one of the steps i n the PDE sol vi ng pr ocess:
I n Draw mode, you can create the 2-D geometr y usi ng the constructi ve sol i d
geometry (CSG) model paradi gm. A set of sol i d objects (rectangl e, ci rcl e,
el l i pse, and pol ygon) i s pr ovi ded. These objects can be combi ned usi ng set
for mul as i n a fl exi bl e way.
I n Boundary mode, you can speci fy the boundar y condi ti ons. You can have
di ffer ent types of boundar y condi ti ons on di ffer ent boundari es. I n thi s mode,
the ori gi nal shapes of the sol i d objects consti tute border s between
subdomai ns of the model . Such bor der s can be el i mi nated i n thi s mode.

Usi ng the G raphi cal User Interface
1-27
I n PDE mode, you can i nter acti vel y speci fy the type of PDE probl em, and the
PDE coeffi ci ents. You can speci fy the coeffi ci ents for each subdomai n
i ndependentl y. Thi s makes i t easy to speci fy, e.g., var i ous mater i al
pr oper ti es i n a PDE model .
I n Mesh mode, you can control the automated mesh generati on and pl ot the
mesh.
I n Solve mode, you can i nvoke and contr ol the nonl i near and adapti ve sol ver
for el l i pti c probl ems. For par abol i c and hyperbol i c PDE pr obl ems, you can
speci fy the i ni ti al val ues, and the ti mes for whi ch the output shoul d be
generated. For the ei genval ue sol ver, you can speci fy the i nter val i n whi ch to
search for ei genval ues.
I n Plot mode ther e i s wi de range of vi sual i zati on possi bi l i ti es. You can
vi sual i ze both i n the pde t ool GUI and i n a separate fi gure wi ndow. You can
vi sual i ze thr ee di ffer ent sol uti on properti es at the same ti me, usi ng col or,
hei ght, and vector fi el d pl ots. There are sur face, mesh, contour , and ar row
(qui ver ) pl ots avai l abl e. For par abol i c and hyperbol i c equati ons, you can
ani mate the sol uti on as i t changes wi th ti me.
The CSG Model and the Set Formula
The PDE Tool box uses the Constructi ve Sol i d Geometr y (CSG) model paradi gm
for the model i ng. You can dr aw solid objects that can overl ap. There are four
types of sol i d objects:
Circle object repr esents the set of poi nts i nsi de and on a ci r cl e.
Polygon object represents the set of poi nts i nsi de and on a pol ygon gi ven
by a set of l i ne segments.
Rectangle object r epresents the set of poi nts i nsi de and on a r ectangl e.
Ellipse object represents the set of poi nts i nsi de and on an el l i pse. The
el l i pse can be r otated.
Each sol i d object i s automati cal l y gi ven a uni que name by the GUI . The defaul t
names are C1, C2, C3, etc., for ci r cl es; P1, P2, P3, etc. for pol ygons; R1, R2, R3,
etc., for rectangl es; E1, E2, E3, etc., for el l i pses. Squares, al though just a
speci al case of rectangl es, ar e named SQ1, SQ2, SQ3, etc. The name i s
di spl ayed on the sol i d object i tsel f. You can use any uni que name, as l ong as i t
contai ns no bl anks. I n Draw mode you can al ter the names and the geometr i es
of the objects by doubl e-cl i cki ng on them. Thi s opens a di al og box wher e you can
1 Tutori al
1-28
edi t the name and the geometry. The fol l owi ng fi gur e shows an object di al og
box for a ci r cl e.
You can use the name of the object to refer to the cor respondi ng set of poi nts i n
a set formul a. The operator s +, *, and are used to form the set of poi nts i n
the pl ane over whi ch the di ffer enti al equati on i s sol ved. The operator s +, the
set uni on oper ator , and *, the set i nter secti on oper ator, have the same
pr ecedence. The oper ator , the set di fference oper ator, has hi gher precedence.
The precedence can be control l ed by usi ng parentheses. The r esul ti ng
geometr i cal model , , i s the set of poi nts for whi ch the set formul a eval uates to
tr ue. By defaul t, i t i s the uni on of al l sol i d objects. We often refer to the area
as the decomposed geometry.
Creating Rounded Corners
As an exampl e of how to use the set for mul a, l ets model a pl ate wi th rounded
cor ner s (fi l l ets).
Start the GUI and turn on the gr i d and the snap-to-gri d feature usi ng the
Options menu. Al so, change the gr i d spaci ng to - 1. 5: 0. 1: 1. 5 for the x-axi s
and - 1: 0. 1: 1 for the y-axi s.
Sel ect Rectangle/square fr om the Draw menu or press the button wi th the
r ectangl e i con. Then draw a r ectangl e wi th a wi dth of 2 and a hei ght of 1 usi ng
the mouse, star ti ng at (-1,0.5). To get the r ound cor ners, add ci rcl es, one i n each
cor ner . The ci r cl es shoul d have a r adi us of 0.2 and center s at a di stance that i s
0.2 uni ts from the l eft/r i ght and l ower /upper rectangl e boundar i es ((-0.8,-0.3),
(-0.8,0.3), (0.8,-0.3), and (0.8,0.3)). To draw several ci r cl es, doubl e-cl i ck on the
button for drawi ng el l i pses/ci rcl es (center ed). Then dr aw the ci rcl es usi ng the
r i ght mouse button or Control-cl i ck starti ng at the ci rcl e centers. Fi nal l y, at
each of the rectangl e corner s, dr aw four smal l squar es wi th a si de of 0.1.
Usi ng the G raphi cal User Interface
1-29
The fi gur e bel ow shows the compl ete drawi ng.
Now you have to edi t the set formul a. To get the rounded cor ners, subtract the
smal l squar es fr om the r ectangl e and then add the ci r cl es. As a set for mul a,
thi s i s expressed as
R1- ( SQ1+SQ2+SQ3+SQ4) +C1+C2+C3+C4
1 Tutori al
1-30
Enter the set for mul a i nto the edi t box at the top of the GUI . Then enter the
Boundary mode by pr essi ng the button or by sel ecti ng the Boundary
Mode opti on fr om the Boundary menu. The CSG model i s now decomposed
usi ng the set for mul a, and you get a r ectangl e wi th rounded cor ner s, as shown
bel ow.
Because of the i nter secti on of the sol i d objects used i n the i ni ti al CSG model , a
number of subdomai n borders r emai n. They ar e dr awn usi ng gr ay l i nes. I f thi s
i s a model of, e.g., a homogeneous pl ate, you can r emove them. Sel ect the
Remove All Subdomain Borders opti on from the Boundary menu. The
subdomai n bor der s are removed and the model of the pl ate i s now compl ete.

Usi ng the G raphi cal User Interface
1-31
Suggested Modeling Method
Al though the PDE Tool box offer s you a gr eat deal of fl exi bi l i ty i n the ways that
you can approach the probl ems and i nteract wi th the tool box functi ons, there
i s a suggested method of choi ce for model i ng and sol vi ng your PDE pr obl ems
usi ng the pde t ool GUI . There ar e al so a number of shor tcuts that you can use
i n cer tai n si tuati ons.
NOTE: Ther e ar e pl atfor m-dependent keyboar d accel er ators avai l abl e for
many of the most common pdet ool GUI acti vi ti es. Learni ng to use the
accel erator keys may i mprove the effi ci ency of your pde t ool sessi ons.
The basi c fl ow of acti ons i s i ndi cated by the way the graphi cal push buttons and
the menus are order ed fr om l eft to ri ght. You wor k your way from l eft to r i ght
i n the process of model i ng, defi ni ng, and sol vi ng your PDE probl em usi ng the
pde t ool GUI .
When you star t, pde t ool i s i n a Draw mode, wher e you can use the four
basi c sol i d objects to dr aw your Constr ucti ve Sol i d Geometry (CSG) model .
You can al so edi t the set for mul a. The sol i d objects are sel ected usi ng the fi ve
l eft-most push buttons (or from the Draw menu).
To the r i ght of the Draw mode buttons you fi nd push buttons through whi ch
you can access al l the functi ons that you need to defi ne and sol ve the PDE
pr obl em: defi ne boundar y condi ti ons, desi gn the tr i angul ar mesh, sol ve the
PDE, and pl ot the sol uti on.
The fol l owi ng sequence of acti ons covers al l the steps of a normal pde t ool
sessi on:
1 Use pdet ool as a drawi ng tool to make a dr awi ng of the 2-D geometr y on
whi ch you want to sol ve your PDE. Make use of the four basi c sol i d objects
and the gri d and the snap-to-gri d feature. The GUI star ts i n the Draw
mode, and you can sel ect the type of object that you want to use by cl i cki ng
on the cor respondi ng button or by usi ng the Draw pul l -down menu.
Combi ne the sol i d objects and the set al gebr a to bui l d the desi red CSG
model .
1 Tutori al
1-32
2 Save the geometr y to a model fi l e. The model fi l e i s an M-fi l e, so i f you want
to conti nue worki ng usi ng the same geometry at your next PDE Tool box
sessi on, si mpl y type the name of the model fi l e at the MATLAB pr ompt. The
pdet ool GUI then star ts wi th the model fi l es sol i d geometr y l oaded. I f you
save the PDE pr obl em at a l ater stage of the sol uti on pr ocess, the model fi l e
al so contai ns commands to r ecr eate the boundar y condi ti ons, the PDE
coeffi ci ents, and the mesh.
3 Move to the next step i n the PDE sol vi ng pr ocess by pressi ng the button.
The outer boundar i es of the decomposed geometr y are di spl ayed wi th the
defaul t boundar y condi ti on i ndi cated. I f the outer boundar i es do not match
the geometry of your probl em, r e-enter the Draw mode. You can then
corr ect your CSG model by addi ng, r emovi ng or al ter i ng any of the sol i d
objects, or change the set for mul a used to eval uate the CSG model .
NOTE: The set formul a can onl y be edi ted whi l e you ar e i n the Draw mode.
I f the drawi ng pr ocess resul ted i n any unwanted subdomai n borders,
r emove them by usi ng the Remove Subdomain Border or Remove All
Subdomain Borders opti on from the Boundary menu.
You can now defi ne your probl ems boundar y condi ti ons by sel ecti ng the
boundar y to change and open a di al og box by doubl e-cl i cki ng on the
boundar y or by usi ng the Specify Boundary Conditions. . . opti on from
the Boundary menu.
4 I ni ti al i ze the tr i angul ar mesh. Pr ess the button or use the cor respondi ng
Mesh menu opti on Initialize Mesh. Nor mal l y, the mesh al gor i thms
defaul t parameter s generate a good mesh. I f necessar y, they can be accessed
usi ng the Parameters. . . menu i tem.
5 I f you need a fi ner mesh, the mesh can be refi ned by pressi ng the Refine
button. Pressi ng the button several ti mes causes a successi ve r efi nement of
the mesh. The cost of a very fi ne mesh i s a si gni fi cant i ncr ease i n the number
of poi nts where the PDE i s sol ved and, consequentl y, a si gni fi cant i ncr ease
i n the ti me r equi r ed to compute the sol uti on. Dont r efi ne unl ess i t i s
r equi r ed to achi eve the desi red accur acy. For each r efi nement, the number
of tri angl es i ncr eases by a factor of four. A better way to i ncr ease the

Usi ng the G raphi cal User Interface
1-33
accuracy of the sol uti on to el l i pti c PDE probl ems i s to use the adapti ve
sol ver, whi ch r efi nes the mesh i n the ar eas where the esti mated err or of the
sol uti on i s l argest. See the entry on adapt mes h i n Chapter 5, "Reference" for
an exampl e of how the adapti ve sol ver can sol ve a Lapl ace equati on wi th an
accuracy that r equi r es more than 10 ti mes as many tr i angl es when r egul ar
r efi nement i s used.
6 Speci fy the PDE fr om the PDE Specification di al og box. You can access
that di al og box usi ng the PDE button or the PDE Specification. . . menu
i tem from the PDE menu.
NOTE: Thi s step can be per for med at any ti me pr i or to sol vi ng the PDE si nce i t
i s i ndependent of the CSG model and the boundar i es. I f the PDE coeffi ci ents
ar e mater i al dependent, they ar e entered i n the PDE mode by doubl e-cl i cki ng
on the di ffer ent subdomai ns.
7 Sol ve the PDE by pressi ng the = button or by sel ecti ng Solve PDE from the
Solve menu. I f you dont want an automati c pl ot of the sol uti on, or i f you
want to change the way the sol uti on i s pr esented, you can do that from the
Plot Selection di al og box pri or to sol vi ng the PDE. You open the Plot
Selection di al og box by pressi ng the button wi th the 3-D sol uti on pl ot i con
or by sel ecti ng the Parameters. . . menu i tem fr om the Plot menu.
8 Now, fr om here you can choose one of several al ter nati ves:
Export the sol uti on and/or the mesh to MATLABs mai n wor kspace for
fur ther anal ysi s.
Vi sual i ze other properti es of the sol uti on.
Change the PDE and recompute the sol uti on.
Change the mesh and recompute the sol uti on. I f you sel ect Initialize
Mesh, the mesh i s i ni ti al i zed; i f you sel ect Refine Mesh, the curr ent
mesh i s refi ned. Fr om the Mesh menu, you can al so ji ggl e the mesh and
undo previ ous mesh changes.
Change the boundary condi ti ons. To r etur n to the mode wher e you can se-
l ect boundari es, use the button or the Boundary Mode opti on fr om
the Boundary menu.

1 Tutori al
1-34
Change the CSG model . You can re-enter the dr aw mode by sel ecti ng
Draw Mode fr om the Draw menu or by cl i cki ng on one of the Draw mode
i cons to add another sol i d object. Back i n the Draw mode, you are abl e to
add, change, or del ete sol i d objects and al so to al ter the set for mul a.
I n addi ti on to the recommended path of acti ons, there are a number of
shortcuts, whi ch al l ow you to ski p over one or mor e steps. I n gener al , the
pde t ool GUI adds the necessary steps automati cal l y.
I f you havent yet defi ned a CSG model , and l eave the Draw mode wi th an
empty model , pdet ool cr eates an L-shaped geometry wi th the defaul t
boundary condi ti on and then proceeds to the acti on cal l ed for , per formi ng al l
the steps necessar y.
I f you ar e i n the Draw mode and pr ess the button to i ni ti al i ze the mesh,
pdet ool fi r st decomposes the geometry usi ng the cur rent set formul a and
assi gns the defaul t boundar y condi ti on to the outer boundari es. After that,
an i ni ti al mesh i s cr eated.
I f you pr ess the refine button to r efi ne the mesh befor e the mesh has been
i ni ti al i zed, pdet ool fi rst i ni ti al i zes the mesh (and decomposes the geometry,
i f you were sti l l i n the Draw mode).
I f you pr ess the = button to sol ve the PDE and you have not yet cr eated a
mesh, pdet ool i ni ti al i zes a mesh before sol vi ng the PDE.
I f you sel ect a pl ot type and choose to pl ot the sol uti on, pde t ool checks to see
i f ther e i s a sol uti on to the curr ent PDE avai l abl e. I f not, pdet ool fi rst sol ves
the curr ent PDE. The sol uti on i s then di spl ayed usi ng the sel ected pl ot
opti ons.
I f you havent defi ned your PDE, pde t ool sol ves the defaul t PDE, whi ch i s
Poi ssons equati on:
- u= 10
(Thi s cor responds to the gener i c el l i pti c PDE wi th c = 1, a = 0, and f = 10.)
For the di ffer ent appl i cati on modes, di ffer ent defaul t PDE setti ngs appl y.
Usi ng the G raphi cal User Interface
1-35
Object Selection Methods
Thr oughout the GUI , si mi l ar pri nci pl es appl y for sel ecti ng objects such as sol i d
objects, subdomai ns, and boundari es.
To sel ect a si ngl e object, cl i ck on i t usi ng the l eft mouse button.
To sel ect sever al objects and to desel ect objects, Shift-cl i ck (or cl i ck usi ng
the mi ddl e mouse button) on the desi red objects.
Cl i cki ng i n the i nter secti on of sever al objects sel ects al l the i nter secti ng
objects.
To open an associ ated di al og box, doubl e-cl i ck on an object. I f the object i s
not sel ected, i t i s sel ected before openi ng the di al og box.
I n Draw mode and PDE mode, cl i cki ng outsi de of objects desel ects al l
objects.
To sel ect al l objects, use the Select All opti on from the Edit menu.
When defi ni ng boundar y condi ti ons and the PDE vi a the menu i tems fr om
the Boundary and PDE menus, and no boundari es or subdomai ns ar e
sel ected, the enter ed val ues appl i es to al l boundar i es and subdomai ns by
defaul t.
Display Additional Information
I n Mesh mode, you can use the mouse to di spl ay the node number and the
tr i angl e number at the posi ti on where you cl i ck. Pr ess the l eft mouse button to
di spl ay the node number on the i nfor mati on l i ne. Pr ess the mi ddl e mouse
button (or use the l eft mouse button and the Shift key) to di spl ay the tri angl e
number on the i nformati on l i ne.
I n Plot mode, you can use the mouse to di spl ay the numeri cal val ue of the
pl otted property at the posi ti on where you cl i ck. Pr ess the l eft mouse button to
di spl ay the tri angl e number and the val ue of the pl otted proper ty on the
i nfor mati on l i ne.
The i nformati on remai ns on the i nformati on l i ne unti l you rel ease the mouse
button.
1 Tutori al
1-36
Entering Parameter Values as MATLAB Expressions
When enteri ng parameter val ues, e.g., as a functi on of x and y, the enter ed
stri ng must be a MATLAB expressi on to be eval uated for x and y defi ned on the
cur rent mesh, i .e., x and y ar e MATLAB row vectors. For exampl e, the functi on
4 x y shoul d be enter ed as 4*x . *y and not as 4*x *y , whi ch normal l y i s not a
val i d MATLAB expr essi on.
Using PDE Toolbox version 1.0 Model M-files
You can conver t Model M-files created usi ng versi on 1.0 of the PDE Tool box for
MATLAB 4.2 for use wi th PDE Tool box versi on 1.0.2 and MATLAB 5. The ol d
Model M-fi l es cannot be used di r ectl y i n PDE Tool box 1.0.2
To conver t your ol d Model M-fi l es, use the conversi on uti l i ty pdemdl c v. To
conver t a Model M-fi l e cal l ed mode l 42. m to a PDE Tool box 1.0.2 compati bl e
Model M-fi l e cal l ed model 5. m, type the fol l owi ng at the MATLAB command l i ne:
pde mdl c v model 42 mode l 5
Usi ng C ommand-Li ne Functi ons
1-37
Using Command-Line Functions
Al though the pdet ool GUI provi des a conveni ent worki ng envi r onment, ther e
ar e si tuati ons wher e the fl exi bi l i ty of usi ng the command-l i ne functi ons i s
needed. These i ncl ude:
Geometri cal shapes other than strai ght l i nes, ci rcul ar ar cs, and el l i pti cal
arcs
Nonstandard boundary condi ti ons
Compl i cated PDE or boundar y condi ti on coeffi ci ents
More than two dependent vari abl es i n the system case
Nonl ocal sol uti on constr ai nts
Speci al sol uti on data processi ng and pr esentati on i temi ze
The GUI can sti l l be a val uabl e ai d i n some of the si tuati ons pr esented above,
i f part of the model i ng i s done usi ng the GUI and then made avai l abl e for
command-l i ne use thr ough the extensi ve data expor t faci l i ti es of the GUI .
Data Structures and Utility Functions
The process of defi ni ng your probl em and sol vi ng i t i s refl ected i n the desi gn of
the GUI . A number of data structures defi ne di ffer ent aspects of the probl em,
and the vari ous processi ng stages pr oduce new data structures out of ol d ones.
See the fi gur e on the next page.
The rectangl es are functi ons, and el l i pses are data r epr esented by matri ces or
M-fi l es. Ar rows i ndi cate data necessary for the functi ons.
As ther e i s a defi ni te di r ecti on i n thi s di agr am, you can cut i nto i t by pr esenti ng
the needed data sets, and then conti nue downwar d. I n the secti ons bel ow we
gi ve poi nter s to descri pti ons of the pr eci se for mats of the vari ous data
str uctur es and M-fi l es.
1 Tutori al
1-38
Constructive Solid Geometry Model
A Constructi ve Sol i d Geometry (CSG) model i s speci fi ed by a Geometry
Description matrix, a set formula, and a Name Space matrix. These data
structures are descri bed i n the Reference chapter entr y on de c s g. At thi s l evel ,
the pr obl em geometr y i s defi ned by over l appi ng sol i d objects. These can be
created by drawi ng the CSG model i n the GUI and then expor ti ng the data
usi ng the Export Geometry Description, Set Formula, Labels. . . opti on
from the Draw menu.
Geometry
Description
mat r i x
Decomposed
Geometry
mat r i x
Mesh
data
Geometry
M- f i l e
Coefficient
mat r i x
Coefficient
M- f i l e
initmesh
refinemesh
assempde
Boundary
M- f i l e
Boundary
Condition
mat r i x
Solution
data
decsg
pdeplot
Usi ng C ommand-Li ne Functi ons
1-39
Decomposed Geometry
A decomposed geometry i s speci fi ed by ei ther a Decomposed Geometry matrix,
or by a Geometry M-file. Her e, the geometry i s descri bed as a set of disjoint
minimal regions bounded by boundary segments and border segments. A
Decomposed Geometry matri x can be created from a CSG model by usi ng the
functi on dec s g. I t can al so be exported from the GUI by sel ecti ng the Export
Decomposed Geometry, Boundary Conds. . . opti on from the Boundary
menu. A Geometr y M-fi l e equi val ent to a gi ven Decomposed Geometry matri x
can be created usi ng the wgeom functi on. A decomposed geometr y can be
vi sual i zed wi th the pde gpl ot functi on. The data str uctur es of the Decomposed
Geometry matri x and Geometr y M-fi l e are descr i bed i n Chapter 5, "Reference"
entr i es on de cs g, and pdegeom, r especti vel y.
Boundary Conditions
These are speci fi ed by ei ther a Boundary Condition matrix, or a Boundary
M-file. Boundar y condi ti ons are gi ven as functi ons on boundar y segments. A
Boundary Condi ti on matr i x can be exported from the GUI by sel ecti ng the
Export Decomposed Geometry, Boundary Conds. . . opti on fr om the
Boundary menu. A Boundar y M-fi l e equi val ent to a gi ven Boundar y
Condi ti on matri x can be cr eated usi ng the wbound functi on. The data
str uctur es of the Boundary Condi ti on matr i x and Boundary M-fi l e are
descr i bed i n Chapter 5, "Refer ence" entri es on as s e mb and pdebound
respecti vel y.
Equation Coefficients
The PDE i s speci fi ed by ei ther a Coefficient matrix or a Coefficient M-file for
each of the PDE coeffi ci ents c, a, f, and d. The coeffi ci ents are functi ons on the
subdomai ns. Coeffi ci ents can be expor ted fr om the GUI by sel ecti ng the
Export PDE Coefficients. . . opti on from the PDE menu. The detai l s on the
equati on coeffi ci ent data structures ar e gi ven i n the Chapter 5, "Reference"
entr y on as s e mpde .
Mesh
A tri angul ar mesh i s descri bed by the mesh data whi ch consi sts of a Point
matrix, an Edge matrix, and a Triangle matrix. I n the mesh, mi ni mal r egi ons
ar e tr i angul ated i nto subdomai ns, and border segments and boundar y
segments are broken up i nto edges. Mesh data i s cr eated from a decomposed
geometry by the functi on i ni t mes h and can be al ter ed by the functi ons
1 Tutori al
1-40
r ef i nemes h and j i ggl eme s h. The Export Mesh. . . opti on fr om the Mesh
menu pr ovi des another way of creati ng mesh data. The adapt mes h functi on
creates mesh data as par t of the sol uti on process. The mesh may be pl otted
wi th the pde me s h functi on. The detai l s on the mesh data r epr esentati on are
gi ven i n the Reference entr y on i ni t me s h.
Solution
The sol uti on of a PDE probl em i s represented by the solution vector. A sol uti on
gi ves the val ue at each mesh poi nt of each dependent vari abl e, perhaps at
sever al poi nts i n ti me, or connected wi th di fferent ei genval ues. Sol uti on
vectors ar e produced fr om the mesh, the boundary condi ti ons, and the equati on
coeffi ci ents by as s empde , pdenonl i n, adapt me s h, par abol i c , hy pe r bol i c, and
pde ei g. The Export Solution. . . opti on from the Solve menu exports
sol uti ons to the wor kspace. Si nce the meani ng of a sol uti on vector i s dependent
on i ts corr espondi ng mesh data, they ar e al ways used together when a sol uti on
i s pr esented. The detai l s on sol uti on vector s are gi ven i n the Chapter 5,
"Reference" entr y on as s e mpde .
Post Processing and Presentation
Gi ven a sol uti on/mesh pai r, a vari ety of tool s i s pr ovi ded for the vi sual i zati on
and processi ng of the data. pdei nt r p and pde pr t ni can be used to i nter pol ate
between functi ons defi ned at tri angl e nodes and functi ons defi ned at tri angl e
mi dpoi nts. t r i 2gr i d i nterpol ates a functi ons fr om a tr i angul ar mesh to a
r ectangul ar gr i d. pde gr ad and pde c gr ad compute gradi ents of the sol uti on.
pde pl ot has a l arge number of opti ons for pl otti ng the sol uti on. pdec ont and
pde s ur f are conveni ent shorthands for pde pl ot .
Hints and Suggestions for Using Command-Line
Functions
Sever al exampl es of command-l i ne functi on usage ar e gi ven i n the Examples
chapter .
Use the export faci l i ti es of the GUI as much as you can. They pr ovi de data
structures wi th the corr ect syntax, and these ar e good starti ng poi nts that you
can modi fy to sui t your needs.
A good way to pr oduce a Geometr y M-fi l e descri bi ng a geometr y outsi de of the
possi bi l i ti es provi ded by the GUI , i s to draw a si mi l ar geometry usi ng the GUI ,
expor t the Decomposed Geometr y matr i x, and wri te a Geometry M-fi l e wi th
wge om. The speci al segments can then be edi ted by hand. An exampl e of a
Usi ng C ommand-Li ne Functi ons
1-41
hand-tai l or ed Geometry M-fi l e i s c ar dg, al so presented i n the Chapter 5,
"Reference" entry on pde ge om.
Worki ng wi th the system matri ces and vector s pr oduced by as s ema and assemb
can someti mes be val uabl e. When sol vi ng the same equati on for di fferent l oads
or boundary condi ti ons, i t pays to assembl e the sti ffness matr i x onl y once.
Poi nt l oads on a par ti cul ar node can be i mpl emented by addi ng the l oad to the
cor respondi ng r ow i n the ri ght-hand si de vector. A non-l ocal constrai nt can be
i ncorporated i nto the H and R matr i ces.
An exampl e of a hand-wri tten Coeffi ci ent M-fi l e i s ci r c l e f that produces a
poi nt l oad. You can fi nd the ful l exampl e i n pdedemo7 and i n the Reference entry
on as s e mpde.
The routi nes for adapti ve mesh gener ati on and sol uti on ar e powerful but can
l ead to dense meshes and thus l ong computati on ti mes. Setti ng the Nge n
parameter to one l i mi ts you to a si ngl e refi nement step. Thi s step can then be
repeated to show the pr ogress of the refi nement. The Maxt parameter hel ps you
stop befor e the adapti ve sol ver generates too many tri angl es. An exampl e of a
hand-wr i tten tr i angl e sel ecti on functi on i s c i r c l e pi ck, used i n pde de mo7.
Remember that you al ways need a decomposed geometr y wi th adapt mes h.
Deformed meshes ar e easi l y pl otted by addi ng offsets to the Poi nt matr i x p.
Assumi ng two vari abl es stor ed i n the sol uti on vector u:
np=s i z e ( p, 2) ;
pde me s h( p+s c al e*[ u( 1: np) u( np+1: np+np) ] ' , e , t )
The ti me evol uti on of ei genmodes i s obtai ned by, e.g.,
u1=u( : , mode ) *c os ( s qr t ( l ( mode) ) *t l i s t ) % hy pe r bol i c
for posi ti ve ei genval ues i n hyperbol i c probl ems, or
u1=u( : , mode ) *e xp( - l ( mode) *t l i s t ) ; % par abol i c
i n par abol i c probl ems. Thi s makes ni ce ani mati ons, perhaps together wi th
defor med mesh pl ots.
1 Tutori al
1-42

2
Exampl es
Examples of Elliptic Problems . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Poi ssons Equati on on Uni t Di sk . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
A Scatteri ng Probl em . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
A Mi ni mal Sur face Probl em . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Domai n Decomposi ti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Examples of Parabolic Problems . . . . . . . . . . . . . . . . . . . . . 2-16
The Heat Equati on: A Heated Metal Bl ock . . . . . . . . . . . . . . . 2-16
Heat Di stri buti on i n Radi oacti ve Rod . . . . . . . . . . . . . . . . . . . . 2-21
Examples of Hyperbolic Problems . . . . . . . . . . . . . . . . . . . 2-23
The Wave Equati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Examples of Eigenvalue Problems . . . . . . . . . . . . . . . . . . . 2-27
Ei genval ues and Ei genfuncti ons for the L-Shaped
Membrane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
L-Shaped Membr ane wi th Rounded Cor ner . . . . . . . . . . . . . . . 2-31
Ei genval ues and Ei genmodes of a Squar e . . . . . . . . . . . . . . . . . 2-32
Application Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
The Appl i cati on Modes and the GUI . . . . . . . . . . . . . . . . . . . . . 2-35
Structural Mechani cs - Pl ane Stress . . . . . . . . . . . . . . . . . . . . . 2-36
Structural Mechani cs - Pl ane Strai n . . . . . . . . . . . . . . . . . . . . . 2-41
El ectrostati cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
Magnetostati cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
AC Power El ectromagneti cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51
Conducti ve Medi a DC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-55
Heat Tr ansfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-57
Di ffusi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-61
2 Examples
2-2
Examples of Elliptic Problems
Thi s secti on descri bes the sol uti on of some el l i pti c PDE probl ems. The l ast
pr obl em, a mi ni mal sur face probl em, i s nonl i near and i l l ustrates the use of the
nonl i near sol ver. The pr obl ems are sol ved usi ng both the gr aphi cal user
i nterface and the command-l i ne functi ons of the PDE Tool box.
Poissons Equation on Unit Disk
As a fi rst exampl e of an el l i pti c probl em, l ets use the si mpl est el l i pti c PDE of
al l Poissons equation.
The probl em for mul ati on i s
U = 1 i n , U = 0 on
where i s the uni t di sk. I n thi s case, the exact sol uti on i s:
so the err or of the numeri c sol uti on can be eval uated for di ffer ent meshes.
Using the Graphical User Interface
Wi th the pde t ool GUI star ted, per for m the fol l owi ng steps usi ng the Generic
Scalar mode:
1 Usi ng some of the Option menu features, add a gr i d and tur n on the
snap-to-gri d featur e. Dr aw a ci r cl e by cl i cki ng on the button wi th the
el l i pse i con wi th the + si gn, and then cl i ck-and-dr ag from the or i gi n, usi ng
the right mouse button to a poi nt at the ci r cl es peri meter . I f the ci r cl e that
you cr eate i s not a perfect uni t ci rcl e, doubl e-cl i ck the ci rcl e. Thi s opens a
di al og box where you can speci fy the exact center l ocati on and radi us of the
ci r cl e.
2 Enter the Boundary mode by cl i cki ng on the button wi th the i con. The
boundar i es of the decomposed geometr y are pl otted, and the outer
boundar i es are assi gned a defaul t boundar y condi ti on (Di r i chl et boundar y
condi ti on, u = 0 on the boundar y). I n thi s case, thi s i s what we want. I f the
boundar y condi ti on i s di ffer ent, doubl e-cl i ck on the boundary to open a
di al og box through whi ch you can enter and di spl ay the boundar y condi ti on.

U x y , ( )
1 x
2
y
2

4
------------------------- =

Examples of Elli pti c Problems
2-3
3 To defi ne the par ti al di fferenti al equati on, press the PDE button. Thi s opens
a di al og box, wher e you can defi ne the PDE coeffi ci ents c , a, and f . I n thi s
si mpl e case, they ar e al l constants: c = 1, f = 1, and a = 0.
4 Press the button or sel ect Initialize Mesh fr om the Mesh menu. Thi s
i ni ti al i zes and di spl ays a tri angul ar mesh.
5 Press the Refine button or sel ect Refine Mesh fr om the Mesh menu. Thi s
causes a refi nement of the i ni ti al mesh, and the new mesh i s di spl ayed.
6 To sol ve the system, just press the = button. The tool box assembl es the PDE
pr obl em and sol ves the l i near system. I t al so provi des a pl ot of the sol uti on.
Usi ng the Plot Selection di al og box, you can sel ect di fferent types of
sol uti on pl ots.
7 To compare the numer i cal sol uti on to the exact sol uti on, sel ect the user
entry i n the Property pop-up menu for Color i n the Plot Selection di al og
box. Then i nput the MATLAB expressi on u( 1x . ^2y. ^2) /4 i n the user
entry edi t fi el d. You obtai n a pl ot of the absol ute er ror i n the sol uti on.
2 Examples
2-4
You can al so compare the numer i cal sol uti on to the exact sol uti on by enteri ng
some si mpl e command-l i ne ori ented commands (see the next secti on). I t i s easy
to export the mesh data and the sol uti on to MATLABs mai n workspace by
usi ng the Export . . . opti ons from the Mesh and Solve menus. To refi ne the
mesh and sol ve the PDE successi vel y, si mpl y press the refine and = push
buttons unti l the desi r ed accuracy i s achi eved. (Another possi bi l i ty i s to use the
adapti ve sol ver.)
Using Command-Line Functions
Fi r st you must cr eate a MATLAB functi on that par ameteri zes the 2-D geometry
i n thi s case a uni t ci rcl e.
The M-fi l e c i r c l e g. m returns the coordi nates of poi nts on the uni t ci rcl es
boundar y. The fi l e conforms to the fi l e format descri bed i n the pde ge om entry
i n the Reference chapter . You can di spl ay the M-fi l e by typi ng t y pe c i r c l e g.
Al so, you need a functi on that descri bes the boundary condi ti on. Thi s i s a
Di ri chl et boundary condi ti on where u = 0 on the boundar y. The M-fi l e
c i r cl eb1. m pr ovi des the boundar y condi ti on. The fi l e conforms to the fi l e
format descri bed i n the pde bound entr y i n Chapter 5, "Reference". You can
di spl ay the M-fi l e by typi ng t ype c i r cl eb1.
Now you can star t worki ng fr om MATLABs command l i ne:
[ p, e, t ] =i ni t me s h( ' ci r cl eg' , ' Hmax ' , 1) ;
e r r or =[ ] ; er r =1;
whi l e e r r > 0. 001,
[ p, e , t ] =r e f i ne mes h( ' c i r cl e g' , p, e , t ) ;
u=as s e mpde ( ' ci r cl eb1' , p, e , t , 1, 0, 1) ;
e xac t =( p( 1, : ) . ^2+p( 2, : ) . ^21) /4;
e r r =nor m( ue xac t ' , i nf ) ;
e r r or =[ e r r or e r r ] ;
end
pde me s h( p, e, t )
pde s ur f ( p, t , u)
pde s ur f ( p, t , uex ac t ' )
The fi rst MATLAB command cr eates the i ni ti al mesh usi ng the parameter i zi ng
functi on ci r c l e g.
Examples of Elli pti c Problems
2-5
Al so, i ni ti al i ze a vector er r or for the maxi mum norm err or s of the successi ve
sol uti ons and set the i ni ti al er ror e r r to 1. The l oop then r uns unti l the err or of
the sol uti on i s smal l er than 10
-3
:
1 Refi ne the mesh. The cur rent tr i angul ar mesh, defi ned by the geometr y
c i r cl eg, the poi nt matri x p, the edge matr i x e, and the tri angl e matri x t , i s
r efi ned, and the mesh i s r etur ned usi ng the same matri x vari abl es.
2 Assembl e and sol ve the l i near system. Note that the coeffi ci ents of the
el l i pti c PDE are constants (c = f = 1, a = 0) for thi s si mpl e case. ci r c l e b1
contai ns a descr i pti on of the boundary condi ti ons, and p, e, and t defi ne the
tr i angul ar mesh.
3 Fi nd the err or of the numer i cal sol uti on produced by the PDE Tool box. The
vector ex act contai ns the exact sol uti on at the nodes. Note that what you
actual l y fi nd i s the max-nor m er ror of the sol uti on at the nodes.
4 Pl ot the mesh, the sol uti on, and the err or. Noti ce that the pl ot functi on
pde s ur f as thi r d ar gument can take any vector of val ues on the mesh gi ven
by p and t , not just the sol uti on. I n thi s case you are al so pl otti ng the err or
functi on.
pde de mo1 performs al l the above steps.
1
0.5
0
0.5
1
1
0.5
0
0.5
1
0
1
2
3
4
x 10
4
The error function
2 Examples
2-6
A Scattering Problem
The scatteri ng probl em i s to compute the waves r efl ected fr om an object
i l l umi nated by i nci dent waves. For thi s pr obl em consi der an i nfi ni te hori zontal
membr ane subjected to smal l ver ti cal di spl acements U. The membrane i s fi xed
at the object boundar y.
We assume that the medi um i s homogeneous so that the wave speed i s
constant, c.
NOTE: Do not confuse thi s c wi th the par ameter c appeari ng i n the PDE
Tool box.
When the i l l umi nati on i s har moni c i n ti me, we can compute the fi el d by sol vi ng
a si ngl e steady probl em. Wi th U(x,y,t) = u(x,y)e
-it
, the wave equati on
turns i nto
2
u c
2
u=0 or the Helmholtzs equation
r
V
U
2

t
2
--------- c
2
U 0 =
u k
2
u 0 =
Examples of Elli pti c Problems
2-7
where k, the wave number, i s rel ated to the angul ar frequency , the frequency
f, and the wavel ength by
We have yet to speci fy the boundar y condi ti ons. Let the i nci dent wave be a
pl ane wave tr avel i ng i n the di r ecti on = (cos(a),si n(a)):
where .
u i s the sum of v and the refl ected wave r,
u =v +r
The boundar y condi ti on for the objects boundary i s easy: u = 0, i .e.,
r = v(x,y)
(For acousti c waves, wher e v i s the pressure di sturbance, the proper condi ti on
woul d be .) The r efl ected wave r tr avel s outward from the object. The
condi ti on at the outer computati onal boundar y shoul d be chosen to al l ow waves
to pass wi thout refl ecti on. Such condi ti ons are usual l y cal l ed nonr efl ecti ng, and
we use the cl assi cal Sommerfeld radiation condition. As approaches i nfi ni ty,
r approxi matel y sati sfi es the one-way wave equati on:
whi ch al l ows waves movi ng i n the posi ti ve -di recti on onl y ( i s the r adi al
di stance from the object). Wi th the ti me-harmoni c sol uti on, thi s tur ns i nto the
gener al i zed Neumann boundar y condi ti on
For si mpl i ci ty reasons, l ets make the outwar d nor mal of the computati onal
domai n approxi mate the outward -di recti on.
k

c
----
2f
c
--------
2

------ = = =
a
V x y t , , ( ) e
i ka x t ( )
v x y , ( )e
it
, = =
v x y , ( ) e
i ka x
=
u
n
------ 0 =
x
r
t
----- c + r 0, =
r ikr =
2 Examples
2-8
Using the Graphical User Interface
You can now use pde t ool to sol ve thi s scatteri ng probl em. Usi ng the Generic
Scalar mode, star t by dr awi ng the 2-D geometr y of the probl em. Let the
i l l umi nated object be a square SQ1 wi th a si de of 0.1 uni ts and center i n [ 0. 8
0. 5] and rotated 45 degr ees, and l et the computati onal domai n be a ci rcl e C1
wi th a radi us of 0.45 uni ts and the same center l ocati on. The Constructi ve Sol i d
Geometr y (CSG) model i s then gi ven by C1SQ1.
For the outer boundar y (the ci r cl e per i meter), the boundar y condi ti on i s a
general i zed Neumann condi ti on wi th q = ik. The wave number k = 60, whi ch
cor responds to a wavel ength of about 0.1 uni ts, so enter 60i as a constant q
and 0 as a constant g.
For the square objects boundary, you have a Di ri chl et boundary condi ti on:
I n thi s probl em, the i nci dent wave i s travel i ng i n the x di r ecti on, so the
boundar y condi ti on i s si mpl y
r = e
-ikx
Enter thi s boundar y condi ti on i n the Boundary Condition di al og box as a
Di ri chl et condi ti on: h=1, r =ex p( i *60*x ) . The r eal part of thi s i s a si nusoi d.
For suffi ci ent accuracy, about 10 fi ni te el ements per wavel ength ar e needed.
The outer boundar y shoul d be l ocated a few object di ameters from the object
i tsel f. An i ni ti al mesh gener ati on and two successi ve mesh r efi nements gi ve
appr oxi matel y the desi r ed r esol uti on.
Al though or i gi nal l y a wave equati on, the transformati on i nto a Hel mhol tzs
equati on makes i t i n the PDE Tool box context, but not str i ctl y
mathemati cal l y an el l i pti c equati on. The el l i pti c PDE coeffi ci ents for thi s
pr obl em ar e c = 1, a = k
2
= 3600, and f = 0. Open the PDE Specification
di al og box and enter these val ues.
The probl em can now be sol ved, and the sol uti on i s compl ex. For a compl ex
sol uti on, the real part i s pl otted and a warni ng message i s i ssued.
The propagati on of the r efl ected waves i s computed as
Re(r(x,y)e
-it
)
whi ch i s the refl ex of
r v x y , ( ) e
i ka x
= =
Examples of Elli pti c Problems
2-9
To see the whol e fi el d, pl ot
The refl ected waves and the shadow behi nd the object ar e cl earl y vi si bl e
when you pl ot the r efl ected wave.
To make an ani mati on of the refl ected wave, the sol uti on and the mesh data
must fi r st be expor ted to the mai n wor kspace. Then make a scri pt M-fi l e or type
the fol l owi ng commands at the MATLAB pr ompt:
h=ne wpl ot ; hf =get ( h, Par ent ) ; s e t ( hf , Re nde r e r , z buf f er )
axi s t i ght , s e t ( gca, Dat aAs pec t Rat i o , [ 1 1 1] ) ; axi s of f
M=mov i e i n( 10, hf ) ;
max u=max( abs ( u) ) ;
col or map( cool )
f or j =1: 10,
ur =r e al ( ex p( j *2*pi /10*s qr t ( 1) ) *u) ) ;
pde pl ot ( p, e, t , ' x ydat a' , ur , ' col or bar ' , ' of f ' , ' mes h' , ' of f ' ) ;
c ax i s ( [ maxu max u] ) ;
axi s t i ght , s e t ( gc a, Dat aAs pe ct Rat i o , [ 1 1 1] ) ; axi s of f
M( : , j ) =get f r ame;
e nd
mov i e ( hf , M, 50) ;
pde de mo2 contai ns a ful l command-l i ne demonstrati on of the scatteri ng
probl em.
Re e
i ka x t ( )
) (
Re r x y , ( ) ( ( e
i ka x
)e
i t
) +
2 Examples
2-10
A Minimal Surface Problem
I n many pr obl ems the coeffi ci ents c, a, and f do not onl y depend on x and y, but
al so on the sol uti on u i tsel f. Consi der the equati on
on the uni t di sk wi th on .
Thi s pr obl em i s nonl i near and cannot be sol ved wi th the regul ar el l i pti c sol ver.
I nstead, the nonl i near sol ver pde nonl i n i s used.
Lets sol ve thi s minimal surface problem usi ng the pdet ool GUI and
command-l i ne functi ons.
Using the Graphical User Interface
Make sur e that the appl i cati on mode i n the pde t ool GUI i s set to Generic
Scalar. The probl em domai n i s si mpl y a uni t ci r cl e. Draw i t and move to the
Boundary mode to defi ne the boundar y condi ti ons. Use Select All from the
Edit menu to sel ect al l boundar i es. Then doubl e-cl i ck on a boundar y to open
the Boundary Condition di al og box. The Di ri chl et condi ti on u =x
2
i s entered
by typi ng x . ^2 i nto the r edi t box. Next, open the PDE Specification di al og
box to defi ne the PDE. Thi s i s an el l i pti c equati on wi th
The nonl i near c i s entered i nto the c edi t box as
1. /s qr t ( 1+ux . ^2+uy . ^2)
I ni ti al i ze a mesh and refi ne i t once.
Before sol vi ng the PDE, sel ect Parameters . . . fr om the Solve menu and
check the Use nonlinear solver opti on. Al so, set the tol er ance par ameter to
0. 001.
Push the = button to sol ve the PDE. Use the Plot Selection di al og box to pl ot
the sol uti on i n 3-D (check u and cont i nuous sel ecti ons i n the Height col umn)
to vi sual i ze the saddl e shape of the sol uti on.

1
1 u
2
+
--------------------------u



0, =
x y ( , ) x
2
y
2
1 + { } = u x
2
=
c
1
1 u
2
+
-------------------------- a 0, = and f 0. = , =
Examples of Elli pti c Problems
2-11
Using Command-Line Functions
Worki ng fr om the command l i ne, the fol l owi ng sequence of commands sol ves
the mi ni mal sur face probl em and pl ots the sol uti on. The M-fi l es ci r c l e g and
ci r cl eb2 contai n the geometry speci fi cati on and boundary condi ti on functi ons,
respecti vel y.
g=' ci r c l e g' ;
b=' ci r c l e b2' ;
c=' 1. /s qr t ( 1+ux . ^2+uy. ^2) ' ;
r t ol =1e 3;

[ p, e, t ] =i ni t mes h( g) ;
[ p, e, t ] =r ef i neme s h( g, p, e , t ) ;

u=pde nonl i n( b, p, e, t , c, 0, 0, Tol , Tol , r t ol ) ;

pde s ur f ( p, t , u)
You can run thi s exampl e by typi ng pde de mo3.
1
0.5
0
0.5
1
1
0.5
0
0.5
1
0
0.2
0.4
0.6
0.8
1
2 Examples
2-12
Domain Decomposition
The PDE Tool box i s desi gned to deal wi th one-l evel domai n decomposi ti on. I f
has a compl i cated geometry, i t i s often useful to decompose i t i nto the uni on
of mor e subdomai ns of si mpl er str uctur e. Such str uctures are often i ntroduced
by pde t ool .
Assume now that i s the di sjoi nt uni on of some subdomai ns
1
,
2
, . . . ,
n
.
Then you coul d r enumber the nodes of a mesh on such that the i ndi ces of the
nodes of each subdomai n are gr ouped together, whi l e al l the i ndi ces of nodes
common to two or mor e subdomai ns come l ast. Si nce K has nonzer o entr i es onl y
at the l i nes and col umns that ar e i ndi ces of nei ghbori ng nodes, the sti ffness
matri x i s par ti ti oned as fol l ows:
whi l e the ri ght-hand si de i s
The PDE Tool box r outi ne as s e mpde can assembl e the matr i ces K
j
, B
j
, f
j
, and C
separ atel y. You have ful l contr ol over the storage and fur ther pr ocessi ng of
these matri ces.
Fur ther more, the structure of the l i near system
Ku =F
i s si mpl i fi ed by decomposi ng K i nto the par ti ti oned matr i x above.
K
K
1
0 0 B
1
T
0 K
2
0 B
2
T
0 0 K
n
B
n
T
B
1
B
2
B
n
C











=
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
F
f
1
f
2
f
n
f
c









=
.

.

.
Examples of Elli pti c Problems
2-13
Now consi der the geometry of the L-shaped membr ane. You can pl ot the
geometry of the membrane by typi ng:
pde gpl ot ( ' l s hape g' )
Noti ce the borders between the subdomai ns. There ar e three subdomai ns. Thus
the matr i x for mul as wi th n = 3 from above can be used. Now gener ate a mesh
for the geometry:
[ p, e, t ] =i ni t mes h( ' l s hape g' ) ;
[ p, e, t ] =r ef i neme s h( ' l s hape g' , p, e, t ) ;
[ p, e, t ] =r ef i neme s h( ' l s hape g' , p, e, t ) ;
So for thi s case, wi th n = 3, you have
and the sol uti on i s gi ven by bl ock el i mi nati on:
K
1
0 0 B
1
T
0 K
2
0 B
2
T
0 0 K
3
B
3
T
B
1
B
2
B
3
C









u
1
u
2
u
3
u
c








f
1
f
2
f
3
f
c








=
C B
1
K
1
1
B
1
T
B
2
K
2
1
B
2
T
B
3
K
3
1
B
3
T
( )u
c
f
c
B
1
K
1
1
f
1
B
2
K
2
1
f
2
B
3
K
3
1
f
3
=
u
1
K
1
1
f
1
B
1
T
u
c
( ) =

2 Examples
2-14
I n the MATLAB sol uti on bel ow, a more effi ci ent al gori thm usi ng Chol eski
factori zati on i s used:
t i me=[ ] ;
np=s i z e ( p, 2) ;
% Fi nd common poi nt s
c =pde s dp( p, e , t ) ;

nc=l e ngt h( c) ;
C=z er os ( nc , nc) ;
FC=z e r os ( nc, 1) ;

[ i 1, c 1] =pdes dp( p, e , t , 1) ; i c1=pde s ubi x ( c , c 1) ;
[ K, F] =as s e mpde ( ' l s hapeb' , p, e, t , 1, 0, 1, t i me, 1) ;
K1=K( i 1, i 1) ; d=s y mmmd( K1) ; i 1=i 1( d) ;
K1=chol ( K1( d, d) ) ; B1=K( c 1, i 1) ; a1=B1/K1;
C( i c1, i c1) =C( i c1, i c1) +K( c 1, c1) a1*a1' ;
f 1=F( i 1) ; e 1=K1' \f 1; FC( i c1) =FC( i c 1) +F( c 1) a1*e 1;

[ i 2, c 2] =pdes dp( p, e , t , 2) ; i c2=pde s ubi x ( c , c 2) ;
[ K, F] =as s e mpde ( ' l s hapeb' , p, e, t , 1, 0, 1, t i me, 2) ;
K2=K( i 2, i 2) ; d=s y mmmd( K2) ; i 2=i 2( d) ;
K2=chol ( K2( d, d) ) ; B2=K( c 2, i 2) ; a2=B2/K2;
C( i c2, i c2) =C( i c2, i c2) +K( c 2, c2) a2*a2' ;
f 2=F( i 2) ; e 2=K2' \f 2; FC( i c2) =FC( i c 2) +F( c 2) a2*e 2;

[ i 3, c 3] =pdes dp( p, e , t , 3) ; i c3=pde s ubi x ( c , c 3) ;
[ K, F] =as s e mpde ( ' l s hapeb' , p, e, t , 1, 0, 1, t i me, 3) ;
K3=K( i 3, i 3) ; d=s y mmmd( K3) ; i 3=i 3( d) ;
K3=chol ( K3( d, d) ) ; B3=K( c 3, i 3) ; a3=B3/K3;
C( i c3, i c3) =C( i c3, i c3) +K( c 3, c3) a3*a3' ;
f 3=F( i 3) ; e 3=K3' \f 3; FC( i c3) =FC( i c 3) +F( c 3) a3*e 3;

% Sol ve
u=z er os ( np, 1) ;
u( c ) =C\ FC;
u( i 1) =K1\( e1a1' *u( c 1) ) ;
u( i 2) =K2\( e2a2' *u( c 2) ) ;
u( i 3) =K3\( e3a3' *u( c 3) ) ;
Examples of Elli pti c Problems
2-15
The pr obl em can al so be sol ved by typi ng:
% Compar e wi t h s ol ut i on not us i ng s ubdomai ns
[ K, F] =as s empde( ' l s hape b' , p, e, t , 1, 0, 1) ; u1=K\F;
nor m( uu1, ' i nf ' )
pde s ur f ( p, t , u)
You can run thi s enti re exampl e by typi ng pdedemo4.
1
0.5
0
0.5
1
1
0.5
0
0.5
1
0
0.05
0.1
0.15
2 Examples
2-16
Examples of Parabolic Problems
Thi s secti on descri bes the sol uti on of some parabol i c PDE pr obl ems. The
pr obl ems ar e sol ved usi ng both the gr aphi cal user i nterface and the
command-l i ne functi ons of the PDE Tool box.
The Heat Equation: A Heated Metal Block
A common par abol i c probl em i s the heat equation:
The heat equati on descr i bes the di ffusi on of heat i n a body of some ki nd. See
the secti on Appl i cati on Modes for more i nfor mati on about heat tr ansfer and
di ffusi on pr obl ems.
Thi s fi r st exampl e studi es a heated metal bl ock wi th a r ectangul ar cr ack or
cavi ty. The l eft-hand si de of the bl ock i s heated to 100 degrees centi grade. At
the r i ght-hand si de of the metal bl ock, heat i s fl owi ng fr om the bl ock to the
surr oundi ng ai r at a constant rate. Al l the other bl ock boundari es are i sol ated.
Thi s l eads to the fol l owi ng set of boundary condi ti ons (when pr oper scal i ng of t
i s chosen):
on the l eft-hand si de (Di r i chl et condi ti on)
on the ri ght-hand si de (Neumann condi ti on)
on al l other boundari es (Neumann condi ti on)
Al so, for the heat equati on we need an i ni ti al val ue: the temperature i n the
metal bl ock at the star ti ng ti me t
0
. I n thi s case, the temperatur e of the bl ock i s
0 degrees at the ti me we star t appl yi ng heat.
Fi nal l y, to compl ete the pr obl em formul ati on, we speci fy that the starti ng ti me
i s 0 and that we want to study the heat di str i buti on duri ng the fi rst fi ve
seconds.
d
u
t
------ u 0 =
u 100 =
u
n
------ 10 =
u
n
------ 0 =
Examples of Paraboli c Problems
2-17
Using the Graphical User Interface
Once you have started the pdet ool GUI and sel ected the Generic Scalar
mode, dr awi ng the CSG model can be done very qui ckl y: Draw a r ectangl e (R1)
wi th the corner s i n x = [ 0. 5 0. 5 0. 5 0. 5] and y = [ 0. 8 0. 8 0. 8 0. 8] .
Dr aw another rectangl e (R2) to r epresent the r ectangul ar cavi ty. I ts cor ner s
shoul d have the coordi nates x = [ 0. 05 0. 05 0. 05 0. 05] and y = [ 0. 4
0. 4 0. 4 0. 4] . To assi st i n dr awi ng the nar row r ectangl e representi ng the
cavi ty, open the Grid Spacing di al og box from the Options and enter x-axi s
extr a ti cks at 0. 05 and 0. 05. Then tur n on the gri d and the snap-to-gr i d
featur e. A r ectangul ar cavi ty wi th the cor rect di mensi ons i s then easy to dr aw.
The CSG model of the metal bl ock i s now si mpl y expr essed as the set for mul a
R1R2.
Leave the Draw mode and enter the Boundary mode by pr essi ng the
button, and conti nue by sel ecti ng boundar i es and speci fyi ng the boundary
condi ti ons. Usi ng the Select All opti on fr om the Edit menu and then defi ni ng
the Neumann condi ti on for al l boundar i es fi rst i s a good i dea si nce that
l eaves onl y the l eft-most and r i ght-most boundari es to defi ne i ndi vi dual l y.
The next step i s to open the PDE Specification di al og box and enter the PDE
coeffi ci ents.

u
n
------ 0 =
2 Examples
2-18
The gener i c parabol i c PDE that the PDE Tool box sol ves i s:
wi th i ni ti al val ues u0 = u(t
0
) and the ti mes at whi ch to compute a sol uti on
speci fi ed i n the ar ray t l i s t .
For thi s case, you have d = 1, c = 1, a = 0, and f = 0.
I ni ti al i ze the mesh by pr essi ng the button. I f you want, you can r efi ne the
mesh by pr essi ng the Refine button.
The i ni ti al val ues u0 = 0, and the l i st of ti mes i s entered as the MATLAB ar ray
[0: 0. 5: 5] . They are entered i nto the Solve Parameters di al og box, whi ch i s
accessed by sel ecti ng Parameters . . . from the Solve menu.
The probl em can now be sol ved. Pr essi ng the = button sol ves the heat equati on
at 11 di ffer ent ti mes from 0 to 5 seconds. By defaul t, an i nterpol ated pl ot of the
sol uti on, i .e., the heat di stri buti on, at the end of the ti me span i s di spl ayed.
A more i nter esti ng way to vi sual i ze the dynami cs of the heat di stri buti on
pr ocess i s to animate the sol uti on. To star t an ani mati on, check the Animation
check box i n the Plot selection di al og box. Al so, sel ect the col ormap hot .
Press the Plot button to start a recor di ng of the sol uti on pl ots i n a separ ate
fi gure wi ndow. The recor ded ani mati on i s then pl ayed fi ve ti mes.
Note that the temperatur e i n the bl ock r i ses very qui ckl y. To i mpr ove the
ani mati on and focus on the fi rst second, tr y to change the l i st of ti mes to the
MATLAB expr essi on l ogs pac e( 2, 0. 5, 20) .
d
u
t
----- cu ( ) au + f, =
Examples of Paraboli c Problems
2-19
Al so, try to change the heat capaci ty coeffi ci ent d and the heat fl ow at the
ri ght-most boundar y to see how they affect the heat di str i buti on.
Using Command-Line Functions
Fi rst, you must cr eate geometr y and boundary condi ti on M-fi l es. The M-fi l es
used her e wer e created usi ng pde t ool . The geometry of the metal bl ock i s
descr i bed i n cr ac kg. m, and the boundary condi ti ons can be found i n c r ackb. m.
To create an i ni ti al mesh, cal l i ni t mes h:
[ p, e, t ] =i ni t me s h( ' c r ackg' ) ;
The heat equati on can now be sol ved usi ng the PDE Tool box functi on
par abol i c . The gener i c parabol i c PDE that par abol i c sol ves i s:
wi th i ni ti al val ue u0 = u(t
0
) and the ti mes at whi ch to compute a sol uti on
speci fi ed i n the ar ray t l i s t . For thi s case, you have d = 1, c = 1, a = 0, and
f = 0. The i ni ti al val ue u0 = 0, and the l i st of ti mes, t l i s t , i s set to the MATLAB
ar ray 0: 0. 5: 5.
d
u
t
----- cu ( ) au + f, =
2 Examples
2-20
To compute the sol uti on, cal l par abol i c:
u=par abol i c ( 0, 0: 0. 5: 5, ' c r ackb' , p, e, t , 1, 0, 0, 1) ;
The sol uti on u created thi s way a matri x wi th 11 col umns, wher e each col umn
cor responds to the sol uti on at the 11 poi nts i n ti me 0,0.5, . . . ,4.5,5.0.
Lets pl ot the sol uti on at t = 5.0 seconds usi ng i nterpol ated shadi ng and a
hi dden mesh. Use the hot col or map:
pdepl ot ( p, e , t , ' xy dat a' , u( : , 11) , ' mes h' , ' of f ' , . . .
' col or map' , ' hot ' )
Examples of Paraboli c Problems
2-21
Heat Distribution in Radioactive Rod
Thi s heat di stri buti on probl em i s an exampl e of a 3-D parabol i c PDE pr obl em
that i s r educed to a 2-D pr obl em by usi ng cyl i ndri cal coordi nates.
Consi der a cyl i ndri cal radi oacti ve rod. At the l eft end, heat i s conti nuousl y
added. The ri ght end i s kept at a constant temperature. At the outer boundar y,
heat i s exchanged wi th the surr oundi ngs by tr ansfer . At the same ti me, heat i s
uni forml y produced i n the whol e r od due to radi oacti ve pr ocesses. Assume that
the i ni ti al temperature i s zero. Thi s l eads to the fol l owi ng pr obl em:
where i s the densi ty, C i s the rods thermal capaci ty, k i s the thermal
conducti vi ty, and f i s the radi oacti ve heat source.
The densi ty for thi s metal r od i s 7800 kg/m
3
, the ther mal capaci ty i s
500 Ws/kgC, and the ther mal conducti vi ty i s 40 W/mC. The heat source i s
20000 W/m
3
. The temperatur e at the r i ght end i s 100 C. The sur roundi ng
temperature at the outer boundar y i s 100 C, and the heat transfer coeffi ci ent
i s 50 W/m
2
C. The heat fl ux at the l eft end i s 5000 W/m
2
.
But thi s i s a cyl i ndr i cal pr obl em, so you need to transform the equati on, usi ng
the cyl i ndr i cal coor di nates r, z, and . Due to symmetr y, the sol uti on i s
i ndependent of , so the tr ansfor med equati on i s
The boundar y condi ti ons ar e:
= 5000 at the l eft end of the rod (Neumann condi ti on). Si nce the
general i zed Neumann condi ti on i n the PDE Tool box i s + qu = g, and
c depends on r i n thi s pr obl em (c =kr), thi s boundary condi ti on i s expr essed
as = 5000r
u = 100 at the r i ght end of the rod (Di ri chl et condi ti on)
= 50(100-u) at the outer boundary (gener al i zed Neumann
condi ti on). I n the PDE tool box thi s must be expr essed as
+ 50r u = 50r 100.
The cyl i nder axi s r = 0 i s not a boundary i n the ori gi nal pr obl em, but i n our
2-D treatment i t has become one. We must gi ve the artificial boundar y
condi ti on here.
The i ni ti al val ue i s u(t
0
) = 0.
C
u
t
----- ku ( ) f, =
rC
u
t
------
r

kr
u
r
------

kr
u
z
------


fr =
n ku ( )
n cu ( )
n cu ( )
n ku ( )
n cu ( )
n cu ( ) 0 =
2 Examples
2-22
Using the Graphical User Interface
Sol ve thi s probl em usi ng the pde t ool GUI . Model the r od as a rectangl e wi th
i ts base al ong the x-axi s, and l et the x-axi s be the z di recti on and the y-axi s be
the r di r ecti on. A r ectangl e wi th corners i n (-1.5,0), (1.5,0), (1.5,0.2), and
(-1.5,0.2) woul d then model a r od wi th l ength 3 and radi us 0.2.
Enter the boundar y condi ti ons by doubl e-cl i cki ng on the boundar i es to open the
Boundary Condition di al og box. For the l eft end, use Neumann condi ti ons
wi th 0 for q and 5000*y for g. For the ri ght end, use Di r i chl et condi ti ons wi th 1
for h and 100 for r . For the outer boundary, use Neumann condi ti ons wi th 50*y
for q and 50*y*100 for g. For the axi s, use Neumann condi ti ons wi th 0 for q
and g.
Enter the coeffi ci ents i nto the PDE Specification di al og box: c i s 40*y , a i s
zero, d i s 7800*500*y , and f i s 20000*y.
Ani mate the sol uti on over a span of 20000 seconds (computi ng the sol uti on
ever y 1000 seconds). We can see how heat fl ows i n over the r i ght and outer
boundar i es as l ong as u < 100, and out when u > 100. You can al so open the
PDE Specification di al og box, and change the PDE type to Elliptic. Thi s
shows the sol uti on when u does not depend on ti me, i .e., the steady state
sol uti on. The pr ofound effect of cool i ng on the outer boundar y can be
demonstrated by setti ng the heat tr ansfer coeffi ci ent to zero.
Examplesof Hyperboli c Problems
2-23
Examples of Hyperbolic Problems
Thi s secti on descr i bes the sol uti on of some hyperbol i c PDE pr obl ems. The
probl ems ar e sol ved usi ng the graphi cal user i nter face and the command-l i ne
functi ons of the PDE Tool box.
The Wave Equation
As an exampl e of a hyper bol i c PDE, l ets sol ve the wave equation
for transver se vi br ati ons of a membr ane on a squar e wi th cor ner s i n (-1,-1),
(-1,1), (1,-1), and (1,1). The membrane i s fi xed (u = 0) at the l eft- and ri ght-hand
si des, and i s fr ee ( ) at the upper - and l ower-hand si des. Addi ti onal l y,
we need i ni ti al val ues for u(t
0
) and . The i ni ti al val ues need to match the
boundary condi ti ons for the sol uti on to be wel l -behaved. I f we star t at
t=0, u(0) = ar ctan(cos( )) and = 3 si n( x) e
sin( )
are i ni ti al val ues that
sati sfy the boundary condi ti ons. The reason for the arctan and exponential
functi ons i s to i ntroduce mor e modes i nto the sol uti on.
Using the Graphical User Interface
Use the pde t ool GUI i n the Generic Scalar mode. Dr aw the square usi ng the
Rectangle/square opti on from the Draw menu or the button wi th the
rectangl e i con. Pr oceed to defi ne the boundar y condi ti ons by pressi ng the
button and then doubl e-cl i ck on the boundari es to defi ne the boundar y
condi ti ons.
I ni ti al i ze the mesh by pr essi ng the button or by sel ecti ng Initialize mesh
from the Mesh menu.

2
u
t
2
-------- u 0 =
u
n
------ 0 =
u t
0
( )
t
---------------

2
---x
u 0 ( )
t
--------------

2
---y

2 Examples
2-24
Al so, defi ne the hyper bol i c PDE by openi ng the PDE Specification di al og box,
sel ecti ng the hyper bol i c PDE, and enteri ng the appropri ate coeffi ci ent val ues.
The gener al hyper bol i c PDE i s descr i bed by
so for the wave equati on you get c = 1, a = 0, f = 0, and d = 1.
Before sol vi ng the PDE, sel ect Parameters . . . fr om the Solve menu to open
the Solve Parameters di al og box. As a l i st of ti mes, enter l i ns pac e ( 0, 5, 31)
and as i ni ti al val ues for u:
at an( cos ( pi /2*x) ) ,
and for :
3*s i n( pi *x ) . *e xp( s i n( pi /2*y ) ) .
d

2
u
t
2
-------- cu ( ) au + f, =
u
t
------
Examplesof Hyperboli c Problems
2-25
Fi nal l y, pr ess the = button to compute the sol uti on. The best pl ot for vi ewi ng
the waves movi ng i n the x and y di r ecti ons i s an ani mati on of the whol e
sequence of sol uti ons. Ani mati on i s a very real ti me and memory consumi ng
featur e, so you may have to cut down on the number of ti mes at whi ch to
compute a sol uti on. A good suggesti on i s to check the Plot in x-y grid opti on.
Usi ng an x-y gr i d can speed up the ani mati on pr ocess si gni fi cantl y.
Using Command-Line Functions
From the command l i ne, sol ve the equati on wi th the boundar y condi ti ons and
the i ni ti al val ues above, star ti ng at ti me 0 and then every 0.05 seconds for fi ve
seconds.
The geometry i s descr i bed i n the fi l e s quar eg. m and the boundar y condi ti ons i n
the fi l e s quar e b3. m. The fol l owi ng sequence of commands then gener ates a
sol uti on and ani mates i t. Fi rst, create a mesh and defi ne the i ni ti al val ues and
the ti mes for whi ch you want to sol ve the equati on:
[ p, e, t ] =i ni t mes h( ' s quar e g' ) ;

x=p( 1, : ) ' ; y=p( 2, : ) ' ;

u0=at an( c os ( pi /2*x ) ) ;
ut 0=3*s i n( pi *x) . *e xp( s i n( pi /2*y ) ) ;

n=31;
t l i s t =l i ns pac e( 0, 5, n) ; % l i s t of t i me s
You ar e now r eady to sol ve the wave equati on. The general for m for the
hyper bol i c PDE i n the PDE Tool box i s:
so here you have d = 1, c = 1, a = 0, and f = 0:
uu=hy pe r bol i c ( u0, ut 0, t l i s t , ' s quar eb3' , p, e, t , 1, 0, 0, 1) ;
d

2
u
t
2
-------- cu ( ) au + f, =
2 Examples
2-26
To vi sual i ze the sol uti on, you can ani mate i t. I nter pol ate to a rectangul ar gr i d
to speed up the pl otti ng:
del t a=1: 0. 1: 1;
[ ux y, t n, a2, a3] =t r i 2gr i d( p, t , uu( : , 1) , de l t a, del t a) ;
gp=[ t n; a2; a3] ;

umax=max( max ( uu) ) ;
umi n=mi n( mi n( uu) ) ;

newpl ot
M=mov i e i n( n) ;
f or i =1: n,
pdepl ot ( p, e , t , ' xy dat a' , uu( : , i ) , ' z dat a' , uu( : , i ) , . . .
' mes h' , ' of f ' , ' x ygr i d' , ' on' , ' gr i dpar am' , gp, . . .
' c ol or bar ' , ' of f ' , ' z s t y l e ' , ' c ont i nuous ' ) ;
ax i s ( [ 1 1 1 1 umi n umax] ) ; c axi s ( [ umi n umax] ) ;
M( : , i ) =ge t f r ame ;
e nd
mov i e ( M, 10) ;
You can fi nd a compl ete demo of thi s pr obl em, i ncl udi ng ani mati on, i n
pde de mo6. I f you have l ots of memor y, you can try i ncr easi ng n, the number of
frames i n the movi e.
Animation of the solution to the wave equation
Examples of Ei genvalue Problems
2-27
Examples of Eigenvalue Problems
Thi s secti on descr i bes the sol uti on of some ei genval ue PDE pr obl ems. The
probl ems ar e sol ved usi ng the graphi cal user i nter face and the command-l i ne
functi ons of the PDE Tool box.
Eigenvalues and Eigenfunctions for the L-Shaped
Membrane
The pr obl em of fi ndi ng the ei genval ues and the cor respondi ng ei genfuncti ons
of an L-shaped membr ane i s of i nter est to al l MATLAB users, si nce the pl ot of
the fi r st ei genfuncti on i s the l ogo of The MathWor ks. I n fact, you can compare
the PDE Tool box computed ei genval ues and ei genfuncti ons to the ones
produced by the MATLAB functi on me mbr ane.
The pr obl em i s to compute al l ei genmodes wi th ei genval ues < 100 for the
eigenmode PDE problem
u = u
on the geometry of the L-shaped membr ane. u = 0 on the boundary (Di ri chl et
condi ti on).
Using the Graphical User Interface
Wi th the pde t ool GUI acti ve, check that the curr ent mode i s Generic Scalar.
Then draw the L-shape as a pol ygon wi th cor ners i n (0,0), (-1,0), (-1,-1), (1,-1),
(1,1), and (0,1).
There i s no need to defi ne any boundary condi ti ons for thi s probl em si nce the
defaul t condi ti on u = 0 on the boundar y i s the cor rect one. Therefore, you
can conti nue to the next step: to i ni ti al i ze the mesh. Refi ne the i ni ti al mesh
twi ce. Defi ni ng the ei genval ue PDE pr obl em i s al so easy. Open the PDE
Specification di al og box and sel ect Eigenmodes. The defaul t val ues for the
PDE coeffi ci ents, c = 1, a = 0, d = 1, al l match the probl em descr i pti on, so you
can exi t the PDE Specification di al og box by pr essi ng the OK button.
Open the Solve Parameters di al og box by sel ecti ng Parameters . . . fr om the
Solve menu. The di al og box contai ns an edi t box for enter i ng the ei genval ue
sear ch r ange. The defaul t entry i s [ 0 100] , whi ch i s just what you want.
2 Examples
2-28
Fi nal l y, sol ve the L-shaped membr ane probl em by pressi ng the = button. The
sol uti on di spl ayed i s the fi r st ei genfuncti on. The val ue of the fi rst (smal l est)
ei genval ue i s al so di spl ayed. You fi nd the number of ei genval ues on the
i nfor mati on l i ne at the bottom of the GUI . You can open the Plot Selection
di al og box and choose whi ch ei genfuncti on to pl ot by sel ecti ng fr om a pop-up
menu of the cor respondi ng ei genval ues.
Using Command-Line Functions
The geometry of the L-shaped membrane i s descri bed i n the fi l e l s hape g.m and
the boundar y condi ti ons i n the fi l e l s hape b. m.
Fi r st, i ni ti al i ze the mesh and r efi ne i t twi ce usi ng the command l i ne functi ons
at the MATLAB prompt:
[ p, e, t ] =i ni t me s h( ' l s hapeg' ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e , t ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e , t ) ;
Recal l the general ei genval ue PDE pr obl em descri pti on:
Thi s means that i n thi s case you have c = 1, a = 0, and d = 1. The syntax of
pde ei g, the ei genval ue sol ver i n the PDE Tool box, i s:
[ v, l ] =pdee i g( b, p, e , t , c, a, d, r )
The i nput argument r i s a two-el ement vector i ndi cati ng the i nter val on the
r eal axi s wher e pde e i g sear ches for ei genval ues. Here you are l ooki ng for
ei genval ues < 100, so the i nter val you use i s [ 0 100] .
Now you can cal l pde ei g and see how many ei genval ues you fi nd:
[ v, l ] =pde e i g( ' l s hape b' , p, e, t , 1, 0, 1, [ 0 100] ) ;
Ther e ar e 19 ei genval ues smal l er than 100. Pl ot the fi rst ei genmode and
compare i t to MATLABs me mbr ane functi on:
pde s ur f ( p, t , v( : , 1) )
f i gur e
membr ane( 1, 20, 9, 9)
cu ( ) au + du =
Examples of Ei genvalue Problems
2-29
me mbr ane can produce the fi rst 12 ei genfuncti ons for the L-shaped membrane.
Compare al so the 12th ei genmodes:
f i gur e
pde s ur f ( p, t , v ( : , 12) )
f i gur e
me mbr ane( 12, 20, 9, 9)
Looki ng at the fol l owi ng ei genmodes, you can see how the number of
osci l l ati ons i ncr eases. The ei genfuncti ons are symmetr i c or anti symmetr i c
ar ound the di agonal from (0,0) to (1,-1), whi ch di vi des the L-shaped membrane
i nto two mi r ror i mages. I n a practi cal computati on, you coul d take advantage
of such symmetr i es i n the PDE pr obl em, and sol ve over a regi on hal f the si ze.
The ei genval ues of the ful l L-shaped membr ane are the uni on of those of the
hal f wi th Di ri chl et boundary condi ti on al ong the di agonal (ei genval ues 2, 4, 7,
11, 13, 16, and 17) and those wi th Neumann boundary condi ti on (ei genval ues
1, 3, 5, 6, 10, 12, 14, and 15).
The ei genval ues
8
and
9
make up a doubl e ei genval ue for the PDE at around
49.64. Al so, the ei genval ues
18
and
19
make up another doubl e ei genval ue at
ar ound 99.87. You may have gotten two di fferent but cl ose val ues. The defaul t
tr i angul ati on made by i ni t mes h i s not symmetri c around the di agonal , but a
symmetri c gri d gi ves a matr i x wi th a true doubl e ei genval ue. Each of the
ei genfuncti ons u
8
and u
9
consi sts of three copi es of ei genfuncti ons over the uni t
square, corr espondi ng to i ts doubl e second ei genval ue. You may not have
obtai ned the zer o val ues al ong a di agonal of the squar e any l i ne through the
center of the squar e may have been computed. Thi s shows a general fact about
mul ti pl e ei genval ues for symmetr i c matr i ces; namel y that any vector i n the
i nvari ant subspace i s equal l y val i d as an ei genvector . The two ei genfuncti ons
u
8
and u
9
ar e orthogonal to each other i f the di vi di ng l i nes make ri ght angl es.
Check your sol uti ons for that.
Actual l y, the ei genval ues of the square can be computed exactl y. They are
(m
2
+n
2
)
2
, e.g., the doubl e ei genval ue
18
and
19
i s 10
2
, whi ch i s pr etty cl ose
to 100. I f you compute the FEM approxi mati on wi th onl y one refi nement, you
woul d onl y fi nd 16 ei genval ues, and you obtai n the wr ong sol uti on to the
ori gi nal probl em. You can of cour se check for thi s si tuati on by computi ng the
ei genval ues over a sl i ghtl y l arger range than the or i gi nal pr obl em.
2 Examples
2-30
You get some i nformati on fr om the pr i ntout i n the MATLAB command wi ndow
that i s pri nted dur i ng the computati on. For thi s probl em, the al gori thm
computed a new set of ei genval ue appr oxi mati ons and tested for conver gence
ever y thi r d step. I n the output, you get the step number, the ti me i n seconds
si nce the start of the ei genval ue computati on, and the number of conver ged
ei genval ues wi th ei genval ues both i nsi de and outsi de the i nterval counted.
Here i s what MATLAB wrote:
Bas i s = 10, Ti me = 2. 70, Ne w conv e i g= 0
Bas i s = 13, Ti me = 3. 50, Ne w conv e i g= 0
Bas i s = 16, Ti me = 4. 36, Ne w conv e i g= 0
Bas i s = 19, Ti me = 5. 34, Ne w conv e i g= 1
Bas i s = 22, Ti me = 6. 46, Ne w conv e i g= 2
Bas i s = 25, Ti me = 7. 61, Ne w conv e i g= 3
Bas i s = 28, Ti me = 8. 86, Ne w conv e i g= 3
Bas i s = 31, Ti me = 10. 23, Ne w conv e i g= 5
Bas i s = 34, Ti me = 11. 69, Ne w conv e i g= 5
Bas i s = 37, Ti me = 13. 28, Ne w conv e i g= 7
Bas i s = 40, Ti me = 14. 97, Ne w conv e i g= 8
Bas i s = 43, Ti me = 16. 77, Ne w conv e i g= 9
Bas i s = 46, Ti me = 18. 70, Ne w conv e i g= 11
Bas i s = 49, Ti me = 20. 73, Ne w conv e i g= 11
Bas i s = 52, Ti me = 22. 90, Ne w conv e i g= 13
Bas i s = 55, Ti me = 25. 13, Ne w conv e i g= 14
Bas i s = 58, Ti me = 27. 58, Ne w conv e i g= 14
Bas i s = 61, Ti me = 30. 13, Ne w conv e i g= 15
Bas i s = 64, Ti me = 32. 83, Ne w conv e i g= 16
Bas i s = 67, Ti me = 35. 64, Ne w conv e i g= 18
Bas i s = 70, Ti me = 38. 62, Ne w conv e i g= 22
End of s we ep: Bas i s = 70, Ti me = 38. 62, Ne w conv e i g= 22
Bas i s = 32, Ti me = 43. 29, Ne w conv e i g= 0
Bas i s = 35, Ti me = 44. 70, Ne w conv e i g= 0
Bas i s = 38, Ti me = 46. 22, Ne w conv e i g= 0
Bas i s = 41, Ti me = 47. 81, Ne w conv e i g= 0
Bas i s = 44, Ti me = 49. 52, Ne w conv e i g= 0
Bas i s = 47, Ti me = 51. 35, Ne w conv e i g= 0
Bas i s = 50, Ti me = 53. 27, Ne w conv e i g= 0
Bas i s = 53, Ti me = 55. 30, Ne w conv e i g= 0
End of s we ep: Bas i s = 53, Ti me = 55. 30, Ne w conv e i g= 0
Examples of Ei genvalue Problems
2-31
You can see that two Arnol di r uns were made. I n the fi rst, 22 ei genval ues
converged after a basi s of si ze 70 was computed; i n the second, wher e the
vectors wer e or thogonal i zed agai nst al l the 22 conver ged vectors, the smal l est
ei genval ue stabi l i zed at a val ue outsi de of the i nter val [0, 100], so the al gori thm
si gnal ed convergence. Of the 22 converged ei genval ues, 19 wer e i nsi de the
sear ch i nterval .
L-Shaped Membrane with Rounded Corner
An extensi on of thi s probl em i s to compute the ei genval ues for an L-shaped
membrane wher e the i nner cor ner at the knee i s rounded. The r oundness i s
cr eated by addi ng a ci r cl e so that the ci rcl es ar c i s a par t of the L-shaped
membranes boundary. By varyi ng the ci rcl es radi us, the degr ee of roundness
can be contr ol l ed. The M-fi l e l s hapec i s an extensi on of an or di nary model fi l e
cr eated usi ng pdet ool . I t contai ns the l i nes
pde pol y ( [ 1, 1, 1, 0, 0, 1] , . . .
[ 1, 1, 1, 1, 0, 0] , ' P1' ) ;
pde ci r c ( a, a, a, ' C1' ) ;
pde r e ct ( [ a 0 a 0] , ' SQ1' ) ;
The extra ci rcl e and r ectangl e that are added usi ng pde ci r c and pde r ec t to
cr eate the r ounded corner ar e affected by the added i nput argument a thr ough
a coupl e of extra l i nes of MATLAB code. Thi s i s possi bl e si nce the PDE Tool box
i s a part of the open MATLAB envi ronment.
Wi th l s hapec you can create L-shaped rounded geometr i es wi th di fferent
degrees of roundness. I f you use l s hape c wi thout an i nput argument, a defaul t
radi us of 0.5 i s used. Other wi se, use l s hape c( a) , where a i s the radi us of the
ci r cl e.
Exper i menti ng usi ng di ffer ent val ues for the radi us a, shows you that the
ei genval ues and the fr equenci es of the cor respondi ng ei genmodes decr ease as
the radi us i ncreases, and the shape of the L-shaped membr ane becomes mor e
rounded. I n the fi gure bel ow, the fi r st ei genmode of an L-shaped membrane
wi th a r ounded cor ner i s pl otted.
2 Examples
2-32
Eigenvalues and Eigenmodes of a Square
Lets study the ei genval ues and ei genmodes of a squar e wi th an i nter esti ng set
of boundary condi ti ons. The squar e has corners i n (-1,-1), (-1,1), (1,1), and (1,-1).
The boundary condi ti ons ar e as fol l ows:
On the l eft boundary, the Di r i chl et condi ti on u = 0
On the upper and l ower boundary, the Neumann condi ti on
On the r i ght boundar y, the general i zed Neumann condi ti on
The ei genval ue PDE probl em i s
u = u.
We are i nter ested i n the ei genval ues smal l er than 10 and the cor respondi ng
ei genmodes, so the search range i s [ I nf 10] . The si gn i n the general i zed
Neumann condi ti on i s such that ther e ar e negati ve ei genval ues.
The first eigenmode for an L-shaped membrane with a rounded corner
u
n
------ 0 =
u
n
------
3
4
---u 0 =
Examples of Ei genvalue Problems
2-33
Using the Graphical User Interface
Usi ng the pdet ool GUI i n the Generic Scalar mode, draw the squar e usi ng
the Rectangle/square opti on from the Draw menu or the button wi th the
rectangl e i con. Then defi ne the boundary condi ti ons by pressi ng the button
and then doubl e-cl i ck on the boundari es to defi ne the boundary condi ti ons. On
the ri ght-hand si de boundar y, you have the general i zed Neumann condi ti ons,
and you enter them as constants: g = 0 and q = 3/4.
I ni ti al i ze the mesh and refi ne i t once by pr essi ng the and refine buttons
or by sel ecti ng the cor respondi ng opti ons fr om the Mesh menu.
Al so, defi ne the ei genval ue PDE pr obl em by openi ng the PDE Specification
di al og box and sel ecti ng the Eigenmodes opti on. The general ei genval ue PDE
i s descr i bed by
so for thi s probl em you use the defaul t val ues c = 1, a = 0, and d = 1. Al so, i n
the Solve Parameters di al og box, enter the ei genval ue range as the MATLAB
vector [ I nf 10] .
Fi nal l y, pr ess the = button to compute the sol uti on. By defaul t, the fi r st
ei genfuncti on i s pl otted. You can pl ot the other ei genfuncti ons by sel ecti ng the
cor respondi ng ei genval ue from a pop-up menu i n the Plot Selection di al og
box. The pop-up menu contai ns al l the ei genval ues found i n the speci fi ed range.
You can al so export the ei genfuncti ons and ei genval ues to the MATLAB mai n
wor kspace by usi ng the Export Solution . . . opti on from the Solve menu.
Using Command-Line Functions
The geometry descr i pti on fi l e and boundary condi ti on fi l e for thi s pr obl em are
cal l ed s quar eg. m and s quar eb2. m, r especti vel y. Use the fol l owi ng sequence of
commands to fi nd the ei genval ues i n the speci fi ed range and the corr espondi ng
ei genfuncti ons:
[ p, e, t ] =i ni t mes h( ' s quar e g' ) ;
[ p, e, t ] =r ef i neme s h( ' s quar e g' , p, e, t ) ;
The ei genval ue PDE coeffi ci ents c, a, and d for thi s pr obl em are c = 1, a = 0, and
d = 1. You can enter the ei genval ue r ange r as the MATLAB vector [ I nf 10] .
pde ei g returns two output ar guments, the ei genval ues as an ar ray l and a
matr i x v of correspondi ng ei genfuncti ons:
[ v , l ] =pde ei g( ' s quar e b2' , p, e , t , 1, 0, 1, [ I nf 10] ) ;

cu ( ) au + du, =
2 Examples
2-34
To pl ot the four th ei genfuncti on as a sur face pl ot, type:
pde s ur f ( p, t , v( : , 4) )
Thi s pr obl em i s separable, i .e.,
The functi ons f and g are ei genfuncti ons i n the x and y di recti ons, respecti vel y.
I n the x di recti on, the fi r st ei genmode i s a sl owl y i ncreasi ng exponenti al
functi on. The hi gher modes i ncl ude si nusoi ds. I n the y di recti on, the fi r st
ei genmode i s a str ai ght l i ne (constant), the second i s hal f a cosi ne, the thi r d i s
a ful l cosi ne, the four th i s one and a hal f ful l cosi nes, etc. These ei genmodes i n
the y di recti on are associ ated wi th the ei genval ues:
Ther e ar e fi ve ei genval ues smal l er than 10 for thi s probl em, and the fi r st one
i s even negati ve (-0.4145). I t i s possi bl e to trace the ei genval ues above i n the
ei genval ues of the sol uti on. Looki ng at a pl ot of the fi r st ei genmode, you can see
that i t i s made up of the fi rst ei genmodes i n the x and y di r ecti ons. The second
ei genmode i s made up of the fi rst ei genmode i n the x di recti on and the second
ei genmode i n the y di r ecti on.
Look at the di ffer ence between the fi r st and the second ei genval ue:
l ( 2) l ( 1)
ans =
2. 4740
pi *pi /4
ans =
2. 4674
Li kewi se, the fi fth ei genmode i s made up of the fi rst ei genmode i n the x
di r ecti on and the thi r d ei genmode i n the y di recti on. As expected, l ( 5) l ( 1) i s
appr oxi matel y equal to
2
. You can expl ore hi gher modes by i ncr easi ng the
sear ch r ange to i ncl ude ei genval ues gr eater than 10.
u x y , ( ) f x ( )g y ( ) =
0

2
4
-----
4
2
4
---------
9
2
4
--------- , , , ,
Appli cati on M odes
2-35
Application Modes
I n thi s secti on we descri be the appl i cati on modes of the pdet ool GUI .
Exampl es ar e gi ven for a vari ety of appl i cati ons to di ffer ent engi neeri ng
probl ems.
The Application Modes and the GUI
The PDE Tool box can be appl i ed to a great number of probl ems i n engi neer i ng
and sci ence. To hel p you i n usi ng the pde t ool GUI for some i mportant and
common appl i cati ons, ei ght di ffer ent appl i cati on modes ar e avai l abl e i n
addi ti on to the gener i c scal ar and system modes.
The avai l abl e appl i cati on modes are
Generi c scal ar (the defaul t mode)
Generi c system
Structural Mechani cs - Pl ane Str ess
Structural Mechani cs - Pl ane Str ai n
El ectr ostati cs
Magnetostati cs
AC Power El ectromagneti cs
Conducti ve Medi a DC
Heat Transfer
Di ffusi on
NOTE: Fr om the GUI , the system PDEs are r estr i cted to pr obl ems wi th vector
val ued u of di mensi on two. Usi ng command-l i ne functi ons, ther e i s no formal
restri cti on on the di mensi on of u.
The appl i cati on mode can be sel ected di rectl y from the pop-up menu i n the
upper r i ght par t of the GUI or by sel ecti ng an appl i cati on fr om the
Application submenu i n the Options menu. Note that changi ng the
appl i cati on resets al l PDE coeffi ci ents and boundar y condi ti ons to the defaul t
val ues for that speci fi c appl i cati on mode.
2 Examples
2-36
When usi ng an appl i cati on mode, the gener i c PDE coeffi ci ents are repl aced by
appl i cati on-speci fi c par ameters such as Youngs modul us for pr obl ems i n
structural mechani cs. The appl i cati on-speci fi c par ameters ar e enter ed by
sel ecti ng Parameters . . . fr om the PDE menu or by pressi ng the PDE button.
You can al so access the PDE parameter s by doubl e-cl i cki ng on a subdomai n, i f
you are i n the PDE mode. That way i t i s possi bl e to defi ne PDE parameter s for
pr obl ems wi th r egi ons of di fferent materi al properti es. The Boundary
condition di al og box i s al so al tered so that the Descri pti on col umn refl ects the
physi cal meani ng of the di fferent boundary condi ti on coeffi ci ents. Fi nal l y, the
Pl ot Sel ecti on di al og box al l ows you to vi sual i ze the r el evant physi cal var i abl es
for the sel ected appl i cati on.
NOTE: I n the User entry opti ons i n the Plot Selection di al og box, the
sol uti on and i ts deri vati ves ar e al ways r efer red to as u, ux , and uy (v , vx , and
v y for the system cases) even i f the appl i cati on mode i s nongeneri c and the
sol uti on of the appl i cati on-speci fi c PDE nor mal l y i s named, e.g., V or T.
I n the r emai ni ng part of thi s secti on, we expl ai n each of the appl i cati on modes
i n more detai l and gi ve exampl es of how to sol ve appl i cati on speci fi c pr obl ems
usi ng the PDE Tool box.
Structural Mechanics - Plane Stress
I n str uctur al mechani cs, the equati ons rel ati ng str ess and strai n ar i se from the
bal ance of forces i n the mater i al medi um. Plane stress i s a condi ti on that
pr evai l s i n a fl at pl ate i n the xy pl ane, l oaded onl y i n i ts own pl ane and wi thout
z-di r ecti on r estr ai nt.
The str ess-str ai n r el ati on can then be wr i tten, assumi ng i sotropi c and
i sothermal condi ti ons:
where
x
and
y
ar e the stresses i n the x and y di recti ons, and
xy
i s the shear
stress. The mater i al pr oper ti es ar e expressed as a combi nati on of E, the elastic
modulus or Youngs modulus, and, Poi ssons r ati o.

xy






E
1
2

--------------
1 0
1 0
0 0 1 ( ) 2





x

xy






=
Appli cati on M odes
2-37
The defor mati on of the materi al i s descr i bed by the di spl acements i n the x and
y di r ecti ons, u and v, from whi ch the strai ns ar e defi ned as
The bal ance of for ce equati ons are
where K
x
and K
y
are vol ume forces (body forces).
Combi ni ng the rel ati ons above, we ar ri ve at the di spl acement equati ons, whi ch
can be wri tten:
(c u) = k
where c i s a rank four tensor , whi ch can be wri tten as four 2-by-2 matr i ces
c
11
, c
12
, c
21
, and c
22
:
where G, the shear modulus, i s defi ned by

x
u
x
------
y
,
v
y
-----
xy
,
u
y
------ = = =
v
x
----- +

x
x
---------

xy
y
---------- K
x
=

xy
x
----------

y
y
--------- K
y
=
c
11
2G + 0
0 G


=
c
12
0
G 0


=
c
21
0 G
0


=
c
22
G 0
0 2G +


=
G
E
2 1 + ( )
-------------------- =
2 Examples
2-38
and i n turn i s defi ned by
ar e volume forces.
Thi s i s an el l i pti c PDE of system type (u i s two-di mensi onal ), but you need onl y
to sel ect the appl i cati on mode Structural Mechanics, Plane Stress and then
enter the mater i al -dependent par ameters E and and the vol ume forces k i nto
the PDE Specification di al og box.
I n thi s mode, you can al so sol ve the ei genval ue pr obl em, whi ch i s descri bed by
(c u) = du
d =
, the densi ty, can al so be entered usi ng the PDE Specification di al og box.
I n the Plot Selection di al og box, the x- and y-di spl acements, u and v, and the
absol ute val ue of the di spl acement vector (u,v) can be vi sual i zed usi ng col or,
contour l i nes, or z-hei ght, and the di spl acement vector fi el d (u,v) can be pl otted
usi ng arrows or a deformed mesh. I n addi ti on, for vi sual i zati on usi ng col or ,
contour l i nes, or hei ght, you can choose from 15 scal ar tensor expressi ons:
ux =
uy =
vx =
vy =
ex x, the x-di r ecti on strai n (
x
)
ey y, the y-di r ecti on strai n (
y
)
2G
v
1
------------ =
k
K
x
K
y



=
0
0


u
x
------
u
y
------
v
x
-----
v
y
-----
Appli cati on M odes
2-39
e x y, the shear strai n (
xy
)
s x x, the x-di r ecti on str ess (
x
)
s y y, the y-di r ecti on str ess (
y
)
s x y, the shear stress (
xy
)
e 1, the fi rst pr i nci pal str ai n (
1
)
e 2, the second pr i nci pal strai n (
2
)
s 1, the fi rst pr i nci pal str ess (
1
)
s 2, the second pr i nci pal stress (
2
)
v on Mi s e s , the von Mi ses effecti ve stress
For a mor e detai l ed di scussi on on the theory of stress-strai n rel ati ons and
appl i cati ons of FEM to probl ems i n structural mechani cs, see [1].
Example
Consi der a steel pl ate that i s cl amped al ong a r i ght-angl e i nset at the l ower l eft
cor ner, and pul l ed al ong a r ounded cut at the upper r i ght corner . Al l other si des
ar e free.
The steel pl ate has the fol l owi ng pr oper ti es: Di mensi on: 1-by-1 meters;
thi ckness 1mm; i nset i s 1/3-by-1/3 meter s. The r ounded cut r uns fr om (2/3, 1)
to (1, 2/3). Youngs modul us: 196 10
3
(MN/m
2
), Poi ssons r ati o: 0.31.
The cur ved boundary i s subjected to an outward normal l oad of 500 N/m. We
need to speci fy a surface tracti on; we therefore di vi de by the thi ckness 1 mm,
thus the sur face tr acti ons shoul d be set to 0.5 MN/m
2
. We wi l l use the for ce uni t
MN i n thi s exampl e.
We want to compute a number of i nter esti ng quanti ti es, such as the x- and
y-di recti on str ai ns and stresses, the shear str ess, and the von Mi ses effecti ve
str ess.
Using the Graphical User Interface
Usi ng the pdet ool GUI , the fi rst thi ng to do i s to sel ect the appl i cati on mode.
For thi s pr obl em, use Structural Mechanics, Plane Stress.
The CSG model can be made ver y qui ckl y by drawi ng a pol ygon wi th corner s i n
x=[ 0 2/3 1 1 1/3 1/3 0] and y =[ 1 1 2/3 0 0 1/3 1/3] and a ci rcl e wi th
center i n x=2/3, y=2/3 and r adi us 1/3.

1
2

2
2

2
+ ( )
2 Examples
2-40
The pol ygon i s normal l y l abel ed P1 and the ci r cl e C1, and the CSG model of the
steel pl ate i s si mpl y P1+C1.
Next, sel ect Boundary Mode to speci fy the boundary condi ti ons. Fi rst,
r emove al l subdomai n borders by sel ecti ng Remove All Subdomain Borders
. . . fr om the Boundary menu. The two boundari es at the i nset i n the l ower l eft
ar e cl amped, i .e., Di ri chl et condi ti ons wi th zero di spl acements. The rounded
cut i s subject to a Neumann condi ti on wi th q=0 and g1=0. 5*nx, g2=0. 5*ny.
The remai ni ng boundar i es are fr ee (no nor mal stress), that i s, a Neumann
condi ti on wi th q=0 and g=0.
The next step i s to open the PDE Specification di al og box and enter the PDE
par ameters.
The E and (nu) parameter s are Youngs modul us and Poi ssons r ati o,
r especti vel y. There are no vol ume forces, so Kx and Ky are zer o. (r ho) i s not
used i n thi s mode. The mater i al i s homogeneous, so the same E and appl y to
the whol e 2-D domai n.
I ni ti al i ze the mesh by pr essi ng the button. I f you want, you can r efi ne the
mesh by pr essi ng the Refine button.
The probl em can now be sol ved by pr essi ng the = button.
A number of di fferent strai n and stress pr oper ti es can be vi sual i zed, such as
the di spl acements u and v, the x- and y-di r ecti on str ai ns and str esses, the shear
stress, the von Mi ses effecti ve str ess, and the pr i nci pal stresses and strai ns. Al l
these pr oper ti es can be sel ected from pop-up menus i n the Plot Selection
di al og box. A combi nati on of scal ar and vector proper ti es can be pl otted
si mul taneousl y by sel ecti ng di ffer ent properti es to be r epresented by col or ,
hei ght, vector fi el d ar rows, and di spl acements i n a 3-D pl ot.
Appli cati on M odes
2-41
Sel ect to pl ot the von Mi ses effecti ve str ess usi ng col or and the di spl acement
vector fi el d (u,v) usi ng a defor med mesh. Check the Color and Deformed
mesh pl ot types. To pl ot the von Mi ses effecti ve str ess, sel ect von Mises fr om
the pop-up menu i n the Color row.
I n areas where the gr adi ent of the sol uti on (the stress) i s l ar ge, you need to
refi ne the mesh i n or der to i ncr ease the accuracy of the sol uti on. Sel ect
Parameters . . . from the Solve menu and check the Adaptive mode opti on.
You can use the defaul t opti ons for adapti on, whi ch ar e the Worst triangles
tr i angl e sel ecti on method wi th the Worst triangle fraction set to 0.5. Now
sol ve the pl ane str ess pr obl em agai n. Check the Show Mesh opti on i n the Plot
Selection di al og box to see how the mesh i s refi ned i n ar eas wher e the stress
i s l ar ge.
Structural Mechanics - Plane Strain
A deformati on state where ther e ar e no di spl acements i n the z-di r ecti on, and
the di spl acements i n the x- and y-di r ecti ons are functi ons of x and y but not z
i s cal l ed plane strain. You can sol ve pl ane strai n pr obl ems wi th the PDE
Tool box by sel ecti ng the appl i cati on mode Structural Mechanics, Plane
Visualization of the von Mises effective stress
using deformed mesh
and the displacements
2 Examples
2-42
Strain. The stress-str ai n rel ati on i s onl y sl i ghtl y di ffer ent from the pl ane
stress case, and the same set of mater i al parameter s i s used. The appl i cati on
i nterfaces are i denti cal for the two structural mechani cs modes.
The pl aces where the pl ane str ai n equati ons di ffer from the pl ane stress
equati ons ar e:
The parameter i n the c tensor i s defi ned as
The von Mi ses effecti ve str ess i s computed as
Pl ane strai n pr obl ems are l ess common than pl ane str ess probl ems. An
exampl e i s a sl i ce of an under ground tunnel that l i es al ong the z-axi s. I t
deforms i n essenti al l y pl ane strai n condi ti ons.
2G

1 2
--------------- =

1
2

2
2
+ ( )
2
1 + ( )
1

2
2
2
2 1 ( )
Appli cati on M odes
2-43
Electrostatics
Appl i cati ons i nvol vi ng el ectrostati cs i ncl ude hi gh vol tage appar atus, el ectr oni c
devi ces, and capaci tor s. The stati cs i mpl i es that the ti me rate of change i s
sl ow, and that wavel engths ar e very l ar ge compared to the si ze of the domai n
of i nterest. I n el ectrostati cs, the el ectrostati c scal ar potenti al V i s r el ated to the
el ectr i c fi el d E by E = V and, usi ng one of Maxwells equations, D = and
the rel ati onshi p D = E, we arri ve at the Poi sson equati on
where i s the coefficient of dielectricity and i s the space charge density.
NOTE: shoul d real l y be wr i tten as
0
, wher e
0
i s the coeffi ci ent of
di el ectr i ci ty or per mi tti vi ty of vacuum (8.854 10
-12
farad/meter) and i s the
rel ati ve coeffi ci ent of di el ectri ci ty that var i es among di fferent di el ectri cs
(1.00059 i n ai r, 2.24 i n transformer oi l , etc.).
Usi ng the PDE Tool box appl i cati on mode Electrostatics, you can sol ve
el ectr ostati c probl ems model ed by the equati on above.
The PDE Specification di al og box contai ns entr i es for and .
The boundar y condi ti ons for el ectr ostati c probl ems can be of Di ri chl et or
Neumann type. For Di r i chl et condi ti ons, the el ectrostati c potenti al V i s
speci fi ed on the boundary. For Neumann condi ti ons, the surface charge
n (V) i s speci fi ed on the boundar y.
For vi sual i zati on of the sol uti on to an el ectrostati c pr obl em, the pl ot sel ecti ons
i ncl ude the el ectr ostati c potenti al V, the el ectri c fi el d E, and the el ectr i c
di spl acement fi el d D.
For a mor e i n-depth di scussi on of pr obl ems i n el ectr ostati cs, see [2].
V ( ) =
2 Examples
2-44
Example
Lets consi der the pr obl em of deter mi ni ng the el ectr ostati c potenti al i n an
ai r -fi l l ed quadrati c frame, bounded by a squar e wi th si de l ength of 0.2 i n the
center and by outer l i mi ts wi th si de l ength of 0.5. At the i nner boundar y, the
el ectrostati c potenti al i s 1000V. At the outer boundar y, the el ectrostati c
potenti al i s 0V. Ther e i s no char ge i n the domai n. Thi s l eads to the pr obl em of
sol vi ng the Lapl ace equati on
V = 0
wi th the Di r i chl et boundary condi ti ons V = 1000 at the i nner boundary,
and V = 0 at the outer boundary.
Using the Graphical User Interface
After sel ecti ng the appl i cati on mode Electrostatics, the 2-D ar ea i s most
easi l y dr awn by fi rst dr awi ng a squar e wi th si des of l ength 0.2 (use the Snap
opti on and adjust the gr i d spaci ng i f necessary). Then draw another squar e
wi th si des of l ength 0.5 usi ng the same center posi ti on. The 2-D domai n i s then
si mpl y SQ2-SQ1, i f the fi rst squar e i s named SQ1 and the second square i s
named SQ2. Enter the expressi on i nto the Set formula edi t box, and proceed
to defi ne the boundar y condi ti ons. Use Shift-cl i ck to sel ect al l the i nner
boundar i es. Then doubl e-cl i ck on an i nner boundar y and enter 1000 as the
Di ri chl et boundary condi ti on for the i nner boundari es.
Next, open the PDE Specification di al og box, and enter 0 i nto the space
char ge densi ty (r ho) edi t fi el d. The coeffi ci ent of di el ectri ci ty can be l eft at 1,
si nce i t does not affect the r esul t as l ong as i t i s constant.
I ni ti al i ze the mesh, and press the = button to sol ve the equati on. Usi ng the
adapti ve mode, you can i mprove the accuracy of the sol uti on by refi ni ng the
mesh cl ose to the r e-entrant corners where the gradi ents ar e steep. For
exampl e, use the tri angl e sel ecti on method pi cki ng the worst tri angl es and set
the maxi mum number of tr i angl es to 500. Add one uni form mesh refi nement
by pressi ng the Refine button once. Fi nal l y turn adapti ve mode off, and press
the = button once more.
Appli cati on M odes
2-45
To l ook at the equi potenti al l i nes, sel ect a contour pl ot fr om the Plot Selection
di al og box. To di spl ay equi potenti al l i nes at ever y 100th vol t, enter 0: 100: 1000
i nto the Contour plot levels edi t box.
Equipotential lines in air-filled frame
2 Examples
2-46
Magnetostatics
Magnets, el ectr i c motors, and tr ansfor mer s are ar eas wher e probl ems
i nvol vi ng magnetostati cs can be found. The stati cs i mpl i es that the ti me rate
of change i s sl ow, so we start wi th Maxwel l s equati ons for steady cases,
H = J
B = 0
and the r el ati onshi p
B = H,
where B i s the magnetic flux density, H i s the magnetic field intensity, J i s the
current density, and i s the mater i al s magnetic permeability.
Si nce B = 0, ther e exi sts a magnetic vector potential A such that
B = A
and
( A) = J ,
The pl ane case assumes that the curr ent fl ows ar e paral l el to the z-axi s, so onl y
the z component of A i s present,
A = (0,0,A),J = (0,0,J ),
and the equati on above can be si mpl i fi ed to the scal ar el l i pti c PDE
where J =J (x,y).
For the 2-D case, we can compute the magneti c fl ux densi ty B as
and the magneti c fi el d H, i n tur n, i s gi ven by
H = B
1

---

1

---A


J, =
B
A
y
------
A
x
------ 0 , ,


=
1

---
Appli cati on M odes
2-47
The i nterface condi ti on across subdomai n bor der s between r egi ons of di fferent
mater i al properti es i s that H n be conti nuous. Thi s i mpl i es the conti nui ty of
and does not requi re speci al treatment si nce we ar e usi ng the vari ati onal
formul ati on of the PDE probl em.
I n ferr omagneti c materi al s, i s usual l y dependent on the fi el d strength
| B| = | A|, so the nonl i near sol ver i s needed.
The Di r i chl et boundar y condi ti on speci fi es the val ue of the magnetostati c
potenti al A on the boundar y. The Neumann condi ti on speci fi es the val ue of the
nor mal component of n ( ) on the boundary. Thi s i s equi val ent to
speci fyi ng the tangenti al val ue of the magneti c fi el d H on the boundar y.
Vi sual i zati on of the magnetostati c potenti al A, the magneti c fi el d H, and the
magneti c fl ux densi ty B i s avai l abl e. B and H can be pl otted as vector fi el ds.
See [2] for a mor e detai l ed di scussi on on Maxwel l s equati ons and
magnetostati cs.
Example
As an exampl e of a probl em i n magnetostati cs, consi der determi ni ng the stati c
magneti c fi el d due to the stator wi ndi ngs i n a two-pol e el ectr i c motor. The
motor i s consi dered to be l ong, and when end effects ar e negl ected, a 2-D
computati onal model suffi ces.
The domai n consi sts of four regi ons:
Two ferr omagneti c pi eces, the stator and the r otor
The ai r gap between the stator and the rotor
The ar mature coi l car ryi ng the DC cur rent
The magneti c permeabi l i ty i s 1 i n the ai r and i n the coi l . I n the stator and the
rotor , i s defi ned by

max
= 5000,
min
= 200, and c = 0.05 are val ues that coul d r epr esent
tr ansfor mer steel .
The cur rent densi ty J i s 0 everywher e except i n the coi l , wher e i t i s 1.
1

---
A
n
------
1

---A


max
1 c A ( )
2
+
--------------------------------
mi n,
+ =
2 Examples
2-48
The geometr y of the probl em makes the magneti c vector potenti al A symmetr i c
wi th respect to y and anti -symmetr i c wi th r espect to x, so you can l i mi t the
domai n to x 0,y0 wi th the Neumann boundary condi ti on n ( ) on the
x-axi s and the Di ri chl et boundar y condi ti on A = 0 on the y-axi s. The fi el d
outsi de the motor i s negl ected l eadi ng to the Di r i chl et boundary condi ti on
A = 0 on the exteri or boundar y.
Using the Graphical User Interface
The geometry i s compl ex, i nvol vi ng fi ve ci rcul ar arcs and two rectangl es. Usi ng
the pde t ool GUI , set the x-axi s l i mi ts to [-1.5 1.5] and the y-axi s l i mi ts to
[ 1 1] . Set the appl i cati on mode to Magnetostatics, and use a gr i d spaci ng
of 0.1. The model i s a uni on of ci r cl es and rectangl es; the r educti on to the fi r st
quadrant i s achi eved by i nter secti on wi th a square. Usi ng the snap-to-gr i d
feature, you can draw the geometry usi ng the mouse, or you can draw i t by
enter i ng the fol l owi ng commands:
pde ci r c ( 0, 0, 1, ' C1' )
pde ci r c ( 0, 0, 0. 8, ' C2' )
pde ci r c ( 0, 0, 0. 6, ' C3' )
pde ci r c ( 0, 0, 0. 5, ' C4' )
pde ci r c ( 0, 0, 0. 4, ' C5' )
pde r e ct ( [ 0. 2 0. 2 0. 2 0. 9] , ' R1' )
pde r e ct ( [ 0. 1 0. 1 0. 2 0. 9] , ' R2' )
pde r e ct ( [ 0 1 0 1] , ' SQ1' )
You shoul d get a CSG model si mi l ar to the one i n the pl ot bel ow:
1

---A 0 =
Appli cati on M odes
2-49
Enter the fol l owi ng set formul a to r educe the model to the fi rst quadrant:
( C1+C2+C3+C4+C5+R1+R2) *SQ1
I n boundar y mode you need to r emove a number of subdomai n border s. Usi ng
Shift-cl i ck, sel ect borders and r emove them usi ng the Remove Subdomain
Border opti on from the Boundary menu unti l the geometry consi sts of four
subdomai ns: the stator , the coi l , the ai r gap, and the rotor . I n the pl ot bel ow,
the stator i s subdomai n 1, the rotor i s subdomai n 2, the coi l i s subdomai n 3,
and the ai r gap i s subdomai n 4. Note that the number i ng of your subdomai ns
may be di ffer ent.
Befor e movi ng to the PDE mode, sel ect the boundar i es al ong the x-axi s and set
the boundary condi ti on to a Neumann condi ti on wi th g = 0 and q = 0. I n the
PDE mode, turn on the l abel s by sel ecti ng the Show Subdomain Labels
opti on fr om the PDE menu. Doubl e-cl i ck on each subdomai n to defi ne the PDE
parameter s.
I n the coi l both and J ar e 1, so the defaul t val ues do not need to be changed.
I n the stator and the rotor i s nonl i near and defi ned by the equati on above.
Enter as
5000. /( 1+0. 05*( ux . ^2+uy . ^2) ) +200.
ux . ^2+uy . ^2 i s equal to | A |
2
. J i s 0 (no cur rent).
I n the ai r gap i s 1, and J i s 0.
2 Examples
2-50
I ni ti al i ze the mesh, and conti nue by openi ng the Solve Parameters di al og box
by sel ecti ng Parameters fr om the Solve menu. Si nce thi s i s a nonl i near
pr obl em, the nonl i near sol ver must be i nvoked by checki ng the Use nonlinear
solver. I f you want, you can adjust the tol erance parameter . The adapti ve
sol ver can be used together wi th the nonl i near sol ver . Sol ve the PDE and pl ot
the magneti c fl ux densi ty B usi ng arr ows and the equi potenti al l i nes of the
magnetostati c potenti al A usi ng a contour pl ot. The pl ot cl earl y shows, as
expected, that the magneti c fl ux i s paral l el to the equi potenti al l i nes of the
magnetostati c potenti al .
Equipotential lines and magnetic flux in two-pole motor
Appli cati on M odes
2-51
AC Power Electromagnetics
AC power el ectr omagneti cs probl ems ar e found when studyi ng motor s,
tr ansfor mer s and conductors carr yi ng al ternati ng cur rents.
Lets start by consi deri ng a homogeneous di el ectri c, wi th coeffi ci ent of
di el ectr i ci ty and magneti c per meabi l i ty , wi th no char ges at any poi nt. The
fi el ds must sati sfy a speci al set of the general Maxwel l s equati ons, see [2]:
I n the absence of cur rent, we can el i mi nate H from the fi r st set and E fr om the
second set and see that both fi el ds sati sfy wave equati ons wi th wave speed
,
We move on to studyi ng a charge-fr ee homogeneous di el ectr i c, wi th coeffi ci ent
of di el ectri cs , magneti c permeabi l i ty , and conducti vi ty . The curr ent
densi ty then i s
J = E
and the waves are damped by the Ohmi c r esi stance,
and si mi l arl y for H.
The case of ti me harmoni c fi el ds i s treated by usi ng the compl ex form, repl aci ng
E by E
c
e
jt
. The pl ane case of thi s PDE Tool box mode has E
c
= (0,0,E
c
) and
J = (0,0,J e
jt
), and the magneti c fi el d
H = (H
x
,H
y
,0) = E
c
,
The scal ar equati on for E
c
becomes
E
H
t
--------, =
H
E
t
------- J + =

2
E
t
2
---------- 0 H ,

2
H
t
2
----------- 0 = =
E
E
t
-------

2
E
t
2
---------- 0 =
1
j
---------

1

---E
c


j
2
( )E
c
+ 0 =
2 Examples
2-52
Thi s i s the equati on used by the PDE Tool box i n the AC Power
Electromagnetics mode. I t i s a compl ex Hel mhol tzs equati on, descri bi ng the
pr opagati on of pl ane el ectromagneti c waves i n i mperfect di el ectri cs and good
conductors ( ). A complex permittivity
c
can be defi ned as
c
= j/. The
condi ti ons at mater i al i nterfaces wi th abr upt changes of and ar e the natur al
ones for the var i ati onal for mul ati on and need no speci al attenti on.
The PDE parameter s that have to be entered i nto the PDE Specification
di al og box ar e the angular frequency , the magneti c per meabi l i ty , the
conducti vi ty , and the coeffi ci ent of di el ectr i ci ty .
The boundary condi ti ons associ ated wi th thi s mode are a Di ri chl et boundar y
condi ti on, speci fyi ng the val ue of the el ectr i c fi el d E
c
on the boundary, and a
Neumann condi ti on, speci fyi ng the nor mal deri vati ve of E
c
. Thi s i s equi val ent
to speci fyi ng the tangenti al component of the magneti c fi el d H:
n ( )
I nteresti ng properti es that can be computed fr om the sol uti on the el ectri c
fi el d E are the cur rent densi ty J =E and the magneti c fl ux densi ty
The el ectr i c fi el d E, the cur rent densi ty J , the magneti c fi el d H and the
magneti c fl ux densi ty B are avai l abl e for pl ots. Addi ti onal l y, the resi sti ve
heati ng r ate i s al so avai l abl e. The magneti c fi el d and the magneti c
fl ux densi ty can be pl otted as vector fi el ds usi ng arr ows.
Example
The exampl e demonstrates the skin effect when AC curr ent i s car ri ed by a wi r e
wi th ci r cul ar cross secti on. The conducti vi ty of copper i s 57 10
6
, and the
permeabi l i ty i s 1, i .e., = 410
-7
. At the l i ne fr equency (50 Hz) the
2
-ter m i s
negl i gi bl e.
Due to the i nducti on, the cur rent densi ty i n the i nteri or of the conductor i s
smal l er than at the outer sur face where i t i s set to J
S
= 1, a Di ri chl et condi ti on
for the el ectri c fi el d, E
c
= 1/. For thi s case an anal yti cal sol uti on i s avai l abl e,
H
t
j

--- - =
1

---E
c
B
j

---- E =
Q E
c
2
=
Appli cati on M odes
2-53
, where , R i s the r adi us of the wi r e, r i s the di stance
from the center l i ne, and J
0
(x) i s the fi rst Bessel functi on of zer oth or der.
Using the Graphical User Interface
Star t the pdet ool GUI and sel ect the appl i cati on mode AC Power
Electromagnetics. Draw a ci rcl e wi th r adi us 0.1 to r epr esent a cross secti on
of the conductor, and pr oceed to the boundary mode to defi ne the boundary
condi ti on. Use the Select All opti on to sel ect al l boundari es and enter 1/57E6
i nto the r edi t fi el d i n the Boundary Condition di al og box to defi ne the
Di r i chl et boundary condi ti on (E = J / ).
Open the PDE Specification di al og box and enter the PDE parameter s. The
angul ar fr equency = 2 50.
I ni ti al i ze the mesh and sol ve the equati on. Due to the ski n effect, the cur rent
densi ty at the surface of the conductor i s much hi gher than i n the conductors
i nter i or. Thi s i s cl ear l y vi sual i zed by pl otti ng the curr ent densi ty J as a 3-D
pl ot. To i mpr ove the accuracy of the sol uti on cl ose to the surface, you need to
refi ne the mesh. Open the Solve Parameters di al og box and check the
Adaptive mode opti on. Al so, set the maxi mum number s of tr i angl es to I nf ,
the maxi mum numbers of r efi nements to 1, and use the tr i angl e sel ecti on
method that pi cks the worst tr i angl es. Recompute the sol uti on several ti mes.
Each ti me the adapti ve sol ver r efi nes the area wi th the l argest er ror s. The
J J
S
J
0
kr ( )
J
0
kR ( )
----------------- = k j =
2 Examples
2-54
number of tri angl es i s pri nted on the command l i ne. The mesh bel ow i s the
r esul t of successi ve adapti ons and contai ns 833 tri angl es.
The sol uti on of the AC power el ectr omagneti cs equati on i s compl ex. The pl ots
show the real part of the sol uti on (a war ni ng message i s i ssued), but the
sol uti on vector, whi ch can be exported to the mai n wor kspace, i s the ful l
compl ex sol uti on. Al so, you can pl ot vari ous properti es of the compl ex sol uti on
by usi ng the user entry. i mag( u) and abs ( u) ar e two exampl es of val i d user
entri es.
The ski n effect i s an AC phenomenon. Decr easi ng the fr equency of the
al ter nati ng cur rent r esul ts i n a decr ease of the ski n effect. Appr oachi ng DC
condi ti ons, the cur rent densi ty i s cl ose to uni form (exper i ment usi ng di fferent
angul ar frequenci es).
The adaptively refined mesh
0
0.2
0.4
0.6
0.8
1
0.1
0.05
0
0.05
0.1
0.1
0.05
0
0.05
0.1
0.2
0
0.2
0.4
0.6
0.8
1
Color: i Height: i
The current density in an AC wire
Appli cati on M odes
2-55
Conductive Media DC
For el ectrol ysi s and computati on of r esi stances of groundi ng pl ates, we have a
conducti ve medi um wi th conducti vi ty and a steady current. The curr ent
densi ty J i s r el ated to the el ectr i c fi el d E thr ough J = E. Combi ni ng the
conti nui ty equati on J = Q, where Q i s a curr ent sour ce, wi th the defi ni ti on
of the el ectri c potenti al V yi el ds the el l i pti c Poi ssons equati on
(V) = Q
The onl y two PDE parameter s ar e the conducti vi ty and the curr ent sour ce Q.
The Di r i chl et boundar y condi ti on assi gns val ues of the el ectri c potenti al V to
the boundar i es, usual l y metal l i c conductors. The Neumann boundary condi ti on
requi res the val ue of the normal component of the curr ent densi ty (n ( (V)))
to be known. I t i s al so possi bl e to speci fy a general i zed Neumann condi ti on
defi ned by n ( (V) + qV =g, where q can be i nter pr eted as a film conductance
for thi n pl ates.
The el ectri c potenti al V, the el ectri c fi el d E, and the curr ent densi ty J ar e al l
avai l abl e for pl otti ng. I nter esti ng quanti ti es to vi sual i ze are the curr ent l i nes
(the vector fi el d of J ) and the equi potenti al l i nes of V. The equi potenti al l i nes
ar e orthogonal to the curr ent l i nes when i s i sotropi c.
Example
Two ci r cul ar metal l i c conductor s are pl aced on a pl ane, thi n conductor l i ke a
bl otti ng paper wetted by br i ne. The equi potenti al s can be traced by a vol tmeter
wi th a si mpl e pr obe, and the curr ent l i nes can be tr aced by str ongl y col ored
i ons, such as permanganate i ons.
The physi cal model for thi s probl em consi sts of the Lapl ace equati on
(V) = 0
for the el ectr i c potenti al V and the boundar y condi ti ons:
V = 1 on the l eft ci rcul ar conductor
V = 1 on the ri ght ci rcul ar conductor
The natur al Neumann boundar y condi ti on on the outer boundar i es
The conducti vi ty = 1 (constant).
V
n
------ 0 =
2 Examples
2-56
Using the Graphical User Interface
I n the pde t ool GUI , sel ect the appl i cati on mode Conductive Media DC and
dr aw the bl otti ng paper as a r ectangl e wi th corners i n (-1.2,-0.6), (1.2,-0.6),
(1.2,0.6), and (-1.2,0.6). Add two ci rcl es wi th r adi us 0.3 representi ng the
ci rcul ar conductor s. Pl ace them symmetri cal l y wi th centers i n (-0.6,0) and
(0.6,0). I f the rectangl es l abel i s R1, and the ci rcl es l abel s ar e C1 and C2, the
2-D domai n of the pr obl em i s expr essed by the set for mul a
R1( C1+C2)
Enter the set formul a and press the button to decompose the geometry and
enter the boundar y mode. Sel ect al l the outer boundar i es and enter the
Neumann boundary condi ti on i nto the Boundary Condition di al og box. For
the l eft ci r cul ar conductor boundari es, enter the Di ri chl et boundary condi ti on
V = 1, and for the ri ght ci r cul ar conductor , enter the Di ri chl et condi ti on V = 1.
Next, open the PDE Specification di al og box and enter 0 i nto the edi t box for
the cur rent source q. The defaul t val ue for the conducti vi ty i s 1 and needs not
to be changed.
I ni ti al i ze the mesh and r efi ne i t twi ce. End by ji ggl i ng the mesh once to
i mpr ove the tr i angl e qual i ty.
Sol ve the PDE by pressi ng the = button. The r esul ti ng potenti al i s zer o al ong
the y-axi s, whi ch i s a ver ti cal l i ne of anti -symmetr y for thi s pr obl em.

Appli cati on M odes
2-57
Vi sual i ze the cur rent densi ty J by pl otti ng the absol ute val ue usi ng a contour
pl ot and the vector fi el d usi ng ar rows. The curr ent fl ows, as expected, from the
conductor wi th a posi ti ve potenti al to the conductor wi th a negati ve potenti al .
Heat Transfer
The heat equati on i s a par abol i c PDE:
I t descr i bes the heat transfer pr ocess for pl ane and axi -symmetri c cases and
uses the fol l owi ng par ameters:
Densi ty
Heat capacity C
Coefficient of heat conduction k
Heat source Q
Convective heat transfer coefficient h
External temper ature T
ext
The current density between two metallic conductors
C
T
t
------ kT ( ) Q h + T
ext
T ( ) =
2 Examples
2-58
The term h (T
ext
T) i s a model of tr ansversal heat transfer from the
surr oundi ngs, and i t may be useful for model i ng heat tr ansfer i n thi n cool i ng
pl ates etc.
For the steady state case, the el l i pti c versi on of the heat equati on,
i s al so avai l abl e.
The boundary condi ti ons can be of Di r i chl et type, where the temper ature on
the boundary i s speci fi ed, or of Neumann type where the heat flux, n (k(T))
i s speci fi ed. A general i zed Neumann boundary condi ti on can al so be used. The
general i zed Neumann boundary condi ti on equati on i s n (k(T)) + qT =g,
where q i s the heat transfer coeffi ci ent.
Vi sual i zati on of the temperatur e, the temper ature gradi ent, and the heat
fl ux kT i s avai l abl e. Pl ot opti ons i ncl ude isotherms and heat fl ux vector fi el d
pl ots.
Example
I n the fol l owi ng exampl e, a heat tr ansfer pr obl em wi th di fferi ng materi al
par ameters i s sol ved.
The probl ems 2-D domai n consi sts of a squar e wi th an embedded di amond (a
squar e wi th 45 degr ees r otati on). The square regi on consi sts of a mater i al wi th
coeffi ci ent of heat conducti on of 10, and a densi ty of 2. The di amond-shaped
r egi on contai ns a uni form heat source of 4, and i t has a coeffi ci ent of heat
conducti on of 2 and a densi ty of 1. Both r egi ons have a heat capaci ty of 0.1.
kT ( ) Q h + T
ext
T ( ) =
Appli cati on M odes
2-59
Using the Graphical User Interface
Star t the pdet ool GUI and sel ect the appl i cati on mode Heat Transfer. I n
draw mode, set the x- and y-axi s l i mi ts to [ 0. 5 3. 5] and sel ect the Axis
Equal opti on from the Options menu. The squar e r egi on has corners i n (0,0),
(3,0), (3,3), and (0,3). The di amond-shaped r egi on has corner s i n (1.5,0.5),
(2.5,1.5), (1.5,2.5), and (0.5,1.5).
The temperatur e i s kept at 0 on al l the outer boundar i es, so you do not have to
change the defaul t boundar y condi ti ons. Move on to defi ne the PDE parameter s
(make sure that the Heat Transfer appl i cati on mode i s sel ected) i n the PDE
mode by doubl e-cl i cki ng on each of the two r egi ons and enter the PDE
parameter s. You want to sol ve the par abol i c heat equati on, so make sur e that
the Parabolic opti on i s sel ected. I n the square regi on, enter a densi ty of 2, a
heat capaci ty of 0.1, and a coeffi ci ent of heat conducti on of 10. There i s no heat
sour ce, so set i t to 0. I n the di amond-shaped regi on, enter a densi ty of 1, a heat
capaci ty of 0.1, and a coeffi ci ent of heat conducti on of 2. Enter 4 i n the edi t fi el d
for the heat source. The tr ansversal heat transfer ter m h (T
ext
T) i s not used,
so set h, the convecti ve heat transfer coeffi ci ent, to 0.
Si nce you ar e sol vi ng a dynami c PDE, you have to defi ne an i ni ti al val ue, and
the ti mes at whi ch you want to sol ve the PDE. Open the Solve Parameters
di al og box by sel ecti ng Parameters . . . from the Solve menu. The dynami cs
for thi s pr obl em i s ver y fast the temperatur e r eaches steady state i n about
0.1 ti me uni ts. To captur e the i nteresti ng part of the dynami cs, enter l ogs pac e
( 2, 1, 10) as the vector of ti mes at whi ch to sol ve the heat equati on.
l ogs pac e( 2, 1, 10) gi ves 10 l ogar i thmi cal l y spaced number s between 0.01
and 0.1. Set the i ni ti al val ue of the temperature to 0. I f the boundar y condi ti ons
and the i ni ti al val ue di ffer, the probl em for mul ati on contai ns di sconti nui ti es.
Sol ve the PDE. By defaul t, the temperatur e di str i buti on at the l ast ti me i s
pl otted. The best way to vi sual i ze the dynami c behavi or of the temperatur e i s
to ani mate the sol uti on. When ani mati ng, tur n on the Height (3-D plot)
opti on to ani mate a 3-D pl ot. Al so, sel ect the Plot in x-y grid opti on. Usi ng a
rectangul ar gri d i nstead of a tri angul ar gri d speeds up the ani mati on pr ocess
si gni fi cantl y.
2 Examples
2-60
Other i nteresti ng vi sual i zati ons ar e made by pl otti ng i sothermal l i nes usi ng a
contour pl ot, and by pl otti ng the heat fl ux vector fi el d usi ng arr ows.
Visualization of the temperature and the heat flux
Appli cati on M odes
2-61
Diffusion
Si nce heat tr ansfer i s a di ffusi on process, the generi c di ffusi on equati on has the
same str uctur e as the heat equati on:
where c i s the concentr ati on, D i s the diffusion coefficient and Q i s a vol ume
sour ce. The di ffusi on pr ocess may be ani sotropi c, i n whi ch case D i s a 2-by-2
matr i x.
The boundar y condi ti ons can be of Di r i chl et type, wher e the concentr ati on on
the boundary i s speci fi ed, or of Neumann type wher e the fl ux, n (D(c)) i s
speci fi ed. I t i s al so possi bl e to speci fy a gener al i zed Neumann condi ti on. I t i s
defi ned by n (D(c)) + qc =g, where q i s a tr ansfer coeffi ci ent.
Vi sual i zati on of the concentrati on, i ts gr adi ent, and the fl ux i s avai l abl e from
the Plot Selection di al og box.
c
t
----- Dc ( ) Q, =
2 Examples
2-62

3
The Graphi cal User
I nterface
PDE Toolbox Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Fi l e Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Edi t Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Opti ons Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Draw Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Rotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Boundar y Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
PDE Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Mesh Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Sol ve Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
Pl ot Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Wi ndow Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
Hel p Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
The Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-38
3 The G raphi cal User Interface
3-2
The PDE Tool box i ncl udes a graphi cal user i nter face (GUI ), pde t ool . The mai n
components of the GUI ar e the menus, the di al og boxes, and the tool bar . They
ar e expl ai ned i n detai l i n thi s secti on.
PDE Toolbox M enus
3-3
PDE Toolbox Menus
The GUI has a pul l -down menu bar that you can use to control the model i ng.
I t confor ms to common pul l -down menu standar ds.
Menu i tems fol l owed by a r i ght arr ow l ead to a submenu. Menu i tems fol l owed
by an el l i psi s l ead to a di al og box. Stand-al one menu i tems l ead to di rect acti on.
Some menu i tems can be executed by usi ng keyboard accel erator s.
pde t ool al so contai ns a tool bar wi th i con buttons for qui ck and easy access to
some of the most i mpor tant pdet ool functi ons.
The fol l owi ng secti ons descri be the contents of the pdet ool menus and the
di al og boxes associ ated wi th menu i tems.
File Menu
New
New del etes the curr ent CSG model and creates a new, empty model cal l ed
Unti tl ed.
New Cr eate a new (empty) Constructive Solid Geometry (CSG) model .
Open. . . Load a model M-fi l e from di sk.
Save Save the GUI sessi on to a Model M-fi l e.
Save As. . . Save the GUI sessi on to a new Model M-fi l e.
Print. . . Pri nt a hardcopy of the PDE Tool box fi gure.
Exit Exi t the pde t ool gr aphi cal user i nterface.
3 The G raphi cal User Interface
3-4
Open . . .
Open . . . di spl ays a di al og box wi th a l i st of exi sti ng M-fi l es from whi ch you
can sel ect the fi l e that you want to l oad. You can l i st the contents of a di ffer ent
di r ectory by changi ng the path i n the Selection text box. You can use the
scrol l bar to di spl ay mor e fi l enames. You can sel ect a fi l e by doubl e-cl i cki ng on
the fi l ename or by cl i cki ng on the fi l ename and then cl i cki ng on the Done
button. When you sel ect a fi l e, the CSG model that i s stor ed i n the Model M-fi l e
i s l oaded i nto the PDE Tool box and di spl ayed. Al so, the equati on, the boundary
condi ti ons, and i nfor mati on about the mesh and the sol uti on are l oaded i f
pr esent, and the model i ng and sol uti on pr ocess conti nues to the same status as
when you saved the fi l e.
PDE Toolbox M enus
3-5
Save As . . .
Save As . . . di spl ays a di al og box i n whi ch you can speci fy the name of the fi l e
i n whi ch to save the CSG model and other i nformati on r egar di ng the GUI
sessi on. You can al so change the di r ector y i n whi ch i t i s saved. I f the fi l ename
i s gi ven wi thout a . m extensi on, . m i s appended automati cal l y.
The GUI sessi on i s stor ed i n a Model M-fi l e, whi ch contai ns a sequence of
drawi ng commands and commands to r ecr eate the model i ng envi r onment (axes
scal i ng, gr i d, etc.). I f you have al r eady defi ned boundar y condi ti ons, PDE
coeffi ci ents, created a tri angul ar mesh, and sol ved the PDE, fur ther commands
to recreate the model i ng and sol uti on of the PDE pr obl em are al so i ncl uded i n
the Model M-fi l e. The pde t ool GUI can be star ted fr om the command l i ne by
enter i ng the name of a Model M-fi l e. The model i n the fi l e i s then di r ectl y
l oaded i nto the GUI .
3 The G raphi cal User Interface
3-6
Print . . .
Print . . . di spl ays a di al og box for pr i nti ng a har dcopy of the PDE Tool box
fi gure. Onl y the mai n part of the fi gur e i s pri nted, not the upper and l ower
menu and i nfor mati on par ts. I n the di al og box, you can enter any devi ce opti on
that i s avai l abl e for MATLABs pr i nt command. The defaul t devi ce opti on i s
dps (PostScri pt for bl ack and whi te pri nters). The paper or i entati on can be set
to por t r ai t , l ands cape, or t al l , and you can pr i nt to a pr i nter or to fi l e.
PDE Toolbox M enus
3-7
Edit Menu
Undo Undo the l ast l i ne when drawi ng a pol ygon.
Cut Move the sel ected sol i d objects to the Cl i pboar d.
Copy Copy the sel ected objects to the Cl i pboar d, l eavi ng them
i ntact i n thei r ori gi nal l ocati on.
Paste . . . Copy the contents of the Cl i pboard to the cur rent CSG
model .
Clear Del ete the sel ected objects.
Select All Sel ect al l sol i d objects i n the curr ent CSG model . Al so,
sel ect al l outer boundar i es or sel ect al l subdomai ns.
3 The G raphi cal User Interface
3-8
Paste . . .
Paste . . . di spl ays a di al og box for pasti ng the contents of the Cl i pboar d on to
the cur rent CSG model . The Cl i pboar d contents can be repeatedl y pasted
addi ng a speci fi ed x- and y-axi s di spl acement to the posi ti ons of the Cl i pboard
objects.
Usi ng the defaul t val ues zero di spl acement and one r epeti ti on , the
Cl i pboar d contents i s i nser ted at i ts or i gi nal posi ti on.
PDE Toolbox M enus
3-9
Options Menu
Grid Turn gri d on/off.
Grid Spacing . . . Adjust the gri d spaci ng.
Snap Turn the snap-to-gri d featur e on/off.
Axis Limits . . . Change the scal i ng of the dr awi ng axes.
Axis Equal Turn the axi s equal featur e on/off.
Turn off Toolbar Help Turn off hel p texts for the tool bar buttons.
Zoom Turn zoom featur e on/off.
Application Sel ect appl i cati on mode.
Refresh Redi spl ay al l graphi cal objects i n the
pdet ool gr aphi cal user i nter face.
3 The G raphi cal User Interface
3-10
Grid Spacing . . .
I n the Grid Spacing di al og box, you can adjust the x-axi s and y-axi s gri d
spaci ng. By defaul t, MATLABs automati c l i near gri d spaci ng i s used. I f you
turn off the Auto checkbox, the edi t fi el ds for l i near spaci ng and extra ti cks ar e
enabl ed. For exampl e, the defaul t l i near spaci ng 1. 5: 0. 5: 1. 5 can be changed
to 1. 5: 0. 2: 1. 5. I n addi ti on, you can add extr a ti cks so that the gr i d can be
customi zed to ai d i n dr awi ng the desi r ed 2-D domai n. Extra ti ck entr i es can be
separ ated usi ng spaces, commas, semi col ons, or br ackets.
Exampl es:
pi
2/3, 0. 78, 1. 1
0. 123; pi /4
Pressi ng the Apply push button appl i es the enter ed gri d spaci ng; pressi ng the
Done button ends the Grid Spacing di al og.
PDE Toolbox M enus
3-11
Axes Limits . . .
I n the Axes Limits di al og box, the r ange of the x-axi s and the y-axi s can be
adjusted. The axi s r ange shoul d be entered as a 1-by-2 MATLAB vector such as
[ 10 10] . I f you check the Auto checkbox, automati c scal i ng of the axi s i s used.
Pressi ng the Apply button appl i es the entered axi s r anges; pr essi ng the Close
button ends the Axes Limits di al og.
Application
From the Application submenu, you can sel ect fr om 10 avai l abl e appl i cati on
modes. The appl i cati on modes can al so be sel ected usi ng the pop-up menu i n
the upper-r i ght corner of the GUI .
3 The G raphi cal User Interface
3-12
The avai l abl e appl i cati on modes ar e:
Gener i c Scal ar (the defaul t mode)
Gener i c System
Str uctur al Mechani cs - Pl ane Str ess
Str uctur al Mechani cs - Pl ane Str ai n
El ectr ostati cs
Magnetostati cs
AC Power El ectr omagneti cs
Conducti ve Medi a DC
Heat Transfer
Di ffusi on
See Appl i cati on Modes on page 2-35 for more detai l s.
PDE Toolbox M enus
3-13
Draw Menu
Draw Mode Enter dr aw mode.
Rectangle/square Dr aw a r ectangl e/square star ti ng at a
cor ner. Usi ng the l eft mouse button,
cl i ck-and-dr ag to create a rectangl e.
Usi ng the ri ght mouse button (or
Control-cl i ck), cl i ck-and-dr ag to
cr eate a squar e.
Rectangle/square (centered) Dr aw a r ectangl e/square star ti ng at
the center. Usi ng the l eft mouse
button, cl i ck-and-drag to cr eate a
rectangl e. Usi ng the ri ght mouse
button (or Control-cl i ck),
cl i ck-and-dr ag to create a square.
Ellipse/circle Dr aw an el l i pse/ci rcl e starti ng at the
peri meter. Usi ng the l eft mouse
button, cl i ck-and-drag to cr eate an
el l i pse. Usi ng the r i ght mouse button
(or Control-cl i ck), cl i ck-and-dr ag to
cr eate a ci rcl e.
3 The G raphi cal User Interface
3-14
Rotate . . .
Rotate . . . opens a di al og box wher e you can enter the angl e of r otati on i n
degr ees. The sel ected objects ar e then rotated by the number of degr ees that
you speci fy. The r otati on i s done counter cl ockwi se for posi ti ve rotati on angl es.
By defaul t, the rotati on center i s the center -of-mass of the sel ected objects. I f
the Use center-of-mass opti on i s unchecked, you can enter a r otati on center
(x
c
,y
c
) as a 1-by-2 MATLAB vector such as [ 0. 4 0. 3] .
Ellipse/circle (centered) Dr aw an el l i pse/ci r cl e star ti ng at the
center. Usi ng the l eft mouse button,
cl i ck-and-drag to cr eate an el l i pse.
Usi ng the ri ght mouse button (or
Control-cl i ck), cl i ck-and-drag to
create a ci rcl e.
Polygon Dr aw a pol ygon. You can cl ose the
pol ygon by pr essi ng the ri ght mouse
button. Cl i cki ng at the star ti ng ver tex
al so cl oses the pol ygon.
Rotate . . . Rotate sel ected objects.
Export Geometry Description,
Set Formula, Labels. . .
Expor t the Geometry Descr i pti on
matr i x gd, the set formul a str i ng s f ,
and the Name Space matr i x ns (l abel s)
to the mai n wor kspace.
PDE Toolbox M enus
3-15
Boundary Menu
Boundary Mode Enter the boundar y mode.
Specify Boundary
Conditions . . .
Speci fy boundary condi ti ons for the sel ected
boundari es. I f no boundar i es ar e sel ected, the
entered boundary condi ti on appl i es to al l
boundari es.
Show Edge Labels Toggl e the l abel i ng of the edges (outer
boundari es and subdomai n border s) on/off.
The edges ar e l abel ed usi ng the col umn
number i n the Decomposed Geometr y matr i x.
Show Subdomains
Labels
Toggl e the l abel i ng of the subdomai ns on/off.
The subdomai ns are l abel ed usi ng the
subdomai n number i ng i n the Decomposed
Geometry matri x.
Remove Subdomain
Border
Remove sel ected subdomai n bor der s.
Remove All Subdomain
Borders
Remove al l subdomai n bor der s.
Export Decomposed
Geometry, Boundary
Conds . . .
Export the Decomposed Geometr y matri x g
and the Boundary Condi ti on matri x b to the
mai n wor kspace.
3 The G raphi cal User Interface
3-16
Specify Boundary Conditions . . .
Specify boundary conditions . . . di spl ays a di al og box i n whi ch you can
speci fy the boundar y condi ti on for the sel ected boundar y segments. There are
three di ffer ent condi ti on types:
Gener al i zed Neumann condi ti ons, where the boundary condi ti on i s
deter mi ned by the coeffi ci ents q and g accor di ng to the fol l owi ng equati on:
I n the system cases, q i s a 2-by-2 matri x and g i s a 2-by-1 vector .
Di r i chl et condi ti ons: u i s speci fi ed on the boundary. The boundary condi ti on
equati on i s hu = r, wher e h i s a wei ght factor that can be appl i ed (normal l y 1).
I n the system cases, h i s a 2-by-2 matri x and r i s a 2-by-1 vector .
Mi xed boundary condi ti ons (system cases onl y), whi ch i s a mi x of Di r i chl et
and Neumann condi ti ons. q i s a 2-by-2 matri x, g i s a 2-by-1 vector, h i s a
1-by-2 vector, and r i s a scal ar .
n c u ( ) qu + g =
PDE Toolbox M enus
3-17
The fol l owi ng fi gure shows the boundary condi ti on di al og box for the gener i c
system PDE.
For boundar y condi ti on entr i es you can use the fol l owi ng vari abl es i n a val i d
MATLAB expressi on:
The 2-D coor di nates x and y
A boundar y segment par ameter s , pr opor ti onal to arc l ength. s i s 0 at the
star t of the boundary segment and i ncreases to 1 al ong the boundary
segment i n the di r ecti on i ndi cated by the ar row.
The outwar d normal vector components nx and ny. I f you need the tangenti al
vector , i t can be expr essed usi ng nx and ny si nce t
x
= -n
y
and t
y
= n
x
.
The sol uti on u
The ti me t
NOTE: I f the boundary condi ti on i s a functi on of the sol uti on u, you must use
the nonl i near sol ver. I f the boundary condi ti on i s a functi on of the ti me t, you
must choose a par abol i c or hyperbol i c PDE.
Exampl es: ( 10080*s ) . *nx, and cos ( x. ^2) .
I n the nongener i c appl i cati on modes, the Description col umn contai ns
descr i pti ons of the physi cal i nterpr etati on of the boundar y condi ti on
parameter s.
3 The G raphi cal User Interface
3-18
PDE Menu
PDE Mode Enter the par ti al di fferenti al equati on
mode.
Show Subdomain Labels Toggl e the l abel i ng of the subdomai ns
on/off. The subdomai ns ar e l abel ed usi ng
the subdomai n numberi ng i n the
decomposed geometr y matri x.
PDE Specification . . . Open di al og box for enteri ng PDE
coeffi ci ents and types.
Export PDE Coefficients . . . Export curr ent PDE coeffi ci ents to the
mai n wor kspace. The r esul ti ng
workspace vari abl es are str i ngs.
PDE Toolbox M enus
3-19
PDE Specification . . .
PDE Specification . . . opens a di al og box where you enter the type of parti al
di ffer enti al equati on and the appl i cabl e parameter s. The di mensi on of the
parameter s i s dependent on the di mensi on of the PDE. The descri pti on bel ow
appl i es to scal ar PDEs. I f a nongeneri c appl i cati on mode i s sel ected,
appl i cati on-speci fi c PDEs and par ameters repl ace the standard PDE
coeffi ci ents. For a thorough descr i pti on of the di fferent appl i cati on modes, see
the secti on Appl i cati on Modes i n the Examples chapter .
Each of the coeffi ci ents c, a, f , and d can be gi ven as a val i d MATLAB
expressi on for computi ng coeffi ci ent val ues at the tr ai ngl e center s of mass. The
fol l owi ng var i abl es are avai l abl e:
x and y: The x- and y-coor di nates.
u: The sol uti on.
ux , uy : The x and y der i vati ves of the sol uti on.
t : The ti me.
NOTE: I f the PDE coeffi ci ent i s a functi on of the sol uti on u or i ts der i vati ves ux
and uy, you must use the nonl i near sol ver. I f the PDE coeffi ci ent i s a functi on
of the ti me t , you must choose a par abol i c or hyper bol i c PDE.
You can al so enter the name of a user-defi ned MATLAB functi on that accepts
the ar guments (p, t , u, t i me ). For an exampl e, type the functi on ci r c l e f .
3 The G raphi cal User Interface
3-20
c can be a scal ar or a 2-by-2 matri x. The matri x c can be used to model , e.g.,
pr obl ems wi th ani sotr opi c materi al pr oper ti es.
I f c contai ns two rows, they ar e the c
1,1
and c
2,2
el ements of a 2-by-2 symmetr i c
matri x
I f c contai ns three r ows, they ar e the c
1,1
, c
1,2
, and c
2,2
el ements of a 2-by-2
symmetri c matri x (c
2,1
= c
1,2
)
I f c contai ns four rows, they are the c
1,1
, c
2,1
, c
1,2
, and c
2,2
el ements of the 2-by-2
matri x above.
The avai l abl e types of PDEs ar e:
El l i pti c. The basi c for m of the el l i pti c PDE i s:
The par ameter d does not appl y to the el l i pti c PDE.
Parabol i c. The basi c for m of the parabol i c PDE i s:
wi th i ni ti al val ues u0 = u(t
0
).
Hyperbol i c. The basi c form of the hyperbol i c PDE i s:
wi th i ni ti al val ues u0 = u(t
0
) and ut 0 = (t
0
)
Ei genmodes. The basi c form of the PDE ei genval ue probl em i s:
The par ameter f does not appl y to the ei genval ue PDE.
c
1 1 ,
0
0 c
2 2 ,



c
1 1 ,
c
1 2 ,
c
2 1 ,
c
2 2 ,



cu ( ) au + f =
d
u
t
------ cu ( ) au + f, =
d

2
u
t
2
-------- cu ( ) au + f, =
u
t
------
cu ( ) au + du =
PDE Toolbox M enus
3-21
I n the system case, c i s a r ank four tensor , whi ch can be represented by four
2-by-2 matr i ces, c11, c 12, c 21, and c 22. They can be enter ed as one, two, thr ee
or four r ows see the scal ar case above. a and d ar e 2-by-2 matri ces, and f i s
a 2-by-1 vector . The PDE Specification di al og box for the system case i s
shown bel ow.
3 The G raphi cal User Interface
3-22
Mesh Menu
Mesh Mode Enter mesh mode.
Initialize Mesh Bui l d and di spl ay an i ni ti al tri angul ar
mesh.
Refine Mesh Uni forml y r efi ne the cur rent tr i angul ar
mesh.
J iggle Mesh Ji ggl e the mesh.
Undo Mesh Change Undo the l ast mesh change. Al l mesh
generati ons ar e saved, so repeated Undo
Mesh Change eventual l y bri ng you back
to the i ni ti al mesh.
Display Triangle Quality Di spl ay a pl ot of the tri angul ar mesh wher e
the i ndi vi dual tri angl es ar e col ored
accor di ng to thei r qual i ty. The qual i ty
measur e i s a number between 0 and 1,
where tr i angl es wi th a qual i ty measure
greater than 0.6 are acceptabl e. For detai l s
on the tr i angl e qual i ty measur e, see
pde t r i q i n the Reference chapter.
PDE Toolbox M enus
3-23
Parameters . . .
Parameters . . . opens a di al og box contai ni ng mesh generati on par ameters.
The parameter s used by the mesh i ni ti al i zati on al gori thm i ni t mes h are:
Maximum edge size: Largest tri angl e edge l ength (appr oxi matel y). Thi s
parameter i s opti onal and must be a r eal posi ti ve number .
Mesh growth rate: The r ate at whi ch the mesh si ze i ncreases away from
smal l parts of the geometr y. The val ue must be between 1 and 2. The defaul t
val ue i s 1.3, i .e., the mesh si ze i ncr eases by 30%.
J iggle mesh: Toggl es automati c ji ggl i ng of the i ni ti al mesh on/off.
Show Node Labels Toggl e the mesh node l abel s on/off. The
node l abel s ar e the col umn numbers i n the
Poi nt matri x p.
Show Triangle Labels Toggl e the mesh tr i angl e l abel s on/off. The
tr i angl e l abel s are the col umn numbers i n
the tr i angl e matri x t .
Parameters . . . Open di al og box for modi fi cati on of mesh
generati on par ameters.
Export Mesh . . . Expor t Poi nt matr i x p, Edge matri x e, and
Tri angl e matr i x t to the mai n wor kspace.
3 The G raphi cal User Interface
3-24
The parameter s used by the mesh ji ggl i ng al gor i thm j i ggl emes h ar e:
J iggle mode: Sel ect a ji ggl e mode fr om a pop-up menu. Avai l abl e modes are
on, opt i mi z e mi ni mum, and opt i mi z e mean. on ji ggl es the mesh once. Usi ng
the ji ggl e mode opt i mi z e mi ni mum, the ji ggl i ng process i s r epeated unti l the
mi ni mum tri angl e qual i ty stops i ncr easi ng or unti l the i ter ati on l i mi t i s
reached. The same appl i es for the opt i mi z e mean opti on, but i t tri es to
i ncrease the mean tr i angl e qual i ty.
Number of jiggle iterations: I terati on l i mi t for the opt i mi z e mi ni mum and
opt i mi z e me an modes. Defaul t: 20.
Fi nal l y, for the mesh r efi nement al gor i thm r ef i ne me s h, the Refinement
method can be r e gul ar or l onge s t . The defaul t refi nement method i s
r egul ar , whi ch resul ts i n a uni for m mesh. The refi nement method l onge s t
al ways r efi nes the l ongest edge on each tr i angl e.
PDE Toolbox M enus
3-25
Solve Menu
Parameters . . .
Solve PDE Sol ve the parti al di fferenti al equati on for the
current CSG model and tr i angul ar mesh, and
pl ot the sol uti on (the automati c sol uti on pl ot can
be di sabl ed).
Parameters . . . Open di al og box for entry of PDE sol ve
parameter s.
Export Solution . . . Export the PDE sol uti on vector u and, i f
appl i cabl e, the computed ei genval ues l to the
mai n wor kspace.
Solve Parameters dialog box for elliptic PDEs
3 The G raphi cal User Interface
3-26
Parameters . . . opens a di al og box wher e you can enter the sol ve par ameters.
The set of sol ve parameter s di ffer s dependi ng on the type of PDE.
El l i pti c PDEs. By defaul t, no speci fi c sol ve par ameters ar e used, and the
el l i pti c PDEs ar e sol ved usi ng the basi c el l i pti c sol ver as s empde . Opti onal l y,
the adapti ve mesh generator and sol ver adapt me s h can be used. For the
adapti ve mode, the fol l owi ng par ameters ar e avai l abl e:
- Adaptive mode. Toggl e the adapti ve mode on/off.
- Maximum number of triangles. The maxi mum number of new
tri angl es al l owed (can be set to I nf ). A defaul t val ue i s cal cul ated based on
the curr ent mesh.
- Maximum number of refinements. The maxi mum number of
successi ve refi nements attempted.
- Triangle selection method. Two tri angl e sel ecti on methods are
i ncl uded i n the PDE Tool box. You can al so suppl y your own functi on.
- Worst triangles. Thi s method pi cks al l tri angl es that are wor se than a
fracti on of the val ue of the wor st tri angl e (defaul t: 0.5). See the Reference
entry pde adwor s t for more detai l s.
- Relative tolerance. Thi s method pi cks tri angl es usi ng a rel ati ve tol er-
ance cr i ter i on (defaul t: 1E-3). See the Reference entry pdeadgs c for more
detai l s.
- User-defined function. Enter the name of a user-defi ned tri angl e
sel ecti on method. See pde de mo7 for an exampl e of a user -defi ned tri angl e
sel ecti on method.
- Function parameter. The functi on parameter al l ows fi ne-tuni ng of the
tri angl e sel ecti on methods. For the worst tr i angl e method (pdeadwor s t ), i t
i s the fracti on of the worst val ue that i s used to determi ne whi ch tri angl es
to r efi ne. For the rel ati ve tol er ance method, i t i s a tol er ance par ameter
that contr ol s how wel l the sol uti on fi ts the PDE.
- Refinement method. Can be r egul ar or l onges t . See the
Parameters. . . di al og box descri pti on i n the Mesh Menu secti on.
PDE Toolbox M enus
3-27
I f the probl em i s nonl i near, i .e., par ameters i n the PDE ar e di r ectl y dependent
on the sol uti on u, a nonl i near sol ver must be used. The fol l owi ng parameter s
ar e used:
- Use nonlinear solver. Toggl e the nonl i near sol ver on/off.
- Nonlinear tolerance. Tol erance parameter for the nonl i near sol ver.
- Initial solution. An i ni ti al guess. Can be a constant or a functi on of x and
y gi ven as a MATLAB expr essi on that can be eval uated on the nodes of the
cur rent mesh.
Exampl es: 1, and e xp( x . *y) . Opti onal parameter , defaul ts to zero.
- J acobian. Jacobi an approxi mati on method: f i xe d (the defaul t), a fi xed
poi nt i ter ati on, l umpe d, a l umped (di agonal ) appr oxi mati on, or f ul l , the
ful l Jacobi an.
- Norm. The type of norm used for computi ng the resi dual . Enter as e ne r gy
for an ener gy norm, or as a r eal scal ar p to gi ve the l
p
norm. The defaul t i s
I nf , the i nfi ni ty (maxi mum) nor m.
NOTE: The adapti ve mode and the nonl i near sol ver can be used together.
Par abol i c PDEs. The sol ve parameter s for the par abol i c PDEs are:
- Time. A MATLAB vector of ti mes at whi ch a sol uti on to the parabol i c PDE
shoul d be generated. The r el evant ti me span i s dependent on the dynami cs
of the probl em.
Exampl es: 0: 10, and l ogs pace ( 2, 0, 20) .
- u(t0). The i ni ti al val ue u(t
0
) for the parabol i c PDE probl em The i ni ti al
val ue can be a constant or a col umn vector of val ues on the nodes of the
cur rent mesh.
- Relative tolerance. Rel ati ve tol erance parameter for the ODE sol ver
that i s used for sol vi ng the ti me-dependent part of the par abol i c PDE
pr obl em.
- Absolute tolerance. Absol ute tol er ance par ameter for the ODE sol ver
that i s used for sol vi ng the ti me-dependent part of the par abol i c PDE
pr obl em.
3 The G raphi cal User Interface
3-28
Hyperbol i c PDEs. The sol ve parameter s for the hyperbol i c PDEs are:
- Time. A MATLAB vector of ti mes at whi ch a sol uti on to the hyperbol i c PDE
shoul d be generated. The rel evant ti me span i s dependent on the dynami cs
of the probl em.
Exampl es: 0: 10, and l ogs pac e( 2, 0, 20) .
- u(t0). The i ni ti al val ue u(t
0
) for the hyperbol i c PDE pr obl em. The i ni ti al
val ue can be a constant or a col umn vector of val ues on the nodes of the
curr ent mesh.
- u(t0). The i ni ti al val ue (t
0
) for the hyperbol i c PDE pr obl em. You can use
the same for mats as for u(t0).
- Relative tolerance. Rel ati ve tol erance parameter for the ODE sol ver
that i s used for sol vi ng the ti me-dependent par t of the hyper bol i c PDE
probl em.
- Absolute tolerance. Absol ute tol er ance par ameter for the ODE sol ver
that i s used for sol vi ng the ti me-dependent par t of the hyper bol i c PDE
probl em.
Solve Parameters dialog box for hyperbolic PDEs
u

PDE Toolbox M enus


3-29
Ei genval ue probl ems. For the ei genval ue PDE, the onl y sol ve par ameter i s
the Eigenvalue search range, a two-el ement vector , defi ni ng an i nter val
on the real axi s as a search range for the ei genval ues. The l eft-hand si de can
be I nf .
Exampl es: [ 0 100] , [ I nf 50] .
Solve Parameters dialog box for eigenvalue PDEs
3 The G raphi cal User Interface
3-30
Plot Menu
Parameters . . .
Parameters . . . opens a di al og box contai ni ng opti ons control l i ng the pl otti ng
and vi sual i zati on.
Plot Solution Di spl ay a pl ot of the sol uti on.
Parameters . . . Open di al og box for pl ot sel ecti on.
Export Movie . . . I f a movi e has been recorded, the movi e matri x M i s
exported to the mai n workspace.
The Plot Selection dialog box
PDE Toolbox M enus
3-31
The upper part of the di al og box contai ns four col umns:
Plot type (far l eft) contai ns a r ow of si x di ffer ent pl ot types, whi ch can be
used for vi sual i zati on:
- Color. Vi sual i zati on of a scal ar property usi ng col or ed surface objects.
- Contour. Vi sual i zati on of a scal ar pr oper ty usi ng col or ed contour l i nes.
The contour l i nes can al so enhance the col or vi sual i zati on when both pl ot
types ( Color and Contour) are checked. The contour l i nes are then
dr awn i n bl ack.
- Arrows. Vi sual i zati on of a vector proper ty usi ng ar rows.
- Deformed mesh. Vi sual i zati on of a vector property by deformi ng the
mesh usi ng the vector pr operty. The deformati on i s automati cal l y scal ed
to 10% of the probl em domai n. Thi s pl ot type i s pri mari l y i ntended for
vi sual i zi ng x- and y-di spl acements (u and v) for pr obl ems i n str uctur al
mechani cs. I f no other pl ot type i s sel ected, the defor med tri angul ar mesh
i s di spl ayed.
- Height (3-D plot). Vi sual i zati on of a scal ar property usi ng hei ght (z-axi s)
i n a 3-D pl ot. 3-D pl ots are pl otted i n separ ate fi gur e wi ndows. I f the Color
and Contour pl ot types are not used, the 3-D pl ot i s si mpl y a mesh pl ot.
You can vi sual i ze another scal ar pr oper ty si mul taneousl y usi ng Color
and/or Contour, whi ch resul ts i n a 3-D surface or contour pl ot.
- Animation. Ani mati on of ti me-dependent sol uti ons to parabol i c and
hyperbol i c probl ems. I f you check thi s opti on, the sol uti on i s recor ded and
then ani mated i n a separ ate fi gur e wi ndow usi ng MATLABs mov i e
functi on.
3 The G raphi cal User Interface
3-32
A col orbar i s added to the pl ots to map the col ors i n the pl ot to the magni tude
of the pr oper ty that i s represented usi ng col or or contour l i nes.
Property contai ns four pop-up menus contai ni ng l i sts of properti es that ar e
avai l abl e for pl otti ng usi ng the corr espondi ng pl ot type. Fr om the fi r st
pop-up menu you control the property that i s vi sual i zed usi ng col or and/or
contour l i nes. The second and thi rd pop-up menus contai n vector val ued
properti es for vi sual i zati on usi ng ar rows and deformed mesh, r especti vel y.
From the fourth pop-up menu, fi nal l y, you contr ol whi ch scal ar property to
vi sual i ze usi ng z-hei ght i n a 3-D pl ot. The l i sts of properti es ar e dependent
on the curr ent appl i cati on mode. For the gener i c scal ar mode, you can sel ect
the fol l owi ng scal ar properti es:
- u. The sol uti on i tsel f.
- abs(grad(u)). The absol ute val ue of u, eval uated at the center of each
tri angl e.
- abs(c*grad(u)). The absol ute val ue of c u, eval uated at the center of
each tr i angl e.
- user entry. A MATLAB expressi on r etur ni ng a vector of data defi ned on
the nodes or the tri angl es of the cur rent tri angul ar mesh. The sol uti on u,
i ts deri vati ves ux and uy , the x and y components of c u, c ux and cuy,
and x and y ar e al l avai l abl e i n the l ocal wor kspace. You enter the
expressi on i nto the edi t box to the ri ght of the Property pop-up menu i n
the User entry col umn.
Exampl es: u. *u, x+y
The vector pr oper ty pop-up menus contai n the fol l owi ng properti es i n the
gener i c scal ar case:
- -grad(u). The negati ve gradi ent of u, -u.
- -c*grad(u). c ti mes the negati ve gr adi ent of u, -c u.
- user entry. A MATLAB expr essi on [ px; py] returni ng a 2-by-ntri matr i x
of data defi ned on the tr i angl es of the curr ent tri angul ar mesh (ntri i s the
number of tri angl es i n the cur rent mesh). The sol uti on u, i ts der i vati ves ux
and uy , the x and y components of c u, cux and cuy , and x and y are al l
avai l abl e i n the l ocal wor kspace. Data defi ned on the nodes i s i nter pol ated
to tri angl e centers. You enter the expr essi on i nto the edi t fi el d to the ri ght
of the Property pop-up menu i n the User entry col umn.
Exampl es: [ ux; uy ] , [ x ; y ]
PDE Toolbox M enus
3-33
For the gener i c system case, the pr oper ti es avai l abl e for vi sual i zati on usi ng
col or , contour l i nes, or z-hei ght ar e u, v, abs(u,v), and a user entr y. For
vi sual i zati on usi ng ar rows or a defor med mesh, you can choose (u,v) or a user
entr y. For appl i cati ons i n structur al mechani cs, u and v ar e the x- and
y-di spl acements, r especti vel y.
For the vi sual i zati on opti ons i n the other appl i cati on modes, see Appl i cati on
Modes on page 2-35. Note that the vari abl es avai l abl e i n the l ocal workspace
for a user enter ed expr essi on are the same for al l scal ar and system modes (the
sol uti on i s al ways referr ed to as u and, i n the system case, v ).
User entry contai ns four edi t fi el ds where you can enter your own
expressi on, i f you sel ect the user entr y property fr om the cor respondi ng
pop-up menu to the l eft of the edi t fi el ds. I f the user entr y property i s not
sel ected, the cor respondi ng edi t fi el d i s di sabl ed.
Plot style contai ns three pop-up menus from whi ch you can control the pl ot
styl e for the col or, arr ow, and hei ght pl ot types respecti vel y. The avai l abl e
pl ot styl es for col or surface pl ots ar e:
- Interpolated shading. A surface pl ot usi ng the sel ected col or map and
i nterpol ated shadi ng, i .e., each tri angul ar ar ea i s col ored usi ng a l i near,
i nterpol ated shadi ng (the defaul t).
- Flat shading. A surface pl ot usi ng the sel ected col or map and fl at shadi ng,
i .e., each tr i angul ar area i s col or ed usi ng a constant col or.
You can use two di ffer ent arr ow pl ot styl es:
- Proportional. The l ength of the ar row cor responds to the magni tude of
the pr oper ty that you vi sual i ze (the defaul t).
- Normalized. The l engths of al l ar rows ar e normal i zed, i .e., al l arr ows
have the same l ength. Thi s i s useful when you are i nter ested i n the
di r ecti on of the vector fi el d. The di r ecti on i s cl earl y vi si bl e even i n ar eas
wher e the magni tude of the fi el d i s very smal l .
For hei ght (3-D pl ots), the avai l abl e pl ot styl es are:
- Continuous. Produces a smooth conti nuous pl ot by i nter pol ati ng data
fr om tr i angl e mi dpoi nts to the mesh nodes (the defaul t).
- Discontinuous. Pr oduces a di sconti nuous pl ot where data and z-hei ght
are constant on each tri angl e.
A total of three pr oper ti es of the sol uti on two scal ar pr oper ti es and one
vector fi el d can be vi sual i zed si mul taneousl y. I f the Height (3-D plot)
3 The G raphi cal User Interface
3-34
opti on i s turned off, the sol uti on pl ot i s a 2-D pl ot and i s pl otted i n the mai n
axes of the pde t ool GUI . I f the Height (3-D plot) opti on i s used, the sol uti on
pl ot i s a 3-D pl ot i n a separ ate fi gur e wi ndow. I f possi bl e, the 3-D pl ot uses an
exi sti ng fi gur e wi ndow. I f you woul d l i ke to pl ot i n a new fi gure wi ndow, si mpl y
type f i gur e at the MATLAB command l i ne.
Additional Plot Control Options
I n the mi ddl e of the di al og box ar e a number of addi ti onal pl ot control opti ons:
Plot in xy grid. I f you check thi s opti on, the sol uti on i s converted from the
ori gi nal tr i angul ar gri d to a rectangul ar x-y gri d. Thi s i s especi al l y useful for
ani mati ons si nce i t speeds up the pr ocess of r ecordi ng the movi e fr ames
si gni fi cantl y.
Show mesh. I n the surface pl ots, the mesh i s pl otted usi ng bl ack col or i f you
check thi s opti on. By defaul t, the mesh i s hi dden.
Contour plot levels. For contour pl ots, the number of l evel curves, e.g., 15
or 20 can be entered. Al ter nati vel y, a MATLAB-vector of l evel s can be
enter ed. The curves of the contour pl ot are then dr awn at those l evel s. The
defaul t i s 20 contour l evel curves.
Exampl es: [ 0: 100: 1000] , l ogs pace ( 1, 1, 30) .
Colormap. Usi ng the Colormap pop-up menu, you can sel ect fr om a
number of di ffer ent col ormaps: cool , gr ay , bone , pi nk, coppe r , hot , j e t , hs v ,
and pr i s m.
Plot solution automatically. Thi s opti on i s nor mal l y sel ected. I f turned
off, the PDE Tool box does not di spl ay a pl ot of the sol uti on i mmedi atel y upon
sol vi ng the PDE. The new sol uti on, however, can be pl otted usi ng thi s di al og
box.
PDE Toolbox M enus
3-35
For the par abol i c and hyperbol i c PDEs, the bottom r i ght par t of the di al og box
contai ns an addi ti onal opti on:
Time for plot. A pop-up menu al l ows you to sel ect whi ch of the sol uti ons to
pl ot by sel ecti ng the cor respondi ng ti me. By defaul t, the l ast sol uti on i s pl otted.
3 The G raphi cal User Interface
3-36
Al so, the Animation pl ot type i s enabl ed. I n i ts property fi el d you fi nd an
Options . . . push button. I f you pr ess on i t, an addi ti onal di al og box appears.
I t contai ns par ameters that control the ani mati on:
Animation rate (fps). For the ani mati on, thi s parameter contr ol s the speed
of the movi e i n frames per second (fps).
Number of repeats. The number of ti mes the movi e i s pl ayed.
Replay movie. I f you check thi s opti on, the current movi e i s r epl ayed
wi thout re-r ecordi ng the movi e fr ames. I f ther e i s no curr ent movi e, thi s
opti on i s di sabl ed.
For ei genval ue probl ems, the bottom r i ght part of the di al og box contai ns a
pop-up menu wi th al l ei genval ues. The pl otted sol uti on i s the ei genvector
associ ated wi th the sel ected ei genval ue. By defaul t, the smal l est ei genval ue i s
sel ected.
You can rotate the 3-D pl ots by cl i cki ng on the pl ot and, whi l e keepi ng the
mouse button down, movi ng the mouse. For gui dance, a sur roundi ng box
appear s. When r el easi ng the mouse, the pl ot i s redrawn usi ng the new
vi ewpoi nt. I ni ti al l y, the sol uti on i s pl otted usi ng -37.5 degr ees hori zontal
r otati on and 30 degr ees el evati on.
I f you press the Plot button, the sol uti on i s pl otted i mmedi atel y usi ng the
cur rent pl ot setup. I f ther e i s no cur rent sol uti on avai l abl e, the PDE i s fi r st
sol ved. The new sol uti on i s then pl otted. The di al og box remai ns on the scr een.
I f you press the Done button, the di al og box i s cl osed. The curr ent setup i s
saved but no addi ti onal pl otti ng takes pl ace.
I f you press the Cancel button, the di al og box i s cl osed. The setup remai ns
unchanged si nce the l ast pl ot.
PDE Toolbox M enus
3-37
Window Menu
From the Window menu, you can sel ect al l cur rentl y open MATLAB fi gur e
wi ndows. The sel ected wi ndow i s brought to the front.
Help Menu
Help . . . Di spl ay a br i ef hel p wi ndow.
About . . . Di spl ay a wi ndow wi th some pr ogram i nfor mati on.
3 The G raphi cal User Interface
3-38
The Toolbar
The tool bar underneath the mai n menu at the top of the GUI contai ns i con
buttons that provi de qui ck and easy access to some of the most i mportant
functi ons. They do not offer any addi ti onal functi onal i ty; al l tool bar buttons
functi ons are al so avai l abl e usi ng menu i tems. The tool bar consi sts of thr ee
di fferent par ts: the fi ve l eft-most buttons for dr aw mode functi ons, the next si x
buttons for di fferent boundar y, mesh, sol uti on and pl ot functi ons, and fi nal l y
the r i ght-most button for acti vati ng the zoom featur e.
The draw mode buttons represent, from l eft to ri ght:
Dr aw a r ectangl e/square starti ng at a corner . Usi ng the l eft mouse button,
cl i ck-and-drag to cr eate a r ectangl e. Usi ng the r i ght mouse button (or
Control-cl i ck), cl i ck-and-dr ag to cr eate a square.
Dr aw a rectangl e/squar e starti ng at the center . Usi ng the l eft mouse button,
cl i ck-and-drag to cr eate a r ectangl e. Usi ng the r i ght mouse button (or
Control-cl i ck), cl i ck-and-dr ag to cr eate a square.
Dr aw an el l i pse/ci r cl e starti ng at the peri meter . Usi ng the l eft mouse button,
cl i ck-and-drag to cr eate an el l i pse. Usi ng the ri ght mouse button (or
Control-cl i ck), cl i ck-and-dr ag to cr eate a ci rcl e.
Dr aw an el l i pse/ci r cl e star ti ng at the center . Usi ng the l eft mouse button,
cl i ck-and-drag to cr eate an el l i pse. Usi ng the ri ght mouse button (or
Control-cl i ck), cl i ck-and-dr ag to cr eate a ci rcl e.
Dr aw a pol ygon. Cl i ck-and-dr ag to create pol ygon edges. You can cl ose the
pol ygon by pr essi ng the ri ght mouse button. Cl i cki ng at the starti ng ver tex
al so cl oses the pol ygon.
The dr aw mode buttons can onl y be acti vated one at the ti me and they al l work
the same way: si ngl e-cl i cki ng on a button al l ows you to draw one sol i d object of
the sel ected type. Doubl e-cl i cki ng on a button makes i t sti ck, and you can
then conti nue to dr aw sol i d objects of the sel ected type unti l you si ngl e-cl i ck on
the button to rel ease i t.
I f you are not i n the draw mode when you cl i ck on one of the draw mode
buttons, the GUI enter s the dr aw mode automati cal l y.
The Toolbar
3-39
The second group of buttons i ncl udes the fol l owi ng buttons, fr om l eft to r i ght:
: Enter s the boundary mode.
PDE: Opens the PDE Speci fi cati on di al og box.
I ni ti al i zes the tr i angul ar mesh.
The Refine button (the four tri angl e i con): Refi nes the tri angul ar mesh.
=: Sol ves the PDE.
The 3-D sol uti on pl ot i con: Opens the Solution Plot Selection di al og box.
The buttons i n the second group are of the fl ash type; si ngl e-cl i cki ng on them
i ni ti ates the associ ated functi on.
The l ast, r i ght-most button wi th the magni fi er i con toggl es the zoom functi on
on/off.

3 The G raphi cal User Interface
3-40

4
The Fi ni te El ement
Method
The Elliptic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
The Elliptic System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
The Parabolic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
The Hyperbolic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
The Eigenvalue Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
Nonlinear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
Adaptive Mesh Refinement . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
The Err or I ndi cator Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
The Mesh Refi ner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-27
The Ter mi nati on Cri teri a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
Fast Solution of Poissons Equation . . . . . . . . . . . . . . . . . . 4-29
4 The Fi ni te Element M ethod
4-2
The cor e of the PDE Tool box i s a PDE sol ver that uses the Finite Element
Method (FEM) for pr obl ems defi ned on bounded domai ns i n the pl ane. The
tool box provi des a user-fri endl y i nter face between the computi ng envi r onment
of MATLAB and the techni cal pr ocedur es of the Fi ni te El ement Method.
The Elli pti c Equati on
4-3
The Elliptic Equation
The basi c el l i pti c equati on handl ed by the tool box i s:
i n ,
where i s a bounded domai n i n the pl ane. c, a, f, and the unknown sol uti on u
ar e compl ex functi ons defi ned on . c can al so be a 2-by-2 matri x functi on on
. The boundary condi ti ons speci fy a combi nati on of u and i ts normal
deri vati ve on the boundary:
Dirichlet: hu =r on the boundar y .
Generalized Neumann: (cu) + qu =g on .
Mixed: Onl y appl i cabl e to systems. A combi nati on of Di r i chl et and
general i zed Neumann.
i s the outward uni t normal . g, q, h, and r are functi ons defi ned on .
Our nomencl ature devi ates sl i ghtl y fr om the tradi ti on for potenti al theory,
where a Neumann condi ti on usual l y r efer s to the case q = 0 and our Neumann
woul d be cal l ed a mi xed condi ti on. I n some contexts, the general i zed Neumann
boundary condi ti ons i s al so r efer red to as the Robin boundary conditions. I n
var i ati onal cal cul us, Di ri chl et condi ti ons ar e al so cal l ed essenti al boundar y
condi ti ons and r estri ct the tr i al space. Neumann condi ti ons are al so cal l ed
natur al condi ti ons and ari se as necessary condi ti ons for a sol uti on. The
var i ati onal for m of the PDE Tool box equati on wi th Neumann condi ti ons i s
gi ven bel ow.
The appr oxi mate sol uti on to the el l i pti c PDE i s found i n three steps:
1 Descr i be the geometr y of the domai n and the boundary condi ti ons. Thi s
can be done ei ther i nter acti vel y usi ng pde t ool (see Chapter 3, "The
Graphi cal User I nterface") or through M-fi l es (see the entri es on pdegeom
and pde bound i n Chapter 5, "Refer ence").
2 Bui l d a tri angul ar mesh on the domai n . The tool box has mesh generati ng
and mesh r efi ni ng faci l i ti es. A mesh i s descr i bed by thr ee matr i ces of fi xed
format that contai n i nfor mati on about the mesh poi nts, the boundary
segments, and the tri angl es.
c u ( ) au + f =

n
n

4 The Fi ni te Element M ethod
4-4
3 Di screti ze the PDE and the boundary condi ti ons to obtai n a l i near system
Ku = F. The unknown vector u contai ns the val ues of the appr oxi mate
sol uti on at the mesh poi nts, the matr i x K i s assembl ed from the coeffi ci ents
c, a, h, and q and the ri ght-hand si de F contai ns, essenti al l y, aver ages of f
around each mesh poi nt and contri buti ons fr om g. Once the matr i ces K and
F ar e assembl ed, you have the enti re MATLAB envi r onment at your di sposal
to sol ve the l i near system and further process the sol uti on.
Mor e el abor ate appl i cati ons make use of the FEM-speci fi c i nfor mati on
r etur ned by the di ffer ent functi ons of the tool box. Ther efor e we qui ckl y
summar i ze the theor y and techni que of FEM sol vers to enabl e advanced
appl i cati ons to make ful l use of the computed quanti ti es.
FEM can be summar i zed i n the fol l owi ng sentence: Project the weak form of the
differential equation onto a finite-dimensional function space. The r est of thi s
secti on deal s wi th expl ai ni ng the above statement.
We star t wi th the weak form of the differential equation. Wi thout r estr i cti ng
the general i ty, we assume gener al i zed Neumann condi ti ons on the whol e
boundar y, si nce Di r i chl et condi ti ons can be approxi mated by gener al i zed
Neumann condi ti ons. I n the si mpl e case of a uni t matr i x h, setti ng g = qr and
then l etti ng yi el ds the Di ri chl et condi ti on because di vi si on wi th a ver y
l ar ge q cancel s the nor mal der i vati ve ter ms. The actual i mpl ementati on i s
di fferent, si nce the above pr ocedur e may create condi ti oni ng probl ems. The
mi xed boundary condi ti on of the system case r equi r es a mor e compl i cated
tr eatment, detai l ed i n the secti on The El l i pti c System.
Assume that u i s a sol uti on of the di ffer enti al equati on. Mul ti pl y the equati on
wi th an ar bi tr ary test function v and i ntegrate on :
I ntegrate by par ts (i .e., use Greens for mul a) to obtai n:
The boundary i ntegr al can be repl aced by the boundary condi ti on:
q
( c u ( ) )v auv x d + fv x d

c u ( )

v auv x d qu g + ( )vds

+ fv x d

=
The Elli pti c Equati on
4-5
Repl ace the ori gi nal probl em wi th: Find u such that
Thi s equati on i s cal l ed the vari ati onal , or weak, for m of the di ffer enti al
equati on. Obvi ousl y, any sol uti on of the di ffer enti al equati on i s al so a sol uti on
of the vari ati onal probl em. The r everse i s true under some r estr i cti ons on the
domai n and on the coeffi ci ent functi ons. The sol uti on of the var i ati onal probl em
i s al so cal l ed the weak sol uti on of the di ffer enti al equati on.
The sol uti on u and the test functi ons v bel ong to some functi on space V. The
next step i s to choose an N
p
-di mensi onal subspace . Project the weak
form of the differential equation onto a finite-dimensional function space si mpl y
means r equesti ng u and v to l i e i n r ather than V. The sol uti on of the fi ni te
di mensi onal probl em tur ns out to be the el ement of that l i es cl osest to the
weak sol uti on when measur ed i n the ener gy norm (see bel ow). Convergence i s
guaranteed i f the space tends to V as . Si nce the di ffer enti al
oper ator i s l i near , we demand that the var i ati onal equati on i s sati sfi ed for N
p

test-functi ons
i
that for m a basi s, i .e.,
Expand u i n the same basi s of
and obtai n the system of equati ons
c u ( )

v auv fv x d qu g + ( )vds

+ 0 v , =
V
N
p
V
V
N
p
V
N
p
V
N
p
N
P

V
N
p
c u ( )


i
au
i
f
i
dx qu g + ( )
i
ds

+ 0 i , 1 N
p
, , = =
V
N
p
u x ( ) U
j

j
x ( )
j 1 =
N
p

=
c
j
( )


i
a
j

i
x d q
j

i
s d

+ +


j 1 =
N
p

U
j
f
i
x d

= g
i
s, d

i + 1 N
p
, , =
4 The Fi ni te Element M ethod
4-6
Use the fol l owi ng notati ons:
(Sti ffness matri x)
(Mass matr i x)
and r ewri te the system i n the form (K +M +Q)U = F + G.
K, M, and Q are N
p
-by-N
p
matr i ces, and F and G ar e N
p
-vectors. K, M, and F
ar e pr oduced by as s e ma, whi l e Q, G ar e pr oduced by as s e mb. When i t i s not
necessar y to di sti ngui sh K, M, and Q or F and G, we col l apse the notati ons to
KU = F, whi ch for m the output of as s e mpde .
When the probl em i s self-adjoint and elliptic i n the usual mathemati cal sense,
the matri x K +M + Q becomes symmetr i c and posi ti ve defi ni te. Many common
pr obl ems have these character i sti cs, most notabl y those that can al so be
formul ated as mi ni mi zati on pr obl ems. For the case of a scal ar equati on, K, M,
and Q ar e obvi ousl y symmetr i c. I f c(x) > 0, a(x) 0 and q(x) 0 wi th q(x) >
0 on some par t of , then, i f U 0.
U
T
(K +M +Q)U i s the energy norm. Ther e are many choi ces of the test-functi on
spaces. The tool box uses conti nuous functi ons that are l i near on each tr i angl e
of the mesh. Pi ecewi se l i near i ty guarantees that the i ntegr al s defi ni ng the
sti ffness matr i x K exi st. Projecti on onto i s nothi ng mor e than l i near
i nterpol ati on, and the eval uati on of the sol uti on i nsi de a tri angl e i s done just
i n ter ms of the nodal val ues. I f the mesh i s uni forml y r efi ned,
appr oxi mates the set of smooth functi ons on .
A sui tabl e basi s for i s the set of tent or hat functi ons
i
. These are l i near
on each tri angl e and take the val ue 0 at al l nodes x
j
except for x
i
. Requesti ng

i
(x
i
) = 1 yi el ds the ver y pl easant pr oper ty
K
i j ,
c
j
( )


i
dx =
M
i j ,
a
j

i
dx

=
Q
i j ,
q
j

i
ds

=
F
i
f
i
dx

=
G
i
g
i
ds

=

U
T
K M Q + + ( )U c u
2

au
2
x d qu
2
s 0 i f U 0. , > d

+ + =
V
N
p
V
N
p
V
N
p
The Elli pti c Equati on
4-7
i .e., by sol vi ng the FEM system we obtai n the nodal val ues of the appr oxi mate
sol uti on. Fi nal l y note that the basi s functi on
i
vani shes on al l the tr i angl es
that do not contai n the node x
i
. The i mmedi ate consequence i s that the
i ntegral s appear i ng i n K
i,j
, M
i,j
, Q
i,j
, F
i
and G
i
onl y need to be computed on the
tr i angl es that contai n the node x
i
. Secondl y, i t means that K
i,j
and M
i,j
are zer o
unl ess x
i
and x
j
ar e verti ces of the same tri angl e and thus K and M are very
spar se matri ces. Thei r spar se str uctur e depends on the order i ng of the i ndi ces
of the mesh poi nts.
The i ntegr al s i n the FEM matr i ces ar e computed by addi ng the contri buti ons
from each tr i angl e to the cor respondi ng entri es (i .e., onl y i f the cor respondi ng
mesh poi nt i s a vertex of the tri angl e). Thi s process i s commonl y cal l ed
assembling, hence the name of the functi on as s e mpde .
The assembl i ng routi nes scan the tr i angl es of the mesh. For each tr i angl e they
compute the so-cal l ed l ocal matri ces
1
and add thei r components to the corr ect
posi ti ons i n the sparse matri ces or vectors. The i ntegr al s ar e computed usi ng
the mi d-poi nt rul e. Thi s appr oxi mati on i s opti mal si nce i t has the same order
of accuracy as the pi ecewi se l i near i nterpol ati on.
Consi der a tr i angl e gi ven by the nodes P
1
, P
2
, and P
3
as i n the fol l owi ng fi gur e.
1. The l ocal 3-by-3 matr i ces contai n the i ntegr al s eval uated onl y on the curr ent tr i angl e.
The coeffi ci ents ar e assumed constant on the tr i angl e and they ar e eval uated onl y i n the
tr i angl e barycenter.
u x
i
( ) U
j

j
x
i
( )
j 1 =
N
p

U
i
, = =
The local triangle P1P2P3
P
P
P
1
2
3
P
c
P
b
x
y
1
1
4 The Fi ni te Element M ethod
4-8
The si mpl est computati ons are for the l ocal mass matr i x m:
where P
c
i s the center of mass of P
1
P
2
P
3
, i .e.,
The contri buti on to the ri ght-hand si de F i s just
For the l ocal sti ffness matr i x we have to eval uate the gradi ents of the basi s
functi ons that do not vani sh on P
1
P
2
P
3
. Si nce the basi s functi ons are l i near on
the tr i angl e P
1
P
2
P
3
, the gr adi ents are constants. Denote the basi s functi ons
1
,

2
, and
3
such that
i
(P
i
) = 1. I f P
2
P
3
= [x
1
,y
1
]
T
then we have that
and after i ntegr ati on (taki ng c as a constant matr i x on the tri angl e)
I f two verti ces of the tr i angl e l i e on the boundary , they contri bute to the
l i ne i ntegr al s associ ated to the boundar y condi ti ons. I f the two boundar y poi nts
ar e P
1
and P
2
, then we have
and
where P
b
i s the mi d-poi nt of P
1
P
2
.
m
i j ,
a P
c
( )
i
x ( )
j
x ( ) x d
P
1
P
2
P
3

a P
c
( )
area P
1
P
2
P
3
( )
12
--------------------------------------- 1
i j ,
+ ( ), = =
P
c
P
1
P
2
P
3
+ +
3
------------------------------- =
f
i
f P
c
( )
area P
1
P
2
P
3
( )
3
--------------------------------------- =

1
2area P
1
P
2
P
3
( )
-------------------------------------------
y
1
x
1
=
k
i j ,
1
4area P
1
P
2
P
3
( )
------------------------------------------- y
j
x
j
, [ ]c P
c
( )
y
1
x
1
=

Q
i j ,
q P
b
( )
P
1
P
2

6
----------------------- 1
i j ,
+ ( ) i j , , 1 2 , = =
G
i
g P
b
( )
P
1
P
2

2
----------------------- i , 1 2 , = =
The Elli pti c Equati on
4-9
For each tr i angl e the ver ti ces P
m
of the l ocal tr i angl e cor respond to the i ndi ces
i
m
of the mesh poi nts. The contr i buti ons of the i ndi vi dual tri angl e ar e added to
the matr i ces such that, e.g.,
Thi s i s done by the functi on as s empde . The gradi ents and the areas of the
tr i angl es are computed by the functi on pde t r g.
The Di r i chl et boundar y condi ti ons ar e tr eated i n a sl i ghtl y di ffer ent manner.
They ar e el i mi nated fr om the l i near system by a pr ocedur e that yi el ds a
symmetri c, reduced system. The functi on as s e mpde can r etur n matri ces K, F,
B, and ud such that the sol uti on i s u = Bv + ud wher e Kv =F. u i s an N
p
-vector ,
and i f the r ank of the Di ri chl et condi ti ons i s rD, then v has N
p
rD components.
K
i
m
i
n
,
t K
i
m
i
n
,
k
m n ,
, m n , + 1 2 3 , , =
4 The Fi ni te Element M ethod
4-10
The Elliptic System
The tool box can al so handl e systems of N par ti al di ffer enti al equati ons over the
domai n . We have the el l i pti c system
(c u) + au = f,
the parabolic system
d - (c u) + au = f,
the hyperbolic system
d - (c u) + au = f,
and the eigenvalue system
- (c u) + au = du,
where c i s an N-by-N-by-2-by-2 tensor . By the notati on (c u), we mean
the N-by-1 matr i x wi th (i,1)-component.
The symbol s a and d denote N-by-N matri ces, and f and u denote col umn
vectors of l ength N.
The el ements c
ijkl
, a
ij
, d
ij
, and f
i
of c, a, d, and f are stored row-wi se i n the
MATLAB matri ces c , a, d, and f . The case of i denti ty, di agonal , and symmetr i c
matri ces ar e handl ed as speci al cases. For the tensor c
ijkl
thi s appl i es both to
the i ndi ces i and j, and to the i ndi ces k and l.
The PDE Tool box does not check the el l i pti ci ty of the pr obl em, and i t i s qui te
possi bl e to defi ne a system that i s not el l i pti c i n the mathemati cal sense. The
pr ocedure descr i bed above for the scal ar case i s appl i ed to each component of
the system, yi el di ng a symmetri c posi ti ve defi ni te system of equati ons
whenever the di fferenti al system possesses these char acter i sti cs.
u
t
------

2
u
t
2
--------

x
-----

j 1 =
N

c
i j 1 1 , , ,

x
-----

x
-----c
i j 1 2 , , ,

y
-----

y
-----c
i j 2 1 , , ,

x
-----

y
-----c
i j 2 2 , , ,

y
-----

+ + + u
j
The Elli pti c System
4-11
The boundar y condi ti ons now i n general ar e mixed, i .e., for each poi nt on the
boundary a combi nati on of Di r i chl et and general i zed Neumann condi ti ons,
By the notati on we mean the N-by-1 matri x wi th (i,1)-component
where the outward normal vector of the boundar y i s .
There are M Di r i chl et condi ti ons and the h-matri x i s M-by-N, M 0. The
gener al i zed Neumann condi ti on contai ns a sour ce h' where the Lagrange
mul ti pl i ers are computed such that the Di r i chl et condi ti ons become sati sfi ed.
I n a str uctur al mechani cs pr obl em, thi s ter m i s exactl y the reacti on for ce
necessar y to sati sfy the ki nemati c constrai nts descri bed by the Di r i chl et
condi ti ons.
The rest of thi s secti on detai l s the treatment of the Di ri chl et condi ti ons and
may be ski pped on a fi r st readi ng.
The PDE Tool box suppor ts two i mpl ementati ons of Di ri chl et condi ti ons. The
si mpl est i s the Sti ff Spr i ng model , so named for i ts i nterpretati on i n sol i d
mechani cs. I t has been menti oned i n the secti on The El l i pti c Equati on on
page 4-3 for the scal ar case, whi ch i s equi val ent to a di agonal h-matr i x. For the
gener al case, Di r i chl et condi ti ons
hu = r
ar e approxi mated by addi ng a term
L(hhu - hr)
to the equati ons KU =F, wher e L i s a l arge number such as 10
4
ti mes a
repr esentati ve si ze of the el ements of K.
When thi s number i s i ncreased, hu = r wi l l be mor e accuratel y sati sfi ed, but
the potenti al i l l -condi ti oni ng of the modi fi ed equati ons wi l l become more
seri ous.
hu r =
n c u ( ) qu + g h + =
n c u ( ) =
( ) cos (
j 1 =
N

c
i j 1 1 , , ,

x
----- ( ) cos c
i j 1 2 , , ,

y
----- ( ) sin c
i j 2 1 , , ,

x
----- ( ) sin c
i j 2 2 , , ,

y
-----

+ + + u
j
n ( ) ( ) sin , cos ( ) =
4 The Fi ni te Element M ethod
4-12
The second method i s al so appl i cabl e to gener al mi xed condi ti ons wi th
nondi agonal h, and i s fr ee of the i l l -condi ti oni ng, but i s more i nvol ved
computati onal l y. Assume that ther e ar e N
p
nodes i n the tr i angul ati on. Then
the number of unknowns i s N
p
N

=

N
u
. When Di r i chl et boundar y condi ti ons fi x
some of the unknowns, the l i near system can be corr espondi ngl y reduced. Thi s
i s easi l y done by r emovi ng rows and col umns when u val ues ar e gi ven, but her e
we must tr eat the case when some l i near combi nati ons of the components of u
ar e gi ven, hu = r. These ar e col l ected i nto HU =R where H i s an M-by-N
u

matri x and R i s an M-vector.
Wi th the r eacti on for ce term the system becomes
KU +H =F
HU =R
The constr ai nts can be sol ved for m of the U-var i abl es, the remai ni ng cal l ed V,
an N
u
- m vector. The nul l space of H i s spanned by the col umns of B, and
U =BV + u
d
makes U sati sfy the Di ri chl et condi ti ons. A per mutati on to bl ock-di agonal for m
expl oi ts the sparsi ty of H to speed up the fol l owi ng computati on to fi nd B i n a
numeri cal l y stabl e way. can be el i mi nated by pr emul ti pl yi ng by B si nce, by
the constr ucti on, HB = 0 or BH = 0. The r educed system becomes
B KBV= B F - BKu
d
whi ch i s symmetr i c and posi ti ve defi ni te i f K i s.
The Paraboli c Equati on
4-13
The Parabolic Equation
The el l i pti c sol ver al l ows other types of equati ons to be more or l ess easi l y
i mpl emented. Bel ow we show how the parabol i c equati on can be reduced to
sol vi ng el l i pti c equati ons. Thi s i s done by the tool box functi on par abol i c.
Consi der the equati on
wi th the i ni ti al condi ti on
and boundary condi ti ons of the same ki nd as for the el l i pti c equati on on .
The heat equati on r eads
i n the presence of di stri buted heat l oss to the surr oundi ngs. i s the densi ty, C
ther mal capaci ty, k thermal conducti vi ty, h fi l m coeffi ci ent, u

ambi ent
temperature, and f heat source.
For ti me-i ndependent coeffi ci ents, the steady state sol uti on of the equati on i s
the sol uti on to our standard el l i pti c equati on
- (cu) + au =f.
Assumi ng a tr i angul ar mesh on and at any ti me t 0, expand the sol uti on to
the PDE (as a functi on of x) i n the Fi ni te El ement method basi s:
d
u
t
------ c u ( ) au + f i n =
u x 0 , ( ) u
0
x ( ) = x

C
u
t
------ k u ( ) h u u

( ) + f =
u x t , ( ) U
i
t ( )

x ( )
i

=
4 The Fi ni te Element M ethod
4-14
Pl uggi ng the expansi on i nto the PDE, mul ti pl yi ng wi th a test functi on
j
,
i ntegr ati ng over , and appl yi ng Gr eens formul a and the boundary condi ti ons
yi el d:
I n matr i x notati on, we have to sol ve the linear, large and sparse ODE system
Thi s method i s tr adi ti onal l y cal l ed method of lines semi di screti zati on.
Sol vi ng the ODE wi th the i ni ti al val ue
U
i
(0) = u
0
(x
i
)
yi el ds the sol uti on to the PDE at each node x
i
and ti me t. Note that K and F ar e
the sti ffness matr i x and the ri ght-hand si de of the el l i pti c pr obl em
- (cu) + au = f i n
wi th the ori gi nal boundar y condi ti ons whi l e M i s just the mass matri x of the
pr obl em
- (0u) + du =0 i n .
When the Di ri chl et condi ti ons ar e ti me dependent, F contai ns contr i buti ons
from ti me der i vati ves of h and r. These der i vati ves ar e eval uated by fi ni te
di fferences of the user-speci fi ed data.

i
d x
U
i
d t ( )
t d
--------------- d

c
i
( ) a
j

i
x d q
j

i
s d

U
i
t ( ) + +
i

+
f
j

x d g
j

s d j. + =
M
dU
dt
------- KU + F. =
The Paraboli c Equati on
4-15
The ODE system i s i l l condi ti oned. Expl i ci t ti me i ntegr ators ar e for ced by
stabi l i ty r equi r ements to very short ti me steps whi l e i mpl i ci t sol ver s can be
expensi ve si nce they sol ve an el l i pti c pr obl em at ever y ti me step. The
numeri cal i ntegrati on of the ODE system i s per formed by the MATLAB ODE
Sui te functi ons, whi ch are effi ci ent for thi s cl ass of probl ems. The ti me-step i s
control l ed to sati sfy a tol erance on the err or , and factori zati ons of coeffi ci ent
matr i ces ar e performed onl y when necessar y. When coeffi ci ents ar e ti me
dependent, the necessi ty of re-eval uati ng and r e-factor i zi ng the matr i ces each
ti me-step may sti l l make the sol uti on ti me consumi ng, al though par abol i c
re-eval uates onl y that whi ch vari es wi th ti me. I n certai n cases a
ti me-dependent Di r i chl et matr i x h(t)may cause the er ror contr ol to fai l , even i f
the probl em i s mathemati cal l y sound and the sol uti on u(t) i s smooth. Thi s can
happen because the ODE i ntegr ator l ooks onl y at the reduced sol uti on v wi th
u = Bv + ud. As h changes, the pi voti ng scheme empl oyed for numer i cal
stabi l i ty may change the el i mi nati on or der from one step to the next. Thi s
means that B,v and ud al l change di sconti nuousl y, al though u i tsel f does not.
4 The Fi ni te Element M ethod
4-16
The Hyperbolic Equation
Usi ng the same i deas as for the par abol i c equati on, hy pe r bol i c i mpl ements
the numeri cal sol uti on of
- (cu) + au = f i n
wi th the i ni ti al condi ti ons
and usual boundar y condi ti ons. I n par ti cul ar , sol uti ons of the equati on
u
tt
- cu = 0 are waves movi ng wi th speed .
Usi ng a gi ven tr i angul ati on of , the method of l i nes yi el ds the second or der
ODE system
wi th the i ni ti al condi ti ons
after we el i mi nate the unknowns fi xed by Di r i chl et boundary condi ti ons. As
before, the sti ffness matr i x K and the mass matr i x M are assembl ed wi th the
ai d of the functi on as s e mpde fr om the pr obl ems
- (cu) + au = f and - (0u) + du =0.
d

2
u
t
2
--------
u x 0 , ( ) u
0
= x ( )
u
t
------ x 0 , ( ) v
0
= x ( ) x
c
M
d
2
U
dt
2
---------- KU + F =
U
i
0 ( ) u
0
x
i
( ), =
d
dt
---- -U
i
0 ( ) v
0
= x
i
( ) i
The Ei genvalue Equati on
4-17
The Eigenvalue Equation
The basi c ei genval ue pr obl em handl ed by the PDE Tool box i s
- (cu) + au =du
where i s an unknown compl ex number . I n sol i d mechani cs, thi s i s a probl em
associ ated wi th wave phenomena descri bi ng, e.g., the natur al modes of a
vi brati ng membrane. I n quantum mechani cs i s the energy l evel of a bound
state i n the potenti al wel l a(x).
The numer i cal sol uti on i s found by di screti zi ng the equati on and sol vi ng the
resul ti ng al gebr ai c ei genval ue pr obl em. Let us fi rst consi der the di scr eti zati on.
Expand u i n the FEM basi s, mul ti pl y wi th a basi s el ement, and i ntegrate on
the domai n . Thi s yi el ds the general i zed ei genval ue equati on
KU = MU,
where the mass matr i x cor responds to the ri ght-hand si de, i .e.,
The matri ces K and M ar e pr oduced by cal l i ng as s ema for the equati ons
- (cu) + au =0 and - (0u) + du =0.
Note that i n the most common case, when the functi on d(x) i s posi ti ve, the mass
matr i x M i s posi ti ve defi ni te symmetr i c. Li kewi se, when c(x) i s posi ti ve and we
have Di ri chl et boundary condi ti ons, the sti ffness matr i x K i s al so posi ti ve
defi ni te.
The gener al i zed ei genval ue pr obl em, KU = MU, i s now sol ved by the Arnoldi
algorithm appl i ed to a shi fted and i nverted matr i x wi th r estar ts unti l al l
ei genval ues i n the user-speci fi ed i nterval have been found.
Let us descr i be how thi s i s done i n more detai l . You may want to l ook at the
exampl e provi ded i n the secti on Exampl es of Ei genval ue Pr obl ems on page
2-27, wher e an actual r un i s r epor ted.
Fi rst a shi ft i s determi ned cl ose to where we want to fi nd the ei genval ues.
When both K and M are posi ti ve defi ni te, i t i s natur al to take = 0, and get the
smal l est ei genval ues; i n other cases take any poi nt i n the i nter val [lb,ub] wher e
ei genval ues ar e sought. Subtr act M from the ei genval ue equati on and get
(K - M)U = ( )MU. Then mul ti pl y wi th the i nver se of thi s shi fted matri x
M
i j ,
x ( )
j
x ( )
i
x ( ) d x. d

=
4 The Fi ni te Element M ethod
4-18
and get . Thi s i s a standard ei genval ue pr obl em AU
=U, wi th the matri x A = (K - M)
-1
M and ei genval ues , i = 1, . . .,
n. The l argest ei genval ues
i
of the tr ansfor med matr i x A now corr espond to the
ei genval ues
i
= + 1/
i
of the or i gi nal pencil (K,M) cl osest to the shi ft .
The Ar nol di al gori thm computes an or thonormal basi s V wher e the shi fted and
i nverted oper ator A i s r epr esented by a Hessenberg matri x H,
AV
j
=V
j
H
j,j
+E
j
.
(The subscr i pts mean that V
j
and E
j
have j col umns and H
j,j
has j r ows and
col umns. When no subscri pts ar e used we deal wi th vector s and matri ces
of si ze n.)
Some of the ei genval ues of thi s Hessenber g matr i x H
j,j
eventual l y gi ve good
appr oxi mati ons to the ei genval ues of the ori gi nal penci l (K,M) when the basi s
gr ows i n di mensi on j, and l ess and l ess of the ei genvector i s hi dden i n the
r esi dual matr i x E
j
.
The basi s V i s bui l t one col umn v
j
at a ti me. The fi rst vector v
1
i s chosen at
r andom, as n nor mal l y di str i buted random numbers. I n step j, the fi rst j vector s
ar e al r eady computed and form the n j matr i x V
j
. The next vector v
j +1
i s
computed by fi r st l etti ng A oper ate on the newest vector v
j
, and then maki ng
the r esul t orthogonal to al l the previ ous vectors.
Thi s i s formul ated as, h
j +1,j
v
j +1
=

Av
j
- V
j
h
j
, where the col umn vector h
j

consi sts of the Gr am-Schmi dt coeffi ci ents, and h
j +1,j
i s the nor mal i zati on
factor that gi ves v
j +1
uni t l ength. Put the cor respondi ng r el ati ons fr om
pr evi ous steps i n fr ont of thi s and get,
where H
j,j
i s a j j Hessenber g matri x wi th the vectors h
j
as col umns. The
second ter m on the r i ght-hand si de has nonzer os onl y i n the l ast col umn; the
ear l i er normal i zati on factors show up i n the subdi agonal of H
j,j
.
The ei gensol uti on of the smal l Hessenber g matr i x H
j,j
gi ves appr oxi mati ons to
some of the ei genval ues and ei genvectors of the l arge matr i x oper ator A i n the
fol l owi ng way. Compute ei genval ues
i
and ei genvector s s
i
of H
j,j
,
1

------------U K M ( ) MU
1
=

i
1

i

-------------- =
AV
j
V
j
H
j j ,
v
j 1 +
h
j 1 j , +
e
j
T
, + =
The Ei genvalue Equati on
4-19
H
j,j
s
i
= s
i

i
, i = 1, . . . ,j.
Then y
i
= V
j
s
i
i s an approxi mate ei genvector of A, and i ts resi dual i s,
r
i
= Ay
i
- y
i

i
= AV
j
s
i
- V
j
s
i

i
= (AV
j
- V
j
H
j,j
)s
i
= v
j+1
h
j+1,j
s
i,j
.
Thi s r esi dual has to be smal l i n nor m for
i
to be a good ei genval ue
approxi mati on. The nor m of the r esi dual i s | | r
i
| | = | h
j+1,j
s
j,i
| , the pr oduct of
the l ast subdi agonal el ement of the Hessenberg matr i x and the l ast el ement of
i ts ei genvector. I t sel dom happens that h
j+1,j
gets par ti cul ar l y smal l , but after
suffi ci entl y many steps j there are al ways some ei genvectors s
i
wi th smal l l ast
el ements. Note that the l ong vector V
j+1
i s of uni t nor m.
I t i s not necessary to actual l y compute the ei genvector approxi mati on y
i
to get
the norm of the resi dual ; we onl y need to exami ne the shor t vector s s
i
, and fl ag
those wi th ti ny l ast components as converged. I n a typi cal case n may be 2000,
whi l e j sel dom exceeds 50, so al l computati ons that i nvol ve onl y matr i ces and
vectors of si ze j are much cheaper than those i nvol vi ng vectors of l ength n.
Thi s ei genval ue computati on and test for conver gence i s done every few steps
j, unti l al l approxi mati ons to ei genval ues i nsi de the i nter val [lb,ub] are fl agged
as converged. When n i s much l arger than j, thi s i s done ver y often, for smal l er
n more sel dom. When al l ei genval ues i nsi de the i nter val have conver ged, or
when j has reached a pr escr i bed maxi mum, the converged ei genvectors, or
more appropri atel y Schur vectors, ar e computed and put i n the front of the
basi s V.
After thi s, the Ar nol di al gor i thm i s restarted wi th a r andom vector, i f al l
approxi mati ons i nsi de the i nter val ar e fl agged as conver ged, or el se wi th the
best unconverged approxi mate ei genvector y
i
. I n each step j of thi s second
Arnol di r un, the vector i s made or thogonal to al l vectors i n V i ncl udi ng the
converged Schur vector s from the pr evi ous r uns. Thi s way, the al gori thm i s
appl i ed to a projected matr i x, and pi cks up a second copy of any doubl e
ei genval ue ther e may be i n the i nterval . I f anythi ng i n the i nter val converges
dur i ng thi s second r un, a thi r d i s attempted and so on, unti l no more
approxi mate ei genval ues
i
show up i nsi de. Then the al gori thm si gnal s
convergence. I f ther e ar e sti l l unconver ged approxi mate ei genval ues after a
prescri bed maxi mum number of steps, the al gor i thm si gnal s nonconvergence
and reports al l sol uti ons i t has found.
4 The Fi ni te Element M ethod
4-20
Thi s i s a heuri sti c strategy that has worked wel l on both symmetr i c,
nonsymmetri c, and even defecti ve ei genval ue probl ems. There i s a ti ny
theor eti cal chance of mi ssi ng an ei genval ue, i f al l the random star ti ng vector s
happen to be or thogonal to i ts ei genvector. Normal l y, the al gor i thm restar ts p
ti mes, i f the maxi mum mul ti pl i ci ty of an ei genval ue i s p. At each restart a new
r andom star ti ng di r ecti on i s i ntr oduced.
Note that the shi fted and i nver ted matri x A = (K - M)
-1
M i s needed onl y to
operate on a vector v
j
i n the Ar nol di al gor i thm. Thi s i s done by computi ng an
LU factori zati on,
P(K - M)Q = LU,
usi ng the spar se MATLAB command l u ( P and Q ar e per mutati ons that make
the tr i angul ar factors L and U spar se and the factor i zati on numeri cal l y stabl e).
Thi s factor i zati on needs to be done onl y once, i n the begi nni ng, then x =Av
j
i s
computed as,
x =QU
-1
L
-1
PMv
j
,
wi th one sparse matr i x vector mul ti pl i cati on, a per mutati on, spar se for war ds-
and backsubsti tuti ons, and a fi nal renumber i ng.
N onli near Equati ons
4-21
Nonlinear Equations
The l ow-l evel functi ons of the PDE Tool box are ai med at sol vi ng l i near
equati ons. Si nce many i nteresti ng computati onal probl ems are nonl i near, the
tool box contai ns a nonl i near sol ver bui l t on top of the as s empde functi on.
The basi c i dea i s to use Gauss-Newton i ter ati ons to sol ve the nonl i near
equati ons. Say you ar e tr yi ng to sol ve the equati on
r(u) = (c(u)u) + a(u)u - f(u) = 0.
I n the FEM setti ng you sol ve the weak for m of r(u) = 0. Set as usual
, mul ti pl y the equati on by an ar bi tr ary test functi on
i
, i ntegr ate
on the domai n , and use Greens for mul a and the boundar y condi ti ons to
obtai n:
whi ch has to hol d for al l i ndi ces i.
The resi dual vector (U) can be easi l y computed as
(U) = (K +M + Q)U - (F +G)
where the matri ces K, M, Q and the vectors F and G are produced by
assembl i ng the pr obl em
(c(U)u) + a(U)u = f(U).
u x ( ) U
j

=
0 U ( ) c ( x U , ( )
j
x ( ) )
i
x ( ) a x U , ( )
j
x ( )
i
x ( )dx +

= =
q x U , ( )
j
x ( )
i
x ( )ds

U
j
+
f x U , ( )
i
x ( )dx

g x U , ( )
i
x ( )ds,

4 The Fi ni te Element M ethod


4-22
Assume that you have a guess U
(n)
of the sol uti on. I f U
(n)
i s cl ose enough to the
exact sol uti on
2
, an i mproved approxi mati on U
(n +1)
i s obtai ned by sol vi ng the
l i neari zed probl em
where i s a posi ti ve number . I t i s wel l known that for suffi ci entl y smal l ,
| | (U
(n + 1)
)| | < | | (U
(n)
)| | ,
and
i s cal l ed a descent di recti on for | | (U)| | , where | | | | i s the l
2
-norm. The
i ter ati on i s
U
(n +1)
= U
(n)
+ p
n
where 1 i s chosen as l arge as possi bl e such that the step has a r easonabl e
descent.
The Gauss-Newton method i s l ocal , and convergence i s assured onl y when U
(0)

i s cl ose enough to the sol uti on. I n general , the fi rst guess may be outsi de the
r egi on of convergence. To i mprove convergence from bad i ni ti al guesses, a
damping str ategy i s i mpl emented for choosi ng , the Armijo-Goldstein line
search. I t chooses the l ar gest dampi ng coeffi ci ent out of the sequence 1, 1/2,
1/4, . . . such that the fol l owi ng i nequal i ty hol ds:
| | (U
(n)
)| | - | | (U
(n)
+ p
n
)| | | | (U
(n)
)| |
whi ch guarantees a r educti on of the r esi dual norm by at l east 1 /2. Note that
each step of the l i ne-sear ch al gori thm requi res an eval uati on of the resi dual
(U
(n)
+ p
n
).
An i mportant poi nt of thi s strategy i s that when U
(n)
appr oaches the sol uti on,
then and thus the conver gence r ate i ncr eases. I f ther e i s a sol uti on to
(U) = 0, the scheme ul ti matel y r ecovers the quadr ati c convergence rate of the
standar d Newton i terati on.
2. I t i s not necessar y that (U)=0 has a sol uti on even i f r(u) = 0 has. I n thi s case the
Gauss-Newton i ter ati on tends to the mi ni mi zer of the r esi dual , i .e., the sol uti on
of mi n
U
| | (U)| | .
U
n ( )
( )
U
----------------------


U
n 1 + ( )
U
n ( )
( ) U
n ( )
( ) =
p
n
U
n ( )
( )
U
----------------------


1
U
n ( )
( ) =

2
---
1
N onli near Equati ons
4-23
Cl osel y r el ated to the above probl em i s the choi ce of the i ni ti al guess U
(0)
. By
defaul t, the sol ver sets U
(0)
and then assembl es the FEM matr i ces K and F and
computes
U
(1)
= K
-1
F.
The damped Gauss-Newton i ter ati on i s then star ted wi th U
(1)
, whi ch shoul d be
a better guess than U
(0)
. I f the boundary condi ti ons do not depend on the
sol uti on u, then U
(1)
sati sfi es them even i f U
(0)
does not. Fur ther mor e, i f the
equati on i s l i near, then U
(1)
i s the exact FEM sol uti on and the sol ver does not
enter the Gauss-Newton l oop.
There are si tuati ons wher e U
(0)
= 0 makes no sense or conver gence i s
i mpossi bl e.
I n some si tuati ons you may al ready have a good appr oxi mati on and the
nonl i near sol ver can be star ted wi th i t, avoi di ng the sl ow conver gence regi me.
Thi s i dea i s used i n the adapti ve mesh gener ator. I t computes a sol uti on on
a mesh, eval uates the er ror, and may r efi ne cer tai n tr i angl es. The i nter pol ant
of i s a ver y good starti ng guess for the sol uti on on the r efi ned mesh.
I n gener al the exact Jacobi an
i s not avai l abl e. Appr oxi mati on of J
n
by fi ni te di ffer ences i n the fol l owi ng way
i s expensi ve but feasi bl e. The i
th
col umn of J
n
can be appr oxi mated by
whi ch i mpl i es the assembl i ng of the FEM matr i ces for the tri angl es contai ni ng
gr i d poi nt i. A ver y si mpl e appr oxi mati on to J
n
, whi ch gi ves a fi xed poi nt
i ter ati on, i s al so possi bl e as fol l ows. Essenti al l y, for a gi ven U
(n)
, compute the
FEM matri ces K and F and set
U
(n + 1)
= K
-1
F.
Thi s i s equi val ent to approxi mati ng the Jacobi an wi th the sti ffness matri x.
I ndeed, si nce (U
(n)
) = KU
(n)
- F, putti ng J
n
= K yi el ds
I n many cases the conver gence r ate i s sl ow, but the cost of each i terati on i s
cheap.
U

J
n
U
n ( )
( )
U
---------------------- =
1

--- U (
n ( )

i
) U
n ( )
( ) + ( )
U
n 1 + ( )
U
n ( )
= J
n
1
U
n ( )
( ) U
n ( )
= K
1
KU
n ( )
( F) K
1
F. =
4 The Fi ni te Element M ethod
4-24
The nonl i near sol ver i mpl emented i n the PDE Tool box al so provi des for a
compr omi se between the two extr emes. To compute the der i vati ve of the
mappi ng , proceed as fol l ows. The a ter m has been omi tted for cl ar i ty,
but appear s agai n i n the fi nal r esul t bel ow.
The fi rst i ntegr al term i s nothi ng more than K
i,j
.
The second ter m i s l umped, i .e., repl aced by a di agonal matri x that contai ns
the r ow sums. Si nce

j
= 1, the second term i s approxi mated by
whi ch i s the i
th
component of K
(c' )
U, wher e K
(c' )
i s the sti ffness matri x
associ ated wi th the coeffi ci ent r ather than c. The same reasoni ng can be
appl i ed to the deri vati ve of the mappi ng . Fi nal l y note that the
deri vati ve of the mappi ng i s exactl y
whi ch i s the mass matr i x associ ated wi th the coeffi ci ent . Thus the Jacobi an
of the r esi dual (U)i s approxi mated by:
where the di ffer enti ati on i s wi th r espect to u. K and M desi gnate sti ffness and
mass matri ces and thei r i ndi ces desi gnate the coeffi ci ents wi th respect to
whi ch they ar e assembl ed. At each Gauss-Newton i terati on, the nonl i near
sol ver assembl es the matri ces corr espondi ng to the equati ons
U KU
KU ( )
i
U
j
------------------
1

---
0
lim c U
j
+ ( )
l

i
dx U
l

l j ,
+ ( )

=
c U ( )
l

i
dxU
l

c U ( )
j

i
dx


j
c
u
------
l

i
dxU
l

+ =

i j ,
c
u
------
l

i
dxU
l

c
u
------
U MU
U F
f
u
------
i

j
dx,

f
u
------
J K
c ( )
M
a f ( )
diag K (
c ( )
M
a ( )
)U + ( ), + + +
N onli near Equati ons
4-25
(cu) + (a - f') u = 0 and - (c'u) + a'u =0
and then pr oduces the appr oxi mate Jacobi an. The di fferenti ati ons of the
coeffi ci ents are done numer i cal l y.
I n the gener al setti ng of el l i pti c systems, the boundary condi ti ons are
appended to the sti ffness matr i x to form the ful l l i near system:
where the coeffi ci ents of and may depend on the sol uti on . The l umped
approach approxi mates the der i vati ve mappi ng of the r esi dual by
The nonl i neari ti es of the boundary condi ti ons and the dependenci es of the
coeffi ci ents on the der i vati ves of are not proper l y l i neari zed by thi s scheme.
When such nonl i neari ti es ar e strong, the scheme reduces to the fi x-poi nt
i ter ati on and may conver ge sl owl y or not at al l . When the boundar y condi ti ons
ar e l i near, they do not affect the convergence properti es of the i terati on
schemes. I n the Neumann case they are i nvi si bl e (H i s an empty matri x) and
i n the Di ri chl et case they mer el y state that the resi dual i s zer o on the
cor respondi ng boundary poi nts.
K

K H
H 0
U

F
R
F

= = =
K

J H
H 0
.
U

4 The Fi ni te Element M ethod


4-26
Adaptive Mesh Refinement
The tool box has a functi on for gl obal , uni for m mesh refi nement. I t di vi des each
tr i angl e i nto four si mi l ar tri angl es by creati ng new corner s at the mi dsi des,
adjusti ng for cur ved boundar i es. You can assess the accuracy of the numer i cal
sol uti on by compari ng r esul ts fr om a sequence of successi vel y refi ned meshes.
I f the sol uti on i s smooth enough, more accur ate resul ts may be obtai ned by
extrapol ati on.
The sol uti ons of the tool box equati on often have geometri c featur es l i ke
l ocal i zed strong gradi ents. An exampl e of engi neeri ng i mportance i n el asti ci ty
i s the stress concentrati on occur ri ng at re-entr ant corner s such as the MATLAB
favor i te, the L-shaped membrane. Then i t i s more economi cal to r efi ne the
mesh sel ecti vel y, i .e., onl y wher e i t i s needed. When the sel ecti on i s based on
esti mates of er ror s i n the computed sol uti ons, a posteri or i esti mates, we speak
of adaptive mesh refinement. See the Reference entry on adapt me s h for an
exampl e of the computati onal savi ngs where gl obal r efi nement needs mor e
than 6000 el ements to compete wi th an adapti vel y r efi ned mesh of 500
el ements.
The adapti ve refi nement gener ates a sequence of sol uti ons on successi vel y
fi ner meshes, at each stage sel ecti ng and r efi ni ng those el ements that are
judged to contr i bute most to the er ror . The pr ocess i s termi nated when the
maxi mum number of el ements i s exceeded or when each tri angl e contr i butes
l ess than a preset tol erance. You need to provi de an i ni ti al mesh, and choose
sel ecti on and termi nati on cri ter i a parameter s. The i ni ti al mesh can be
pr oduced by the i ni t mes h functi on. The thr ee components of the al gori thm are
the err or i ndi cator functi on, whi ch computes an esti mate of the el ement error
contr i buti on, the mesh refi ner , whi ch sel ects and subdi vi des el ements, and the
ter mi nati on cr i teri a.
The Error Indicator Function
The adapti on i s a feedback pr ocess. As such, i t i s easi l y appl i ed to a l arger
r ange of pr obl ems than those for whi ch i ts desi gn was tai l or ed. You want
esti mates, sel ecti on cri ter i a, etc., to be opti mal i n the sense of gi vi ng the most
accurate sol uti on at fi xed cost or l owest computati onal effort for a gi ven
accuracy. Such resul ts have been proved onl y for model pr obl ems, but
general l y, the equi di str i buti on heuri sti c has been found near opti mal . El ement
si zes shoul d be chosen such that each el ement contr i butes the same to the
err or. The theor y of adapti ve schemes makes use of a pri ori bounds for
Adapti ve M esh Refi nement
4-27
sol uti ons i n ter ms of the sour ce functi on f. For nonel l i pti c probl ems such a
bound may not exi st, whi l e the refi nement scheme i s sti l l wel l defi ned and has
been found to work wel l .
The er ror i ndi cator functi on used i n the tool box i s an el ement-wi se esti mate of
the contri buti on, based on the work of C. Johnson et al . [5], [6]. For Poi sson's
equati on u = f on , the fol l owi ng er ror esti mate for the FEM-sol uti on u
h

hol ds i n the L
2
-norm | | | | :
| | (u - u
h
) | | | | hf | | + D
h
(u
h
),
where h = h(x) i s the l ocal mesh si ze, and
The braced quanti ty i s the jump i n nor mal deri vati ve of v across edge , h
r
i s
the l ength of edge , and the sum runs over E
i
, the set of al l i nteri or edges of
the tr i angul ati on. The coeffi ci ents and ar e i ndependent of the
tr i angul ati on. Thi s bound i s tur ned i nto an el ement-wi se er ror i ndi cator
functi on E(K) for el ement K by summi ng the contri buti ons fr om i ts edges. The
fi nal form for the tool box equati on
(cu) + au = f
becomes
where n

i s the uni t nor mal of edge and the braced term i s the jump i n fl ux
across the el ement edge. The L
2
norm i s computed over the el ement K. Thi s
err or i ndi cator i s computed by the pde j mps functi on.
The Mesh Refiner
The PDE Tool box i s gear ed to el l i pti c probl ems. For r easons of accur acy and
i l l -condi ti oni ng, they requi re the el ements not to devi ate too much from bei ng
equi l ateral . Thus, even at essenti al l y one-di mensi onal sol uti on features, such
as boundary l ayers, the refi nement techni que must guar antee reasonabl y
shaped tr i angl es.
D
h
v ( ) h

2
v n

[ ]
2
E
1



1 2
. =
E K ( ) h f ( au )
K
=
1
2
--- h

2
n
r
c u
h
[ ]
2
K



1 2
, +
4 The Fi ni te Element M ethod
4-28
When an el ement i s r efi ned, new nodes appear on i ts mi dsi des, and i f the
nei ghbor tri angl e i s not refi ned i n a si mi l ar way, i t i s sai d to have hanging
nodes. The fi nal tr i angul ati on must have no hangi ng nodes, and they ar e
r emoved by spl i tti ng nei ghbor tri angl es. To avoi d fur ther deteri or ati on of
tr i angl e qual i ty i n successi ve gener ati ons, the l ongest edge bi secti on scheme
Rosenberg-Stenger [8] i s used, i n whi ch the l ongest si de of a tr i angl e i s al ways
spl i t, whenever any of the si des have hangi ng nodes. Thi s guarantees that no
angl e i s ever smal l er than hal f the smal l est angl e of the or i gi nal tri angul ati on.
Two sel ecti on cr i teri a can be used. One, pde adwor s t , refi nes al l el ements wi th
val ue of the err or i ndi cator l ar ger than hal f the wor st of any el ement. The
other , pde adgs c, refi nes al l el ements wi th an i ndi cator val ue exceedi ng a
user-defi ned di mensi onl ess tol erance. The compar i son wi th the tol erance i s
pr oper l y scal ed wi th respect to domai n and sol uti on si ze, etc.
The Termination Criteria
For smooth sol uti ons, er ror equi di str i buti on can be achi eved by the pdeadgs c
sel ecti on i f the maxi mum number of el ements i s l ar ge enough. The pdeadwor s t
adapti on onl y termi nates when the maxi mum number of el ements has been
exceeded. Thi s mode i s natural when the sol uti on exhi bi ts si ngul ari ti es. The
err or i ndi cator of the el ements next to the si ngul ari ty may never vani sh,
r egardl ess of el ement si ze, and equi di str i buti on i s too much to hope for.
Fast Soluti on of Poi sson sEquati on
4-29
Fast Solution of Poissons Equation
Whi l e the gener al str ategy of the PDE Tool box i s to use MATLABs bui l t-i n
sol ver s for sparse systems, there are si tuati ons wher e faster sol uti on
al gor i thms are avai l abl e. One such exampl e i s when sol vi ng Poi ssons equati on
-u = f i n
wi th Di r i chl et boundar y condi ti ons, wher e i s a r ectangl e.
For the fast sol uti on al gori thms to wor k, the mesh on the r ectangl e must be a
regular mesh. I n thi s context i t means that the fi r st si de of the r ectangl e i s
di vi ded i nto N
1
segments of l ength h
1
, the second i nto N
2
segments of l ength
h
2
, and (N
1
+ 1)-by-(N
2
+ 1) poi nts ar e i ntroduced on the r egul ar gr i d thus
defi ned. The tri angl es ar e al l congr uent wi th si des h
1
, h
2
and a ri ght angl e i n
between.
The Di r i chl et boundar y condi ti ons ar e el i mi nated i n the usual way, and the
resul ti ng probl em for the i nter i or nodes i s Kv = F. I f the i nter i or nodes are
numbered from l eft to r i ght, and then from bottom to top, the K matr i x i s bl ock
tr i di agonal . The N
2
- 1 di agonal bl ocks, here cal l ed T, ar e themsel ves
tr i di agonal (N
1
- 1)-by-(N
1
- 1) matri ces, wi th 2(h
1
/h
2
+ h
2
/h
1
) on the di agonal
and -h
2
/h
1
on the subdi agonal s. The subdi agonal bl ocks, her e cal l ed I , are -h
1
/
h
2
ti mes the uni t N
1
- 1 matri x.
The key to the sol uti on of the probl em Kv =F i s that the pr obl em Tw =f i s
possi bl e to sol ve usi ng the discrete sine transform. Let S be the (N
1
- 1)-by-
(N
1
- 1) matr i x wi th S
i j
= si n(ij/N
1
). Then S
-1
TS =, where i s a di agonal
matr i x wi th di agonal entri es 2(h
1
/h
2
+ h
2
/h
1
) - 2h
2
/h
1
cos(i/N
1
). w = S
-1
S
-1
f,
but mul ti pl yi ng wi th S i s nothi ng mor e than taki ng the di scr ete si ne transform,
and mul ti pl yi ng wi th S
-1
i s the same as taki ng the i nverse di screte si ne
tr ansfor m. The di scr ete si ne transform can be effi ci entl y cal cul ated usi ng the
fast Fouri er transform on a sequence of l ength 2N
1
.
4 The Fi ni te Element M ethod
4-30
Sol vi ng Tw = f usi ng the di screte si ne transfor m woul d not be an advantage i n
i tsel f, si nce the system i s tr i di agonal and shoul d be sol ved as such. However ,
for the ful l system Kv =F, a tr ansfor mati on of the bl ocks i n K turns i t i nto
N
1
- 1 decoupl ed tri di agonal systems of si ze N
2
- 1. Thus, a sol uti on al gori thm
woul d l ook l i ke
1 Di vi de F i nto N
2
- 1 bl ocks of l ength N
1
- 1, and perfor m an i nver se di screte
si ne transform on each bl ock.
2 Reor der the el ements and sol ve N
1
- 1 tr i di agonal systems of si ze N
2
- 1, wi th
2(h
1
/h
2
+ h
2
/h
1
) - 2h
2
/h
1
cos(i/N
1
) on the di agonal , and -h
1
/h
2
on the
subdi agonal s.
3 Reverse the reorder i ng, and per form N
2
- 1 di screte si ne tr ansfor ms on the
bl ocks of l ength N
1
- 1.
When usi ng a fast sol ver such as thi s one, ti me and memor y ar e al so saved
si nce the matri x K i n fact never has to be assembl ed. A dr awback i s that si nce
the mesh has to be regul ar , i t i s i mpossi bl e to do adapti ve mesh r efi nement.
The fast el l i pti c sol ver for Poi ssons equati on i s i mpl emented i n poi s ol v . The
di screte si ne tr ansfor m and the i nver se di scr ete si ne transform are computed
by ds t and i ds t , respecti vel y.

5
Reference
Commands Grouped by Function . . . . . . . . . . . . . . . . . . . . . 5-3
PDE Al gor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
User I nterface Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Geometr y Al gor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Pl ot Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Uti l i ty Al gor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
User Defi ned Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
5 Reference
5-2
Thi s chapter contai ns detai l ed descr i pti ons of most of the functi ons i n the Parti al Di ffer enti al
Equati on (PDE) Tool box. Some of the functi ons that ar e used by the graphi cal user i nter face (GUI )
functi on pde t ool ar e not l i sted i n thi s chapter because they are not supposed to be used
di r ectl y they ar e cal l ed fr om pde t ool .
C ommands G rouped by Functi on
5-3
Commands Grouped by Function
PDE Algorithms
User Interface Algorithms
Function Purpose
adapt me s h Adapti ve mesh gener ati on and PDE sol uti on.
as s e ma Assembl e ar ea i ntegr al contr i buti ons.
as s e mb Assembl e boundary condi ti on contr i buti ons
as s e mpde Assembl e the sti ffness matr i x and ri ght-hand si de of a
PDE pr obl em.
hy pe r bol i c Sol ve hyper bol i c PDE probl em.
par abol i c Sol ve parabol i c PDE pr obl em.
pdee i g Sol ve ei genval ue PDE pr obl em.
pdenonl i n Sol ve nonl i near PDE probl em.
poi s ol v Fast sol uti on of Poi ssons equati on on a rectangul ar
gr i d.
Function Purpose
pde ci r c Draw ci rcl e.
pde el l i p Draw el l i pse.
pde mdl cv Convert PDE Tool box 1.0 Model M-fi l es
pde pol y Draw pol ygon.
pde r e c t Draw rectangl e.
pde t ool PDE Tool box graphi cal user i nter face (GUI ).
5 Reference
5-4
Geometry Algorithms
Plot Functions
Function Purpose
c s gchk Check val i di ty of Geometr y Descri pti on Matri x.
c s gde l Del ete border s between mi ni mal r egi ons.
dec s g Decompose Constructi ve Sol i d Geometr y i nto
mi ni mal regi ons.
i ni t mes h Cr eate i ni ti al tr i angul ar mesh.
j i ggl emes h Ji ggl e i nter nal poi nts of a tri angul ar mesh.
pde ar cl I nter pol ati on between parametri c representati on and
ar c l ength.
poi me s h Make regul ar mesh on a rectangul ar geometry.
r ef i nemes h Refi ne a tri angul ar mesh.
wbound Wri te boundar y condi ti on speci fi cati on fi l e.
wge om Wri te geometr y speci fi cati on functi on.
Function Purpose
pde cont Shorthand command for contour pl ot.
pde gpl ot Pl ot a PDE geometr y.
pde me s h Pl ot a PDE tr i angul ar mesh.
pde pl ot Generi c PDE Tool box pl ot functi on.
pde s ur f Shorthand command for surface pl ot.
C ommands G rouped by Functi on
5-5
Utility Algorithms
Function Purpose
ds t Di screte si ne transfor m.
i ds t I nverse di screte si ne tr ansfor m.
pde adgs c Sel ect tri angl es usi ng a r el ati ve tol erance cr i teri on.
pde adwor s t Sel ect tri angl es r el ati ve to the worst val ue.
pde cgr ad The fl ux of a PDE sol uti on.
pde ent I ndi ces of tr i angl es nei ghbori ng a gi ven set of
tri angl es.
pde gr ad The gr adi ent of a PDE sol uti on.
pde i nt r p I nterpol ate from node data to tri angl e mi dpoi nt data.
pde j mps Er ror esti mates for adapti on.
pde pr t ni I nterpol ate from tri angl e mi dpoi nt data to node data.
pde s de I ndi ces of edges i n a set of subdomai ns.
pde s dp I ndi ces of poi nts i n a set of subdomai ns.
pde s dt I ndi ces of tr i angl es i n a set of subdomai ns.
pde s me ch Cal cul ate structur al mechani cs tensor functi ons.
pde t r g Tr i angl e geometr y data.
5 Reference
5-6
pde t r i q Tri angl e qual i ty measure.
poi as ma Boundary poi nt matri x contr i buti ons for fast sol ver s
of Poi ssons equati on.
poi cal c Fast sol ver for Poi ssons equati on on a
r ectangul ar gr i d.
poi i nde x I ndi ces of poi nts i n canoni cal or der i ng for
r ectangul ar gr i d.
s pt ar n Sol ve general i zed spar se ei genval ue pr obl em.
t r i 2gr i d I nterpol ate from PDE tr i angul ar mesh to
r ectangul ar gr i d.
Function Purpose
C ommands G rouped by Functi on
5-7
User Defined Algorithms
Demonstration Programs
Function Purpose
pde bound Boundary M-fi l e.
pde ge om Geometr y M-fi l e.
Function Purpose
pde de mo1 Exact sol uti on of Poi ssons equati on on uni t di sk.
pde de mo2 Sol ve Hel mhol tzs equati on and study the r efl ected
waves.
pde de mo3 Sol ve a mi ni mal sur face pr obl em.
pde de mo4 Sol ve PDE probl em usi ng subdomai n decomposi ti on.
pde de mo5 Sol ve a parabol i c PDE (the heat equati on).
pde de mo6 Sol ve a hyper bol i c PDE (the wave equati on).
pde de mo7 Adapti ve sol uti on wi th poi nt sour ce.
pde de mo8 Sol ve Poi ssons equati on on rectangul ar gr i d.
adaptmesh
5-8
adaptmesh
Purpose Adapti ve mesh generati on and PDE sol uti on.
Synopsis [ u, p, e, t ] =adapt mes h( g, b, c , a, f )
[ u, p, e, t ] =adapt mes h( g, b, c , a, f , ' Pr ope r t yName' , Pr oper t y Val ue , )
Description [ u, p, e, t ] =adapt mes h( g, b, c , a, f , ' Pr ope r t yName' , Pr oper t y Val ue , )
performs adapti ve mesh generati on and PDE sol uti on. Opti onal arguments ar e
gi ven as property name/pr oper ty val ue pai r s.
The functi on produces a sol uti on u to the el l i pti c scal ar PDE pr obl em
(cu) + au =f on ,
or the el l i pti c system PDE probl em
(c u) + au =f on
wi th the probl em geometry and boundar y condi ti ons gi ven by g and b. The
mesh i s descri bed by the p, e , and t .
The sol uti on u i s r epresented as the sol uti on vector u. Detai l s on the
repr esentati on of the sol uti on vector can be found i n the entr y on as s e mpde.
The al gor i thm wor ks by sol vi ng a sequence of PDE probl ems usi ng r efi ned
tr i angul ar meshes. The fi rst tri angul ar mesh generati on i s obtai ned ei ther as
an opti onal ar gument to adapt mes h or by a cal l to i ni t me s h wi thout opti ons.
The fol l owi ng generati ons of tr i angul ar meshes ar e obtai ned by sol vi ng the
PDE probl em, computi ng an err or esti mate, sel ecti ng a set of tri angl es based
on the er ror esti mate, and then fi nal l y r efi ni ng these tr i angl es. The sol uti on to
the PDE pr obl em i s then recomputed. The l oop conti nues unti l no tr i angl es ar e
sel ected by the tr i angl e sel ecti on method, or unti l the maxi mum number of
tr i angl es i s attai ned, or unti l the maxi mum number of tri angl e generati ons has
been gener ated.
g descr i bes the decomposed geometr y of the PDE probl em. g can ei ther be a
Decomposed Geometry matri x or the name of a Geometr y M-fi l e. The for mats
of the Decomposed Geometry matr i x and Geometr y M-fi l e ar e descr i bed i n the
entr i es on de cs g and pde ge om, respecti vel y.
b descr i bes the boundary condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condi ti on matr i x or the name of a Boundar y M-fi l e. The for mats of
the Boundary Condi ti on matr i x and Boundary M-fi l e are descr i bed i n the
entr i es on as s e mb and pdebound, respecti vel y.
adaptmesh
5-9
The adapted tr i angul ar mesh of the PDE pr obl em i s gi ven by the mesh data p,
e, and t . Detai l s on the mesh data r epr esentati on can be found i n the entry on
i ni t mes h.
The coeffi ci ents c , a, and f of the PDE pr obl em can be gi ven i n a wi de var i ety
of ways. I n the context of adapt me s h the coeffi ci ents can depend on u i f the
nonl i near sol ver i s enabl ed usi ng the pr oper ty nonl i n. The coeffi ci ents cannot
depend on t , the ti me. A compl ete l i sti ng of al l opti ons can be found i n the entr y
on as s e mpde.
The tabl e bel ow l i sts the property name/property val ue pai rs, thei r defaul t
val ues, and descri pti ons of the proper ti es.
Par i s passed to the Tr i pi c k functi on. (The Tr i pi c k functi on i s descri bed
bel ow.) Normal l y i t i s used as tol erance of how wel l the sol uti on fi ts the
equati on.
Property Property Default Description
Max t posi ti ve i nteger i nf Maxi mum number of new
tr i angl es
Nge n posi ti ve i nteger 10 Maxi mum number of tri angl e
generati ons
Mes h p1, e1, t 1 i ni t me s h I ni ti al mesh
Tr i pi ck MATLAB functi on pdeadwor s t Tri angl e sel ecti on method
Par numer i c 0. 5 Functi on parameter
Rme t hod l onges t | r e gul ar l onges t Tri angl e refi nement method
Nonl i n on| of f of f Use nonl i near sol ver
Tol n numer i c 1e 4 Nonl i near tol er ance
I ni t u0 0 Nonl i near i ni ti al val ue
Jac f i xe d| l umpe d| f ul l f i xe d Nonl i near Jacobi an
cal cul ati on
nor m numer i c| i nf | e ne r gy i nf Nonl i near r esi dual nor m
adaptmesh
5-10
No mor e than Ngen successi ve refi nements are attempted. Refi nement i s al so
stopped when the number of tri angl es i n the mesh exceeds Max t .
p1, e 1, and t 1 ar e the i nput mesh data. Thi s tri angul ar mesh i s used as star ti ng
mesh for the adapti ve al gori thm. Detai l s on the mesh data representati on can
be found i n the entr y on i ni t me s h. I f no i ni ti al mesh i s pr ovi ded, the resul t of
a cal l to i ni t me s h wi th no opti ons i s used as i ni ti al mesh.
The tri angl e sel ecti on method, Tr i pi ck, i s a user -defi nabl e tri angl e sel ecti on
method. Gi ven the err or esti mate computed by the functi on pdej mps , the
tr i angl e sel ecti on method sel ects the tr i angl es to be r efi ned i n the next tri angl e
gener ati on. The functi on i s cal l ed usi ng the arguments p, t , c c, aa, f f , u, e r r f ,
and par . p and t r epr esent the curr ent gener ati on of tri angl es, cc , aa, and f f
ar e the curr ent coeffi ci ents for the PDE pr obl em, expanded to tri angl e
mi dpoi nts, u i s the curr ent sol uti on, e r r f i s the computed error esti mate, and
par , the functi on par ameter, gi ven to adapt me s h as opti onal argument. The
matr i ces c c, aa, f f , and er r f al l have N
t
col umns, where N
t
i s the curr ent
number of tri angl es. The number of rows i n c c, aa, and f f are exactl y the same
as the i nput arguments c, a, and f . er r f has one row for each equati on i n the
system. Ther e ar e two standar d tr i angl e sel ecti on methods i n the tool box
pde adwor s t and pde adgs c . pde adwor s t sel ects tri angl es wher e e r r f exceeds a
fracti on (defaul t: 0.5) of the the worst val ue, and pde adgs c sel ects tri angl es
usi ng a rel ati ve tol erance cr i teri on.
The r efi nement method i s ei ther l onge s t or r egul ar . Detai l s on the refi nement
method can be found i n the entry on r ef i nemes h.
The adapti ve al gori thm can al so sol ve nonl i near PDE pr obl ems. For nonl i near
PDE probl ems, the Nonl i n parameter must be set to on. The nonl i near
tol erance Tol n, nonl i near i ni ti al val ue u0, nonl i near Jacobi an cal cul ati on Jac,
and nonl i near r esi dual norm Nor m are passed to the nonl i near sol ver
pde nonl i n. See the entry on pde nonl i n for detai l s on the nonl i near sol ver .
adaptmesh
5-11
Examples Sol ve the Lapl ace equati on over a ci r cl e sector , wi th Di r i chl et boundar y
condi ti ons u = cos(2/3atan2(y,x)) al ong the ar c, and u = 0 al ong the str ai ght
l i nes, and compar e to the exact sol uti on. We r efi ne the tr i angl es usi ng the
wor st er ror cri ter i on unti l we obtai n a mesh wi th at l east 500 tr i angl es:
[ u, p, e , t ] =adapt me s h( ' c i r s g' , ' c i r s b' , 1, 0, 0, ' max t ' , 500, . . .
' t r i pi ck' , ' pdeadwor s t ' , ' ngen' , i nf ) ;
x =p( 1, : ) ; y=p( 2, : ) ;
e xact =( ( x . ^2+y . ^2) . ( 1/3) . *c os ( 2/3*at an2( y, x) ) ) ' ;
max ( abs ( uex ac t ) )
ans =
0. 0058
s i z e( t , 2)
ans =
534
pde me s h( p, e, t )
adaptmesh
5-12
The maxi mum absol ute er ror i s 0.0058, wi th 534 tr i angl es. We test how many
refi nements we have to use wi th an uni for m tri angl e net:
[ p, e, t ] =i ni t me s h( ' ci r s g' ) ;
[ p, e, t ] =r e f i ne me s h( ' c i r s g' , p, e, t ) ;
u=as s empde ( ' ci r s b' , p, e, t , 1, 0, 0) ;
x =p( 1, : ) ; y=p( 2, : ) ;
e xact =( ( x. ^2+y . ^2) . ^( 1/3) . *cos ( 2/3*at an2( y , x) ) ) ' ;
max ( abs ( uex ac t ) )
ans =
0. 0085
s i z e( t , 2)
ans =
1640
[ p, e, t ] =r e f i ne me s h( ' c i r s g' , p, e, t ) ;
u=as s empde ( ' ci r s b' , p, e, t , 1, 0, 0) ;
x =p( 1, : ) ; y=p( 2, : ) ;
e xact =( ( x. ^2+y . ^2) . ^( 1/3) . *cos ( 2/3*at an2( y , x) ) ) ' ;
max ( abs ( uex ac t ) )
ans =
0. 0054
s i z e( t , 2)
ans =
6560
pde me s h( p, e, t )
Thus, wi th uni form refi nement, we need 6560 tri angl es to achi eve better
absol ute er ror than what we achi eved wi th the adapti ve method. Note that the
err or i s r educed onl y by 0.6 when the number of el ements i n quadr upl ed by the
uni form refi nement. For a pr obl em wi th r egul ar sol uti on, we expect a O(h
2
)
err or, but thi s sol uti on i s si ngul ar si nce u r
1/3
at the or i gi n.
Diagnostics Upon termi nati on, one of the fol l owi ng messages i s di spl ayed:
Adapt i on compl e t e d (Thi s means that the Tr i pi ck functi on returned zero
tri angl es to refi ne.)
Maxi mum numbe r of t r i angl e s obt ai ne d
Maxi mum numbe r of r e f i ne me nt pas s es obt ai ned
See Also i ni t mes h, r e f i ne me s h, as s empde, pdeadgs c , pde adwor s t , pdej mps
assema
5-13
assema
Purpose Assembl e ar ea i ntegr al contr i buti ons.
Synopsis [ K, M, F] =as s ema( p, t , c , a, f )
[ K, M, F] =as s ema( p, t , c , a, f , u0)
[ K, M, F] =as s ema( p, t , c , a, f , u0, t i me)
[ K, M, F] =as s ema( p, t , c , a, f , u0, t i me, s dl )
[ K, M, F] =as s ema( p, t , c , a, f , t i me )
[ K, M, F] =as s ema( p, t , c , a, f , t i me , s dl )
Description [ K, M, F] =as s ema( p, t , c , a, f ) assembl es the sti ffness matr i x K, the mass
matr i x M, and the ri ght-hand si de vector F.
The i nput parameter s p, t , c, a, f , u0, t i me, and s dl have the same meani ng as
i n as s empde.
See Also as s empde
assemb
5-14
assemb
Purpose Assembl e boundar y condi ti on contr i buti ons.
Synopsis [ Q, G, H, R] =as s e mb( b, p, e )
[ Q, G, H, R] =as s e mb( b, p, e , u0)
[ Q, G, H, R] =as s e mb( b, p, e , u0, t i me)
[ Q, G, H, R] =as s e mb( b, p, e , u0, t i me, s dl )
[ Q, G, H, R] =as s e mb( b, p, e , t i me )
[ Q, G, H, R] =as s e mb( b, p, e , t i me , s dl )
Description [ Q, G, H, R] =as s e mb( b, p, e ) assembl es the matri ces Q and H, and the vector s G
and R. Q shoul d be added to the system matr i x and contai ns contr i buti ons from
mi xed boundary condi ti ons. G shoul d be added to the r i ght-hand si de and
contai ns contr i buti ons from gener al i zed Neumann and mi xed boundar y
condi ti ons. The equati on H*u=R r epresents the Di r i chl et type boundar y
condi ti ons.
The i nput par ameters p, e, u0, t i me , and s dl have the same meani ng as i n
as s empde.
b descr i bes the boundary condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condition matrix or the name of a Boundar y M-fi l e. The for mat of
the Boundary Condi ti on matr i x i s descr i bed bel ow, and the format of the
Boundary M-fi l e i s descr i bed i n the entr y on pde bound.
The tool box treats the fol l owi ng boundary condi ti on types:
On a gener al i zed Neumann boundar y segment, q and g are rel ated to the
normal der i vati ve val ue by
(cu) + qu =g.
On a Di r i chl et boundary segment, hu = r.
The tool box can al so handl e systems of parti al di fferenti al equati ons over the
domai n . Let the number of var i abl es i n the system be N. Our general
boundary condi ti on i s
hu = r
(c u) + + h.
By the notati on (c u) we mean the N-by-1 matr i x wi th (i,1)-component
n
n qu g =
n
assemb
5-15
where i s the angl e of the nor mal vector of the boundary, poi nti ng i n the
di recti on out from , the domai n.
The Boundar y Condi ti on matri x i s created i nter nal l y i n pdet ool (actual l y a
functi on cal l ed by pdet ool ) and then used fr om the functi on as s e mb for
assembl i ng the contr i buti ons fr om the boundary to the matri ces Q, G, H, and R.
The Boundar y Condi ti on matri x can al so be saved onto a fi l e as a boundar y
M-fi l e for l ater use wi th the wbound functi on.
For each col umn i n the Decomposed Geometr y matri x there must be a
cor respondi ng col umn i n the Boundary Condi ti on matr i x. The format of each
col umn i s accordi ng to the l i st bel ow:
Row one contai ns the di mensi on N of the system.
Row two contai ns the number M of Di ri chl et boundar y condi ti ons.
Row three to 3 + N
2
- 1 contai n the l engths for the stri ngs r epresenti ng .The
l engths ar e stor ed i n col umn-wi se order wi th respect to .
Row 3 + N
2
to 3 + N
2
+N- 1 contai n the l engths for the stri ngs repr esenti ng g.
Row 3 + N
2
+ N to 3 + N
2
+ N +MN - 1 contai n the l engths for the stri ngs
repr esenti ng h. The l engths ar e stor ed i n col umn-wi se order wi th respect to h.
Row 3 + N
2
+ N +NM to 3 + N
2
+ N +MN + M - 1 contai n the l engths for the
str i ngs representi ng r.
The fol l owi ng r ows contai n MATLAB text expr essi ons r epresenti ng the actual
boundary condi ti on functi ons. The text stri ngs have the l engths accordi ng to
above. The MATLAB text expr essi ons ar e stored i n col umn-wi se order wi th
respect to matr i ces h and . There are no separati on char acters between the
( ) cos c
i j 1 1 , , ,

x
----- ( ) cos c
i j 1 2 , , ,

y
----- ( ) sin c
i j 2 1 , , ,

x
----- ( ) sin c
i j 2 2 , , ,

y
----- + + +


u
j
,
1 =
N

q
q
q
assemb
5-16
str i ngs. You can i nsert MATLAB expr essi ons contai ni ng the fol l owi ng
var i abl es:
The 2-D coor di nates x and y
A boundar y segment par ameter s , pr opor ti onal to ar c l ength. s i s 0 at the
star t of the boundary segment and i ncreases to 1 al ong the boundar y
segment i n the di r ecti on i ndi cated by the ar row.
The outwar d normal vector components nx and ny. I f you need the tangenti al
vector , i t can be expr essed usi ng nx and ny si nce t
x
=-n
y
and t
y
=n
x
.
The sol uti on u (onl y i f the i nput argument u has been speci fi ed)
The ti me t (onl y i f the i nput argument t i me has been speci fi ed)
Examples The fol l owi ng exampl es descr i be the format of the boundary condi ti on matr i x.
For a boundar y i n a scal ar PDE (N = 1) wi th Neumann boundary condi ti on
(M = 0)
(cu) = -x
2
,
the boundary condi ti on woul d be r epr esented by the col umn vector
[ 1 0 1 5 ' 0' ' x . ^2' ] '
Note that no l engths ar e stor ed for h or r.
Al so for a scal ar PDE, the Di ri chl et boundary condi ti on
u = x
2
-y
2

i s stor ed i n the col umn vector
[ 1 1 1 1 1 9 ' 0' ' 0' ' 1' ' x . ^2y. ^2' ] '
For a system (N = 2) wi th mi xed boundar y condi ti ons (M = 1)
n
n c u ( )
q
11
q
12
q
21
q
22



u +
g
1
g
2



s + =
h
11
h
12
( )u r
1
=
.
assemb
5-17
the col umn l ooks l i ke
2
1
l q11
l q21
l q12
l q22
l g1
l g2
l h11
l h12
l r 1
q11 . . .
q21 . . .
q12 . . .
q22 . . .
g1 . . .
g2 . . .
h11 . . .
h12 . . .
r 1 . . .
Where l q11, l q21, . . . denote l engths of the MATLAB text expr essi ons, and q11,
q21, . . . denote the actual expressi ons.
You can easi l y create your own exampl es by tr yi ng out pdet ool . Enter
boundary condi ti ons by doubl e-cl i cki ng on boundari es i n boundar y mode, and
then expor t the Boundar y Condi ti on matr i x to the MATLAB mai n workspace by
sel ecti ng the Export Decomposed Geometry, Boundary Conds . . . opti on
from the Boundary menu.
See Also as s empde, pde bound
assempde
5-18
assempde
Purpose Assembl e the sti ffness matr i x and ri ght-hand si de of a PDE pr obl em.
Synopsis u=as s empde( b, p, e , t , c , a, f )
u=as s empde( b, p, e , t , c , a, f , u0)
u=as s empde( b, p, e , t , c , a, f , u0, t i me)
u=as s empde( b, p, e , t , c , a, f , t i me )
[ K, F] =as s empde ( b, p, e , t , c , a, f )
[ K, F] =as s empde ( b, p, e , t , c , a, f , u0)
[ K, F] =as s empde ( b, p, e , t , c , a, f , u0, t i me )
[ K, F] =as s empde ( b, p, e , t , c , a, f , u0, t i me , s dl )
[ K, F] =as s empde ( b, p, e , t , c , a, f , t i me )
[ K, F] =as s empde ( b, p, e , t , c , a, f , t i me , s dl )
[ K, F, B, ud] =as s empde( b, p, e , t , c , a, f )
[ K, F, B, ud] =as s empde( b, p, e , t , c , a, f , u0)
[ K, F, B, ud] =as s empde( b, p, e , t , c , a, f , u0, t i me)
[ K, F, B, ud] =as s empde( b, p, e , t , c , a, f , t i me )
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f )
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f , u0)
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f , u0, t i me )
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f , u0, t i me , s dl )
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f , t i me)
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f , t i me, s dl )
u=as s empde( K, M, F, Q, G, H, R)
[ K1, F1] =as s empde ( K, M, F, Q, G, H, R)
[ K1, F1, B, ud] =as s empde( K, M, F, Q, G, H, R)
Description as s empde i s the basi c functi on of the PDE Tool box. I t assembl es a PDE probl em
by usi ng the FEM formul ati on descri bed i n Chapter 4, "The Fi ni te El ement
Method". The command as s empde assembl es the scal ar PDE pr obl em
(cu) + au = f on ,
or the system PDE pr obl em
(c u) + au = f on .
The command can opti onal l y pr oduce a sol uti on to the PDE probl em.
assempde
5-19
For the scal ar case the solution vector u i s r epresented as a col umn vector of
sol uti on val ues at the corr espondi ng node poi nts fr om p. For a system of
di mensi on N wi th n
p
node poi nts, the fi r st n
p
val ues of u descri be the fi rst
component of u, the fol l owi ng n
p
val ues of u descri be the second component of
u, and so on. Thus, the components of u ar e pl aced i n the vector u as N bl ocks
of node poi nt val ues.
u=as s empde( b, p, e , t , c , a, f ) assembl es and sol ves the PDE pr obl em by
el i mi nati ng the Di ri chl et boundar y condi ti ons from the system of l i near
equati ons.
[ K, F] =as s empde( b, p, e , t , c , a, f ) assembl es the PDE pr obl em by
approxi mati ng the Di r i chl et boundar y condi ti on wi th sti ff spr i ngs (see the
secti on The El l i pti c System i n The Finite Element Method chapter for
detai l s). K and F are the sti ffness matr i x and r i ght-hand si de, respecti vel y. The
sol uti on to the FEM formul ati on of the PDE pr obl em i s u=K\F.
[ K, F, B, ud] =as s e mpde( b, p, e, t , c , a, f ) assembl es the PDE probl em by
el i mi nati ng the Di ri chl et boundar y condi ti ons from the system of l i near
equati ons. u1=K\F r etur ns the sol uti on on the non-Di ri chl et poi nts. The
sol uti on to the ful l PDE pr obl em can be obtai ned as the MATLAB expressi on
u=B*u1+ud.
[ K, M, F, Q, G, H, R] =as s e mpde ( b, p, e, t , c, a, f ) gi ves a spl i t representati on of
the PDE probl em.
u=as s empde( K, M, F, Q, G, H, R) col l apses the spl i t repr esentati on i nto the si ngl e
matr i x/vector for m, and then sol ves the PDE probl em by el i mi nati ng the
Di r i chl et boundary condi ti ons fr om the system of l i near equati ons.
[ K1, F1] =as s empde ( K, M, F, Q, G, H, R) col l apses the spl i t repr esentati on i nto the
si ngl e matri x/vector for m, by fi xi ng the Di ri chl et boundary condi ti on wi th l ar ge
spr i ng constants.
[ K1, F1, B, ud] =as s empde( K, M, F, Q, G, H, R) col l apses the spl i t representati on
i nto the si ngl e matr i x/vector for m by el i mi nati ng the Di r i chl et boundary
condi ti ons from the system of l i near equati ons.
assempde
5-20
b descr i bes the boundary condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condi ti on matr i x or the name of a Boundar y M-fi l e. The for mats of
the Boundary Condi ti on matr i x and Boundary M-fi l e are descr i bed i n the
entr i es on as s e mb and pdebound, respecti vel y.
The geometry of the PDE probl em i s gi ven by the mesh data p, e , and t. Detai l s
on the mesh data repr esentati on can be found i n the entry on i ni t mes h.
The opti onal l i st of subdomai n l abel s, s dl , restr i cts the assembl y pr ocess to the
subdomai ns denoted by the l abel s i n the l i st. The opti onal i nput ar guments u0
and t i me are used for the nonl i near sol ver and ti me steppi ng al gor i thms,
respecti vel y. The tentati ve i nput sol uti on vector u0 has the same for mat as u.
PDE Coefficients for Scalar Case
The coeffi ci ents c, a, and f i n the scal ar PDE probl em can be r epr esented i n the
MATLAB var i abl es c , a, and f i n the fol l owi ng ways:
A constant.
A r ow vector of val ues at the tri angl e center s of mass.
A MATLAB text expressi on for computi ng coeffi ci ent val ues at the tr i angl e
center s of mass. The expr essi on i s eval uated i n a context wher e the var i abl es
x, y , s d, u, ux, uy, and t are row vectors r epr esenti ng val ues at the tri angl e
center s of mass (t i s a scal ar ). The row vector s contai n x- and y-coor di nates,
subdomai n l abel , sol uti on, x and y deri vati ves of the sol uti on, and t i me. u, ux ,
and uy can onl y be used i f u0 has been passed to as s e mpde . The same appl i es
to the scal ar t , whi ch i s passed to as s empde as t i me.
A sequence of MATLAB text expressi ons separated by excl amati on mar ks ! .
The syntax of each of the text expressi ons must be accor di ng to the above
i tem. The number of expressi ons i n the sequence must equal the number of
subdomai n l abel s i n the tr i angl e l i st t . (Thi s number can be checked by
typi ng max( t ( 4, : ) ) .)
The name of a user-defi ned MATLAB functi on that accepts the arguments
(p, t , u, t i me ). u and t i me ar e empty matri ces i f the corr espondi ng par ameter
i s not passed to as s e mpde. p and t are mesh data, u i s the u0 i nput ar gument,
and t i s the t i me i nput argument to as s e mpde . I f ti me i s NaN and the functi on
depends on ti me, the functi on must r etur n a matr i x of cor rect si ze,
contai ni ng NaNs i n al l posi ti ons.
assempde
5-21
We r efer to the matr i ces above as Coefficient matrix, and the user -defi ned
MATLAB functi on as Coefficient M-file.
I f c contai ns two rows wi th data accor di ng to any of the above i tems, they are
the c
1,1
, and c
2,2
, el ements of the 2-by-2 di agonal matri x
I f c contai ns four r ows, they are the c
1,1
, c
2,1
, c
1,2
, and c
2,2
el ements of a 2-by-2
matr i x.
PDE Coefficients for System Case
Let N be the di mensi on of the PDE system. Now c i s an N-by-N-by-2-by-2
tensor , a an N-by-N-matr i x, and f a col umn vector of l ength N. The el ements
c
ijkl
, a
ij
, d
ij
, and f
i
of c, a, d, and f ar e stored row-wi se i n the MATLAB matr i ces
c, a, d, and f . Each r ow i n these matri ces i s si mi l ar i n syntax to the scal ar case.
There i s one di ffer ence, however: At the poi nt of eval uati on of MATLAB text
expressi ons, the vari abl es u, ux , and uy contai n matri ces wi th N r ows, one row
for each component. The case of i denti ty, di agonal , and symmetri c matri ces are
handl ed as speci al cases. For the tensor c
ijkl
thi s appl i es both to the i ndi ces i
and j, and to the i ndi ces k and l.
The number of rows i n f determi nes the di mensi on N of the system. Row i i n f
repr esents the component f
i
i n f.
The number of rows n
a
i n a i s r el ated to the components a
ij
of a accordi ng to
the fol l owi ng tabl e. For the symmetri c case assume that j i. Al l el ements a
ij

that cannot be formed are assumed to be zer o:
n
a
Symmetric a
i j
Row in a
1 No a
i i
1
N No a
i i
i
N(N + 1)/2 Yes a
i j
j(j - 1)/2 +i
N
2
No a
i j
N(j - 1) +i
c
1 1 ,
0
0 c
2 2 ,



.
assempde
5-22
An exampl e of how a i s stor ed i n a can be found bel ow.
The codi ng of c i n c i s determi ned by the di mensi on N and the number of rows
n
c
i n c. The number of rows n
c
i n c i s matched to the functi on of N i n the fi rst
col umn i n the tabl e bel ow sequenti al l y from the fi rst l i ne to the l ast l i ne.
The fi rst match determi nes the type of codi ng of c. Thi s actual l y means that for
some smal l val ues, 2 N 4, the codi ng i s onl y deter mi ned by the order i n
whi ch the tests are performed. For the symmetri c case assume that j i,
and l k. Al l el ements c
ijkl
that can not be for med ar e assumed to be zer o:
An exampl e of how c i s stor ed i n c can be found bel ow.
n
c
Symmetric c
i jkl
Row in c
1 No c
i i kk
1
2 No c
i i kk
k
3 Yes c
i i kl
l +k - 1
4 No c
i i kl
2l + k - 2
N No c
i i kk
i
2N No c
i i kk
2i + k - 2
3N Yes c
i i kl
3i + l +k - 4
4N No c
i i kl
4i + 2l +k - 6
2N(2N + 1)/2 Yes c
i i kl
2j
2
+j +l + k - 4
c
i jkl
2j
2
- 3j +4i + 2l +k - 5
4N
2
No c
i jkl
4N(j - 1)+4i +2l +k - 6
assempde
5-23
Examples Example 1
Sol ve the equati on on the geometr y defi ned by the L-shaped
membrane. Use Di r i chl et boundar y condi ti ons u = 0 on . Fi nal l y pl ot the
sol uti on.
[ p, e, t ] =i ni t me s h( ' l s hapeg' , ' Hmax' , 0. 2) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e, t ) ;
u=as s empde ( ' l s hape b' , p, e, t , 1, 0, 1) ;
pde s ur f ( p, t , u)
Example 2
Consi der Poi ssons equati on on the uni t ci r cl e wi th uni t poi nt source at the
ori gi n. The exact sol uti on i s known for thi s probl em. We defi ne
the functi on f =c i r c l e f ( p, t , u, t i me) for computi ng the ri ght-hand si de.
ci r cl ef r etur ns zero for al l tri angl es except for the one l ocated at the ori gi n;
for that tri angl e i t r etur ns 1/a, where a i s the tr i angl e ar ea. pde demo7 performs
a ful l demonstr ati on of the pr obl em wi th adapti ve sol uti on.
u 1 =

u
1
2
------ r ( ) log =
1
0.5
0
0.5
1
1
0.5
0
0.5
1
0
0.2
0.4
0.6
0.8
1
assempde
5-24
Example 3
We study how the matri ces a (and al so d) are stored i n the MATLAB matr i x a
for system case N = 3:
The bul l et symbol () bel ow means that the matr i x i s symmetr i c:
We study how the tensor c i s stored i n the MATLAB matr i x c for the system case
N = 3:
n
a
= 1: a( 1) 0 0 n
a
= 3: a( 1) 0 0
0 a( 1) 0 0 a( 2) 0
0 0 a( 1) 0 0 a( 3)
n
a
= 6: a( 1) a( 2) a( 4) n
a
= 9: a( 1) a( 4) a( 7)
a( 3) a( 5) a( 2) a( 5) a( 8)
a( 6) a( 3) a( 6) a( 9)
n
c
= 1: c( 1) 0 0 0 0 0
0 c ( 1) 0 0 0 0
0 0 c ( 1) 0 0 0
0 0 0 c( 1) 0 0
0 0 0 0 c( 1) 0
0 0 0 0 0 c ( 1)
n
c
= 2: c( 1) 0 0 0 0 0
0 c ( 2) 0 0 0 0
0 0 c ( 1) 0 0 0
0 0 0 c( 2) 0 0
0 0 0 0 c( 1) 0
0 0 0 0 0 c ( 2)
assempde
5-25
The bul l et symbol () bel ow means that the matr i x i s symmetr i c:
The case n
c
= 3 takes pr ecedence over the case n
c
= N, and the for m n
c
= N thus
cannot be used.
n
c
= 3: c ( 1) c( 2) 0 0 0 0
c( 3) 0 0 0 0
0 0 c( 1) c ( 2) 0 0
0 0 c ( 3) 0 0
0 0 0 0 c( 1) c( 2)
0 0 0 0 c( 3)
n
c
= 4: c ( 1) c ( 3) 0 0 0 0
c ( 2) c ( 4) 0 0 0 0
0 0 c( 1) c( 3) 0 0
0 0 c( 2) c( 4) 0 0
0 0 0 0 c ( 1) c ( 3)
0 0 0 0 c ( 2) c ( 4)
n
c
= 6: c ( 1) 0 0 0 0 0
0 c ( 2) 0 0 0 0
0 0 c( 3) 0 0 0
0 0 0 c( 4) 0 0
0 0 0 0 c ( 5) 0
0 0 0 0 0 c ( 6)
assempde
5-26
n
c
= 9: c ( 1) c ( 2) 0 0 0 0
c ( 3) 0 0 0 0
0 0 c( 4) c( 5) 0 0
0 0 c( 6) 0 0
0 0 0 0 c ( 7) c ( 8)
0 0 0 0 c ( 9)
n
c
= 12: c ( 1) c ( 3) 0 0 0 0
c ( 2) c ( 4) 0 0 0 0
0 0 c( 5) c( 7) 0 0
0 0 c( 6) c( 8) 0 0
0 0 0 0 c ( 9) c( 11)
0 0 0 0 c ( 10) c( 12)
n
c
= 21: c ( 1) c ( 2) c( 4) c( 6) c ( 11) c( 13)
c ( 3) c( 5) c( 7) c ( 12) c( 14)
c( 8) c( 9) c ( 15) c( 17)
c ( 10) c ( 16) c( 18)
c ( 19) c( 20)
c( 21)
assempde
5-27
See Also i ni t mes h, r ef i ne me s h, pde bound, as s e ma, as s emb
n
c
= 36: c ( 1) c ( 3) c( 13) c ( 15) c ( 25) c( 27)
c ( 2) c ( 4) c( 14) c ( 16) c ( 26) c( 28)
c ( 5) c ( 7) c( 17) c ( 19) c ( 29) c( 31)
c ( 6) c ( 8) c( 18) c ( 20) c ( 30) c( 32)
c ( 9) c( 11) c( 21) c ( 23) c ( 33) c( 35)
c ( 10) c( 12) c( 22) c ( 24) c ( 34) c( 36)
csgchk
5-28
csgch k
Purpose Check val i di ty of Geometr y Descri pti on matri x.
Synopsis gs t at =c s gchk( gd, xl i m, y l i m)
gs t at =c s gchk( gd)
Description gs t at =c s gchk( gd, xl i m, y l i m) checks i f the sol i d objects i n the Geometry
Descri pti on matri x gd are val i d, gi ven opti onal real number s x l i m and y l i m as
curr ent l ength of the x- and y-axi s, and usi ng a speci al for mat for pol ygons. For
a pol ygon, the l ast ver tex coordi nate can be equal to the fi rst one, to i ndi cate a
cl osed pol ygon. I f x l i m and y l i m ar e speci fi ed and i f the fi rst and the l ast
ver ti ces ar e not equal , the pol ygon i s consi dered as cl osed i f these ver ti ces ar e
wi thi n a cer tai n cl osi ng di stance. These opti onal i nput arguments ar e meant
to be used onl y when cal l i ng cs gc hk fr om pde t ool .
gs t at =c s gchk( gd) i s i denti cal to the above cal l , except for usi ng the same
format of gd that i s used by de cs g. Thi s cal l i s r ecommended when usi ng
c s gchk as a command-l i ne functi on.
gs t at i s a row vector of i nteger s that i ndi cates the val i di ty status of the
cor respondi ng sol i d objects, i .e., col umns, i n gd.
For a ci rcl e sol i d, gs t at =0 i ndi cates that the ci rcl e has a posi ti ve radi us, 1
i ndi cates a nonposi ti ve radi us, and 2 i ndi cates that the ci rcl e i s not uni que.
For a pol ygon, gs t at =0 i ndi cates that the pol ygon i s cl osed and does not
i ntersect i tsel f, i .e., i t has a wel l -defi ned, uni que i nteri or regi on. 1 i ndi cates an
open and non sel f-i nter secti ng pol ygon, 2 i ndi cates a cl osed and
sel f-i ntersecti ng pol ygon, and 3 i ndi cates an open and sel f-i ntersecti ng
pol ygon.
For a rectangl e sol i d, gs t at i s i denti cal to that of a pol ygon. Thi s i s so because
a rectangl e i s consi der ed as a pol ygon by c s gchk.
For an el l i pse sol i d, gs t at =0 i ndi cates that the el l i pse has posi ti ve semi axes, 1
i ndi cates that at l east one of the semi axes i s nonposi ti ve, and 2 i ndi cates that
the el l i pse i s not uni que.
I f gs t at consi sts of zero entr i es onl y, then gd i s val i d and can be used as i nput
ar gument by de cs g.
See Also dec s g
csgdel
5-29
csgdel
Purpose Del ete borders between mi ni mal r egi ons.
Synopsis [ dl 1, bt 1] =c s gde l ( dl , bt , bl )
[ dl 1, bt 1] =c s gde l ( dl , bt )
Description [ dl 1, bt 1] =c s gde l ( dl , bt , bl ) del etes the border segments i n the l i st bl . I f the
consi stency of the Decomposed Geometr y matr i x i s not preser ved by del eti ng
the el ements i n the l i st bl , addi ti onal border segments ar e del eted. Boundary
segments cannot be del eted.
The concepts or border segments, boundary segments, and mi ni mal r egi ons ar e
expl ai ned i n the entry dec s g.
dl and dl 1 are Decomposed Geometry matri ces. See the entry on dec s g for a
descr i pti on of the Decomposed Geometr y matr i x. The format of the Bool ean
tabl es bt and bt 1 i s al so descri bed i n the entr y on de cs g.
[ dl 1, bt 1] =c s gde l ( dl , bt ) del etes al l bor der segments.
See Also de c s g, cs gc hk
decsg
5-30
decsg
Purpose Decompose Constructi ve Sol i d Geometr y i nto mi ni mal r egi ons.
Synopsis dl =de cs g( gd)
dl =de cs g( gd, s f , ns )
[ dl , bt ] =dec s g( gd)
[ dl , bt ] =dec s g( gd, s f , ns )
[ dl , bt , dl 1, bt 1, ms b] =de cs g( gd)
[ dl , bt , dl 1, bt 1, ms b] =de cs g( gd, s f , ns )
Description Thi s functi on anal yzes the Constructive Solid Geometry model (CSG model )
that you draw. I t anal yzes the CSG model , constr ucts a set of di sjoi nt mi ni mal
regi ons, bounded by boundary segments and border segments, and opti onal l y
eval uates a set for mul a i n ter ms of the objects i n the CSG model . We often refer
to the set of mi ni mal r egi ons as the decomposed geometry. The decomposed
geometr y makes i t possi bl e for other tool box functi ons to under stand the
geometr y you speci fy. For pl otti ng pur poses a second set of mi ni mal r egi ons
wi th a connected boundar y i s constr ucted.
The gr aphi cal user i nter face pde t ool uses dec s g for many pur poses. Each ti me
a new sol i d object i s dr awn or changed, pde t ool cal l s dec s g i n order to be abl e
to dr aw the sol i d objects and mi ni mal r egi ons corr ectl y. The Del aunay
tr i angul ati on al gori thm, i ni t me s h, al so uses the output of de c s g to gener ate an
i ni ti al mesh.
dl =de cs g( gd, s f , ns ) decomposes the CSG model gd i nto the decomposed
geometr y dl . The CSG model i s repr esented by the Geometry Descr i pti on
matr i x, and the decomposed geometr y i s r epresented by the Decomposed
Geometr y matr i x. de cs g r etur ns the mi ni mal r egi ons that eval uate to tr ue for
the set for mul a s f . The Name Space matri x ns i s a text matri x that rel ates the
col umns i n gd to var i abl e names i n s f .
dl =de cs g( gd) returns al l mi ni mal regi ons. (The same as l etti ng s f corr espond
to the uni on of al l objects i n gd.)
[ dl , bt ] =dec s g( gd) and [ dl , bt ] =dec s g( gd, s f , ns ) addi ti onal l y return a
Boolean table that r el ates the ori gi nal sol i d objects to the mi ni mal regi ons. A
col umn i n bt cor responds to the col umn wi th the same i ndex i n gd. A row i n bt
cor responds to a mi ni mal r egi on i ndex.
decsg
5-31
[ dl , bt , dl 1, bt 1, ms b] =de cs g( gd) and
[ dl , bt , dl 1, bt 1, ms b] =de cs g( gd, s f , ns ) r etur n a second set of mi ni mal
regi ons dl 1 wi th a cor respondi ng Bool ean tabl e bt 1. Thi s second set of mi ni mal
regi ons al l have a connected boundary. These mi ni mal r egi ons can be pl otted
by usi ng MATLAB patch objects. The second set of mi ni mal regi ons have
border s that may not have been i nduced by the or i gi nal sol i d objects. Thi s
occur s when two or more gr oups of sol i d objects have noni nter secti ng
boundari es.
The cal l i ng sequences addi ti onal l y r eturn a sequence ms b of dr awi ng
commands for each second mi ni mal regi on. The fi rst r ow contai ns the number
of edge segment that bounds the mi ni mal r egi on. The addi ti onal rows contai n
the sequence of edge segments fr om the Decomposed Geometr y matri x that
consti tutes the bound. I f the i ndex edge segment l abel i s gr eater than the total
number of edge segments, i t i ndi cates that the total number of edge segments
shoul d be subtr acted from the contents to get the edge segment l abel number
and the drawi ng di r ecti on i s opposi te to the one gi ven by the Decomposed
Geometry matri x.
Geometry Description Matrix
The Geometry Description matrix gd descr i bes the CSG model that you dr aw
usi ng pde t ool . The curr ent Geometry Descr i pti on matr i x can be made
avai l abl e to the MATLAB mai n workspace by sel ecti ng the Export Geometry
Description, Set Formula, Labels . . . opti on from the Draw menu i n pdet ool .
Each col umn i n the Geometry Descr i pti on matr i x cor responds to an object i n
the CSG model . Four types of solid objects are supported. The object type i s
speci fi ed i n row 1:
For the circle solid, row one contai ns 1, the second and thi r d r ow contai n the
center x- and y-coordi nates, r especti vel y. Row four contai ns the radi us of the
ci r cl e.
For a polygon solid, r ow one contai ns 2, and the second row contai ns the
number , n, of l i ne segments i n the boundary of the pol ygon. The fol l owi ng n
decsg
5-32
rows contai n the x-coor di nates of the star ti ng poi nts of the edges, and the
fol l owi ng n r ows contai n the y-coordi nates of the starti ng poi nts of the edges.
For a rectangle solid, r ow one contai ns 3. The format i s other wi se i denti cal
to the pol ygon for mat.
For an ellipse solid, row one contai ns 4, the second and thi rd row contai ns
the center x- and y-coordi nates, respecti vel y. Rows four and fi ve contai n the
semi axes of the el l i pse. The rotati onal angl e of the el l i pse i s stored i n row si x.
Set Formula
s f contai ns a set formula expr essed wi th the set of vari abl es l i sted i n ns . The
operator s +, *, and corr espond to the set operati ons uni on, i ntersecti on,
and set di ffer ence, r especti vel y. The pr ecedence of the oper ator s + and * ar e
the same. has hi gher precedence. The precedence can be contr ol l ed wi th
par entheses.
Name Space Matrix
The Name Space matrix ns rel ates the col umns i n gd to vari abl e names i n s f .
Each col umn i n ns contai ns a sequence of char acters, padded wi th spaces. Each
such character col umn assi gns a name to the corr espondi ng geometri c object i n
gd. Thi s way we can r efer to a speci fi c object i n gd i n the set for mul a s f .
Decomposed Geometry Matrix
The Decomposed Geometry matrix dl contai ns a representati on of the
decomposed geometr y i n terms of di sjoi nted minimal regions that have been
constr ucted by the de cs g al gori thm. Each edge segment of the mi ni mal regi ons
cor responds to a col umn i n dl . We r efer to edge segments between mi ni mal
regi ons as border segments and outer boundari es as boundary segments. I n
each such col umn rows two and three contai n the starti ng and endi ng
x-coordi nate, and r ows four and fi ve the cor respondi ng y-coordi nate. Rows si x
and seven contai n l eft and r i ght mi ni mal r egi on l abel s wi th respect to the
di recti on i nduced by the star t and end poi nts (counter cl ockwi se di recti on on
decsg
5-33
ci r cl e and el l i pse segments). Ther e are three types of possi bl e edge segments i n
a mi ni mal r egi on:
For ci rcl e edge segments row one i s 1. Rows ei ght and ni ne contai n the
coordi nates of the center of the ci rcl e. Row 10 contai ns the r adi us.
For l i ne edge segments row one i s 2.
For el l i pse edge segments r ow one i s 4. Rows ei ght and ni ne contai n the
coordi nates of the center of the el l i pse. Rows 10 and 11 contai n the semi axes
of the el l i pse, r especti vel y. The rotati onal angl e of the el l i pse i s stored i n
row 12.
Examples The command sequence bel ow star ts pdet ool and dr aws a uni t ci rcl e and a uni t
square.
pde ci r c ( 0, 0, 1)
pde r e ct ( [ 0 1 0 1] )
I nser t the set for mul a C1SQ1. Export the Geometr y Descr i pti on matri x, set
formul a, and Name Space matri x to the MATLAB mai n workspace by sel ecti ng
the Export Geometry Description . . . opti on from the Draw menu. Then type:
[ dl , bt ] =de cs g( gd, s f , ns ) ;
dl =
2. 0000 2. 0000 1. 0000 1. 0000 1. 0000
0 0 1. 0000 0. 0000 0. 0000
1. 0000 0 0. 0000 1. 0000 1. 0000
0 1. 0000 0. 0000 1. 0000 1. 0000
0 0 1. 0000 0 0. 0000
0 0 1. 0000 1. 0000 1. 0000
1. 0000 1. 0000 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 1. 0000 1. 0000 1. 0000
bt =
1 0
Note that ther e i s one mi ni mal r egi on, wi th fi ve edge segments, three ci rcl e
edge segments, and two l i ne edge segments.
decsg
5-34
Algorithm The al gor i thm consi sts of the fol l owi ng steps:
1 Deter mi ne the i nter secti on poi nts between the bor der s of the model objects.
2 For each i ntersecti on poi nt, sort the i ncomi ng edge segments on angl e and
cur vature.
3 Deter mi ne i f the i nduced graph i s connected. I f not, add some appropri ate
edges, and redo al gori thm fr om step 1.
4 Cycl e thr ough edge segments of mi ni mal regi ons.
5 For each or i gi nal r egi on, deter mi ne mi ni mal regi ons i nsi de i t.
6 Organi ze output and r emove the addi ti onal edges.
Cautionary The i nput CSG model i s not checked for cor rectness. I t i s assumed that no
ci rcl es or el l i pses ar e i denti cal or degener ated and that no l i nes have zero
l ength. Pol ygons must not be sel fi ntersecti ng. Use the functi on cs gc hk to check
the CSG model .
Diagnostics NaN i s r etur ned i f the set formul a s f cannot be eval uated.
See Also pde t ool , pde ge om, pde bound, wge om, wbound, pdec i r c , pder ec t , pdepol y,
pde el l i p, c s gc hk, cs gde l
dst, idst
5-35
dst, i dst
Purpose Di scr ete si ne transform.
Synopsis y=ds t ( x )
x=i ds t ( y)
Description y=ds t ( x ) computes the di screte si ne tr ansfor m of the col umns of x . For best
performance speed, the number of r ows i n x shoul d be 2
m
- 1, for some i nteger
m.
y=ds t ( x , n) pads or tr uncates the vector x to l ength n before transformi ng.
I f x i s a matr i x, the ds t oper ati on i s appl i ed to each col umn.
x=i ds t ( y) cal cul ates the i nverse di screte si ne transfor m of the col umns of y.
For best perfor mance speed, the number of rows i n y shoul d be 2
m
- 1, for some
i nteger m.
x=i ds t ( y, n) pads or truncates the vector y to l ength n befor e tr ansfor mi ng.
I f y i s a matr i x, the i ds t operati on i s appl i ed to each col umn.
See Also poi s ol v , poi as ma, poi i nde x
hyperbolic
5-36
hyperbol i c
Purpose Sol ve hyper bol i c PDE probl em.
Synopsis u1=hy pe r bol i c ( u0, ut 0, t l i s t , b, p, e, t , c , a, f , d)
u1=hy pe r bol i c ( u0, ut 0, t l i s t , b, p, e, t , c , a, f , d, r t ol )
u1=hy pe r bol i c ( u0, ut 0, t l i s t , b, p, e, t , c , a, f , d, r t ol , at ol )
u1=hy pe r bol i c ( u0, ut 0, t l i s t , K, F, B, ud, M)
u1=hy pe r bol i c ( u0, ut 0, t l i s t , K, F, B, ud, M, r t ol )
u1=hy pe r bol i c ( u0, ut 0, t l i s t , K, F, B, ud, M, r t ol , at ol )
Description u1=hy pe r bol i c ( u0, ut 0, t l i s t , b, p, e, t , c , a, f , d) pr oduces the sol uti on to the
FEM for mul ati on of the scal ar PDE pr obl em
(cu) + au = f on ,
or the system PDE pr obl em
(c u) + au = f on
on a mesh descr i bed by p, e , and t , wi th boundar y condi ti ons gi ven by b, and
wi th i ni ti al val ue u0 and i ni ti al der i vati ve ut 0.
I n the scal ar case, each row i n the sol uti on matr i x u1 i s the sol uti on at the
coor di nates gi ven by the cor respondi ng col umn i n p. Each col umn i n u1 i s the
sol uti on at the ti me gi ven by the corr espondi ng i tem i n t l i s t . For a system of
di mensi on N wi th n
p
node poi nts, the fi r st n
p
r ows of u1 descr i be the fi r st
component of u, the fol l owi ng n
p
r ows of u1 descr i be the second component of
u, and so on. Thus, the components of u ar e pl aced i n bl ocks u as N bl ocks of
node poi nt rows.
b descr i bes the boundary condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condi ti on matr i x or the name of a Boundar y M-fi l e. The boundary
condi ti ons can depend on t , the ti me. The for mats of the Boundar y Condi ti on
matr i x and Boundary M-fi l e ar e descr i bed i n the entr i es on as s e mb and
pde bound, r especti vel y.
The geometr y of the PDE pr obl em i s gi ven by the mesh data p, e , and t . Detai l s
on the mesh data repr esentati on can be found i n the entry on i ni t mes h.
The coeffi ci ents c, a, d, and f of the PDE probl em can be gi ven i n a var i ety of
ways. The coeffi ci ents can depend on t , the ti me. A compl ete l i sti ng of al l
opti ons can be found i n the entr y on as s e mpde .
d

2
u
t
2
--------
d

2
u
t
2
---------
hyperbolic
5-37
at ol and r t ol ar e absol ute and rel ati ve tol er ances that are passed to the ODE
sol ver .
u1=hy pe r bol i c ( u0, ut 0, t l i s t , K, F, B, ud, M) produces the sol uti on to the ODE
probl em
wi th i ni ti al val ues for u bei ng u0 and ut 0.
Examples Sol ve the wave equati on
on a square geometry -1 x,y 1 (s quar e g), wi th Di ri chl et boundar y condi ti ons
u = 0 for x = 1, and Neumann boundar y condi ti ons
for y = 1 (s quar e b3). Choose
u(0) = arctan(cos(x))
and
= 3si n(x)exp(cos(y)).
Compute the sol uti on at ti mes 0, 1/6, 1/3, ... , 29/6, 5.
[ p, e, t ] =i ni t me s h( ' s quar eg' ) ;
x =p( 1, : ) ' ;
y =p( 2, : ) ' ;
u0=at an( c os ( pi /2*x ) ) ;
ut 0=3*s i n( pi *x ) . *e xp( cos ( pi *y ) ) ;
t l i s t =l i ns pace ( 0, 5, 31) ;
uu=hy pe r bol i c( u0, ut 0, t l i s t , ' s quar e b3' , p, e, t , 1, 0, 0, 1) ;
The fi l e pde de mo6 contai ns a compl ete exampl e wi th ani mati on.
See Also as s empde, par abol i c
BMB
d
2
u
i
dt
2
---------- K + u
i
F, = u Bu
i
u
d
+ =

2
u
t
2
-------- u =
u
n
------ 0 =
du 0 ( )
dt
--------------
initmesh
5-38
i ni tmesh
Purpose Cr eate i ni ti al tr i angul ar mesh.
Synopsis [ p, e, t ] =i ni t me s h( g)
[ p, e, t ] =i ni t me s h( g, ' Pr ope r t yName' , Pr oper t y Val ue , . . . )
Description [ p, e, t ] =i ni t me s h( g) retur ns a tr i angul ar mesh usi ng the geometr y
speci fi cati on functi on g. I t uses a Del aunay tri angul ati on al gori thm. The mesh
si ze i s determi ned from the shape of the geometr y.
g descr i bes the geometry of the PDE pr obl em. g can ei ther be a Decomposed
Geometr y matri x or the name of a Geometr y M-fi l e. The for mats of the
Decomposed Geometr y matr i x and Geometry M-fi l e are descri bed i n the entr i es
on de cs g and pde ge om, r especti vel y.
The outputs p, e , and t ar e the mesh data.
I n the Point matrix p, the fi r st and second rows contai n x- and y-coor di nates of
the poi nts i n the mesh.
I n the Edge matrix e, the fi r st and second rows contai n i ndi ces of the starti ng
and endi ng poi nt, the thi r d and four th r ows contai n the starti ng and endi ng
par ameter val ues, the fi fth r ow contai ns the edge segment number, and the
si xth and seventh row contai n the l eft- and r i ght-hand si de subdomai n
numbers.
I n the Triangle matrix t , the fi rst three r ows contai n i ndi ces to the cor ner
poi nts, gi ven i n counter cl ockwi se order, and the fourth r ow contai ns the
subdomai n number.
initmesh
5-39
The fol l owi ng pr oper ty name/property val ue pai rs ar e al l owed:
The Hmax pr oper ty control s the si ze of the tr i angl es on the mesh. i ni t me s h
cr eates a mesh wher e no tr i angl e si de exceeds Hmax.
The Hgr ad property determi nes te mesh gr owth rate away from a smal l par t of
the geometry. The defaul t val ue i s 1.3, i .e., a growth r ate of 30%. Hgr ad must
be between 1 and 2.
Both the Box and I ni t proper ty are rel ated to the way the mesh al gori thm
wor ks. By tur ni ng on Box you can get a good i dea of how the mesh generati on
al gor i thm works wi thi n the boundi ng box. By tur ni ng on I ni t you can see the
i ni ti al tri angul ati on of the boundari es. By usi ng the command sequence
[ p, e, t ] =i ni t me s h( dl , ' hmax ' , i nf , ' i ni t ' , ' on' ) ;
[ ux y, t n, a2, a3] =t r i 2gr i d( p, t , z er os ( s i z e ( p, 2) ) , x, y) ;
n=t ( 4, t n) ;
you can determi ne the subdomai n number n of the poi nt x y . I f the poi nt i s
outsi de the geometr y, t n i s NaN and the command n=t ( 4, t n) r esul ts i n a
fai l ure.
The Ji ggl e property i s used to control whether ji ggl i ng of the mesh shoul d be
attempted (see the entr y on j i ggl e me s h for detai l s). Ji ggl i ng can be done unti l
the mi ni mum or the mean of the qual i ty of the tr i angl es decr eases. Ji ggl e I t er
can be used to set an upper l i mi t on the number of i ter ati ons.
Property Value Default Description
Hmax numeri c esti mate Maxi mum edge si ze
Hgr ad numeri c 1. 3 Mesh growth rate
Box on| of f of f Preser ve boundi ng box
I ni t on| of f of f Edge tr i angul ati on
Ji ggl e of f | mean| mi n mean Cal l j i ggl eme s h
Ji ggl e I t e r numeri c 10 Maxi mum i ter ati ons
initmesh
5-40
Algorithm i ni t mes h i mpl ements a Del aunay tri angul ati on al gori thm:
1 Pl ace node poi nts on the edges.
2 Encl ose geometry i n boundi ng box.
3 Tri angul ate edges.
4 Check that the tr i angul ati on respects boundar i es.
5 I nsert node poi nts i nto centers of ci rcumscr i bed ci rcl es of l ar ge tri angl es.
6 Repeat from step 4 i f Hmax not yet achi eved.
7 Remove boundi ng box.
Examples Make a si mpl e tr i angul ar mesh of the L-shaped membrane i n pdet ool .
Before you do anythi ng i n pde t ool , set the Maximum edge size to i nf i n the
Mesh Parameters di al og box. You open the di al og box by sel ecti ng the
Parameters . . . opti on from the Mesh menu. Al so sel ect the i tems Show Node
Labels and Show Triangle Labels i n the Mesh menu. Then create the i ni ti al
mesh by pr essi ng the button. (Thi s can al so be done by sel ecti ng the
Initialize Mesh opti on from the Mesh menu.)
The fi gur e bel ow appear s:
1.5 1 0.5 0 0.5 1 1.5
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
1 2
3 4
5 6
1
2
3
4
initmesh
5-41
The corr espondi ng mesh data str uctur es can be expor ted to the mai n
wor kspace by sel ecti ng the Expor t Mesh opti on fr om the Mesh menu.
p
p =
1 1 1 0 0 1
1 1 1 1 0 0
e
e =
1 2 3 4 5 6
2 3 4 5 6 1
0 0 0 0 0 0
1 1 1 1 1 1
1 2 3 4 5 6
1 1 1 1 1 1
0 0 0 0 0 0
t
t =
1 2 3 1
2 3 4 5
5 5 5 6
1 1 1 1

See Also de c s g, pdegeom, j i ggl e mes h, r ef i ne me s h
Reference George, P. L., Automatic Mesh Generation Application to Finite Element
Methods, WI LEY, 1991.
jigglemesh
5-42
ji ggl emesh
Purpose Ji ggl e i nter nal poi nts of a tr i angul ar mesh.
Synopsis p1=j i ggl e me s h( p, e, t )
p1=j i ggl e me s h( p, e, t , ' Pr oper t y Name ' , Pr ope r t yVal ue, . . . )
Description p1=j i ggl e me s h( p, e, t ) ji ggl es the tri angul ar mesh by adjusti ng the node poi nt
posi ti ons. The qual i ty of the mesh normal l y i ncr eases.
The fol l owi ng pr oper ty name/property val ue pai r s are al l owed:
Each mesh poi nt that i s not l ocated on an edge segment i s moved toward the
center of mass of the pol ygon for med by the adjacent tr i angl es. Thi s process i s
repeated accordi ng to the setti ng of the Opt and I t er var i abl es:
When Opt i s set to of f thi s pr ocess i s repeated I t er ti mes (defaul t: 1).
When Opt i s set to me an the pr ocess i s repeated unti l the mean tri angl e
qual i ty does not si gni fi cantl y i ncrease, or unti l the bound I t e r i s reached
(defaul t: 20).
When Opt i s set to mi n the process i s r epeated unti l the mi ni mum tr i angl e
qual i ty does not si gni fi cantl y i ncrease, or unti l the bound I t e r i s reached
(defaul t: 20).
Examples Cr eate a tr i angul ar mesh of the L-shaped membrane, fi rst wi thout ji ggl i ng,
and then ji ggl e the mesh.
[ p, e, t ] =i ni t me s h( ' l s hapeg' , ' j i ggl e ' , ' of f ' ) ;
q=pde t r i q( p, t ) ;
pde pl ot ( p, e, t , ' x ydat a' , q, ' c ol or bar ' , ' on' , ' x ys t y l e ' , ' f l at ' )
p1=j i ggl emes h( p, e, t , ' opt ' , ' me an' , ' i t er ' , i nf ) ;
q=pde t r i q( p1, t ) ;
pde pl ot ( p1, e , t , ' xy dat a' , q, ' col or bar ' , ' on' , ' xy s t yl e' , ' f l at ' )
See Also i ni t mes h, pdet r i q
Property Value Default Description
Opt of f | mean| mi n me an Opti mi zati on method
I t er numeri c 1 or 20 (see bel ow) Maxi mum i terati ons
parabolic
5-43
parabol i c
Purpose Sol ve parabol i c PDE probl em.
Synopsis u1=par abol i c( u0, t l i s t , b, p, e , t , c , a, f , d)
u1=par abol i c( u0, t l i s t , b, p, e , t , c , a, f , d, r t ol )
u1=par abol i c( u0, t l i s t , b, p, e , t , c , a, f , d, r t ol , at ol )
u1=par abol i c( u0, t l i s t , K, F, B, ud, M)
u1=par abol i c( u0, t l i s t , K, F, B, ud, M, r t ol )
u1=par abol i c( u0, t l i s t , K, F, B, ud, M, r t ol , at ol )
Description u1=par abol i c( u0, t l i s t , g, b, p, e , t , c , a, f , d) produces the sol uti on to the
FEM for mul ati on of the scal ar PDE pr obl em
(cu) + au = f on ,
or the system PDE pr obl em
(c u) + au = f on .
on a mesh descr i bed by p, e , and t , wi th boundar y condi ti ons gi ven by b, and
wi th i ni ti al val ue u0.
For the scal ar case, each r ow i n the sol uti on matri x u1 i s the sol uti on at the
coor di nates gi ven by the cor respondi ng col umn i n p. Each col umn i n u1 i s the
sol uti on at the ti me gi ven by the corr espondi ng i tem i n t l i s t . For a system of
di mensi on N wi th n
p
node poi nts, the fi r st n
p
r ows of u1 descr i be the fi r st
component of u, the fol l owi ng n
p
r ows of u1 descr i be the second component of
u, and so on. Thus, the components of u ar e pl aced i n the vector u as N bl ocks
of node poi nt rows.
b descr i bes the boundary condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condi ti on matr i x or the name of a Boundar y M-fi l e. The boundary
condi ti ons can depend on t , the ti me. The for mats of the Boundar y Condi ti on
matr i x and Boundary M-fi l e are descr i bed i n the entr i es on as s emb and
pde bound, r especti vel y.
The geometr y of the PDE probl em i s gi ven by the mesh data p, e , and t . Detai l s
on the mesh data repr esentati on can be found i n the entr y on i ni t me s h.
The coeffi ci ents c , a, d, and f of the PDE probl em can be gi ven i n a var i ety of
ways. The coeffi ci ents can depend on t , the ti me. A compl ete l i sti ng of al l
opti ons can be found i n under the entry as s empde.
d
u
t
------
d
u
t
------
parabolic
5-44
at ol and r t ol ar e absol ute and rel ati ve tol er ances that are passed to the ODE
sol ver .
u1=par abol i c( u0, t l i s t , K, F, B, ud, M) pr oduces the sol uti on to the ODE
probl em
wi th i ni ti al val ue for u bei ng u0.
Examples Sol ve the heat equati on
on a squar e geometry -1 x,y 1 (s quar eg). Choose u(0) = 1 on the di sk x
2
+y
2

< 0.4
2
, and u(0) = 0 other wi se. Use Di ri chl et boundary condi ti ons u = 0
(s quar eb1). Compute the sol uti on at ti mes l i ns pac e( 0, 0. 1, 20) .
[ p, e, t ] =i ni t me s h( ' s quar eg' ) ;
[ p, e, t ] =r e f i ne me s h( ' s quar eg' , p, e , t ) ;
u0=z e r os ( s i z e( p, 2) , 1) ;
i x=f i nd( s qr t ( p( 1, : ) . ^2+p( 2, : ) . ^2) <0. 4) ;
u0( i x ) =one s ( s i z e ( i x) ) ;
t l i s t =l i ns pace ( 0, 0. 1, 20) ;
u1=par abol i c ( u0, t l i s t , ' s quar e b1' , p, e , t , 1, 0, 1, 1) ;
See Also as s empde, hy pe r bol i c
BMB
du
i
dt
------- K + u
i
F, = u Bu
i
u
d
+ =
u
t
------ u =
pdeadgsc
5-45
pdeadgsc
Purpose Sel ect tr i angl es usi ng a rel ati ve tol er ance cri ter i on.
Synopsis bt =pdeadgs c ( p, t , c, a, f , u, er r f , t ol )
Description bt =pdeadgs c ( p, t , c, a, f , u, er r f , t ol ) r etur ns i ndi ces of tr i angl es to be
refi ned i n bt . Used fr om adapt me s h to sel ect the tr i angl es to be further refi ned.
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t . See the
entr y on i ni t me s h for mor e detai l s.
c, a, and f are PDE coeffi ci ents. See as s e mpde for detai l s.
u i s the curr ent sol uti on, gi ven as a col umn vector . See the entry on as s empde
for detai l s.
er r f i s the er ror i ndi cator , as cal cul ated by pdej mps .
t ol i s a tol er ance par ameter.
Tri angl es ar e sel ected usi ng the cri teri on e r r f >t ol *s c al e , wher e s cal e i s
cal cul ated as fol l ows:
Let c max, amax, f max, and umax be the maxi mum of c, a, f , and u, r especti vel y.
Let l be the si de of the smal l est axi s-al i gned squar e that contai ns the geometry.
Then s c al e =max ( f max *l ^2, amax*umax*l ^2, cmax*umax ) . The scal i ng makes
the t ol parameter i ndependent of the scal i ng of the equati on and the geometry.
See Also adapt me s h, pde j mps
pdeadworst
5-46
pdeadworst
Purpose Sel ect tr i angl es rel ati ve to the wor st val ue.
Synopsis bt =pdeadwor s t ( p, t , c, a, f , u, e r r f , wl ev e l )
Description bt =pdeadwor s t ( p, t , c, a, f , u, e r r f , wl ev e l ) returns i ndi ces of tri angl es to be
refi ned i n bt . Used fr om adapt me s h to sel ect the tr i angl es to be fur ther refi ned.
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t . See the
entr y on i ni t me s h for mor e detai l s.
c , a, and f are PDE coeffi ci ents. See the entr y on as s e mpde for detai l s.
u i s the curr ent sol uti on, gi ven as a col umn vector . See the entry on as s empde
for detai l s.
e r r f i s the er ror i ndi cator , as cal cul ated by pdej mps .
wl e ve l i s the err or l evel rel ati ve to the worst err or . wl ev el must be between 0
and 1.
Tri angl es ar e sel ected usi ng the cri teri on e r r f >wl ev el *max( er r f ) .
See Also adapt me s h, pde j mps
pdearcl
5-47
pdearcl
Purpose I nter pol ati on between par ametri c representati on and ar c l ength.
Synopsis pp=pdear c l ( p, xy , s , s 0, s 1)
Description pp=pdear c l ( p, xy , s , s 0, s 1) r etur ns parameter val ues for a parameter i zed
curve cor respondi ng to a gi ven set of ar c l ength val ues.
p i s a monotone r ow vector of parameter val ues and x y i s a matri x wi th two
rows gi vi ng the cor respondi ng poi nts on the curve.
The fi r st poi nt of the cur ve i s gi ven the ar c l ength val ue s 0 and the l ast poi nt
the val ue s 1.
On r etur n, pp contai ns par ameter val ues corr espondi ng to the ar c l ength
val ues speci fi ed i n s .
The arc l ength val ues s , s 0, and s 1 can be an affi ne tr ansfor mati on of the ar c
l ength.
Examples See the exampl e car dg i n the entry pde ge om.
See Also pde ge om
pdebound
5-48
pdebound
Purpose Boundary M-fi l e.
Synopsis [ q, g, h, r ] =pde bound( p, e , u, t i me )
Description The Boundar y M-fi l e speci fi es the boundary condi ti ons of a PDE pr obl em.
The most general form of boundar y condi ti ons that we can handl e i s
hu = r
(c u) + u = g + h.
By the notati on (c u) we mean the N-by-1 matri x wi th (i,1)-component
where the outward normal vector of the boundary . There
ar e M Di r i chl et condi ti ons and the h-matri x i s M-by-N, M 0. The general i zed
Neumann condi ti on contai ns a source h where the Lagr ange mul ti pl i er s i s
computed such that the Di ri chl et condi ti ons become sati sfi ed.
The data that you speci fy i s q, g, h, and r.
For M = 0 we say that we have a general i zed Neumann boundar y condi ti on, for
M = N a Di r i chl et boundary condi ti on, and for 0 < M < N a mi xed boundary
condi ti on.
The Boundary M-fi l e [ q, g, h, r ] =pde bound( p, e , u, t i me ) computes the val ues
of q, g, h, and r, on the a set of edges e.
The matri ces p and e ar e mesh data. e needs onl y to be a subset of the edges
i n the mesh. Detai l s on the mesh data r epr esentati on can be found i n the entry
on i ni t mes h.
The i nput ar guments u and t i me ar e used for the nonl i near sol ver and ti me
steppi ng al gor i thms, respecti vel y. u and t i me are empty matri ces i f the
cor respondi ng parameter i s not passed to as s emb. I f t i me i s NaN and any of the
functi on q, g, h, and r depends on t i me , pdebound must r etur n a matri x of
cor rect si ze, contai ni ng NaNs i n al l posi ti ons, i n the cor respondi ng output
ar gument.
The sol uti on u i s r epresented by the sol uti on vector u. Detai l s on the
repr esentati on can be found i n the entr y on as s e mpde.
n q
n
( ) cos c
i j 1 1 , , ,

x
----- ( ) cos c
i j 1 2 , , ,

y
----- ( ) sin c
i j 2 1 , , ,

x
----- ( ) sin c
i j 2 2 , , ,

y
----- + + +


u
j
,
j 1 =
N

n ( ) cos ( ) sin , ( ) =
pdebound
5-49
q and g must contai n the val ue of q and g on the mi dpoi nt of each boundar y.
Thus we have s i z e( q) =[ N^2 ne] , where N i s the di mensi on of the system, and
ne the number of edges i n e, and s i z e ( g) =[ N ne ] . For the Di ri chl et case, the
cor respondi ng val ues must be zeros.
h and r must contai n the val ues of h and r at the fi r st poi nt on each edge
fol l owed by the val ue at the second poi nt on each edge. Thus we have
s i z e( h) =[ N^2 2*ne] , wher e N i s the di mensi on of the system, and ne the
number of edges i n e , and s i z e ( r ) =[ N 2*ne ] . When M < N, h and r must be
padded wi th N - M rows of zer os.
The el ements of the matr i ces q and h are stored i n col umn-wi se orderi ng i n the
MATLAB matr i ces q and h.
Examples For the boundary condi ti ons
the val ues bel ow shoul d be stor ed i n q, g, h, and r :
1
q=[ . . . 2 . . . ]
2
0
g=[ . . . 3 . . . ]
4
1 1
h=[ . . . 0 . . . 0 . . . ]
1 1
0 0
r =[ . . . 2 . . . 2 . . . ]
0 0
See Also i ni t mes h, pde geom, pde s dt , pdee nt
1 1 ( )u 2 =
n c u ( )
1 2
2 0


u +
3
4


h + =
.
pdecgrad
5-50
pdecgrad
Purpose The fl ux of a PDE sol uti on.
Synopsis [ cgxu, c gy u] =pdec gr ad( p, t , c, u)
[ cgxu, c gy u] =pdec gr ad( p, t , c, u, t i me )
[ cgxu, c gy u] =pdec gr ad( p, t , c, u, t i me , s dl )
Description [ cgxu, c gy u] =pdec gr ad( p, t , c, u) returns the fl ux, c u, eval uated at the
center of each tri angl e.
Row i of cgxu contai ns
Row i of cgyu contai ns
There i s one col umn for each tri angl e i n t i n both cgxu and c gyu.
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t. Detai l s
on the mesh data repr esentati on can be found i n the entry on i ni t mes h.
The coeffi ci ent c of the PDE pr obl em can be gi ven i n a vari ety of ways. A
compl ete l i sti ng of al l opti ons can be found i n the entr y on as s e mpde .
The for mat for the sol uti on vector u i s descri bed i n as s empde.
The scal ar opti onal ar gument t i me i s used for par abol i c and hyperbol i c
probl ems, i f c depends on t , the ti me.
The opti onal ar gument s dl restr i cts the computati on to the subdomai ns i n the
l i st s dl .
See Also as s empde
c
i j 11
u
j
x
-------
j 1 =
N

c
ij 12
u
j
y
------- +
.
c
i j 21
u
j
x
-------
j 1 =
N

c
i j 22
u
j
y
------- +
.
pdecirc
5-51
pdeci rc
Purpose Dr aw ci rcl e.
Synopsis pde ci r c ( x c, yc , r adi us )
pde ci r c ( x c, yc , r adi us , l abel )
Description pde ci r c ( x c, yc , r adi us ) dr aws a ci rcl e wi th center i n ( x c , y c) and r adi us
r adi us . I f the pdet ool GUI i s not acti ve, i t i s automati cal l y started, and the
ci r cl e i s drawn i n an empty geometr y model .
The opti onal ar gument l abel assi gns a name to the ci r cl e (other wi se a defaul t
name i s chosen).
The state of the Geometr y Descri pti on matri x i nsi de pdet ool i s updated to
i ncl ude the ci r cl e. You can expor t the Geometry Descr i pti on matr i x from
pde t ool by usi ng the Export Geometry Description . . . opti on from the Draw
menu. The for mat of the Geometry Descri pti on matr i x i s descri bed i n the entry
on de cs g.
Examples The command bel ow star ts pdet ool and draws a uni t ci r cl e.
pde ci r c ( 0, 0, 1)
See Also pde el l i p, pde pol y, pde r ec t , pde t ool
pdecont
5-52
pdecont
Purpose Shor thand command for contour pl ot.
Synopsis pde cont ( p, t , u)
pde cont ( p, t , u, n)
pde cont ( p, t , u, v)
h=pde cont ( p, t , u)
h=pde cont ( p, t , u, n)
h=pde cont ( p, t , u, v)
Description pde cont ( p, t , u) draws 10 l evel cur ves of the PDE node or tri angl e data u.
h=pde cont ( p, t , u) addi ti onal l y returns handl es to the drawn axes objects.
I f u i s a col umn vector, node data i s assumed. I f u i s a row vector , tri angl e data
i s assumed. Tri angl e data i s converted to node data usi ng the functi on
pde pr t ni .
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t. Detai l s
on the mesh data repr esentati on can be found i n the entry on i ni t mes h.
pde cont ( p, t , u, n) pl ots usi ng n l evel s.
pde cont ( p, t , u, v) pl ots usi ng the l evel s speci fi ed by v .
Thi s command i s just shorthand for the cal l
pde pl ot ( p, [ ] , t , ' xy dat a' , u, ' xy s t yl e ' , ' of f ' , ' c ont our ' , ' on' , . . .
' l ev el s ' , n, ' col or bar ' , ' of f ' ) ;
I f you want to have more control over your contour pl ot, use pde pl ot i nstead of
pde cont .
Examples Pl ot the contours of the sol uti on to the equati on over the geometr y
defi ned by the L-shaped membr ane. Use Di ri chl et boundary condi ti ons u = 0
on .
[ p, e, t ] =i ni t me s h( ' l s hapeg' ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e , t ) ;
u=as s empde ( ' l s hape b' , p, e, t , 1, 0, 1) ;
pde cont ( p, t , u)
See Also pde pl ot , pde me s h, pde s ur f
u 1 =

pdeeig
5-53
pdeei g
Purpose Sol ve ei genval ue PDE probl em.
Synopsis [ v , l ] =pde ei g( b, p, e , t , c , a, d, r )
[ v , l ] =pde ei g( K, B, M, r )
Description [ v , l ] =pde ei g( b, p, e , t , c , a, d, r ) produces the sol uti on to the FEM
formul ati on of the scal ar PDE ei genval ue pr obl em
(cu) + au = du on ,
or the system PDE ei genval ue pr obl em
(c u) + au = du on
on a geometry descr i bed by p, e, and t , and wi th boundary condi ti ons gi ven by b.
r i s a two el ement vector, i ndi cati ng an i nter val on the real axi s. (The l eft-hand
si de can be I nf .) The al gor i thm returns al l ei genval ues i n thi s i nter val i n l .
v. i s an eigenvector matrix. For the scal ar case each col umn i n v i s an
ei genvector of sol uti on val ues at the cor respondi ng node poi nts from p. For a
system of di mensi on N wi th n
p
node poi nts, the fi r st n
p
rows of v descr i be the
fi rst component of v, the fol l owi ng n
p
rows of v descr i be the second component
of v, and so on. Thus, the components of v ar e pl aced i n bl ocks v as N bl ocks of
node poi nt rows.
b. descr i bes the boundar y condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condi ti on matr i x or the name of a Boundar y M-fi l e. The for mats of
the Boundary Condi ti on matr i x and Boundary M-fi l e are descr i bed i n the
entr i es on as s e mb and pde bound, respecti vel y. Note that the ei genval ue PDE
probl em i s a homogeneous pr obl em, i .e., onl y boundar y condi ti ons where g = 0
and r = 0 can be used. The non-homogeneous par t i s removed automati cal l y.
The geometr y of the PDE probl em i s gi ven by the mesh data p, e , and t . Detai l s
on the mesh data repr esentati on can be found i n the entr y on i ni t me s h.
The coeffi ci ents c , a, d of the PDE probl em can be gi ven i n a wi de var i ety of
ways. I n the context of pdee i g the coeffi ci ents cannot depend on u nor t , the
ti me. A compl ete l i sti ng of al l opti ons can be found i n the entr y on as s e mpde .
[ v , l ] =pde ei g( K, B, M, r ) . pr oduces the sol uti on to the gener al i zed sparse
matr i x ei genval ue probl em
K u
i
= BMBu
i
, u = Bu
i
,
wi th Real () i n the i nterval i n r.
pdeeig
5-54
Examples Compute the ei genval ues l ess than 100 and cor respondi ng ei genmodes for
u = u,
on the geometry of the L-shaped membr ane. Then di spl ay the fi rst and
si xteenth ei genmodes.
[ p, e, t ] =i ni t me s h( ' l s hapeg' ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e , t ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e , t ) ;
[ v, l ] =pdee i g( ' l s hape b' , p, e, t , 1, 0, 1, [ I nf 100] ) ;
l ( 1) % f i r s t ei ge nv al ue
pde s ur f ( p, t , v( : , 1) ) % f i r s t ei ge nmode
f i gur e
membr ane ( 1, 20, 9, 9) % t he MATLAB f unct i on
f i gur e
l ( 16) % s i x t e e nt h ei ge nv al ue
pde s ur f ( p, t , v( : , 16) ) % s i x t e e nt h ei ge nmode
Cautionary I n the standar d case c and d are posi ti ve i n the enti re regi on. Al l ei genval ues
ar e posi ti ve, and 0 i s a good choi ce for a l ower bound of the i nterval . The cases
where ei ther c or d i s zero are di scussed bel ow.
I f d = 0 i n a subr egi on, the mass matr i x M becomes si ngul ar. Thi s does not
cause any troubl e, pr ovi ded that c > 0 ever ywhere. The penci l (K,M) has a set
of i nfi ni te ei genval ues.
I f c = 0 i n a subregi on, the sti ffness matri x K becomes si ngul ar , and the penci l
(K,M) has many zer o ei genval ues. Wi th an i nter val contai ni ng zero, pde ei g
goes on for a very l ong ti me to fi nd al l the zer o ei genval ues. Choose a posi ti ve
l ower bound away from zero but bel ow the smal l est nonzero ei genval ue.
I f ther e i s a r egi on wher e both c = 0 and d = 0, we get a si ngul ar penci l . The
whol e ei genval ue probl em i s undeter mi ned, and any val ue i s equal l y
pl ausi bl e as an ei genval ue.
Some of the awkward cases ar e detected by pde ei g. I f the shi fted matr i x i s
si ngul ar, another shi ft i s attempted. I f the matr i x wi th the new shi ft i s sti l l
si ngul ar a good guess i s that the enti r e penci l (K,M) i s si ngul ar .
I f you try any probl em not bel ongi ng to the standard case, you must use your
knowl edge of the or i gi nal physi cal probl em to i nter pr et the resul ts from the
computati on.
See Also s pt ar n
pdeellip
5-55
pdeel l i p
Purpose Dr aw el l i pse.
Synopsis pde el l i p( xc , y c, a, b, phi )
pde el l i p( xc , y c, a, b, phi , l abe l )
Description pde el l i p( xc , y c, a, b, phi ) draws an el l i pse wi th center i n ( xc , y c) and
semi axes a and b. The r otati on of the el l i pse (i n radi ans) i s gi ven by phi . I f the
pde t ool GUI i s not acti ve, i t i s automati cal l y star ted, and the el l i pse i s drawn
i n an empty geometr y model .
The opti onal argument l abel assi gns a name to the el l i pse (other wi se a defaul t
name i s chosen.)
The state of the Geometr y Descri pti on matri x i nsi de pdet ool i s updated to
i ncl ude the el l i pse. You can export the Geometr y Descri pti on matri x fr om
pde t ool by sel ecti ng the Export Geometry Description . . . opti on from the
Draw menu. The format of the Geometr y Descri pti on matr i x i s descr i bed i n the
entr y on de cs g.
Examples The command bel ow star ts pdet ool and draws an el l i pse.
pde el l i p( 0, 0, 1, 0. 3, pi /4)
See Also pde ci r c , pdepol y , pder e ct , pdet ool
pdeent
5-56
pdeent
Purpose I ndi ces of tr i angl es nei ghbori ng a gi ven set of tr i angl es.
Synopsis nt l =pde ent ( t , t l )
Description Gi ven tri angl e data t and a l i st of tri angl e i ndi ces t l , nt l contai ns i ndi ces of
the tr i angl es i n t l and thei r i mmedi ate nei ghbor s, i .e., those whose
i ntersecti on wi th t l i s nonempty.
See Also r ef i nemes h
pdegeom
5-57
pdegeom
Purpose Geometry M-fi l e.
Synopsis ne =pdegeom
d=pde ge om( bs )
[ x , y] =pde ge om( bs , s )
Description We r epr esent 2-D regi ons by par ameteri zed edge segments. Both the regi ons
and edge segments ar e assi gned uni que posi ti ve number s as l abel s. The edge
segments cannot over l ap. The ful l 2-D pr obl em descr i pti on can contai n sever al
noni nter secti ng regi ons, and they can have common bor der segments. The
boundary of a r egi on can consi st of sever al edge segments. Al l edge segment
juncti ons must coi nci de wi th edge segment endpoi nts. We someti mes r efer to
an edge segment as a boundary segment or a border segment. A boundar y
segment i s l ocated on the outer boundary of the uni on of the mi ni mal regi ons,
and a border segment i s l ocated on the bor der between mi ni mal regi ons.
There are two opti ons for speci fyi ng the pr obl em geometr y:
Create a Decomposed Geometr y matr i x wi th the functi on functi on dec s g.
Thi s i s done automati cal l y fr om pde t ool . Usi ng the Decomposed Geometry
matri x restr i cts the edge segments to be str ai ght l i nes, ci r cl e, or el l i pse
segments. The Decomposed Geometry matr i x can be used i nstead of the
Geometry M-fi l e i n the tool box.
Create a Geometry M-fi l e. By creati ng your own Geometry M-fi l e, you can
cr eate a geometry that fol l ows any mathemati cal functi on exactl y. Bel ow i s
an exampl e of how to cr eate a cardi oi d.
ne =pdegeomi s the number of edge segments.
d=pde ge om( bs ) i s a matri x wi th one col umn for each edge segment speci fi ed i n
bs .
Row 1 contai ns the star t parameter val ue.
Row 2 contai ns the end parameter val ue.
Row 3 contai ns the l abel of the l eft-hand r egi on (l eft wi th respect to di r ecti on
i nduced by star t and end from row 1 and 2).
Row 4 contai ns the l abel of the r i ght-hand r egi on.
pdegeom
5-58
The compl ement of the uni on of al l r egi ons i s assi gned the r egi on number 0.
[ x, y] =pde ge om( bs , s ) pr oduces coor di nates of edge segment poi nts. bs
speci fi es the edge segments and s the cor respondi ng parameter val ues. bs can
be a scal ar. The par ameter s shoul d be approxi matel y proporti onal to the curve
l ength. Al l mi ni mal regi ons shoul d have at l east two, and preferabl y thr ee,
edge segments i n thei r boundary.
Examples The functi on car dg defi nes the geometry of a cardi oi d
r = 2(1+cos()).
f unct i on [ x, y] =c ar dg( bs , s )
%CARDG Ge ome t r y Fi l e de f i ni ng t he ge omet r y of a c ar di oi d.
nbs =4;
i f nar gi n==0
x =nbs ;
r et ur n
e nd
dl =[ 0 pi /2 pi 3*pi /2
pi /2 pi 3*pi /2 2*pi ;
1 1 1 1
0 0 0 0] ;
i f nar gi n==1
x =dl ( : , bs ) ;
r et ur n
e nd
x =z er os ( s i z e ( s ) ) ;
y =z er os ( s i z e ( s ) ) ;
[ m, n] =s i z e ( bs ) ;
i f m==1 n==1,
bs =bs *ones ( s i z e( s ) ) ; e xpand bs
e l s ei f m =s i z e ( s , 1) n =s i z e( s , 2) ,
e r r or ( ' bs mus t be s c al ar or of s ame s i z e as s ' ) ;
e nd
pdegeom
5-59
nt h=400;
t h=l i ns pace ( 0, 2*pi , nt h) ;
r =2*( 1+cos ( t h) ) ;
x t =r . *c os ( t h) ;
y t =r . *s i n( t h) ;
t h=pdear c l ( t h, [ x t ; yt ] , s , 0, 2*pi ) ;
r =2*( 1+cos ( t h) ) ;
x ( : ) =r . *c os ( t h) ;
y ( : ) =r . *s i n( t h) ;
We use the functi on pdear c l to make the par ameter s proporti onal to ar c
l ength. You can test the functi on by typi ng:
pde gpl ot ( ' car dg' ) , ax i s e qual
[ p, e, t ] =i ni t me s h( ' car dg' ) ;
pde me s h( p, e, t ) , ax i s equal
Then sol ve the PDE probl em on the geometr y defi ned by the the
cardi oi d. Use Di r i chl et boundar y condi ti ons u = 0 on . Fi nal l y pl ot the
sol uti on.
u=as s empde ( ' car db' , p, e, t , 1, 0, 1) ;
pde s ur f ( p, t , u) ;
Cautionary The parameter s shoul d be approxi matel y pr opor ti onal to the curve l ength. Al l
mi ni mal r egi ons shoul d have at l east two, and preferabl y thr ee, edge segments
i n thei r boundary.
See Also i ni t mes h, r ef i ne me s h, pde ar cl
u 1 =

pdegplot
5-60
pdegpl ot
Purpose Pl ot a PDE geometr y.
Synopsis pde gpl ot ( g)
h=pde gpl ot ( g)
Description pde gpl ot ( g) pl ots the geometr y of a PDE pr obl em.
h=pde gpl ot ( g) r etur ns handl es to the pl otted axes objects.
g descr i bes the geometry of the PDE pr obl em. g can ei ther be a Decomposed
Geometr y matri x or the name of a Geometr y M-fi l e. The for mats of the
Decomposed Geometr y matr i x and Geometry M-fi l e are descri bed i n the entr i es
on de cs g and pde ge om, r especti vel y.
Examples Pl ot the geometry of the L-shaped membr ane
pde gpl ot ( ' l s hape g' )
See Also pde ge om
pdegrad
5-61
pdegr ad
Purpose The gradi ent of a PDE sol uti on.
Synopsis [ ux , uy] =pde gr ad( p, t , u)
[ ux , uy] =pde gr ad( p, t , u, s dl )
Description [ ux , uy] =pde gr ad( p, t , u) r etur ns the gr adi ent of u eval uated at the center of
each tri angl e.
Row i fr om 1 to N of ux contai ns
row i fr om 1 to N of uy contai ns
There i s one col umn for each tri angl e i n t i n both ux and uy.
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t. Detai l s
on the mesh data repr esentati on can be found i n the entr y on i ni t me s h.
The for mat for the sol uti on vector u i s descri bed i n as s e mpde.
The opti onal ar gument s dl restr i cts the computati on to the subdomai ns i n the
l i st s dl .
See Also as s empde
u
i
x
-------
u
i
y
-------
pdeintrp
5-62
pdei ntr p
Purpose I nter pol ate fr om node data to tri angl e mi dpoi nt data.
Synopsis ut =pdei nt r p( p, t , un)
Description ut =pdei nt r p( p, t , un) gi ves l i nearl y i nter pol ated val ues at tri angl e mi dpoi nts
from the val ues at node poi nts.
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t. Detai l s
on the mesh data repr esentati on can be found i n the entry on i ni t mes h.
Let N be the di mensi on of the PDE system, n
p
the number of node poi nts, and
n
t
the number of tr i angl es. The components of the node data ar e stored i n un
ei ther as N col umns of l ength n
p
or as an ordi nary sol uti on vector . The fi rst n
p

val ues of un descr i be the fi rst component, the fol l owi ng n
p
val ues of un descr i be
the second component, and so on. The components of triangle data are stored
i n ut as N r ows of l ength n
t
.
Cautionary pde pr t ni and pdei nt r p are not i nver se functi ons. The i nterpol ati on i ntr oduces
some averagi ng.
See Also as s empde, i ni t me s h, pde pr t ni
pdejmps
5-63
pdejmps
Purpose Err or esti mates for adapti on.
Synopsis er r f =pdej mps ( p, t , c , a, f , u, al f a, bet a, m)
Description er r f =pdej mps ( p, t , c , a, f , u, al f a, bet a, m) cal cul ates the err or i ndi cati on
functi on used for adapti on. The col umns of e r r f cor respond to tri angl es, and
the rows corr espond to the di fferent equati ons i n the PDE system.
p and t are mesh data. See the entry on i ni t mes h for detai l s.
c, a, and f ar e PDE coeffi ci ents. See the entr y on as s e mpde for detai l s. c , a,
and f must be expanded, so that col umns cor respond to tri angl es.
u i s the sol uti on vector . See the entry on as s empde for detai l s.
The for mul a for computi ng the er ror i ndi cator E(K) for each tri angl e K i s
where n

i s the uni t nor mal of edge and the braced term i s the jump i n fl ux
across the el ement edge. The norm i s an L
2
nor m computed over the el ement
K. The er ror i ndi cator i s stor ed i n er r f as col umn vectors, one for each tr i angl e
i n t . More i nformati on can be found i n the secti on Adapti ve Mesh Refi nement
on page 4-26.
See Also adapt me s h, pde adgs c, pdeadwor s t
E K ( ) h f au ( )
K
=
1
2
--- h

2
n

[ c u
h
( ) ]
2



1 2
+ ,
pdemdlcv
5-64
pdemdl cv
Purpose Conver t PDE Tool box 1.0 Model M-fi l es to PDE Tool box 1.0.2 format.
Synopsis pde mdl c v( i nf i l e, out f i l e)
Description pde mdl c v( i nf i l e, out f i l e) conver ts the PDE Tool box 1.0 Model -fi l e i nf i l e
to a PDE Tool box 1.0.2 compati bl e Model M-fi l e. The r esul ti ng M-fi l e i s saved
as out f i l e . I f the . m extensi on i s mi ssi ng i n out f i l e , i t i s added automati cal l y.
I f you want to use Model M-fi l es gener ated usi ng PDE Tool box 1.0, they must
fi rst be converted usi ng pde mdl c v .
Example pde dmdl cv ( model 42. m , mode l 5. m ) conver ts the PDE Tool box 1.0 Model
M-fi l e mode l 42. m and saves the converted model i n model 5. m.
pdemesh
5-65
pdemesh
Purpose Pl ot a PDE tr i angul ar mesh.
Synopsis pde me s h( p, e , t )
pde me s h( p, e , t , u)
h=pde me s h( p, e , t )
h=pde me s h( p, e , t , u)
Description pde me s h( p, e , t ) pl ots the mesh speci fi ed by the mesh data p, e, and t .
h=pde me s h( p, e , t ) addi ti onal l y returns handl es to the pl otted axes objects.
pde me s h( p, e , t , u) pl ots PDE node or tr i angl e data u usi ng a mesh pl ot. I f u i s
a col umn vector , node data i s assumed. I f u i s a row vector, tri angl e data i s
assumed. Thi s command pl ots substanti al l y faster than the pdes ur f command.
The geometr y of the PDE probl em i s gi ven by the mesh data p, e , and t . Detai l s
on the mesh data repr esentati on can be found i n the entr y on i ni t me s h.
Thi s command i s just shorthand for the cal l s
pde pl ot ( p, e, t )
pde pl ot ( p, e, t , ' z dat a' , u)
I f you want to have mor e control over your mesh pl ot, use pde pl ot i nstead of
pde me s h.
Examples Pl ot the mesh for the geometry of the L-shaped membrane.
[ p, e, t ] =i ni t me s h( ' l s hapeg' ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e, t ) ;
pde me s h( p, e, t )
Now sol ve Poi ssons equati on u = 1 over the geometry defi ned by the
L-shaped membrane. Use Di ri chl et boundary condi ti ons u = 0 on , and pl ot
the resul t.
u=as s empde ( ' l s hape b' , p, e, t , 1, 0, 1) ;
pde me s h( p, e, t , u)
See Also pde pl ot , pdec ont , pdes ur f

pdenonlin
5-66
pden onl i n
Purpose Sol ve nonl i near PDE pr obl em.
Synopsis [ u, r e s ] =pde nonl i n( b, p, e, t , c , a, f )
[ u, r e s ] =pde nonl i n( b, p, e, t , c , a, f , ' Pr ope r t yName' ,
' Pr oper t y Val ue ' , . . . )
Description [ u, r e s ] =pde nonl i n( b, p, e, t , c , a, f ) sol ves the nonl i near PDE scal ar PDE
probl em
(cu) + au = f on ,
or the nonl i near system PDE probl em
(c u) + au = f on ,
where the coeffi ci ents c, a, and f may depend on u. The al gori thm sol ves the
equati on by usi ng damped Newton i terati on wi th the Ar mi jo-Gol dstei n l i ne
sear ch strategy.
The sol uti on u i s r epresented as the sol uti on vector u. Detai l s on the
repr esentati on of the sol uti on vector can be found i n the entry on as s e mpde . r es
i s the nor m of the Newton step resi dual s.
The tr i angul ar mesh of the PDE pr obl em i s gi ven by the mesh data p, e , and t .
Detai l s on the mesh data r epr esentati on can be found i n the entry on i ni t mes h.
b descr i bes the boundary condi ti ons of the PDE pr obl em. b can be ei ther a
Boundary Condi ti on matr i x or the name of a Boundar y M-fi l e. The for mats of
the Boundary Condi ti on matr i x and Boundary M-fi l e are descr i bed i n the
entr i es on as s e mb and pdebound, respecti vel y, respecti vel y. Note that for the
gener al cal l to pdebound the boundary condi ti ons can al so depend on u. A
fi xed-poi nt i ter ati on str ategy i s empl oyed to sol ve for the nonl i near boundar y
condi ti ons.
The coeffi ci ents c, a, f of the PDE probl em can be gi ven i n a wi de vari ety of
ways. I n the context of pdenonl i n the coeffi ci ents can depend on u. The
coeffi ci ents cannot depend on t , the ti me. A compl ete l i sti ng of al l format
opti ons can be found i n the entr y on as s e mpde .
pdenonlin
5-67
The sol ver can be fi ne-tuned by setti ng some of the opti ons descr i bed bel ow:
There are three methods cur rentl y i mpl emented to compute the Jacobi an:
Numeri cal eval uati on of the ful l Jacobi an based on the spar se ver si on of the
functi on numj ac
A l umped appr oxi mati on descr i bed i n Chapter 4, "The Fi ni te El ement
Method" based on the numer i cal di fferenti ati on of the coeffi ci ents
A fi xed-poi nt i ter ati on matri x where the Jacobi an i s approxi mated by the
sti ffness matri x
Sel ect the desi r ed method by setti ng the Jacobi an property to f ul l , l umped, or
f i x ed, beari ng i n mi nd that the more pr eci se methods ar e computati onal l y
more expensi ve.
U0 i s the starti ng guess that can be gi ven as an expressi on, a gener i c scal ar, or
a vector . By defaul t i t i s set to 0, but thi s i s usel ess i n probl ems such as (1/u
u) = 0 wi th Di ri chl et boundary condi ti ons u = e
x+y
. Tol fi xes the exi t cr i teri on
from the Gauss-Newton i ter ati on, i .e., the i ter ati ons ar e termi nated when the
resi dual norm i s l ess then Tol . The norm i n whi ch the r esi dual i s computed i s
sel ected through Nor m. Thi s can be any admi ssi bl e MATLAB vector norm or
ene r gy for the energy norm.
Property Name Property Value Default Description
Jacobi an fi xe d| l umped| f ul l f i xe d Approxi mati on of Jacobi an
U0 stri ng or numer i c 0 I ni ti al sol uti on guess
Tol posi ti ve scal ar 1e 4 Resi dual si ze at ter mi nati on
MaxI t e r posi ti ve i nteger 25 Maxi mum Gauss-Newton
i terati ons
Mi nSt e p posi ti ve scal ar 1/2^16 Mi ni mum dampi ng of search
di recti on
Re por t on| of f of f Pri nt conver gence i nformati on
Nor m stri ng or numer i c I nf Resi dual norm
pdenonlin
5-68
Max I t er and Mi nSt e p are safeguards agai nst i nfi ni te Gauss-Newton l oops and
they bound the number of i ter ati ons and the step si ze used i n each i terati on.
Setti ng Re por t to on forces pr i nti ng of conver gence i nformati on.
Diagnostics I f the Newton i terati on does not converge, the err or message Too many
i t e r at i ons or St eps i z e t oo s mal l i s di spl ayed. I f the i ni ti al guess pr oduces
matr i ces contai ni ng NaN or I nf el ements, the er ror message Uns ui t abl e
i ni t i al gue s s U0 ( de f aul t : U0=0) i s pri nted.
See Also as s empde, pdebound
pdeplot
5-69
pdepl ot
Purpose Gener i c PDE Tool box pl ot functi on.
Synopsis pde pl ot ( p, e , t , ' Pr ope r t yName ' , Pr oper t y Val ue , )
h=pde pl ot ( p, e , t , ' Pr ope r t yName ' , Pr oper t yVal ue , )
Description pde pl ot ( p, e , t , p1, v 1, . . . ) i s the generi c PDE Tool box pl ot functi on. I t can
di spl ay several functi ons of a PDE sol uti on at the same ti me.
The geometr y of the PDE probl em i s gi ven by the mesh data p, e , and t . Detai l s
on the mesh data repr esentati on can be found i n the entr y on i ni t me s h.
Val i d property/val ue pai r s i ncl ude:
Property Name Property Value/ Default Description
x ydat a data Tri angl e data
x ys t y l e of f | f l at | {i nt e r p} x-y data pl ot styl e
c ont our {off}| on Show contours
z dat a data Node or tr i angl e data
z s t yl e of f | {cont i nuous }|
di s cont i nuous
3-D hei ght pl otstyl e
f l owdat a data Node or tr i angl e data
f l ows t y l e of f | {ar r ow} Fl ow pl ot styl e
c ol or map col or map cool x-y data col or map name or col ormap matr i x
x ygr i d {of f }| on Conver t to x-y gri d before pl otti ng
gr i dpar am [tn; a2; a3] Tri angl e i ndex and i nterpol ati on par ameters
from earl i er cal l to t r i 2gr i d
mes h {of f }| on Show mesh i n pl ot
c ol or bar of f | {on} Show col orbar
t i t l e Pl ot ti tl e text
l ev el s 10 Number of l evel s or a vector speci fyi ng l evel s
pdeplot
5-70
The pde pl ot i s used both fr om i nsi de the pdet ool GUI and fr om the command
l i ne. I t i s abl e to di spl ay three enti ti es si mul taneousl y. xy dat a can be
vi sual i zed by a surface pl ot. Ei ther fl at or i nter pol ated (defaul t) shadi ng can be
used for the surface pl ots. A contour pl ot can be superi mposed on the sur face
pl ot (i n bl ack) or pl otted i ndependentl y (i n col or s) by setti ng cont our to on.
z dat a i s vi sual i zed by di spl ayi ng hei ght. The tri angl es can be ei ther ti l ted by
i nterpol ati on (defaul t) or fl at. Fl ow data can be vi sual i zed by pl otti ng ar rows
l i ke the MATLAB qui v er pl ot. Al l data types can be ei ther node data or tri angl e
data (fl ow data can onl y be tr i angl e data). Node data i s represented by a
col umn vector of l ength s i z e( p, 2) and triangle data i s represented by a row
vector of l ength s i z e( t , 2) . I f no x ydat a, z dat a, or f l owdat a i s suppl i ed,
pde pl ot pl ots the mesh speci fi ed by p, e , and t .
The opti on me s h di spl ays or hi des (defaul t) the tr i angl e mesh i n the pl ot. The
opti on xy gr i d fi rst conver ts the data to x-y data (usi ng t r i 2gr i d), and then
uses a standar d MATLAB pl otti ng al gor i thm. The pr oper ty gr i dpar am passes
the t r i 2gr i d data to pdepl ot . Thi s speeds up ani mati on (see pdedemo5 and
pde de mo6). The property col or map r enders the pl ot usi ng any MATLAB
col or map or col or matri x. col or bar adds a col or bar to the pl ot. t i t l e i nserts a
ti tl e i nto the pl ot. l ev e l s onl y appl i es to contour pl ots: Gi ven a scal ar i nteger
val ue, i t pl ots that number of equal l y spaced contour l evel s; gi ven a vector of
l evel val ues, i t pl ots that contour l i nes on the l evel s i n the vector .
h=pde pl ot ( p, t , u) addi ti onal l y returns handl es to the drawn axes objects.
Examples The command sequence bel ow pl ots the sol uti on to Poi sson' s equati on on the
L-shaped membrane i n 3-D.
[ p, e, t ] =i ni t me s h( ' l s hapeg' ) ;
u=as s empde ( ' l s hape b' , p, e, t , 1, 0, 1) ;
pde pl ot ( p, e, t , ' x ydat a' , u, ' z dat a' , u, ' me s h' , ' of f ' ) ;
See Also pde cont , pde gpl ot , pdemes h, pde s ur f
pdepoly
5-71
pdepol y
Purpose Dr aw pol ygon.
Synopsis pde pol y ( x , y )
pde pol y ( x , y , l abe l )
Description pde pol y ( x , y ) draws a pol ygon wi th corner coordi nates defi ned by x and y . I f
the pde t ool GUI i s not acti ve, i t i s automati cal l y started, and the pol ygon i s
drawn i n an empty geometr y model .
The opti onal argument l abel assi gns a name to the pol ygon (otherwi se a
defaul t name i s chosen).
The state of the Geometr y Descri pti on matri x i nsi de pdet ool i s updated to
i ncl ude the pol ygon. You can export the Geometry Descr i pti on matr i x from
pde t ool by usi ng the Export Geometry Description . . . opti on from the Draw
menu. The for mat of the Geometry Descri pti on matr i x i s descri bed i n the entry
on de cs g.
Examples The command
pde pol y ( [ 1 0 0 1 1 1] , [ 0 0 1 1 1 1] ) ;
cr eates the L-shaped membrane geometr y as one pol ygon.
See Also pde ci r c , pder ect, pdet ool
pdeprtni
5-72
pdeprtni
Purpose I nter pol ate fr om tr i angl e mi dpoi nt data to node data.
Synopsis un=pdepr t ni ( p, t , ut )
Description un=pdepr t ni ( p, t , ut ) gi ves l i nearl y i nterpol ated val ues at node poi nts fr om
the val ues at tri angl e mi dpoi nts.
The geometry of the PDE pr obl em i s gi ven by the mesh data p and t. Detai l s
on the mesh data repr esentati on can be found i n the entry on i ni t mes h.
Let N be the di mensi on of the PDE system, n
p
the number of node poi nts, and
n
t
the number of tr i angl es. The components of tr i angl e data i n ut ar e stored as
N r ows of l ength n
t
. The components of the node data ar e stor ed i n un as N
col umns of l ength n
p
.
Cautionary pde pr t ni and pdei nt r p are not i nver se functi ons. The i nterpol ati on i ntr oduces
some averagi ng.
See Also as s empde, i ni t me s h, pde i nt r p
pderect
5-73
pder ect
Purpose Dr aw rectangl e.
Synopsis pde r e ct ( x y)
pde r e ct ( x y, l abe l )
Description pde r e ct ( x y) draws a rectangl e wi th cor ner coor di nates defi ned by xy =[ xmi n
xmax y mi n y max ] . I f the pdet ool GUI i s not acti ve, i t i s automati cal l y started,
and the rectangl e i s dr awn i n an empty geometry model .
The opti onal argument l abel assi gns a name to the r ectangl e (other wi se a
defaul t name i s chosen).
The state of the Geometr y Descri pti on matri x i nsi de pdet ool i s updated to
i ncl ude the rectangl e. You can export the Geometr y Descr i pti on matri x from
pde t ool by sel ecti ng the Export Geometry Description . . . opti on from the
Draw menu. The format of the Geometr y Descri pti on matr i x i s descr i bed i n the
entr y on de cs g.
Examples The command sequence bel ow star ts pde t ool and dr aws the L-shaped
membrane as the uni on of thr ee squares.
pde r e ct ( [ 1 0 1 0] )
pde r e ct ( [ 0 1 1 0] )
pde r e ct ( [ 0 1 0 1] )
See Also pde ci r c , pdee l l i p, pde pol y, pde t ool
pdesdp, pdesde, pdesdt
5-74
pdesdp, pdesde, pdesdt
Purpose I ndi ces of poi nts/edges/tr i angl es i n a set of subdomai ns.
Synopsis c =pde s dp( p, e, t )
[ i , c] =pde s dp( p, e , t )
c =pde s dp( p, e, t , s dl )
[ i , c] =pde s dp( p, e , t , s dl )
i =pde s dt ( t )
i =pde s dt ( t , s dl )
i =pde s de( e)
i =pde s de( e, s dl )
Description [ i , c] =pde s dp( p, e , t , s dl ) gi ven mesh data p, e, and t and a l i st of subdomai n
numbers s dl , the functi on returns al l poi nts bel ongi ng to those subdomai ns. A
poi nt can bel ong to several subdomai ns, and the poi nts bel ongi ng to the
domai ns i n s dl are di vi ded i nto two di sjoi nt sets. i contai ns i ndi ces of the
poi nts that whol l y bel ong to the subdomai ns l i sted i n s dl , and c l i sts poi nts
that al so bel ongs to the other subdomai ns.
c =pde s dp( p, e, t , s dl ) retur ns i ndi ces of poi nts that bel ong to mor e than one of
the subdomai ns i n s dl .
i =pde s dt ( t , s dl ) gi ven tr i angl e data t and a l i st of subdomai n numbers s dl ,
i contai ns i ndi ces of the tri angl es i nsi de that set of subdomai ns.
i =pde s de( e, s dl ) gi ven edge data e, i t extr acts i ndi ces of outer boundar y edges
of the set of subdomai ns.
I f s dl i s not gi ven, a l i st of al l subdomai ns i s assumed.
pdesmech
5-75
pdesmech
Purpose Cal cul ate structural mechani cs tensor functi ons.
Synopsis ux =pdes me ch( p, t , c, u, ' Pr ope r t y Name ' , Pr ope r t yVal ue , . . . )
Description ux =pdes me ch( p, t , c, u, p1, v 1, . . . ) r etur ns a tensor expressi on eval uated at
the center of each tri angl e. The tensor expr essi ons are stresses and str ai ns for
str uctur al mechani cs appl i cati ons wi th pl ane str ess or pl ane strai n condi ti ons.
pde s mec h i s i ntended to be used for postprocessi ng of a sol uti on computed usi ng
the str uctur al mechani cs appl i cati on modes of the pdet ool GUI , after
exporti ng the sol uti on, the mesh, and the PDE coeffi ci ents to the MATLAB
mai n wor kspace. Poi ssons r ati o, nu, has to be suppl i ed expl i ci tl y for
cal cul ati ons of shear str esses and strai ns, and for the von Mi ses effecti ve str ess
i n pl ane strai n mode.
Val i d property name/pr oper ty val ue pai rs i ncl ude:
The avai l abl e tensor expressi ons ar e
ux =
uy =
vx =
vy =
ex x, the x-di r ecti on strai n (
x
)
ey y, the y-di r ecti on strai n (
y
)
ex y, the shear strai n (
xy
)
Property Name Property Value/ Default Description
t e ns or ux| uy | v x | v y| ex x| ey y | e xy | s xx | s y y| s x y| e1|
e 2| s 1| s 2| {v on Mi s es }
Tensor expressi on
appl i cat i on {ps }| pn Pl ane stress| pl ane str ai n
nu scal ar or stri ng expressi on {0. 3} Poi ssons r ati o
u
x
------
u
y
------
v
x
-----
v
y
-----
pdesmech
5-76
s x x, the x-di r ecti on stress (
x
)
s y y, the y-di r ecti on stress (
y
)
s x y, the shear stress (
xy
)
e1, the fi rst pr i nci pal str ai n (
1
)
e2, the second pr i nci pal str ai n (
2
)
s 1, the fi rst pr i nci pal str ess (
1
)
s 2, the second pr i nci pal str ess (
2
)
von Mi s e s , the von Mi ses effecti ve stress ( for pl ane stress
condi ti ons, or for pl ane strai n
condi ti ons).
Examples Assumi ng that a probl em has been sol ved usi ng the appl i cati on mode
Structural Mechani cs, Pl ane Str ess, di scussed i n Str uctur al Mechani cs -
Pl ane Str ess on page 2-36, and that the sol uti on u, the mesh data p and t, and
the PDE coeffi ci ent c al l have been exported to the MATLAB mai n wor kspace,
the x-di recti on str ai n i s computed as
s x=pdes mec h( p, t , c, u, ' t e ns or ' , ' s x x' ) ;
To compute the von Mi ses effecti ve stress for a pl ane strai n probl em wi th
Poi ssons rati o equal to 0.3, type
mi s es =pde s mec h( p, t , c , u, ' t ens or ' , ' von Mi s e s ' , . . .
' appl i c at i on' , ' pn' , ' nu' , 0. 3) ;

1
2

2
2

2
+

1
2

2
2
+ ( ) v
2
v 1 + ( )
1

2
2v
2
2v 1 ( )
pdesurf
5-77
pdesur f
Purpose Shor thand command for surface pl ot.
Synopsis pde s ur f ( p, t , u)
Description pde s ur f ( p, t , u) pl ots a 3-D sur face of PDE node or tr i angl e data. I f u i s a
col umn vector, node data i s assumed, and conti nuous styl e and i nterpol ated
shadi ng ar e used. I f u i s a r ow vector , tri angl e data i s assumed, and
di sconti nuous styl e and fl at shadi ng ar e used.
h=pde s ur f ( p, t , u) addi ti onal l y returns handl es to the drawn axes objects.
For node data, thi s command i s just shor thand for the cal l
pde pl ot ( p, [ ] , t , ' xy dat a' , u, ' xy s t yl e' , ' i nt er p' , . . .
' z dat a' , u, ' z s t yl e' , ' cont i nuous ' , ' col or bar ' , ' of f ' ) ;
and for tri angl e data i t i s
pde pl ot ( p, [ ] , t , ' xy dat a' , u, ' xy s t yl e' , ' f l at ' , . . .
' z dat a' , u, ' z s t yl e' , ' di s c ont i nuous ' , ' c ol or bar ' , ' of f ' ) ;
I f you want to have more contr ol over your surface pl ot, use pdepl ot i nstead of
pde s ur f .
Examples Surface pl ot of the sol uti on to the equati on u = 1 over the geometr y defi ned
by the L-shaped membrane. Use Di ri chl et boundar y condi ti ons u = 0 on .
[ p, e, t ] =i ni t me s h( ' l s hapeg' ) ;
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e, t ) ;
u=as s empde ( ' l s hape b' , p, e, t , 1, 0, 1) ;
pde s ur f ( p, t , u)
See Also pde pl ot , pdec ont , pdeme s h

pdetool
5-78
pdetool
Purpose PDE Tool box graphi cal user i nter face (GUI ).
Synopsis pde t ool
pde t ool ( act i on, f l ag)
Description pde t ool provi des the gr aphi cal user i nter face (GUI ) for the PDE Tool box. Cal l
pde t ool wi thout arguments to start the appl i cati on. You shoul d not cal l
pde t ool wi th ar guments.
The GUI hel ps you to draw the 2-D domai n and to defi ne boundar y condi ti ons
for a PDE pr obl em. I t al so makes i t possi bl e to speci fy the par ti al di ffer enti al
equati on, to cr eate, i nspect and refi ne the mesh, and to compute and di spl ay
the sol uti on from the GUI .
pde t ool contai ns sever al di ffer ent modes:
I n Draw mode, you constr uct a Constructive Solid Geometry model (CSG
model ) of the geometry. You can draw solid objects that can over l ap. There ar e
four types of sol i d objects:
Circle object repr esents the set of poi nts i nsi de a ci r cl e.
Polygon object r epresents the set of poi nts i nsi de the pol ygon gi ven
by a set of l i ne segments.
Rectangle object represents the set of poi nts i nsi de the rectangl e gi ven
by a set of l i ne segments.
Ellipse object represents the set of poi nts i nsi de an el l i pse. The el l i pse
can be rotated.
The sol i d objects can be moved and rotated. Operati ons appl y to groups of
objects by doi ng mul ti pl e sel ects. (A Select all opti on i s al so avai l abl e.) You can
cut and paste among the sel ected objects. The model can be saved and restor ed.
pde t ool can be star ted by just typi ng the name of the model . (Thi s star ts the
cor respondi ng M-fi l e that contai ns the MATLAB commands necessar y to cr eate
the model .)
The sol i d objects can be combi ned by typi ng a set for mul a. Each object i s
automati cal l y assi gned a uni que name, whi ch i s di spl ayed i n the GUI on the
sol i d object i tsel f. The names refer to the object i n the set formul a. Mor e
speci fi cal l y, i n the set formul a, the name r efer s to the set of poi nts i nsi de the
object. The resul ti ng geometr i cal model i s the set of poi nts for whi ch the set
pdetool
5-79
formul a eval uates to tr ue. (For a descri pti on of the syntax of the set for mul a,
see dec s g.) By defaul t, the resul ti ng geometri cal model i s the uni on of al l
objects.
A snap-to-gri d functi on i s avai l abl e. Thi s means that objects al i gn to the gri d.
The gr i d can be turned on and off, and the scal i ng and the gr i d spaci ng can be
changed.
I n boundary mode, you can speci fy the boundary condi ti ons. You can have
di ffer ent types of boundar y condi ti ons on di ffer ent boundari es. I n thi s mode,
the ori gi nal shapes of the sol i d bui l di ng objects consti tute bor der s between
subdomai ns of the model . Such bor ders can be el i mi nated i n thi s mode. The
outer boundari es ar e col or coded to i ndi cate the type of boundary condi ti ons. A
red outer boundary corr esponds to Di ri chl et boundar y condi ti ons, bl ue to
gener al i zed Neumann boundar y condi ti ons, and gr een to mi xed boundary
condi ti ons. You can r etur n to the boundary condi ti on di spl ay by cl i cki ng on the
button or by sel ecti ng Boundary Mode fr om the Boundary menu.
I n PDE mode, you can speci fy the type of PDE probl em, and the coeffi ci ents c,
a, f, and d. You may speci fy the coeffi ci ents for each subdomai n i ndependentl y.
Thi s makes i t easy to speci fy, e.g., var i ous mater i al properti es i n one PDE
model . The PDE to be sol ved can be speci fi ed by cl i cki ng on the PDE button or
by sel ecti ng PDE Specification . . . from the PDE menu. Thi s br i ngs up a
di al og box.
I n Mesh mode, you can contr ol the automated mesh gener ati on and pl ot the
mesh. An i ni ti al mesh can be gener ated by cl i cki ng on the button or by
sel ecti ng Initialize Mesh from the Mesh menu. The i ni ti al mesh can be
repeatedl y refi ned by cl i cki ng on the r efi ne button or by sel ecti ng Refine Mesh
from the Mesh menu.
I n Solve mode, you can speci fy sol ve parameter s and sol ve the PDE. For
parabol i c and hyper bol i c PDE probl ems, you can al so speci fy the i ni ti al
condi ti ons, and the ti mes at whi ch the output shoul d be gener ated. For
ei genval ue pr obl ems, the sear ch range can be speci fi ed. Al so, the adapti ve and
nonl i near sol vers for el l i pti c PDEs can be i nvoked. The PDE pr obl em i s sol ved
by cl i cki ng on the = button or by sel ecti ng Solve PDE fr om the Solve menu. By
defaul t, the sol uti on i s pl otted i n the pde t ool axes.

pdetool
5-80
I n Plot mode you can sel ect a wi de vari ety of vi sual i zati on methods such as
surface, mesh, contour, and qui ver (vector fi el d) pl ots. For sur face pl ots, you
can choose between i nterpol ated and fl at render i ng schemes. The mesh can be
hi dden i n al l pl ot types. For par abol i c and hyperbol i c equati ons, you can
ani mate the sol uti on as i t changes wi th ti me. You can show the sol uti on both
i n 2-D and 3-D. 2-D pl ots are shown i nsi de pde t ool . 3-D pl ots are pl otted i n
separ ate fi gure wi ndows. Di ffer ent types of pl ots can be sel ected by cl i cki ng on
the button wi th the sol uti on pl ot i con or by sel ecti ng Parameters . . . fr om the
Plot menu. Thi s opens a di al og box.
Boundary Condition Dialog Box
I n thi s di al og box, the boundar y condi ti on for the sel ected boundar i es i s
enter ed.The fol l owi ng boundar y condi ti ons can be handl ed:
Dirichlet: hu =r on the boundary.
Generalized Neumann: (cu) + qu =g on the boundar y.
Mixed: a combi nati on of Di ri chl et and gener al i zed Neumann condi ti on.
i s the outward uni t l ength normal .
The boundar y condi ti ons can be entered i n a vari ety of ways. See the entry on
as s emb and the Boundary Menu on page 3-15.
PDE Specification Dialog Box
I n thi s di al og box, the type of PDE and the PDE coeffi ci ents ar e enter ed. The
fol l owi ng types of PDEs can be handl ed:
El l i pti c PDE: (cu) + au = f
Parabol i c PDE: (cu) + au = f
Hyper bol i c PDE: (cu) + au = f
Ei genval ue PDE: (cu) + au = du
for x and y on the pr obl ems 2-D domai n .
The PDE coeffi ci ents can be entered i n a vari ety of ways. See the entry on
as s empde and the PDE Menu on page 3-18.
n
n
d
u
t
------
d

2
u
t
2
--------
pdetool
5-81
Model M-file
The Model M-file contai ns the MATLAB commands necessar y to create a CSG
model . I t can al so contai n addi ti onal commands to set boundary condi ti ons,
defi ne the PDE, create the mesh, sol ve the pde, and pl ot the sol uti on. Thi s type
of M-fi l e can be saved and opened fr om the File menu.
The Model M-fi l e i s a MATLAB functi on and not a scr i pt. Thi s way name
cl ashes between vari abl es used i n the functi on and i n the mai n wor kspace ar e
avoi ded. The name of the fi l e must coi nci de wi th the model name. The
begi nni ng of the fi l e al ways l ooks si mi l ar to the code fragment bel ow:
f unct i on pde mode l
pde i ni t ;
pde _f i g=gcf ;
ax=gc a;
pde t ool ( ' appl _cb' , 1) ;
s et upr op( pde _f i g, ' cur r par am' , s t r 2mat ( ' 1. 0' , ' 0. 0' , ' 10. 0' , ' 1. 0' ) ) ;
pde t ool ( ' s napon' ) ;
s et ( ax, ' As pe ct Rat i o' , [ 1. 5 1] ) ;
s et ( ax, ' XLi m' , [ 1. 5 1. 5] ) ;
s et ( ax, ' YLi m' , [ 1 1] ) ;
s et ( ax, ' XTi c kMode' , ' aut o' ) ;
s et ( ax, ' YTi c kMode' , ' aut o' ) ;
gr i d on;
The pde i ni t command starts up pde t ool . I f pdet ool has al ready been started,
the curr ent model i s cl eared. The fol l owi ng commands set up the scal i ng and
ti ck mar ks of the axi s of pde t ool and other user parameter s.
Then a sequence of drawi ng commands i s i ssued. The commands that can be
used ar e named pde ci r c , pdee l l i p, pde pol y, and pde r ec t . The command
sequence bel ow creates the L-shaped membrane as the uni on of three squares.
The sol i d objects ar e gi ven names SQ1, SQ2, SQ3, etc.
% Geome t r y des cr i pt i on:
pde r e ct ( [ 1 0 0 1] , ' SQ1' ) ;
pde r e ct ( [ 0 1 0 1] , ' SQ2' ) ;
pde r e ct ( [ 0 1 1 0] , ' SQ3' ) ;
pdetool
5-82
We do not i ntend to ful l y document the format of the Model M-fi l e. I t can be
used to change the geometr y of the dr awn objects, si nce the pdec i r c, pdee l l i p,
pde pol y , and pde r e ct commands ar e documented.
See Also i ni t mes h, as s e mpde , par abol i c , wav e, pde e i g, pdes ur f , pdec ont
pdetrg
5-83
pdetrg
Purpose Tri angl e geometry data.
Synopsis [ ar , a1, a2, a3] =pdet r g( p, t )
[ ar , g1x , g1y , g2x , g2y, g3x, g3y ] =pdet r g( p, t )
Description [ ar , a1, a2, a3] =pdet r g( p, t ) returns the area of each tri angl e i n ar and hal f of
the negati ve cotangent of each angl e i n a1, a2, and a3.
[ ar , g1x , g1y , g2x , g2y, g3x, g3y ] =pdet r g( p, t ) returns the area and the
gr adi ent components of the tr i angl e base functi ons.
The tri angul ar mesh of the PDE pr obl em i s gi ven by the mesh data p and t.
Detai l s on the mesh data r epr esentati on can be found i n the entry on i ni t mes h.
pdetriq
5-84
pdetri q
Purpose Tri angl e qual i ty measure.
Synopsis q=pde t r i q( p, t )
Description q=pde t r i q( p, t ) returns a tr i angl e qual i ty measur e gi ven mesh data.
The tri angul ar mesh i s gi ven by the mesh data p, e , and t . Detai l s on the mesh
data repr esentati on can be found i n the entr y on i ni t me s h.
The tri angl e qual i ty i s gi ven by the formul a
where a i s the ar ea and h
1
, h
2
, and h
3
the si de l engths of the tri angl e.
I f q > 0.6 the tri angl e i s of acceptabl e qual i ty. q = 1 when h
1
= h
2
= h
3
.
See Also i ni t mes h, j i ggl e me s h, r ef i nemes h
Reference Bank, Randol ph E., PLTMG: A Software Package for Solving Elliptic Partial
Differential Equations, Users Guide 6.0, Soci ety for I ndustri al and Appl i ed
Mathemati cs, Phi l adel phi a, PA, 1990.
q
4 3a
h
1
2
h
2
2
h
3
2
+ +
----------------------------- = ,
poiasma
5-85
poi asma
Purpose Boundary poi nt matri x contr i buti ons for fast sol ver s of Poi ssons equati on.
Synopsis K=poi as ma( n1, n2, h1, h2)
K=poi as ma( n1, n2)
K=poi as ma( n)
Description K=poi as ma( n1, n2, h1, h2) assembl es the contri buti ons to the sti ffness matr i x
from boundary poi nts. n1 and n2 are the number s of poi nts i n the fi r st and
second di r ecti ons, and h1 and h2 are the mesh spaci ngs. K i s a spar se
n1*n2-by-n1*n2 matr i x. The poi nt number i ng i s the canoni cal numberi ng for a
rectangul ar mesh.
K=poi as ma( n1, n2) uses h1=h2.
K=poi as ma( n) uses n1=n2=n.
See Also poi i nde x, poi s ol v
poicalc
5-86
poi cal c
Purpose Fast sol ver for Poi ssons equati on on a r ectangul ar gri d.
Synopsis u=poi cal c ( f , h1, h2, n1, n2)
u=poi cal c ( f , h1, h2)
u=poi cal c ( f )
Description u=poi cal c ( f , h1, h2, n1, n2) cal cul ates the sol uti on of Poi ssons equati on for
the i nteri or poi nts of an evenl y spaced rectangul ar gri d. The col umns of u
contai n the sol uti ons corr espondi ng to the col umns of the r i ght-hand si de f . h1
and h2 ar e the spaci ngs i n the fi r st and second di r ecti on, and n1 and n2 are the
number of poi nts.
The number of rows i n f must be n1*n2. I f n1 and n2 ar e not gi ven, the square
root of the number of rows of f i s assumed. I f h1 and h2 are not gi ven, they ar e
assumed to be equal .
The or der i ng of the r ows i n u and f i s the canoni cal or der i ng of i nteri or poi nts,
as returned by poi i ndex .
The sol uti on i s obtai ned by si ne tr ansfor ms i n the fi rst di r ecti on and
tr i di agonal matri x sol uti on i n the second di recti on. n1 shoul d be 1 l ess than a
power of 2 for best per formance.
See Also poi i nde x, poi as ma, ds t , i ds t , poi s ol v
poiindex
5-87
poi i ndex
Purpose I ndi ces of poi nts i n canoni cal order i ng for rectangul ar gri d.
Synopsis [ n1, n2, h1, h2, i , c , i i , cc ] =poi i nde x( p, e, t , s d)
Description [ n1, n2, h1, h2, i , c , i i , cc ] =poi i nde x( p, e, t , s d) i denti fi es a gi ven gr i d p, e, t
i n the subdomai n s d as an evenl y spaced rectangul ar gri d. I f the gr i d i s not
rectangul ar, n1 i s 0 on return. Other wi se n1 and n2 ar e the number of poi nts i n
the fi rst and second di recti ons, h1 and h2 ar e the spaci ngs. i and i i ar e of
l ength ( n12) *( n22) and contai n i ndi ces of i nteri or poi nts. i contai ns i ndi ces
of the or i gi nal mesh, whereas i i contai ns i ndi ces of the canoni cal or der i ng. c
and c c are of l ength n1*n2( n12) *( n22) and contai n i ndi ces of bor der
poi nts. i i and cc ar e i ncr easi ng.
I n the canoni cal orderi ng, poi nts are numbered fr om l eft to ri ght and then
from bottom to top. Thus i f n1=3 and n2=5, then i i =[ 5 8 11] and
cc =[ 1 2 3 4 6 7 9 10 12 13 14 15] .
See Also poi s ol v , poi as ma
poimesh
5-88
poi mesh
Purpose Make regul ar mesh on a rectangul ar geometry.
Synopsis [ p, e, t ] =poi me s h( g, nx , ny)
[ p, e, t ] =poi me s h( g, n)
[ p, e, t ] =poi me s h( g)
Description [ p, e, t ] =poi me s h( g, nx , ny) constr ucts a regul ar mesh on the r ectangul ar
geometr y speci fi ed by g, by di vi di ng the x edge i nto nx pi eces and the y edge
i nto ny pi eces, and pl aci ng ( nx+1) *( ny+1) poi nts at the i nter secti ons.
The x edge i s the one that makes the smal l est angl e wi th the x-axi s.
[ p, e, t ] =poi me s h( g, n) uses nx=ny =n, and [ p, e , t ] =poi me s h( g) uses nx =ny=1.
The tri angul ar mesh i s descri bed by the mesh data p, e, and t . Detai l s on the
mesh data r epr esentati on can be found i n the entry on i ni t mes h.
For best performance wi th poi s ol v , the l ar ger of nx and ny shoul d be a power
of 2.
I f g does not seem to descri be a r ectangl e, p i s zer o on r etur n.
Examples Try the demo command pdede mo8. The sol uti on of Poi ssons equati on over a
rectangul ar gr i d wi th boundary condi ti on gi ven by the fi l e s quar e b4 i s
returned. The sol uti on ti me i s compar ed to the usual FEM appr oach.
See Also i ni t mes h, poi s ol v
poisolv
5-89
poi sol v
Purpose Fast sol uti on of Poi ssons equati on on a r ectangul ar gr i d.
Synopsis u=poi s ol v ( b, p, e , t , f )
Description u=poi s ol v ( b, p, e , t , f ) sol ves Poi ssons equati on wi th Di r i chl et boundar y
condi ti ons on a r egul ar r ectangul ar gr i d. A combi nati on of si ne transforms and
tr i di agonal sol uti ons i s used for i ncr eased per for mance.
The boundar y condi ti ons b must speci fy Di ri chl et condi ti ons for al l boundary
poi nts.
The mesh p, e , and t must be a regul ar rectangul ar gri d. Detai l s on the mesh
data repr esentati on can be found i n the entr y on i ni t me s h.
f gi ves the ri ght-hand si de of Poi ssons equati on.
Apart fr om r oundoff er rors, the resul t shoul d be the same as
u=as s empde( b, p, e , t , 1, 0, f ) .
See Also poi cal c , poi me s h
Reference Str ang, Gi l bert, I ntroduction to Applied Mathematics, Wel l esl ey-Cambri dge
Press, Cambr i dge, MA, 1986, pp. 453458.
refinemesh
5-90
refi nemesh
Purpose Refi ne a tri angul ar mesh.
Synopsis [ p1, e 1, t 1] =r e f i nemes h( g, p, e , t )
[ p1, e 1, t 1] =r e f i nemes h( g, p, e , t , ' r e gul ar ' )
[ p1, e 1, t 1] =r e f i nemes h( g, p, e , t , ' l onge s t ' )
[ p1, e 1, t 1] =r e f i nemes h( g, p, e , t , i t )
[ p1, e 1, t 1] =r e f i nemes h( g, p, e , t , i t , ' r e gul ar ' )
[ p1, e 1, t 1] =r e f i nemes h( g, p, e , t , i t , ' l onges t ' )
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u)
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u, ' r e gul ar ' )
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u, ' l onges t ' )
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u, i t )
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u, i t , ' r egul ar ' )
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u, i t , ' l onge s t ' )
Description [ p1, e 1, t 1] =r e f i nemes h( g, p, e , t ) retur ns a refi ned versi on of the tr i angul ar
mesh speci fi ed by the geometry g, Poi nt matr i x p, Edge matr i x e , and Tr i angl e
matr i x t .
The tri angul ar mesh i s gi ven by the mesh data p, e , and t . Detai l s on the mesh
data repr esentati on can be found i n the entr y on i ni t me s h.
[ p1, e 1, t 1, u1] =r e f i ne me s h( g, p, e, t , u) r efi nes the mesh and al so extends
the functi on u to the new mesh by l i near i nterpol ati on. The number of r ows i n
u shoul d corr espond to the number of col umns i n p, and u1 has as many r ows
as ther e ar e poi nts i n p1. Each col umn of u i s i nterpol ated separatel y.
An extr a i nput argument i t i s i nter pr eted as a l i st of subdomai ns to r efi ne, i f
i t i s a row vector, or a l i st of tri angl es to refi ne, i f i t i s a col umn vector .
The defaul t refi nement method i s r egul ar refi nement, where al l of the speci fi ed
tr i angl es are di vi ded i nto four tri angl es of the same shape. Longest edge
refi nement, wher e the l ongest edge of each speci fi ed tri angl e i s bi sected, can be
demanded by gi vi ng l onge s t as a fi nal par ameter. Usi ng r egul ar as a fi nal
par ameter resul ts i n regul ar r efi nement. Some tr i angl es outsi de of the
speci fi ed set may al so be r efi ned, i n or der to pr eserve the tr i angul ati on and i ts
qual i ty.
refinemesh
5-91
Examples Refi ne the mesh of the L-shaped membrane sever al ti mes. Pl ot the mesh for the
geometry of the L-shaped membr ane.
[ p, e, t ] =i ni t me s h( ' l s hapeg' , ' hmax' , i nf ) ;
s ubpl ot ( 2, 2, 1) , pdeme s h( p, e , t )
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e, t ) ;
s ubpl ot ( 2, 2, 2) , pdeme s h( p, e , t )
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e, t ) ;
s ubpl ot ( 2, 2, 3) , pdeme s h( p, e , t )
[ p, e, t ] =r e f i ne me s h( ' l s hapeg' , p, e, t ) ;
s ubpl ot ( 2, 2, 4) , pdeme s h( p, e , t )
s ubpl ot
Algorithm The al gori thm i s descr i bed by the steps bel ow:
1 Pi ck the i ni ti al set of tri angl es to be r efi ned.
2 Ei ther di vi de al l edges of the sel ected tri angl es i n hal f (regul ar refi nement),
or di vi de the l ongest edge i n hal f (l ongest edge r efi nement).
3 Di vi de the l ongest edge of any tri angl e that has a di vi ded edge.
4 Repeat step 3 unti l no fur ther edges ar e di vi ded.
5 I ntroduce new poi nts of al l di vi ded edges, and repl ace al l di vi ded entri es i n
e by two new entri es.
6 Form the new tr i angl es. I f al l thr ee si des ar e di vi ded, new tri angl es ar e
formed by joi ni ng the si de mi dpoi nts. I f two si des are di vi ded, the mi dpoi nt
of the l ongest edge i s joi ned wi th the the opposi ng cor ner and wi th the other
mi dpoi nt. I f onl y the l ongest edge i s di vi ded, i ts mi dpoi nt i s joi ned wi th the
opposi ng corner .
See Also i ni t mes h, pde geom, pde s dt , pdee nt
sptarn
5-92
sptarn
Purpose Sol ve gener al i zed sparse ei genval ue pr obl em.
Synopsis [ xv , l mb, i r e s ul t ] = s pt ar n( A, B, l b, ub)
[ xv , l mb, i r e s ul t ] = s pt ar n( A, B, l b, ub, s pd)
[ xv , l mb, i r e s ul t ] = s pt ar n( A, B, l b, ub, s pd, t ol c onv )
[ xv , l mb, i r e s ul t ] = s pt ar n( A, B, l b, ub, s pd, t ol c onv , j max)
[ xv , l mb, i r e s ul t ] = s pt ar n( A, B, l b, ub, s pd, t ol c onv , j max, maxmul )
Description [ xv , l mb, i r e s ul t ] = s pt ar n( A, B, l b, ub, s pd, t ol c onv , j max, maxmul ) fi nds
ei genval ues of the pencil (A B)x = 0 i n i nterval [lb,ub]. (A matri x of l i near
pol ynomi al s A
ij
B
ij
, A B, i s cal l ed a pencil.)
A and B ar e sparse matr i ces. l b and ub ar e l ower and upper bounds for
ei genval ues to be sought. We may have l b=i nf i f al l ei genval ues to the l eft of
ub are sought, and r b=i nf i f al l ei genval ues to the ri ght of l b are sought. One
of l b and ub must be fi ni te. A nar rower i nterval makes the al gor i thm faster. I n
the compl ex case, the r eal par ts of l mb ar e compar ed to l b and ub.
x v ar e ei genvectors, or dered so that nor m( a*xv b*x v*di ag( l mb) ) i s smal l . l mb
i s the sor ted ei genval ues. I f i r e s ul t >=0 the al gori thm succeeded, and al l
ei genval ues i n the i nter val s have been found. I f i r e s ul t <0 the al gor i thm has
not yet been successful , there may be mor e ei genval ues try wi th a smal l er
i nterval .
s pd i s 1 i f the penci l i s known to be symmetr i c posi ti ve defi ni te (defaul t 0).
t ol conv i s the expected r el ati ve accuracy. Defaul t i s 100*e ps , where eps i s the
machi ne preci si on.
j max i s the maxi mum number of basi s vectors. The al gori thm needs j max*n
wor ki ng space so a smal l val ue may be justi fi ed on a smal l computer, other wi se
l et i t be the defaul t val ue j max =100. Normal l y the al gori thm stops ear l i er when
enough ei genval ues have converged.
max mul i s the number of Arnol di r uns tri ed. Must at l east be as l arge as
maxi mum mul ti pl i ci ty of any ei genval ue. I f a smal l val ue of j max i s gi ven,
many Arnol di r uns ar e necessary. The defaul t val ue i s maxmul =n, whi ch i s
needed when al l the ei genval ues of the uni t matri x ar e sought.
sptarn
5-93
Algorithm The Arnoldi algorithm wi th spectr al tr ansfor mati on i s used. The shi ft i s chosen
at ub, l b, or at a random poi nt i n i nterval (l b,ub) when both bounds are fi ni te.
The number of steps j i n the Ar nol di run depends on how many ei genval ues
ther e ar e i n the i nter val , but i t stops at j =mi n( j max, n) . After a stop, the
al gor i thm restarts to fi nd more Schur vectors i n orthogonal compl ement to al l
those al r eady found. When no more ei genval ues ar e found i n l b < l mb <= ub,
the al gor i thm stops. For smal l val ues of j max , sever al restarts may be needed
before a cer tai n ei genval ue has converged. The al gor i thm wor ks when j max i s
at l east one l arger than the number of ei genval ues i n the i nterval , but then
many r estar ts ar e needed. For l arge val ues of j max, whi ch i s the preferr ed
choi ce, mul +1 runs are needed. mul i s the maxi mum mul ti pl i ci ty of an
ei genval ue i n the i nterval .
Cautionary The al gori thm wor ks on nonsymmetri c as wel l as symmetri c penci l s, but then
accur acy i s appr oxi matel y t ol ti mes the Henri ci depar tur e fr om nor mal i ty.
The parameter s pd i s used onl y to choose between s y mmmd and col mmd when
factor i zi ng, the for mer bei ng margi nal l y better for symmetri c matri ces cl ose to
the l ower end of the spectrum.
I n case of troubl e:
I f convergence i s too sl ow, tr y (i n thi s or der of pri or i ty)
1 a smal l er i nterval l b, ub
2 a l arger j max
3 a l arger maxmul
I f factori zati on fai l s, tr y agai n wi th l b or ub fi ni te. Then shi ft i s chosen at
random and hopeful l y not at an ei genval ue. I f i t fai l s agai n, check whether
penci l may be si ngul ar.
I f i t goes on forever, there may be too many ei genval ues i n the stri p. Tr y wi th
a smal l val ue max mul =2 and see whi ch ei genval ues you get. Those you get are
sptarn
5-94
some of the ei genval ues, but a negati ve i r es ul t tel l s you that you have not
gotten them al l .
I f memory over fl ow, tr y smal l er j max.
The al gor i thm i s desi gned for ei genval ues cl ose to the real axi s. I f you want
those cl ose to the i magi nary axi s, try A=i *A.
When s pd=1, the shi ft i s at l b so that advantage i s taken of the faster
factor i zati on for symmetr i c posi ti ve defi ni te matri ces. No har m i s done, but
the executi on i s sl ower i f l b i s above the l owest ei genval ue.
See Also pde ei g
Reference Gol ub, Gene H., and Charl es F. Van Loan, Matrix Computations, 2nd edi ti on,
Johns Hopki ns Uni versi ty Press, Bal ti mor e, MD, 1989.
Saad, Yousef, Vari ati ons on Arnol di s Method for Computi ng Ei genel ements
of Large Unsymmetr i c Matri ces, Linear Algebra and its Applications, Vol 34,
1980, pp. 269295.
tri2grid
5-95
tr i 2gr i d
Purpose I nter pol ate fr om PDE tr i angul ar mesh to r ectangul ar gr i d.
Synopsis ux y =t r i 2gr i d( p, t , u, x , y )
[ ux y, t n, a2, a3] =t r i 2gr i d( p, t , u, x , y )
ux y =t r i 2gr i d( p, t , u, t n, a2, a3)
Description ux y =t r i 2gr i d( p, t , u, x , y ) computes the functi on val ues uxy over the gr i d
defi ned by the vector s x and y, from the functi on u wi th val ues on the tri angul ar
mesh defi ned by p and t. Val ues ar e computed usi ng l i near i nterpol ati on i n the
tr i angl e contai ni ng the gri d poi nt. The vectors x and y must be i ncreasi ng.
[ ux y, t n, a2, a3] =t r i 2gr i d( p, t , u, x , y ) addi ti onal l y l i sts the i ndex t n of the
tr i angl e contai ni ng each gr i d poi nt, and i nterpol ati on coeffi ci ents a2 and a3.
ux y =t r i 2gr i d( p, t , u, t n, a2, a3) , wi th t n, a2, and a3 computed i n an earl i er
cal l to t r i 2gr i d, i nter pol ates usi ng the same gri d as i n the ear l i er cal l . Thi s
var i ant i s, however, much faster i f sever al functi ons have to be i nterpol ated
usi ng the same gr i d.
For gri d poi nts outsi de of the tr i angul ar mesh, NaN i s r etur ned i n ux y, t n, a2,
and a3.
See Also i ni t mes h, r ef i ne me s h, as s empde
wbound
5-96
wbound
Purpose Wri te boundary condi ti on speci fi cati on fi l e.
Synopsis f i d=wbound( bl , mn)
Description f i d=wbound( bl , mn) wri tes a Boundary M-fi l e wi th the name [ mn, ' . m' ] . The
Boundary M-fi l e i s equi val ent to the Boundary Condi ti on matri x bl . f i d
returns 1 i f the fi l e coul dnt be wr i tten.
bl descri bes the boundar y condi ti ons of the PDE probl em. bl i s a Boundary
Condi ti on matri x. See the entry on as s emb for detai l s.
The output fi l e [ mn, ' . m' ] i s the name of a Boundar y M-fi l e. See the entry on
pde bound.
See Also dec s g, pdege om, pdebound, wge om
wgeom
5-97
wgeom
Purpose Wri te geometry speci fi cati on functi on.
Synopsis f i d=wge om( dl , mn)
Description f i d=wge om( dl , mn) wr i tes a Geometry M-fi l e wi th the name [ mn, ' . m' ] . The
Geometry M-fi l e i s equi val ent to the Decomposed Geometry matri x dl . f i d
returns 1 i f the fi l e coul dnt be wr i tten.
dl i s a Decomposed Geometr y matr i x. The for mat of the Decomposed Geometr y
matr i x i s descr i bed i n the entry on dec s g.
The output fi l e [ mn, ' . m' ] i s the name of a Geometr y M-fi l e. The Geometry
M-fi l e for mat i s descr i bed i n the entry on pde ge om.
See Also de c s g, pdegeom, wbound
I-1
Index
A
AC power el ectr omagneti cs 2-51
adapti ve mesh r efi nement 1-22, 4-26
adaptmesh 5-8
ani mati on 2-18, 3-31, 3-36
Appl i cati on command 3-11
appl i cati on modes 2-35
Ar mi jo-Gol dstei n l i ne search 4-22
Ar nol di al gori thm 5-93
assema 5-13
assemb 5-14
assembl i ng 4-7, 5-18
assempde 5-18
Axes Li mi ts command 3-11
B
Bool ean tabl e 5-30
bor der segment 5-32, 5-57
boundar y condi ti on 3-16, 4-3, 4-11, 5-14, 5-80
Boundary Condi ti on matri x 1-39, 5-14
Boundary menu 3-15
Boundary M-fi l e 1-39, 5-48
boundar y mode 1-26
boundar y segment 5-32, 5-57
C
ci r cl e sol i d 5-31
Coeffi ci ent matr i x 1-39, 5-21
Coeffi ci ent M-fi l e 1-39, 5-21
command-l i ne functi ons, usi ng 1-37, 2-4, 2-11,
2-19, 2-25, 2-28, 2-33
conducti ve medi a DC 2-55
Constructi ve Sol i d Geometry model 1-27, 1-38,
5-30, 5-78
CSG model 1-27, 1-38, 5-30, 5-78
csgchk 5-28
csgdel 5-29
cyl i ndri cal probl em 2-21
D
decomposed geometry 1-28, 1-39, 5-30
Decomposed Geometr y matri x 1-39, 5-32
decsg 5-30
Di ri chl et boundary condi ti on 4-3, 4-11
di scr ete si ne tr ansform 4-29, 5-35
domai n decomposi ti on 2-12
Dr aw menu 3-13
dr aw mode 1-26
dst 5-35
E
Edge matr i x 1-39, 5-38
Edi t menu 3-7
ei genmodes 2-32
ei genval ue equati on 4-17
ei genval ue pr obl ems 1-21, 2-27, 5-53
ei genvector matri x 5-53
el ectr ostati cs 2-43
el l i pse sol i d 5-32
el l i pti c equati on 1-3, 1-19, 4-3
el l i pti c pr obl ems 2-2
el l i pti c system 4-10
ener gy nor m 4-6
Index
I-2
F
fast sol ver 4-29, 5-89
FEM 1-18, 4-2
Fi l e menu 3-3
Fi ni te El ement Method 1-18, 4-1
G
Gauss-Newton method 4-22
Geometry Descr i pti on matr i x 1-38, 5-31
Geometry M-fi l e 1-39, 5-57
gr aphi cal user i nter face, usi ng 1-9, 1-23, 2-2, 2-8,
2-10, 2-17, 2-22, 2-23, 2-27, 2-33, 2-39,
2-44, 2-48, 2-53, 2-56, 2-59
Gr eens formul a 1-19, 4-4
Gr i d Spaci ng command 3-10
H
heat di str i buti on i n radi oacti ve rod 2-21
heat equati on 2-16, 2-57, 4-13
heat transfer 2-57
Hel mhol tzs equati on 2-6, 2-52
Hel p menu 3-37
hyper bol i c 5-36
hyper bol i c equati on 1-3, 4-16
hyper bol i c probl ems 2-23
I
i ni tmesh 5-38
J
ji ggl emesh 5-42
L
Lapl ace equati on 2-44, 2-55
L-shaped membr ane 2-27, 2-31
M
magnetostati cs 2-46
mass matr i x 4-6, 4-16
Maxwel l s equati ons 2-43, 2-46, 2-51
menus 1-24, 3-3
mesh data 1-39, 5-38
Mesh menu 3-22
mesh mode 1-27
mesh par ameters 3-23
method of l i nes 4-14
mi ni mal regi on 1-39, 5-32
mi ni mal sur face pr obl em 2-10
mi xed boundar y condi ti on 4-3, 4-11
Model M-fi l e 1-36, 5-64, 5-81
N
Name Space matri x 1-38, 5-32
Neumann boundar y condi ti on 4-3, 4-11
New command 3-3
node data 5-62, 5-70
nonl i near equati on 4-21
nonl i near pr obl em 2-10
nonl i near sol ver 1-21
O
Open command 3-4
Opti ons menu 3-9
Index
I-3
P
par abol i c 5-43
par abol i c equati on 1-3, 4-13
par abol i c probl ems 2-16
Paste command 3-8
PDE coeffi ci ents 3-19, 5-20, 5-21
PDE menu 3-18
PDE mode 1-27
PDE Speci fi cati on 3-19
pdeadgsc 5-45
pdeadworst 5-46
pdearcl 5-47
pdebound 5-48
pdecgr ad 5-50
pdeci rc 5-51
pdecont 5-52
pdeei g 5-53
pdeel l i p 5-55
pdegeom 5-57
pdegpl ot 5-60
pdegrad 5-61
pdei ntrp 5-62
pdejmps 5-63
pdemdl cv 5-64
pdemesh 5-65
pdenonl i n 5-66
pdepl ot 5-69
pdepol y 5-71
pdepr tni 5-72
pderect 5-73
pdesde 5-74
pdesdp 5-74
pdesdt 5-74
pdesmech 5-75
pdesur f 5-77
pdetool 5-78
pdetr g 5-83
pdetri q 5-84
penci l 5-92
pl ane str ai n 2-41
pl ane str ess 2-36
Pl ot menu 3-30
pl ot mode 1-27
Pl ot par ameters 3-30
poi asma 5-85
poi cal c 5-86
poi i ndex 5-87
poi mesh 5-88
Poi nt matr i x 1-39, 5-38
poi sol v 5-89
Poi sson's equati on 4-27
Poi ssons equati on 1-9, 2-2, 2-55
pol ygon sol i d 5-31
Pri nt command 3-6
R
r ectangl e sol i d 5-32
r efi nemesh 5-90
Robi n boundar y condi ti on 4-3
Rotate command 3-14
S
Save As command 3-5
scatteri ng probl em 2-6
Schur vector 4-19
set formul a 1-5, 1-11, 1-28, 1-38, 5-32
ski n effect 2-52
sol i d object 1-9, 1-27, 5-31, 5-78
sol uti on vector 1-40, 5-19
Sol ve menu 3-25
sol ve mode 1-27
sol ve parameter s 3-25
Index
I-4
sptarn 5-92
sti ff spri ngs 4-11, 5-19
sti ffness matri x 4-6, 4-16
structural mechani cs 2-36, 2-41
T
test functi on 1-19, 4-4
tool bar 1-25, 3-38
tri 2gri d 5-95
tri angl e data 5-62, 5-70
Tri angl e matri x 1-39, 5-38
tri angl e qual i ty 3-22, 5-84
V
von Mi ses effecti ve str ess 2-39, 2-42, 5-76
W
wave equati on 2-23
wbound 5-96
weak form 4-4
wgeom 5-97
Wi ndow menu 3-37

You might also like