SlideShare ist ein Scribd-Unternehmen logo
1 von 31
1
1
Programming, Computation, Simulation
Applications in Math & Physics
Finite Difference Methods
Syeilendra Pramuditya
Department of Physics
Institut Teknologi Bandung
2
Grid-based Computation
 Euler-type Methods
 Differential equations
 Temporal domain (variation in time)
 Initial value problems
 Initial conditions
 Finite Difference Methods
 Differential equations
 Spatial domain (variation in space)
 Boundary value problems
 Dirichlet boundary conditions: value of solution at
boundaries
 Von Neumann boundary conditions: derivative of
solution at boundaries
3
Differential Equation
2
2
( ) 48
'' 48
( 0) 6
Boundary Conditions
( 1) 7
Can you solve for ( )...?
d
y x x
dx
y x
y x
y x
y x


  

  
4
Differential Equation
3
Sure! Super easy! Just integrate twice!
( ) 8 7 6
y x x x
  
0.00
1.00
2.00
3.00
4.00
5.00
6.00
7.00
8.00
0.00 0.20 0.40 0.60 0.80 1.00
x
5
Differential Equation
2
2
( ) 5 ( ) 10 ( ) 10
5 10 10
( 0) 0
Boundary Conditions
( 1) 100
Can you solve for ( )...???
d d
y x y x y x x
dx dx
y y y x
y x
y x
y x
  
 
  
  

  
6
Derivation from Taylor Series
 Forward difference equation
7
Derivation from Taylor Series
 Backward difference equation
8
Derivation from Taylor Series
 Central difference equation
Now substract this
From this
9
Finite Difference Approximation
 Approx. the slope of function
Forward Diff.
Backward Diff.
Central Diff.
10
Finite Difference Equations
 The Central Difference
11
Finite Difference
1 1
2
1 1
2 2 2
( ) ( )
( ) ( )
2 2
2
( ) 2 ( ) ( )
( ) ( )
( )
i i
i i i
f f
d f x x f x x
f x f x
dx x h
f f f
d f x x f x f x x
f x f x
dx x h
 
 

    
   

 
     
   

2
2
( ) 48
'' 48
( 0) 6
Boundary Conditions
( 1) 7
0.05, 0.10, 0.15, ... , 1.00
i
d
y x x
dx
y x
y x
y x
x


  

  

12
Finite Difference
1 1
2
2
1 1
2
1 1
'' 48
2
48
2 48
48
2
i i i
i
i i i i
i i i
i
y x
y y y
x
h
y y y h x
y y h x
y
 
 
 

 

  
 

1 1
2
1 1
2 2
( ) ( )
2
2
( ) ( )
i i
i i i
f f
d
f x f x
dx h
f f f
d
f x f x
dx h
 
 

  
 
  
13
0.00
1.00
2.00
3.00
4.00
5.00
6.00
7.00
8.00
0.00 0.20 0.40 0.60 0.80 1.00
x
Finite Difference
Initial Guess
2
2
( ) 48
'' 48
( 0) 6
Boundary Conditions
( 1) 7
0.05, 0.10, 0.15, ... , 1.00
i
d
y x x
dx
y x
y x
y x
x


  

  

2
1 1 48
2
old old
new i i i
i
y y h x
y  
 

Loop only the internal points,
Until:
0.0001
For all points i
new old
i i
old
i
y y
y


 
14
Finite Difference
0
1
2
3
0 1 2 3 4 5 6 7 8 9 10
Point
10-point Grid
old
i
y 1
old
i
y 
1
old
i
y 
old
i
y
1
old
i
y 
new
i
y
2
1 1 48
2
old old
new i i i
i
y y h x
y  
 

15
Code Structure
 Define domain boundaries (x1 & xN)
 Define resolution
 Define number of points (xi)
 Calculate h or x
 Define initial guess for internal points
 Define boundary conditions  f(x1) & f(xN)
 Dirichlet BC
 Double Loop
 Inner loop  Update internal points using finite
