The Control-Volume Finite-Difference Approximation to the Diffusion Equation ME 448/548 Notes Gerald Recktenwald Portland State University Department of Mechanical & Materials Engineering [email protected]21 January 2014 ME 448/548: 2D Diffusion Equation
33
Embed
The Control-Volume Finite-Di erence Approximation to …web.cecs.pdx.edu/~gerry/class/ME448/notes/pdf/CVFD2D_Slides.pdf · The Control-Volume Finite-Di erence Approximation to the
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
The Control-Volume Finite-DifferenceApproximation to the Diffusion Equation
4. Solve the system of equations Aφ = b, where φ is the vector of unknowns.
5. Post-process to visualize the solution
The Poisson equation is steady. Each step is performed only once.
ME 448/548: 2D Diffusion Equation 19
Structured Mesh
The CVFD Matlab codes use structured meshes. in size.
• The cells in the domain are topologically equivalent to a rectangular array
• The cells need not be uniform in size.
• Each cell not on a boundary touches four other cells
• Each row has the same number of cells
• Each column has the same number of cells
Uniform Mesh Block-Uniform Mesh
Lx1, nx1 Lx2, nx2
Ly1, ny1
Ly2, ny2
Ly3, ny3
x
y
∆x
∆y
ME 448/548: 2D Diffusion Equation 20
Boundary Conditions (part 1)
Boundarytype
BoundaryCondition Post-processing in fvpost
1 Specified T Compute q′′ from discrete approximation to Fourier’s law.
q′′
= kTb − Tixb − xi
where Ti and Tb are interior and boundary temperatures, respectively.
2 Specified q′′ Compute Tb from discrete approximation to Fourier’s law.
Tb = Ti + q′′ xb − xi
kwhere Ti and Tb are interior and boundary temperatures, respectively.
ME 448/548: 2D Diffusion Equation 21
Boundary Conditions (part 2)
Boundarytype
BoundaryCondition Post-processing in fvpost
3 Convection From specified h and T∞, compute boundary temperature and heat fluxthrough the cell face on the boundary. Continuity of heat flux requires
−kTb − Tixb − xi
= h(Tb − Tamb)
which can be solved for Tb to give
Tb =hTamb + (k/δxe)Ti
h+ (k/δxe)
where δxe = xb − xi
4 Symmetry q′′ = 0. Set boundary Tb equal to adjacent interior Ti.
ME 448/548: 2D Diffusion Equation 22
Matlab codes for obtaining the numerical solution
A set of general purpose codes has been written to facilitate experimentation with the
CVFD method.
Algorithm Tasks Core Routines
Define the mesh fvUniformMesh or
fvUniBlockMesh
Define boundary conditions
Compute finite-volume coefficients for interior cells fvcoef
Adjust coefficients for boundary conditions fvbc
Solve system of equations
Assemble coefficient matrix fvAmatrix
Solve
Compute boundary values and/or fluxes fvpost
Plot results
ME 448/548: 2D Diffusion Equation 23
Model Problem 1
Choose a source term that may be physically unrealistic, but one that gives an exact
solution that is easy to evaluate
S =
[(π
Lx
)2
+
(2π
Ly
)2]
sin
(πx
Lx
)sin
(2πy
Ly
)
The exact solution is
φ = sin
(πx
Lx
)sin
(2πy
Ly
)Main code to solve this problem is in demoModel1.m
ME 448/548: 2D Diffusion Equation 24
Model Problem 1
The exact solution is
φ = sin
(πx
Lx
)sin
(2πy
Ly
)
0
0.5
1
00.2
0.40.6
0.81
0
0.5
1
1.5
2
yx
ME 448/548: 2D Diffusion Equation 25
Solutions to Model Problem 1 Show Correct Truncation Error
The local truncation error at each node is
ei ∼ O(∆x2).
Since the exact solution is known we can
compute
‖e‖2
N=
√∑e2i
N∼√Ne2
N=
e√N.
where N = nxny is the total number of
interior nodes in the domain, and e is the
average truncation error per node.10
−310
−210
−110
010
−8
10−7
10−6
10−5
10−4
10−3
10−2
10−1
∆ x
Me
asu
red
err
or
Measured
Theoretical error ~ (∆ x)3
Since ei ∼ O(∆x2), N ∼ n2x, and ∆x = Lx/(nx + 1), we can estimate
‖e‖2
N∼
e√N
=O(∆x2)
nx=O(L2x/(nx + 1)2
)nx
∼ O(
1
nx
)3
= O(∆x3).
ME 448/548: 2D Diffusion Equation 26
Model Problem 2
Uniform source term: S = 1.
Analytical solution is an infinite
series
Code in demoModel2.m
0
0.5
1
00.2
0.40.6
0.81
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
yx
ME 448/548: 2D Diffusion Equation 27
Model Problem 3
Heat conduction in a rectangle consisting of
two material regions.
• Inner rectangle with high conductivity
• Outer rectangle with low conductivity
• Inner region has uniform heat source
0.25Lx
0.25Ly
0.5Ly
0.5Lx
Lx
Ly
Γ1 = 1
S1 = 0
Γ2 = αΓ
1
S2 = 1000
The discontinuity and difference in material properties can be used to stress the solution
algorithm.
α =Γ2
Γ1
The analytical solution does not exist. Code in demoModel3.m
ME 448/548: 2D Diffusion Equation 28
Model Problem 3
0.25Lx
0.25Ly
0.5Ly
0.5Lx
Lx
Ly
Γ1 = 1
S1 = 0
Γ2 = αΓ
1
S2 = 1000
Solution with α = 100
0
0.5
1
00.2
0.40.6
0.81
0
5
10
15
20
25
30
35
yx
ME 448/548: 2D Diffusion Equation 29
Model Problem 4: Fully Developed Flow in a Rectangular Duct
For simple fully-developed flow the governing equation for the axial velocity w is
µ
[∂2w
∂x2+∂2w
∂y2
]−dp
dz= 0
This corresponds to the generic model equation with
φ = w, Γ = µ (= constant), S = −dp
dz.
ME 448/548: 2D Diffusion Equation 30
Model Problem 4: Fully Developed Flow in a Rectangular Duct
The symmetry in the problem allows alternative ways of defining the numerical model
Full Duct
x
y
Lx
Ly
Quarter Duct
x
y
Lx
Ly
For the full duct simulation depicted on the left hand side, the boundary conditions are no