0% found this document useful (0 votes)
25 views13 pages

FV Diffusion

This document describes the finite volume method for solving diffusion problems. It presents the governing differential equation, integrates it over a control volume to obtain an algebraic equation, and describes how to discretize and solve the equation numerically on a grid with different boundary conditions.

Uploaded by

Nâzım Koşan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views13 pages

FV Diffusion

This document describes the finite volume method for solving diffusion problems. It presents the governing differential equation, integrates it over a control volume to obtain an algebraic equation, and describes how to discretize and solve the equation numerically on a grid with different boundary conditions.

Uploaded by

Nâzım Koşan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Section 3: Finite Volume Method for Diffusion Problems

Governing Differential Equation for a Diffusion Problem

𝜕 𝜕𝜙 𝜕 𝜕𝜙
(Γ ) + (Γ ) + 𝑆 = 0
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦
or, in vector form:
∇ ∙ (Γ∇𝜙)+S=0

Integrate Over Control Volume

∫ ∇ ∙ (Γ∇𝜙)𝑑𝑉 + ∫ 𝑆𝑑𝑉 = 0

Apply the Gauss Divergence Theorem, which converts the volume


integral to a surface integral, and is given as

∫ ∇ ∙ 𝑎 𝑑𝑉 = ∫ 𝑎 ∙ 𝑛̂ 𝑑𝑆

Applied to our integral we find

∫ Γ∇𝜙 ∙ 𝑛̂ 𝑑𝑆 + ∫ 𝑆𝑑𝑉 = 0
Typical Finite Volume Mesh and Terminology
𝜕𝜙 𝜕𝜙 𝜕𝜙 𝜕𝜙
𝐴𝑒 Γ𝑒 | − 𝐴𝑤 Γ𝑤 | + 𝐴𝑛 Γ𝑛 | − 𝐴𝑠 Γ𝑠 | + 𝑆̅Δ𝑥Δ𝑦 = 0
𝜕𝑥 𝑒 𝜕𝑥 𝑤 𝜕𝑦 𝑛 𝜕𝑦 𝑠
Finite-difference approximation for derivatives
𝜕𝜙 𝜙𝐸 − 𝜙𝑃
| = + 𝑂(𝛿𝑥)2
𝜕𝑥 𝑒 (𝛿𝑥)𝑒
and
source term linearization
𝑆̅Δ𝑥Δ𝑦 = 𝑆𝑢 + 𝑆𝑝 𝜙𝑝
results in
𝜙𝐸 − 𝜙𝑃 𝜙𝑃 − 𝜙𝑊 𝜙𝑁 − 𝜙𝑃 𝜙𝑃 − 𝜙𝑆
Δ𝑦 (Γ𝑒 − Γ𝑤 ) + Δ𝑥 (Γ𝑛 − Γ𝑠 )
(𝛿𝑥)𝑒 (𝛿𝑥)𝑤 (𝛿𝑦)𝑛 (𝛿𝑦)𝑠
+ 𝑆𝑢 + 𝑆𝑃 𝜙𝑃 = 0

Rearrange as
Γ𝑤 Δ𝑦 Γ𝑒 Δ𝑦 Γ𝑠 Δ𝑥 Γ𝑛 Δ𝑥
( + + + − 𝑆𝑝 ) 𝜙𝑃
(𝛿𝑥)𝑤 (𝛿𝑥)𝑒 (𝛿𝑦)𝑠 (𝛿𝑦)𝑛
Γ𝑤 Δ𝑦 Γ𝑒 Δ𝑦 Γ𝑛 Δ𝑥 Γ𝑠 Δ𝑥
= 𝜙𝑊 + 𝜙𝐸 + 𝜙𝑁 + 𝜙 + 𝑆𝑢
(𝛿𝑥)𝑤 (𝛿𝑥)𝑒 (𝛿𝑦)𝑛 (𝛿𝑦)𝑠 𝑆

𝐴𝑃 𝜙𝑃 = 𝐴𝑊 𝜙𝑊 + 𝐴𝐸 𝜙𝐸 + 𝐴𝑆 𝜙𝑆 + 𝐴𝑁 𝜙𝑁 + 𝑆𝑢

Γ𝑤 Δ𝑦
𝐴𝑊 =
(𝛿𝑥)𝑤
Γ𝑒 Δ𝑦
𝐴𝐸 =
(𝛿𝑥)𝑒
Γ𝑠 Δ𝑥
𝐴𝑆 =
(𝛿𝑦)𝑠
Γ𝑛 Δ𝑥
𝐴𝑁 =
(𝛿𝑦)𝑛
𝐴𝑃 = 𝐴𝑊 + 𝐴𝐸 + 𝐴𝑆 + 𝐴𝑁 − 𝑆𝑃

**********************************************************
Boundaries
A) Fixed (Dirichlet) boundary condition (i.e., set 𝜙 on a boundary)
Look at west boundary as an example
Find
−Γ𝑤 Δ𝑦
𝑆𝑝 =
((𝛿𝑥)𝑤 /2)
Γ𝑤 Δ𝑦
𝑆𝑢 = 𝜙
((𝛿𝑥)𝑤 ⁄2) 𝐵𝐶
𝐴𝑊 = 0
What did we do? “Cut the link” to west boundary and utilized source
terms to implement boundary condition.

B) Derivative (Neumann) boundary condition on the west boundary