difference equation
 Outer loop  Convergence check: how much the change
of each point is?
 Loop until iteration is converged
 No significant change for all points
16
Code Output
Converged in 379 iterations.
0, 6
0.05, 5.65543
0.1, 5.31675
0.15, 4.98985
0.2, 4.68064
0.25, 4.39501
0.3, 4.1389
0.35, 3.91822
0.4, 3.73892
0.45, 3.60695
0.5, 3.5283
0.55, 3.50895
0.6, 3.55492
0.65, 3.67221
0.7, 3.8669
0.75, 4.14501
0.8, 4.51263
0.85, 4.97585
0.9, 5.54074
0.95, 6.21343
1, 7
17
Finite Difference
2
1 1 48
2
old old
new i i i
i
y y h x
y  
 

0.00
1.00
2.00
3.00
4.00
5.00
6.00
7.00
8.00
0.00 0.20 0.40 0.60 0.80 1.00
x
Init Guess Iter 10
Iter 25 Iter 50
Iter 100 Iter 200
18
Finite Difference
Max error = 1E-4  379 iterations to converged
0.00
1.00
2.00
3.00
4.00
5.00
6.00
7.00
8.00
0.00 0.20 0.40 0.60 0.80 1.00
x
Exact
Finite Diff.
19
Speed up the process..?
0
1
2
3
0 1 2 3 4 5 6 7 8 9 10
Point
10-point Grid
old
i
y 1
old
i
y 
1
old
i
y 
old
i
y
1
old
i
y 
new
i
y
2
1 1 48
2
old old
new i i i
i
y y h x
y  
 

20
Speed up the process..?
2
1 1 48
2
old old
new i i i
i
y y h x
y  
 

2
1 1 48
2
old new
new i i i
i
y y h x
y  
 

Jacobi Method
Gauss-Siedel Method
379 iterations  219 iterations
1.73X Speed up!
21
Finite Difference: Example
1 1
2
1 1
2 2 2
( ) ( )
( ) ( )
2 2
2
( ) 2 ( ) ( )
( ) ( )
( )
i i
i i i
f f
d f x x f x x
f x f x
dx x h
f f f
d f x x f x f x x
f x f x
dx x h
 
 

    
  

 
     
  



5 10 10
(0) 0
( ) 100
0.0, 0.1, 0.2, ... , 1.0
i
y y y x
y
y n
x
 
  



22
Finite Difference: Example
1 1 1 1
2
2
1 1
2
5 10 10
2
5 10 10
2
1 5 5
1 1 10
2 10 2 2
i i i i i
i i
i i i i
y y y x
y y y y y
y x
h h
h h
y y y h x
h
   
 
 
  
  
  
 
   
    
   
 
    
 
1 1
2
1 1
2 2
( ) ( )
2
2
( ) ( )
i i
i i i
f f
d
f x f x
dx h
f f f
d
f x f x
dx h
 
 

  
 
  
23
Physics Sample Problem
General heat transport eq.
0
p
T
c k T q
t



   

 
2
2
1 1
2
1 1
Steady state, 1D, no heat source:
0 Laplace equation
2
0
2
Dirichlet boundary conditions:
constant
constant
j j j
j j
j
left
right
d T
dx
T T T
x
T T
T
T
T
 
 
 
 






Heat Diffusion (Conduction)
Dirichlet Boundary Condition
24
Physics Sample Problem
General heat transport eq.
0
p
T
c k T q
t



   

 
2
2
1 1
2
1 1
Steady state, 1D, no heat source:
0 Laplace equation
2
0
2
Neumann boundary conditions:
constant
constant
j j j
j j
j
left
right
d T
dx
T T T
x
T T
T
dT
dx
dT
dx
 
 
 
 






