SlideShare a Scribd company logo
1 of 47
1
Computational Method to Solve
the Partial Differential
Equations (PDEs)
By
Dr. Khurram Mehboob
1
Mehboob, K
NE: 402 computation Method in Nuclear
Engineering
Department of Nuclear Engineering,
KAU, Jeddah, KSA
2017. 5. 1
How to solve 1st Order PDEs
using MATLAB
2
Contents
• Solving PDEs using MATLAB (Explicit method)
- FTCS method
- Lax method
- Crank Nicolson method
- Jacobi’s method
- Simultaneous-over-relaxation (SOR) method
• Solving PDEs using MATLAB
- Examples of PDEs
3
PDE (Partial Differential Equation)
PDEs are used as mathematical models for phenomena in
all branches of engineering and science.
2 2 2
2 2
2 ( , , , , )
u u u u u
A B C D x t u
t xt x t x
    
  
    
u u
and
t x
 
 
linear in
- Three Types of PDEs:
1) Elliptic:
 Steady heat transfer, flow and diffusion
2) Parabolic:
 Transient heat transfer, flow and diffusion
3) Hyperbolic:
 Transient wave equation
2
0B AC 
2 2
2 2 0u u
x y
  
 
Laplace equations
2
0B AC 
2
2
u uD
t x
 
 
Diffusion Equation
2
0B AC  2 2
2 2 2
1u u
x c t
 
 
Wave Equation
4
Similarity method to solve PDE
often the solution of a PDE together wit its initial and boundary problem depends upon its
variables. In such cases the problem can be reduce to the combination ODEs with its
independent variables
The key to the similarity solution is the diffusing equation is that both the equations and
initial and boundary conditions are under the scaling x→lx and t →l2x.
Therefore, x/√t is independent transformation. In general the function should be of
form
The u(x,t)=U(z)
2
2
u u
t x
 
 
, 0t x 
( , ) 1 0
( , ) 0 0
u x t t
u x t x
 
 
( / )u t f x t 

x
t
 
2
2
1 0
2
U U
 
  
 
(0) 1
( ) 0
U
U

 
2
/4
0
( ) s
U C e ds D

 
 
2
/41( ) s
U e ds





 
2
/4
/
1( , ) s
x t
u x t e ds



 
5
FTCS method for Advection Eq
Advection equation
The Forward time and central space (FTCS)
method implementation
,
0,1........
0,1........
( , )
n o n
j o n
n j n j
x x n x n N
t t j x j t
u u x t
   
   

, 1 , 1, 1,
2
n j n j n j n j
u u u u
c
t x
  
 
 
 
0u uc
t x
  
 
FTCS is explicit scheme
, 1 , 1, 1,
( )
2n j n j n j n j
c tu u u u
x  
  

