Partial Differential Equation Toolbox documentation

Pages 936
Views 3,201
Size 6.3 MiB
Downloads 218
Partial Differential Equation Toolbox documentation

Contents

Partial Differential Equation Toolbox Product Description 1-2
Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Equations You Can Solve Using Legacy Functions . . . . . . . . 1-3
Equations You Can Solve Using Recommended Functions . 1-6
Common Toolbox Applications . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Solve 2-D PDEs Using the PDE App . . . . . . . . . . . . . . . . . . . 1-10
Visualize and Animate Solutions . . . . . . . . . . . . . . . . . . . . . . 1-11
Poisson’s Equation with Complex 2-D Geometry . . . . . . . . . 1-12
PDE App Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
Finite Element Method (FEM) Basics . . . . . . . . . . . . . . . . . . 1-26
Setting Up Your PDE
Open the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Specify Geometry Using a CSG Model . . . . . . . . . . . . . . . . . . 2-5
Select Graphical Objects Representing Your Geometry . . . . 2-7
Rounded Corners Using CSG Modeling . . . . . . . . . . . . . . . . . 2-8
Solve Problems Using Legacy PDEModel Objects . . . . . . . . 2-11
Solve Problems Using PDEModel Objects . . . . . . . . . . . . . . 2-14
Create 2-D Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Three Ways to Create 2-D Geometry . . . . . . . . . . . . . . . . . . 2-17
How to Decide on a Geometry Creation Method . . . . . . . . . 2-17
Create CSG Geometry at the Command Line . . . . . . . . . . . . 2-19
Three Elements of Geometry . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Create Basic Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Create Names for the Basic Shapes . . . . . . . . . . . . . . . . . . 2-21
Set Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Create Geometry and Remove Subdomains . . . . . . . . . . . . . 2-22
Decomposed Geometry Data Structure . . . . . . . . . . . . . . . . 2-24
Create Geometry Using a Geometry Function . . . . . . . . . . . 2-26
Required Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Geometry Function for a Circle . . . . . . . . . . . . . . . . . . . . . . 2-29
Arc Length Calculations for a Geometry Function . . . . . . . . 2-31
Geometry Function Example with Subdomains and a Hole . 2-44
Create and View 3-D Geometry . . . . . . . . . . . . . . . . . . . . . . . 2-47
Methods of Obtaining 3-D Geometry . . . . . . . . . . . . . . . . . . 2-47
Import STL File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
3-D Geometry from a Finite Element Mesh . . . . . . . . . . . . . 2-56
3-D Geometry from Point Cloud . . . . . . . . . . . . . . . . . . . . . 2-58
Functions That Support 3-D Geometry . . . . . . . . . . . . . . . . . 2-61
Put Equations in Divergence Form . . . . . . . . . . . . . . . . . . . . 2-62
Coefficient Matching for Divergence Form . . . . . . . . . . . . . . 2-62
Boundary Conditions Can Affect the c Coefficient . . . . . . . . 2-63
Some Equations Cannot Be Converted . . . . . . . . . . . . . . . . 2-64
Systems of PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-65
Scalar PDE Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-66
Specify Scalar PDE Coefficients in String Form . . . . . . . . . 2-68
Coefficients for Scalar PDEs in PDE App . . . . . . . . . . . . . . . 2-71
Specify 2-D Scalar Coefficients in Function Form . . . . . . . . 2-74
Coefficients as the Result of a Program . . . . . . . . . . . . . . . . 2-74
Calculate Coefficients in Function Form . . . . . . . . . . . . . . . 2-75
Specify 3-D PDE Coefficients in Function Form . . . . . . . . . 2-77
Solve PDE with Coefficients in Functional Form . . . . . . . . 2-79
Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-79
PDE Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-80
Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-81
Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-81
Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-82
Parabolic Solution Times . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-82
Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-82
Alternative Coefficient Syntax . . . . . . . . . . . . . . . . . . . . . . . 2-83
Enter Coefficients in the PDE App . . . . . . . . . . . . . . . . . . . . 2-85
Coefficients for Systems of PDEs . . . . . . . . . . . . . . . . . . . . . 2-93
Systems in the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-95
f Coefficient for Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-98
f Coefficient for specifyCoefficients . . . . . . . . . . . . . . . . 2-101
c Coefficient for specifyCoefficients . . . . . . . . . . . . . . . 2-104
Overview of the c Coefficient . . . . . . . . . . . . . . . . . . . . . . . 2-104
Definition of the c Tensor Elements . . . . . . . . . . . . . . . . . 2-105
Some c Vectors Can Be Short . . . . . . . . . . . . . . . . . . . . . . 2-107
Functional Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-121
c Coefficient for Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-125
c as Tensor, Matrix, and Vector . . . . . . . . . . . . . . . . . . . . 2-125
2-D Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-128
3-D Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-134
m, d, or a Coefficient for specifyCoefficients . . . . . . . . . . . 2-143
Coefficients m, d, or a . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-143
Short m, d, or a vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-144
Nonconstant m, d, or a . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-145
a or d Coefficient for Systems . . . . . . . . . . . . . . . . . . . . . . . 2-148
Coefficients a or d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-148
Scalar a or d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-149
N-Element Column Vector a or d . . . . . . . . . . . . . . . . . . . 2-149
N(N+1)/2-Element Column Vector a or d . . . . . . . . . . . . . . 2-149
N2-Element Column Vector a or d . . . . . . . . . . . . . . . . . . . 2-150
View, Edit, and Delete PDE Coefficients . . . . . . . . . . . . . . 2-151
View Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-151
Delete Existing Coefficients . . . . . . . . . . . . . . . . . . . . . . . . 2-153
Change a Coefficient Assignment . . . . . . . . . . . . . . . . . . . 2-154
Set Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-155
What Are Initial Conditions? . . . . . . . . . . . . . . . . . . . . . . . 2-155
Constant Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . 2-155
Nonconstant Initial Conditions . . . . . . . . . . . . . . . . . . . . . 2-156
View, Edit, and Delete Initial Conditions . . . . . . . . . . . . . . 2-158
View Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-158
Delete Existing Initial Conditions . . . . . . . . . . . . . . . . . . . 2-160
Change an Initial Conditions Assignment . . . . . . . . . . . . . 2-161
Solve PDEs with Initial Conditions . . . . . . . . . . . . . . . . . . . 2-162
What Are Initial Conditions? . . . . . . . . . . . . . . . . . . . . . . . 2-162
Constant Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . 2-162
Initial Conditions in String Form . . . . . . . . . . . . . . . . . . . 2-163
Initial Conditions at Mesh Nodes . . . . . . . . . . . . . . . . . . . 2-163
No Boundary Conditions Between Subdomains . . . . . . . . 2-165
Identify Boundary Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-168
Forms of Boundary Condition Specification . . . . . . . . . . . 2-170
Boundary Matrix for 2-D Geometry . . . . . . . . . . . . . . . . . . . 2-171
Boundary Matrix Specification . . . . . . . . . . . . . . . . . . . . . 2-171
One Column of a Boundary Matrix . . . . . . . . . . . . . . . . . . 2-172
Create Boundary Condition Matrices Programmatically . . 2-173
Classification of Boundary Conditions . . . . . . . . . . . . . . . . 2-177
Boundary Conditions for Scalar PDEs . . . . . . . . . . . . . . . . 2-177
Boundary Conditions for Systems of PDEs . . . . . . . . . . . . 2-177
Specify Boundary Conditions Objects . . . . . . . . . . . . . . . . . 2-179
Specify Constant Boundary Conditions . . . . . . . . . . . . . . . 2-181
Boundary Condition Parameters . . . . . . . . . . . . . . . . . . . . 2-181
Scalar Dirichlet Boundary Conditions Using u . . . . . . . . . 2-181
Scalar Neumann Boundary Conditions . . . . . . . . . . . . . . . 2-182
Dirichlet Boundary Conditions for Systems Using u and
EquationIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-182
Dirichlet Boundary Conditions for Systems Using the (r,h)
Pair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-183
Neumann Boundary Conditions for Systems . . . . . . . . . . . 2-183
Solve PDEs with Constant Boundary Conditions . . . . . . . 2-185
Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-185
Scalar Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-186
System of PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-187
Specify Nonconstant Boundary Conditions . . . . . . . . . . . . 2-190
Solve PDEs with Nonconstant Boundary Conditions . . . . 2-193
Scalar Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-194
System of PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-196
Boundary Conditions by Writing Functions . . . . . . . . . . . . 2-199
About Boundary Conditions by Writing Functions . . . . . . . 2-199
Boundary Conditions for Scalar PDE . . . . . . . . . . . . . . . . 2-199
Boundary Conditions for PDE Systems . . . . . . . . . . . . . . . 2-204
Mesh Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-211
What Is Mesh Data? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-211
Mesh Data for FEMesh . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-211
Mesh Data for [p,e,t] Triples: 2-D . . . . . . . . . . . . . . . . . . . 2-211
Mesh Data for [p,e,t] Triples: 3-D . . . . . . . . . . . . . . . . . . . 2-212
Adaptive Mesh Refinement . . . . . . . . . . . . . . . . . . . . . . . . . . 2-214
Improving Solution Accuracy Using Mesh Refinement . . . . 2-214
Error Estimate for the FEM Solution . . . . . . . . . . . . . . . . 2-215
Mesh Refinement Functions . . . . . . . . . . . . . . . . . . . . . . . 2-216
Mesh Refinement Termination Criteria . . . . . . . . . . . . . . . 2-216
Solving PDEs
Solve 2-D PDEs Using the PDE App . . . . . . . . . . . . . . . . . . . . 3-3
Structural Mechanics — Plane Stress . . . . . . . . . . . . . . . . . . . 3-7
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Structural Mechanics — Plane Strain . . . . . . . . . . . . . . . . . . 3-13
Clamped, Square Isotropic Plate With a Uniform Pressure
Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Deflection of a Piezoelectric Actuator . . . . . . . . . . . . . . . . . 3-19
Electrostatics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-33
3-D Linear Elasticity Equations in Toolbox Form . . . . . . . . 3-35
How to Express Coefficients . . . . . . . . . . . . . . . . . . . . . . . . 3-35
Summary of the Equations of Linear Elasticity . . . . . . . . . . 3-35
Conversion to Toolbox Form . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Magnetostatics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43
AC Power Electromagnetics . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50
Conductive Media DC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53
Heat Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-60
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-61
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-61
Nonlinear Heat Transfer In a Thin Plate . . . . . . . . . . . . . . . 3-64
Diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-74
Solve Poisson’s Equation on a Unit Disk . . . . . . . . . . . . . . . 3-75
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-75
Solve Poisson’s Equation Using Command-Line Functions . 3-78
Scattering Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-81
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-83
Minimal Surface Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-86
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-86
Minimal Surface Problem on the Unit Disk . . . . . . . . . . . . . 3-87
Domain Decomposition Problem . . . . . . . . . . . . . . . . . . . . . . 3-91
Heat Equation for Metal Block with Cavity . . . . . . . . . . . . . 3-95
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-95
Metal Block Using Command-Line Functions . . . . . . . . . . . 3-98
Heat Distribution in a Radioactive Rod . . . . . . . . . . . . . . . 3-102
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-103
Wave Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-104
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-104
Wave Equation Using Command-Line Functions . . . . . . . . 3-106
Eigenvalues and Eigenfunctions for the L-Shaped
Membrane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-110
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-110
Eigenvalues for the L-Shaped Membrane Using Command-Line
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-111
L-Shaped Membrane with a Rounded Corner . . . . . . . . . . 3-117
Eigenvalues and Eigenmodes of a Square . . . . . . . . . . . . . 3-119
Using the PDE App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-119
Eigenvalues of a Square Using Command-Line Functions . 3-120
Vibration Of a Circular Membrane Using The MATLAB eigs
Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-124
Solve PDEs Programmatically . . . . . . . . . . . . . . . . . . . . . . . 3-128
When You Need Programmatic Solutions . . . . . . . . . . . . . 3-128
Data Structures in Partial Differential Equation Toolbox . 3-128
Tips for Solving PDEs Programmatically . . . . . . . . . . . . . . 3-131
Solve Poisson’s Equation on a Grid . . . . . . . . . . . . . . . . . . . 3-133
Plot 2-D Solutions and Their Gradients . . . . . . . . . . . . . . . 3-135
Plot Solutions Without Explicit Interpolation . . . . . . . . . . 3-135
Interpolate and Plot Solutions and Gradients . . . . . . . . . . 3-137
Plot 3-D Solutions and Their Gradients . . . . . . . . . . . . . . . 3-145
Types of 3-D Solution Plots . . . . . . . . . . . . . . . . . . . . . . . . 3-145
Surface Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-145
2-D Slices Through 3-D Geometry . . . . . . . . . . . . . . . . . . . 3-149
Contour Slices Through a 3-D Solution . . . . . . . . . . . . . . . 3-154
Plots of Gradients and Streamlines . . . . . . . . . . . . . . . . . . 3-161
Dimensions of Solutions and Gradients . . . . . . . . . . . . . . . 3-167
PDE App
4
Specify 2-D Geometry in the PDE App . . . . . . . . . . . . . . . . . . 4-2
Specify Boundary Conditions in the PDE App . . . . . . . . . . . 4-5
Specify Coefficients in the PDE App . . . . . . . . . . . . . . . . . . . . 4-8
Specify Mesh Parameters in the PDE App . . . . . . . . . . . . . . . 4-9
Tooltip Displays for Mesh and Plots . . . . . . . . . . . . . . . . . . . 4-11
Adjust Solve Parameters in the PDE App . . . . . . . . . . . . . . 4-12
Elliptic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Parabolic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
Hyperbolic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
Eigenvalue Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Plot the Solution in the PDE App . . . . . . . . . . . . . . . . . . . . . 4-17
Additional Plot Control Options . . . . . . . . . . . . . . . . . . . . . 4-20
Finite Element Method
Elliptic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Finite Element Basis for 3-D . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
Systems of PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13
Parabolic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17
Reducing Parabolic Equations to Elliptic Equations . . . . . . 5-17
Hyperbolic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
Eigenvalue Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
Nonlinear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31