Heat Diffusion (Conduction)
Neumann Boundary Condition
Heat Flux
dT
q k
dx
  
25
Simplified Heat Conduction
 Temperature Distribution
0
10
20
30
40
50
60
70
80
90
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
x
T(x)
26
Code Structure
START
Set Boundary Conditions
Set Initial Guess
Repeat
Calculate interior points
Convergence check
Update interior points
Until Converge
Print Output
1 1
2
old old
new i i
i
T T
T  


for all i
new old
i i
old
i
T T
T



= for all i
old new
i i
T T
27
Physics Sample Problem
 Vibrating String
 Guitar, bass, violin, piano, etc
 Resonance frequency  standing wave with
two closed ends
28
Physics Sample Problem
 The Wave Equation
2 2
2 2
2 2
2
2 2
( , ) ( , )
Exact solution ( , ) sin( )
Guessed solution by variable separation ( , ) ( ) ( )
( ) ( )
1 1
const.
( ) ( )
m
x t x t
T
t x
x t kx t
x t y x t
d y x d t
T
y x dx t dt
 

  
 


 
 

 
  
 
   
2
2
2
2 2
2
( )
( ) Temporal domain (SHM), requires initial conditions
( )
( ) Spatial domain, requires boundary conditions
Solve the y(x) by finite difference?
d t
t
dt
d y x
y x
dx T

 
 
  
  
29
Solving Wave Equation
2 2
2
2
1 1
2
2
1 1
2 2
2
1 1
2 2
2
1 1
2 2
1 1 1 1
2 2
2
2
2
( )
( ) 0
2
0
2
0
2
2
2
2
i i i
i
i i i
i
i i
i i
i i
i
i i i i
i
d y x
y x
dx T
y y y
y
h T
y y y
y
h h T
y y
y y
h h T
y y
y
h h T
y y y y
y
h
h
T
h T
 
 
 
 
 
 
 
 
 
 
 
   
 
 
 

  

 
 

 
 
 
 
 
 


 
 
Now imagine how you would write the code..?
What are the inputs?
30
Solving Wave Equation
 Input
 String tension, T
 String length, L
 String linear density, 
 Harmonic order, n
31
Solving Wave Equation
0.0
0.5
1.0
1.5
2.0
2.5
0.0 0.2 0.4 0.6 0.8 1.0
String Length x
y(x)
Exact
Init Guess = 0.5
Init Guess = 1.0
Init Guess = 1.5

Weitere ähnliche Inhalte

Was ist angesagt?

Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...Suddhasheel GHOSH, PhD
 
Newton-Raphson Method
Newton-Raphson MethodNewton-Raphson Method
Newton-Raphson MethodJigisha Dabhi
 
Cauchy integral theorem & formula (complex variable & numerical method )
Cauchy integral theorem & formula (complex variable & numerical method )Cauchy integral theorem & formula (complex variable & numerical method )
Cauchy integral theorem & formula (complex variable & numerical method )Digvijaysinh Gohil
 
Iterative methods
Iterative methodsIterative methods
Iterative methodsKetan Nayak
 
presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve Mukuldev Khunte
 
Solution of non-linear equations
Solution of non-linear equationsSolution of non-linear equations
Solution of non-linear equationsZunAib Ali
 
Jacobi iteration method
Jacobi iteration methodJacobi iteration method
Jacobi iteration methodMONIRUL ISLAM
 
Newton's forward & backward interpolation
Newton's forward & backward interpolationNewton's forward & backward interpolation
Newton's forward & backward interpolationHarshad Koshti
 
Partial differential equation & its application.
Partial differential equation & its application.Partial differential equation & its application.
Partial differential equation & its application.isratzerin6
 

Was ist angesagt? (20)

The wave equation
The wave equationThe wave equation
The wave equation
 
Rayleigh Ritz Method
Rayleigh Ritz MethodRayleigh Ritz Method
Rayleigh Ritz Method
 
Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...
 
