SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
1
2	
PROGRAM LIST
PROG.
NO.
PROGRAM DESCRIPTION COMPILER PAGE
NO.
1 Error difference between analytical
solution and finite difference method
FORTRAN
95
3
2 Solving 1D steady state differential heat
equation
FORTRAN
95
3 Solving 2D steady state heat equation FORTRAN
95
4 Solving 1D transient heat equation MATLAB
5 Solving 2D transient heat equation MATLAB
6 Investigation of the sprinkler response
time with activation temperature
MATLAB
7 Solving steady state advection-diffusion
equation
FORTRAN
95
8 Solving 1D time dependent advection
diffusion using FOU scheme
FORTRAN
95
3	
FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS
Rahul Roy
Department of Mechanical Engineering, Jadavpur
University, Kolkata 700032, India
INTRODUCTION	
	
This	report	provides	a	practical	overview	of	numerical	solutions	to	the	heat	equation	using	the	
finite	difference	method	(FDM).	The	forward	time,	centered	space	(FTCS),	the	backward	time,	
centered	 space	 (BTCS),	 and	 Crank-Nicolson	 schemes	 are	 developed,	 and	 applied	 to	 a	 simple	
problem	 in1volving	 the	 one-dimensional	 heat	 equation.	 Complete,	 working	 Matlab	 and	
FORTRAN	 codes	 for	 each	 program	 are	 presented.	 The	 results	 of	 running	 the	 codes	 on	 finer	
(one-dimensional)	 meshes,	 and	 with	 smaller	 time	 steps	 are	 demonstrated.	 These	 sample	
calculations	 show	 that	 the	 schemes	 realize	 theoretical	 predictions	 of	 how	 their	 truncation	
errors	depend	on	mesh	spacing	and	time	step.	The	Matlab	codes	are	straightforward	and	allow	
us	 to	 see	 the	 differences	 in	 implementation	 between	 explicit	 method	 (FTCS)	 and	 implicit	
methods	 (BTCS).	 The	 codes	 also	 allow	 us	 to	 experiment	 with	 the	 stability	 limit	 of	 the	 FTCS	
scheme.		
FINITE	DIFFERENCE	METHOD	
	
The	finite	difference	method	is	one	of	several	techniques	for	obtaining	numerical	solutions.	In	
all	 numerical	 solutions	 the	 continuous	 partial	 differential	 equation	 (PDE)	 is	 replaced	 with	 a	
discrete	approximation.	In	this	context	the	word	“discrete”	means	that	the	numerical	solution	is	
known	 only	 at	 a	 finite	 number	 of	 points	 in	 the	 physical	 domain.	 The	 user	 of	 the	 numerical	
method	can	select	the	number	of	those	points.	In	general,	increasing	the	number	of	points	not	
only	 increases	 the	 resolution,	 but	 also	 the	 accuracy	 of	 the	 numerical	 solution.	 The	 discrete	
approximation	 results	 in	 a	 set	 of	 algebraic	 equations	 that	 are	 evaluated	 (or	 solved)	 for	 the	
values	of	the	discrete	unknowns.		
	
The	mesh	is	the	set	of	locations	where	the	discrete	solution	is	computed.	These	points	are	called	
nodes,	and	if	one	were	to	draw	lines	between	adjacent	nodes	in	the	domain	the	resulting	image	
would	 resemble	 a	 net	 or	 mesh.	 Two	 key	 parameters	 of	 the	 mesh	 are	 ∆x,	 the	 local	 distance	
between	adjacent	points	in	space,	and	∆t,	the	local	distance	between	adjacent	time	steps.		
	
The	core	idea	of	the	finite-difference	method	is	to	replace	continuous	derivatives	with	so	called	
difference	formulas	that	involve	only	the	discrete	values	associated	with	positions	on	the	mesh.		
Applying	 the	 finite-difference	 method	 to	 a	 differential	 equation	 involves	 re-	 placing	 all	
derivatives	with	difference	formulas.	In	the	heat	equation	there	are	derivatives	with	respect	to	
time,	and	derivatives	with	respect	to	space.	Using	different	combinations	of	mesh	points	in	the	
difference	formulas	results	in	different	schemes.	In	the	limit	as	the	mesh	spacing	(∆x	and	∆t)	go	
to	zero,	the	numerical	solution	obtained	with	any	useful	scheme	will	approach	the	true	solution	
to	 the	 original	 differential	 equation.	 However,	 the	 rate	 at	 which	 the	 numerical	 solution	
approaches	 the	 true	 solution	 varies	 with	 the	 scheme.	 In	 addition,	 there	 are	 some	 practically	
useful	schemes	that	can	fail	to	yield	a	solution	for	bad	combinations	of	∆x	and	∆t.
4	
PROGRAM	1	
	
A	simple,	basic	Fortran95	code	is	written	to	find	the	tangent	of	the	function	𝑓 𝑥 = cos (𝑥)	by	
using	finite	difference	approach.	This	approach	uses	the	concept	of	discretization	of	space	and	
time	into	distinct	points	or	units.	Every	equation	is	satisfied	for	each	distinct	point	or	steps	and	
a	 numerical	 iteration	 is	 carried	 out	 to	 reach	 a	 optimum	 solution.	 The	 numerical	 solution	
approaches	 the	 true	 solution	 as	 the	 number	 of	 grids	 is	 increased.	 The	 finite	 difference	
approximation	becomes	more	accurate	as	grid	spacing	decreases.		
	
FORTRAN	CODE	FOR	PROGRAM	1	
	
1 program	Heat					
2 implicit	none	
3 integer	::	n																					
4 integer	::	i	
5 real,allocatable	::	y(:),dydx(:)	
6 real	::	x,dx	
7 write(*,*)	'Enter	No.	of	grid	Points'	
8 read(*,*)	n	
9 allocate	(y(n)	,	dydx(n))	
10 dx=10.0/(n-1)	
11 do	i=1,n	
12 x=(i-1)*dx	
13 y(i)=cos(x)	
14 end	do	
15 call	derivative	(y,n,dx,dydx)	
16 do	i=1,n	
17 x=(i-1)*dx	
18 print	*,	dydx(i),	-sin(x)	,	-sin(x)-dydx(i)	
19 end	do	
20 deallocate	(y,dydx)	
21 contains	
22 subroutine	derivative	(a,np,h,aprime)	
23 integer	::	np	
24 real	::	a(np),h	
25 real	::	aprime(np)	
26 do	i=1,np-1	
27 aprime(i)=(a(i+1)-a(i))/h	
28 end	do	
29 aprime(np)	=	0	
30 end	subroutine	derivative	
31 end	program	Heat	
The above program illustrates the difference between the values obtained from actual derivatives and
the finite difference approximations. The difference between the two values gives the error due to the
scheme. A graph has been plotted to obtain the results of the finite difference method in Figure 1. The
results show that there is only slight error between the two values.
5	
Figure	1.	Differentiation	of	the	function	f(x)	using	(i)	Finite	Difference	Method		
(ii)	Calculus	Method	
PROGRAM	2	
	
A	 FORTRAN95	 program	 which	 applies	 the	 finite	 difference	 method	 to	 estimate	 the	
solution	 of	 the	 steady	 state	 (time	 independent)	 heat	 equation	 over	 a	 one-dimensional	
region,	which	can	be	thought	of	as	a	thin	metal	rod.	We	will	assume	the	rod	extends	over	
the	range	A	<=	X	<=	B.	The	quantity	of	interest	is	the	temperature	U(X)	at	each	point	in	the	
rod.	We	will	assume	that	the	temperature	of	the	rod	is	fixed	at	known	values	at	the	two	
endpoints.	 The	 material	 of	 the	 rod	 is	 considered	 as	 homogenous	 and	 isotropic.	
Symbolically,	we	write	the	boundary	conditions:	U(A)=Ua	and	U(B)=Ub.	Inside	the	rod,	we	
assume	 that	 a	 version	 of	 the	 steady	 (time	 independent)	 heat	 equation	 applies.	 This	
assumes	 that	 the	 situation	 in	 the	 rod	 has	 "settled	 down",	 so	 that	 the	 temperature	
configuration	has	no	further	tendency	to	change.	The	equation	we	will	consider	is:	
	
−
𝑑
𝑑𝑥
𝑘(𝑥)
𝑑𝑈 𝑥
𝑑𝑥
= 𝐹(𝑥)	
	
Here,	 the	 right	 hand	 side	 term	 F(X)	 allows	 us	 to	 consider	 internal	 heat	 sources	 in	 the	
metal	-	perhaps	a	portion	of	the	rod	is	sitting	above	a	blow	torch.	The	coefficient	K(X)	is	a	
measure	of	heat	conductivity.	It	measures	the	rate	at	which	the	heat	from	a	local	hot	spot	
will	spread	out.	If	the	heat	source	function	F(X)	is	zero	everywhere,	and	if	K(X)	is	constant,	
then	the	solution	U(X)	will	be	the	straight	line	function	that	matches	the	two	endpoint	
values.	 Making	 F(X)	 positive	 over	 a	 small	 interval	 will	 "heat	 up"	 that	 portion.	 We	 can	
simulate	a	rod	that	is	divided	into	regions	of	different	materials	by	setting	the	function	
K(X)	to	have	a	given	value	K1	over	some	subinterval	of	[A,B]	and	value	K2	over	the	rest	of	
the	region.	To	estimate	the	value	of	the	solution,	we	will	pick	a	uniform	mesh	of	N	points
6	
X(1)	 through	 X(N),	 from	 A	 to	 B.	 At	 the	 i-th	 point,	 we	 will	 compute	 an	 estimated	
temperature	 U(i).	 To	 do	 this,	 we	 will	 need	 to	 use	 the	 boundary	 conditions	 and	 the	
differential	equation.	Since	X(1)	=	A	and	X(N)	=	B,	we	can	use	the	boundary	conditions	to	
set	U(1)	=	Ua	and	U(N)	=	Ub.	For	the	points	in	the	interior,	we	need	to	approximate	the	
differential	equation	in	a	way	that	allows	us	to	determine	the	solution	values.	We	will	do	
this	using	a	finite	difference	approximation.	Suppose	we	are	working	at	node	X(I),	which	is	
associated	with	U(I).	Then	a	centered	difference	approximation	to	the	double	derivative	
is:	
	