6
Implementation in MATLAB
FTCS is explicit scheme
Square-wave Test for the Explicit Method to solve the Advection Equation
clear;
% Parameters to define the advection equation and the range in space and time
Lmax = 1.0; % Maximum length
Tmax = 1.0; % Maximum time
c = 1.0; % Advection velocity
% Parameters needed to solve the equation within the explicit method
maxt = 3000; % Number of time steps
dt = Tmax/maxt;
n = 30; % Number of space steps
nint=15; % The wave-front: intermediate point from which u=0
dx = Lmax/n;
b = c*dt/(2.*dx);
% Initial value of the function u (amplitude of the wave)
for i = 1:(n+1)
if i < nint
u(i,1)=1.;
else
u(i,1)=0.;
end
x(i) =(i-1)*dx;
end
% Value of the amplitude at the boundary
for k=1:maxt+1
u(1,k) = 1.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit method
for k=1:maxt % Time loop
for i=2:n % Space loop
u(i,k+1) =u(i,k)-b*(u(i+1,k)-u(i-1,k));
end
end
% Graphical representation of the wave at different selected times
plot(x,u(:,1),'-',x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-')
title('Square-wave test within the Explicit Method I')
xlabel('X')
ylabel('Amplitude(X)')
0u uc
t x
  
 
( , ) 1 0
( , ) 0 0
u x t t
u x t x
 
 
7
0.025
2
c t
x
 

FTSC Lax method for Advection Eq
Advection equation
To increase the stability of FTCS method simply
talke the average of term u(n,j) ,
0,1........
0,1........
( , )
n o n
j o n
n j n j
x x n x n N
t t j x j t
u u x t
   
   

0u uc
t x
  
 
FTCS is explicit scheme, 1 , 1, 1,
( )
2n j n j n j n j
c tu u u u
x  
  

1, 1,
,
( )
2
n j n j
n j
u u
u  


1, 1,
, 1 1, 1,
( )
( )
2 2
n j n j
n j n j n j
u u c tu u u
x
 
  
   

LEX method (explicit)
8
Implementation in MATLAB
LEX method is explicit scheme
0u uc
t x
  
 
( , ) 0 0 ( , ) 1 0u x t t u x t x   
wave Test for the Lax method to solve the Advection Equation
clear;
% Parameters to define the advection equation and the range in space and time
Lmax = 1.0; % Maximum length
Tmax = 1.; % Maximum time
c = 1.0; % Advection velocity
% Parameters needed to solve the equation within the Lax method
maxt = 350; % Number of time steps
dt = Tmax/maxt;
n = 300; % Number of space steps
nint=50; % The wave-front: intermediate point from which u=0 (nint<n)!!
dx = Lmax/n;
b = c*dt/(2.*dx);
% The Lax method is stable for abs(b)=< 1/2 but it gets difussed unless abs(b)= 1/2
% Initial value of the function u (amplitude of the wave)
for i = 1:(n+1)
if i < nint
u(i,1)=1.;
else
u(i,1)=0.;
end
x(i) =(i-1)*dx;
end
% Value of the amplitude at the boundary at any time
for k=1:maxt+1
u(1,k) = 1.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the Lax method
for k=1:maxt % Time loop
for i=2:n % Space loop
u(i,k+1) =0.5*(u(i+1,k)+u(i-1,k))-b*(u(i+1,k)-u(i-1,k));
end
end
% Graphical representations of the evolution of the wave
figure(1)
mesh(x,time,u')
title('Square-wave test within the Lax Method'); xlabel('X'); ylabel('T')
figure(2)
plot(x,u(:,1),'-',x,u(:,20),'-',x,u(:,50),'-',x,u(:,100),'-')
title('Square-wave test within the Lax Method')
xlabel('X')
ylabel('Amplitude(X)')
9
1.01
2
c t
x
 

1.0
2
c t
x
 

0.5
2
c t
x
 

CTCS method for Advection
Advection equation
The Forward time and central space (FTCS)
method implementation
,
0,1........
0,1........
( , )
n o n
j o n
n j n j
x x n x n N
t t j x j t
u u x t
   
   

0u uc
t x
  
 
Center point in time
2 2, 1 , 1 1, 1,
( ) ( )
2 2
n j n j n j n j
u u u uu uo t o x
t t x x
   
       
   
Center point in Space
, 1 , 1 1, 1,
2 2
n j n j n j n ju u
t
u u
c
x
   


 

, 1 , 1 1, 1,
2 ( )
2n j n j n j n j
c tu u u u
x   
  

, 1 , 1 1, 1,
( )n j n j n j n j
c tu u u u
x   
  

CTCS is also an explicit scheme
10
CTCS Lax method for Advection Eq
Advection equation
To increase the stability of CTCS method simply
take the average of term u(n,j-1)
,
0,1........
0,1........
( , )
n o n
j o n
n j n j
x x n x n N
t t j x j t
u u x t
   
   

0u uc
t x
  
 
CTCS explicit scheme, 1 , 1 1, 1,
( )n j n j n j n j
c tu u u u
x   
  

1, 1 1, 1
, 1
( )
2
n j n j
n j
u u
u    



1, 1 1, 1
, 1 1, 1,
( )
( )
2
n j n j
n j n j n j
u u c tu u u
x
   
  
   

LEX CTCS method (explicit)
, 1 , 1 1, 1,
( )n j n j n j n j
c tu u u u
x   
  

11
Implementation in MATLAB (CTCS)
0u uc
t x
  
 
( , ) 1 0
( , ) 0 0
u x t t
u x t x
 
 
% Matlab Program : Square-wave Test for the Explicit Method to solve the advection Equation
clear;
% Parameters to define the advection equation and the range in space and % time
Lmax = 1.0; % Maximum length
Tmax = 1.; % Maximum time
c = 1.0; % Advection velocity
% Parameters needed to solve the equation within the explicit method
maxt = 100; % Number of time steps
dt = Tmax/maxt;
n = 100; % Number of space steps
nint=15; % The wave-front: intermediate point from which u=0
dx = Lmax/n;
b = c*dt/(dx)
% Initial value of the function u (amplitude of the wave)
for i = 1:(n+1)
if i < nint
u(i,1)=1.;else
u(i,1)=0.;
end
x(i) =(i-1)*dx;
end
% Value of the amplitude at the boundary
for k=2:maxt+1
u(1,k) = 1.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit method
for k=2:maxt % Time loop
for i=2:n % Space loop
u(i,k+1) =u(i,k-1)-b*(u(i+1,k)-u(i-1,k));
end
end
% Graphical representation of the wave at different selected times
plot(x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-',x,u(:,maxt),'-')
title('Square-wave test within the Explicit Method')
xlabel('X')
ylabel('Amplitude(X)')
1c t
x
 

0.5c t
x
 

12
Implementation in MATLAB (CTCS)
0u uc
t x
  
 
( , ) 1 0
( , ) 0 0
u x t t
u x t x
 
 
% Matlab Program : Square-wave Test for the Explicit Method to solve the advection Equation
clear;
% Parameters to define the advection equation and the range in space and % time
Lmax = 1.0; % Maximum length
Tmax = 1.; % Maximum time
c = 1.0; % Advection velocity
% Parameters needed to solve the equation within the explicit method
maxt = 100; % Number of time steps
dt = Tmax/maxt;
n = 100; % Number of space steps
nint=15; % The wave-front: intermediate point from which u=0
dx = Lmax/n;
b = c*dt/(dx)
% Initial value of the function u (amplitude of the wave)
for i = 1:(n+1)
if i < nint
u(i,1)=1.;else
u(i,1)=0.;
end
x(i) =(i-1)*dx;
end
% Value of the amplitude at the boundary
for k=2:maxt+1
u(1,k) = 1.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit method
for k=2:maxt % Time loop
for i=2:n % Space loop
u(i,k+1) =0.5*(u(i+1,k-1)+u(i-1,k-1))-b*(u(i+1,k)-u(i-1,k));
end
end
% Graphical representation of the wave at different selected times
plot(x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-',x,u(:,maxt),'-')
title('Square-wave test within the Explicit Method')
xlabel('X')
ylabel('Amplitude(X)')
0.5c t
x
 

1c t
x
 

13
Mehboob, K
NE: 402 computation Method in Nuclear
Engineering
Department of Nuclear Engineering,
KAU, Jeddah, KSA
2017. 5. 3
How to solve 2nd Order PDEs
using MATLAB
14
Diffusion Problem
),(
),(),(
2
2
txS
x
txu
D
t
txu






L
x
xu
conditionsinitial
tutLututu
conditionsBoundry
2
cos100)0,(
),(),(),(),0( 21



ydiffusivitThermalD :
SourceHeattxS :),(
),(
),(),(
txS
x
txu
D
xt
txu













15
FTCS method for the heat equation
FTCS ( Forward Euler in Time and Central difference in Space )
):),(),(),(),0((
),(),(),(
21
2
2
ydiffusivitthermalDtutLututu
txStxu
x
Dtxu
t







Heat equation in a slab
),( 1
t
uu
t
txu n
j
n
jnj




 
2
11
2
2
2),(
x
uuu
x
txu n
j
n
j
n
jnj




 
n
jnj utxu ),(Let
Forward Euler in Time
2nd order Central difference in Space
1
2 1 1
( 2 )n n n n n n
j j j j j j
D tu u tS u u u
x

 
    

1
1 1
2
2
( , )
n n n n n
j j j j j
u u u u u
D s x t
t x

 
  
 
 
FTCS explicit scheme for diffusion Equation
16
Implementation in MATLAB (FTCS heat equation)
% Heat Diffusion in one dimensional wire within the % Explicit Method
clear;
% Parameters to define the heat equation and the range in space and time
L = 1.; % Length of the wire
T =1.; % Final time
% Parameters needed to solve the equation within the explicit method
maxk = 2500; % Number of time steps
dt = T/maxk;
n = 50; % Number of space steps
dx = L/n;
cond = 1/4; % Conductivity
b = cond*dt/(dx*dx); % Stability parameter (b=<1)
% Initial temperature of the wire: a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end
% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit method
for k=1:maxk % Time Loop
for i=2:n; % Space Loop
u(i,k+1) =u(i,k) + b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
end
end
% Graphical representation of the temperature at different selected times
figure(1)
plot(x,u(:,1),'-',x,u(:,100),'-',x,u(:,300),'-',x,u(:,600),'-')
title('Temperature within the explicit method')
xlabel('X')
ylabel('T')
figure(2)
mesh(x,time,u')
title('Temperature within the explicit method')
xlabel('X')
ylabel('Temperature')
),(
),(),(
2
2
txS
x
txu
D
t
txu






)sin()0,(
0),(,0),(,0),0(
xxu
conditionsinitial
txstLutu
conditionsBoundry


17
Implementation in MATLAB (FTCS heat equation)
Courant condition for
FTCS
1
2
2



x
tD
2
2 1.01D t
x
 
2
2 1
2
D t
x
 

18
CTCS method for the heat equation
FTCS ( Forward Euler in Time and Central difference in Space )
):),(),(),(),0((
),(),(),(
21
2
2
ydiffusivitthermalDtutLututu
txStxu
x
Dtxu
t







Heat equation in a slab
2
),( 11
t
uu
t
txu n
j
n
jnj




 
2
11
2
2
2),(
x
uuu
x
txu n
j
n
j
n
jnj




 
n
jnj utxu ),(Let
Center difference in Time
2nd order Central difference in Space
1 1
2 1 1
22 ( 2 )n n n n n n
j j j j j j
D tu u tS u u u
x
 
 
     

1 1
1 1
2
2
( , )
2
n n n n n
j j j j j
u u u u u
D s x t
t x
 
 
  
 
 
FTCS explicit scheme for diffusion Equation
19
CTCS method for the heat equation% Heat Diffusion in one dimensional wire within the % Explicit Method
clear; clc;
% Parameters to define the heat equation and the range in space and time
L = 1.; % Length of the wire
T =1.; % Final time
% Parameters needed to solve the equation within the explicit method
maxk = 600; % Number of time steps
dt = T/maxk;
n = 20; % Number of space steps
dx = L/n;
cond = 1/132; % Conductivity
b =2.*cond*dt/(dx*dx) % Stability parameter (b=<0.01)
% Initial temperature of the wire: a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end
% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit method
for k=2:maxk % Time Loop
for i=2:n; % Space Loop
u(i,k+1) =u(i,k-1) + 0.5*2*b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
end
end
% Graphical representation of the temperature at different selected times
figure(1)
plot(x,u(:,1),'-',x,u(:,10),'-',x,u(:,30),'-',x,u(:,60),'-')
title('Temperature within the explicit method')
xlabel('X')
ylabel('T')
figure(2)
mesh(x,time,u')
title('Temperature within the explicit method')
xlabel('X')
ylabel('Temperature')
),(
),(),(
2
2
txS
x
txu
D
t
txu






)sin()0,(
0),(,0),(,0),0(
xxu
conditionsinitial
txstLutu
conditionsBoundry


0126.0
2
2



x
tD
20
Stability of FTCS and CTCS
FTCS is first-order accuracy in time and second-order
accuracy in space.
So small time steps are required to achieve reasonable
accuracy.
Courant condition for FTCS
2
1
2



x
tD
)2(
2
2 112
11 n
j
n
j
n
j
n
j
n
j
n
j uuu
x
tD
tSuu 





CTCS method for heat equation
(Both the time and space derivatives are
center-differenced.)
However, CTCS method is unstable for
any time step size.
2
2 1
2
D t
x
 

2
2 0.0126D t
x
 

CTCS (unstable)
FTCS (Stable)
21
Lax method (FTCS)
Simple modification to the FTCS method
In the differenced time derivative,
)2()( 112112
11 n
j
n
j
n
j
n
j
n
j
n
j
n
j uuu
x
tD
tSuuu 





t
uuu
t
uu n
j
n
j
n
j
n
j
n
j




 

)]([)( 112
111
Replacement by average value from surrounding grid points
The resulting difference equation is
Courant condition for Lax method
4
1
2



x
tD
( Second-order accuracy in both time and space )
22
Lax method(CTCS)
Simple modification to the CTCS method
In the differenced time derivative,
)2(
2
2)( 112
1
1
1
12
11 n
j
n
j
n
j
n
j
n
j
n
j
n
j uuu
x
tD
tSuuu 









t
uuu
t
uu n
j
n
j
n
j
n
j
n
j




 




2
)]([
2
)( 1
1
1
12
1111
Replacement by average value from surrounding grid points
The resulting difference equation is
Courant condition for Lax method
4
1
2



x
tD
( Second-order accuracy in both time and space )
23
Implementation (FTCS-Lax) Method
% Initial temperature of the wire: a
sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end
% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit
method
for k=2:maxk % Time Loop
for i=2:n; % Space Loop
u(i,k+1) =0.5*(u(i+1,k)+u(i-1,k)) +
0.5*b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
end
end
2
2 0.1786D t
x
 

2
2 1
2
D t
x
 

Stability condition
2
2 0.0047D t
x
 

24
Implementation Lax method(CTCS)
2
2 0.3571D t
x
 

2
2 1
2
D t
x
 

Stability condition
% Initial temperature of the wire:
a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end
% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end
% Implementation of the explicit
method
for k=2:maxk % Time Loop
for i=2:n; % Space Loop
u(i,k+1) =0.5*(u(i+1,k-1)+u(i-1,k-
1))+ 0.5*2*b*(u(i-1,k)+u(i+1,k)-
2.*u(i,k));
end
end
25
Implementation Lax method(CTCS)
26
Crank Nicolson Algorithm ( Implicit Method )
BTCS ( Backward time, centered space ) method for heat equation
)2( 11
1
2
n
j
n
j
n
jx
tn
j
n
j
n
j TTTtSTT 

 
( This is stable for any choice of time steps,
however it is first-order accurate in time. )
Crank-Nicolson scheme for heat equation
taking the average between time steps n-1 and n,

))22(
)(
1
1
11
111
1
2
11
2








n
j
n
j
n
j
n
j
n
j
n
jx
t
n
j
n
j
n
j
n
j
TTTTTT
SStTT

( This is stable for any choice of time steps and second-order accurate in time. )
a set of coupled linear equations for n
jT
27
Crank Nicolson Algorithm
Initial
conditions
Plot
Crank-
Nicolson
scheme
)/sin(),(
22
/
LxetxT Lt


Exact solution
28
Crank Nicolson Algorithm
29
Multiple Spatial Dimensions
),,(),,(),,( 2
2
2
2
tyxStyxT
yx
tyxT
t















FTCS for 2D heat equation
)2()2( 112112
1 n
jk
n
jk
n
jk
n
kj
n
jk
n
kj
n
jk
n
jk
n
jk TTT
y
t
TTT
x
t
tSTT 









Courant condition for this scheme
22
22
2
1
yx
yx
t



( Other schemes such as CTCS and Lax can be easily extended to multiple dimensions. )
30
Wave equation with nonuniform wave speed
),,(),(),,( 2
2
2
2
2
2
2
tyxz
yx
yxctyxz
t 













2D wave equation
0
),()0,,(),,()0,,(
00
00


vz
yxvyxzyxzyxz 
txxtxz
txztyztyz
2sin)1(),0,(
,0),1,(),,1(),,0(


Initial condition :
Boundary
condition :
 ])5.0(5)5.0(2exp[7.01),( 22
10
1
 yxyxcWave speed :
)2()2(2 112
22
112
22
11 n
jk
n
jk
n
jk
jkn
kj
n
jk
n
kj
jkn
jk
n
jk
n
jk TTz
y
tc
zzz
x
tc
zzz 








CTCS method for the wave equation :
)(
2
1
2
22



yxfor
tc
Courant condition :
31
Wave equation with nonuniform wave speed
Since evaluation of the nth timestep
refers back to the n-2nd step,
for the first step, a trick is employed.
jk
t
jkjkjk atvzz 20
01 2


)2()2( 112
2
0
1
00
12
2
n
jk
n
jk
n
jk
jk
kjjkkj
jk
jk TTz
y
c
zzz
x
c
a  




Since initial velocity and value,
0
0
1
0
0


jk
jkjk
z
zv
32
Wave equation with nonuniform wave speed
33
Wave equation with nonuniform wave speed
34
2D Poisson’s equation
),(),()( 2
2
2
2
yxyxyx
  



Poisson’s equation
Direct Solution for Poisson’s equation
jk
jkjkjkkjjkkj
yx







 
2
11
2
11 22
Centered-difference the spatial derivatives
35
Jacobi’s method ( Relaxation method )
Direct solution can be difficult to program efficiently.
Relaxation methods are relatively simple to code,
however, they are not as fast as the direct methods.
Idea :
I. Poisson’s equation can be thought of as the equilibrium solution to the heat
equation with source.
II. Starting with any initial condition, the heat equation solution will eventually
relax to a solution of Poisson’s equation.













 

)2(
1
)2(
1
2
1
11211222
22
1 n
jk
n
jk
n
jk
n
kj
n
jk
n
kjjk
n
jk
n
jk
yxyx
yx














  )(
1
)(
1
2
1
11211222
22
n
jk
n
jk
n
kj
n
kjjk
yxyx
yx

),(),(),,(
t
),(),( 22
yxyxtyxyxyx  


 )
2
1
( 22
22
yx
yx
t



FTCS
(Maximum time step satisfying Courant condition)
36
Jacobi method
37
Simultaneous OverRelaxation (SOR)
The convergence of the Jacobi method is quite slow.
Furthermore, the larger the system, the slower the convergence.
Simultaneous OverRelaxation (SOR) :
the Jacobi method is modified in two ways,



















)(
1
)(
1
2
)1(
1
112
1
112
22
22
1
n
jk
n
jk
n
kj
n
kjjk
n
jk
n
jk
yx
yx
yx



1. Improved values are used as soon as they become available.
2. Relaxation parameter ω tries to overshoot for going to the final result.
( 1<ω<2)
38
Simultaneous OverRelaxation (SOR)
39
MATLAB The Language of Technical Computing MATLAB PDE
Run: dftcs.m >> dftcs
dftcs - Program to solve the diffusion equation using the Forward Time Centered Space scheme.
Enter time step: 0.0001
Enter the number of grid points: 51
Solution is expected to be stable
2
2
),(),(
x
txT
t
txT






40
MATLAB The Language of Technical Computing MATLAB PDE
Run: dftcs.m >> dftcs
dftcs - Program to solve the diffusion equation using the Forward Time Centered Space scheme.
Enter time step: 0.00015
Enter the number of grid points: 61
WARNING: Solution is expected to be unstable
41
MATLAB The Language of Technical Computing MATLAB PDE
Run: neutrn.m >> neutrn Program to solve the neutron diffusion equation using the FTCS.
Enter time step: 0.0005
Enter the number of grid points: 61
Enter system length: 2 => System length is subcritical
Solution is expected to be stable
Enter number of time steps: 12000
),(
),(),(
2
2
txn
x
txn
t
txn
 





42
MATLAB The Language of Technical Computing MATLAB PDE
Run: neutrn.m >> neutrn Program to solve the neutron diffusion equation using the FTCS.
Enter time step: 0.0005
Enter the number of grid points: 61
Enter system length: 4 => System length is supercritical
Solution is expected to be stable
Enter number of time steps: 12000
43
MATLAB The Language of Technical Computing MATLAB PDE
Run: advect.m >> advect
advect - Program to solve the advection equation using the various hyperbolic PDE schemes:
FTCS, Lax, Lax-Wendorf
Enter number of grid points: 50
Time for wave to move one grid spacing is 0.02
Enter time step: 0.002
Wave circles system in 500 steps
Enter number of steps: 500
FTCS FTCS
0
),(),(






x
txu
t
txu

44
MATLAB The Language of Technical Computing MATLAB PDE
Run: advect.m >> advect
advect - Program to solve the advection equation using the various hyperbolic PDE schemes:
FTCS, Lax, Lax-Wendorf
Enter number of grid points: 50
Time for wave to move one grid spacing is 0.02
Enter time step: 0.02
Wave circles system in 50 steps
Enter number of steps: 50
Lax Lax
45
MATLAB The Language of Technical Computing MATLAB PDE
Run: relax.m >> relax
relax - Program to solve the Laplace equation using Jacobi, Gauss-Seidel and SOR methods on a
square grid
Enter number of grid points on a side: 50
Theoretical optimum omega = 1.88184
Enter desired omega: 1.8
Potential at y=L equals 1
Potential is zero on all other boundaries
Desired fractional change = 0.0001
0
),(),(
2
2
2
2






y
yx
x
yx 
46
47
The END
47

More Related Content

What's hot

Gaussian Quadrature Formula
Gaussian Quadrature FormulaGaussian Quadrature Formula
Gaussian Quadrature FormulaDhaval Shukla
 
Introduction to finite element method(fem)
Introduction to finite element method(fem)Introduction to finite element method(fem)
Introduction to finite element method(fem)Sreekanth G
 
Fundamentals of Finite Difference Methods
Fundamentals of Finite Difference MethodsFundamentals of Finite Difference Methods
Fundamentals of Finite Difference Methods1rj
 
Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...
Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...
Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...IOSR Journals
 
Numerical Analysis (Solution of Non-Linear Equations) part 2
Numerical Analysis (Solution of Non-Linear Equations) part 2Numerical Analysis (Solution of Non-Linear Equations) part 2
Numerical Analysis (Solution of Non-Linear Equations) part 2Asad Ali
 
FEM: Introduction and Weighted Residual Methods
FEM: Introduction and Weighted Residual MethodsFEM: Introduction and Weighted Residual Methods
FEM: Introduction and Weighted Residual MethodsMohammad Tawfik
 
OpenFoam Simulation of Flow over Ahmed Body using Visual CFD software
OpenFoam Simulation of Flow over Ahmed Body using Visual CFD softwareOpenFoam Simulation of Flow over Ahmed Body using Visual CFD software
OpenFoam Simulation of Flow over Ahmed Body using Visual CFD softwareSrinivas Nag H.V
 
Linear Systems Gauss Seidel
Linear Systems   Gauss SeidelLinear Systems   Gauss Seidel
Linear Systems Gauss SeidelEric Davishahl
 
Gauss elimination method
Gauss elimination methodGauss elimination method
Gauss elimination methodgilandio
 
Delay-Differential Equations. Tools for Epidemics Modelling
Delay-Differential Equations. Tools for Epidemics ModellingDelay-Differential Equations. Tools for Epidemics Modelling
Delay-Differential Equations. Tools for Epidemics ModellingIgnasi Gros
 
Numerical methods for 2 d heat transfer
Numerical methods for 2 d heat transferNumerical methods for 2 d heat transfer
Numerical methods for 2 d heat transferArun Sarasan
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsMeenakshisundaram N
 
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONSNUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONSnaveen kumar
 
ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSfenil patel
 

What's hot (20)

Gaussian Quadrature Formula
Gaussian Quadrature FormulaGaussian Quadrature Formula
Gaussian Quadrature Formula
 
Introduction to finite element method(fem)
Introduction to finite element method(fem)Introduction to finite element method(fem)
Introduction to finite element method(fem)
 
Fundamentals of Finite Difference Methods
Fundamentals of Finite Difference MethodsFundamentals of Finite Difference Methods
Fundamentals of Finite Difference Methods
 
Finite Element Methods
Finite Element  MethodsFinite Element  Methods
Finite Element Methods
 
Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...
Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...
Numerical Solution for Two Dimensional Laplace Equation with Dirichlet Bounda...
 
Numerical Analysis (Solution of Non-Linear Equations) part 2
Numerical Analysis (Solution of Non-Linear Equations) part 2Numerical Analysis (Solution of Non-Linear Equations) part 2
Numerical Analysis (Solution of Non-Linear Equations) part 2
 
Introduction to Finite Elements
Introduction to Finite ElementsIntroduction to Finite Elements
Introduction to Finite Elements
 
FEM: Introduction and Weighted Residual Methods
FEM: Introduction and Weighted Residual MethodsFEM: Introduction and Weighted Residual Methods
FEM: Introduction and Weighted Residual Methods
 
OpenFoam Simulation of Flow over Ahmed Body using Visual CFD software
OpenFoam Simulation of Flow over Ahmed Body using Visual CFD softwareOpenFoam Simulation of Flow over Ahmed Body using Visual CFD software
OpenFoam Simulation of Flow over Ahmed Body using Visual CFD software
 
Linear Systems Gauss Seidel
Linear Systems   Gauss SeidelLinear Systems   Gauss Seidel
Linear Systems Gauss Seidel
 
METHOD OF JACOBI
METHOD OF JACOBIMETHOD OF JACOBI
METHOD OF JACOBI
 
Gauss elimination method
Gauss elimination methodGauss elimination method
Gauss elimination method
 
Jacobi method for MATLAB
Jacobi method for MATLAB Jacobi method for MATLAB
Jacobi method for MATLAB
 
Delay-Differential Equations. Tools for Epidemics Modelling
Delay-Differential Equations. Tools for Epidemics ModellingDelay-Differential Equations. Tools for Epidemics Modelling
Delay-Differential Equations. Tools for Epidemics Modelling
 
Numerical methods for 2 d heat transfer
Numerical methods for 2 d heat transferNumerical methods for 2 d heat transfer
Numerical methods for 2 d heat transfer
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential Equations
 
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONSNUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
 
Quadrature
QuadratureQuadrature
Quadrature
 
ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONS
 
Rayleigh Ritz Method
Rayleigh Ritz MethodRayleigh Ritz Method
Rayleigh Ritz Method
 

Similar to Computational Method to Solve the Partial Differential Equations (PDEs)

Project on CFD using MATLAB
Project on CFD using MATLABProject on CFD using MATLAB
Project on CFD using MATLABRohit Avadhani
 
Ray : modeling dynamic systems
Ray : modeling dynamic systemsRay : modeling dynamic systems
Ray : modeling dynamic systemsHouw Liong The
 
Ph 101-9 QUANTUM MACHANICS
Ph 101-9 QUANTUM MACHANICSPh 101-9 QUANTUM MACHANICS
Ph 101-9 QUANTUM MACHANICSChandan Singh
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Alexander Litvinenko
 
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Alexander Litvinenko
 
SURF 2012 Final Report(1)
SURF 2012 Final Report(1)SURF 2012 Final Report(1)
SURF 2012 Final Report(1)Eric Zhang
 
Introduction to Diffusion Monte Carlo
Introduction to Diffusion Monte CarloIntroduction to Diffusion Monte Carlo
Introduction to Diffusion Monte CarloClaudio Attaccalite
 
Mit2 092 f09_lec20
Mit2 092 f09_lec20Mit2 092 f09_lec20
Mit2 092 f09_lec20Rahman Hakim
 
Fourier Specturm via MATLAB
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLABZunAib Ali
 

Similar to Computational Method to Solve the Partial Differential Equations (PDEs) (20)

Project on CFD using MATLAB
Project on CFD using MATLABProject on CFD using MATLAB
Project on CFD using MATLAB
 
assignment_2
assignment_2assignment_2
assignment_2
 
Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
 
residue
residueresidue
residue
 
Ray : modeling dynamic systems
Ray : modeling dynamic systemsRay : modeling dynamic systems
Ray : modeling dynamic systems
 
002 ray modeling dynamic systems
002 ray modeling dynamic systems002 ray modeling dynamic systems
002 ray modeling dynamic systems
 
002 ray modeling dynamic systems
002 ray modeling dynamic systems002 ray modeling dynamic systems
002 ray modeling dynamic systems
 
Ph 101-9 QUANTUM MACHANICS
Ph 101-9 QUANTUM MACHANICSPh 101-9 QUANTUM MACHANICS
Ph 101-9 QUANTUM MACHANICS
 
wave_equation
wave_equationwave_equation
wave_equation
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...
 
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
 
Mechanical Engineering Assignment Help
Mechanical Engineering Assignment HelpMechanical Engineering Assignment Help
Mechanical Engineering Assignment Help
 
Wave function
Wave functionWave function
Wave function
 
Solution a ph o 3
Solution a ph o 3Solution a ph o 3
Solution a ph o 3
 
SURF 2012 Final Report(1)
SURF 2012 Final Report(1)SURF 2012 Final Report(1)
SURF 2012 Final Report(1)
 
05_AJMS_332_21.pdf
05_AJMS_332_21.pdf05_AJMS_332_21.pdf
05_AJMS_332_21.pdf
 
KAUST_talk_short.pdf
KAUST_talk_short.pdfKAUST_talk_short.pdf
KAUST_talk_short.pdf
 
Introduction to Diffusion Monte Carlo
Introduction to Diffusion Monte CarloIntroduction to Diffusion Monte Carlo
Introduction to Diffusion Monte Carlo
 
Mit2 092 f09_lec20
Mit2 092 f09_lec20Mit2 092 f09_lec20
Mit2 092 f09_lec20
 
Fourier Specturm via MATLAB
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLAB
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

Computational Method to Solve the Partial Differential Equations (PDEs)

  • 1. 1 Computational Method to Solve the Partial Differential Equations (PDEs) By Dr. Khurram Mehboob 1
  • 2. Mehboob, K NE: 402 computation Method in Nuclear Engineering Department of Nuclear Engineering, KAU, Jeddah, KSA 2017. 5. 1 How to solve 1st Order PDEs using MATLAB 2
  • 3. Contents • Solving PDEs using MATLAB (Explicit method) - FTCS method - Lax method - Crank Nicolson method - Jacobi’s method - Simultaneous-over-relaxation (SOR) method • Solving PDEs using MATLAB - Examples of PDEs 3
  • 4. PDE (Partial Differential Equation) PDEs are used as mathematical models for phenomena in all branches of engineering and science. 2 2 2 2 2 2 ( , , , , ) u u u u u A B C D x t u t xt x t x              u u and t x     linear in - Three Types of PDEs: 1) Elliptic:  Steady heat transfer, flow and diffusion 2) Parabolic:  Transient heat transfer, flow and diffusion 3) Hyperbolic:  Transient wave equation 2 0B AC  2 2 2 2 0u u x y      Laplace equations 2 0B AC  2 2 u uD t x     Diffusion Equation 2 0B AC  2 2 2 2 2 1u u x c t     Wave Equation 4
  • 5. Similarity method to solve PDE often the solution of a PDE together wit its initial and boundary problem depends upon its variables. In such cases the problem can be reduce to the combination ODEs with its independent variables The key to the similarity solution is the diffusing equation is that both the equations and initial and boundary conditions are under the scaling x→lx and t →l2x. Therefore, x/√t is independent transformation. In general the function should be of form The u(x,t)=U(z) 2 2 u u t x     , 0t x  ( , ) 1 0 ( , ) 0 0 u x t t u x t x     ( / )u t f x t   x t   2 2 1 0 2 U U        (0) 1 ( ) 0 U U    2 /4 0 ( ) s U C e ds D      2 /41( ) s U e ds        2 /4 / 1( , ) s x t u x t e ds      5
  • 6. FTCS method for Advection Eq Advection equation The Forward time and central space (FTCS) method implementation , 0,1........ 0,1........ ( , ) n o n j o n n j n j x x n x n N t t j x j t u u x t          , 1 , 1, 1, 2 n j n j n j n j u u u u c t x          0u uc t x      FTCS is explicit scheme , 1 , 1, 1, ( ) 2n j n j n j n j c tu u u u x       6
  • 7. Implementation in MATLAB FTCS is explicit scheme Square-wave Test for the Explicit Method to solve the Advection Equation clear; % Parameters to define the advection equation and the range in space and time Lmax = 1.0; % Maximum length Tmax = 1.0; % Maximum time c = 1.0; % Advection velocity % Parameters needed to solve the equation within the explicit method maxt = 3000; % Number of time steps dt = Tmax/maxt; n = 30; % Number of space steps nint=15; % The wave-front: intermediate point from which u=0 dx = Lmax/n; b = c*dt/(2.*dx); % Initial value of the function u (amplitude of the wave) for i = 1:(n+1) if i < nint u(i,1)=1.; else u(i,1)=0.; end x(i) =(i-1)*dx; end % Value of the amplitude at the boundary for k=1:maxt+1 u(1,k) = 1.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=1:maxt % Time loop for i=2:n % Space loop u(i,k+1) =u(i,k)-b*(u(i+1,k)-u(i-1,k)); end end % Graphical representation of the wave at different selected times plot(x,u(:,1),'-',x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-') title('Square-wave test within the Explicit Method I') xlabel('X') ylabel('Amplitude(X)') 0u uc t x      ( , ) 1 0 ( , ) 0 0 u x t t u x t x     7 0.025 2 c t x   
  • 8. FTSC Lax method for Advection Eq Advection equation To increase the stability of FTCS method simply talke the average of term u(n,j) , 0,1........ 0,1........ ( , ) n o n j o n n j n j x x n x n N t t j x j t u u x t          0u uc t x      FTCS is explicit scheme, 1 , 1, 1, ( ) 2n j n j n j n j c tu u u u x       1, 1, , ( ) 2 n j n j n j u u u     1, 1, , 1 1, 1, ( ) ( ) 2 2 n j n j n j n j n j u u c tu u u x           LEX method (explicit) 8
  • 9. Implementation in MATLAB LEX method is explicit scheme 0u uc t x      ( , ) 0 0 ( , ) 1 0u x t t u x t x    wave Test for the Lax method to solve the Advection Equation clear; % Parameters to define the advection equation and the range in space and time Lmax = 1.0; % Maximum length Tmax = 1.; % Maximum time c = 1.0; % Advection velocity % Parameters needed to solve the equation within the Lax method maxt = 350; % Number of time steps dt = Tmax/maxt; n = 300; % Number of space steps nint=50; % The wave-front: intermediate point from which u=0 (nint<n)!! dx = Lmax/n; b = c*dt/(2.*dx); % The Lax method is stable for abs(b)=< 1/2 but it gets difussed unless abs(b)= 1/2 % Initial value of the function u (amplitude of the wave) for i = 1:(n+1) if i < nint u(i,1)=1.; else u(i,1)=0.; end x(i) =(i-1)*dx; end % Value of the amplitude at the boundary at any time for k=1:maxt+1 u(1,k) = 1.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the Lax method for k=1:maxt % Time loop for i=2:n % Space loop u(i,k+1) =0.5*(u(i+1,k)+u(i-1,k))-b*(u(i+1,k)-u(i-1,k)); end end % Graphical representations of the evolution of the wave figure(1) mesh(x,time,u') title('Square-wave test within the Lax Method'); xlabel('X'); ylabel('T') figure(2) plot(x,u(:,1),'-',x,u(:,20),'-',x,u(:,50),'-',x,u(:,100),'-') title('Square-wave test within the Lax Method') xlabel('X') ylabel('Amplitude(X)') 9 1.01 2 c t x    1.0 2 c t x    0.5 2 c t x   
  • 10. CTCS method for Advection Advection equation The Forward time and central space (FTCS) method implementation , 0,1........ 0,1........ ( , ) n o n j o n n j n j x x n x n N t t j x j t u u x t          0u uc t x      Center point in time 2 2, 1 , 1 1, 1, ( ) ( ) 2 2 n j n j n j n j u u u uu uo t o x t t x x                 Center point in Space , 1 , 1 1, 1, 2 2 n j n j n j n ju u t u u c x          , 1 , 1 1, 1, 2 ( ) 2n j n j n j n j c tu u u u x        , 1 , 1 1, 1, ( )n j n j n j n j c tu u u u x        CTCS is also an explicit scheme 10
  • 11. CTCS Lax method for Advection Eq Advection equation To increase the stability of CTCS method simply take the average of term u(n,j-1) , 0,1........ 0,1........ ( , ) n o n j o n n j n j x x n x n N t t j x j t u u x t          0u uc t x      CTCS explicit scheme, 1 , 1 1, 1, ( )n j n j n j n j c tu u u u x        1, 1 1, 1 , 1 ( ) 2 n j n j n j u u u        1, 1 1, 1 , 1 1, 1, ( ) ( ) 2 n j n j n j n j n j u u c tu u u x             LEX CTCS method (explicit) , 1 , 1 1, 1, ( )n j n j n j n j c tu u u u x        11
  • 12. Implementation in MATLAB (CTCS) 0u uc t x      ( , ) 1 0 ( , ) 0 0 u x t t u x t x     % Matlab Program : Square-wave Test for the Explicit Method to solve the advection Equation clear; % Parameters to define the advection equation and the range in space and % time Lmax = 1.0; % Maximum length Tmax = 1.; % Maximum time c = 1.0; % Advection velocity % Parameters needed to solve the equation within the explicit method maxt = 100; % Number of time steps dt = Tmax/maxt; n = 100; % Number of space steps nint=15; % The wave-front: intermediate point from which u=0 dx = Lmax/n; b = c*dt/(dx) % Initial value of the function u (amplitude of the wave) for i = 1:(n+1) if i < nint u(i,1)=1.;else u(i,1)=0.; end x(i) =(i-1)*dx; end % Value of the amplitude at the boundary for k=2:maxt+1 u(1,k) = 1.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=2:maxt % Time loop for i=2:n % Space loop u(i,k+1) =u(i,k-1)-b*(u(i+1,k)-u(i-1,k)); end end % Graphical representation of the wave at different selected times plot(x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-',x,u(:,maxt),'-') title('Square-wave test within the Explicit Method') xlabel('X') ylabel('Amplitude(X)') 1c t x    0.5c t x    12
  • 13. Implementation in MATLAB (CTCS) 0u uc t x      ( , ) 1 0 ( , ) 0 0 u x t t u x t x     % Matlab Program : Square-wave Test for the Explicit Method to solve the advection Equation clear; % Parameters to define the advection equation and the range in space and % time Lmax = 1.0; % Maximum length Tmax = 1.; % Maximum time c = 1.0; % Advection velocity % Parameters needed to solve the equation within the explicit method maxt = 100; % Number of time steps dt = Tmax/maxt; n = 100; % Number of space steps nint=15; % The wave-front: intermediate point from which u=0 dx = Lmax/n; b = c*dt/(dx) % Initial value of the function u (amplitude of the wave) for i = 1:(n+1) if i < nint u(i,1)=1.;else u(i,1)=0.; end x(i) =(i-1)*dx; end % Value of the amplitude at the boundary for k=2:maxt+1 u(1,k) = 1.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=2:maxt % Time loop for i=2:n % Space loop u(i,k+1) =0.5*(u(i+1,k-1)+u(i-1,k-1))-b*(u(i+1,k)-u(i-1,k)); end end % Graphical representation of the wave at different selected times plot(x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-',x,u(:,maxt),'-') title('Square-wave test within the Explicit Method') xlabel('X') ylabel('Amplitude(X)') 0.5c t x    1c t x    13
  • 14. Mehboob, K NE: 402 computation Method in Nuclear Engineering Department of Nuclear Engineering, KAU, Jeddah, KSA 2017. 5. 3 How to solve 2nd Order PDEs using MATLAB 14
  • 16. FTCS method for the heat equation FTCS ( Forward Euler in Time and Central difference in Space ) ):),(),(),(),0(( ),(),(),( 21 2 2 ydiffusivitthermalDtutLututu txStxu x Dtxu t        Heat equation in a slab ),( 1 t uu t txu n j n jnj       2 11 2 2 2),( x uuu x txu n j n j n jnj       n jnj utxu ),(Let Forward Euler in Time 2nd order Central difference in Space 1 2 1 1 ( 2 )n n n n n n j j j j j j D tu u tS u u u x          1 1 1 2 2 ( , ) n n n n n j j j j j u u u u u D s x t t x           FTCS explicit scheme for diffusion Equation 16
  • 17. Implementation in MATLAB (FTCS heat equation) % Heat Diffusion in one dimensional wire within the % Explicit Method clear; % Parameters to define the heat equation and the range in space and time L = 1.; % Length of the wire T =1.; % Final time % Parameters needed to solve the equation within the explicit method maxk = 2500; % Number of time steps dt = T/maxk; n = 50; % Number of space steps dx = L/n; cond = 1/4; % Conductivity b = cond*dt/(dx*dx); % Stability parameter (b=<1) % Initial temperature of the wire: a sinus. for i = 1:n+1 x(i) =(i-1)*dx; u(i,1) =sin(pi*x(i)); end % Temperature at the boundary (T=0) for k=1:maxk+1 u(1,k) = 0.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=1:maxk % Time Loop for i=2:n; % Space Loop u(i,k+1) =u(i,k) + b*(u(i-1,k)+u(i+1,k)-2.*u(i,k)); end end % Graphical representation of the temperature at different selected times figure(1) plot(x,u(:,1),'-',x,u(:,100),'-',x,u(:,300),'-',x,u(:,600),'-') title('Temperature within the explicit method') xlabel('X') ylabel('T') figure(2) mesh(x,time,u') title('Temperature within the explicit method') xlabel('X') ylabel('Temperature') ),( ),(),( 2 2 txS x txu D t txu       )sin()0,( 0),(,0),(,0),0( xxu conditionsinitial txstLutu conditionsBoundry   17
  • 18. Implementation in MATLAB (FTCS heat equation) Courant condition for FTCS 1 2 2    x tD 2 2 1.01D t x   2 2 1 2 D t x    18
  • 19. CTCS method for the heat equation FTCS ( Forward Euler in Time and Central difference in Space ) ):),(),(),(),0(( ),(),(),( 21 2 2 ydiffusivitthermalDtutLututu txStxu x Dtxu t        Heat equation in a slab 2 ),( 11 t uu t txu n j n jnj       2 11 2 2 2),( x uuu x txu n j n j n jnj       n jnj utxu ),(Let Center difference in Time 2nd order Central difference in Space 1 1 2 1 1 22 ( 2 )n n n n n n j j j j j j D tu u tS u u u x            1 1 1 1 2 2 ( , ) 2 n n n n n j j j j j u u u u u D s x t t x            FTCS explicit scheme for diffusion Equation 19
  • 20. CTCS method for the heat equation% Heat Diffusion in one dimensional wire within the % Explicit Method clear; clc; % Parameters to define the heat equation and the range in space and time L = 1.; % Length of the wire T =1.; % Final time % Parameters needed to solve the equation within the explicit method maxk = 600; % Number of time steps dt = T/maxk; n = 20; % Number of space steps dx = L/n; cond = 1/132; % Conductivity b =2.*cond*dt/(dx*dx) % Stability parameter (b=<0.01) % Initial temperature of the wire: a sinus. for i = 1:n+1 x(i) =(i-1)*dx; u(i,1) =sin(pi*x(i)); end % Temperature at the boundary (T=0) for k=1:maxk+1 u(1,k) = 0.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=2:maxk % Time Loop for i=2:n; % Space Loop u(i,k+1) =u(i,k-1) + 0.5*2*b*(u(i-1,k)+u(i+1,k)-2.*u(i,k)); end end % Graphical representation of the temperature at different selected times figure(1) plot(x,u(:,1),'-',x,u(:,10),'-',x,u(:,30),'-',x,u(:,60),'-') title('Temperature within the explicit method') xlabel('X') ylabel('T') figure(2) mesh(x,time,u') title('Temperature within the explicit method') xlabel('X') ylabel('Temperature') ),( ),(),( 2 2 txS x txu D t txu       )sin()0,( 0),(,0),(,0),0( xxu conditionsinitial txstLutu conditionsBoundry   0126.0 2 2    x tD 20
  • 21. Stability of FTCS and CTCS FTCS is first-order accuracy in time and second-order accuracy in space. So small time steps are required to achieve reasonable accuracy. Courant condition for FTCS 2 1 2    x tD )2( 2 2 112 11 n j n j n j n j n j n j uuu x tD tSuu       CTCS method for heat equation (Both the time and space derivatives are center-differenced.) However, CTCS method is unstable for any time step size. 2 2 1 2 D t x    2 2 0.0126D t x    CTCS (unstable) FTCS (Stable) 21
  • 22. Lax method (FTCS) Simple modification to the FTCS method In the differenced time derivative, )2()( 112112 11 n j n j n j n j n j n j n j uuu x tD tSuuu       t uuu t uu n j n j n j n j n j        )]([)( 112 111 Replacement by average value from surrounding grid points The resulting difference equation is Courant condition for Lax method 4 1 2    x tD ( Second-order accuracy in both time and space ) 22
  • 23. Lax method(CTCS) Simple modification to the CTCS method In the differenced time derivative, )2( 2 2)( 112 1 1 1 12 11 n j n j n j n j n j n j n j uuu x tD tSuuu           t uuu t uu n j n j n j n j n j           2 )]([ 2 )( 1 1 1 12 1111 Replacement by average value from surrounding grid points The resulting difference equation is Courant condition for Lax method 4 1 2    x tD ( Second-order accuracy in both time and space ) 23
  • 24. Implementation (FTCS-Lax) Method % Initial temperature of the wire: a sinus. for i = 1:n+1 x(i) =(i-1)*dx; u(i,1) =sin(pi*x(i)); end % Temperature at the boundary (T=0) for k=1:maxk+1 u(1,k) = 0.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=2:maxk % Time Loop for i=2:n; % Space Loop u(i,k+1) =0.5*(u(i+1,k)+u(i-1,k)) + 0.5*b*(u(i-1,k)+u(i+1,k)-2.*u(i,k)); end end 2 2 0.1786D t x    2 2 1 2 D t x    Stability condition 2 2 0.0047D t x    24
  • 25. Implementation Lax method(CTCS) 2 2 0.3571D t x    2 2 1 2 D t x    Stability condition % Initial temperature of the wire: a sinus. for i = 1:n+1 x(i) =(i-1)*dx; u(i,1) =sin(pi*x(i)); end % Temperature at the boundary (T=0) for k=1:maxk+1 u(1,k) = 0.; u(n+1,k) = 0.; time(k) = (k-1)*dt; end % Implementation of the explicit method for k=2:maxk % Time Loop for i=2:n; % Space Loop u(i,k+1) =0.5*(u(i+1,k-1)+u(i-1,k- 1))+ 0.5*2*b*(u(i-1,k)+u(i+1,k)- 2.*u(i,k)); end end 25
  • 27. Crank Nicolson Algorithm ( Implicit Method ) BTCS ( Backward time, centered space ) method for heat equation )2( 11 1 2 n j n j n jx tn j n j n j TTTtSTT     ( This is stable for any choice of time steps, however it is first-order accurate in time. ) Crank-Nicolson scheme for heat equation taking the average between time steps n-1 and n,  ))22( )( 1 1 11 111 1 2 11 2         n j n j n j n j n j n jx t n j n j n j n j TTTTTT SStTT  ( This is stable for any choice of time steps and second-order accurate in time. ) a set of coupled linear equations for n jT 27
  • 30. Multiple Spatial Dimensions ),,(),,(),,( 2 2 2 2 tyxStyxT yx tyxT t                FTCS for 2D heat equation )2()2( 112112 1 n jk n jk n jk n kj n jk n kj n jk n jk n jk TTT y t TTT x t tSTT           Courant condition for this scheme 22 22 2 1 yx yx t    ( Other schemes such as CTCS and Lax can be easily extended to multiple dimensions. ) 30
  • 31. Wave equation with nonuniform wave speed ),,(),(),,( 2 2 2 2 2 2 2 tyxz yx yxctyxz t               2D wave equation 0 ),()0,,(),,()0,,( 00 00   vz yxvyxzyxzyxz  txxtxz txztyztyz 2sin)1(),0,( ,0),1,(),,1(),,0(   Initial condition : Boundary condition :  ])5.0(5)5.0(2exp[7.01),( 22 10 1  yxyxcWave speed : )2()2(2 112 22 112 22 11 n jk n jk n jk jkn kj n jk n kj jkn jk n jk n jk TTz y tc zzz x tc zzz          CTCS method for the wave equation : )( 2 1 2 22    yxfor tc Courant condition : 31
  • 32. Wave equation with nonuniform wave speed Since evaluation of the nth timestep refers back to the n-2nd step, for the first step, a trick is employed. jk t jkjkjk atvzz 20 01 2   )2()2( 112 2 0 1 00 12 2 n jk n jk n jk jk kjjkkj jk jk TTz y c zzz x c a       Since initial velocity and value, 0 0 1 0 0   jk jkjk z zv 32
  • 33. Wave equation with nonuniform wave speed 33
  • 34. Wave equation with nonuniform wave speed 34
  • 35. 2D Poisson’s equation ),(),()( 2 2 2 2 yxyxyx       Poisson’s equation Direct Solution for Poisson’s equation jk jkjkjkkjjkkj yx          2 11 2 11 22 Centered-difference the spatial derivatives 35
  • 36. Jacobi’s method ( Relaxation method ) Direct solution can be difficult to program efficiently. Relaxation methods are relatively simple to code, however, they are not as fast as the direct methods. Idea : I. Poisson’s equation can be thought of as the equilibrium solution to the heat equation with source. II. Starting with any initial condition, the heat equation solution will eventually relax to a solution of Poisson’s equation.                 )2( 1 )2( 1 2 1 11211222 22 1 n jk n jk n jk n kj n jk n kjjk n jk n jk yxyx yx                 )( 1 )( 1 2 1 11211222 22 n jk n jk n kj n kjjk yxyx yx  ),(),(),,( t ),(),( 22 yxyxtyxyxyx      ) 2 1 ( 22 22 yx yx t    FTCS (Maximum time step satisfying Courant condition) 36
  • 38. Simultaneous OverRelaxation (SOR) The convergence of the Jacobi method is quite slow. Furthermore, the larger the system, the slower the convergence. Simultaneous OverRelaxation (SOR) : the Jacobi method is modified in two ways,                    )( 1 )( 1 2 )1( 1 112 1 112 22 22 1 n jk n jk n kj n kjjk n jk n jk yx yx yx    1. Improved values are used as soon as they become available. 2. Relaxation parameter ω tries to overshoot for going to the final result. ( 1<ω<2) 38
  • 40. MATLAB The Language of Technical Computing MATLAB PDE Run: dftcs.m >> dftcs dftcs - Program to solve the diffusion equation using the Forward Time Centered Space scheme. Enter time step: 0.0001 Enter the number of grid points: 51 Solution is expected to be stable 2 2 ),(),( x txT t txT       40
  • 41. MATLAB The Language of Technical Computing MATLAB PDE Run: dftcs.m >> dftcs dftcs - Program to solve the diffusion equation using the Forward Time Centered Space scheme. Enter time step: 0.00015 Enter the number of grid points: 61 WARNING: Solution is expected to be unstable 41
  • 42. MATLAB The Language of Technical Computing MATLAB PDE Run: neutrn.m >> neutrn Program to solve the neutron diffusion equation using the FTCS. Enter time step: 0.0005 Enter the number of grid points: 61 Enter system length: 2 => System length is subcritical Solution is expected to be stable Enter number of time steps: 12000 ),( ),(),( 2 2 txn x txn t txn        42
  • 43. MATLAB The Language of Technical Computing MATLAB PDE Run: neutrn.m >> neutrn Program to solve the neutron diffusion equation using the FTCS. Enter time step: 0.0005 Enter the number of grid points: 61 Enter system length: 4 => System length is supercritical Solution is expected to be stable Enter number of time steps: 12000 43
  • 44. MATLAB The Language of Technical Computing MATLAB PDE Run: advect.m >> advect advect - Program to solve the advection equation using the various hyperbolic PDE schemes: FTCS, Lax, Lax-Wendorf Enter number of grid points: 50 Time for wave to move one grid spacing is 0.02 Enter time step: 0.002 Wave circles system in 500 steps Enter number of steps: 500 FTCS FTCS 0 ),(),(       x txu t txu  44
  • 45. MATLAB The Language of Technical Computing MATLAB PDE Run: advect.m >> advect advect - Program to solve the advection equation using the various hyperbolic PDE schemes: FTCS, Lax, Lax-Wendorf Enter number of grid points: 50 Time for wave to move one grid spacing is 0.02 Enter time step: 0.02 Wave circles system in 50 steps Enter number of steps: 50 Lax Lax 45
  • 46. MATLAB The Language of Technical Computing MATLAB PDE Run: relax.m >> relax relax - Program to solve the Laplace equation using Jacobi, Gauss-Seidel and SOR methods on a square grid Enter number of grid points on a side: 50 Theoretical optimum omega = 1.88184 Enter desired omega: 1.8 Potential at y=L equals 1 Potential is zero on all other boundaries Desired fractional change = 0.0001 0 ),(),( 2 2 2 2       y yx x yx  46