1 d wave equation
1 d wave equation1 d wave equation
1 d wave equation
 
Runge Kutta Method
Runge Kutta MethodRunge Kutta Method
Runge Kutta Method
 
Newton-Raphson Method
Newton-Raphson MethodNewton-Raphson Method
Newton-Raphson Method
 
Cauchy integral theorem & formula (complex variable & numerical method )
Cauchy integral theorem & formula (complex variable & numerical method )Cauchy integral theorem & formula (complex variable & numerical method )
Cauchy integral theorem & formula (complex variable & numerical method )
 
Iterative methods
Iterative methodsIterative methods
Iterative methods
 
Fourier series
Fourier seriesFourier series
Fourier series
 
presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve
 
Legendre functions
Legendre functionsLegendre functions
Legendre functions
 
Convolution
ConvolutionConvolution
Convolution
 
Solution of non-linear equations
Solution of non-linear equationsSolution of non-linear equations
Solution of non-linear equations
 
Fourier series
Fourier seriesFourier series
Fourier series
 
Jacobi method
Jacobi methodJacobi method
Jacobi method
 
Jacobi iteration method
Jacobi iteration methodJacobi iteration method
Jacobi iteration method
 
Newton's forward & backward interpolation
Newton's forward & backward interpolationNewton's forward & backward interpolation
Newton's forward & backward interpolation
 
Properties of Fourier transform
Properties of Fourier transformProperties of Fourier transform
Properties of Fourier transform
 
Partial differential equation & its application.
Partial differential equation & its application.Partial differential equation & its application.
Partial differential equation & its application.
 
Fourier Transform
Fourier TransformFourier Transform
Fourier Transform
 

Ähnlich wie Finite Difference Method

Solution of simplified neutron diffusion equation by FDM
Solution of simplified neutron diffusion equation by FDMSolution of simplified neutron diffusion equation by FDM
Solution of simplified neutron diffusion equation by FDMSyeilendra Pramuditya
 
The response of a rectangular micro-plate to me-chanical shocks considering m...
The response of a rectangular micro-plate to me-chanical shocks considering m...The response of a rectangular micro-plate to me-chanical shocks considering m...
The response of a rectangular micro-plate to me-chanical shocks considering m...Kaveh Rashvand
 
SPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta MethodsSPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta MethodsSyeilendra Pramuditya
 
Lecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdfLecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdfRayRabara
 
dynamical analysis of soil and structures
dynamical analysis of soil and structuresdynamical analysis of soil and structures
dynamical analysis of soil and structuresHaHoangJR
 
Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715HelpWithAssignment.com
 
Controllability of Linear Dynamical System
Controllability of  Linear Dynamical SystemControllability of  Linear Dynamical System
Controllability of Linear Dynamical SystemPurnima Pandit
 
Circuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace TransformCircuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace TransformSimen Li
 
Week3 ap3421 2019_part1
Week3 ap3421 2019_part1Week3 ap3421 2019_part1
Week3 ap3421 2019_part1David Cian
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...ieijjournal
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...ieijjournal
 
Positive and negative solutions of a boundary value problem for a fractional ...
Positive and negative solutions of a boundary value problem for a fractional ...Positive and negative solutions of a boundary value problem for a fractional ...
Positive and negative solutions of a boundary value problem for a fractional ...journal ijrtem
 
Vu_HPSC2012_02.pptx
Vu_HPSC2012_02.pptxVu_HPSC2012_02.pptx
Vu_HPSC2012_02.pptxQucngV
 
CAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONS
CAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONSCAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONS
CAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONSCarlon Baird
 

Ähnlich wie Finite Difference Method (20)

Solution of simplified neutron diffusion equation by FDM
Solution of simplified neutron diffusion equation by FDMSolution of simplified neutron diffusion equation by FDM
Solution of simplified neutron diffusion equation by FDM
 