−
𝑑
𝑑𝑥
𝑘 𝑥
𝑑𝑈 𝑥
𝑑𝑥
= −
(𝑘(𝑋 𝑖 +
Δ𝑥
2
)(𝑈 𝑋 𝑖 + 1 − 𝑈 𝑋 𝑖 )
Δ𝑥
−
(𝑘(𝑋 𝑖 −
Δ𝑥
2
)(𝑈 𝑋 𝑖 − 𝑈 𝑋 𝑖 − 1 )
Δ𝑥!
	
	
If	we	rearrange	the	terms	in	this	approximation,	and	set	it	equal	to	F(X(i)),	we	get	the	
finite	difference	approximation	to	the	differential	equation	at	X(i):	
	
−𝑘 𝑋 𝑖 −
Δ𝑥
2
∗ 𝑈 𝑋 𝑖 − 1 + 𝑘 𝑋 𝑖 −
Δ𝑥
2
+ 𝑘 𝑋 𝑖 +
Δ𝑥
2
∗ 𝑈 𝑋 𝑖 − 𝑘 𝑋 𝑖 +
Δ𝑥
2
∗ 𝑈 𝑋 𝑖 + 1
= Δ𝑥 ∗ Δ𝑥 ∗ 𝐹(𝑋 𝑖 )	
	
This	means	that	we	have	N-2	equations,	each	of	which	involves	an	unknown	U(i)	and	its	
left	 and	 right	 neighbors,	 plus	 the	 two	 boundary	 conditions,	 which	 give	 us	 a	 total	 of	 N	
equations	in	N	unknowns.	We	can	set	up	and	solve	these	linear	equations	using	a	matrix	A	
for	the	coefficients,	and	a	vector	RHS	for	the	right	hand	side	terms,	and	calling	a	function	
to	solve	the	system	A*U=RHS	will	give	us	the	solution.	Because	finite	differences	are	only	
an	 approximation	 to	 derivatives,	 this	 process	 only	 produces	 estimates	 of	 the	 solution.	
Usually,	we	can	reduce	this	error	by	decreasing	Δ𝑥.	
	
FORTRAN	CODE	FOR	PROGRAM	2	
	
1 program	HEAT	
2 implicit	none	
3 integer	::	n	
4 real	::	a,	b,	dx,	f,	k	
5 integer	::	i	
6 real	::	rhs(n),	tri(3,n)	
7 real	::	u(n),	x(n)	
8 real	::	ua,	ub,	xm,	xp	
9 a=0	
10 b=1	
11 ua=0	
12 ub=1	
13 n=11	
14 dx=(b-a)/(n-1)	
15 do	i=1,n	
16 x(i)=((n-1)*a+(i-1)*b)/(n-1)	
17 end	do	
18 tri(1,1)=0	
19 tri(2,1)=1
7	
20 tri(3,1)=0	
21 rhs(1)=ua	
22 do	i=2,n-1	
23 xm=(x(i-1)+x(i))/2	
24 xp=(x(i)+x(i+1)/2	
25 tri(1,i)=(-xm)/(dx*dx)	
26 tri(2,i)=(xm+xp)/(dx*dx)	
27 tri(3,i)=(-xp)/(dx*dx)	
28 rhs(i)=0	
29 end	do	
30 tri(1,n)=0	
31 tri(2,n)=0	
32 tri(3,n)=0	
33 u(1:n)=rhs(1:n)	
34 do	i=2,n	
35 tri(2,i)=tri(2,i)-tri(3,i-1)*tri(1,i)/tri(2,i-1)	
36 u(i)=u(i)-u(i-1)*tri(1,i)/tri(2,i-1)	
37 end	do	
38 u(n)=u(n)/tri(2,n)	
39 do	i=n-1,1,-1	
40 u(i)=(u(i)-tri(3,i)*u(i+1))/tri(2,i)	
41 end	do	
42 u(n)=u(n)/tri(2,n)	
43 do	i=n-1,1,-1	
44 u(i)=(u(i)-tri(3,i)*u(i+1))/tri(2,i)	
45 end	do	
46 end	program	HEAT	
	
The	nomenclature	for	the	above	program	is	given	by:	
Ø n	is	the	number	of	spatial	points.	
Ø a,	b	are	the	left	and	right	endpoints.	
Ø ua,	ub	are	the	temperature	values	at	the	left	and	right	endpoints.	
Ø k	is	the	name	of	the	function	which	evaluates	K(X);	
Ø f	is	the	name	of	the	function,	which	evaluates	the	right	hand	side	F(X).	
Ø x	is	the	X	coordinates	of	nodes	(output);	
Ø u	is	the	computed	value	of	the	temperature	at	the	nodes.	
	
4	different	boundary	conditions	are	taken	for	the	above	program	to	simulate	different	
results:	
1. Test	1:	uses	K(X)	=	1,	F(X)	=	0,	so	the	solution	should	be	the	straight	line	that	
connects	the	boundary	values.	
2. Test	2:	uses	K(X)	which	is	set	to	different	constants	over	three	sub	regions,	and	
F(X)	=	0,	so	the	solution	will	be	a	piecewise	linear	function	that	connects	the	
boundary	values.	
3. Test	3:	uses	K(X)	=	1,	F(X)	defines	a	heat	source,	so	the	solution	can	rise	above	the	
boundary	values.	
4. Test	4:	uses	K(X)	=	1,	F(X)	defines	a	heat	source	and	a	heat	sink,	so	the	solution	can	
go	above	and	below	the	boundary	values.
8	
	
				 	
	
					 	
	
	
Figure	2:	Temperature	distribution	for	different	boundary	conditions	for	a	steady	
state	1D-heat	equation
9	
PROGRAM	3	
	
A	simple,	Fortran95	program	for	a	2D,	steady	state	(time-independent)	heat	equation	in	a	2D	
rectangular	region.	This	diagram	suggests	the	physical	regions,	and	the	boundary	conditions:	
	
The	region	is	covered	with	a	grid	of	NX	by	NY	nodes,	and	an	NX	by	NY	array	T	is	used	to	record	
the	temperature.	The	correspondence	between	array	indices	and	locations	in	the	region	is	
suggested	by	giving	the	indices	of	the	four	corners.	
	
The	form	of	the	steady	heat	equation	is:	
	
−
𝑑
𝑑𝑥
𝐾 𝑥, 𝑦
𝑑𝑇
𝑑𝑥
−
𝑑
𝑑𝑦
𝐾 𝑥, 𝑦
𝑑𝑇
𝑑𝑦
= 𝐹(𝑥, 𝑦)	
		
The	following	assumptions	are	considered	for	the	following	problem:	
1. 𝐹 𝑥, 𝑦 = 0	(No	heat	generation)	
2. Thermal	conductivity	of	the	material	does	not	vary	along	x	or	y	axis	
3. 𝐾 𝑥, 𝑦 = 𝐾	(Isotropic)	
	
𝜕!
𝑇
𝜕𝑥!
+
𝜕!
𝑇
𝜕𝑦!
= 0	
	
The	above	equation	is	called	Laplace	equation.	To	obtain	the	temperature	distribution,	we	need	
to	solve	the	above	PDE.	By	using	a	simple	finite	difference	approximation,	this	single	equation	
can	be	replaced	by	NX	*	NY	linear	equations	in	NX	*	NY	variables;	each	equation	is	associated	
with	one	of	the	nodes	in	the	mesh.	Nodes	long	the	boundary	generates	boundary	condition	
equations,	while	interior	nodes	generate	equations	that	approximate	the	steady	heat	equation.	
For	simplicity,	we	consider	dx=dy.	The	linear	system	is	sparse,	and	can	easily	be	solved	directly	
in	FORTRAN95.	
	
𝑇!!!.! + 𝑇!!!.! + 𝑇!.!!! + 𝑇!.!!! − 4 ∗ 𝑇!.! = 0	
	
Here	i	represent	the	node	location	along	the	x	direction	and	j	represents	the	node	location	along	
y	direction.
10	
FORTRAN	CODE	FOR	PROGRAM	3	
	
1 program	HEAT	
2 implicit	none	
3 integer	::	i,	j,	k	
4 integer	::	m,	n	
5 integer	::	L,	H	
6 integer	::	T1,	T2,	T3,	T4	
7 real	::	A(5,5),	B(5,5),	C(5,5)	
8 T1=300	
9 T2=100	
10 T3=50	
11 T4=75	
12 m=5	
13 n=5	
14 do	10	j=1,n	
15 do	20	i=1,m	
16 C(i,j)=0	
17 B(i,j)=0	
18 IF	(j==1)	THEN	A(i,j)=50	
19 else	if(j==n)	THEN	A(i,j)=300	
20 else	if(i==1)	THEN	A(i,j)=75	
21 else	if(i==m)	THEN	A(i,j)=100	
22 else	A(i,j)=0	
23 END	IF	
24 20	END	DO	
25 10	END	DO	
26 DO	70	k=1,10	
27 DO	50	j=2,n-1	
28 DO	60	i=2,m-1	
29 A(i,j)=(A(i+1,j)+A(i-1,j)+A(i,j+1)+A(i,j-1))*(0.25)	
30 C(i,j)=B(i,j)/A(i,j)	
31 C(i,j)=1-C(i,j)	
32 60	END	DO	
33 50	END	DO	
34 do	30	j=1,n	
35 do	40	i=1,m	
36 write(*,*)	i,j,	A(i,j),C(i,j)	
37 B(i,j)=A(i,J)	
38 40	END	DO	
39 30	END	DO	
40 70	END	DO	
41 end	program	HEAT
11	
	
	
Figure	3:	Output	screen	for	Program	3a	
	
We	consider	the	temperature	distribution	for	a	different	boundary	condition.	The	number	
of	grids	taken	is	10*10.		
	
	
	
	
Figure	4:	Output	screen	for	Program	3b
12	
The	temperature	verses	x	and	y	directions	of	the	rectangular	plate	is	also	plotted	in	the	
graph	as	shown	in	the	below	figure.	
	
	
													 	
	
	
Figure	5:	Temperature	distribution	on	the	rectangular	plate	
	
The	constant	temperature	lines	are	plotted	in	a	graph	as	shown	in	Figure	5.		
	
	
	
	
Figure	6:	Isotherm	on	temperature	distribution	diagram
13	
PROGRAM	4	
	
Consider	the	one-dimensional,	transient	(i.e.	time-dependent)	heat	conduction	equation	
without	heat	generating	sources.		
	
𝜌𝑐!
𝜕𝑇
𝜕𝑡
=
𝜕
𝜕𝑥
𝑘
𝜕𝑇
𝜕𝑥
	
If the thermal conductivity, density and heat capacity are constant over the model domain, the
equation can be simplified to:
	
𝜕𝑇
𝜕𝑡
=
𝑘
𝜌𝑐!
𝜕!
𝑇
𝜕𝑥!
= 𝛼
𝜕!
𝑇
𝜕𝑥!
	
	
We	 are	 interested	 in	 the	 temperature	 evolution	 versus	 time,	 T(x,t),	 which	 satisfies	 the	
above	 equation,	 given	 an	 initial	 temperature	 distribution.	 The	 first	 step	 in	 the	 finite	
differences	method	is	to	construct	a	grid	with	points	on	which	we	are	interested	in	solving	
the	equation,	called	discretization.	The	next	step	is	to	replace	the	continuous	derivatives	
of	the	above	with	their	finite	difference	approximations.	First,	the	explicit	forward	time,	
centered	space	or	FTCS	approximation	method	is	used	in	solving	the	heat	equation.		
	
𝑇!
!!!
− 𝑇!
!
∆𝑡
= 𝛼
𝑇!!!
!
− 2𝑇!
!
+ 𝑇!!!
!
∆𝑥 !
	
𝑇!
!!!
= 𝑇!
!
+ 𝛼∆𝑡
𝑇!!!
!
− 2𝑇!
!
+ 𝑇!!!
!
∆𝑥 !
	
	
Here,	n	represents	the	temperature	at	the	current	time	step	whereas	n	+	1	represents	the	
new	(future)	temperature.	The	subscript	i	refers	to	the	location.	Both	n	and	i	are	integers;	
n	varies	from	1	to	nt	(total	number	of	time	steps)	and	i	varies	from	1	to	nx	(total	number	
of	 grid	 points	 in	 x-direction).	 Because	 the	 temperature	 at	 the	 current	 time	 step	 (n)	 is	
known,	 we	 can	 use	 the	 equation	 to	 compute	 the	 new	 temperature	 without	 solving	 any	
additional	equations.	Such	a	scheme	is	and	explicit	finite	difference	method	and	was	made	
possible	by	the	choice	to	evaluate	the	temporal	derivative	with	forward	differences.	We	
know	that	this	numerical	scheme	will	converge	to	the	exact	solution	for	small	∆x	and	∆t	
because	 it	 has	 been	 shown	 to	 be	 consistent	 –	 that	 its	 discretization	 process	 can	 be	
reversed,	through	a	Taylor	series	expansion,	to	recover	the	governing	partial	differential	
equation	 –	 and	 because	 it	 is	 stable	 for	 certain	 values	 of	 ∆t	 and	 ∆x:	 any	 spontaneous	
perturbations	 in	 the	 solution	 (such	 as	 round-off	 error)	 will	 either	 be	 bounded	 or	 will	
decay.	The	last	step	is	to	specify	the	initial	and	the	boundary	conditions.		
	
1. Total	time=60sec	
2. The	initial	temperature	is	taken	as	0.	
3. The	temperature	at	the	left	and	right	hand	side	of	the	wall	is	taken	as	40°C	and	
20°C	respectively.	
4. The	number	of	grids	is	taken	as	10.	
5. Length	of	the	domain=0.1	
6. Alpha	is	taken	as	0.0001
14	
	
	
FLOWCHART	FOR	PROGRAM	4	
	
MATLAB	CODE	FOR	FTCS	SCHEME	
	
1 L=0.1	
2 alpha=0.0001	
3 t_final=60	
4 n=10	
5 T0=0	
6 T1s=40	
7 T2s=20	
8 dx=L/n	
9 dt=0.1	
10 x=dx/2:dx:L-dx/2	
11 T=ones(n,1)*T0	
12 dTdt=zeros(n,1)	
13 t=0:dt:t_final	
14 for	j=1:length(t)	
15 for	i=2:n-1	
16 dTdt(i)=alpha*(T(i+1)+T(i-1)-2*T(i))/dx^2	
17 end	
18 dTdt(1)=alpha*(T(2)+T1s-2*T(1))/dx^2	
19 dTdt(n)=alpha*(T2s+T(n-1)-2*T(n))/dx^2	
20 T=T+dTdt*dt	
21 figure(1)	
22 plot(x,T,	'Linewidth',3)	
23 axis([0	L	0	50])	
24 xlabel('Distance	(m)')	
25 ylabel('Temperature	(circC)')	
26 pause(0.1)	
27 end
15	
	
						 	
	 	 	 t=0.1s		 	 	 	 	 t=3s	
	
				 	
	 	 	 t=13s	 	 	 	 	 	 t=40s	
	
	
Figure	7:	Output	plot	for	FTCS	scheme	at	various	time-step	
	
It	has	been	observed	from	the	above	results	that	the	initial	temperature	is	at	0°C.	After	3s,	
the	surface	temperatures	of	the	wall	are	hotter	than	0°C.	Hence,	the	heat	flux	comes	at	the	
beginning	at	both	sides	and	the	temperature	starts	to	rise	over	the	whole	wall.	It	gradually	
rises	until	it	reaches	a	steady	state.	The	final	temperature	distribution	is	a	straight	line,	
which	is	validated	from	the	analytical	results.	
	
A	 3D	 plot	 has	 been	 taken	 by	 taking	 the	 time	 axis	 as	 the	 third	 axis	 and	 plotting	 the	
temperature	distribution	along	the	length	of	the	wall.	The	total	time	taken	to	reach	the	
steady	state	is	taken	as	80	sec.	To	get	a	better	view,	the	temperature	on	both	the	surfaces	
of	the	wall	is	taken	as	70°C	and	90°C.
16	
	
	
Figure	8:	3D	plot	of	temperature	distribution	of	time-dependent	1D	heat	equation	
	
For	 the	 backward	 time,	 centered	 space	 (BTCS)	 method,	 the	 backward	 difference	 is	
selected	to	get:	
	
𝑇!
!
− 𝑇!
!!!
∆𝑡
= 𝛼
𝑇!!!
!
− 2𝑇!
!
+ 𝑇!!!
!
∆𝑥 !
	
	
Unlike	 the	 FTCS	 method,	 the	 above	 equation	 cannot	 be	 rearranged	 to	 obtain	 a	 simple	
algebraic	formula.	The	equation	is	an	implicit	function	and	is	a	system	of	equations	for	the	
values	of	T	at	the	internal	nodes	of	the	spatial	mesh.	To	see	the	set	of	system	of	equations	
more	clearly,	we	rearrange	to	get	the	resulting	equation	as:	
	
−
𝛼
∆𝑥 !
𝑇!!!
!
+
1
Δ𝑡
+
2𝛼
∆𝑥 !
𝑇!
!
−
𝛼
∆𝑥 !
𝑇!!!
!
=
𝑇!
!!!
Δ𝑡
	
	
The	 set	 of	 equations	 can	 be	 represented	 in	 matrix	 form	 A*T=B	 to	 get	 the	 temperature	
distribution	at	the	interior	nodes.		
	
MATLAB	CODE	FOR	BTCS	SCHEME	
	
1 nt=10	
2 nx=20	
3 alpha=0.1	
4 L=1	
5 Tmax=0.5	
6 dx=L/(nx-1);	
7 dt=tmax/(nt-1);
17	
8 x=linespace(0,L,nx)’;	
9 t=linespace(0,tmax,nt);	
10 U=zeroes(nx,nt);	
11 u0=0;	
12 uL=0;	
13 a=(-alpha/dx^2)*ones(nx,1);	
14 c=a;	
15 b=(1/dt)*ones(nx,1)-2*a;	
16 b(1)=1;	
17 c(1)=0;	
18 b(end)=1;	
19 a(end)=1;	
20 d=U(:,m-1)/dt;	
21 d(1)=u0;	
22 d(end)=uL;	
23 U(:,m)=tridiagLUSolve(d,a,e,f,U(:m,m-1));	
24 end	
	
	
	
	
	
Figure	9:	Output	plot	for	BTCS	scheme	at	different	time-step
18	
PROGRAM	5	
	
A	MATLAB	program	has	been	written	to	solve	the	2D	differential	heat	equation.	The	heat	
equation	is	given	by:	
	
𝜕𝑇
𝜕𝑡
= 𝜅
𝜕!
𝑇
𝜕𝑥!
+
𝜕!
𝑇
𝜕𝑦!
= 𝜅∇!
𝑇	
where	𝜅	is	the	thermal	diffusivity.	Now,	we	discretize	this	equation	using	the	finite	
difference	method.	We	take	ni	points	in	the	X-direction	and	nj	points	in	the	Y-direction.	
The	grid	spacing	is	taken	as	dx.	We	take	Δx=Δy=h.		
	
	
	
	
The	explicit	method	is	unstable	if	the	time-step	is	too	large.	This	means,	we	get	oscillations	
and	the	amplitude	grows	exponentially	with	time.	This	depends	on	the	grid	spacing.		
	
∆𝑡!"#$#!%& = 𝑎 (∆𝑥)!
𝜅	
	
MATLAB	CODE	FOR	PROGRAM	5	
	
1 clear	all;	
2 clc;	
3 Li=0.1;	
4 Lj=0.2;	
5 ni=10;	
6 nj=Lj/(Li*ni);	
7 dx=Li/(ni-1);	
8 Th=600;	
9 Tc=290;	
10 Ta=293;	
11 t2=10;	
12 t(1)=0;	
13 dt=0.01;	
14 ks=387;	
15 rho=8940;	
16 cp=380;	
17 alpha=ks/(rho*cp);	
18 h=20;	
19 T(1:ni+2:nj)=Ta;
19	
20 Fo=alpha*dt/(dx.^2);	
21 Bi=h*dx/ks;	
22 k=1	
23 while	t<t2	
24 for	i=2:ni+1	
25 for	j=1:nj	
26 if	j==1	
27 T(i,j,k+1)=Fo*(2*T(i-1,j,k)+T(i+,j,k)+T(i,j+1,k)+2*Bi*Th)+(1-4*Fo-2*Bi*Fo)*T(i,j,k);	
28 else	if	j>1	&&	j<nj	
29 T(i,j,k+1)=Fo*(T(i+1,j,k)+T(i-1,j,k)+T(i,j+1,k)+T(i,j-1,k))+(1-4*Fo)*T(i,j,k);	
30 elseif	j==nj	
31 T(i,j,k+1)=Fo*(2*T(i-1,j,k)+T(i+1,j,k)+T(i,j-1,k)+2*Bi*Tc)+(1-4*Fo-
2*Bi*Fo)*T(i,j,k);		
32 end	
33 end	
34 end	
35 for	j	=	1:nj	
36 T(1,j,k+1)=	T(3,j,k)	;	
37 T(ni+2,j,k+1)=	T(ni,j,k);	
38 end	
39 t(k+1)=	t(k)	+	dt;	
40 k=k	+	1;					
41 end		
42 Temp(1:ni,1:nj)=T(2:ni+1,1:nj,k-1);	
43 for	i	=	1:ni	
44 x(i)=dx*(i-1)	;	
45 end	
46 for	j	=	1:nj	
47 y(j)	=	dx*(j-1)	;	
48 end
20	
PROGRAM	6	
	
A	 MATLAB	 program	 for	 the	 investigation	 of	 the	 sprinkler	 response	 time	 predictive	
capability	 has	 been	 written.	 A	 heat	 detector	 response	 model	 is	 intended	 to	 predict	 the	
time	at	which	a	heat	detector	is	expected	to	operate	given	the	properties	of	the	detector	
and	the	fire	environment	to	which	it	is	exposed.		
	
The	activation	time	of	the	sprinkler	is	the	time	at	which	the	temperature	of	the	sprinkler	
bulb	 reaches	 the	 nominal	 activation	 temperature.	 Convective	 heat	 transfer	 from	 the	
flowing	 gases	 in	 the	 ceiling	 jet	 to	 the	 sprinkler	 bulb	 is	 the	 primary	 heat	 transfer	
mechanism.	However,	for	an	enclosure	where	the	ceiling	jet	is	immersed	in	a	hot	layer,	
additional	 heat	 transfer	 from	 the	 hot	 layer	 to	 the	 sprinkler	 occurs.	 There	 are	 also	 heat	
conduction	losses	from	the	sprinkler	head	to	the	attached	pipework.		
	
The	 differential	 equation	 describing	 the	 rate	 of	 change	 of	 temperature	 of	 the	 sensing	
element	of	the	sprinkler	is	given	by:	
	
𝑑𝑇!
𝑑𝑥
=
𝑉!(𝑇! − 𝑇!)
𝑅𝑇𝐼
	
	
The	predicted	sprinkler	response	time	is	based	on	a	single	burning	object	located	within	
the	room	of	fire	origin.		
	
MATLAB	CODE	FOR	PROGRAM	6	
	
1 clear	all	
2 close	all	
3 clc	
4 vel_g=5;	
5 RTI=40		;								
6 T_amb=293;												
7 T_g=500;	
8 T_d_final=400;								
9 dt=	0.1	;	
10 t(1)	=	0		;		
11 T_d(1)	=	T_	inf;	
12 i=1;	
13 while	T_d	<	T_d_final	
14 del_T_d=	sqrt(vel_g)/RTI*(T_g-T_d(i))*dt	;		
15 T_d(i+1)	=	T_d(i)	+	del_T_d	;	
16 	t(i+1)=	t(i)	+	dt	;				
17 	i	=	i	+	1		;				
18 	if	i	>	50000	
19 	fprintf('autobreak')	
20 	break	
21 	end			
22 end	
23 figure	
24 plot(t,T_d)
21	
25 xlabel('Time	-	seconds')	
26 ylabel('Detector	Temperature	-	K')	
27 title('Detector	Temperature	vs.	Time')
22	
PROGRAM	7	
	
The	advection-diffusion	equation	describes	physical	phenomena	where	particles,	energy,	
or	other	physical	quantities	are	transferred	inside	a	physical	system	due	to	two	processes:	
diffusion	and	advection.	Advection	is	a	transport	mechanism	of	a	substance	or	conserved	
property	 by	 a	 fluid	 due	 to	 the	 fluid’s	 bulk	 motion.	 Diffusion	 is	 the	 net	 movement	 of	
molecules	or	atoms	from	a	region	of	high	concentration	to	a	region	of	low	concentration.	
The	 advection-diffusion	 equation	 is	 a	 relatively	 simple	 equation	 describing	 flows,	 or	
alternatively,	describing	a	stochastically-changing	system.		
	
The	general	form	of	the	1D	advection-diffusion	is	given	as:	
	
𝑑𝑈
𝑑𝑡
= 𝜖
𝑑!
𝑈
𝑑𝑥!
− 𝑎
𝑑𝑈
𝑑𝑥
+ 𝐹	
	
where	 U	 is	 the	 temperature	 for	 this	 given	 problem,	 t	 is	 the	 time,	𝜖	is	 the	 diffusion	
coefficient,	a	is	the	average	velocity,	F	describes	the	“sources”	or	“sinks”	of	the	quantity	U.	
The	 four	 terms	 represent	 the	 transient,	 diffusion,	 advection	 and	 source	 or	 sink	 term	
respectively.		For	the	steady	state,	
!"
!"
= 0.		
	
A	 FORTRAN95	 code	 has	 been	 written	 to	 numerically	 approximate	 the	 solution	 of	 the	
advection-diffusion	 equation	 typically	 using	 the	 finite	 difference	 method	 (FDM).	 Our	
problem	reduces	to:	
	
−𝜖
𝑑!
𝑈
𝑑𝑥!
+ 𝑎
𝑑𝑈
𝑑𝑥
= 0, 0 < 𝑥 < 1 ; 𝑈 0 = 0 ; 𝑈 1 = 0	
	
We	discretize	the	interval	[0,1]	into	NX	nodes.	We	write	the	boundary	conditions	at	the	
first	and	last	nodes.	At	the	i-th	interior	node,	we	replace	derivatives	by	differences:	
	
𝑑𝑈
𝑑𝑥
=
(𝑈 𝑥 + 𝑑𝑥 − 𝑈(𝑥 − 𝑑𝑥))
2𝑑𝑥
	
	
𝑑!
𝑈
𝑑𝑥!
=
(𝑈 𝑥 + 𝑑𝑥 − 2𝑈 𝑥 + 𝑈 𝑥 − 𝑑𝑥 )
(𝑑𝑥)!
	
	
This	 becomes	 a	 set	 of	 NX	 linear	 equations	 in	 the	 NX	 unknown	 values	 of	 U.	 The	 exact	
solution	to	this	differential	equation	is	known:	
	
𝑈 =
(1 − 𝑒!"
)
(1 − 𝑒!)
𝑤ℎ𝑒𝑟𝑒 𝑟 =
𝑎
𝜖
	
	
The	results	for	the	exact	analytical	solution	and	the	solution	obtained	from	FDM	has	been	
compared	and	plotted	in	graph.	It	has	been	seen	that	there	is	an	insignificant	difference	
between	the	two	values.
23	
FORTRAN	CODE	FOR	PROGRAM	7	
	
1 program	Heat	
2 implicit	none	
3 real	::	a,	b	
4 real,	allocatable	::	a3(:,:)	
5 real	::	dx	
6 real,	allocatable	::	f(:)	
7 integer	::	i,j	
8 real	::	k,	r,	v	
9 integer	::	nx	
10 real,	allocatable	::	u(:),w(:),x(:)	
11 real	::	xm	
12 v=1	
13 k=0.05	
14 nx=101	
15 a=0	
16 b=1	
17 dx=(b-a)/(nx-1)	
18 allocate	(x(1:nx))	
19 if	(nx==1)	then	
20 x(1)=(a+b)/2	
21 else	
22 do	i=1,nx	
23 x(i)=((nx-i)*a+(i-1)*b)/(nx-1)	
24 end	do	
25 end	if	
26 allocate	(a3(1:nx,1:3))	
27 a3(1:nx,1:3)=0	
28 allocate	(f(1:nx))	
29 f(1:nx)=0	
30 a3(1,2)=1	
31 f(1)=0	
32 do	i=2,nx-1	
33 a3(i,1)=-v/(2*dx)-k/(dx*dx)	
34 a3(i,2)=(2*k)/(dx*dx)	
35 a3(i,3)=v/(2*dx)-k/(dx*dx)	
36 f(i)=0	
37 end	do	
38 a3(nx,2)=1	
39 f(nx)=1	
40 allocate	(u(1:nx))	
41 do	i=1,nx	
42 if(	a3(i,2)==0)	then	
43 write(*,*)	“error”	
44 end	if	
45 end	do	
46 u(1:nx)=f(1:nx)	
47 do	i=2,nx
24	
48 xm=a3(i,1)/a3(i-1,2)	
49 a3(i,2)=a3(i,2)-xm*a3(i-1,3)	
50 u(i)=u(i)-xm*u(i-1)	
51 end	do	
52 u(nx)=u(nx)/a3(nx,2)	
53 do	i=nx-1,1,-1	
54 u(i)=(u(i)-a3(i,3)*u(i+1))/a3(i,2)	
55 end	do	
56 r=v*(b-a)/k	
57 allocate(w(1:nx))	
58 w(1:nx)=(1-exp(r*x(1:nx)))/(1-exp(r))	
59 deallocate(a3)	
60 deallocate(f)	
61 deallocate(u)	
62 deallocate(w)	
63 deallocate(x)	
64 end	
65 end	program	Heat	
	
	
	
	
	
Figure	12:	Output	plot	for	Program	7
25	
	
	
	
	
	
	
	
Figure	13:	Output	screen	for	Program	7
26	
PROGRAM	8	
	
For	the	1D,	time	dependent	advection	diffusion	a	MATLAB	program	has	been	written	to	
solve	the	equation	by	using	the	First-order	Upwind	(FOU)	scheme.	The	equation	is	given	
as:		
	
𝑑𝑈
𝑑𝑡
= −𝑣
𝑑𝑈
𝑑𝑥
	
	
The	exact	values	have	also	been	plotted	in	the	same	program	with	a	red	curve.		
	
MATLAB	CODE	FOR	PROGRAM	8	
	
1 clear	
2 clc	
3 xmin=0;	
4 xmax=1;	
5 N=100;	
6 dt=0.009;	
7 t=0;	
8 tmax=0.5;	
9 v=1;	
10 dx=(xmax-xmin)/N;	
11 u0=exp(-200*(x-0.25).^2);	
12 u=u0;	
13 unp1=u0;	
14 nsteps=tmax/dt;	
15 for	n=1:nsteps	
16 u(1)=u(3);	
17 u(N+3)=u(N+1);	
18 for	i=2:N+2	
19 unp1(i)=u(i)-v*dt/dx*(u(i)-u(i-1));	
20 end	
21 t=t+dt;	
22 u=unp1;	
23 exact=exp(-200*(x-0.25-v*t).^2);	
24 plot(x,exact,’r-‘,);	
25 hold	on	
26 plot(x,u,’bo-‘,’markerfacecolor’,’b’);	
27 hold	off	
28 axis([xmin	xmax	-0.5	1.5])	
29 xlabel(‘x’,’fontsize’,16)	
30 ylabel(‘U(t,x)’,’fontsize’,16)	
31 title(sprint(‘time=%1.3f’,t),’fontsize’,16)	
32 shg	
33 pause(dt);	
34 end
27	
Nomenclature	for	the	above	program	is:	
Ø xmin	is	the	minimum	value	of	x	
Ø xmax	is	the	maximum	value	of	x	
Ø N	is	the	number	of	nodes	minus	one	
Ø dt	is	the	timestep	
Ø t	is	the	time	in	seconds	
Ø tmax	is	the	maximum	value	of	t	
Ø v	is	the	velocity	
	
	
					 	
	 	 	 t=0.009s	 	 	 	 	 t=0.162s	
	
					 	
	 	 	 t=0.252s	 	 	 	 	 							t=0.495s	
	
	
Figure	14:	Output	screen	for	the	advection	diffusion	equation		
at	different	time-steps

Weitere ähnliche Inhalte

Was ist angesagt?

6th ed solution manual---fundamentals-of-heat-and-mass-transfer
6th ed solution manual---fundamentals-of-heat-and-mass-transfer6th ed solution manual---fundamentals-of-heat-and-mass-transfer
6th ed solution manual---fundamentals-of-heat-and-mass-transferRonald Tenesaca
 
First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...
First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...
First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...Kum Visal
 
Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...
Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...
Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...kl kl
 
Application of Ordinary Differential Equation in civil engineering
Application of Ordinary Differential Equation in civil engineeringApplication of Ordinary Differential Equation in civil engineering
Application of Ordinary Differential Equation in civil engineeringEngr Mir Noor Ahmed Langove
 
One-dimensional conduction-with_no_heat_generation
One-dimensional conduction-with_no_heat_generationOne-dimensional conduction-with_no_heat_generation
One-dimensional conduction-with_no_heat_generationtmuliya
 
003 heat conduction equation thai
003 heat conduction equation thai003 heat conduction equation thai
003 heat conduction equation thaiSaranyu Pilai
 
Application of Differential Equation
Application of Differential EquationApplication of Differential Equation
Application of Differential EquationSalim Hosen
 
Design & CFD Analysis of Heat Exchanger
Design & CFD Analysis of Heat ExchangerDesign & CFD Analysis of Heat Exchanger
Design & CFD Analysis of Heat ExchangerCPDLR
 
Heat transfer & Conduction
Heat transfer & ConductionHeat transfer & Conduction
Heat transfer & ConductionAlan Wrafter
 
Chapter 5 NUMERICAL METHODS IN HEAT CONDUCTION
Chapter 5NUMERICAL METHODS IN HEAT CONDUCTIONChapter 5NUMERICAL METHODS IN HEAT CONDUCTION
Chapter 5 NUMERICAL METHODS IN HEAT CONDUCTIONAbdul Moiz Dota
 
Thermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of ThermodynamicsThermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of ThermodynamicsMuhammad Surahman
 
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJAPPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJZuhair Bin Jawaid
 
Advanced thermodynamics
Advanced thermodynamicsAdvanced thermodynamics
Advanced thermodynamicsOrtal Levi
 

Was ist angesagt? (20)

Introduction of Partial Differential Equations
Introduction of Partial Differential EquationsIntroduction of Partial Differential Equations
Introduction of Partial Differential Equations
 
6th ed solution manual---fundamentals-of-heat-and-mass-transfer
6th ed solution manual---fundamentals-of-heat-and-mass-transfer6th ed solution manual---fundamentals-of-heat-and-mass-transfer
6th ed solution manual---fundamentals-of-heat-and-mass-transfer
 
Fluid dynamics
Fluid dynamicsFluid dynamics
Fluid dynamics
 
First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...
First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...
First Law of Thermodynamics: Energy Conservation For Mechanical and Industria...
 
Heat transfer chapter one and two
Heat transfer chapter one and twoHeat transfer chapter one and two
Heat transfer chapter one and two
 
Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...
Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...
Solution Manual – Heat and Mass Transfer: Fundamentals and Application, 5th e...
 
Application of Ordinary Differential Equation in civil engineering
Application of Ordinary Differential Equation in civil engineeringApplication of Ordinary Differential Equation in civil engineering
Application of Ordinary Differential Equation in civil engineering
 
One-dimensional conduction-with_no_heat_generation
One-dimensional conduction-with_no_heat_generationOne-dimensional conduction-with_no_heat_generation
One-dimensional conduction-with_no_heat_generation
 
Chapter 4 transient heat condution
Chapter 4 transient heat condution Chapter 4 transient heat condution
Chapter 4 transient heat condution
 
003 heat conduction equation thai
003 heat conduction equation thai003 heat conduction equation thai
003 heat conduction equation thai
 
Application of Differential Equation
Application of Differential EquationApplication of Differential Equation
Application of Differential Equation
 
Design & CFD Analysis of Heat Exchanger
Design & CFD Analysis of Heat ExchangerDesign & CFD Analysis of Heat Exchanger
Design & CFD Analysis of Heat Exchanger
 
Heat transfer & Conduction
Heat transfer & ConductionHeat transfer & Conduction
Heat transfer & Conduction
 
Unit2
Unit2Unit2
Unit2
 
95396211 heat-transfer-lab-manual
95396211 heat-transfer-lab-manual95396211 heat-transfer-lab-manual
95396211 heat-transfer-lab-manual
 
Chapter 5 NUMERICAL METHODS IN HEAT CONDUCTION
Chapter 5NUMERICAL METHODS IN HEAT CONDUCTIONChapter 5NUMERICAL METHODS IN HEAT CONDUCTION
Chapter 5 NUMERICAL METHODS IN HEAT CONDUCTION
 
Thermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of ThermodynamicsThermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of Thermodynamics
 
Finite Difference Method
Finite Difference MethodFinite Difference Method
Finite Difference Method
 
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJAPPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
 
Advanced thermodynamics
Advanced thermodynamicsAdvanced thermodynamics
Advanced thermodynamics
 

Ähnlich wie FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS

Numerical solution of heat equation through double interpolation
Numerical solution of heat equation through double interpolationNumerical solution of heat equation through double interpolation
Numerical solution of heat equation through double interpolationIOSR Journals
 
Application of thermal error in machine tools based on Dynamic Bayesian Network
Application of thermal error in machine tools based on Dynamic Bayesian NetworkApplication of thermal error in machine tools based on Dynamic Bayesian Network
Application of thermal error in machine tools based on Dynamic Bayesian NetworkIJRES Journal
 
An Efficient Tangent Scheme For Solving Phase-Change Problems
An Efficient Tangent Scheme For Solving Phase-Change ProblemsAn Efficient Tangent Scheme For Solving Phase-Change Problems
An Efficient Tangent Scheme For Solving Phase-Change ProblemsDarian Pruitt
 
Numerical modeling-of-gas-turbine-engines
Numerical modeling-of-gas-turbine-enginesNumerical modeling-of-gas-turbine-engines
Numerical modeling-of-gas-turbine-enginesCemal Ardil
 
Numerical Solution of Diffusion Equation by Finite Difference Method
Numerical Solution of Diffusion Equation by Finite Difference MethodNumerical Solution of Diffusion Equation by Finite Difference Method
Numerical Solution of Diffusion Equation by Finite Difference Methodiosrjce
 
Heat flow through concrete floor
Heat flow through concrete floorHeat flow through concrete floor
Heat flow through concrete floorAmy Do
 
Graphical methods for 2 d heat transfer
Graphical methods for 2 d heat transfer Graphical methods for 2 d heat transfer
Graphical methods for 2 d heat transfer Arun Sarasan
 
HOME ASSIGNMENT (0).pptx
HOME ASSIGNMENT (0).pptxHOME ASSIGNMENT (0).pptx
HOME ASSIGNMENT (0).pptxSayedulHassan1
 
A Numerical Method For Friction Problems With Multiple Contacts
A Numerical Method For Friction Problems With Multiple ContactsA Numerical Method For Friction Problems With Multiple Contacts
A Numerical Method For Friction Problems With Multiple ContactsJoshua Gorinson
 
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
 
HOME ASSIGNMENT omar ali.pptx
HOME ASSIGNMENT omar ali.pptxHOME ASSIGNMENT omar ali.pptx
HOME ASSIGNMENT omar ali.pptxSayedulHassan1
 
Jamie Fogarty CFD FINAL DRAFT PRINT
Jamie Fogarty CFD FINAL DRAFT PRINTJamie Fogarty CFD FINAL DRAFT PRINT
Jamie Fogarty CFD FINAL DRAFT PRINTJamie Fogarty
 
Staircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalghStaircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalghJacob Greenhalgh
 
Numerical methods- Steady-state-1D-and-2D-Part- I
Numerical methods- Steady-state-1D-and-2D-Part- INumerical methods- Steady-state-1D-and-2D-Part- I
Numerical methods- Steady-state-1D-and-2D-Part- Itmuliya
 

Ähnlich wie FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS (20)

Numerical solution of heat equation through double interpolation
Numerical solution of heat equation through double interpolationNumerical solution of heat equation through double interpolation
Numerical solution of heat equation through double interpolation
 
Application of thermal error in machine tools based on Dynamic Bayesian Network
Application of thermal error in machine tools based on Dynamic Bayesian NetworkApplication of thermal error in machine tools based on Dynamic Bayesian Network
Application of thermal error in machine tools based on Dynamic Bayesian Network
 
APPLICATION OF NUMERICAL METHODS IN SMALL SIZE
APPLICATION OF NUMERICAL METHODS IN SMALL SIZEAPPLICATION OF NUMERICAL METHODS IN SMALL SIZE
APPLICATION OF NUMERICAL METHODS IN SMALL SIZE
 
An Efficient Tangent Scheme For Solving Phase-Change Problems
An Efficient Tangent Scheme For Solving Phase-Change ProblemsAn Efficient Tangent Scheme For Solving Phase-Change Problems
An Efficient Tangent Scheme For Solving Phase-Change Problems
 
Numerical modeling-of-gas-turbine-engines
Numerical modeling-of-gas-turbine-enginesNumerical modeling-of-gas-turbine-engines
Numerical modeling-of-gas-turbine-engines
 
numerical.ppt
numerical.pptnumerical.ppt
numerical.ppt
 
Numerical Solution of Diffusion Equation by Finite Difference Method
Numerical Solution of Diffusion Equation by Finite Difference MethodNumerical Solution of Diffusion Equation by Finite Difference Method
Numerical Solution of Diffusion Equation by Finite Difference Method
 
Heat flow through concrete floor
Heat flow through concrete floorHeat flow through concrete floor
Heat flow through concrete floor
 
Graphical methods for 2 d heat transfer
Graphical methods for 2 d heat transfer Graphical methods for 2 d heat transfer
Graphical methods for 2 d heat transfer
 
HOME ASSIGNMENT (0).pptx
HOME ASSIGNMENT (0).pptxHOME ASSIGNMENT (0).pptx
HOME ASSIGNMENT (0).pptx
 
A Numerical Method For Friction Problems With Multiple Contacts
A Numerical Method For Friction Problems With Multiple ContactsA Numerical Method For Friction Problems With Multiple Contacts
A Numerical Method For Friction Problems With Multiple Contacts
 
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...
 
HOME ASSIGNMENT omar ali.pptx
HOME ASSIGNMENT omar ali.pptxHOME ASSIGNMENT omar ali.pptx
HOME ASSIGNMENT omar ali.pptx
 
Jamie Fogarty CFD FINAL DRAFT PRINT
Jamie Fogarty CFD FINAL DRAFT PRINTJamie Fogarty CFD FINAL DRAFT PRINT
Jamie Fogarty CFD FINAL DRAFT PRINT
 
first research paper
first research paperfirst research paper
first research paper
 
Staircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalghStaircases_in_Fluid_Dynamics_JacobGreenhalgh
Staircases_in_Fluid_Dynamics_JacobGreenhalgh
 
zueva_abstract_of_thesis
zueva_abstract_of_thesiszueva_abstract_of_thesis
zueva_abstract_of_thesis
 
Transient heat conduction
Transient heat conductionTransient heat conduction
Transient heat conduction
 
Numerical methods- Steady-state-1D-and-2D-Part- I
Numerical methods- Steady-state-1D-and-2D-Part- INumerical methods- Steady-state-1D-and-2D-Part- I
Numerical methods- Steady-state-1D-and-2D-Part- I
 

Kürzlich hochgeladen

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfsmsksolar
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...Health
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stageAbc194748
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 

Kürzlich hochgeladen (20)

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 

FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS

  • 1. 1
  • 2. 2 PROGRAM LIST PROG. NO. PROGRAM DESCRIPTION COMPILER PAGE NO. 1 Error difference between analytical solution and finite difference method FORTRAN 95 3 2 Solving 1D steady state differential heat equation FORTRAN 95 3 Solving 2D steady state heat equation FORTRAN 95 4 Solving 1D transient heat equation MATLAB 5 Solving 2D transient heat equation MATLAB 6 Investigation of the sprinkler response time with activation temperature MATLAB 7 Solving steady state advection-diffusion equation FORTRAN 95 8 Solving 1D time dependent advection diffusion using FOU scheme FORTRAN 95
  • 3. 3 FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS Rahul Roy Department of Mechanical Engineering, Jadavpur University, Kolkata 700032, India INTRODUCTION This report provides a practical overview of numerical solutions to the heat equation using the finite difference method (FDM). The forward time, centered space (FTCS), the backward time, centered space (BTCS), and Crank-Nicolson schemes are developed, and applied to a simple problem in1volving the one-dimensional heat equation. Complete, working Matlab and FORTRAN codes for each program are presented. The results of running the codes on finer (one-dimensional) meshes, and with smaller time steps are demonstrated. These sample calculations show that the schemes realize theoretical predictions of how their truncation errors depend on mesh spacing and time step. The Matlab codes are straightforward and allow us to see the differences in implementation between explicit method (FTCS) and implicit methods (BTCS). The codes also allow us to experiment with the stability limit of the FTCS scheme. FINITE DIFFERENCE METHOD The finite difference method is one of several techniques for obtaining numerical solutions. In all numerical solutions the continuous partial differential equation (PDE) is replaced with a discrete approximation. In this context the word “discrete” means that the numerical solution is known only at a finite number of points in the physical domain. The user of the numerical method can select the number of those points. In general, increasing the number of points not only increases the resolution, but also the accuracy of the numerical solution. The discrete approximation results in a set of algebraic equations that are evaluated (or solved) for the values of the discrete unknowns. The mesh is the set of locations where the discrete solution is computed. These points are called nodes, and if one were to draw lines between adjacent nodes in the domain the resulting image would resemble a net or mesh. Two key parameters of the mesh are ∆x, the local distance between adjacent points in space, and ∆t, the local distance between adjacent time steps. The core idea of the finite-difference method is to replace continuous derivatives with so called difference formulas that involve only the discrete values associated with positions on the mesh. Applying the finite-difference method to a differential equation involves re- placing all derivatives with difference formulas. In the heat equation there are derivatives with respect to time, and derivatives with respect to space. Using different combinations of mesh points in the difference formulas results in different schemes. In the limit as the mesh spacing (∆x and ∆t) go to zero, the numerical solution obtained with any useful scheme will approach the true solution to the original differential equation. However, the rate at which the numerical solution approaches the true solution varies with the scheme. In addition, there are some practically useful schemes that can fail to yield a solution for bad combinations of ∆x and ∆t.
  • 4. 4 PROGRAM 1 A simple, basic Fortran95 code is written to find the tangent of the function 𝑓 𝑥 = cos (𝑥) by using finite difference approach. This approach uses the concept of discretization of space and time into distinct points or units. Every equation is satisfied for each distinct point or steps and a numerical iteration is carried out to reach a optimum solution. The numerical solution approaches the true solution as the number of grids is increased. The finite difference approximation becomes more accurate as grid spacing decreases. FORTRAN CODE FOR PROGRAM 1 1 program Heat 2 implicit none 3 integer :: n 4 integer :: i 5 real,allocatable :: y(:),dydx(:) 6 real :: x,dx 7 write(*,*) 'Enter No. of grid Points' 8 read(*,*) n 9 allocate (y(n) , dydx(n)) 10 dx=10.0/(n-1) 11 do i=1,n 12 x=(i-1)*dx 13 y(i)=cos(x) 14 end do 15 call derivative (y,n,dx,dydx) 16 do i=1,n 17 x=(i-1)*dx 18 print *, dydx(i), -sin(x) , -sin(x)-dydx(i) 19 end do 20 deallocate (y,dydx) 21 contains 22 subroutine derivative (a,np,h,aprime) 23 integer :: np 24 real :: a(np),h 25 real :: aprime(np) 26 do i=1,np-1 27 aprime(i)=(a(i+1)-a(i))/h 28 end do 29 aprime(np) = 0 30 end subroutine derivative 31 end program Heat The above program illustrates the difference between the values obtained from actual derivatives and the finite difference approximations. The difference between the two values gives the error due to the scheme. A graph has been plotted to obtain the results of the finite difference method in Figure 1. The results show that there is only slight error between the two values.
  • 5. 5 Figure 1. Differentiation of the function f(x) using (i) Finite Difference Method (ii) Calculus Method PROGRAM 2 A FORTRAN95 program which applies the finite difference method to estimate the solution of the steady state (time independent) heat equation over a one-dimensional region, which can be thought of as a thin metal rod. We will assume the rod extends over the range A <= X <= B. The quantity of interest is the temperature U(X) at each point in the rod. We will assume that the temperature of the rod is fixed at known values at the two endpoints. The material of the rod is considered as homogenous and isotropic. Symbolically, we write the boundary conditions: U(A)=Ua and U(B)=Ub. Inside the rod, we assume that a version of the steady (time independent) heat equation applies. This assumes that the situation in the rod has "settled down", so that the temperature configuration has no further tendency to change. The equation we will consider is: − 𝑑 𝑑𝑥 𝑘(𝑥) 𝑑𝑈 𝑥 𝑑𝑥 = 𝐹(𝑥) Here, the right hand side term F(X) allows us to consider internal heat sources in the metal - perhaps a portion of the rod is sitting above a blow torch. The coefficient K(X) is a measure of heat conductivity. It measures the rate at which the heat from a local hot spot will spread out. If the heat source function F(X) is zero everywhere, and if K(X) is constant, then the solution U(X) will be the straight line function that matches the two endpoint values. Making F(X) positive over a small interval will "heat up" that portion. We can simulate a rod that is divided into regions of different materials by setting the function K(X) to have a given value K1 over some subinterval of [A,B] and value K2 over the rest of the region. To estimate the value of the solution, we will pick a uniform mesh of N points
  • 6. 6 X(1) through X(N), from A to B. At the i-th point, we will compute an estimated temperature U(i). To do this, we will need to use the boundary conditions and the differential equation. Since X(1) = A and X(N) = B, we can use the boundary conditions to set U(1) = Ua and U(N) = Ub. For the points in the interior, we need to approximate the differential equation in a way that allows us to determine the solution values. We will do this using a finite difference approximation. Suppose we are working at node X(I), which is associated with U(I). Then a centered difference approximation to the double derivative is: − 𝑑 𝑑𝑥 𝑘 𝑥 𝑑𝑈 𝑥 𝑑𝑥 = − (𝑘(𝑋 𝑖 + Δ𝑥 2 )(𝑈 𝑋 𝑖 + 1 − 𝑈 𝑋 𝑖 ) Δ𝑥 − (𝑘(𝑋 𝑖 − Δ𝑥 2 )(𝑈 𝑋 𝑖 − 𝑈 𝑋 𝑖 − 1 ) Δ𝑥! If we rearrange the terms in this approximation, and set it equal to F(X(i)), we get the finite difference approximation to the differential equation at X(i): −𝑘 𝑋 𝑖 − Δ𝑥 2 ∗ 𝑈 𝑋 𝑖 − 1 + 𝑘 𝑋 𝑖 − Δ𝑥 2 + 𝑘 𝑋 𝑖 + Δ𝑥 2 ∗ 𝑈 𝑋 𝑖 − 𝑘 𝑋 𝑖 + Δ𝑥 2 ∗ 𝑈 𝑋 𝑖 + 1 = Δ𝑥 ∗ Δ𝑥 ∗ 𝐹(𝑋 𝑖 ) This means that we have N-2 equations, each of which involves an unknown U(i) and its left and right neighbors, plus the two boundary conditions, which give us a total of N equations in N unknowns. We can set up and solve these linear equations using a matrix A for the coefficients, and a vector RHS for the right hand side terms, and calling a function to solve the system A*U=RHS will give us the solution. Because finite differences are only an approximation to derivatives, this process only produces estimates of the solution. Usually, we can reduce this error by decreasing Δ𝑥. FORTRAN CODE FOR PROGRAM 2 1 program HEAT 2 implicit none 3 integer :: n 4 real :: a, b, dx, f, k 5 integer :: i 6 real :: rhs(n), tri(3,n) 7 real :: u(n), x(n) 8 real :: ua, ub, xm, xp 9 a=0 10 b=1 11 ua=0 12 ub=1 13 n=11 14 dx=(b-a)/(n-1) 15 do i=1,n 16 x(i)=((n-1)*a+(i-1)*b)/(n-1) 17 end do 18 tri(1,1)=0 19 tri(2,1)=1
  • 7. 7 20 tri(3,1)=0 21 rhs(1)=ua 22 do i=2,n-1 23 xm=(x(i-1)+x(i))/2 24 xp=(x(i)+x(i+1)/2 25 tri(1,i)=(-xm)/(dx*dx) 26 tri(2,i)=(xm+xp)/(dx*dx) 27 tri(3,i)=(-xp)/(dx*dx) 28 rhs(i)=0 29 end do 30 tri(1,n)=0 31 tri(2,n)=0 32 tri(3,n)=0 33 u(1:n)=rhs(1:n) 34 do i=2,n 35 tri(2,i)=tri(2,i)-tri(3,i-1)*tri(1,i)/tri(2,i-1) 36 u(i)=u(i)-u(i-1)*tri(1,i)/tri(2,i-1) 37 end do 38 u(n)=u(n)/tri(2,n) 39 do i=n-1,1,-1 40 u(i)=(u(i)-tri(3,i)*u(i+1))/tri(2,i) 41 end do 42 u(n)=u(n)/tri(2,n) 43 do i=n-1,1,-1 44 u(i)=(u(i)-tri(3,i)*u(i+1))/tri(2,i) 45 end do 46 end program HEAT The nomenclature for the above program is given by: Ø n is the number of spatial points. Ø a, b are the left and right endpoints. Ø ua, ub are the temperature values at the left and right endpoints. Ø k is the name of the function which evaluates K(X); Ø f is the name of the function, which evaluates the right hand side F(X). Ø x is the X coordinates of nodes (output); Ø u is the computed value of the temperature at the nodes. 4 different boundary conditions are taken for the above program to simulate different results: 1. Test 1: uses K(X) = 1, F(X) = 0, so the solution should be the straight line that connects the boundary values. 2. Test 2: uses K(X) which is set to different constants over three sub regions, and F(X) = 0, so the solution will be a piecewise linear function that connects the boundary values. 3. Test 3: uses K(X) = 1, F(X) defines a heat source, so the solution can rise above the boundary values. 4. Test 4: uses K(X) = 1, F(X) defines a heat source and a heat sink, so the solution can go above and below the boundary values.
  • 9. 9 PROGRAM 3 A simple, Fortran95 program for a 2D, steady state (time-independent) heat equation in a 2D rectangular region. This diagram suggests the physical regions, and the boundary conditions: The region is covered with a grid of NX by NY nodes, and an NX by NY array T is used to record the temperature. The correspondence between array indices and locations in the region is suggested by giving the indices of the four corners. The form of the steady heat equation is: − 𝑑 𝑑𝑥 𝐾 𝑥, 𝑦 𝑑𝑇 𝑑𝑥 − 𝑑 𝑑𝑦 𝐾 𝑥, 𝑦 𝑑𝑇 𝑑𝑦 = 𝐹(𝑥, 𝑦) The following assumptions are considered for the following problem: 1. 𝐹 𝑥, 𝑦 = 0 (No heat generation) 2. Thermal conductivity of the material does not vary along x or y axis 3. 𝐾 𝑥, 𝑦 = 𝐾 (Isotropic) 𝜕! 𝑇 𝜕𝑥! + 𝜕! 𝑇 𝜕𝑦! = 0 The above equation is called Laplace equation. To obtain the temperature distribution, we need to solve the above PDE. By using a simple finite difference approximation, this single equation can be replaced by NX * NY linear equations in NX * NY variables; each equation is associated with one of the nodes in the mesh. Nodes long the boundary generates boundary condition equations, while interior nodes generate equations that approximate the steady heat equation. For simplicity, we consider dx=dy. The linear system is sparse, and can easily be solved directly in FORTRAN95. 𝑇!!!.! + 𝑇!!!.! + 𝑇!.!!! + 𝑇!.!!! − 4 ∗ 𝑇!.! = 0 Here i represent the node location along the x direction and j represents the node location along y direction.
  • 10. 10 FORTRAN CODE FOR PROGRAM 3 1 program HEAT 2 implicit none 3 integer :: i, j, k 4 integer :: m, n 5 integer :: L, H 6 integer :: T1, T2, T3, T4 7 real :: A(5,5), B(5,5), C(5,5) 8 T1=300 9 T2=100 10 T3=50 11 T4=75 12 m=5 13 n=5 14 do 10 j=1,n 15 do 20 i=1,m 16 C(i,j)=0 17 B(i,j)=0 18 IF (j==1) THEN A(i,j)=50 19 else if(j==n) THEN A(i,j)=300 20 else if(i==1) THEN A(i,j)=75 21 else if(i==m) THEN A(i,j)=100 22 else A(i,j)=0 23 END IF 24 20 END DO 25 10 END DO 26 DO 70 k=1,10 27 DO 50 j=2,n-1 28 DO 60 i=2,m-1 29 A(i,j)=(A(i+1,j)+A(i-1,j)+A(i,j+1)+A(i,j-1))*(0.25) 30 C(i,j)=B(i,j)/A(i,j) 31 C(i,j)=1-C(i,j) 32 60 END DO 33 50 END DO 34 do 30 j=1,n 35 do 40 i=1,m 36 write(*,*) i,j, A(i,j),C(i,j) 37 B(i,j)=A(i,J) 38 40 END DO 39 30 END DO 40 70 END DO 41 end program HEAT
  • 13. 13 PROGRAM 4 Consider the one-dimensional, transient (i.e. time-dependent) heat conduction equation without heat generating sources. 𝜌𝑐! 𝜕𝑇 𝜕𝑡 = 𝜕 𝜕𝑥 𝑘 𝜕𝑇 𝜕𝑥 If the thermal conductivity, density and heat capacity are constant over the model domain, the equation can be simplified to: 𝜕𝑇 𝜕𝑡 = 𝑘 𝜌𝑐! 𝜕! 𝑇 𝜕𝑥! = 𝛼 𝜕! 𝑇 𝜕𝑥! We are interested in the temperature evolution versus time, T(x,t), which satisfies the above equation, given an initial temperature distribution. The first step in the finite differences method is to construct a grid with points on which we are interested in solving the equation, called discretization. The next step is to replace the continuous derivatives of the above with their finite difference approximations. First, the explicit forward time, centered space or FTCS approximation method is used in solving the heat equation. 𝑇! !!! − 𝑇! ! ∆𝑡 = 𝛼 𝑇!!! ! − 2𝑇! ! + 𝑇!!! ! ∆𝑥 ! 𝑇! !!! = 𝑇! ! + 𝛼∆𝑡 𝑇!!! ! − 2𝑇! ! + 𝑇!!! ! ∆𝑥 ! Here, n represents the temperature at the current time step whereas n + 1 represents the new (future) temperature. The subscript i refers to the location. Both n and i are integers; n varies from 1 to nt (total number of time steps) and i varies from 1 to nx (total number of grid points in x-direction). Because the temperature at the current time step (n) is known, we can use the equation to compute the new temperature without solving any additional equations. Such a scheme is and explicit finite difference method and was made possible by the choice to evaluate the temporal derivative with forward differences. We know that this numerical scheme will converge to the exact solution for small ∆x and ∆t because it has been shown to be consistent – that its discretization process can be reversed, through a Taylor series expansion, to recover the governing partial differential equation – and because it is stable for certain values of ∆t and ∆x: any spontaneous perturbations in the solution (such as round-off error) will either be bounded or will decay. The last step is to specify the initial and the boundary conditions. 1. Total time=60sec 2. The initial temperature is taken as 0. 3. The temperature at the left and right hand side of the wall is taken as 40°C and 20°C respectively. 4. The number of grids is taken as 10. 5. Length of the domain=0.1 6. Alpha is taken as 0.0001
  • 14. 14 FLOWCHART FOR PROGRAM 4 MATLAB CODE FOR FTCS SCHEME 1 L=0.1 2 alpha=0.0001 3 t_final=60 4 n=10 5 T0=0 6 T1s=40 7 T2s=20 8 dx=L/n 9 dt=0.1 10 x=dx/2:dx:L-dx/2 11 T=ones(n,1)*T0 12 dTdt=zeros(n,1) 13 t=0:dt:t_final 14 for j=1:length(t) 15 for i=2:n-1 16 dTdt(i)=alpha*(T(i+1)+T(i-1)-2*T(i))/dx^2 17 end 18 dTdt(1)=alpha*(T(2)+T1s-2*T(1))/dx^2 19 dTdt(n)=alpha*(T2s+T(n-1)-2*T(n))/dx^2 20 T=T+dTdt*dt 21 figure(1) 22 plot(x,T, 'Linewidth',3) 23 axis([0 L 0 50]) 24 xlabel('Distance (m)') 25 ylabel('Temperature (circC)') 26 pause(0.1) 27 end
  • 15. 15 t=0.1s t=3s t=13s t=40s Figure 7: Output plot for FTCS scheme at various time-step It has been observed from the above results that the initial temperature is at 0°C. After 3s, the surface temperatures of the wall are hotter than 0°C. Hence, the heat flux comes at the beginning at both sides and the temperature starts to rise over the whole wall. It gradually rises until it reaches a steady state. The final temperature distribution is a straight line, which is validated from the analytical results. A 3D plot has been taken by taking the time axis as the third axis and plotting the temperature distribution along the length of the wall. The total time taken to reach the steady state is taken as 80 sec. To get a better view, the temperature on both the surfaces of the wall is taken as 70°C and 90°C.
  • 16. 16 Figure 8: 3D plot of temperature distribution of time-dependent 1D heat equation For the backward time, centered space (BTCS) method, the backward difference is selected to get: 𝑇! ! − 𝑇! !!! ∆𝑡 = 𝛼 𝑇!!! ! − 2𝑇! ! + 𝑇!!! ! ∆𝑥 ! Unlike the FTCS method, the above equation cannot be rearranged to obtain a simple algebraic formula. The equation is an implicit function and is a system of equations for the values of T at the internal nodes of the spatial mesh. To see the set of system of equations more clearly, we rearrange to get the resulting equation as: − 𝛼 ∆𝑥 ! 𝑇!!! ! + 1 Δ𝑡 + 2𝛼 ∆𝑥 ! 𝑇! ! − 𝛼 ∆𝑥 ! 𝑇!!! ! = 𝑇! !!! Δ𝑡 The set of equations can be represented in matrix form A*T=B to get the temperature distribution at the interior nodes. MATLAB CODE FOR BTCS SCHEME 1 nt=10 2 nx=20 3 alpha=0.1 4 L=1 5 Tmax=0.5 6 dx=L/(nx-1); 7 dt=tmax/(nt-1);
  • 17. 17 8 x=linespace(0,L,nx)’; 9 t=linespace(0,tmax,nt); 10 U=zeroes(nx,nt); 11 u0=0; 12 uL=0; 13 a=(-alpha/dx^2)*ones(nx,1); 14 c=a; 15 b=(1/dt)*ones(nx,1)-2*a; 16 b(1)=1; 17 c(1)=0; 18 b(end)=1; 19 a(end)=1; 20 d=U(:,m-1)/dt; 21 d(1)=u0; 22 d(end)=uL; 23 U(:,m)=tridiagLUSolve(d,a,e,f,U(:m,m-1)); 24 end Figure 9: Output plot for BTCS scheme at different time-step
  • 18. 18 PROGRAM 5 A MATLAB program has been written to solve the 2D differential heat equation. The heat equation is given by: 𝜕𝑇 𝜕𝑡 = 𝜅 𝜕! 𝑇 𝜕𝑥! + 𝜕! 𝑇 𝜕𝑦! = 𝜅∇! 𝑇 where 𝜅 is the thermal diffusivity. Now, we discretize this equation using the finite difference method. We take ni points in the X-direction and nj points in the Y-direction. The grid spacing is taken as dx. We take Δx=Δy=h. The explicit method is unstable if the time-step is too large. This means, we get oscillations and the amplitude grows exponentially with time. This depends on the grid spacing. ∆𝑡!"#$#!%& = 𝑎 (∆𝑥)! 𝜅 MATLAB CODE FOR PROGRAM 5 1 clear all; 2 clc; 3 Li=0.1; 4 Lj=0.2; 5 ni=10; 6 nj=Lj/(Li*ni); 7 dx=Li/(ni-1); 8 Th=600; 9 Tc=290; 10 Ta=293; 11 t2=10; 12 t(1)=0; 13 dt=0.01; 14 ks=387; 15 rho=8940; 16 cp=380; 17 alpha=ks/(rho*cp); 18 h=20; 19 T(1:ni+2:nj)=Ta;
  • 19. 19 20 Fo=alpha*dt/(dx.^2); 21 Bi=h*dx/ks; 22 k=1 23 while t<t2 24 for i=2:ni+1 25 for j=1:nj 26 if j==1 27 T(i,j,k+1)=Fo*(2*T(i-1,j,k)+T(i+,j,k)+T(i,j+1,k)+2*Bi*Th)+(1-4*Fo-2*Bi*Fo)*T(i,j,k); 28 else if j>1 && j<nj 29 T(i,j,k+1)=Fo*(T(i+1,j,k)+T(i-1,j,k)+T(i,j+1,k)+T(i,j-1,k))+(1-4*Fo)*T(i,j,k); 30 elseif j==nj 31 T(i,j,k+1)=Fo*(2*T(i-1,j,k)+T(i+1,j,k)+T(i,j-1,k)+2*Bi*Tc)+(1-4*Fo- 2*Bi*Fo)*T(i,j,k); 32 end 33 end 34 end 35 for j = 1:nj 36 T(1,j,k+1)= T(3,j,k) ; 37 T(ni+2,j,k+1)= T(ni,j,k); 38 end 39 t(k+1)= t(k) + dt; 40 k=k + 1; 41 end 42 Temp(1:ni,1:nj)=T(2:ni+1,1:nj,k-1); 43 for i = 1:ni 44 x(i)=dx*(i-1) ; 45 end 46 for j = 1:nj 47 y(j) = dx*(j-1) ; 48 end
  • 20. 20 PROGRAM 6 A MATLAB program for the investigation of the sprinkler response time predictive capability has been written. A heat detector response model is intended to predict the time at which a heat detector is expected to operate given the properties of the detector and the fire environment to which it is exposed. The activation time of the sprinkler is the time at which the temperature of the sprinkler bulb reaches the nominal activation temperature. Convective heat transfer from the flowing gases in the ceiling jet to the sprinkler bulb is the primary heat transfer mechanism. However, for an enclosure where the ceiling jet is immersed in a hot layer, additional heat transfer from the hot layer to the sprinkler occurs. There are also heat conduction losses from the sprinkler head to the attached pipework. The differential equation describing the rate of change of temperature of the sensing element of the sprinkler is given by: 𝑑𝑇! 𝑑𝑥 = 𝑉!(𝑇! − 𝑇!) 𝑅𝑇𝐼 The predicted sprinkler response time is based on a single burning object located within the room of fire origin. MATLAB CODE FOR PROGRAM 6 1 clear all 2 close all 3 clc 4 vel_g=5; 5 RTI=40 ; 6 T_amb=293; 7 T_g=500; 8 T_d_final=400; 9 dt= 0.1 ; 10 t(1) = 0 ; 11 T_d(1) = T_ inf; 12 i=1; 13 while T_d < T_d_final 14 del_T_d= sqrt(vel_g)/RTI*(T_g-T_d(i))*dt ; 15 T_d(i+1) = T_d(i) + del_T_d ; 16 t(i+1)= t(i) + dt ; 17 i = i + 1 ; 18 if i > 50000 19 fprintf('autobreak') 20 break 21 end 22 end 23 figure 24 plot(t,T_d)
  • 22. 22 PROGRAM 7 The advection-diffusion equation describes physical phenomena where particles, energy, or other physical quantities are transferred inside a physical system due to two processes: diffusion and advection. Advection is a transport mechanism of a substance or conserved property by a fluid due to the fluid’s bulk motion. Diffusion is the net movement of molecules or atoms from a region of high concentration to a region of low concentration. The advection-diffusion equation is a relatively simple equation describing flows, or alternatively, describing a stochastically-changing system. The general form of the 1D advection-diffusion is given as: 𝑑𝑈 𝑑𝑡 = 𝜖 𝑑! 𝑈 𝑑𝑥! − 𝑎 𝑑𝑈 𝑑𝑥 + 𝐹 where U is the temperature for this given problem, t is the time, 𝜖 is the diffusion coefficient, a is the average velocity, F describes the “sources” or “sinks” of the quantity U. The four terms represent the transient, diffusion, advection and source or sink term respectively. For the steady state, !" !" = 0. A FORTRAN95 code has been written to numerically approximate the solution of the advection-diffusion equation typically using the finite difference method (FDM). Our problem reduces to: −𝜖 𝑑! 𝑈 𝑑𝑥! + 𝑎 𝑑𝑈 𝑑𝑥 = 0, 0 < 𝑥 < 1 ; 𝑈 0 = 0 ; 𝑈 1 = 0 We discretize the interval [0,1] into NX nodes. We write the boundary conditions at the first and last nodes. At the i-th interior node, we replace derivatives by differences: 𝑑𝑈 𝑑𝑥 = (𝑈 𝑥 + 𝑑𝑥 − 𝑈(𝑥 − 𝑑𝑥)) 2𝑑𝑥 𝑑! 𝑈 𝑑𝑥! = (𝑈 𝑥 + 𝑑𝑥 − 2𝑈 𝑥 + 𝑈 𝑥 − 𝑑𝑥 ) (𝑑𝑥)! This becomes a set of NX linear equations in the NX unknown values of U. The exact solution to this differential equation is known: 𝑈 = (1 − 𝑒!" ) (1 − 𝑒!) 𝑤ℎ𝑒𝑟𝑒 𝑟 = 𝑎 𝜖 The results for the exact analytical solution and the solution obtained from FDM has been compared and plotted in graph. It has been seen that there is an insignificant difference between the two values.
  • 23. 23 FORTRAN CODE FOR PROGRAM 7 1 program Heat 2 implicit none 3 real :: a, b 4 real, allocatable :: a3(:,:) 5 real :: dx 6 real, allocatable :: f(:) 7 integer :: i,j 8 real :: k, r, v 9 integer :: nx 10 real, allocatable :: u(:),w(:),x(:) 11 real :: xm 12 v=1 13 k=0.05 14 nx=101 15 a=0 16 b=1 17 dx=(b-a)/(nx-1) 18 allocate (x(1:nx)) 19 if (nx==1) then 20 x(1)=(a+b)/2 21 else 22 do i=1,nx 23 x(i)=((nx-i)*a+(i-1)*b)/(nx-1) 24 end do 25 end if 26 allocate (a3(1:nx,1:3)) 27 a3(1:nx,1:3)=0 28 allocate (f(1:nx)) 29 f(1:nx)=0 30 a3(1,2)=1 31 f(1)=0 32 do i=2,nx-1 33 a3(i,1)=-v/(2*dx)-k/(dx*dx) 34 a3(i,2)=(2*k)/(dx*dx) 35 a3(i,3)=v/(2*dx)-k/(dx*dx) 36 f(i)=0 37 end do 38 a3(nx,2)=1 39 f(nx)=1 40 allocate (u(1:nx)) 41 do i=1,nx 42 if( a3(i,2)==0) then 43 write(*,*) “error” 44 end if 45 end do 46 u(1:nx)=f(1:nx) 47 do i=2,nx
  • 24. 24 48 xm=a3(i,1)/a3(i-1,2) 49 a3(i,2)=a3(i,2)-xm*a3(i-1,3) 50 u(i)=u(i)-xm*u(i-1) 51 end do 52 u(nx)=u(nx)/a3(nx,2) 53 do i=nx-1,1,-1 54 u(i)=(u(i)-a3(i,3)*u(i+1))/a3(i,2) 55 end do 56 r=v*(b-a)/k 57 allocate(w(1:nx)) 58 w(1:nx)=(1-exp(r*x(1:nx)))/(1-exp(r)) 59 deallocate(a3) 60 deallocate(f) 61 deallocate(u) 62 deallocate(w) 63 deallocate(x) 64 end 65 end program Heat Figure 12: Output plot for Program 7
  • 26. 26 PROGRAM 8 For the 1D, time dependent advection diffusion a MATLAB program has been written to solve the equation by using the First-order Upwind (FOU) scheme. The equation is given as: 𝑑𝑈 𝑑𝑡 = −𝑣 𝑑𝑈 𝑑𝑥 The exact values have also been plotted in the same program with a red curve. MATLAB CODE FOR PROGRAM 8 1 clear 2 clc 3 xmin=0; 4 xmax=1; 5 N=100; 6 dt=0.009; 7 t=0; 8 tmax=0.5; 9 v=1; 10 dx=(xmax-xmin)/N; 11 u0=exp(-200*(x-0.25).^2); 12 u=u0; 13 unp1=u0; 14 nsteps=tmax/dt; 15 for n=1:nsteps 16 u(1)=u(3); 17 u(N+3)=u(N+1); 18 for i=2:N+2 19 unp1(i)=u(i)-v*dt/dx*(u(i)-u(i-1)); 20 end 21 t=t+dt; 22 u=unp1; 23 exact=exp(-200*(x-0.25-v*t).^2); 24 plot(x,exact,’r-‘,); 25 hold on 26 plot(x,u,’bo-‘,’markerfacecolor’,’b’); 27 hold off 28 axis([xmin xmax -0.5 1.5]) 29 xlabel(‘x’,’fontsize’,16) 30 ylabel(‘U(t,x)’,’fontsize’,16) 31 title(sprint(‘time=%1.3f’,t),’fontsize’,16) 32 shg 33 pause(dt); 34 end
  • 27. 27 Nomenclature for the above program is: Ø xmin is the minimum value of x Ø xmax is the maximum value of x Ø N is the number of nodes minus one Ø dt is the timestep Ø t is the time in seconds Ø tmax is the maximum value of t Ø v is the velocity t=0.009s t=0.162s t=0.252s t=0.495s Figure 14: Output screen for the advection diffusion equation at different time-steps