SlideShare a Scribd company logo
clc
clear all
close all
%%
% Book : CFD Vol.I by K A.Hoffmann
% Chapter : 3
% Number of example : 3.5 applications
% Author: Parham Sagharichi ha
%
parhamsagharchi@gmail.com
% inputs:
%
%
% outputs:
%
%%
%-------------------S------T------A------R------T-------------------------%
deltay = 0:1:40;
deltat = 0:0.001:2;
a = length(deltay);
b = length(deltat);
T = zeros(a,b);
T(a,:) = 50;
Tftcs = T;
Tfrankel = T;
Tcrank = T;
Timplicit = T;
% Forward time/central space (FTCS) method :
kappa = (0.000217*0.001)/(0.001^2);
for n1 = 2:b;
for m1 = 2:a-1;
Tftcs(m1,n1) = Tftcs(m1,n1-1) +
kappa*(Tftcs(m1+1,n1-1)-2*Tftcs(m1,n1-1) + Tftcs(m1-1,n1-
1));
end
end
% The DuFort-Frankel method :
Tfrankel(:,2)= Tftcs(:,2);
for n2 = 3:b;
for m2 = 2:a-1;
Tfrankel(m2,n2) = (((1-
2*kappa)/(1+2*kappa))*Tfrankel(m2,n2-
2))+(2*kappa/(1+2*kappa))*(Tfrankel(m2+1,n2-1)+Tfrankel(m2-
1,n2-1));
end
end
% The Crank-Nicolson method :
A1 = sparse(a,a);
A2 = sparse(a,a);
for i = 2:a-1;
A1(i,i-1) = -kappa/2;
A1(i,i) = 1+kappa;
A1(i,i+1) = -kappa/2;
A2(i,i-1) = kappa/2;
A2(i,i) = 1-kappa;
A2(i,i+1) = kappa/2;
end
A1(1,1) = 1;
A1(a,a) = 1;
A2(1,1) = 1;
A2(a,a) = 1;
figure(1)
spy(A1)
figure(2)
spy(A2)
for i = 1:b-1;
B1 = Tcrank(:,i);
Tcrank(:,i+1) = A1(A2*B1);
end
% Implicit method :
A3 = sparse(a,a);
for i = 2:a-1
A3(i,i-1) = -kappa;
A3(i,i) = (1+2*kappa);
A3(i,i+1) = -kappa;
end
A3(1,1) = 1;
A3(a,a) = 1;
figure(3)
spy(A3)
for i = 1:b-1;
B3 = Timplicit(:,i);
Timplicit(:,i+1) = A3B3;
end
% Timplicit(:,i+1) = A3B OR Timplicit(:,i+1) =
inv(A3)*B;
% an = a0 + (n-1)d --> a0 =0 --> n = an/d +1
n1 = 0.5/0.001 + 1;
n2 = 1/0.001 +1;
n3 = 1.5/0.001 +1;
deltay1 = deltay/1000;
% @ 2s
figure(4)
plot(Timplicit(:,end),deltay1,'-
ro',Tcrank(:,end),deltay1,'-
.b',Tftcs(:,end),deltay1,'+g',Tfrankel(:,end),deltay1,'*y')
ylabel(' delta y (m) ')
xlabel (' Velocity (m/s^2) ')
title(' @ t = 2s ')
legend('Implicit','Crank-Nicolson','FTCS','DuFort-
Frankel')
grid on
% @ 1.5s
figure(5)
plot(Timplicit(:,n3),deltay1,'-
ro',Tcrank(:,n3),deltay1,'-
.b',Tftcs(:,n3),deltay1,'+g',Tfrankel(:,n3),deltay1,'*y')
ylabel(' delta y (m) ')
xlabel (' Velocity (m/s^2) ')
title(' @ t = 1.5s ')
legend('Implicit','Crank-Nicolson','FTCS','DuFort-
Frankel')
grid on
% @ 1s
figure(6)
plot(Timplicit(:,n2),deltay1,'-
ro',Tcrank(:,n2),deltay1,'-
.b',Tftcs(:,n2),deltay1,'+g',Tfrankel(:,n2),deltay1,'*y')
ylabel(' delta y (m) ')
xlabel (' Velocity (m/s^2) ')
title(' @ t = 1s ')
legend('Implicit','Crank-Nicolson','FTCS','DuFort-
Frankel')
grid on
% @ 0.5s
figure(7)
plot(Timplicit(:,n1),deltay1,'-
ro',Tcrank(:,n1),deltay1,'-
.b',Tftcs(:,n1),deltay1,'+g',Tfrankel(:,n1),deltay1,'*y')
ylabel(' delta y (m) ')
xlabel (' Velocity (m/s^2) ')
title(' @ t = 0.5s ')
legend('Implicit','Crank-Nicolson','FTCS','DuFort-
Frankel')
grid on
%---------------F------I------N------I------S------H----------------------%
Implicit crank nicolson - du fort-frankel - ftcs
Implicit crank nicolson - du fort-frankel - ftcs

More Related Content

Viewers also liked

bconiireportfull-160616083404
bconiireportfull-160616083404bconiireportfull-160616083404
bconiireportfull-160616083404Andrew Law
 
Cartell intercanvi llibres
Cartell intercanvi llibresCartell intercanvi llibres
Cartell intercanvi llibresanesbamus
 
Male Pelvic Floor Dysfunction in Elite Sport
Male Pelvic Floor Dysfunction in Elite Sport Male Pelvic Floor Dysfunction in Elite Sport
Male Pelvic Floor Dysfunction in Elite Sport
Gerard Greene Physio
 
Key note speech media-130716_final
Key note speech media-130716_finalKey note speech media-130716_final
Key note speech media-130716_final
Maria Boura
 
Sunu1
Sunu1Sunu1
Water Conservation
Water ConservationWater Conservation
Water Conservation
Parhamsagharchi
 
Grade 6 Mathematics: Number Forms
Grade 6 Mathematics: Number FormsGrade 6 Mathematics: Number Forms
Grade 6 Mathematics: Number Forms
Bridgette Mackey
 
Minimal Change Disease
Minimal Change DiseaseMinimal Change Disease
Minimal Change Disease
jayatheeswaranvijayakumar
 
Evolutions of Bicycle
Evolutions of BicycleEvolutions of Bicycle
Evolutions of Bicycle
Akshay Kaleeah
 
Mjedisi armela-braka
Mjedisi armela-brakaMjedisi armela-braka
Mjedisi armela-braka
Megi Braka
 
Güneş si̇stemi̇ ve ötesi̇
Güneş si̇stemi̇ ve ötesi̇Güneş si̇stemi̇ ve ötesi̇
Güneş si̇stemi̇ ve ötesi̇
tuğba hasar
 
Ovum Decision Matrix
Ovum Decision MatrixOvum Decision Matrix
Ovum Decision Matrix
Francisco González Jiménez
 

Viewers also liked (13)

bconiireportfull-160616083404
bconiireportfull-160616083404bconiireportfull-160616083404
bconiireportfull-160616083404
 
Cartell intercanvi llibres
Cartell intercanvi llibresCartell intercanvi llibres
Cartell intercanvi llibres
 
Male Pelvic Floor Dysfunction in Elite Sport
Male Pelvic Floor Dysfunction in Elite Sport Male Pelvic Floor Dysfunction in Elite Sport
Male Pelvic Floor Dysfunction in Elite Sport
 
Key note speech media-130716_final
Key note speech media-130716_finalKey note speech media-130716_final
Key note speech media-130716_final
 
Sunu1
Sunu1Sunu1
Sunu1
 
Water Conservation
Water ConservationWater Conservation
Water Conservation
 
Grade 6 Mathematics: Number Forms
Grade 6 Mathematics: Number FormsGrade 6 Mathematics: Number Forms
Grade 6 Mathematics: Number Forms
 
CFD Project
CFD ProjectCFD Project
CFD Project
 
Minimal Change Disease
Minimal Change DiseaseMinimal Change Disease
Minimal Change Disease
 
Evolutions of Bicycle
Evolutions of BicycleEvolutions of Bicycle
Evolutions of Bicycle
 
Mjedisi armela-braka
Mjedisi armela-brakaMjedisi armela-braka
Mjedisi armela-braka
 
Güneş si̇stemi̇ ve ötesi̇
Güneş si̇stemi̇ ve ötesi̇Güneş si̇stemi̇ ve ötesi̇
Güneş si̇stemi̇ ve ötesi̇
 
Ovum Decision Matrix
Ovum Decision MatrixOvum Decision Matrix
Ovum Decision Matrix
 

Similar to Implicit crank nicolson - du fort-frankel - ftcs

matlab code for channel estimation for ofdm
matlab code for channel estimation for ofdmmatlab code for channel estimation for ofdm
matlab code for channel estimation for ofdmGyana Ranjan Mati
 
Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
Digitla Communication pulse shaping filter
Digitla Communication pulse shaping filterDigitla Communication pulse shaping filter
Digitla Communication pulse shaping filtermirfanjum
 
Program 6.pptx
Program 6.pptxProgram 6.pptx
Program 6.pptx
PraveenBulusu2
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpsk
blzz2net
 
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
Parhamsagharchi
 
FishersEquationCode
FishersEquationCodeFishersEquationCode
FishersEquationCodeTalal Tahir
 
Introduction to Fuzzy Logic in Networks
Introduction to Fuzzy Logic in NetworksIntroduction to Fuzzy Logic in Networks
Introduction to Fuzzy Logic in Networks
Dr. Edwin Hernandez
 
MATLAB Final Project
MATLAB Final ProjectMATLAB Final Project
MATLAB Final ProjectAlexis Ploss
 
ACS 22LIE12 lab Manul.docx
ACS 22LIE12 lab Manul.docxACS 22LIE12 lab Manul.docx
ACS 22LIE12 lab Manul.docx
VasantkumarUpadhye
 
Interactive Transmission System Computation Unit
Interactive Transmission System Computation UnitInteractive Transmission System Computation Unit
Interactive Transmission System Computation Unit
mayankraj0805
 
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
meerobertsonheyde608
 
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfI need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
eyewatchsystems
 
OFDMA MATLAB CODE.pdf
OFDMA MATLAB CODE.pdfOFDMA MATLAB CODE.pdf
OFDMA MATLAB CODE.pdf
SameeUllaKhan1
 
System Software/Operating Sytems lab report
System Software/Operating Sytems lab reportSystem Software/Operating Sytems lab report
System Software/Operating Sytems lab report
Vishnu K N
 
System Software /Operating System Lab Report
System Software /Operating System Lab ReportSystem Software /Operating System Lab Report
System Software /Operating System Lab Report
Vishnu K N
 

Similar to Implicit crank nicolson - du fort-frankel - ftcs (20)

matlab code for channel estimation for ofdm
matlab code for channel estimation for ofdmmatlab code for channel estimation for ofdm
matlab code for channel estimation for ofdm
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
Digitla Communication pulse shaping filter
Digitla Communication pulse shaping filterDigitla Communication pulse shaping filter
Digitla Communication pulse shaping filter
 
Program 6.pptx
Program 6.pptxProgram 6.pptx
Program 6.pptx
 
Md Nasfik
Md NasfikMd Nasfik
Md Nasfik
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpsk
 
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
 
FishersEquationCode
FishersEquationCodeFishersEquationCode
FishersEquationCode
 
Matlab code
Matlab codeMatlab code
Matlab code
 
Introduction to Fuzzy Logic in Networks
Introduction to Fuzzy Logic in NetworksIntroduction to Fuzzy Logic in Networks
Introduction to Fuzzy Logic in Networks
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 
MATLAB Final Project
MATLAB Final ProjectMATLAB Final Project
MATLAB Final Project
 
ACS 22LIE12 lab Manul.docx
ACS 22LIE12 lab Manul.docxACS 22LIE12 lab Manul.docx
ACS 22LIE12 lab Manul.docx
 
บทที่ 3
บทที่ 3บทที่ 3
บทที่ 3
 
Interactive Transmission System Computation Unit
Interactive Transmission System Computation UnitInteractive Transmission System Computation Unit
Interactive Transmission System Computation Unit
 
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
 
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfI need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
 
OFDMA MATLAB CODE.pdf
OFDMA MATLAB CODE.pdfOFDMA MATLAB CODE.pdf
OFDMA MATLAB CODE.pdf
 
System Software/Operating Sytems lab report
System Software/Operating Sytems lab reportSystem Software/Operating Sytems lab report
System Software/Operating Sytems lab report
 
System Software /Operating System Lab Report
System Software /Operating System Lab ReportSystem Software /Operating System Lab Report
System Software /Operating System Lab Report
 

Recently uploaded

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 

Implicit crank nicolson - du fort-frankel - ftcs

  • 1.
  • 2.
  • 3. clc clear all close all %% % Book : CFD Vol.I by K A.Hoffmann % Chapter : 3 % Number of example : 3.5 applications % Author: Parham Sagharichi ha % parhamsagharchi@gmail.com % inputs: % % % outputs: % %% %-------------------S------T------A------R------T-------------------------% deltay = 0:1:40; deltat = 0:0.001:2; a = length(deltay); b = length(deltat); T = zeros(a,b); T(a,:) = 50; Tftcs = T; Tfrankel = T; Tcrank = T; Timplicit = T; % Forward time/central space (FTCS) method : kappa = (0.000217*0.001)/(0.001^2); for n1 = 2:b; for m1 = 2:a-1; Tftcs(m1,n1) = Tftcs(m1,n1-1) + kappa*(Tftcs(m1+1,n1-1)-2*Tftcs(m1,n1-1) + Tftcs(m1-1,n1- 1)); end end % The DuFort-Frankel method : Tfrankel(:,2)= Tftcs(:,2); for n2 = 3:b;
  • 4. for m2 = 2:a-1; Tfrankel(m2,n2) = (((1- 2*kappa)/(1+2*kappa))*Tfrankel(m2,n2- 2))+(2*kappa/(1+2*kappa))*(Tfrankel(m2+1,n2-1)+Tfrankel(m2- 1,n2-1)); end end % The Crank-Nicolson method : A1 = sparse(a,a); A2 = sparse(a,a); for i = 2:a-1; A1(i,i-1) = -kappa/2; A1(i,i) = 1+kappa; A1(i,i+1) = -kappa/2; A2(i,i-1) = kappa/2; A2(i,i) = 1-kappa; A2(i,i+1) = kappa/2; end A1(1,1) = 1; A1(a,a) = 1; A2(1,1) = 1; A2(a,a) = 1; figure(1) spy(A1) figure(2) spy(A2) for i = 1:b-1; B1 = Tcrank(:,i); Tcrank(:,i+1) = A1(A2*B1); end % Implicit method : A3 = sparse(a,a); for i = 2:a-1 A3(i,i-1) = -kappa; A3(i,i) = (1+2*kappa); A3(i,i+1) = -kappa; end
  • 5. A3(1,1) = 1; A3(a,a) = 1; figure(3) spy(A3) for i = 1:b-1; B3 = Timplicit(:,i); Timplicit(:,i+1) = A3B3; end % Timplicit(:,i+1) = A3B OR Timplicit(:,i+1) = inv(A3)*B; % an = a0 + (n-1)d --> a0 =0 --> n = an/d +1 n1 = 0.5/0.001 + 1; n2 = 1/0.001 +1; n3 = 1.5/0.001 +1; deltay1 = deltay/1000; % @ 2s figure(4) plot(Timplicit(:,end),deltay1,'- ro',Tcrank(:,end),deltay1,'- .b',Tftcs(:,end),deltay1,'+g',Tfrankel(:,end),deltay1,'*y') ylabel(' delta y (m) ') xlabel (' Velocity (m/s^2) ') title(' @ t = 2s ') legend('Implicit','Crank-Nicolson','FTCS','DuFort- Frankel') grid on % @ 1.5s figure(5) plot(Timplicit(:,n3),deltay1,'- ro',Tcrank(:,n3),deltay1,'- .b',Tftcs(:,n3),deltay1,'+g',Tfrankel(:,n3),deltay1,'*y') ylabel(' delta y (m) ') xlabel (' Velocity (m/s^2) ') title(' @ t = 1.5s ') legend('Implicit','Crank-Nicolson','FTCS','DuFort- Frankel') grid on
  • 6. % @ 1s figure(6) plot(Timplicit(:,n2),deltay1,'- ro',Tcrank(:,n2),deltay1,'- .b',Tftcs(:,n2),deltay1,'+g',Tfrankel(:,n2),deltay1,'*y') ylabel(' delta y (m) ') xlabel (' Velocity (m/s^2) ') title(' @ t = 1s ') legend('Implicit','Crank-Nicolson','FTCS','DuFort- Frankel') grid on % @ 0.5s figure(7) plot(Timplicit(:,n1),deltay1,'- ro',Tcrank(:,n1),deltay1,'- .b',Tftcs(:,n1),deltay1,'+g',Tfrankel(:,n1),deltay1,'*y') ylabel(' delta y (m) ') xlabel (' Velocity (m/s^2) ') title(' @ t = 0.5s ') legend('Implicit','Crank-Nicolson','FTCS','DuFort- Frankel') grid on %---------------F------I------N------I------S------H----------------------%