The response of a rectangular micro-plate to me-chanical shocks considering m...
The response of a rectangular micro-plate to me-chanical shocks considering m...The response of a rectangular micro-plate to me-chanical shocks considering m...
The response of a rectangular micro-plate to me-chanical shocks considering m...
 
SPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta MethodsSPSF04 - Euler and Runge-Kutta Methods
SPSF04 - Euler and Runge-Kutta Methods
 
Lecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdfLecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdf
 
dynamical analysis of soil and structures
dynamical analysis of soil and structuresdynamical analysis of soil and structures
dynamical analysis of soil and structures
 
Conference ppt
Conference pptConference ppt
Conference ppt
 
Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715
 
UNIT I_3.pdf
UNIT I_3.pdfUNIT I_3.pdf
UNIT I_3.pdf
 
Controllability of Linear Dynamical System
Controllability of  Linear Dynamical SystemControllability of  Linear Dynamical System
Controllability of Linear Dynamical System
 
Circuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace TransformCircuit Network Analysis - [Chapter4] Laplace Transform
Circuit Network Analysis - [Chapter4] Laplace Transform
 
cfdht-fvm-unit3.ppt
cfdht-fvm-unit3.pptcfdht-fvm-unit3.ppt
cfdht-fvm-unit3.ppt
 
Week3 ap3421 2019_part1
Week3 ap3421 2019_part1Week3 ap3421 2019_part1
Week3 ap3421 2019_part1
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
 
SPSF03 - Numerical Integrations
SPSF03 - Numerical IntegrationsSPSF03 - Numerical Integrations
SPSF03 - Numerical Integrations
 
Modeling and vibration Analyses of a rotor having multiple disk supported by ...
Modeling and vibration Analyses of a rotor having multiple disk supported by ...Modeling and vibration Analyses of a rotor having multiple disk supported by ...
Modeling and vibration Analyses of a rotor having multiple disk supported by ...
 
Positive and negative solutions of a boundary value problem for a fractional ...
Positive and negative solutions of a boundary value problem for a fractional ...Positive and negative solutions of a boundary value problem for a fractional ...
Positive and negative solutions of a boundary value problem for a fractional ...
 
Vu_HPSC2012_02.pptx
Vu_HPSC2012_02.pptxVu_HPSC2012_02.pptx
Vu_HPSC2012_02.pptx
 
CAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONS
CAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONSCAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONS
CAPE PURE MATHEMATICS UNIT 2 MODULE 1 PRACTICE QUESTIONS
 
Adaline and Madaline.ppt
Adaline and Madaline.pptAdaline and Madaline.ppt
Adaline and Madaline.ppt
 