𝑆𝑃 = 0
𝜕𝜙
𝑆𝑢 = −𝐴𝑤 Γ𝑤 |
𝜕𝑥 𝑤
𝐴𝑊 = 0
*******************************************************
Solution algorithm
Successive over relaxation iterative scheme
Ω
𝜙𝑃 = 𝜙𝑃 + (𝐴 𝜙 + 𝐴𝐸 𝜙𝐸 + 𝐴𝑆 𝜙𝑆 + 𝐴𝑁 𝜙𝑁 + 𝑆𝑢 − 𝐴𝑃 𝜙𝑃 )
𝐴𝑃 𝑊 𝑊
0< Ω<2
*********************************************************
Example Problem
Solve the following problem using the finite-volume method:

∇2 𝜙=0

0≤𝑥≤1 0≤𝑦≤1

Set the boundary conditions as:

𝜙(0, 𝑦) = 0; 𝜙(1, 𝑦) = 𝑦; 𝜙(𝑥, 0) = 0; 𝜙(𝑥, 1) = 𝑥

This problem is of the form:

∇ ∙ (Γ∇ϕ) = 0

with Γ = 1.

The problem has the analytic solution 𝜙(𝑥, 𝑦) = 𝑥𝑦.


Consequently, we can determine our numerical errors.
Simple Code in Fortran90

! PROGRAM TO SOLVE LAPLACE EQUATION OVER DOMAIN


! 0<=x<=1, 0<=y<=1
! with boundary conditions phi=x*y
!**************************************************
implicit none
integer, parameter :: nx=25, ny=25
integer :: i,j,iterations
real :: x,y,z,dx,dy,omega
real, dimension(1:nx,1:ny) :: AE,AW,AN,AS,AP,SP,SU
real, dimension(0:nx+1,0:ny+1) :: phi
!**************************************************
dx=1./float(nx); dy=1./float(ny)
! initialize all SU and SP to interior cell values of zero
SU=0; SP=0
phi=0.0
! initialize AE,AW,AN,AS,AP over all cells
! to the values over the interior cells
AE=1.; AW=1.; AN=1.; AS=1.
!*************************************************
! set wall boundary values (overwrite initialization values)
! west boundary
AW(1,:)=0. !cut link
SU(1,:)=0.
SP(1,:)=-2.

! east boundary
AE(NX,:)=0. !cut link
SP(NX,:)=-2.
do j=1,NY
SU(NX,j)=2.*( (dy/2.) + dy*float(j-1) )
end do

! south boundary
AS(:,1)=0. !cut link
SU(:,1)=0.
SP(:,1)=-2.
! north boundary
AN(:,NY)=0. ! cut link
SP(:,NY)=-2.
do i=1,NX
SU(i,NY)=2.*( (dx/2.) + dx*float(i-1) )
end do

corner cell boundary values


! southwest
AS(1,1)=0. ! cut links
AW(1,1)=0.
SU(1,1)=0.
SP(1,1)=-4.

! northwest
AN(1,ny)=0. ! cut links
AW(1,ny)=0.
SU(1,ny)=2.*(dx/2.)
SP(1,ny)=-4.
! southeast
AS(nx,1)=0. ! cut links
AE(nx,1)=0.
SU(nx,1)=2.*(dy/2.)
SP(nx,1)=-4.

! northeast
AN(nx,ny)=0. ! cut links
AE(nx,ny)=0.
SU(nx,ny)=2.*((dx/2.) + dx*float(nx-1)) + 2.*((dy/2.) + dy*float(ny-1))
SP(nx,ny)=-4.
AP=AE+AW+AN+AS-SP

! Successive Over-Relaxation ITERATIVE SOLVER


omega=1.7 ! relaxation factor
do iterations=1,500 ! set iterations over interior cells to 500
do i=1,nx
do j=1,ny
phi(i,j)=phi(i,j) + omega/AP(i,j)*(AE(i,j)*phi(i+1,j)+ &
AW(i,j)*phi(i-1,j)+AN(i,j)*phi(i,j+1)+ &
AS(i,j)*phi(i,j-1)+SU(i,j)-AP(i,j)*phi(i,j))
end do; end do; end do
!*************************************************
! WRITE comma separated DATA FILE FOR PARAVIEW
open(unit=10,file='results.csv')
write(10,*)'x coord, y coord, z coord, phi'

! write out Interior data points


do i=1,nx
do j=1,ny
x=dx/2+float(i-1)*dx
y=dy/2+float(j-1)*dy
z=0.
write(10,*)x,',',y,',',z,',',phi(i,j)
end do; end do
! write west boundary values
do j=1,ny
y=dy/2+float(j-1)*dy
write(10,*)0.0,',',y,',',0.0,',',0.0
end do;

! write east boundary values


do j=1,ny
y=dy/2+float(j-1)*dy
write(10,*)1.0,',',y,',',0.0,',',y
end do

! write south boundary values


do i=1,nx
x=dx/2+float(i-1)*dx
write(10,*)x,',',0.0,',',0.0,',',0.0
end do;
! write north boundary values
do i=1,nx
x=dx/2+float(i-1)*dx
write(10,*)x,',',1.0,',',0.0,',',x
end do;
! write corner boundary values
write(10,*)0.0,',',0.0,',',0.0,',',0.0 ! southwest

write(10,*)0.0,',',1.0,',',0.0,',',0.0 ! northwest

write(10,*)1.0,',',0.0,',',0.0,',',0.0 ! southeast

write(10,*)1.0,',',1.0,',',0.0,',',1.0 ! northeast

end

You might also like