Kürzlich hochgeladen

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Kürzlich hochgeladen (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

Finite Difference Method

  • 1. 1 1 Programming, Computation, Simulation Applications in Math & Physics Finite Difference Methods Syeilendra Pramuditya Department of Physics Institut Teknologi Bandung
  • 2. 2 Grid-based Computation  Euler-type Methods  Differential equations  Temporal domain (variation in time)  Initial value problems  Initial conditions  Finite Difference Methods  Differential equations  Spatial domain (variation in space)  Boundary value problems  Dirichlet boundary conditions: value of solution at boundaries  Von Neumann boundary conditions: derivative of solution at boundaries
  • 3. 3 Differential Equation 2 2 ( ) 48 '' 48 ( 0) 6 Boundary Conditions ( 1) 7 Can you solve for ( )...? d y x x dx y x y x y x y x         
  • 4. 4 Differential Equation 3 Sure! Super easy! Just integrate twice! ( ) 8 7 6 y x x x    0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 0.00 0.20 0.40 0.60 0.80 1.00 x
  • 5. 5 Differential Equation 2 2 ( ) 5 ( ) 10 ( ) 10 5 10 10 ( 0) 0 Boundary Conditions ( 1) 100 Can you solve for ( )...??? d d y x y x y x x dx dx y y y x y x y x y x               
  • 6. 6 Derivation from Taylor Series  Forward difference equation
  • 7. 7 Derivation from Taylor Series  Backward difference equation
  • 8. 8 Derivation from Taylor Series  Central difference equation Now substract this From this
  • 9. 9 Finite Difference Approximation  Approx. the slope of function Forward Diff. Backward Diff. Central Diff.
  • 10. 10 Finite Difference Equations  The Central Difference
  • 11. 11 Finite Difference 1 1 2 1 1 2 2 2 ( ) ( ) ( ) ( ) 2 2 2 ( ) 2 ( ) ( ) ( ) ( ) ( ) i i i i i f f d f x x f x x f x f x dx x h f f f d f x x f x f x x f x f x dx x h                             2 2 ( ) 48 '' 48 ( 0) 6 Boundary Conditions ( 1) 7 0.05, 0.10, 0.15, ... , 1.00 i d y x x dx y x y x y x x          
  • 12. 12 Finite Difference 1 1 2 2 1 1 2 1 1 '' 48 2 48 2 48 48 2 i i i i i i i i i i i i y x y y y x h y y y h x y y h x y                 1 1 2 1 1 2 2 ( ) ( ) 2 2 ( ) ( ) i i i i i f f d f x f x dx h f f f d f x f x dx h             
  • 13. 13 0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 0.00 0.20 0.40 0.60 0.80 1.00 x Finite Difference Initial Guess 2 2 ( ) 48 '' 48 ( 0) 6 Boundary Conditions ( 1) 7 0.05, 0.10, 0.15, ... , 1.00 i d y x x dx y x y x y x x           2 1 1 48 2 old old new i i i i y y h x y      Loop only the internal points, Until: 0.0001 For all points i new old i i old i y y y    
  • 14. 14 Finite Difference 0 1 2 3 0 1 2 3 4 5 6 7 8 9 10 Point 10-point Grid old i y 1 old i y  1 old i y  old i y 1 old i y  new i y 2 1 1 48 2 old old new i i i i y y h x y     
  • 15. 15 Code Structure  Define domain boundaries (x1 & xN)  Define resolution  Define number of points (xi)  Calculate h or x  Define initial guess for internal points  Define boundary conditions  f(x1) & f(xN)  Dirichlet BC  Double Loop  Inner loop  Update internal points using finite difference equation  Outer loop  Convergence check: how much the change of each point is?  Loop until iteration is converged  No significant change for all points
  • 16. 16 Code Output Converged in 379 iterations. 0, 6 0.05, 5.65543 0.1, 5.31675 0.15, 4.98985 0.2, 4.68064 0.25, 4.39501 0.3, 4.1389 0.35, 3.91822 0.4, 3.73892 0.45, 3.60695 0.5, 3.5283 0.55, 3.50895 0.6, 3.55492 0.65, 3.67221 0.7, 3.8669 0.75, 4.14501 0.8, 4.51263 0.85, 4.97585 0.9, 5.54074 0.95, 6.21343 1, 7
  • 17. 17 Finite Difference 2 1 1 48 2 old old new i i i i y y h x y      0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 0.00 0.20 0.40 0.60 0.80 1.00 x Init Guess Iter 10 Iter 25 Iter 50 Iter 100 Iter 200
  • 18. 18 Finite Difference Max error = 1E-4  379 iterations to converged 0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 0.00 0.20 0.40 0.60 0.80 1.00 x Exact Finite Diff.
  • 19. 19 Speed up the process..? 0 1 2 3 0 1 2 3 4 5 6 7 8 9 10 Point 10-point Grid old i y 1 old i y  1 old i y  old i y 1 old i y  new i y 2 1 1 48 2 old old new i i i i y y h x y     
  • 20. 20 Speed up the process..? 2 1 1 48 2 old old new i i i i y y h x y      2 1 1 48 2 old new new i i i i y y h x y      Jacobi Method Gauss-Siedel Method 379 iterations  219 iterations 1.73X Speed up!
  • 21. 21 Finite Difference: Example 1 1 2 1 1 2 2 2 ( ) ( ) ( ) ( ) 2 2 2 ( ) 2 ( ) ( ) ( ) ( ) ( ) i i i i i f f d f x x f x x f x f x dx x h f f f d f x x f x f x x f x f x dx x h                             5 10 10 (0) 0 ( ) 100 0.0, 0.1, 0.2, ... , 1.0 i y y y x y y n x        
  • 22. 22 Finite Difference: Example 1 1 1 1 2 2 1 1 2 5 10 10 2 5 10 10 2 1 5 5 1 1 10 2 10 2 2 i i i i i i i i i i i y y y x y y y y y y x h h h h y y y h x h                                          1 1 2 1 1 2 2 ( ) ( ) 2 2 ( ) ( ) i i i i i f f d f x f x dx h f f f d f x f x dx h             
  • 23. 23 Physics Sample Problem General heat transport eq. 0 p T c k T q t           2 2 1 1 2 1 1 Steady state, 1D, no heat source: 0 Laplace equation 2 0 2 Dirichlet boundary conditions: constant constant j j j j j j left right d T dx T T T x T T T T T               Heat Diffusion (Conduction) Dirichlet Boundary Condition
  • 24. 24 Physics Sample Problem General heat transport eq. 0 p T c k T q t           2 2 1 1 2 1 1 Steady state, 1D, no heat source: 0 Laplace equation 2 0 2 Neumann boundary conditions: constant constant j j j j j j left right d T dx T T T x T T T dT dx dT dx               Heat Diffusion (Conduction) Neumann Boundary Condition Heat Flux dT q k dx   
  • 25. 25 Simplified Heat Conduction  Temperature Distribution 0 10 20 30 40 50 60 70 80 90 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 x T(x)
  • 26. 26 Code Structure START Set Boundary Conditions Set Initial Guess Repeat Calculate interior points Convergence check Update interior points Until Converge Print Output 1 1 2 old old new i i i T T T     for all i new old i i old i T T T    = for all i old new i i T T
  • 27. 27 Physics Sample Problem  Vibrating String  Guitar, bass, violin, piano, etc  Resonance frequency  standing wave with two closed ends
  • 28. 28 Physics Sample Problem  The Wave Equation 2 2 2 2 2 2 2 2 2 ( , ) ( , ) Exact solution ( , ) sin( ) Guessed solution by variable separation ( , ) ( ) ( ) ( ) ( ) 1 1 const. ( ) ( ) m x t x t T t x x t kx t x t y x t d y x d t T y x dx t dt                           2 2 2 2 2 2 ( ) ( ) Temporal domain (SHM), requires initial conditions ( ) ( ) Spatial domain, requires boundary conditions Solve the y(x) by finite difference? d t t dt d y x y x dx T           
  • 29. 29 Solving Wave Equation 2 2 2 2 1 1 2 2 1 1 2 2 2 1 1 2 2 2 1 1 2 2 1 1 1 1 2 2 2 2 2 ( ) ( ) 0 2 0 2 0 2 2 2 2 i i i i i i i i i i i i i i i i i i i i d y x y x dx T y y y y h T y y y y h h T y y y y h h T y y y h h T y y y y y h h T h T                                                             Now imagine how you would write the code..? What are the inputs?
  • 30. 30 Solving Wave Equation  Input  String tension, T  String length, L  String linear density,   Harmonic order, n
  • 31. 31 Solving Wave Equation 0.0 0.5 1.0 1.5 2.0 2.5 0.0 0.2 0.4 0.6 0.8 1.0 String Length x y(x) Exact Init Guess = 0.5 Init Guess = 1.0 Init Guess = 1.5